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_RATE_CONTROL_SETTINGS_H_ 12 #define RTC_BASE_EXPERIMENTS_RATE_CONTROL_SETTINGS_H_ 13 14 #include "absl/types/optional.h" 15 #include "api/field_trials_view.h" 16 #include "api/units/data_size.h" 17 #include "api/video_codecs/video_codec.h" 18 #include "rtc_base/experiments/struct_parameters_parser.h" 19 #include "video/config/video_encoder_config.h" 20 21 namespace webrtc { 22 23 struct CongestionWindowConfig { 24 static constexpr char kKey[] = "WebRTC-CongestionWindow"; 25 absl::optional<int> queue_size_ms; 26 absl::optional<int> min_bitrate_bps; 27 absl::optional<DataSize> initial_data_window; 28 bool drop_frame_only = false; 29 std::unique_ptr<StructParametersParser> Parser(); 30 static CongestionWindowConfig Parse(absl::string_view config); 31 }; 32 33 struct VideoRateControlConfig { 34 static constexpr char kKey[] = "WebRTC-VideoRateControl"; 35 absl::optional<double> pacing_factor; 36 bool alr_probing = false; 37 absl::optional<int> vp8_qp_max; 38 absl::optional<int> vp8_min_pixels; 39 bool trust_vp8 = true; 40 bool trust_vp9 = true; 41 bool bitrate_adjuster = true; 42 bool adjuster_use_headroom = true; 43 bool vp8_s0_boost = false; 44 bool vp8_base_heavy_tl3_alloc = false; 45 46 std::unique_ptr<StructParametersParser> Parser(); 47 }; 48 49 class RateControlSettings final { 50 public: 51 ~RateControlSettings(); 52 RateControlSettings(RateControlSettings&&); 53 54 static RateControlSettings ParseFromFieldTrials(); 55 static RateControlSettings ParseFromKeyValueConfig( 56 const FieldTrialsView* const key_value_config); 57 58 // When CongestionWindowPushback is enabled, the pacer is oblivious to 59 // the congestion window. The relation between outstanding data and 60 // the congestion window affects encoder allocations directly. 61 bool UseCongestionWindow() const; 62 int64_t GetCongestionWindowAdditionalTimeMs() const; 63 bool UseCongestionWindowPushback() const; 64 bool UseCongestionWindowDropFrameOnly() const; 65 uint32_t CongestionWindowMinPushbackTargetBitrateBps() const; 66 absl::optional<DataSize> CongestionWindowInitialDataWindow() const; 67 68 absl::optional<double> GetPacingFactor() const; 69 bool UseAlrProbing() const; 70 71 absl::optional<int> LibvpxVp8QpMax() const; 72 absl::optional<int> LibvpxVp8MinPixels() const; 73 bool LibvpxVp8TrustedRateController() const; 74 bool Vp8BoostBaseLayerQuality() const; 75 bool Vp8DynamicRateSettings() const; 76 bool LibvpxVp9TrustedRateController() const; 77 bool Vp9DynamicRateSettings() const; 78 79 bool Vp8BaseHeavyTl3RateAllocation() const; 80 81 bool UseEncoderBitrateAdjuster() const; 82 bool BitrateAdjusterCanUseNetworkHeadroom() const; 83 84 private: 85 explicit RateControlSettings(const FieldTrialsView* const key_value_config); 86 87 CongestionWindowConfig congestion_window_config_; 88 VideoRateControlConfig video_config_; 89 }; 90 91 } // namespace webrtc 92 93 #endif // RTC_BASE_EXPERIMENTS_RATE_CONTROL_SETTINGS_H_ 94