| 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/modules/video_coding/frame_object.h" | 11 #include "webrtc/modules/video_coding/frame_object.h" |
| 12 #include "webrtc/common_video/h264/h264_common.h" | 12 #include "webrtc/common_video/h264/h264_common.h" |
| 13 #include "webrtc/modules/video_coding/packet_buffer.h" | 13 #include "webrtc/modules/video_coding/packet_buffer.h" |
| 14 #include "webrtc/rtc_base/checks.h" | 14 #include "webrtc/rtc_base/checks.h" |
| 15 #include "webrtc/rtc_base/logging.h" |
| 15 | 16 |
| 16 namespace webrtc { | 17 namespace webrtc { |
| 17 namespace video_coding { | 18 namespace video_coding { |
| 18 | 19 |
| 19 FrameObject::FrameObject() | 20 FrameObject::FrameObject() |
| 20 : picture_id(0), | 21 : picture_id(0), |
| 21 spatial_layer(0), | 22 spatial_layer(0), |
| 22 timestamp(0), | 23 timestamp(0), |
| 23 num_references(0), | 24 num_references(0), |
| 24 inter_layer_predicted(false) {} | 25 inter_layer_predicted(false) {} |
| 25 | 26 |
| 26 RtpFrameObject::RtpFrameObject(PacketBuffer* packet_buffer, | 27 RtpFrameObject::RtpFrameObject(PacketBuffer* packet_buffer, |
| 27 uint16_t first_seq_num, | 28 uint16_t first_seq_num, |
| 28 uint16_t last_seq_num, | 29 uint16_t last_seq_num, |
| 29 size_t frame_size, | 30 size_t frame_size, |
| 30 int times_nacked, | 31 int times_nacked, |
| 31 int64_t received_time) | 32 int64_t received_time) |
| 32 : packet_buffer_(packet_buffer), | 33 : packet_buffer_(packet_buffer), |
| 33 first_seq_num_(first_seq_num), | 34 first_seq_num_(first_seq_num), |
| 34 last_seq_num_(last_seq_num), | 35 last_seq_num_(last_seq_num), |
| 35 received_time_(received_time), | 36 received_time_(received_time), |
| 36 times_nacked_(times_nacked) { | 37 times_nacked_(times_nacked) { |
| 38 LOG(LS_ERROR) << __func__ << first_seq_num << " " << last_seq_num; |
| 37 VCMPacket* first_packet = packet_buffer_->GetPacket(first_seq_num); | 39 VCMPacket* first_packet = packet_buffer_->GetPacket(first_seq_num); |
| 38 RTC_CHECK(first_packet); | 40 RTC_CHECK(first_packet); |
| 39 | 41 |
| 40 // RtpFrameObject members | 42 // RtpFrameObject members |
| 41 frame_type_ = first_packet->frameType; | 43 frame_type_ = first_packet->frameType; |
| 42 codec_type_ = first_packet->codec; | 44 codec_type_ = first_packet->codec; |
| 43 | 45 |
| 46 if (first_packet->video_header.stereoInfo.frame_index == 0 && |
| 47 codec_type_ == kVideoCodecStereo) { |
| 48 uint16_t index = first_seq_num; |
| 49 while (index != last_seq_num) { |
| 50 VCMPacket* packet = packet_buffer_->GetPacket(first_seq_num); |
| 51 if (packet->video_header.stereoInfo.frame_index > 0) |
| 52 break; |
| 53 index = (index + 1) % packet_buffer_->size_; |
| 54 } |
| 55 last_seq_num_ = index; |
| 56 |
| 57 _codecSpecificInfo.stereoInfo.num_frames = 1; |
| 58 RtpFrameObject* alpha = |
| 59 new RtpFrameObject(packet_buffer, index, last_seq_num, frame_size, |
| 60 times_nacked, received_time); |
| 61 _codecSpecificInfo.stereoInfo.encoded_images[0] = alpha; |
| 62 _codecSpecificInfo.stereoInfo.codec_specific_infos[0] = |
| 63 alpha->CodecSpecific(); |
| 64 } |
| 65 |
| 44 // TODO(philipel): Remove when encoded image is replaced by FrameObject. | 66 // TODO(philipel): Remove when encoded image is replaced by FrameObject. |
| 45 // VCMEncodedFrame members | 67 // VCMEncodedFrame members |
| 46 CopyCodecSpecific(&first_packet->video_header); | 68 CopyCodecSpecific(&first_packet->video_header); |
| 47 _completeFrame = true; | 69 _completeFrame = true; |
| 48 _payloadType = first_packet->payloadType; | 70 _payloadType = first_packet->payloadType; |
| 49 _timeStamp = first_packet->timestamp; | 71 _timeStamp = first_packet->timestamp; |
| 50 ntp_time_ms_ = first_packet->ntp_time_ms_; | 72 ntp_time_ms_ = first_packet->ntp_time_ms_; |
| 51 | 73 |
| 52 // Setting frame's playout delays to the same values | 74 // Setting frame's playout delays to the same values |
| 53 // as of the first packet's. | 75 // as of the first packet's. |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 rtc::Optional<RTPVideoTypeHeader> RtpFrameObject::GetCodecHeader() const { | 210 rtc::Optional<RTPVideoTypeHeader> RtpFrameObject::GetCodecHeader() const { |
| 189 rtc::CritScope lock(&packet_buffer_->crit_); | 211 rtc::CritScope lock(&packet_buffer_->crit_); |
| 190 VCMPacket* packet = packet_buffer_->GetPacket(first_seq_num_); | 212 VCMPacket* packet = packet_buffer_->GetPacket(first_seq_num_); |
| 191 if (!packet) | 213 if (!packet) |
| 192 return rtc::Optional<RTPVideoTypeHeader>(); | 214 return rtc::Optional<RTPVideoTypeHeader>(); |
| 193 return rtc::Optional<RTPVideoTypeHeader>(packet->video_header.codecHeader); | 215 return rtc::Optional<RTPVideoTypeHeader>(packet->video_header.codecHeader); |
| 194 } | 216 } |
| 195 | 217 |
| 196 } // namespace video_coding | 218 } // namespace video_coding |
| 197 } // namespace webrtc | 219 } // namespace webrtc |
| OLD | NEW |