diff --git a/webrtc/modules/congestion_controller/probe_controller.cc b/webrtc/modules/congestion_controller/probe_controller.cc index e66f0cec3d..373b268d2c 100644 --- a/webrtc/modules/congestion_controller/probe_controller.cc +++ b/webrtc/modules/congestion_controller/probe_controller.cc @@ -72,6 +72,8 @@ void ProbeController::SetBitrates(int64_t min_bitrate_bps, start_bitrate_bps_ = min_bitrate_bps; } + // The reason we use the variable |old_max_bitrate_pbs| is because we + // need to set |max_bitrate_bps_| before we call InitiateProbing. int64_t old_max_bitrate_bps = max_bitrate_bps_; max_bitrate_bps_ = max_bitrate_bps; @@ -85,10 +87,11 @@ void ProbeController::SetBitrates(int64_t min_bitrate_bps, break; case State::kProbingComplete: - // Initiate probing when |max_bitrate_| was increased mid-call. - if (estimated_bitrate_bps_ != kExponentialProbingDisabled && - estimated_bitrate_bps_ < old_max_bitrate_bps && - max_bitrate_bps_ > old_max_bitrate_bps) { + // If the new max bitrate is higher than the old max bitrate and the + // estimate is lower than the new max bitrate then initiate probing. + if (estimated_bitrate_bps_ != 0 && + old_max_bitrate_bps < max_bitrate_bps_ && + estimated_bitrate_bps_ < max_bitrate_bps_) { // The assumption is that if we jump more than 20% in the bandwidth // estimate or if the bandwidth estimate is within 90% of the new // max bitrate then the probing attempt was successful. diff --git a/webrtc/modules/congestion_controller/probe_controller_unittest.cc b/webrtc/modules/congestion_controller/probe_controller_unittest.cc index fd6ecc137f..19a9039ada 100644 --- a/webrtc/modules/congestion_controller/probe_controller_unittest.cc +++ b/webrtc/modules/congestion_controller/probe_controller_unittest.cc @@ -79,6 +79,21 @@ TEST_F(ProbeControllerTest, InitiatesProbingOnMaxBitrateIncrease) { kMaxBitrateBps + 100); } +TEST_F(ProbeControllerTest, InitiatesProbingOnMaxBitrateIncreaseAtMaxBitrate) { + EXPECT_CALL(pacer_, CreateProbeCluster(_)).Times(AtLeast(2)); + probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, + kMaxBitrateBps); + // Long enough to time out exponential probing. + clock_.AdvanceTimeMilliseconds(kExponentialProbingTimeoutMs); + probe_controller_->SetEstimatedBitrate(kStartBitrateBps); + probe_controller_->Process(); + + probe_controller_->SetEstimatedBitrate(kMaxBitrateBps); + EXPECT_CALL(pacer_, CreateProbeCluster(kMaxBitrateBps + 100)); + probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, + kMaxBitrateBps + 100); +} + TEST_F(ProbeControllerTest, TestExponentialProbing) { probe_controller_->SetBitrates(kMinBitrateBps, kStartBitrateBps, kMaxBitrateBps);