blob: 01cdae63646dc17aad6927848a5f919b82fd6e4f [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"
Rasmus Brandtc402dbe2019-02-04 11:09:46 +010016#include "api/video_codecs/video_codec.h"
17#include "api/video_codecs/video_encoder_config.h"
Sebastian Jansson0ee80082019-08-14 13:16:26 +020018#include "rtc_base/experiments/struct_parameters_parser.h"
Erik Språng71215642019-01-21 16:30:55 +010019
20namespace webrtc {
21
Sebastian Jansson0ee80082019-08-14 13:16:26 +020022struct 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
30struct 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;
Rasmus Brandt2b9317a2019-10-30 13:01:46 +010045 bool vp8_base_heavy_tl3_alloc = false;
Sebastian Jansson0ee80082019-08-14 13:16:26 +020046 bool vp8_dynamic_rate = false;
47 bool vp9_dynamic_rate = false;
48
49 std::unique_ptr<StructParametersParser> Parser();
50};
51
Erik Språng71215642019-01-21 16:30:55 +010052class RateControlSettings final {
53 public:
54 ~RateControlSettings();
55 RateControlSettings(RateControlSettings&&);
56
57 static RateControlSettings ParseFromFieldTrials();
58 static RateControlSettings ParseFromKeyValueConfig(
59 const WebRtcKeyValueConfig* const key_value_config);
60
61 // When CongestionWindowPushback is enabled, the pacer is oblivious to
62 // the congestion window. The relation between outstanding data and
63 // the congestion window affects encoder allocations directly.
64 bool UseCongestionWindow() const;
65 int64_t GetCongestionWindowAdditionalTimeMs() const;
66 bool UseCongestionWindowPushback() const;
67 uint32_t CongestionWindowMinPushbackTargetBitrateBps() const;
68
Erik Språngcd76eab2019-01-21 18:06:46 +010069 absl::optional<double> GetPacingFactor() const;
70 bool UseAlrProbing() const;
71
Åsa Perssond7dd49f2019-05-08 14:44:12 +020072 absl::optional<int> LibvpxVp8QpMax() const;
Åsa Perssona0948492019-06-27 13:44:30 +020073 absl::optional<int> LibvpxVp8MinPixels() const;
Erik Språng4b4266f2019-01-23 12:48:13 +010074 bool LibvpxVp8TrustedRateController() const;
Erik Språng7f24fb92019-02-13 10:49:37 +010075 bool Vp8BoostBaseLayerQuality() const;
Erik Språng7a3fe892019-04-15 12:22:55 +020076 bool Vp8DynamicRateSettings() const;
Erik Språng4b4266f2019-01-23 12:48:13 +010077 bool LibvpxVp9TrustedRateController() const;
Erik Språng7a3fe892019-04-15 12:22:55 +020078 bool Vp9DynamicRateSettings() const;
Erik Språng4b4266f2019-01-23 12:48:13 +010079
Rasmus Brandtc402dbe2019-02-04 11:09:46 +010080 // TODO(bugs.webrtc.org/10272): Remove one of these when we have merged
81 // VideoCodecMode and VideoEncoderConfig::ContentType.
82 double GetSimulcastHysteresisFactor(VideoCodecMode mode) const;
83 double GetSimulcastHysteresisFactor(
84 VideoEncoderConfig::ContentType content_type) const;
Erik Språng2c58ba12019-01-23 16:53:18 +010085
Rasmus Brandt2b9317a2019-10-30 13:01:46 +010086 bool Vp8BaseHeavyTl3RateAllocation() const;
87
Erik Språng5118bbc2019-01-29 18:28:06 +010088 bool TriggerProbeOnMaxAllocatedBitrateChange() const;
Erik Språng7ca375c2019-02-06 16:20:17 +010089 bool UseEncoderBitrateAdjuster() const;
Erik Språng3d11e2f2019-04-15 14:48:30 +020090 bool BitrateAdjusterCanUseNetworkHeadroom() const;
Erik Språng5118bbc2019-01-29 18:28:06 +010091
Erik Språng71215642019-01-21 16:30:55 +010092 private:
93 explicit RateControlSettings(
94 const WebRtcKeyValueConfig* const key_value_config);
95
Sebastian Jansson0ee80082019-08-14 13:16:26 +020096 const CongestionWindowConfig congestion_window_config_;
97 VideoRateControlConfig video_config_;
Erik Språng71215642019-01-21 16:30:55 +010098};
99
100} // namespace webrtc
101
102#endif // RTC_BASE_EXPERIMENTS_RATE_CONTROL_SETTINGS_H_