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

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

Issue 1903523003: Convert Vp9 Rtp headers to frame references. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added comments. Created 4 years, 8 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
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 <array> 14 #include <array>
15 #include <utility>
15 #include <vector> 16 #include <vector>
16 #include <map> 17 #include <map>
17 #include <set> 18 #include <set>
18 #include <queue> 19 #include <queue>
19 20
20 #include "webrtc/base/criticalsection.h" 21 #include "webrtc/base/criticalsection.h"
21 #include "webrtc/base/scoped_ptr.h" 22 #include "webrtc/base/scoped_ptr.h"
22 #include "webrtc/base/thread_annotations.h" 23 #include "webrtc/base/thread_annotations.h"
24 #include "webrtc/modules/include/module_common_types.h"
23 #include "webrtc/modules/video_coding/packet.h" 25 #include "webrtc/modules/video_coding/packet.h"
24 #include "webrtc/modules/video_coding/sequence_number_util.h" 26 #include "webrtc/modules/video_coding/sequence_number_util.h"
25 27
26 namespace webrtc { 28 namespace webrtc {
27 namespace video_coding { 29 namespace video_coding {
28 30
29 class FrameObject; 31 class FrameObject;
30 class RtpFrameObject; 32 class RtpFrameObject;
31 33
32 class OnCompleteFrameCallback { 34 class OnCompleteFrameCallback {
(...skipping 12 matching lines...) Expand all
45 bool InsertPacket(const VCMPacket& packet); 47 bool InsertPacket(const VCMPacket& packet);
46 void ClearTo(uint16_t seq_num); 48 void ClearTo(uint16_t seq_num);
47 void Flush(); 49 void Flush();
48 50
49 private: 51 private:
50 static const uint16_t kPicIdLength = 1 << 7; 52 static const uint16_t kPicIdLength = 1 << 7;
51 static const uint8_t kMaxTemporalLayer = 5; 53 static const uint8_t kMaxTemporalLayer = 5;
52 static const int kMaxStashedFrames = 10; 54 static const int kMaxStashedFrames = 10;
53 static const int kMaxLayerInfo = 10; 55 static const int kMaxLayerInfo = 10;
54 static const int kMaxNotYetReceivedFrames = 20; 56 static const int kMaxNotYetReceivedFrames = 20;
57 static const int kMaxGofSaved = 5;
stefan-webrtc 2016/04/26 08:15:12 This constant seems to only be used in the .cc fil
stefan-webrtc 2016/04/26 08:15:12 I wonder if 5 GOFs will actually be enough... It c
philipel 2016/04/28 09:40:42 Increased to 15.
philipel 2016/04/28 09:40:42 This is used on line 193 in the .h file.
55 58
56 friend RtpFrameObject; 59 friend RtpFrameObject;
57 // Since we want the packet buffer to be as packet type agnostic 60 // Since we want the packet buffer to be as packet type agnostic
58 // as possible we extract only the information needed in order 61 // as possible we extract only the information needed in order
59 // to determine whether a sequence of packets is continuous or not. 62 // to determine whether a sequence of packets is continuous or not.
60 struct ContinuityInfo { 63 struct ContinuityInfo {
61 // The sequence number of the packet. 64 // The sequence number of the packet.
62 uint16_t seq_num = 0; 65 uint16_t seq_num = 0;
63 66
64 // If this is the first packet of the frame. 67 // If this is the first packet of the frame.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // Find references for Vp8 frames 111 // Find references for Vp8 frames
109 void ManageFrameVp8(std::unique_ptr<RtpFrameObject> frame) 112 void ManageFrameVp8(std::unique_ptr<RtpFrameObject> frame)
110 EXCLUSIVE_LOCKS_REQUIRED(crit_); 113 EXCLUSIVE_LOCKS_REQUIRED(crit_);
111 114
112 // Updates all necessary state used to determine frame references 115 // Updates all necessary state used to determine frame references
113 // for Vp8 and then calls the |frame_callback| callback with the 116 // for Vp8 and then calls the |frame_callback| callback with the
114 // completed frame. 117 // completed frame.
115 void CompletedFrameVp8(std::unique_ptr<RtpFrameObject> frame) 118 void CompletedFrameVp8(std::unique_ptr<RtpFrameObject> frame)
116 EXCLUSIVE_LOCKS_REQUIRED(crit_); 119 EXCLUSIVE_LOCKS_REQUIRED(crit_);
117 120
121 // Find references for Vp9 frames
122 void ManageFrameVp9(std::unique_ptr<RtpFrameObject> frame)
123 EXCLUSIVE_LOCKS_REQUIRED(crit_);
124
125 // Unwrap the picture id and the frame references and then call the
126 // |frame_callback| callback with the completed frame.
127 void CompletedFrameVp9(std::unique_ptr<RtpFrameObject> frame)
128 EXCLUSIVE_LOCKS_REQUIRED(crit_);
129
118 // All picture ids are unwrapped to 16 bits. 130 // All picture ids are unwrapped to 16 bits.
119 uint16_t UnwrapPictureId(uint16_t picture_id) 131 uint16_t UnwrapPictureId(uint16_t picture_id)
120 EXCLUSIVE_LOCKS_REQUIRED(crit_); 132 EXCLUSIVE_LOCKS_REQUIRED(crit_);
121 133
122 rtc::CriticalSection crit_; 134 rtc::CriticalSection crit_;
123 135
124 // Buffer size_ and max_size_ must always be a power of two. 136 // Buffer size_ and max_size_ must always be a power of two.
125 size_t size_ GUARDED_BY(crit_); 137 size_t size_ GUARDED_BY(crit_);
126 const size_t max_size_; 138 const size_t max_size_;
127 139
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 177
166 // Frames that have been fully received but didn't have all the information 178 // Frames that have been fully received but didn't have all the information
167 // needed to determine their references. 179 // needed to determine their references.
168 std::queue<std::unique_ptr<RtpFrameObject>> stashed_frames_ GUARDED_BY(crit_); 180 std::queue<std::unique_ptr<RtpFrameObject>> stashed_frames_ GUARDED_BY(crit_);
169 181
170 // Holds the information about the last completed frame for a given temporal 182 // Holds the information about the last completed frame for a given temporal
171 // layer given a Tl0 picture index. 183 // layer given a Tl0 picture index.
172 std::map<uint8_t, 184 std::map<uint8_t,
173 std::array<int16_t, kMaxTemporalLayer>, 185 std::array<int16_t, kMaxTemporalLayer>,
174 DescendingSeqNumComp<uint8_t>> layer_info_ GUARDED_BY(crit_); 186 DescendingSeqNumComp<uint8_t>> layer_info_ GUARDED_BY(crit_);
187
188 // Where the current scalability structure is in the
189 // |scalability_structures_| array.
190 uint8_t current_ss_idx_;
191
192 // Holds received scalability structures.
193 std::array<GofInfoVP9, kMaxGofSaved>
194 scalability_structures_ GUARDED_BY(crit_);
195
196 // Holds the picture id and the Gof information for a given TL0 picture index.
197 std::map<uint8_t,
198 std::pair<uint16_t, GofInfoVP9*>,
199 DescendingSeqNumComp<uint8_t>> gof_info_ GUARDED_BY(crit_);
175 }; 200 };
176 201
177 } // namespace video_coding 202 } // namespace video_coding
178 } // namespace webrtc 203 } // namespace webrtc
179 204
180 #endif // WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_ 205 #endif // WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698