Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: webrtc/modules/video_coding/packet_buffer.h

Issue 2926083002: Only create H264 frames if there are no gaps in the packet sequence number. (Closed)
Patch Set: Rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/modules/video_coding/packet_buffer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_ 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_
12 #define WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_ 12 #define WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_
13 13
14 #include <memory>
15 #include <set>
14 #include <vector> 16 #include <vector>
15 #include <memory>
16 17
17 #include "webrtc/base/criticalsection.h" 18 #include "webrtc/base/criticalsection.h"
18 #include "webrtc/base/scoped_ref_ptr.h" 19 #include "webrtc/base/scoped_ref_ptr.h"
19 #include "webrtc/base/thread_annotations.h" 20 #include "webrtc/base/thread_annotations.h"
20 #include "webrtc/modules/include/module_common_types.h" 21 #include "webrtc/modules/include/module_common_types.h"
21 #include "webrtc/modules/video_coding/packet.h" 22 #include "webrtc/modules/video_coding/packet.h"
22 #include "webrtc/modules/video_coding/rtp_frame_reference_finder.h" 23 #include "webrtc/modules/video_coding/rtp_frame_reference_finder.h"
23 #include "webrtc/modules/video_coding/sequence_number_util.h" 24 #include "webrtc/modules/video_coding/sequence_number_util.h"
24 25
25 namespace webrtc { 26 namespace webrtc {
(...skipping 21 matching lines...) Expand all
47 OnReceivedFrameCallback* frame_callback); 48 OnReceivedFrameCallback* frame_callback);
48 49
49 virtual ~PacketBuffer(); 50 virtual ~PacketBuffer();
50 51
51 // Returns true if |packet| is inserted into the packet buffer, false 52 // Returns true if |packet| is inserted into the packet buffer, false
52 // otherwise. The PacketBuffer will always take ownership of the 53 // otherwise. The PacketBuffer will always take ownership of the
53 // |packet.dataPtr| when this function is called. Made virtual for testing. 54 // |packet.dataPtr| when this function is called. Made virtual for testing.
54 virtual bool InsertPacket(VCMPacket* packet); 55 virtual bool InsertPacket(VCMPacket* packet);
55 void ClearTo(uint16_t seq_num); 56 void ClearTo(uint16_t seq_num);
56 void Clear(); 57 void Clear();
58 void PaddingReceived(uint16_t seq_num);
57 59
58 // Timestamp (not RTP timestamp) of the last received packet/keyframe packet. 60 // Timestamp (not RTP timestamp) of the last received packet/keyframe packet.
59 rtc::Optional<int64_t> LastReceivedPacketMs() const; 61 rtc::Optional<int64_t> LastReceivedPacketMs() const;
60 rtc::Optional<int64_t> LastReceivedKeyframePacketMs() const; 62 rtc::Optional<int64_t> LastReceivedKeyframePacketMs() const;
61 63
62 int AddRef() const; 64 int AddRef() const;
63 int Release() const; 65 int Release() const;
64 66
65 protected: 67 protected:
66 // Both |start_buffer_size| and |max_buffer_size| must be a power of 2. 68 // Both |start_buffer_size| and |max_buffer_size| must be a power of 2.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 116
115 // Get the packet with sequence number |seq_num|. 117 // Get the packet with sequence number |seq_num|.
116 // Virtual for testing. 118 // Virtual for testing.
117 virtual VCMPacket* GetPacket(uint16_t seq_num) 119 virtual VCMPacket* GetPacket(uint16_t seq_num)
118 EXCLUSIVE_LOCKS_REQUIRED(crit_); 120 EXCLUSIVE_LOCKS_REQUIRED(crit_);
119 121
120 // Mark all slots used by |frame| as not used. 122 // Mark all slots used by |frame| as not used.
121 // Virtual for testing. 123 // Virtual for testing.
122 virtual void ReturnFrame(RtpFrameObject* frame); 124 virtual void ReturnFrame(RtpFrameObject* frame);
123 125
126 void UpdateMissingPackets(uint16_t seq_num) EXCLUSIVE_LOCKS_REQUIRED(crit_);
127
124 rtc::CriticalSection crit_; 128 rtc::CriticalSection crit_;
125 129
126 // Buffer size_ and max_size_ must always be a power of two. 130 // Buffer size_ and max_size_ must always be a power of two.
127 size_t size_ GUARDED_BY(crit_); 131 size_t size_ GUARDED_BY(crit_);
128 const size_t max_size_; 132 const size_t max_size_;
129 133
130 // The fist sequence number currently in the buffer. 134 // The fist sequence number currently in the buffer.
131 uint16_t first_seq_num_ GUARDED_BY(crit_); 135 uint16_t first_seq_num_ GUARDED_BY(crit_);
132 136
133 // If the packet buffer has received its first packet. 137 // If the packet buffer has received its first packet.
134 bool first_packet_received_ GUARDED_BY(crit_); 138 bool first_packet_received_ GUARDED_BY(crit_);
135 139
136 // If the buffer is cleared to |first_seq_num_|. 140 // If the buffer is cleared to |first_seq_num_|.
137 bool is_cleared_to_first_seq_num_ GUARDED_BY(crit_); 141 bool is_cleared_to_first_seq_num_ GUARDED_BY(crit_);
138 142
139 // Buffer that holds the inserted packets. 143 // Buffer that holds the inserted packets.
140 std::vector<VCMPacket> data_buffer_ GUARDED_BY(crit_); 144 std::vector<VCMPacket> data_buffer_ GUARDED_BY(crit_);
141 145
142 // Buffer that holds the information about which slot that is currently in use 146 // Buffer that holds the information about which slot that is currently in use
143 // and information needed to determine the continuity between packets. 147 // and information needed to determine the continuity between packets.
144 std::vector<ContinuityInfo> sequence_buffer_ GUARDED_BY(crit_); 148 std::vector<ContinuityInfo> sequence_buffer_ GUARDED_BY(crit_);
145 149
146 // Called when a received frame is found. 150 // Called when a received frame is found.
147 OnReceivedFrameCallback* const received_frame_callback_; 151 OnReceivedFrameCallback* const received_frame_callback_;
148 152
149 // Timestamp (not RTP timestamp) of the last received packet/keyframe packet. 153 // Timestamp (not RTP timestamp) of the last received packet/keyframe packet.
150 rtc::Optional<int64_t> last_received_packet_ms_ GUARDED_BY(crit_); 154 rtc::Optional<int64_t> last_received_packet_ms_ GUARDED_BY(crit_);
151 rtc::Optional<int64_t> last_received_keyframe_packet_ms_ GUARDED_BY(crit_); 155 rtc::Optional<int64_t> last_received_keyframe_packet_ms_ GUARDED_BY(crit_);
152 156
157 rtc::Optional<uint16_t> newest_inserted_seq_num_ GUARDED_BY(crit_);
158 std::set<uint16_t, DescendingSeqNumComp<uint16_t>> missing_packets_
159 GUARDED_BY(crit_);
160
153 mutable volatile int ref_count_ = 0; 161 mutable volatile int ref_count_ = 0;
154 }; 162 };
155 163
156 } // namespace video_coding 164 } // namespace video_coding
157 } // namespace webrtc 165 } // namespace webrtc
158 166
159 #endif // WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_ 167 #endif // WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/video_coding/packet_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698