Index: webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc |
diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc |
index 006a5ad542397cb839b2fe70bd5e59c093fbdbc8..ab0b4bf7cd1ff6c2d2b432004786968fc6063e9f 100644 |
--- a/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc |
+++ b/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc |
@@ -907,4 +907,42 @@ TEST_F(NetEqImplTest, UnsupportedDecoder) { |
EXPECT_EQ(kChannels, num_channels); |
} |
+// This test inserts packets until the buffer is flushed. After that, it asks |
+// NetEq for the network statistics. The purpose of the test is to make sure |
+// that even though the buffer size increment is negative (which it becomes when |
+// the packet causing a flush is inserted), the packet length stored in the |
+// decision logic remains valid. |
+TEST_F(NetEqImplTest, FloodBufferAndGetNetworkStats) { |
+ UseNoMocks(); |
+ CreateInstance(); |
+ |
+ const int kPayloadLengthSamples = 80; |
Peter Kasting
2015/08/27 08:45:33
Nit: Use size_t here...
hlundin-webrtc
2015/08/27 09:54:03
Done.
|
+ const size_t kPayloadLengthBytes = 2 * kPayloadLengthSamples; // PCM 16-bit. |
+ const uint8_t kPayloadType = 17; // Just an arbitrary number. |
+ const uint32_t kReceiveTime = 17; // Value doesn't matter for this test. |
+ uint8_t payload[kPayloadLengthBytes] = {0}; |
+ WebRtcRTPHeader rtp_header; |
+ rtp_header.header.payloadType = kPayloadType; |
+ rtp_header.header.sequenceNumber = 0x1234; |
+ rtp_header.header.timestamp = 0x12345678; |
+ rtp_header.header.ssrc = 0x87654321; |
+ |
+ EXPECT_EQ(NetEq::kOK, |
+ neteq_->RegisterPayloadType(kDecoderPCM16B, kPayloadType)); |
+ |
+ // Insert packets until the buffer flushes. |
+ for (size_t i = 0; i <= config_.max_packets_in_buffer; ++i) { |
+ EXPECT_EQ(i, packet_buffer_->NumPacketsInBuffer()); |
+ EXPECT_EQ(NetEq::kOK, |
+ neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes, |
+ kReceiveTime)); |
+ rtp_header.header.timestamp += kPayloadLengthSamples; |
Peter Kasting
2015/08/27 08:45:33
Nit: ...and cast to uint32_t here
hlundin-webrtc
2015/08/27 09:54:03
Done.
|
+ rtp_header.header.sequenceNumber += 1; |
Peter Kasting
2015/08/27 08:45:33
Nit: ++rtp_header.header.sequenceNumber;
hlundin-webrtc
2015/08/27 09:54:03
Done.
|
+ } |
+ EXPECT_EQ(1u, packet_buffer_->NumPacketsInBuffer()); |
+ |
+ // Ask for network statistics. This should not crash. |
+ NetEqNetworkStatistics stats; |
+ EXPECT_EQ(NetEq::kOK, neteq_->NetworkStatistics(&stats)); |
+} |
} // namespace webrtc |