OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
| 3 * |
| 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 |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 #import "WebRTC/RTCVideoCodec.h" |
| 12 |
| 13 #import "RTCVideoCodec+Private.h" |
| 14 |
| 15 @implementation RTCEncodedImage |
| 16 |
| 17 @synthesize buffer = _buffer; |
| 18 @synthesize encodedWidth = _encodedWidth; |
| 19 @synthesize encodedHeight = _encodedHeight; |
| 20 @synthesize timeStamp = _timeStamp; |
| 21 @synthesize captureTimeMs = _captureTimeMs; |
| 22 @synthesize ntpTimeMs = _ntpTimeMs; |
| 23 @synthesize isTimingFrame = _isTimingFrame; |
| 24 @synthesize encodeStartMs = _encodeStartMs; |
| 25 @synthesize encodeFinishMs = _encodeFinishMs; |
| 26 @synthesize frameType = _frameType; |
| 27 @synthesize rotation = _rotation; |
| 28 @synthesize completeFrame = _completeFrame; |
| 29 @synthesize qp = _qp; |
| 30 |
| 31 - (instancetype)initWithEncodedImage:(webrtc::EncodedImage)encodedImage { |
| 32 if (self = [super init]) { |
| 33 // Wrap the buffer in NSData without copying, do not take ownership. |
| 34 _buffer = [NSData dataWithBytesNoCopy:encodedImage._buffer |
| 35 length:encodedImage._length |
| 36 freeWhenDone:NO]; |
| 37 _encodedWidth = encodedImage._encodedWidth; |
| 38 _encodedHeight = encodedImage._encodedHeight; |
| 39 _timeStamp = encodedImage._timeStamp; |
| 40 _captureTimeMs = encodedImage.capture_time_ms_; |
| 41 _ntpTimeMs = encodedImage.ntp_time_ms_; |
| 42 _isTimingFrame = encodedImage.timing_.is_timing_frame; |
| 43 _encodeStartMs = encodedImage.timing_.encode_start_ms; |
| 44 _encodeFinishMs = encodedImage.timing_.encode_finish_ms; |
| 45 _frameType = (RTCFrameType)encodedImage._frameType; |
| 46 _rotation = encodedImage.rotation_; |
| 47 _completeFrame = encodedImage._completeFrame; |
| 48 _qp = encodedImage.qp_ == -1 ? nil : @(encodedImage.qp_); |
| 49 } |
| 50 |
| 51 return self; |
| 52 } |
| 53 |
| 54 - (webrtc::EncodedImage)toCpp { |
| 55 // Return the pointer without copying. |
| 56 webrtc::EncodedImage encodedImage( |
| 57 (uint8_t *)_buffer.bytes, (size_t)_buffer.length, (size_t)_buffer.length); |
| 58 encodedImage._encodedWidth = _encodedWidth; |
| 59 encodedImage._encodedHeight = _encodedHeight; |
| 60 encodedImage._timeStamp = _timeStamp; |
| 61 encodedImage.capture_time_ms_ = _captureTimeMs; |
| 62 encodedImage.ntp_time_ms_ = _ntpTimeMs; |
| 63 encodedImage.timing_.is_timing_frame = _isTimingFrame; |
| 64 encodedImage.timing_.encode_start_ms = _encodeStartMs; |
| 65 encodedImage.timing_.encode_finish_ms = _encodeFinishMs; |
| 66 encodedImage._frameType = webrtc::FrameType(_frameType); |
| 67 encodedImage.rotation_ = webrtc::VideoRotation(_rotation); |
| 68 encodedImage._completeFrame = _completeFrame; |
| 69 encodedImage.qp_ = _qp ? _qp.intValue : -1; |
| 70 |
| 71 return encodedImage; |
| 72 } |
| 73 |
| 74 @end |
OLD | NEW |