Don't clear newer packets from the video_coding::PacketBuffer when calling ClearTo.

BUG=webrtc:8060

Review-Url: https://codereview.webrtc.org/2987013002
Cr-Commit-Position: refs/heads/master@{#19212}
This commit is contained in:
philipel
2017-08-02 04:28:57 -07:00
committed by Commit Bot
parent c18f1d7c94
commit c5fb4683e5
2 changed files with 46 additions and 5 deletions

View File

@ -303,6 +303,30 @@ TEST_F(TestPacketBuffer, ClearSinglePacket) {
EXPECT_TRUE(Insert(seq_num + kMaxSize, kDeltaFrame, kFirst, kLast));
}
TEST_F(TestPacketBuffer, ClearFullBuffer) {
for (int i = 0; i < kMaxSize; ++i)
EXPECT_TRUE(Insert(i, kDeltaFrame, kFirst, kLast));
packet_buffer_->ClearTo(kMaxSize - 1);
for (int i = kMaxSize; i < 2 * kMaxSize; ++i)
EXPECT_TRUE(Insert(i, kDeltaFrame, kFirst, kLast));
}
TEST_F(TestPacketBuffer, DontClearNewerPacket) {
EXPECT_TRUE(Insert(0, kKeyFrame, kFirst, kLast));
packet_buffer_->ClearTo(0);
EXPECT_TRUE(Insert(2 * kStartSize, kKeyFrame, kFirst, kLast));
EXPECT_TRUE(Insert(3 * kStartSize + 1, kKeyFrame, kFirst, kNotLast));
packet_buffer_->ClearTo(2 * kStartSize);
EXPECT_TRUE(Insert(3 * kStartSize + 2, kKeyFrame, kNotFirst, kLast));
ASSERT_EQ(3UL, frames_from_callback_.size());
CheckFrame(0);
CheckFrame(2 * kStartSize);
CheckFrame(3 * kStartSize + 1);
}
TEST_F(TestPacketBuffer, OneIncompleteFrame) {
const uint16_t seq_num = Rand();