Erik Språng | 7121564 | 2019-01-21 16:30:55 +0100 | [diff] [blame] | 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/transport/webrtc_key_value_config.h" |
Rasmus Brandt | c402dbe | 2019-02-04 11:09:46 +0100 | [diff] [blame] | 16 | #include "api/video_codecs/video_codec.h" |
| 17 | #include "api/video_codecs/video_encoder_config.h" |
Sebastian Jansson | 0ee8008 | 2019-08-14 13:16:26 +0200 | [diff] [blame^] | 18 | #include "rtc_base/experiments/struct_parameters_parser.h" |
Erik Språng | 7121564 | 2019-01-21 16:30:55 +0100 | [diff] [blame] | 19 | |
| 20 | namespace webrtc { |
| 21 | |
Sebastian Jansson | 0ee8008 | 2019-08-14 13:16:26 +0200 | [diff] [blame^] | 22 | struct CongestionWindowConfig { |
| 23 | static constexpr char kKey[] = "WebRTC-CongestionWindow"; |
| 24 | absl::optional<int> queue_size_ms; |
| 25 | absl::optional<int> min_bitrate_bps; |
| 26 | std::unique_ptr<StructParametersParser> Parser(); |
| 27 | static CongestionWindowConfig Parse(absl::string_view config); |
| 28 | }; |
| 29 | |
| 30 | struct VideoRateControlConfig { |
| 31 | static constexpr char kKey[] = "WebRTC-VideoRateControl"; |
| 32 | absl::optional<double> pacing_factor; |
| 33 | bool alr_probing = false; |
| 34 | absl::optional<int> vp8_qp_max; |
| 35 | absl::optional<int> vp8_min_pixels; |
| 36 | bool trust_vp8 = false; |
| 37 | bool trust_vp9 = false; |
| 38 | double video_hysteresis = 1.0; |
| 39 | // Default to 35% hysteresis for simulcast screenshare. |
| 40 | double screenshare_hysteresis = 1.35; |
| 41 | bool probe_max_allocation = true; |
| 42 | bool bitrate_adjuster = false; |
| 43 | bool adjuster_use_headroom = false; |
| 44 | bool vp8_s0_boost = true; |
| 45 | bool vp8_dynamic_rate = false; |
| 46 | bool vp9_dynamic_rate = false; |
| 47 | |
| 48 | std::unique_ptr<StructParametersParser> Parser(); |
| 49 | }; |
| 50 | |
Erik Språng | 7121564 | 2019-01-21 16:30:55 +0100 | [diff] [blame] | 51 | class RateControlSettings final { |
| 52 | public: |
| 53 | ~RateControlSettings(); |
| 54 | RateControlSettings(RateControlSettings&&); |
| 55 | |
| 56 | static RateControlSettings ParseFromFieldTrials(); |
| 57 | static RateControlSettings ParseFromKeyValueConfig( |
| 58 | const WebRtcKeyValueConfig* const key_value_config); |
| 59 | |
| 60 | // When CongestionWindowPushback is enabled, the pacer is oblivious to |
| 61 | // the congestion window. The relation between outstanding data and |
| 62 | // the congestion window affects encoder allocations directly. |
| 63 | bool UseCongestionWindow() const; |
| 64 | int64_t GetCongestionWindowAdditionalTimeMs() const; |
| 65 | bool UseCongestionWindowPushback() const; |
| 66 | uint32_t CongestionWindowMinPushbackTargetBitrateBps() const; |
| 67 | |
Erik Språng | cd76eab | 2019-01-21 18:06:46 +0100 | [diff] [blame] | 68 | absl::optional<double> GetPacingFactor() const; |
| 69 | bool UseAlrProbing() const; |
| 70 | |
Åsa Persson | d7dd49f | 2019-05-08 14:44:12 +0200 | [diff] [blame] | 71 | absl::optional<int> LibvpxVp8QpMax() const; |
Åsa Persson | a094849 | 2019-06-27 13:44:30 +0200 | [diff] [blame] | 72 | absl::optional<int> LibvpxVp8MinPixels() const; |
Erik Språng | 4b4266f | 2019-01-23 12:48:13 +0100 | [diff] [blame] | 73 | bool LibvpxVp8TrustedRateController() const; |
Erik Språng | 7f24fb9 | 2019-02-13 10:49:37 +0100 | [diff] [blame] | 74 | bool Vp8BoostBaseLayerQuality() const; |
Erik Språng | 7a3fe89 | 2019-04-15 12:22:55 +0200 | [diff] [blame] | 75 | bool Vp8DynamicRateSettings() const; |
Erik Språng | 4b4266f | 2019-01-23 12:48:13 +0100 | [diff] [blame] | 76 | bool LibvpxVp9TrustedRateController() const; |
Erik Språng | 7a3fe89 | 2019-04-15 12:22:55 +0200 | [diff] [blame] | 77 | bool Vp9DynamicRateSettings() const; |
Erik Språng | 4b4266f | 2019-01-23 12:48:13 +0100 | [diff] [blame] | 78 | |
Rasmus Brandt | c402dbe | 2019-02-04 11:09:46 +0100 | [diff] [blame] | 79 | // TODO(bugs.webrtc.org/10272): Remove one of these when we have merged |
| 80 | // VideoCodecMode and VideoEncoderConfig::ContentType. |
| 81 | double GetSimulcastHysteresisFactor(VideoCodecMode mode) const; |
| 82 | double GetSimulcastHysteresisFactor( |
| 83 | VideoEncoderConfig::ContentType content_type) const; |
Erik Språng | 2c58ba1 | 2019-01-23 16:53:18 +0100 | [diff] [blame] | 84 | |
Erik Språng | 5118bbc | 2019-01-29 18:28:06 +0100 | [diff] [blame] | 85 | bool TriggerProbeOnMaxAllocatedBitrateChange() const; |
Erik Språng | 7ca375c | 2019-02-06 16:20:17 +0100 | [diff] [blame] | 86 | bool UseEncoderBitrateAdjuster() const; |
Erik Språng | 3d11e2f | 2019-04-15 14:48:30 +0200 | [diff] [blame] | 87 | bool BitrateAdjusterCanUseNetworkHeadroom() const; |
Erik Språng | 5118bbc | 2019-01-29 18:28:06 +0100 | [diff] [blame] | 88 | |
Erik Språng | 7121564 | 2019-01-21 16:30:55 +0100 | [diff] [blame] | 89 | private: |
| 90 | explicit RateControlSettings( |
| 91 | const WebRtcKeyValueConfig* const key_value_config); |
| 92 | |
Sebastian Jansson | 0ee8008 | 2019-08-14 13:16:26 +0200 | [diff] [blame^] | 93 | const CongestionWindowConfig congestion_window_config_; |
| 94 | VideoRateControlConfig video_config_; |
Erik Språng | 7121564 | 2019-01-21 16:30:55 +0100 | [diff] [blame] | 95 | }; |
| 96 | |
| 97 | } // namespace webrtc |
| 98 | |
| 99 | #endif // RTC_BASE_EXPERIMENTS_RATE_CONTROL_SETTINGS_H_ |