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 #include "webrtc/base/checks.h" | |
11 #include "webrtc/modules/video_coding/frame_object.h" | 12 #include "webrtc/modules/video_coding/frame_object.h" |
12 #include "webrtc/modules/video_coding/packet_buffer.h" | 13 #include "webrtc/modules/video_coding/packet_buffer.h" |
13 | 14 |
14 namespace webrtc { | 15 namespace webrtc { |
15 namespace video_coding { | 16 namespace video_coding { |
16 | 17 |
17 FrameObject::FrameObject() | 18 FrameObject::FrameObject() |
18 : picture_id(0), | 19 : picture_id(0), |
19 spatial_layer(0), | 20 spatial_layer(0), |
20 timestamp(0), | 21 timestamp(0), |
21 num_references(0), | 22 num_references(0), |
22 inter_layer_predicted(false) {} | 23 inter_layer_predicted(false) {} |
23 | 24 |
24 RtpFrameObject::RtpFrameObject(PacketBuffer* packet_buffer, | 25 RtpFrameObject::RtpFrameObject(PacketBuffer* packet_buffer, |
25 uint16_t first_seq_num, | 26 uint16_t first_seq_num, |
26 uint16_t last_seq_num, | 27 uint16_t last_seq_num, |
27 size_t frame_size, | 28 size_t frame_size, |
28 int times_nacked, | 29 int times_nacked, |
29 int64_t received_time) | 30 int64_t received_time) |
30 : packet_buffer_(packet_buffer), | 31 : packet_buffer_(packet_buffer), |
31 first_seq_num_(first_seq_num), | 32 first_seq_num_(first_seq_num), |
32 last_seq_num_(last_seq_num), | 33 last_seq_num_(last_seq_num), |
33 received_time_(received_time), | 34 received_time_(received_time), |
34 times_nacked_(times_nacked) { | 35 times_nacked_(times_nacked) { |
35 VCMPacket* packet = packet_buffer_->GetPacket(first_seq_num); | 36 VCMPacket* first_packet = packet_buffer_->GetPacket(first_seq_num); |
36 if (packet) { | 37 RTC_DCHECK(first_packet); |
37 // RtpFrameObject members | |
38 frame_type_ = packet->frameType; | |
39 codec_type_ = packet->codec; | |
40 | 38 |
41 // TODO(philipel): Remove when encoded image is replaced by FrameObject. | 39 // RtpFrameObject members |
42 // VCMEncodedFrame members | 40 frame_type_ = first_packet->frameType; |
43 CopyCodecSpecific(&packet->video_header); | 41 codec_type_ = first_packet->codec; |
44 _completeFrame = true; | |
45 _payloadType = packet->payloadType; | |
46 _timeStamp = packet->timestamp; | |
47 ntp_time_ms_ = packet->ntp_time_ms_; | |
48 | 42 |
49 // Since FFmpeg use an optimized bitstream reader that reads in chunks of | 43 // TODO(philipel): Remove when encoded image is replaced by FrameObject. |
50 // 32/64 bits we have to add at least that much padding to the buffer | 44 // VCMEncodedFrame members |
51 // to make sure the decoder doesn't read out of bounds. | 45 CopyCodecSpecific(&first_packet->video_header); |
52 // NOTE! EncodedImage::_size is the size of the buffer (think capacity of | 46 _completeFrame = true; |
53 // an std::vector) and EncodedImage::_length is the actual size of | 47 _payloadType = first_packet->payloadType; |
54 // the bitstream (think size of an std::vector). | 48 _timeStamp = first_packet->timestamp; |
55 if (codec_type_ == kVideoCodecH264) | 49 ntp_time_ms_ = first_packet->ntp_time_ms_; |
56 _size = frame_size + EncodedImage::kBufferPaddingBytesH264; | |
57 else | |
58 _size = frame_size; | |
59 | 50 |
60 _buffer = new uint8_t[_size]; | 51 // Since FFmpeg use an optimized bitstream reader that reads in chunks of |
61 _length = frame_size; | 52 // 32/64 bits we have to add at least that much padding to the buffer |
62 _frameType = packet->frameType; | 53 // to make sure the decoder doesn't read out of bounds. |
63 GetBitstream(_buffer); | 54 // NOTE! EncodedImage::_size is the size of the buffer (think capacity of |
55 // an std::vector) and EncodedImage::_length is the actual size of | |
56 // the bitstream (think size of an std::vector). | |
57 if (codec_type_ == kVideoCodecH264) | |
58 _size = frame_size + EncodedImage::kBufferPaddingBytesH264; | |
59 else | |
60 _size = frame_size; | |
64 | 61 |
65 // FrameObject members | 62 _buffer = new uint8_t[_size]; |
66 timestamp = packet->timestamp; | 63 _length = frame_size; |
67 } | 64 _frameType = first_packet->frameType; |
65 GetBitstream(_buffer); | |
66 | |
67 // FrameObject members | |
68 timestamp = first_packet->timestamp; | |
69 | |
70 VCMPacket* last_packet = packet_buffer_->GetPacket(last_seq_num); | |
philipel
2016/11/21 15:15:21
Apparently the video rotation is set in the last p
brandtr
2016/11/21 16:46:45
Is this according to the RFC, or just the way that
sprang_webrtc
2016/11/21 16:49:14
Don't we set it on all packets? Or is it that we s
philipel
2016/11/22 14:56:23
Added (copied from frame_buffer.cc) a comment abou
philipel
2016/11/22 14:56:23
Added comment, also, this piece of logic is copied
sprang_webrtc
2016/11/28 13:40:44
Acknowledged.
| |
71 RTC_DCHECK(last_packet && last_packet->markerBit); | |
72 rotation_ = last_packet->video_header.rotation; | |
73 _rotation_set = true; | |
68 } | 74 } |
69 | 75 |
70 RtpFrameObject::~RtpFrameObject() { | 76 RtpFrameObject::~RtpFrameObject() { |
71 packet_buffer_->ReturnFrame(this); | 77 packet_buffer_->ReturnFrame(this); |
72 } | 78 } |
73 | 79 |
74 uint16_t RtpFrameObject::first_seq_num() const { | 80 uint16_t RtpFrameObject::first_seq_num() const { |
75 return first_seq_num_; | 81 return first_seq_num_; |
76 } | 82 } |
77 | 83 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 rtc::Optional<RTPVideoTypeHeader> RtpFrameObject::GetCodecHeader() const { | 116 rtc::Optional<RTPVideoTypeHeader> RtpFrameObject::GetCodecHeader() const { |
111 rtc::CritScope lock(&packet_buffer_->crit_); | 117 rtc::CritScope lock(&packet_buffer_->crit_); |
112 VCMPacket* packet = packet_buffer_->GetPacket(first_seq_num_); | 118 VCMPacket* packet = packet_buffer_->GetPacket(first_seq_num_); |
113 if (!packet) | 119 if (!packet) |
114 return rtc::Optional<RTPVideoTypeHeader>(); | 120 return rtc::Optional<RTPVideoTypeHeader>(); |
115 return rtc::Optional<RTPVideoTypeHeader>(packet->video_header.codecHeader); | 121 return rtc::Optional<RTPVideoTypeHeader>(packet->video_header.codecHeader); |
116 } | 122 } |
117 | 123 |
118 } // namespace video_coding | 124 } // namespace video_coding |
119 } // namespace webrtc | 125 } // namespace webrtc |
OLD | NEW |