OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_ | |
12 #define WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_ | |
13 | |
14 #include <vector> | |
15 | |
16 #include "webrtc/base/criticalsection.h" | |
17 #include "webrtc/base/scoped_ptr.h" | |
18 #include "webrtc/base/thread_annotations.h" | |
19 #include "webrtc/modules/video_coding/packet.h" | |
20 | |
21 namespace webrtc { | |
22 namespace video_coding { | |
23 | |
24 class FrameObject; | |
25 class RtpFrameObject; | |
26 | |
27 class OnCompleteFrameCallback { | |
28 public: | |
29 virtual ~OnCompleteFrameCallback() {} | |
30 virtual void OnCompleteFrame(std::unique_ptr<FrameObject> frame) = 0; | |
31 }; | |
32 | |
33 class PacketBuffer { | |
34 public: | |
35 PacketBuffer(int start_buffer_size, | |
stefan-webrtc
2016/03/17 12:06:31
size_t here and below
philipel
2016/03/17 15:00:35
Done.
| |
36 int max_buffer_size, | |
37 OnCompleteFrameCallback* frame_callback); | |
38 bool InsertPacket(const VCMPacket& packet); | |
39 void ClearUpTo(uint16_t seq_num); | |
40 void Flush(); | |
41 | |
42 private: | |
43 friend RtpFrameObject; | |
44 // Since we want the packet buffer to be as packet type agnostic | |
45 // as possible we extract only the information needed in order | |
46 // to determin whether a sequence of packets is continuous or not. | |
47 struct ContinuityInfo { | |
48 uint16_t seq_num = 0; | |
49 bool frame_begin = false; | |
50 bool frame_end = false; | |
51 bool used = false; | |
52 bool continuous = false; | |
53 }; | |
54 | |
55 bool ExpandBufferSize() EXCLUSIVE_LOCKS_REQUIRED(crit_); | |
56 bool IsContinous(uint16_t seq_num) const EXCLUSIVE_LOCKS_REQUIRED(crit_); | |
stefan-webrtc
2016/03/17 12:06:31
IsContinuous
philipel
2016/03/17 15:00:36
Done.
| |
57 void FindCompleteFrames(uint16_t seq_num) EXCLUSIVE_LOCKS_REQUIRED(crit_); | |
58 | |
59 // Buffer size_ and max_size_ must always be a power of two. | |
60 int size_ GUARDED_BY(crit_); | |
61 const int max_size_; | |
62 | |
63 rtc::CriticalSection crit_; | |
64 uint16_t clear_up_to_ GUARDED_BY(crit_); | |
stefan-webrtc
2016/03/17 12:06:31
Group all members guarded by the crit
philipel
2016/03/17 15:00:35
Done.
| |
65 bool initialized_ GUARDED_BY(crit_); | |
66 std::vector<VCMPacket> data_buffer_ GUARDED_BY(crit_); | |
67 std::vector<ContinuityInfo> sequence_buffer_ GUARDED_BY(crit_); | |
68 OnCompleteFrameCallback* const frame_callback_; | |
69 }; | |
70 | |
71 } // namespace video_coding | |
72 } // namespace webrtc | |
73 | |
74 #endif // WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_ | |
OLD | NEW |