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 2011bef2bd..1e59cb5b4d 100644 --- a/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.cc +++ b/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.cc @@ -47,6 +47,10 @@ CongestionWindowPushbackController::CongestionWindowPushbackController() { } } +CongestionWindowPushbackController::CongestionWindowPushbackController( + uint32_t min_pushback_target_bitrate_bps) + : min_pushback_target_bitrate_bps_(min_pushback_target_bitrate_bps) {} + void CongestionWindowPushbackController::UpdateOutstandingData( size_t outstanding_bytes) { outstanding_bytes_ = outstanding_bytes; 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 d8a334395d..7ef0974cce 100644 --- a/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.h +++ b/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.h @@ -23,6 +23,8 @@ namespace webrtc { class CongestionWindowPushbackController { public: CongestionWindowPushbackController(); + explicit CongestionWindowPushbackController( + uint32_t min_pushback_target_bitrate_bps); void UpdateOutstandingData(size_t outstanding_bytes); void UpdateMaxOutstandingData(size_t max_outstanding_bytes); uint32_t UpdateTargetBitrate(uint32_t bitrate_bps); diff --git a/modules/congestion_controller/include/send_side_congestion_controller.h b/modules/congestion_controller/include/send_side_congestion_controller.h index 06856a3c9d..88530a22c1 100644 --- a/modules/congestion_controller/include/send_side_congestion_controller.h +++ b/modules/congestion_controller/include/send_side_congestion_controller.h @@ -113,6 +113,9 @@ class SendSideCongestionController void SetAllocatedBitrateWithoutFeedback(uint32_t bitrate_bps) override; + void EnableCongestionWindowPushback(int64_t accepted_queue_ms, + uint32_t min_pushback_target_bitrate_bps); + private: void MaybeTriggerOnNetworkChanged(); @@ -161,7 +164,7 @@ class SendSideCongestionController bool pacer_pushback_experiment_ = false; float encoding_rate_ = 1.0; - const std::unique_ptr + std::unique_ptr congestion_window_pushback_controller_; RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(SendSideCongestionController); diff --git a/modules/congestion_controller/send_side_congestion_controller.cc b/modules/congestion_controller/send_side_congestion_controller.cc index 5b5443f83c..cf03baa2ab 100644 --- a/modules/congestion_controller/send_side_congestion_controller.cc +++ b/modules/congestion_controller/send_side_congestion_controller.cc @@ -164,6 +164,23 @@ SendSideCongestionController::SendSideCongestionController( SendSideCongestionController::~SendSideCongestionController() {} +void SendSideCongestionController::EnableCongestionWindowPushback( + int64_t accepted_queue_ms, + uint32_t min_pushback_target_bitrate_bps) { + RTC_DCHECK(!congestion_window_pushback_controller_) + << "The congestion pushback is already enabled."; + RTC_CHECK_GE(accepted_queue_ms, 0) + << "Accepted must be greater than or equal to 0."; + RTC_CHECK_GE(min_pushback_target_bitrate_bps, 0) + << "Min pushback target bitrate must be greater than or equal to 0."; + + in_cwnd_experiment_ = true; + accepted_queue_ms_ = accepted_queue_ms; + congestion_window_pushback_controller_ = + absl::make_unique( + min_pushback_target_bitrate_bps); +} + void SendSideCongestionController::RegisterPacketFeedbackObserver( PacketFeedbackObserver* observer) { transport_feedback_adapter_.RegisterPacketFeedbackObserver(observer);