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

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

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 #include "webrtc/modules/video_coding/packet_buffer.h" 11 #include "webrtc/modules/video_coding/packet_buffer.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <limits> 14 #include <limits>
15 15
16 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
17 #include "webrtc/base/logging.h" 17 #include "webrtc/base/logging.h"
18 #include "webrtc/modules/video_coding/frame_object.h" 18 #include "webrtc/modules/video_coding/frame_object.h"
19 #include "webrtc/system_wrappers/include/clock.h" 19 #include "webrtc/system_wrappers/include/clock.h"
20 20
21 namespace webrtc { 21 namespace webrtc {
22 namespace video_coding { 22 namespace video_coding {
23 23
24 rtc::scoped_refptr<PacketBuffer> PacketBuffer::Create(
25 Clock* clock,
26 size_t start_buffer_size,
27 size_t max_buffer_size,
28 OnCompleteFrameCallback* frame_callback) {
29 return rtc::scoped_refptr<PacketBuffer>(new PacketBuffer(clock,
30 start_buffer_size, max_buffer_size, frame_callback));
31 }
32
24 PacketBuffer::PacketBuffer(Clock* clock, 33 PacketBuffer::PacketBuffer(Clock* clock,
25 size_t start_buffer_size, 34 size_t start_buffer_size,
26 size_t max_buffer_size, 35 size_t max_buffer_size,
27 OnCompleteFrameCallback* frame_callback) 36 OnCompleteFrameCallback* frame_callback)
28 : clock_(clock), 37 : clock_(clock),
29 size_(start_buffer_size), 38 size_(start_buffer_size),
30 max_size_(max_buffer_size), 39 max_size_(max_buffer_size),
31 first_seq_num_(0), 40 first_seq_num_(0),
32 last_seq_num_(0), 41 last_seq_num_(0),
33 first_packet_received_(false), 42 first_packet_received_(false),
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } 241 }
233 242
234 void PacketBuffer::Clear() { 243 void PacketBuffer::Clear() {
235 rtc::CritScope lock(&crit_); 244 rtc::CritScope lock(&crit_);
236 for (size_t i = 0; i < size_; ++i) 245 for (size_t i = 0; i < size_; ++i)
237 sequence_buffer_[i].used = false; 246 sequence_buffer_[i].used = false;
238 247
239 first_packet_received_ = false; 248 first_packet_received_ = false;
240 } 249 }
241 250
251 void PacketBuffer::Stop() {
252 rtc::CritScope lock(&crit_);
253 reference_finder_.Stop();
254 }
255
256 int PacketBuffer::AddRef() const {
257 return rtc::AtomicOps::Increment(&ref_count_);
258 }
259
260 int PacketBuffer::Release() const {
261 int count = rtc::AtomicOps::Decrement(&ref_count_);
262 if (!count) {
263 delete this;
264 }
265 return count;
266 }
267
242 } // namespace video_coding 268 } // namespace video_coding
243 } // namespace webrtc 269 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698