| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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/include/video_coding_defines.h" | 11 #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
| 12 #include "webrtc/modules/video_coding/encoded_frame.h" | 12 #include "webrtc/modules/video_coding/encoded_frame.h" |
| 13 #include "webrtc/modules/video_coding/generic_encoder.h" | 13 #include "webrtc/modules/video_coding/generic_encoder.h" |
| 14 #include "webrtc/modules/video_coding/jitter_buffer_common.h" | 14 #include "webrtc/modules/video_coding/jitter_buffer_common.h" |
| 15 | 15 |
| 16 namespace webrtc { | 16 namespace webrtc { |
| 17 | 17 |
| 18 VCMEncodedFrame::VCMEncodedFrame() | 18 VCMEncodedFrame::VCMEncodedFrame() |
| 19 : webrtc::EncodedImage(), | 19 : webrtc::EncodedImage(), |
| 20 _renderTimeMs(-1), | 20 _renderTimeMs(-1), |
| 21 _payloadType(0), | 21 _payloadType(0), |
| 22 _missingFrame(false), | 22 _missingFrame(false), |
| 23 _codec(kVideoCodecUnknown), | 23 _codec(kVideoCodecUnknown), |
| 24 _fragmentation(), | |
| 25 _rotation_set(false) { | 24 _rotation_set(false) { |
| 26 _codecSpecificInfo.codecType = kVideoCodecUnknown; | 25 _codecSpecificInfo.codecType = kVideoCodecUnknown; |
| 27 } | 26 } |
| 28 | 27 |
| 29 VCMEncodedFrame::VCMEncodedFrame(const webrtc::EncodedImage& rhs) | 28 VCMEncodedFrame::VCMEncodedFrame(const webrtc::EncodedImage& rhs) |
| 30 : webrtc::EncodedImage(rhs), | 29 : webrtc::EncodedImage(rhs), |
| 31 _renderTimeMs(-1), | 30 _renderTimeMs(-1), |
| 32 _payloadType(0), | 31 _payloadType(0), |
| 33 _missingFrame(false), | 32 _missingFrame(false), |
| 34 _codec(kVideoCodecUnknown), | 33 _codec(kVideoCodecUnknown), |
| 35 _fragmentation(), | |
| 36 _rotation_set(false) { | 34 _rotation_set(false) { |
| 37 _codecSpecificInfo.codecType = kVideoCodecUnknown; | 35 _codecSpecificInfo.codecType = kVideoCodecUnknown; |
| 38 _buffer = NULL; | 36 _buffer = NULL; |
| 39 _size = 0; | 37 _size = 0; |
| 40 _length = 0; | 38 _length = 0; |
| 41 if (rhs._buffer != NULL) { | 39 if (rhs._buffer != NULL) { |
| 42 VerifyAndAllocate(rhs._length + | 40 VerifyAndAllocate(rhs._length + |
| 43 EncodedImage::GetBufferPaddingBytes(_codec)); | 41 EncodedImage::GetBufferPaddingBytes(_codec)); |
| 44 memcpy(_buffer, rhs._buffer, rhs._length); | 42 memcpy(_buffer, rhs._buffer, rhs._length); |
| 45 } | 43 } |
| 46 } | 44 } |
| 47 | 45 |
| 48 VCMEncodedFrame::VCMEncodedFrame(const VCMEncodedFrame& rhs) | 46 VCMEncodedFrame::VCMEncodedFrame(const VCMEncodedFrame& rhs) |
| 49 : webrtc::EncodedImage(rhs), | 47 : webrtc::EncodedImage(rhs), |
| 50 _renderTimeMs(rhs._renderTimeMs), | 48 _renderTimeMs(rhs._renderTimeMs), |
| 51 _payloadType(rhs._payloadType), | 49 _payloadType(rhs._payloadType), |
| 52 _missingFrame(rhs._missingFrame), | 50 _missingFrame(rhs._missingFrame), |
| 53 _codecSpecificInfo(rhs._codecSpecificInfo), | 51 _codecSpecificInfo(rhs._codecSpecificInfo), |
| 54 _codec(rhs._codec), | 52 _codec(rhs._codec), |
| 55 _fragmentation(), | |
| 56 _rotation_set(rhs._rotation_set) { | 53 _rotation_set(rhs._rotation_set) { |
| 57 _buffer = NULL; | 54 _buffer = NULL; |
| 58 _size = 0; | 55 _size = 0; |
| 59 _length = 0; | 56 _length = 0; |
| 60 if (rhs._buffer != NULL) { | 57 if (rhs._buffer != NULL) { |
| 61 VerifyAndAllocate(rhs._length + | 58 VerifyAndAllocate(rhs._length + |
| 62 EncodedImage::GetBufferPaddingBytes(_codec)); | 59 EncodedImage::GetBufferPaddingBytes(_codec)); |
| 63 memcpy(_buffer, rhs._buffer, rhs._length); | 60 memcpy(_buffer, rhs._buffer, rhs._length); |
| 64 _length = rhs._length; | 61 _length = rhs._length; |
| 65 } | 62 } |
| 66 _fragmentation.CopyFrom(rhs._fragmentation); | |
| 67 } | 63 } |
| 68 | 64 |
| 69 VCMEncodedFrame::~VCMEncodedFrame() { | 65 VCMEncodedFrame::~VCMEncodedFrame() { |
| 70 Free(); | 66 Free(); |
| 71 } | 67 } |
| 72 | 68 |
| 73 void VCMEncodedFrame::Free() { | 69 void VCMEncodedFrame::Free() { |
| 74 Reset(); | 70 Reset(); |
| 75 if (_buffer != NULL) { | 71 if (_buffer != NULL) { |
| 76 delete[] _buffer; | 72 delete[] _buffer; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 break; | 192 break; |
| 197 } | 193 } |
| 198 default: { | 194 default: { |
| 199 _codecSpecificInfo.codecType = kVideoCodecUnknown; | 195 _codecSpecificInfo.codecType = kVideoCodecUnknown; |
| 200 break; | 196 break; |
| 201 } | 197 } |
| 202 } | 198 } |
| 203 } | 199 } |
| 204 } | 200 } |
| 205 | 201 |
| 206 const RTPFragmentationHeader* VCMEncodedFrame::FragmentationHeader() const { | |
| 207 return &_fragmentation; | |
| 208 } | |
| 209 | |
| 210 void VCMEncodedFrame::VerifyAndAllocate(size_t minimumSize) { | 202 void VCMEncodedFrame::VerifyAndAllocate(size_t minimumSize) { |
| 211 if (minimumSize > _size) { | 203 if (minimumSize > _size) { |
| 212 // create buffer of sufficient size | 204 // create buffer of sufficient size |
| 213 uint8_t* newBuffer = new uint8_t[minimumSize]; | 205 uint8_t* newBuffer = new uint8_t[minimumSize]; |
| 214 if (_buffer) { | 206 if (_buffer) { |
| 215 // copy old data | 207 // copy old data |
| 216 memcpy(newBuffer, _buffer, _size); | 208 memcpy(newBuffer, _buffer, _size); |
| 217 delete[] _buffer; | 209 delete[] _buffer; |
| 218 } | 210 } |
| 219 _buffer = newBuffer; | 211 _buffer = newBuffer; |
| 220 _size = minimumSize; | 212 _size = minimumSize; |
| 221 } | 213 } |
| 222 } | 214 } |
| 223 | 215 |
| 224 } // namespace webrtc | 216 } // namespace webrtc |
| OLD | NEW |