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

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

Issue 2199133004: PacketBuffer is now ref counted. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: PacketBuffer/RtpFrameReferenceFinder can now be stopped. Created 4 years, 4 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 <vector> 14 #include <vector>
15 15
16 #include "webrtc/base/criticalsection.h" 16 #include "webrtc/base/criticalsection.h"
17 #include "webrtc/base/refcount.h"
danilchap 2016/08/02 15:29:34 not needed now
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 {
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 void Stop();
52
53 int AddRef() const;
54 int Release() const;
55
56 private:
40 // Both |start_buffer_size| and |max_buffer_size| must be a power of 2. 57 // Both |start_buffer_size| and |max_buffer_size| must be a power of 2.
41 PacketBuffer(Clock* clock, 58 PacketBuffer(Clock* clock,
42 size_t start_buffer_size, 59 size_t start_buffer_size,
43 size_t max_buffer_size, 60 size_t max_buffer_size,
44 OnCompleteFrameCallback* frame_callback); 61 OnCompleteFrameCallback* frame_callback);
45 62
46 bool InsertPacket(const VCMPacket& packet);
47 void ClearTo(uint16_t seq_num);
48 void Clear();
49
50 private:
51 friend RtpFrameObject; 63 friend RtpFrameObject;
52 // Since we want the packet buffer to be as packet type agnostic 64 // Since we want the packet buffer to be as packet type agnostic
53 // as possible we extract only the information needed in order 65 // as possible we extract only the information needed in order
54 // to determine whether a sequence of packets is continuous or not. 66 // to determine whether a sequence of packets is continuous or not.
55 struct ContinuityInfo { 67 struct ContinuityInfo {
56 // The sequence number of the packet. 68 // The sequence number of the packet.
57 uint16_t seq_num = 0; 69 uint16_t seq_num = 0;
58 70
59 // If this is the first packet of the frame. 71 // If this is the first packet of the frame.
60 bool frame_begin = false; 72 bool frame_begin = false;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // Buffer that holds the inserted packets. 123 // Buffer that holds the inserted packets.
112 std::vector<VCMPacket> data_buffer_ GUARDED_BY(crit_); 124 std::vector<VCMPacket> data_buffer_ GUARDED_BY(crit_);
113 125
114 // Buffer that holds the information about which slot that is currently in use 126 // Buffer that holds the information about which slot that is currently in use
115 // and information needed to determine the continuity between packets. 127 // and information needed to determine the continuity between packets.
116 std::vector<ContinuityInfo> sequence_buffer_ GUARDED_BY(crit_); 128 std::vector<ContinuityInfo> sequence_buffer_ GUARDED_BY(crit_);
117 129
118 // Frames that have received all their packets are handed off to the 130 // Frames that have received all their packets are handed off to the
119 // |reference_finder_| which finds the dependencies between the frames. 131 // |reference_finder_| which finds the dependencies between the frames.
120 RtpFrameReferenceFinder reference_finder_; 132 RtpFrameReferenceFinder reference_finder_;
133
134 mutable volatile int ref_count_ = 0;
121 }; 135 };
122 136
123 } // namespace video_coding 137 } // namespace video_coding
124 } // namespace webrtc 138 } // namespace webrtc
125 139
126 #endif // WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_ 140 #endif // WEBRTC_MODULES_VIDEO_CODING_PACKET_BUFFER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698