diff --git a/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.cc b/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.cc index 969c0f03d6..479fefc565 100644 --- a/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.cc +++ b/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.cc @@ -28,15 +28,10 @@ CongestionWindowPushbackController::CongestionWindowPushbackController( .find("Enabled") == 0), min_pushback_target_bitrate_bps_( RateControlSettings::ParseFromKeyValueConfig(key_value_config) - .CongestionWindowMinPushbackTargetBitrateBps()) {} - -CongestionWindowPushbackController::CongestionWindowPushbackController( - const WebRtcKeyValueConfig* key_value_config, - uint32_t min_pushback_target_bitrate_bps) - : add_pacing_( - key_value_config->Lookup("WebRTC-AddPacingToCongestionWindowPushback") - .find("Enabled") == 0), - min_pushback_target_bitrate_bps_(min_pushback_target_bitrate_bps) {} + .CongestionWindowMinPushbackTargetBitrateBps()), + current_data_window_( + RateControlSettings::ParseFromKeyValueConfig(key_value_config) + .CongestionWindowInitialDataWindow()) {} void CongestionWindowPushbackController::UpdateOutstandingData( int64_t outstanding_bytes) { @@ -47,15 +42,6 @@ void CongestionWindowPushbackController::UpdatePacingQueue( pacing_bytes_ = pacing_bytes; } -void CongestionWindowPushbackController::UpdateMaxOutstandingData( - size_t max_outstanding_bytes) { - DataSize data_window = DataSize::bytes(max_outstanding_bytes); - if (current_data_window_) { - data_window = (data_window + current_data_window_.value()) / 2; - } - current_data_window_ = data_window; -} - void CongestionWindowPushbackController::SetDataWindow(DataSize data_window) { current_data_window_ = data_window; } diff --git a/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.h b/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.h index edf8bcb33f..7a49a83d5b 100644 --- a/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.h +++ b/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.h @@ -29,21 +29,17 @@ class CongestionWindowPushbackController { public: explicit CongestionWindowPushbackController( const WebRtcKeyValueConfig* key_value_config); - CongestionWindowPushbackController( - const WebRtcKeyValueConfig* key_value_config, - uint32_t min_pushback_target_bitrate_bps); void UpdateOutstandingData(int64_t outstanding_bytes); void UpdatePacingQueue(int64_t pacing_bytes); - void UpdateMaxOutstandingData(size_t max_outstanding_bytes); uint32_t UpdateTargetBitrate(uint32_t bitrate_bps); void SetDataWindow(DataSize data_window); private: + const bool add_pacing_; + const uint32_t min_pushback_target_bitrate_bps_; absl::optional current_data_window_; int64_t outstanding_bytes_ = 0; int64_t pacing_bytes_ = 0; - const bool add_pacing_; - const uint32_t min_pushback_target_bitrate_bps_; double encoding_rate_ratio_ = 1.0; }; diff --git a/modules/congestion_controller/goog_cc/congestion_window_pushback_controller_unittest.cc b/modules/congestion_controller/goog_cc/congestion_window_pushback_controller_unittest.cc index a13aa960b4..426d9e182f 100644 --- a/modules/congestion_controller/goog_cc/congestion_window_pushback_controller_unittest.cc +++ b/modules/congestion_controller/goog_cc/congestion_window_pushback_controller_unittest.cc @@ -10,7 +10,10 @@ #include "modules/congestion_controller/goog_cc/congestion_window_pushback_controller.h" +#include + #include "api/transport/field_trial_based_config.h" +#include "test/field_trial.h" #include "test/gmock.h" #include "test/gtest.h" @@ -21,53 +24,70 @@ namespace test { class CongestionWindowPushbackControllerTest : public ::testing::Test { public: - CongestionWindowPushbackControllerTest() - : cwnd_controller_(&field_trial_based_config_) {} + CongestionWindowPushbackControllerTest() { + cwnd_controller_.reset( + new CongestionWindowPushbackController(&field_trial_config_)); + } protected: - FieldTrialBasedConfig field_trial_based_config_; + FieldTrialBasedConfig field_trial_config_; - CongestionWindowPushbackController cwnd_controller_; + std::unique_ptr cwnd_controller_; }; TEST_F(CongestionWindowPushbackControllerTest, FullCongestionWindow) { - cwnd_controller_.UpdateOutstandingData(100000); - cwnd_controller_.UpdateMaxOutstandingData(50000); + cwnd_controller_->UpdateOutstandingData(100000); + cwnd_controller_->SetDataWindow(DataSize::bytes(50000)); uint32_t bitrate_bps = 80000; - bitrate_bps = cwnd_controller_.UpdateTargetBitrate(bitrate_bps); + bitrate_bps = cwnd_controller_->UpdateTargetBitrate(bitrate_bps); EXPECT_EQ(72000u, bitrate_bps); - cwnd_controller_.UpdateMaxOutstandingData(50000); - bitrate_bps = cwnd_controller_.UpdateTargetBitrate(bitrate_bps); + cwnd_controller_->SetDataWindow(DataSize::bytes(50000)); + bitrate_bps = cwnd_controller_->UpdateTargetBitrate(bitrate_bps); EXPECT_EQ(static_cast(72000 * 0.9 * 0.9), bitrate_bps); } TEST_F(CongestionWindowPushbackControllerTest, NormalCongestionWindow) { - cwnd_controller_.UpdateOutstandingData(100000); - cwnd_controller_.SetDataWindow(DataSize::bytes(200000)); + cwnd_controller_->UpdateOutstandingData(199999); + cwnd_controller_->SetDataWindow(DataSize::bytes(200000)); uint32_t bitrate_bps = 80000; - bitrate_bps = cwnd_controller_.UpdateTargetBitrate(bitrate_bps); - EXPECT_EQ(80000u, bitrate_bps); - - cwnd_controller_.UpdateMaxOutstandingData(20000); - bitrate_bps = cwnd_controller_.UpdateTargetBitrate(bitrate_bps); + bitrate_bps = cwnd_controller_->UpdateTargetBitrate(bitrate_bps); EXPECT_EQ(80000u, bitrate_bps); } TEST_F(CongestionWindowPushbackControllerTest, LowBitrate) { - cwnd_controller_.UpdateOutstandingData(100000); - cwnd_controller_.SetDataWindow(DataSize::bytes(50000)); + cwnd_controller_->UpdateOutstandingData(100000); + cwnd_controller_->SetDataWindow(DataSize::bytes(50000)); uint32_t bitrate_bps = 35000; - bitrate_bps = cwnd_controller_.UpdateTargetBitrate(bitrate_bps); + bitrate_bps = cwnd_controller_->UpdateTargetBitrate(bitrate_bps); EXPECT_EQ(static_cast(35000 * 0.9), bitrate_bps); - cwnd_controller_.UpdateMaxOutstandingData(20000); - bitrate_bps = cwnd_controller_.UpdateTargetBitrate(bitrate_bps); + cwnd_controller_->SetDataWindow(DataSize::bytes(20000)); + bitrate_bps = cwnd_controller_->UpdateTargetBitrate(bitrate_bps); EXPECT_EQ(30000u, bitrate_bps); } +TEST_F(CongestionWindowPushbackControllerTest, NoPushbackOnDataWindowUnset) { + cwnd_controller_->UpdateOutstandingData(1e8); // Large number + + uint32_t bitrate_bps = 80000; + bitrate_bps = cwnd_controller_->UpdateTargetBitrate(bitrate_bps); + EXPECT_EQ(80000u, bitrate_bps); +} + +TEST_F(CongestionWindowPushbackControllerTest, PushbackOnInititialDataWindow) { + test::ScopedFieldTrials trials("WebRTC-CongestionWindow/InitWin:100000/"); + cwnd_controller_.reset( + new CongestionWindowPushbackController(&field_trial_config_)); + cwnd_controller_->UpdateOutstandingData(1e8); // Large number + + uint32_t bitrate_bps = 80000; + bitrate_bps = cwnd_controller_->UpdateTargetBitrate(bitrate_bps); + EXPECT_GT(80000u, bitrate_bps); +} + } // namespace test } // namespace webrtc diff --git a/rtc_base/experiments/BUILD.gn b/rtc_base/experiments/BUILD.gn index add3988672..058e9b7f20 100644 --- a/rtc_base/experiments/BUILD.gn +++ b/rtc_base/experiments/BUILD.gn @@ -161,6 +161,7 @@ rtc_library("rate_control_settings") { "../:rtc_base_approved", "../../api/transport:field_trial_based_config", "../../api/transport:webrtc_key_value_config", + "../../api/units:data_size", "../../api/video_codecs:video_codecs_api", "../../system_wrappers:field_trial", "//third_party/abseil-cpp/absl/types:optional", diff --git a/rtc_base/experiments/rate_control_settings.cc b/rtc_base/experiments/rate_control_settings.cc index 579b8a5db9..bf623bda86 100644 --- a/rtc_base/experiments/rate_control_settings.cc +++ b/rtc_base/experiments/rate_control_settings.cc @@ -62,7 +62,8 @@ constexpr char CongestionWindowConfig::kKey[]; std::unique_ptr CongestionWindowConfig::Parser() { return StructParametersParser::Create("QueueSize", &queue_size_ms, // - "MinBitrate", &min_bitrate_bps); + "MinBitrate", &min_bitrate_bps, + "InitWin", &initial_data_window); } // static @@ -147,6 +148,11 @@ uint32_t RateControlSettings::CongestionWindowMinPushbackTargetBitrateBps() kDefaultMinPushbackTargetBitrateBps); } +absl::optional +RateControlSettings::CongestionWindowInitialDataWindow() const { + return congestion_window_config_.initial_data_window; +} + absl::optional RateControlSettings::GetPacingFactor() const { return video_config_.pacing_factor; } diff --git a/rtc_base/experiments/rate_control_settings.h b/rtc_base/experiments/rate_control_settings.h index 01cdae6364..3f1d8dee70 100644 --- a/rtc_base/experiments/rate_control_settings.h +++ b/rtc_base/experiments/rate_control_settings.h @@ -13,6 +13,7 @@ #include "absl/types/optional.h" #include "api/transport/webrtc_key_value_config.h" +#include "api/units/data_size.h" #include "api/video_codecs/video_codec.h" #include "api/video_codecs/video_encoder_config.h" #include "rtc_base/experiments/struct_parameters_parser.h" @@ -23,6 +24,7 @@ struct CongestionWindowConfig { static constexpr char kKey[] = "WebRTC-CongestionWindow"; absl::optional queue_size_ms; absl::optional min_bitrate_bps; + absl::optional initial_data_window; std::unique_ptr Parser(); static CongestionWindowConfig Parse(absl::string_view config); }; @@ -65,6 +67,7 @@ class RateControlSettings final { int64_t GetCongestionWindowAdditionalTimeMs() const; bool UseCongestionWindowPushback() const; uint32_t CongestionWindowMinPushbackTargetBitrateBps() const; + absl::optional CongestionWindowInitialDataWindow() const; absl::optional GetPacingFactor() const; bool UseAlrProbing() const;