Fix jitter buffer delay reporting.

Previously, if more than one packet is extracted in a GetAudio call then
an incorrect number of samples will be reported.

Bug: webrtc:10363
Change-Id: Ia1bcc87a0e0082060e4f746d37a4008735eec6b3
Reviewed-on: https://webrtc-review.googlesource.com/c/124829
Reviewed-by: Minyue Li <minyue@webrtc.org>
Commit-Queue: Jakob Ivarsson‎ <jakobi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26903}
This commit is contained in:
Jakob Ivarsson
2019-02-28 09:55:49 +01:00
committed by Commit Bot
parent c58c01d6d4
commit 26c59ff6ca
2 changed files with 33 additions and 1 deletions

View File

@ -1915,7 +1915,7 @@ int NetEqImpl::ExtractPackets(size_t required_samples,
}
extracted_samples = packet->timestamp - first_timestamp + packet_duration;
stats_.JitterBufferDelay(extracted_samples, waiting_time_ms);
stats_.JitterBufferDelay(packet_duration, waiting_time_ms);
packet_list->push_back(std::move(*packet)); // Store packet in list.
packet = absl::nullopt; // Ensure it's never used after the move.

View File

@ -1702,6 +1702,38 @@ TEST_F(NetEqDecodingTestFaxMode, TestJitterBufferDelayWithLoss) {
TestJitterBufferDelay(true);
}
TEST_F(NetEqDecodingTestFaxMode, TestJitterBufferDelayWithAcceleration) {
const int kPacketLenMs = 10; // All packets are of 10 ms size.
const size_t kSamples = kPacketLenMs * 16;
const size_t kPayloadBytes = kSamples * 2;
RTPHeader rtp_info;
rtp_info.ssrc = 0x1234; // Just an arbitrary SSRC.
rtp_info.payloadType = 94; // PCM16b WB codec.
rtp_info.markerBit = 0;
const uint8_t payload[kPayloadBytes] = {0};
neteq_->InsertPacket(rtp_info, payload, 0);
bool muted;
neteq_->GetAudio(&out_frame_, &muted);
rtp_info.sequenceNumber += 1;
rtp_info.timestamp += kSamples;
neteq_->InsertPacket(rtp_info, payload, 0);
rtp_info.sequenceNumber += 1;
rtp_info.timestamp += kSamples;
neteq_->InsertPacket(rtp_info, payload, 0);
// We have two packets in the buffer and kAccelerate operation will
// extract 20 ms of data.
neteq_->GetAudio(&out_frame_, &muted, Operations::kAccelerate);
// Check jitter buffer delay.
NetEqLifetimeStatistics stats = neteq_->GetLifetimeStatistics();
EXPECT_EQ(10 * kSamples * 3, stats.jitter_buffer_delay_ms);
EXPECT_EQ(kSamples * 3, stats.jitter_buffer_emitted_count);
}
namespace test {
TEST(NetEqNoTimeStretchingMode, RunTest) {
NetEq::Config config;