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}
diff --git a/webrtc/modules/video_coding/packet_buffer.h b/webrtc/modules/video_coding/packet_buffer.h
index 3d9eb9c..d5011b6 100644
--- a/webrtc/modules/video_coding/packet_buffer.h
+++ b/webrtc/modules/video_coding/packet_buffer.h
@@ -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 @@
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 @@
// 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 @@
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;
};