From 9b7b75324f2deb9a17c1d25292123ae1f4021d9a Mon Sep 17 00:00:00 2001 From: Irfan Sheriff Date: Fri, 16 Sep 2016 11:30:44 -0700 Subject: [PATCH] Avoid max bitrate probing when exponential probing in progress Avoid starting the max probing when there is an exponential probing session in progress. BUG=webrtc:6332 R=philipel@webrtc.org, stefan@webrtc.org Review URL: https://codereview.webrtc.org/2269873002 . Cr-Commit-Position: refs/heads/master@{#14268} --- .../congestion_controller/probe_controller.cc | 12 +++++++----- .../probe_controller_unittest.cc | 9 ++++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/webrtc/modules/congestion_controller/probe_controller.cc b/webrtc/modules/congestion_controller/probe_controller.cc index cf7f3e1b61..e91e06efd5 100644 --- a/webrtc/modules/congestion_controller/probe_controller.cc +++ b/webrtc/modules/congestion_controller/probe_controller.cc @@ -54,11 +54,13 @@ void ProbeController::SetBitrates(int min_bitrate_bps, } // Only do probing if: - // - we are mid-call, which we consider to be if - // |estimated_bitrate_bps_| != 0, and - // - the current bitrate is lower than the new |max_bitrate_bps|, and - // - we actually want to increase the |max_bitrate_bps_|. - if (estimated_bitrate_bps_ != 0 && estimated_bitrate_bps_ < max_bitrate_bps && + // we are mid-call, which we consider to be if + // exponential probing is not active and + // |estimated_bitrate_bps_| is valid (> 0) and + // the current bitrate is lower than the new |max_bitrate_bps|, and + // we actually want to increase the |max_bitrate_bps_|. + if (state_ != State::kWaitingForProbingResult && + estimated_bitrate_bps_ != 0 && estimated_bitrate_bps_ < max_bitrate_bps && max_bitrate_bps > max_bitrate_bps_) { InitiateProbing({max_bitrate_bps}, kExponentialProbingDisabled); } diff --git a/webrtc/modules/congestion_controller/probe_controller_unittest.cc b/webrtc/modules/congestion_controller/probe_controller_unittest.cc index 693277552c..9e01660aa2 100644 --- a/webrtc/modules/congestion_controller/probe_controller_unittest.cc +++ b/webrtc/modules/congestion_controller/probe_controller_unittest.cc @@ -29,6 +29,8 @@ constexpr int kMinBitrateBps = 100; constexpr int kStartBitrateBps = 300; constexpr int kMaxBitrateBps = 1000; +constexpr int kExponentialProbingTimeoutMs = 5000; + } // namespace class ProbeControllerTest : public ::testing::Test { @@ -53,9 +55,10 @@ TEST_F(ProbeControllerTest, InitiatesProbingOnMaxBitrateIncrease) { EXPECT_CALL(pacer_, CreateProbeCluster(_, _)).Times(AtLeast(2)); probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, kMaxBitrateBps); - clock_.AdvanceTimeMilliseconds(25); - + // Long enough to time out exponential probing. + clock_.AdvanceTimeMilliseconds(kExponentialProbingTimeoutMs); probe_controller_->SetEstimatedBitrate(kStartBitrateBps); + EXPECT_CALL(pacer_, CreateProbeCluster(kMaxBitrateBps + 100, _)); probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, kMaxBitrateBps + 100); @@ -73,7 +76,7 @@ TEST_F(ProbeControllerTest, TestExponentialProbingTimeout) { kMaxBitrateBps); // Advance far enough to cause a time out in waiting for probing result. - clock_.AdvanceTimeMilliseconds(5000); + clock_.AdvanceTimeMilliseconds(kExponentialProbingTimeoutMs); EXPECT_CALL(pacer_, CreateProbeCluster(2 * 1800, _)).Times(0); probe_controller_->SetEstimatedBitrate(1800); }