Chromium Code Reviews| 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 c836f40f5e7187f242e828dc4b64c4e1e7ca3652..acef4da7fb8abcd0f3a51643f9b44fbc147476eb 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" |
| @@ -24,6 +25,7 @@ |
| #include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h" |
| #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.h" |
| #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.h" |
| +#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
|
danilchap
2016/07/04 12:22:57
with RateLimiter moved to base this is no longer n
sprang_webrtc
2016/07/04 12:47:00
Done.
|
| #include "webrtc/modules/utility/include/process_thread.h" |
| #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
| #include "webrtc/video/payload_router.h" |
| @@ -32,6 +34,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, |
| @@ -163,6 +167,8 @@ CongestionController::CongestionController( |
| new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), |
| bitrate_controller_( |
| BitrateController::CreateBitrateController(clock_, bitrate_observer)), |
| + 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), |
| @@ -184,6 +190,8 @@ CongestionController::CongestionController( |
| remote_bitrate_estimator_( |
| new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), |
| bitrate_controller_(BitrateController::CreateBitrateController(clock_)), |
| + 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), |
| @@ -209,6 +217,8 @@ CongestionController::CongestionController( |
| // Constructed last as this object calls the provided callback on |
| // construction. |
| bitrate_controller_(BitrateController::CreateBitrateController(clock_)), |
| + 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), |
| @@ -284,6 +294,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) { |
| @@ -315,6 +329,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() { |
| @@ -339,8 +361,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; |