Fixes issue where dynamic pacer could pace audio.

Specifically, if dynamic pacer (i.e. TaskQueuePacer) was enabled while
AccountForAudio was set to true, the pacer would pace audio packets.
This should only happen when the WebRTC-Pacer-BlockAudio field trial is
enabled.

Bug: webrtc:10809
Change-Id: If5edc77de88ca9866abeb3b47e171df50673299e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/172082
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30938}
This commit is contained in:
Erik Språng
2020-03-28 17:15:54 +01:00
committed by Commit Bot
parent f74d2ce649
commit 9cb58d5d46
2 changed files with 32 additions and 6 deletions

View File

@ -343,13 +343,11 @@ Timestamp PacingController::NextSendTime() const {
// In dynamic mode, figure out when the next packet should be sent,
// given the current conditions.
if (Congested() || packet_counter_ == 0) {
// If congested, we only send keep-alive or audio (if audio is
// configured in pass-through mode).
if (!pace_audio_ && packet_queue_.NextPacketIsAudio()) {
return now;
}
if (!pace_audio_ && packet_queue_.NextPacketIsAudio()) {
return now;
}
if (Congested() || packet_counter_ == 0) {
// We need to at least send keep-alive packets with some interval.
return last_send_time_ + kCongestedPacketInterval;
}

View File

@ -1767,6 +1767,34 @@ TEST_P(PacingControllerTest, NoProbingWhilePaused) {
PacingController::kPausedProcessInterval);
}
TEST_P(PacingControllerTest, AudioNotPacedEvenWhenAccountedFor) {
const uint32_t kSsrc = 12345;
uint16_t sequence_number = 1234;
const size_t kPacketSize = 123;
// Account for audio - so that audio packets can cause pushback on other
// types such as video. Audio packet should still be immediated passed
// through though ("WebRTC-Pacer-BlockAudio" needs to be enabled in order
// to pace audio packets).
pacer_->SetAccountForAudioPackets(true);
// Set pacing rate to 1 packet/s, no padding.
pacer_->SetPacingRates(DataSize::Bytes(kPacketSize) / TimeDelta::Seconds(1),
DataRate::Zero());
// Add and send an audio packet.
SendAndExpectPacket(RtpPacketMediaType::kAudio, kSsrc, sequence_number++,
clock_.TimeInMilliseconds(), kPacketSize);
pacer_->ProcessPackets();
// Advance time, add another audio packet and process. It should be sent
// immediately.
clock_.AdvanceTimeMilliseconds(5);
SendAndExpectPacket(RtpPacketMediaType::kAudio, kSsrc, sequence_number++,
clock_.TimeInMilliseconds(), kPacketSize);
pacer_->ProcessPackets();
}
INSTANTIATE_TEST_SUITE_P(
WithAndWithoutIntervalBudget,
PacingControllerTest,