Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Side by Side Diff: webrtc/sdk/objc/Framework/Classes/RTCVideoFrame.mm

Issue 2176623002: iOS render: Handle frame rotation in OpenGL (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@nv21_texture_render
Patch Set: Remove unused vertex buffer argument to RTCSetVertexData Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 @implementation RTCVideoFrame { 15 @implementation RTCVideoFrame {
16 std::unique_ptr<cricket::VideoFrame> _videoFrame; 16 rtc::scoped_refptr<webrtc::VideoFrameBuffer> _videoBuffer;
17 int _rotation;
18 int64_t _timeStampNs;
17 rtc::scoped_refptr<webrtc::VideoFrameBuffer> _i420Buffer; 19 rtc::scoped_refptr<webrtc::VideoFrameBuffer> _i420Buffer;
18 } 20 }
19 21
20 - (size_t)width { 22 - (size_t)width {
21 return _videoFrame->width(); 23 return _videoBuffer->width();
22 } 24 }
23 25
24 - (size_t)height { 26 - (size_t)height {
25 return _videoFrame->height(); 27 return _videoBuffer->height();
28 }
29
30 - (int)rotation {
31 return _rotation;
26 } 32 }
27 33
28 // TODO(nisse): chromaWidth and chromaHeight are used only in 34 // TODO(nisse): chromaWidth and chromaHeight are used only in
29 // RTCOpenGLVideoRenderer.mm. Update, and then delete these 35 // RTCOpenGLVideoRenderer.mm. Update, and then delete these
30 // properties. 36 // properties.
31 - (size_t)chromaWidth { 37 - (size_t)chromaWidth {
32 return (self.width + 1) / 2; 38 return (self.width + 1) / 2;
33 } 39 }
34 40
35 - (size_t)chromaHeight { 41 - (size_t)chromaHeight {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 return self.i420Buffer->StrideU(); 77 return self.i420Buffer->StrideU();
72 } 78 }
73 79
74 - (int32_t)vPitch { 80 - (int32_t)vPitch {
75 if (!self.i420Buffer) { 81 if (!self.i420Buffer) {
76 return 0; 82 return 0;
77 } 83 }
78 return self.i420Buffer->StrideV(); 84 return self.i420Buffer->StrideV();
79 } 85 }
80 86
81 - (int64_t)timeStamp { 87 - (int64_t)timeStampNs {
82 return _videoFrame->GetTimeStamp(); 88 return _timeStampNs;
83 } 89 }
84 90
85 - (CVPixelBufferRef)nativeHandle { 91 - (CVPixelBufferRef)nativeHandle {
86 return static_cast<CVPixelBufferRef>( 92 return static_cast<CVPixelBufferRef>(_videoBuffer->native_handle());
87 _videoFrame->video_frame_buffer()->native_handle());
88 } 93 }
89 94
90 - (void)convertBufferIfNeeded { 95 - (void)convertBufferIfNeeded {
91 if (!_i420Buffer) { 96 if (!_i420Buffer) {
92 if (_videoFrame->video_frame_buffer()->native_handle()) { 97 _i420Buffer = _videoBuffer->native_handle()
93 // Convert to I420. 98 ? _videoBuffer->NativeToI420Buffer()
94 _i420Buffer = _videoFrame->video_frame_buffer()->NativeToI420Buffer(); 99 : _videoBuffer;
95 } else {
96 // Should already be I420.
97 _i420Buffer = _videoFrame->video_frame_buffer();
98 }
99 } 100 }
100 } 101 }
101 102
102 #pragma mark - Private 103 #pragma mark - Private
103 104
104 - (instancetype)initWithNativeFrame:(const cricket::VideoFrame *)nativeFrame { 105 - (instancetype)initWithVideoBuffer:
106 (rtc::scoped_refptr<webrtc::VideoFrameBuffer>)videoBuffer
107 rotation:(int)rotation
108 timeStampNs:(int64_t)timeStampNs {
105 if (self = [super init]) { 109 if (self = [super init]) {
106 // Keep a shallow copy of the video frame. The underlying frame buffer is 110 _videoBuffer = videoBuffer;
107 // not copied. 111 _rotation = rotation;
108 _videoFrame.reset(nativeFrame->Copy()); 112 _timeStampNs = timeStampNs;
109 } 113 }
110 return self; 114 return self;
111 } 115 }
112 116
113 - (rtc::scoped_refptr<webrtc::VideoFrameBuffer>)i420Buffer { 117 - (rtc::scoped_refptr<webrtc::VideoFrameBuffer>)i420Buffer {
114 [self convertBufferIfNeeded]; 118 [self convertBufferIfNeeded];
115 return _i420Buffer; 119 return _i420Buffer;
116 } 120 }
117 121
118 @end 122 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698