OLD | NEW |
---|---|
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 <vector> | 14 #include <vector> |
15 | 15 |
16 #include "webrtc/base/criticalsection.h" | 16 #include "webrtc/base/criticalsection.h" |
17 #include "webrtc/base/refcount.h" | |
18 #include "webrtc/base/scoped_ref_ptr.h" | |
17 #include "webrtc/base/thread_annotations.h" | 19 #include "webrtc/base/thread_annotations.h" |
18 #include "webrtc/modules/include/module_common_types.h" | 20 #include "webrtc/modules/include/module_common_types.h" |
19 #include "webrtc/modules/video_coding/packet.h" | 21 #include "webrtc/modules/video_coding/packet.h" |
20 #include "webrtc/modules/video_coding/rtp_frame_reference_finder.h" | 22 #include "webrtc/modules/video_coding/rtp_frame_reference_finder.h" |
21 #include "webrtc/modules/video_coding/sequence_number_util.h" | 23 #include "webrtc/modules/video_coding/sequence_number_util.h" |
22 | 24 |
23 namespace webrtc { | 25 namespace webrtc { |
24 | 26 |
25 class Clock; | 27 class Clock; |
26 | 28 |
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 { |
33 public: | 35 public: |
34 virtual ~OnCompleteFrameCallback() {} | 36 virtual ~OnCompleteFrameCallback() {} |
35 virtual void OnCompleteFrame(std::unique_ptr<FrameObject> frame) = 0; | 37 virtual void OnCompleteFrame(std::unique_ptr<FrameObject> frame) = 0; |
36 }; | 38 }; |
37 | 39 |
38 class PacketBuffer { | 40 class PacketBuffer : rtc::RefCountInterface { |
danilchap
2016/08/02 14:04:45
Do you need to derive from this interface?
If you
philipel
2016/08/02 14:39:59
Removed inheritance.
| |
39 public: | 41 public: |
42 static rtc::scoped_refptr<PacketBuffer> Create( | |
43 Clock* clock, | |
44 size_t start_buffer_size, | |
45 size_t max_buffer_size, | |
46 OnCompleteFrameCallback* frame_callback); | |
47 | |
48 bool InsertPacket(const VCMPacket& packet); | |
49 void ClearTo(uint16_t seq_num); | |
50 void Clear(); | |
51 | |
52 int AddRef() const; | |
53 int Release() const; | |
54 | |
55 private: | |
40 // Both |start_buffer_size| and |max_buffer_size| must be a power of 2. | 56 // Both |start_buffer_size| and |max_buffer_size| must be a power of 2. |
41 PacketBuffer(Clock* clock, | 57 PacketBuffer(Clock* clock, |
42 size_t start_buffer_size, | 58 size_t start_buffer_size, |
43 size_t max_buffer_size, | 59 size_t max_buffer_size, |
44 OnCompleteFrameCallback* frame_callback); | 60 OnCompleteFrameCallback* frame_callback); |
45 | 61 |
46 bool InsertPacket(const VCMPacket& packet); | |
47 void ClearTo(uint16_t seq_num); | |
48 void Clear(); | |
49 | |
50 private: | |
51 friend RtpFrameObject; | 62 friend RtpFrameObject; |
52 // Since we want the packet buffer to be as packet type agnostic | 63 // Since we want the packet buffer to be as packet type agnostic |
53 // as possible we extract only the information needed in order | 64 // as possible we extract only the information needed in order |
54 // to determine whether a sequence of packets is continuous or not. | 65 // to determine whether a sequence of packets is continuous or not. |
55 struct ContinuityInfo { | 66 struct ContinuityInfo { |
56 // The sequence number of the packet. | 67 // The sequence number of the packet. |
57 uint16_t seq_num = 0; | 68 uint16_t seq_num = 0; |
58 | 69 |
59 // If this is the first packet of the frame. | 70 // If this is the first packet of the frame. |
60 bool frame_begin = false; | 71 bool frame_begin = false; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 // Buffer that holds the inserted packets. | 122 // Buffer that holds the inserted packets. |
112 std::vector<VCMPacket> data_buffer_ GUARDED_BY(crit_); | 123 std::vector<VCMPacket> data_buffer_ GUARDED_BY(crit_); |
113 | 124 |
114 // Buffer that holds the information about which slot that is currently in use | 125 // Buffer that holds the information about which slot that is currently in use |
115 // and information needed to determine the continuity between packets. | 126 // and information needed to determine the continuity between packets. |
116 std::vector<ContinuityInfo> sequence_buffer_ GUARDED_BY(crit_); | 127 std::vector<ContinuityInfo> sequence_buffer_ GUARDED_BY(crit_); |
117 | 128 |
118 // Frames that have received all their packets are handed off to the | 129 // Frames that have received all their packets are handed off to the |
119 // |reference_finder_| which finds the dependencies between the frames. | 130 // |reference_finder_| which finds the dependencies between the frames. |
120 RtpFrameReferenceFinder reference_finder_; | 131 RtpFrameReferenceFinder reference_finder_; |
132 | |
133 mutable volatile int ref_count_ = 0; | |
121 }; | 134 }; |
122 | 135 |
123 } // namespace video_coding | 136 } // namespace video_coding |
124 } // namespace webrtc | 137 } // namespace webrtc |
125 | 138 |
126 #endif // WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_ | 139 #endif // WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_ |
OLD | NEW |