1 /* 2 * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef RTC_BASE_EXPERIMENTS_QUALITY_RAMPUP_EXPERIMENT_H_ 12 #define RTC_BASE_EXPERIMENTS_QUALITY_RAMPUP_EXPERIMENT_H_ 13 14 #include "absl/types/optional.h" 15 #include "api/transport/webrtc_key_value_config.h" 16 #include "rtc_base/experiments/field_trial_parser.h" 17 18 namespace webrtc { 19 20 class QualityRampupExperiment final { 21 public: 22 static QualityRampupExperiment ParseSettings(); 23 24 absl::optional<int> MinPixels() const; 25 absl::optional<int> MinDurationMs() const; 26 absl::optional<double> MaxBitrateFactor() const; 27 28 // Sets the max bitrate and the frame size. 29 // The call has no effect if the frame size is less than |min_pixels_|. 30 void SetMaxBitrate(int pixels, uint32_t max_bitrate_kbps); 31 32 // Returns true if the available bandwidth is a certain percentage 33 // (max_bitrate_factor_) above |max_bitrate_kbps_| for |min_duration_ms_|. 34 bool BwHigh(int64_t now_ms, uint32_t available_bw_kbps); 35 36 bool Enabled() const; 37 38 private: 39 explicit QualityRampupExperiment( 40 const WebRtcKeyValueConfig* const key_value_config); 41 42 FieldTrialOptional<int> min_pixels_; 43 FieldTrialOptional<int> min_duration_ms_; 44 FieldTrialOptional<double> max_bitrate_factor_; 45 46 absl::optional<int64_t> start_ms_; 47 absl::optional<uint32_t> max_bitrate_kbps_; 48 }; 49 50 } // namespace webrtc 51 52 #endif // RTC_BASE_EXPERIMENTS_QUALITY_RAMPUP_EXPERIMENT_H_ 53