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/RTCEncodedImage.h> | |
12 | |
13 #import "RTCVideoCodec+Private.h" | |
14 | |
15 // An encoded frame | |
magjed_webrtc
2017/07/05 13:22:32
Comment that this is an ObjC wrapper for webrtc::E
andersc
2017/07/06 12:39:41
Done.
| |
16 | |
17 @implementation RTCEncodedImage | |
18 | |
19 @synthesize buffer = _buffer; | |
20 @synthesize encodedWidth = _encodedWidth; | |
21 @synthesize encodedHeight = _encodedHeight; | |
22 @synthesize timeStamp = _timeStamp; | |
23 @synthesize captureTimeMs = _captureTimeMs; | |
24 @synthesize ntpTimeMs = _ntpTimeMs; | |
25 @synthesize isTimingFrame = _isTimingFrame; | |
26 @synthesize encodeStartMs = _encodeStartMs; | |
27 @synthesize encodeFinishMs = _encodeFinishMs; | |
28 @synthesize frameType = _frameType; | |
29 @synthesize rotation = _rotation; | |
30 @synthesize completeFrame = _completeFrame; | |
31 @synthesize qp = _qp; | |
32 | |
33 - (instancetype)initWithEncodedImage:(webrtc::EncodedImage)encodedImage { | |
34 if (self = [super init]) { | |
35 // Wrap the buffer in NSData without copying, do not take ownership | |
36 _buffer = [NSData dataWithBytesNoCopy:encodedImage._buffer | |
37 length:encodedImage._length | |
38 freeWhenDone:NO]; | |
39 _encodedWidth = encodedImage._encodedWidth; | |
40 _encodedHeight = encodedImage._encodedHeight; | |
41 _timeStamp = encodedImage._timeStamp; | |
42 _captureTimeMs = encodedImage.capture_time_ms_; | |
43 _ntpTimeMs = encodedImage.ntp_time_ms_; | |
44 _isTimingFrame = encodedImage.timing_.is_timing_frame; | |
45 _encodeStartMs = encodedImage.timing_.encode_start_ms; | |
46 _encodeFinishMs = encodedImage.timing_.encode_finish_ms; | |
47 _frameType = (RTCFrameType)encodedImage._frameType; | |
48 _rotation = encodedImage.rotation_; | |
49 _completeFrame = encodedImage._completeFrame; | |
50 _qp = encodedImage.qp_ == -1 ? nil : @(encodedImage.qp_); | |
51 } | |
52 | |
53 return self; | |
54 } | |
55 | |
56 - (webrtc::EncodedImage)toCpp { | |
57 // Return the pointer without copying | |
58 webrtc::EncodedImage encodedImage( | |
59 (uint8_t *)_buffer.bytes, (size_t)_buffer.length, (size_t)_buffer.length); | |
60 encodedImage._encodedWidth = _encodedWidth; | |
61 encodedImage._encodedHeight = _encodedHeight; | |
62 encodedImage._timeStamp = _timeStamp; | |
63 encodedImage.capture_time_ms_ = _captureTimeMs; | |
64 encodedImage.ntp_time_ms_ = _ntpTimeMs; | |
65 encodedImage.timing_.is_timing_frame = _isTimingFrame; | |
66 encodedImage.timing_.encode_start_ms = _encodeStartMs; | |
67 encodedImage.timing_.encode_finish_ms = _encodeFinishMs; | |
68 encodedImage._frameType = webrtc::FrameType(_frameType); | |
69 encodedImage.rotation_ = webrtc::VideoRotation(_rotation); | |
70 encodedImage._completeFrame = _completeFrame; | |
71 encodedImage.qp_ = _qp ? _qp.intValue : -1; | |
72 | |
73 return encodedImage; | |
74 } | |
75 | |
76 @end | |
OLD | NEW |