Only create H264 frames if there are no gaps in the packet sequence number.

In the case of H264 we can't know which packet that is the fist packet of a
frame. In order to avoid creating incomplete frames we keep track of which
packets that we haven't received, and if there is a gap in the packet sequence
number leading up to this frame then a frame wont be created.

BUG=chromium:716558

Review-Url: https://codereview.webrtc.org/2926083002
Cr-Commit-Position: refs/heads/master@{#18559}
This commit is contained in:
philipel
2017-06-13 02:47:28 -07:00
committed by Commit Bot
parent fc309750a9
commit 2c9f9f2bc9
4 changed files with 159 additions and 46 deletions

View File

@ -11,8 +11,9 @@
#ifndef WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_
#define WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_
#include <vector>
#include <memory>
#include <set>
#include <vector>
#include "webrtc/base/criticalsection.h"
#include "webrtc/base/scoped_ref_ptr.h"
@ -54,6 +55,7 @@ class PacketBuffer {
virtual bool InsertPacket(VCMPacket* packet);
void ClearTo(uint16_t seq_num);
void Clear();
void PaddingReceived(uint16_t seq_num);
// Timestamp (not RTP timestamp) of the last received packet/keyframe packet.
rtc::Optional<int64_t> LastReceivedPacketMs() const;
@ -121,6 +123,8 @@ class PacketBuffer {
// Virtual for testing.
virtual void ReturnFrame(RtpFrameObject* frame);
void UpdateMissingPackets(uint16_t seq_num) EXCLUSIVE_LOCKS_REQUIRED(crit_);
rtc::CriticalSection crit_;
// Buffer size_ and max_size_ must always be a power of two.
@ -150,6 +154,10 @@ class PacketBuffer {
rtc::Optional<int64_t> last_received_packet_ms_ GUARDED_BY(crit_);
rtc::Optional<int64_t> last_received_keyframe_packet_ms_ GUARDED_BY(crit_);
rtc::Optional<uint16_t> newest_inserted_seq_num_ GUARDED_BY(crit_);
std::set<uint16_t, DescendingSeqNumComp<uint16_t>> missing_packets_
GUARDED_BY(crit_);
mutable volatile int ref_count_ = 0;
};