blob: b003bee7260d43f245bb44331cb11be243a598a7 [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"
Erik Språng71215642019-01-21 16:30:55 +010018#include "rtc_base/experiments/field_trial_parser.h"
Erik Språngcd76eab2019-01-21 18:06:46 +010019#include "rtc_base/experiments/field_trial_units.h"
Erik Språng71215642019-01-21 16:30:55 +010020
21namespace webrtc {
22
23class RateControlSettings final {
24 public:
25 ~RateControlSettings();
26 RateControlSettings(RateControlSettings&&);
27
28 static RateControlSettings ParseFromFieldTrials();
29 static RateControlSettings ParseFromKeyValueConfig(
30 const WebRtcKeyValueConfig* const key_value_config);
31
32 // When CongestionWindowPushback is enabled, the pacer is oblivious to
33 // the congestion window. The relation between outstanding data and
34 // the congestion window affects encoder allocations directly.
35 bool UseCongestionWindow() const;
36 int64_t GetCongestionWindowAdditionalTimeMs() const;
37 bool UseCongestionWindowPushback() const;
38 uint32_t CongestionWindowMinPushbackTargetBitrateBps() const;
39
Erik Språngcd76eab2019-01-21 18:06:46 +010040 absl::optional<double> GetPacingFactor() const;
41 bool UseAlrProbing() const;
42
Åsa Perssond7dd49f2019-05-08 14:44:12 +020043 absl::optional<int> LibvpxVp8QpMax() const;
Åsa Perssona0948492019-06-27 13:44:30 +020044 absl::optional<int> LibvpxVp8MinPixels() const;
Erik Språng4b4266f2019-01-23 12:48:13 +010045 bool LibvpxVp8TrustedRateController() const;
Erik Språng7f24fb92019-02-13 10:49:37 +010046 bool Vp8BoostBaseLayerQuality() const;
Erik Språng7a3fe892019-04-15 12:22:55 +020047 bool Vp8DynamicRateSettings() const;
Erik Språng4b4266f2019-01-23 12:48:13 +010048 bool LibvpxVp9TrustedRateController() const;
Erik Språng7a3fe892019-04-15 12:22:55 +020049 bool Vp9DynamicRateSettings() const;
Erik Språng4b4266f2019-01-23 12:48:13 +010050
Rasmus Brandtc402dbe2019-02-04 11:09:46 +010051 // TODO(bugs.webrtc.org/10272): Remove one of these when we have merged
52 // VideoCodecMode and VideoEncoderConfig::ContentType.
53 double GetSimulcastHysteresisFactor(VideoCodecMode mode) const;
54 double GetSimulcastHysteresisFactor(
55 VideoEncoderConfig::ContentType content_type) const;
Erik Språng2c58ba12019-01-23 16:53:18 +010056
Erik Språng5118bbc2019-01-29 18:28:06 +010057 bool TriggerProbeOnMaxAllocatedBitrateChange() const;
Erik Språng7ca375c2019-02-06 16:20:17 +010058 bool UseEncoderBitrateAdjuster() const;
Erik Språng3d11e2f2019-04-15 14:48:30 +020059 bool BitrateAdjusterCanUseNetworkHeadroom() const;
Erik Språng5118bbc2019-01-29 18:28:06 +010060
Erik Språng71215642019-01-21 16:30:55 +010061 private:
62 explicit RateControlSettings(
63 const WebRtcKeyValueConfig* const key_value_config);
64
Rasmus Brandtc402dbe2019-02-04 11:09:46 +010065 double GetSimulcastVideoHysteresisFactor() const;
66 double GetSimulcastScreenshareHysteresisFactor() const;
67
Erik Språng71215642019-01-21 16:30:55 +010068 FieldTrialOptional<int> congestion_window_;
69 FieldTrialOptional<int> congestion_window_pushback_;
Erik Språngcd76eab2019-01-21 18:06:46 +010070 FieldTrialOptional<double> pacing_factor_;
71 FieldTrialParameter<bool> alr_probing_;
Åsa Perssond7dd49f2019-05-08 14:44:12 +020072 FieldTrialOptional<int> vp8_qp_max_;
Åsa Perssona0948492019-06-27 13:44:30 +020073 FieldTrialOptional<int> vp8_min_pixels_;
Erik Språng4b4266f2019-01-23 12:48:13 +010074 FieldTrialParameter<bool> trust_vp8_;
75 FieldTrialParameter<bool> trust_vp9_;
Erik Språng2c58ba12019-01-23 16:53:18 +010076 FieldTrialParameter<double> video_hysteresis_;
77 FieldTrialParameter<double> screenshare_hysteresis_;
Erik Språng5118bbc2019-01-29 18:28:06 +010078 FieldTrialParameter<bool> probe_max_allocation_;
Erik Språng7ca375c2019-02-06 16:20:17 +010079 FieldTrialParameter<bool> bitrate_adjuster_;
Erik Språng3d11e2f2019-04-15 14:48:30 +020080 FieldTrialParameter<bool> adjuster_use_headroom_;
Erik Språng7f24fb92019-02-13 10:49:37 +010081 FieldTrialParameter<bool> vp8_s0_boost_;
Erik Språng7a3fe892019-04-15 12:22:55 +020082 FieldTrialParameter<bool> vp8_dynamic_rate_;
83 FieldTrialParameter<bool> vp9_dynamic_rate_;
Erik Språng71215642019-01-21 16:30:55 +010084};
85
86} // namespace webrtc
87
88#endif // RTC_BASE_EXPERIMENTS_RATE_CONTROL_SETTINGS_H_