| 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 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 uint16_t last_seq_num, | 28 uint16_t last_seq_num, |
| 29 size_t frame_size, | 29 size_t frame_size, |
| 30 int times_nacked, | 30 int times_nacked, |
| 31 int64_t received_time) | 31 int64_t received_time) |
| 32 : packet_buffer_(packet_buffer), | 32 : packet_buffer_(packet_buffer), |
| 33 first_seq_num_(first_seq_num), | 33 first_seq_num_(first_seq_num), |
| 34 last_seq_num_(last_seq_num), | 34 last_seq_num_(last_seq_num), |
| 35 received_time_(received_time), | 35 received_time_(received_time), |
| 36 times_nacked_(times_nacked) { | 36 times_nacked_(times_nacked) { |
| 37 VCMPacket* first_packet = packet_buffer_->GetPacket(first_seq_num); | 37 VCMPacket* first_packet = packet_buffer_->GetPacket(first_seq_num); |
| 38 RTC_DCHECK(first_packet); | 38 RTC_CHECK(first_packet); |
| 39 | 39 |
| 40 // RtpFrameObject members | 40 // RtpFrameObject members |
| 41 frame_type_ = first_packet->frameType; | 41 frame_type_ = first_packet->frameType; |
| 42 codec_type_ = first_packet->codec; | 42 codec_type_ = first_packet->codec; |
| 43 | 43 |
| 44 // TODO(philipel): Remove when encoded image is replaced by FrameObject. | 44 // TODO(philipel): Remove when encoded image is replaced by FrameObject. |
| 45 // VCMEncodedFrame members | 45 // VCMEncodedFrame members |
| 46 CopyCodecSpecific(&first_packet->video_header); | 46 CopyCodecSpecific(&first_packet->video_header); |
| 47 _completeFrame = true; | 47 _completeFrame = true; |
| 48 _payloadType = first_packet->payloadType; | 48 _payloadType = first_packet->payloadType; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 67 _buffer = new uint8_t[_size]; | 67 _buffer = new uint8_t[_size]; |
| 68 _length = frame_size; | 68 _length = frame_size; |
| 69 | 69 |
| 70 // For H264 frames we can't determine the frame type by just looking at the | 70 // For H264 frames we can't determine the frame type by just looking at the |
| 71 // first packet. Instead we consider the frame to be a keyframe if it | 71 // first packet. Instead we consider the frame to be a keyframe if it |
| 72 // contains an IDR NALU. | 72 // contains an IDR NALU. |
| 73 if (codec_type_ == kVideoCodecH264) { | 73 if (codec_type_ == kVideoCodecH264) { |
| 74 _frameType = kVideoFrameDelta; | 74 _frameType = kVideoFrameDelta; |
| 75 frame_type_ = kVideoFrameDelta; | 75 frame_type_ = kVideoFrameDelta; |
| 76 for (uint16_t seq_num = first_seq_num; | 76 for (uint16_t seq_num = first_seq_num; |
| 77 seq_num != last_seq_num + 1 && _frameType == kVideoFrameDelta; | 77 seq_num != static_cast<uint16_t>(last_seq_num + 1) && |
| 78 _frameType == kVideoFrameDelta; |
| 78 ++seq_num) { | 79 ++seq_num) { |
| 79 VCMPacket* packet = packet_buffer_->GetPacket(seq_num); | 80 VCMPacket* packet = packet_buffer_->GetPacket(seq_num); |
| 80 RTC_DCHECK(packet); | 81 RTC_CHECK(packet); |
| 81 const RTPVideoHeaderH264& header = packet->video_header.codecHeader.H264; | 82 const RTPVideoHeaderH264& header = packet->video_header.codecHeader.H264; |
| 82 for (size_t i = 0; i < header.nalus_length; ++i) { | 83 for (size_t i = 0; i < header.nalus_length; ++i) { |
| 83 if (header.nalus[i].type == H264::NaluType::kIdr) { | 84 if (header.nalus[i].type == H264::NaluType::kIdr) { |
| 84 _frameType = kVideoFrameKey; | 85 _frameType = kVideoFrameKey; |
| 85 frame_type_ = kVideoFrameKey; | 86 frame_type_ = kVideoFrameKey; |
| 86 break; | 87 break; |
| 87 } | 88 } |
| 88 } | 89 } |
| 89 } | 90 } |
| 90 } else { | 91 } else { |
| 91 _frameType = first_packet->frameType; | 92 _frameType = first_packet->frameType; |
| 92 frame_type_ = first_packet->frameType; | 93 frame_type_ = first_packet->frameType; |
| 93 } | 94 } |
| 94 | 95 |
| 95 GetBitstream(_buffer); | 96 GetBitstream(_buffer); |
| 96 _encodedWidth = first_packet->width; | 97 _encodedWidth = first_packet->width; |
| 97 _encodedHeight = first_packet->height; | 98 _encodedHeight = first_packet->height; |
| 98 | 99 |
| 99 // FrameObject members | 100 // FrameObject members |
| 100 timestamp = first_packet->timestamp; | 101 timestamp = first_packet->timestamp; |
| 101 | 102 |
| 102 VCMPacket* last_packet = packet_buffer_->GetPacket(last_seq_num); | 103 VCMPacket* last_packet = packet_buffer_->GetPacket(last_seq_num); |
| 103 RTC_DCHECK(last_packet && last_packet->markerBit); | 104 RTC_CHECK(last_packet && last_packet->markerBit); |
| 104 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ | 105 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ |
| 105 // ts_126114v120700p.pdf Section 7.4.5. | 106 // ts_126114v120700p.pdf Section 7.4.5. |
| 106 // The MTSI client shall add the payload bytes as defined in this clause | 107 // The MTSI client shall add the payload bytes as defined in this clause |
| 107 // onto the last RTP packet in each group of packets which make up a key | 108 // onto the last RTP packet in each group of packets which make up a key |
| 108 // frame (I-frame or IDR frame in H.264 (AVC), or an IRAP picture in H.265 | 109 // frame (I-frame or IDR frame in H.264 (AVC), or an IRAP picture in H.265 |
| 109 // (HEVC)). | 110 // (HEVC)). |
| 110 rotation_ = last_packet->video_header.rotation; | 111 rotation_ = last_packet->video_header.rotation; |
| 111 _rotation_set = true; | 112 _rotation_set = true; |
| 112 content_type_ = last_packet->video_header.content_type; | 113 content_type_ = last_packet->video_header.content_type; |
| 113 } | 114 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 rtc::Optional<RTPVideoTypeHeader> RtpFrameObject::GetCodecHeader() const { | 160 rtc::Optional<RTPVideoTypeHeader> RtpFrameObject::GetCodecHeader() const { |
| 160 rtc::CritScope lock(&packet_buffer_->crit_); | 161 rtc::CritScope lock(&packet_buffer_->crit_); |
| 161 VCMPacket* packet = packet_buffer_->GetPacket(first_seq_num_); | 162 VCMPacket* packet = packet_buffer_->GetPacket(first_seq_num_); |
| 162 if (!packet) | 163 if (!packet) |
| 163 return rtc::Optional<RTPVideoTypeHeader>(); | 164 return rtc::Optional<RTPVideoTypeHeader>(); |
| 164 return rtc::Optional<RTPVideoTypeHeader>(packet->video_header.codecHeader); | 165 return rtc::Optional<RTPVideoTypeHeader>(packet->video_header.codecHeader); |
| 165 } | 166 } |
| 166 | 167 |
| 167 } // namespace video_coding | 168 } // namespace video_coding |
| 168 } // namespace webrtc | 169 } // namespace webrtc |
| OLD | NEW |