| 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 size_t frame_size, | 28 size_t frame_size, |
| 29 int times_nacked, | 29 int times_nacked, |
| 30 int64_t received_time) | 30 int64_t received_time) |
| 31 : packet_buffer_(packet_buffer), | 31 : packet_buffer_(packet_buffer), |
| 32 first_seq_num_(first_seq_num), | 32 first_seq_num_(first_seq_num), |
| 33 last_seq_num_(last_seq_num), | 33 last_seq_num_(last_seq_num), |
| 34 received_time_(received_time), | 34 received_time_(received_time), |
| 35 times_nacked_(times_nacked) { | 35 times_nacked_(times_nacked) { |
| 36 VCMPacket* packet = packet_buffer_->GetPacket(first_seq_num); | 36 VCMPacket* packet = packet_buffer_->GetPacket(first_seq_num); |
| 37 if (packet) { | 37 if (packet) { |
| 38 // RtpFrameObject members |
| 39 frame_type_ = packet->frameType; |
| 40 codec_type_ = packet->codec; |
| 41 |
| 38 // TODO(philipel): Remove when encoded image is replaced by FrameObject. | 42 // TODO(philipel): Remove when encoded image is replaced by FrameObject. |
| 39 // VCMEncodedFrame members | 43 // VCMEncodedFrame members |
| 40 CopyCodecSpecific(&packet->video_header); | 44 CopyCodecSpecific(&packet->video_header); |
| 41 _completeFrame = true; | 45 _completeFrame = true; |
| 42 _payloadType = packet->payloadType; | 46 _payloadType = packet->payloadType; |
| 43 _timeStamp = packet->timestamp; | 47 _timeStamp = packet->timestamp; |
| 44 ntp_time_ms_ = packet->ntp_time_ms_; | 48 ntp_time_ms_ = packet->ntp_time_ms_; |
| 45 _buffer = new uint8_t[frame_size](); | 49 |
| 46 _size = frame_size; | 50 // Since FFmpeg use an optimized bitstream reader that reads in chunks of |
| 51 // 32/64 bits we have to add at least that much padding to the buffer |
| 52 // to make sure the decoder doesn't read out of bounds. |
| 53 // NOTE! EncodedImage::_size is the size of the buffer (think capacity of |
| 54 // an std::vector) and EncodedImage::_length is the actual size of |
| 55 // the bitstream (think size of an std::vector). |
| 56 if (codec_type_ == kVideoCodecH264) |
| 57 _size = frame_size + EncodedImage::kBufferPaddingBytesH264; |
| 58 else |
| 59 _size = frame_size; |
| 60 |
| 61 _buffer = new uint8_t[_size]; |
| 47 _length = frame_size; | 62 _length = frame_size; |
| 48 _frameType = packet->frameType; | 63 _frameType = packet->frameType; |
| 49 GetBitstream(_buffer); | 64 GetBitstream(_buffer); |
| 50 | 65 |
| 51 // RtpFrameObject members | |
| 52 frame_type_ = packet->frameType; | |
| 53 codec_type_ = packet->codec; | |
| 54 | |
| 55 // FrameObject members | 66 // FrameObject members |
| 56 timestamp = packet->timestamp; | 67 timestamp = packet->timestamp; |
| 57 } | 68 } |
| 58 } | 69 } |
| 59 | 70 |
| 60 RtpFrameObject::~RtpFrameObject() { | 71 RtpFrameObject::~RtpFrameObject() { |
| 61 packet_buffer_->ReturnFrame(this); | 72 packet_buffer_->ReturnFrame(this); |
| 62 } | 73 } |
| 63 | 74 |
| 64 uint16_t RtpFrameObject::first_seq_num() const { | 75 uint16_t RtpFrameObject::first_seq_num() const { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 110 |
| 100 RTPVideoTypeHeader* RtpFrameObject::GetCodecHeader() const { | 111 RTPVideoTypeHeader* RtpFrameObject::GetCodecHeader() const { |
| 101 VCMPacket* packet = packet_buffer_->GetPacket(first_seq_num_); | 112 VCMPacket* packet = packet_buffer_->GetPacket(first_seq_num_); |
| 102 if (!packet) | 113 if (!packet) |
| 103 return nullptr; | 114 return nullptr; |
| 104 return &packet->video_header.codecHeader; | 115 return &packet->video_header.codecHeader; |
| 105 } | 116 } |
| 106 | 117 |
| 107 } // namespace video_coding | 118 } // namespace video_coding |
| 108 } // namespace webrtc | 119 } // namespace webrtc |
| OLD | NEW |