blob: db7f1cd136b9dfaa799b5c18ab02a72f62f28312 [file] [log] [blame]
Erik Språng71215642019-01-21 16:30:55 +01001/*
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"
Christoffer Rodbro034f7672019-12-06 13:13:40 +010016#include "api/units/data_size.h"
Rasmus Brandtc402dbe2019-02-04 11:09:46 +010017#include "api/video_codecs/video_codec.h"
18#include "api/video_codecs/video_encoder_config.h"
Sebastian Jansson0ee80082019-08-14 13:16:26 +020019#include "rtc_base/experiments/struct_parameters_parser.h"
Erik Språng71215642019-01-21 16:30:55 +010020
21namespace webrtc {
22
Sebastian Jansson0ee80082019-08-14 13:16:26 +020023struct CongestionWindowConfig {
24 static constexpr char kKey[] = "WebRTC-CongestionWindow";
25 absl::optional<int> queue_size_ms;
26 absl::optional<int> min_bitrate_bps;
Christoffer Rodbro034f7672019-12-06 13:13:40 +010027 absl::optional<DataSize> initial_data_window;
Ying Wang9b881ab2020-02-07 14:29:32 +010028 bool drop_frame_only = false;
Sebastian Jansson0ee80082019-08-14 13:16:26 +020029 std::unique_ptr<StructParametersParser> Parser();
30 static CongestionWindowConfig Parse(absl::string_view config);
31};
32
33struct 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ång9d69cbe2020-10-22 17:44:42 +020039 bool trust_vp8 = true;
40 bool trust_vp9 = true;
41 double video_hysteresis = 1.2;
Sebastian Jansson0ee80082019-08-14 13:16:26 +020042 // Default to 35% hysteresis for simulcast screenshare.
43 double screenshare_hysteresis = 1.35;
44 bool probe_max_allocation = true;
Erik Språng9d69cbe2020-10-22 17:44:42 +020045 bool bitrate_adjuster = true;
46 bool adjuster_use_headroom = true;
47 bool vp8_s0_boost = false;
Rasmus Brandt2b9317a2019-10-30 13:01:46 +010048 bool vp8_base_heavy_tl3_alloc = false;
Sebastian Jansson0ee80082019-08-14 13:16:26 +020049
50 std::unique_ptr<StructParametersParser> Parser();
51};
52
Erik Språng71215642019-01-21 16:30:55 +010053class RateControlSettings final {
54 public:
55 ~RateControlSettings();
56 RateControlSettings(RateControlSettings&&);
57
58 static RateControlSettings ParseFromFieldTrials();
59 static RateControlSettings ParseFromKeyValueConfig(
60 const WebRtcKeyValueConfig* const key_value_config);
61
62 // When CongestionWindowPushback is enabled, the pacer is oblivious to
63 // the congestion window. The relation between outstanding data and
64 // the congestion window affects encoder allocations directly.
65 bool UseCongestionWindow() const;
66 int64_t GetCongestionWindowAdditionalTimeMs() const;
67 bool UseCongestionWindowPushback() const;
Ying Wang9b881ab2020-02-07 14:29:32 +010068 bool UseCongestionWindowDropFrameOnly() const;
Erik Språng71215642019-01-21 16:30:55 +010069 uint32_t CongestionWindowMinPushbackTargetBitrateBps() const;
Christoffer Rodbro034f7672019-12-06 13:13:40 +010070 absl::optional<DataSize> CongestionWindowInitialDataWindow() const;
Erik Språng71215642019-01-21 16:30:55 +010071
Erik Språngcd76eab2019-01-21 18:06:46 +010072 absl::optional<double> GetPacingFactor() const;
73 bool UseAlrProbing() const;
74
Åsa Perssond7dd49f2019-05-08 14:44:12 +020075 absl::optional<int> LibvpxVp8QpMax() const;
Åsa Perssona0948492019-06-27 13:44:30 +020076 absl::optional<int> LibvpxVp8MinPixels() const;
Erik Språng4b4266f2019-01-23 12:48:13 +010077 bool LibvpxVp8TrustedRateController() const;
Erik Språng7f24fb92019-02-13 10:49:37 +010078 bool Vp8BoostBaseLayerQuality() const;
Erik Språng7a3fe892019-04-15 12:22:55 +020079 bool Vp8DynamicRateSettings() const;
Erik Språng4b4266f2019-01-23 12:48:13 +010080 bool LibvpxVp9TrustedRateController() const;
Erik Språng7a3fe892019-04-15 12:22:55 +020081 bool Vp9DynamicRateSettings() const;
Erik Språng4b4266f2019-01-23 12:48:13 +010082
Rasmus Brandtc402dbe2019-02-04 11:09:46 +010083 // TODO(bugs.webrtc.org/10272): Remove one of these when we have merged
84 // VideoCodecMode and VideoEncoderConfig::ContentType.
85 double GetSimulcastHysteresisFactor(VideoCodecMode mode) const;
86 double GetSimulcastHysteresisFactor(
87 VideoEncoderConfig::ContentType content_type) const;
Erik Språng2c58ba12019-01-23 16:53:18 +010088
Rasmus Brandt2b9317a2019-10-30 13:01:46 +010089 bool Vp8BaseHeavyTl3RateAllocation() const;
90
Erik Språng5118bbc2019-01-29 18:28:06 +010091 bool TriggerProbeOnMaxAllocatedBitrateChange() const;
Erik Språng7ca375c2019-02-06 16:20:17 +010092 bool UseEncoderBitrateAdjuster() const;
Erik Språng3d11e2f2019-04-15 14:48:30 +020093 bool BitrateAdjusterCanUseNetworkHeadroom() const;
Erik Språng5118bbc2019-01-29 18:28:06 +010094
Erik Språng71215642019-01-21 16:30:55 +010095 private:
96 explicit RateControlSettings(
97 const WebRtcKeyValueConfig* const key_value_config);
98
Sebastian Jansson0ee80082019-08-14 13:16:26 +020099 const CongestionWindowConfig congestion_window_config_;
100 VideoRateControlConfig video_config_;
Erik Språng71215642019-01-21 16:30:55 +0100101};
102
103} // namespace webrtc
104
105#endif // RTC_BASE_EXPERIMENTS_RATE_CONTROL_SETTINGS_H_