Clear PacketBuffer when full.
BUG=webrtc:5514
Review-Url: https://codereview.webrtc.org/2769963003
Cr-Commit-Position: refs/heads/master@{#17362}
diff --git a/webrtc/modules/video_coding/packet_buffer.cc b/webrtc/modules/video_coding/packet_buffer.cc
index f30a3ea..3b0d09f 100644
--- a/webrtc/modules/video_coding/packet_buffer.cc
+++ b/webrtc/modules/video_coding/packet_buffer.cc
@@ -148,7 +148,8 @@
bool PacketBuffer::ExpandBufferSize() {
if (size_ == max_size_) {
LOG(LS_WARNING) << "PacketBuffer is already at max size (" << max_size_
- << "), failed to increase size.";
+ << "), failed to increase size. Clearing PacketBuffer.";
+ Clear();
return false;
}
diff --git a/webrtc/modules/video_coding/video_packet_buffer_unittest.cc b/webrtc/modules/video_coding/video_packet_buffer_unittest.cc
index d938b8b..0af60b3 100644
--- a/webrtc/modules/video_coding/video_packet_buffer_unittest.cc
+++ b/webrtc/modules/video_coding/video_packet_buffer_unittest.cc
@@ -212,7 +212,7 @@
for (int i = 0; i < kMaxSize; ++i)
EXPECT_TRUE(Insert(seq_num + i, kKeyFrame, kFirst, kLast));
- EXPECT_FALSE(Insert(seq_num + kMaxSize + 1, kKeyFrame, kFirst, kLast));
+ EXPECT_TRUE(Insert(seq_num + kMaxSize + 1, kKeyFrame, kFirst, kLast));
}
TEST_F(TestPacketBuffer, OnePacketOneFrame) {
@@ -465,7 +465,7 @@
EXPECT_FALSE(Insert(1, kKeyFrame, kFirst, kNotLast, 5, data3));
// Expect to free data4 upon insertion (packet buffer is full).
- EXPECT_FALSE(Insert(2 + kMaxSize, kKeyFrame, kFirst, kNotLast, 5, data4));
+ EXPECT_TRUE(Insert(2 + kMaxSize, kKeyFrame, kFirst, kNotLast, 5, data4));
}
TEST_F(TestPacketBuffer, ContinuousSeqNumDoubleMarkerBit) {