Prevent updating state in the delay manager if the packet was reordered.
Currently, if the last packet was reordered (e.g. due to retransmission) then the next packet's inter-arrival time will be estimated incorrectly due to the jump in sequence numbers. This change prevents that by not resetting the stopwatch on reordered packets.
This will also better estimate inter-arrival times when we have multiple reordered packets in a burst. Currently we would only measure the iat of the first reordered packet correctly and not the ones coming after it.
There is a slight risk introducing this: If we would receive an out of order packet far into the future (in sequence numbers) and then continue getting packets in the normal order, then we would not update the current sequence number for these and incorrectly estimate their inter-arrival times since they would all be considered reordered.
Change-Id: Ic938a37cbddf1cb9c30b610218f56794568d3d01
Bug: webrtc:10178
Reviewed-on: https://webrtc-review.googlesource.com/c/119949
Reviewed-by: Minyue Li <minyue@webrtc.org>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Commit-Queue: Jakob Ivarsson‎ <jakobi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26572}
diff --git a/modules/audio_coding/neteq/delay_manager_unittest.cc b/modules/audio_coding/neteq/delay_manager_unittest.cc
index b0e23a9..e33b2aa 100644
--- a/modules/audio_coding/neteq/delay_manager_unittest.cc
+++ b/modules/audio_coding/neteq/delay_manager_unittest.cc
@@ -46,6 +46,7 @@
MockDelayPeakDetector detector_;
uint16_t seq_no_;
uint32_t ts_;
+ bool enable_rtx_handling_ = false;
};
DelayManagerTest::DelayManagerTest()
@@ -60,8 +61,8 @@
void DelayManagerTest::RecreateDelayManager() {
EXPECT_CALL(detector_, Reset()).Times(1);
- dm_.reset(new DelayManager(kMaxNumberOfPackets, kMinDelayMs, &detector_,
- &tick_timer_));
+ dm_.reset(new DelayManager(kMaxNumberOfPackets, kMinDelayMs,
+ enable_rtx_handling_, &detector_, &tick_timer_));
}
void DelayManagerTest::SetPacketAudioLength(int lengt_ms) {
@@ -320,6 +321,31 @@
EXPECT_EQ(0, dm_->Update(seq_no_ - 1, ts_ - kFrameSizeMs, kFs));
}
+TEST_F(DelayManagerTest, EnableRtxHandling) {
+ enable_rtx_handling_ = true;
+ RecreateDelayManager();
+
+ // Insert first packet.
+ SetPacketAudioLength(kFrameSizeMs);
+ InsertNextPacket();
+
+ // Insert reordered packet.
+ // TODO(jakobi): Test estimated inter-arrival time by mocking the histogram
+ // instead of checking the call to the peak detector.
+ EXPECT_CALL(detector_, Update(3, true, _));
+ EXPECT_EQ(0, dm_->Update(seq_no_ - 3, ts_ - 3 * kFrameSizeMs, kFs));
+
+ // Insert another reordered packet.
+ EXPECT_CALL(detector_, Update(2, true, _));
+ EXPECT_EQ(0, dm_->Update(seq_no_ - 2, ts_ - 2 * kFrameSizeMs, kFs));
+
+ // Insert the next packet in order and verify that the inter-arrival time is
+ // estimated correctly.
+ IncreaseTime(kFrameSizeMs);
+ EXPECT_CALL(detector_, Update(1, false, _));
+ InsertNextPacket();
+}
+
// Tests that skipped sequence numbers (simulating empty packets) are handled
// correctly.
TEST_F(DelayManagerTest, EmptyPacketsReported) {