Erik Språng | 7121564 | 2019-01-21 15:30:55 | [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" |
Jonas Oreland | e62c2f2 | 2022-03-29 09:04:48 | [diff] [blame] | 15 | #include "api/field_trials_view.h" |
Christoffer Rodbro | 034f767 | 2019-12-06 12:13:40 | [diff] [blame] | 16 | #include "api/units/data_size.h" |
Rasmus Brandt | c402dbe | 2019-02-04 10:09:46 | [diff] [blame] | 17 | #include "api/video_codecs/video_codec.h" |
Sebastian Jansson | 0ee8008 | 2019-08-14 11:16:26 | [diff] [blame] | 18 | #include "rtc_base/experiments/struct_parameters_parser.h" |
Jonas Oreland | 6c2dae2 | 2022-09-29 08:28:24 | [diff] [blame] | 19 | #include "video/config/video_encoder_config.h" |
Erik Språng | 7121564 | 2019-01-21 15:30:55 | [diff] [blame] | 20 | |
| 21 | namespace webrtc { |
| 22 | |
Sebastian Jansson | 0ee8008 | 2019-08-14 11:16:26 | [diff] [blame] | 23 | struct CongestionWindowConfig { |
| 24 | static constexpr char kKey[] = "WebRTC-CongestionWindow"; |
| 25 | absl::optional<int> queue_size_ms; |
| 26 | absl::optional<int> min_bitrate_bps; |
Christoffer Rodbro | 034f767 | 2019-12-06 12:13:40 | [diff] [blame] | 27 | absl::optional<DataSize> initial_data_window; |
Ying Wang | 9b881ab | 2020-02-07 13:29:32 | [diff] [blame] | 28 | bool drop_frame_only = false; |
Sebastian Jansson | 0ee8008 | 2019-08-14 11:16:26 | [diff] [blame] | 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; |
Erik Språng | 9d69cbe | 2020-10-22 15:44:42 | [diff] [blame] | 39 | bool trust_vp8 = true; |
| 40 | bool trust_vp9 = true; |
Erik Språng | 9d69cbe | 2020-10-22 15:44:42 | [diff] [blame] | 41 | bool bitrate_adjuster = true; |
| 42 | bool adjuster_use_headroom = true; |
| 43 | bool vp8_s0_boost = false; |
Rasmus Brandt | 2b9317a | 2019-10-30 12:01:46 | [diff] [blame] | 44 | bool vp8_base_heavy_tl3_alloc = false; |
Sebastian Jansson | 0ee8008 | 2019-08-14 11:16:26 | [diff] [blame] | 45 | |
| 46 | std::unique_ptr<StructParametersParser> Parser(); |
| 47 | }; |
| 48 | |
Erik Språng | 7121564 | 2019-01-21 15:30:55 | [diff] [blame] | 49 | class RateControlSettings final { |
| 50 | public: |
Danil Chapovalov | ac42626 | 2024-05-06 10:03:53 | [diff] [blame] | 51 | explicit RateControlSettings(const FieldTrialsView& key_value_config); |
Erik Språng | 7121564 | 2019-01-21 15:30:55 | [diff] [blame] | 52 | RateControlSettings(RateControlSettings&&); |
Danil Chapovalov | ac42626 | 2024-05-06 10:03:53 | [diff] [blame] | 53 | ~RateControlSettings(); |
Erik Språng | 7121564 | 2019-01-21 15:30:55 | [diff] [blame] | 54 | |
Erik Språng | 7121564 | 2019-01-21 15:30:55 | [diff] [blame] | 55 | // When CongestionWindowPushback is enabled, the pacer is oblivious to |
| 56 | // the congestion window. The relation between outstanding data and |
| 57 | // the congestion window affects encoder allocations directly. |
| 58 | bool UseCongestionWindow() const; |
| 59 | int64_t GetCongestionWindowAdditionalTimeMs() const; |
| 60 | bool UseCongestionWindowPushback() const; |
Ying Wang | 9b881ab | 2020-02-07 13:29:32 | [diff] [blame] | 61 | bool UseCongestionWindowDropFrameOnly() const; |
Erik Språng | 7121564 | 2019-01-21 15:30:55 | [diff] [blame] | 62 | uint32_t CongestionWindowMinPushbackTargetBitrateBps() const; |
Christoffer Rodbro | 034f767 | 2019-12-06 12:13:40 | [diff] [blame] | 63 | absl::optional<DataSize> CongestionWindowInitialDataWindow() const; |
Erik Språng | 7121564 | 2019-01-21 15:30:55 | [diff] [blame] | 64 | |
Erik Språng | cd76eab | 2019-01-21 17:06:46 | [diff] [blame] | 65 | absl::optional<double> GetPacingFactor() const; |
| 66 | bool UseAlrProbing() const; |
| 67 | |
Åsa Persson | d7dd49f | 2019-05-08 12:44:12 | [diff] [blame] | 68 | absl::optional<int> LibvpxVp8QpMax() const; |
Åsa Persson | a094849 | 2019-06-27 11:44:30 | [diff] [blame] | 69 | absl::optional<int> LibvpxVp8MinPixels() const; |
Erik Språng | 4b4266f | 2019-01-23 11:48:13 | [diff] [blame] | 70 | bool LibvpxVp8TrustedRateController() const; |
Erik Språng | 7f24fb9 | 2019-02-13 09:49:37 | [diff] [blame] | 71 | bool Vp8BoostBaseLayerQuality() const; |
Erik Språng | 7a3fe89 | 2019-04-15 10:22:55 | [diff] [blame] | 72 | bool Vp8DynamicRateSettings() const; |
Erik Språng | 4b4266f | 2019-01-23 11:48:13 | [diff] [blame] | 73 | bool LibvpxVp9TrustedRateController() const; |
Erik Språng | 7a3fe89 | 2019-04-15 10:22:55 | [diff] [blame] | 74 | bool Vp9DynamicRateSettings() const; |
Erik Språng | 4b4266f | 2019-01-23 11:48:13 | [diff] [blame] | 75 | |
Rasmus Brandt | 2b9317a | 2019-10-30 12:01:46 | [diff] [blame] | 76 | bool Vp8BaseHeavyTl3RateAllocation() const; |
| 77 | |
Erik Språng | 7ca375c | 2019-02-06 15:20:17 | [diff] [blame] | 78 | bool UseEncoderBitrateAdjuster() const; |
Erik Språng | 3d11e2f | 2019-04-15 12:48:30 | [diff] [blame] | 79 | bool BitrateAdjusterCanUseNetworkHeadroom() const; |
Erik Språng | 5118bbc | 2019-01-29 17:28:06 | [diff] [blame] | 80 | |
Erik Språng | 7121564 | 2019-01-21 15:30:55 | [diff] [blame] | 81 | private: |
Ying Wang | 4593047 | 2021-02-05 10:07:00 | [diff] [blame] | 82 | CongestionWindowConfig congestion_window_config_; |
Sebastian Jansson | 0ee8008 | 2019-08-14 11:16:26 | [diff] [blame] | 83 | VideoRateControlConfig video_config_; |
Erik Språng | 7121564 | 2019-01-21 15:30:55 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | } // namespace webrtc |
| 87 | |
| 88 | #endif // RTC_BASE_EXPERIMENTS_RATE_CONTROL_SETTINGS_H_ |