Don't detect a new frame if a previous packet is used in a previous frame.

In this CL:
 - Removed unused variable |last_seq_num_|.
 - Fixed bug where a new incomplete frame was detected as a complete frame.
 - Added fuzzer to video_coding::PacketBuffer.

BUG=chromium:677101

Review-Url: https://codereview.webrtc.org/2613833003
Cr-Commit-Position: refs/heads/master@{#16003}
This commit is contained in:
philipel
2017-01-11 02:01:56 -08:00
committed by Commit bot
parent cecf86e9b0
commit ea142f8de3
5 changed files with 67 additions and 8 deletions

View File

@ -40,7 +40,6 @@ PacketBuffer::PacketBuffer(Clock* clock,
size_(start_buffer_size),
max_size_(max_buffer_size),
first_seq_num_(0),
last_seq_num_(0),
first_packet_received_(false),
is_cleared_to_first_seq_num_(false),
data_buffer_(start_buffer_size),
@ -65,7 +64,6 @@ bool PacketBuffer::InsertPacket(VCMPacket* packet) {
if (!first_packet_received_) {
first_seq_num_ = seq_num;
last_seq_num_ = seq_num;
first_packet_received_ = true;
} else if (AheadOf(first_seq_num_, seq_num)) {
// If we have explicitly cleared past this packet then it's old,
@ -100,9 +98,6 @@ bool PacketBuffer::InsertPacket(VCMPacket* packet) {
}
}
if (AheadOf(seq_num, last_seq_num_))
last_seq_num_ = seq_num;
sequence_buffer_[index].frame_begin = packet->is_first_packet_in_frame;
sequence_buffer_[index].frame_end = packet->markerBit;
sequence_buffer_[index].seq_num = packet->seqNum;
@ -186,6 +181,8 @@ bool PacketBuffer::PotentialNewFrame(uint16_t seq_num) const {
return true;
if (!sequence_buffer_[prev_index].used)
return false;
if (sequence_buffer_[prev_index].frame_created)
return false;
if (sequence_buffer_[prev_index].seq_num !=
static_cast<uint16_t>(sequence_buffer_[index].seq_num - 1)) {
return false;

View File

@ -126,9 +126,6 @@ class PacketBuffer {
// The fist sequence number currently in the buffer.
uint16_t first_seq_num_ GUARDED_BY(crit_);
// The last sequence number currently in the buffer.
uint16_t last_seq_num_ GUARDED_BY(crit_);
// If the packet buffer has received its first packet.
bool first_packet_received_ GUARDED_BY(crit_);

View File

@ -468,5 +468,14 @@ TEST_F(TestPacketBuffer, DontLeakPayloadData) {
EXPECT_FALSE(Insert(2 + kMaxSize, kKeyFrame, kFirst, kNotLast, 5, data4));
}
TEST_F(TestPacketBuffer, ContinuousSeqNumDoubleMarkerBit) {
Insert(2, kKeyFrame, kNotFirst, kNotLast);
Insert(1, kKeyFrame, kFirst, kLast);
frames_from_callback_.clear();
Insert(3, kKeyFrame, kNotFirst, kLast);
EXPECT_EQ(0UL, frames_from_callback_.size());
}
} // namespace video_coding
} // namespace webrtc