• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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"
16 #include "api/units/data_size.h"
17 #include "api/video_codecs/video_codec.h"
18 #include "api/video_codecs/video_encoder_config.h"
19 #include "rtc_base/experiments/struct_parameters_parser.h"
20 
21 namespace webrtc {
22 
23 struct CongestionWindowConfig {
24   static constexpr char kKey[] = "WebRTC-CongestionWindow";
25   absl::optional<int> queue_size_ms;
26   absl::optional<int> min_bitrate_bps;
27   absl::optional<DataSize> initial_data_window;
28   bool drop_frame_only = false;
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;
39   bool trust_vp8 = false;
40   bool trust_vp9 = false;
41   double video_hysteresis = 1.0;
42   // Default to 35% hysteresis for simulcast screenshare.
43   double screenshare_hysteresis = 1.35;
44   bool probe_max_allocation = true;
45   bool bitrate_adjuster = false;
46   bool adjuster_use_headroom = false;
47   bool vp8_s0_boost = true;
48   bool vp8_base_heavy_tl3_alloc = false;
49   bool vp8_dynamic_rate = false;
50   bool vp9_dynamic_rate = false;
51 
52   std::unique_ptr<StructParametersParser> Parser();
53 };
54 
55 class RateControlSettings final {
56  public:
57   ~RateControlSettings();
58   RateControlSettings(RateControlSettings&&);
59 
60   static RateControlSettings ParseFromFieldTrials();
61   static RateControlSettings ParseFromKeyValueConfig(
62       const WebRtcKeyValueConfig* const key_value_config);
63 
64   // When CongestionWindowPushback is enabled, the pacer is oblivious to
65   // the congestion window. The relation between outstanding data and
66   // the congestion window affects encoder allocations directly.
67   bool UseCongestionWindow() const;
68   int64_t GetCongestionWindowAdditionalTimeMs() const;
69   bool UseCongestionWindowPushback() const;
70   bool UseCongestionWindowDropFrameOnly() const;
71   uint32_t CongestionWindowMinPushbackTargetBitrateBps() const;
72   absl::optional<DataSize> CongestionWindowInitialDataWindow() const;
73 
74   absl::optional<double> GetPacingFactor() const;
75   bool UseAlrProbing() const;
76 
77   absl::optional<int> LibvpxVp8QpMax() const;
78   absl::optional<int> LibvpxVp8MinPixels() const;
79   bool LibvpxVp8TrustedRateController() const;
80   bool Vp8BoostBaseLayerQuality() const;
81   bool Vp8DynamicRateSettings() const;
82   bool LibvpxVp9TrustedRateController() const;
83   bool Vp9DynamicRateSettings() const;
84 
85   // TODO(bugs.webrtc.org/10272): Remove one of these when we have merged
86   // VideoCodecMode and VideoEncoderConfig::ContentType.
87   double GetSimulcastHysteresisFactor(VideoCodecMode mode) const;
88   double GetSimulcastHysteresisFactor(
89       VideoEncoderConfig::ContentType content_type) const;
90 
91   bool Vp8BaseHeavyTl3RateAllocation() const;
92 
93   bool TriggerProbeOnMaxAllocatedBitrateChange() const;
94   bool UseEncoderBitrateAdjuster() const;
95   bool BitrateAdjusterCanUseNetworkHeadroom() const;
96 
97  private:
98   explicit RateControlSettings(
99       const WebRtcKeyValueConfig* const key_value_config);
100 
101   const CongestionWindowConfig congestion_window_config_;
102   VideoRateControlConfig video_config_;
103 };
104 
105 }  // namespace webrtc
106 
107 #endif  // RTC_BASE_EXPERIMENTS_RATE_CONTROL_SETTINGS_H_
108