rate_control_settings.h 3.8 KB

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