blob: 0781205dc4e168278bd12f15fd1edbaf5534af0f [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;
45 bool vp8_dynamic_rate = false;
46 bool vp9_dynamic_rate = false;
47
48 std::unique_ptr<StructParametersParser> Parser();
49};
50
Erik Språng71215642019-01-21 16:30:55 +010051class 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ångcd76eab2019-01-21 18:06:46 +010068 absl::optional<double> GetPacingFactor() const;
69 bool UseAlrProbing() const;
70
Åsa Perssond7dd49f2019-05-08 14:44:12 +020071 absl::optional<int> LibvpxVp8QpMax() const;
Åsa Perssona0948492019-06-27 13:44:30 +020072 absl::optional<int> LibvpxVp8MinPixels() const;
Erik Språng4b4266f2019-01-23 12:48:13 +010073 bool LibvpxVp8TrustedRateController() const;
Erik Språng7f24fb92019-02-13 10:49:37 +010074 bool Vp8BoostBaseLayerQuality() const;
Erik Språng7a3fe892019-04-15 12:22:55 +020075 bool Vp8DynamicRateSettings() const;
Erik Språng4b4266f2019-01-23 12:48:13 +010076 bool LibvpxVp9TrustedRateController() const;
Erik Språng7a3fe892019-04-15 12:22:55 +020077 bool Vp9DynamicRateSettings() const;
Erik Språng4b4266f2019-01-23 12:48:13 +010078
Rasmus Brandtc402dbe2019-02-04 11:09:46 +010079 // 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ång2c58ba12019-01-23 16:53:18 +010084
Erik Språng5118bbc2019-01-29 18:28:06 +010085 bool TriggerProbeOnMaxAllocatedBitrateChange() const;
Erik Språng7ca375c2019-02-06 16:20:17 +010086 bool UseEncoderBitrateAdjuster() const;
Erik Språng3d11e2f2019-04-15 14:48:30 +020087 bool BitrateAdjusterCanUseNetworkHeadroom() const;
Erik Språng5118bbc2019-01-29 18:28:06 +010088
Erik Språng71215642019-01-21 16:30:55 +010089 private:
90 explicit RateControlSettings(
91 const WebRtcKeyValueConfig* const key_value_config);
92
Sebastian Jansson0ee80082019-08-14 13:16:26 +020093 const CongestionWindowConfig congestion_window_config_;
94 VideoRateControlConfig video_config_;
Erik Språng71215642019-01-21 16:30:55 +010095};
96
97} // namespace webrtc
98
99#endif // RTC_BASE_EXPERIMENTS_RATE_CONTROL_SETTINGS_H_