Index: webrtc/modules/congestion_controller/congestion_controller.cc |
diff --git a/webrtc/modules/congestion_controller/congestion_controller.cc b/webrtc/modules/congestion_controller/congestion_controller.cc |
index 7582258185e4ab4b70c87720a9bc3ef702716afa..d1ab03af0f8fe92d54749fc5046dcc2c47362f38 100644 |
--- a/webrtc/modules/congestion_controller/congestion_controller.cc |
+++ b/webrtc/modules/congestion_controller/congestion_controller.cc |
@@ -17,6 +17,7 @@ |
#include "webrtc/base/checks.h" |
#include "webrtc/base/constructormagic.h" |
#include "webrtc/base/logging.h" |
+#include "webrtc/base/rate_limiter.h" |
#include "webrtc/base/socket.h" |
#include "webrtc/base/thread_annotations.h" |
#include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
@@ -32,6 +33,8 @@ namespace webrtc { |
namespace { |
static const uint32_t kTimeOffsetSwitchThreshold = 30; |
+static const int64_t kMinRetransmitWindowSizeMs = 30; |
+static const int64_t kMaxRetransmitWindowSizeMs = 1000; |
// Makes sure that the bitrate and the min, max values are in valid range. |
static void ClampBitrates(int* bitrate_bps, |
@@ -164,6 +167,8 @@ CongestionController::CongestionController( |
new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), |
bitrate_controller_( |
BitrateController::CreateBitrateController(clock_, event_log)), |
+ retransmission_rate_limiter_( |
+ new RateLimiter(clock, kMaxRetransmitWindowSizeMs)), |
remote_estimator_proxy_(clock_, packet_router_.get()), |
transport_feedback_adapter_(bitrate_controller_.get(), clock_), |
min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps), |
@@ -191,6 +196,8 @@ CongestionController::CongestionController( |
// construction. |
bitrate_controller_( |
BitrateController::CreateBitrateController(clock_, event_log)), |
+ retransmission_rate_limiter_( |
+ new RateLimiter(clock, kMaxRetransmitWindowSizeMs)), |
remote_estimator_proxy_(clock_, packet_router_.get()), |
transport_feedback_adapter_(bitrate_controller_.get(), clock_), |
min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps), |
@@ -266,6 +273,10 @@ CongestionController::GetTransportFeedbackObserver() { |
return &transport_feedback_adapter_; |
} |
+RateLimiter* CongestionController::GetRetransmissionRateLimiter() { |
+ return retransmission_rate_limiter_.get(); |
+} |
+ |
void CongestionController::SetAllocatedSendBitrateLimits( |
int min_send_bitrate_bps, |
int max_padding_bitrate_bps) { |
@@ -299,6 +310,14 @@ void CongestionController::OnSentPacket(const rtc::SentPacket& sent_packet) { |
void CongestionController::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { |
remote_bitrate_estimator_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); |
transport_feedback_adapter_.OnRttUpdate(avg_rtt_ms, max_rtt_ms); |
+ |
+ int64_t nack_window_size_ms = max_rtt_ms; |
+ if (nack_window_size_ms > kMaxRetransmitWindowSizeMs) { |
+ nack_window_size_ms = kMaxRetransmitWindowSizeMs; |
+ } else if (nack_window_size_ms < kMinRetransmitWindowSizeMs) { |
+ nack_window_size_ms = kMinRetransmitWindowSizeMs; |
+ } |
+ retransmission_rate_limiter_->SetWindowSize(nack_window_size_ms); |
} |
int64_t CongestionController::TimeUntilNextProcess() { |
@@ -323,8 +342,10 @@ void CongestionController::MaybeTriggerOnNetworkChanged() { |
int64_t rtt; |
bool estimate_changed = bitrate_controller_->GetNetworkParameters( |
&bitrate_bps, &fraction_loss, &rtt); |
- if (estimate_changed) |
+ if (estimate_changed) { |
pacer_->SetEstimatedBitrate(bitrate_bps); |
+ retransmission_rate_limiter_->SetMaxRate(bitrate_bps); |
+ } |
bitrate_bps = IsNetworkDown() || IsSendQueueFull() ? 0 : bitrate_bps; |