Check timestamp difference when choosing to extract multiple packets from the jitter buffer.
This fixes a bug where we sometimes extract an Opus CNG packet and the packet after, even though there was big timestamp gap between the packets, which causes expansion during the next GetAudio calls.
Change-Id: I2409ac08df58afc496f74b91981657b7206e8bb1
Bug: webrtc:10167
Reviewed-on: https://webrtc-review.googlesource.com/c/115419
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Commit-Queue: Jakob Ivarsson‎ <jakobi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26179}
diff --git a/modules/audio_coding/neteq/neteq_impl.cc b/modules/audio_coding/neteq/neteq_impl.cc
index 4c8607f..e1b3bc1 100644
--- a/modules/audio_coding/neteq/neteq_impl.cc
+++ b/modules/audio_coding/neteq/neteq_impl.cc
@@ -1938,13 +1938,14 @@
!has_cng_packet) {
int16_t seq_no_diff = next_packet->sequence_number - prev_sequence_number;
size_t ts_diff = next_packet->timestamp - prev_timestamp;
- if (seq_no_diff == 1 ||
- (seq_no_diff == 0 && ts_diff == decoder_frame_length_)) {
+ if ((seq_no_diff == 1 || seq_no_diff == 0) &&
+ ts_diff <= packet_duration) {
// The next sequence number is available, or the next part of a packet
// that was split into pieces upon insertion.
next_packet_available = true;
}
prev_sequence_number = next_packet->sequence_number;
+ prev_timestamp = next_packet->timestamp;
}
} while (extracted_samples < required_samples && next_packet_available);