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 #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 first_packet, | |
20 uint16_t last_packet) : | |
21 packet_buffer_(packet_buffer), | |
22 first_packet_(first_packet), | |
23 last_packet_(last_packet) {} | |
24 | |
25 RtpFrameObject::~RtpFrameObject() { | |
26 rtc::CritScope lock(&packet_buffer_->crit_); | |
27 int index = first_packet_ % packet_buffer_->size_; | |
stefan-webrtc
2016/03/17 12:06:31
I think this code would be better to have in Packe
philipel
2016/03/17 15:00:35
I would like to keep this function in the frame ob
stefan-webrtc
2016/03/24 09:41:21
I understand, but I think it's pretty ugly to expo
philipel
2016/03/30 09:44:54
Done.
| |
28 int end = ++last_packet_ % packet_buffer_->size_; | |
29 uint16_t seq_num = first_packet_; | |
30 while (index != end) { | |
31 if (packet_buffer_->sequence_buffer_[index].seq_num == seq_num) { | |
32 packet_buffer_->sequence_buffer_[index].used = false; | |
33 packet_buffer_->sequence_buffer_[index].continuous = false; | |
34 } | |
35 index = (index + 1) % packet_buffer_->size_; | |
36 ++seq_num; | |
37 } | |
38 } | |
39 | |
40 uint16_t RtpFrameObject::FirstPacket() const { | |
41 return first_packet_; | |
42 } | |
43 | |
44 uint16_t RtpFrameObject::LastPacket() const { | |
45 return last_packet_; | |
46 } | |
47 | |
48 uint16_t RtpFrameObject::PictureId() const { | |
49 return 1; | |
stefan-webrtc
2016/03/17 12:06:31
Is this correct?
philipel
2016/03/17 15:00:35
Added picture id to the frame object, but the corr
stefan-webrtc
2016/03/24 09:41:19
Acknowledged.
| |
50 } | |
51 | |
52 bool RtpFrameObject::GetBitstream(uint8_t* destination) const { | |
53 rtc::CritScope lock(&packet_buffer_->crit_); | |
stefan-webrtc
2016/03/17 12:06:31
Seems like most of this code also should live in p
philipel
2016/03/17 15:00:35
Again, I would like the functionality of the packe
philipel
2016/03/30 09:44:54
Done.
| |
54 | |
55 int index = first_packet_ % packet_buffer_->size_; | |
56 int end = last_packet_ + 1 % packet_buffer_->size_; | |
57 uint16_t seq_num = first_packet_; | |
58 while (index != end) { | |
59 if (!packet_buffer_->sequence_buffer_[index].used || | |
60 packet_buffer_->sequence_buffer_[index].seq_num != seq_num) | |
61 return false; | |
62 | |
63 const uint8_t* source = packet_buffer_->data_buffer_[index].dataPtr; | |
64 size_t length = packet_buffer_->data_buffer_[index].sizeBytes; | |
65 memcpy(destination, source, length); | |
66 destination += length; | |
67 index = (index + 1) % packet_buffer_->size_; | |
68 ++seq_num; | |
69 } | |
70 return true; | |
71 } | |
72 | |
73 } // namespace video_coding | |
74 } // namespace webrtc | |
OLD | NEW |