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

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

Issue 1772383002: Packet buffer for the new jitter buffer. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Feedback fixes. Created 4 years, 9 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
(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 #include "webrtc/modules/video_coding/frame_object.h"
12 #include "webrtc/base/criticalsection.h"
13 #include "webrtc/modules/video_coding/packet_buffer.h"
14
15 namespace webrtc {
16 namespace video_coding {
17
18 RtpFrameObject::RtpFrameObject(PacketBuffer* packet_buffer,
19 uint16_t picture_id,
20 uint16_t first_packet,
21 uint16_t last_packet)
22 : packet_buffer_(packet_buffer),
23 first_packet_(first_packet),
24 last_packet_(last_packet) {}
25
26 RtpFrameObject::~RtpFrameObject() {
27 rtc::CritScope lock(&packet_buffer_->crit_);
28 int index = first_packet_ % packet_buffer_->size_;
29 int end = ++last_packet_ % packet_buffer_->size_;
30 uint16_t seq_num = first_packet_;
31 while (index != end) {
32 if (packet_buffer_->sequence_buffer_[index].seq_num == seq_num) {
33 packet_buffer_->sequence_buffer_[index].used = false;
34 packet_buffer_->sequence_buffer_[index].continuous = false;
35 }
36 index = (index + 1) % packet_buffer_->size_;
37 ++seq_num;
38 }
39 }
40
41 uint16_t RtpFrameObject::first_packet() const {
42 return first_packet_;
43 }
44
45 uint16_t RtpFrameObject::last_packet() const {
46 return last_packet_;
47 }
48
49 uint16_t RtpFrameObject::picture_id() const {
50 return picture_id_;
51 }
52
53 bool RtpFrameObject::GetBitstream(uint8_t* destination) const {
54 rtc::CritScope lock(&packet_buffer_->crit_);
55
56 int index = first_packet_ % packet_buffer_->size_;
57 int end = last_packet_ + 1 % packet_buffer_->size_;
58 uint16_t seq_num = first_packet_;
59 while (index != end) {
60 if (!packet_buffer_->sequence_buffer_[index].used ||
61 packet_buffer_->sequence_buffer_[index].seq_num != seq_num)
62 return false;
63
64 const uint8_t* source = packet_buffer_->data_buffer_[index].dataPtr;
65 size_t length = packet_buffer_->data_buffer_[index].sizeBytes;
66 memcpy(destination, source, length);
67 destination += length;
68 index = (index + 1) % packet_buffer_->size_;
69 ++seq_num;
70 }
71 return true;
72 }
73
74 } // namespace video_coding
75 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698