OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 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 #import "RTCVideoFrame+Private.h" | 11 #import "RTCVideoFrame+Private.h" |
12 | 12 |
| 13 #include "webrtc/common_video/include/corevideo_frame_buffer.h" |
| 14 |
13 @implementation RTCVideoFrame { | 15 @implementation RTCVideoFrame { |
14 rtc::scoped_refptr<webrtc::VideoFrameBuffer> _videoBuffer; | 16 rtc::scoped_refptr<webrtc::VideoFrameBuffer> _videoBuffer; |
15 RTCVideoRotation _rotation; | 17 RTCVideoRotation _rotation; |
16 int64_t _timeStampNs; | 18 int64_t _timeStampNs; |
17 } | 19 } |
18 | 20 |
19 - (int)width { | 21 - (int)width { |
20 return _videoBuffer->width(); | 22 return _videoBuffer->width(); |
21 } | 23 } |
22 | 24 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 return static_cast<CVPixelBufferRef>(_videoBuffer->native_handle()); | 62 return static_cast<CVPixelBufferRef>(_videoBuffer->native_handle()); |
61 } | 63 } |
62 | 64 |
63 - (RTCVideoFrame *)newI420VideoFrame { | 65 - (RTCVideoFrame *)newI420VideoFrame { |
64 return [[RTCVideoFrame alloc] | 66 return [[RTCVideoFrame alloc] |
65 initWithVideoBuffer:_videoBuffer->NativeToI420Buffer() | 67 initWithVideoBuffer:_videoBuffer->NativeToI420Buffer() |
66 rotation:_rotation | 68 rotation:_rotation |
67 timeStampNs:_timeStampNs]; | 69 timeStampNs:_timeStampNs]; |
68 } | 70 } |
69 | 71 |
| 72 - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer |
| 73 rotation:(RTCVideoRotation)rotation |
| 74 timeStampNs:(int64_t)timeStampNs { |
| 75 rtc::scoped_refptr<webrtc::VideoFrameBuffer> videoBuffer( |
| 76 new rtc::RefCountedObject<webrtc::CoreVideoFrameBuffer>(pixelBuffer)); |
| 77 return [self initWithVideoBuffer:videoBuffer |
| 78 rotation:rotation |
| 79 timeStampNs:timeStampNs]; |
| 80 } |
| 81 |
| 82 - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer |
| 83 scaledWidth:(int)scaledWidth |
| 84 scaledHeight:(int)scaledHeight |
| 85 cropWidth:(int)cropWidth |
| 86 cropHeight:(int)cropHeight |
| 87 cropX:(int)cropX |
| 88 cropY:(int)cropY |
| 89 rotation:(RTCVideoRotation)rotation |
| 90 timeStampNs:(int64_t)timeStampNs { |
| 91 rtc::scoped_refptr<webrtc::VideoFrameBuffer> videoBuffer( |
| 92 new rtc::RefCountedObject<webrtc::CoreVideoFrameBuffer>( |
| 93 pixelBuffer, |
| 94 scaledWidth, scaledHeight, |
| 95 cropWidth, cropHeight, |
| 96 cropX, cropY)); |
| 97 return [self initWithVideoBuffer:videoBuffer |
| 98 rotation:rotation |
| 99 timeStampNs:timeStampNs]; |
| 100 } |
| 101 |
70 #pragma mark - Private | 102 #pragma mark - Private |
71 | 103 |
72 - (instancetype)initWithVideoBuffer: | 104 - (instancetype)initWithVideoBuffer: |
73 (rtc::scoped_refptr<webrtc::VideoFrameBuffer>)videoBuffer | 105 (rtc::scoped_refptr<webrtc::VideoFrameBuffer>)videoBuffer |
74 rotation:(RTCVideoRotation)rotation | 106 rotation:(RTCVideoRotation)rotation |
75 timeStampNs:(int64_t)timeStampNs { | 107 timeStampNs:(int64_t)timeStampNs { |
76 if (self = [super init]) { | 108 if (self = [super init]) { |
77 _videoBuffer = videoBuffer; | 109 _videoBuffer = videoBuffer; |
78 _rotation = rotation; | 110 _rotation = rotation; |
79 _timeStampNs = timeStampNs; | 111 _timeStampNs = timeStampNs; |
80 } | 112 } |
81 return self; | 113 return self; |
82 } | 114 } |
83 | 115 |
84 @end | 116 @end |
OLD | NEW |