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 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 return 0; | 76 return 0; |
77 } | 77 } |
78 return self.i420Buffer->stride(webrtc::kVPlane); | 78 return self.i420Buffer->stride(webrtc::kVPlane); |
79 } | 79 } |
80 | 80 |
81 - (int64_t)timeStamp { | 81 - (int64_t)timeStamp { |
82 return _videoFrame->GetTimeStamp(); | 82 return _videoFrame->GetTimeStamp(); |
83 } | 83 } |
84 | 84 |
85 - (CVPixelBufferRef)nativeHandle { | 85 - (CVPixelBufferRef)nativeHandle { |
86 return static_cast<CVPixelBufferRef>(_videoFrame->GetNativeHandle()); | 86 return static_cast<CVPixelBufferRef>( |
| 87 _videoFrame->video_frame_buffer()->native_handle()); |
87 } | 88 } |
88 | 89 |
89 - (void)convertBufferIfNeeded { | 90 - (void)convertBufferIfNeeded { |
90 if (!_i420Buffer) { | 91 if (!_i420Buffer) { |
91 if (_videoFrame->GetNativeHandle()) { | 92 if (_videoFrame->video_frame_buffer()->native_handle()) { |
92 // Convert to I420. | 93 // Convert to I420. |
93 _i420Buffer = _videoFrame->video_frame_buffer()->NativeToI420Buffer(); | 94 _i420Buffer = _videoFrame->video_frame_buffer()->NativeToI420Buffer(); |
94 } else { | 95 } else { |
95 // Should already be I420. | 96 // Should already be I420. |
96 _i420Buffer = _videoFrame->video_frame_buffer(); | 97 _i420Buffer = _videoFrame->video_frame_buffer(); |
97 } | 98 } |
98 } | 99 } |
99 } | 100 } |
100 | 101 |
101 #pragma mark - Private | 102 #pragma mark - Private |
102 | 103 |
103 - (instancetype)initWithNativeFrame:(const cricket::VideoFrame *)nativeFrame { | 104 - (instancetype)initWithNativeFrame:(const cricket::VideoFrame *)nativeFrame { |
104 if (self = [super init]) { | 105 if (self = [super init]) { |
105 // 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 |
106 // not copied. | 107 // not copied. |
107 _videoFrame.reset(nativeFrame->Copy()); | 108 _videoFrame.reset(nativeFrame->Copy()); |
108 } | 109 } |
109 return self; | 110 return self; |
110 } | 111 } |
111 | 112 |
112 - (rtc::scoped_refptr<webrtc::VideoFrameBuffer>)i420Buffer { | 113 - (rtc::scoped_refptr<webrtc::VideoFrameBuffer>)i420Buffer { |
113 [self convertBufferIfNeeded]; | 114 [self convertBufferIfNeeded]; |
114 return _i420Buffer; | 115 return _i420Buffer; |
115 } | 116 } |
116 | 117 |
117 @end | 118 @end |
OLD | NEW |