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 <memory> | 13 #include <memory> |
14 | 14 |
15 #include "webrtc/media/engine/webrtcvideoframe.h" | |
16 | |
17 @implementation RTCVideoFrame { | 15 @implementation RTCVideoFrame { |
18 std::unique_ptr<cricket::VideoFrame> _videoFrame; | 16 std::unique_ptr<cricket::VideoFrame> _videoFrame; |
19 rtc::scoped_refptr<webrtc::VideoFrameBuffer> _i420Buffer; | 17 rtc::scoped_refptr<webrtc::VideoFrameBuffer> _i420Buffer; |
20 } | 18 } |
21 | 19 |
22 - (size_t)width { | 20 - (size_t)width { |
23 return _videoFrame->width(); | 21 return _videoFrame->width(); |
24 } | 22 } |
25 | 23 |
26 - (size_t)height { | 24 - (size_t)height { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 } | 98 } |
101 } | 99 } |
102 } | 100 } |
103 | 101 |
104 #pragma mark - Private | 102 #pragma mark - Private |
105 | 103 |
106 - (instancetype)initWithNativeFrame:(const cricket::VideoFrame *)nativeFrame { | 104 - (instancetype)initWithNativeFrame:(const cricket::VideoFrame *)nativeFrame { |
107 if (self = [super init]) { | 105 if (self = [super init]) { |
108 // Keep a shallow copy of the video frame. The underlying frame buffer is | 106 // Keep a shallow copy of the video frame. The underlying frame buffer is |
109 // not copied. | 107 // not copied. |
110 _videoFrame.reset(new cricket::WebRtcVideoFrame( | 108 _videoFrame.reset(nativeFrame->Copy()); |
111 nativeFrame->video_frame_buffer(), | |
112 nativeFrame->rotation(), | |
113 nativeFrame->timestamp_us())); | |
114 } | 109 } |
115 return self; | 110 return self; |
116 } | 111 } |
117 | 112 |
118 - (rtc::scoped_refptr<webrtc::VideoFrameBuffer>)i420Buffer { | 113 - (rtc::scoped_refptr<webrtc::VideoFrameBuffer>)i420Buffer { |
119 [self convertBufferIfNeeded]; | 114 [self convertBufferIfNeeded]; |
120 return _i420Buffer; | 115 return _i420Buffer; |
121 } | 116 } |
122 | 117 |
123 @end | 118 @end |
OLD | NEW |