diff --git a/modules/pacing/pacing_controller.cc b/modules/pacing/pacing_controller.cc index 0d0d1ae5dd..e346a838f5 100644 --- a/modules/pacing/pacing_controller.cc +++ b/modules/pacing/pacing_controller.cc @@ -308,6 +308,10 @@ bool PacingController::ShouldSendKeepalive(Timestamp now) const { Timestamp PacingController::NextSendTime() const { Timestamp now = CurrentTime(); + if (paused_) { + return last_send_time_ + kPausedProcessInterval; + } + // If probing is active, that always takes priority. if (prober_.IsProbing()) { Timestamp probe_time = prober_.NextProbeTime(now); @@ -318,10 +322,7 @@ Timestamp PacingController::NextSendTime() const { } if (mode_ == ProcessMode::kPeriodic) { - // In periodc non-probing mode, we just have a fixed interval. - if (paused_) { - return last_send_time_ + kPausedProcessInterval; - } + // In periodic non-probing mode, we just have a fixed interval. return last_process_time_ + min_packet_limit_; } diff --git a/modules/pacing/pacing_controller_unittest.cc b/modules/pacing/pacing_controller_unittest.cc index 9337ad2f8a..e581e30492 100644 --- a/modules/pacing/pacing_controller_unittest.cc +++ b/modules/pacing/pacing_controller_unittest.cc @@ -1737,6 +1737,35 @@ TEST_P(PacingControllerTest, TaskLate) { pacer_->ProcessPackets(); } +TEST_P(PacingControllerTest, NoProbingWhilePaused) { + uint32_t ssrc = 12345; + uint16_t sequence_number = 1234; + + pacer_->SetProbingEnabled(true); + + // Send at least one packet so probing can initate. + SendAndExpectPacket(RtpPacketToSend::Type::kVideo, ssrc, sequence_number, + clock_.TimeInMilliseconds(), 250); + while (pacer_->QueueSizePackets() > 0) { + AdvanceTimeAndProcess(); + } + + // Trigger probing. + pacer_->CreateProbeCluster(DataRate::kbps(10000), // 10 Mbps. + /*cluster_id=*/3); + + // Time to next send time should be small. + EXPECT_LT(pacer_->NextSendTime() - clock_.CurrentTime(), + PacingController::kPausedProcessInterval); + + // Pause pacer, time to next send time should now be the pause process + // interval. + pacer_->Pause(); + + EXPECT_EQ(pacer_->NextSendTime() - clock_.CurrentTime(), + PacingController::kPausedProcessInterval); +} + INSTANTIATE_TEST_SUITE_P( WithAndWithoutIntervalBudget, PacingControllerTest,