Fixed bug in PacketBuffer to correctly detect new complete frames after ClearTo has been called.
BUG=webrtc:5514 R=stefan@webrtc.org, terelius@webrtc.org Review URL: https://codereview.webrtc.org/2527903002 . Cr-Commit-Position: refs/heads/master@{#15269}
This commit is contained in:
@ -172,16 +172,8 @@ bool PacketBuffer::PotentialNewFrame(uint16_t seq_num) const {
|
||||
return false;
|
||||
if (sequence_buffer_[index].frame_created)
|
||||
return false;
|
||||
if (sequence_buffer_[index].frame_begin &&
|
||||
(!sequence_buffer_[prev_index].used ||
|
||||
AheadOf(seq_num, sequence_buffer_[prev_index].seq_num))) {
|
||||
// The reason we only return true if this packet is the first packet of the
|
||||
// frame and the sequence number is newer than the packet with the previous
|
||||
// index is because we want to avoid an inifite loop in the case where
|
||||
// a single frame containing more packets than the current size of the
|
||||
// packet buffer is inserted.
|
||||
if (sequence_buffer_[index].frame_begin)
|
||||
return true;
|
||||
}
|
||||
if (!sequence_buffer_[prev_index].used)
|
||||
return false;
|
||||
if (sequence_buffer_[prev_index].seq_num !=
|
||||
@ -197,7 +189,8 @@ bool PacketBuffer::PotentialNewFrame(uint16_t seq_num) const {
|
||||
std::vector<std::unique_ptr<RtpFrameObject>> PacketBuffer::FindFrames(
|
||||
uint16_t seq_num) {
|
||||
std::vector<std::unique_ptr<RtpFrameObject>> found_frames;
|
||||
while (PotentialNewFrame(seq_num)) {
|
||||
size_t packets_tested = 0;
|
||||
while (packets_tested < size_ && PotentialNewFrame(seq_num)) {
|
||||
size_t index = seq_num % size_;
|
||||
sequence_buffer_[index].continuous = true;
|
||||
|
||||
@ -229,6 +222,7 @@ std::vector<std::unique_ptr<RtpFrameObject>> PacketBuffer::FindFrames(
|
||||
max_nack_count, clock_->TimeInMilliseconds()));
|
||||
}
|
||||
++seq_num;
|
||||
++packets_tested;
|
||||
}
|
||||
return found_frames;
|
||||
}
|
||||
|
@ -425,5 +425,18 @@ TEST_F(TestPacketBuffer, InvalidateFrameByClearing) {
|
||||
EXPECT_FALSE(frames_from_callback_.begin()->second->GetBitstream(nullptr));
|
||||
}
|
||||
|
||||
TEST_F(TestPacketBuffer, FramesAfterClear) {
|
||||
Insert(9025, kDeltaFrame, kFirst, kLast);
|
||||
Insert(9024, kKeyFrame, kFirst, kLast);
|
||||
packet_buffer_->ClearTo(9025);
|
||||
Insert(9057, kDeltaFrame, kFirst, kLast);
|
||||
Insert(9026, kDeltaFrame, kFirst, kLast);
|
||||
|
||||
CheckFrame(9024);
|
||||
CheckFrame(9025);
|
||||
CheckFrame(9026);
|
||||
CheckFrame(9057);
|
||||
}
|
||||
|
||||
} // namespace video_coding
|
||||
} // namespace webrtc
|
||||
|
Reference in New Issue
Block a user