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

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

Issue 2517173004: Move VideoFrame and related declarations to webrtc/api/video. (Closed)
Patch Set: Make rotation check clearer. Created 3 years, 11 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 #include "avfoundationvideocapturer.h" 11 #include "avfoundationvideocapturer.h"
12 12
13 #import <AVFoundation/AVFoundation.h> 13 #import <AVFoundation/AVFoundation.h>
14 14
15 #import "RTCAVFoundationVideoCapturerInternal.h" 15 #import "RTCAVFoundationVideoCapturerInternal.h"
16 #import "RTCDispatcher+Private.h" 16 #import "RTCDispatcher+Private.h"
17 #import "WebRTC/RTCLogging.h" 17 #import "WebRTC/RTCLogging.h"
18 18
19 #include "avfoundationformatmapper.h" 19 #include "avfoundationformatmapper.h"
20 #include "libyuv/rotate.h" 20
21 #include "webrtc/api/video/video_rotation.h"
21 #include "webrtc/base/bind.h" 22 #include "webrtc/base/bind.h"
22 #include "webrtc/base/checks.h" 23 #include "webrtc/base/checks.h"
23 #include "webrtc/base/logging.h" 24 #include "webrtc/base/logging.h"
24 #include "webrtc/base/thread.h" 25 #include "webrtc/base/thread.h"
25 #include "webrtc/common_video/include/corevideo_frame_buffer.h" 26 #include "webrtc/common_video/include/corevideo_frame_buffer.h"
26 #include "webrtc/common_video/rotation.h"
27 27
28 namespace webrtc { 28 namespace webrtc {
29 29
30 enum AVFoundationVideoCapturerMessageType : uint32_t { 30 enum AVFoundationVideoCapturerMessageType : uint32_t {
31 kMessageTypeFrame, 31 kMessageTypeFrame,
32 }; 32 };
33 33
34 AVFoundationVideoCapturer::AVFoundationVideoCapturer() : _capturer(nil) { 34 AVFoundationVideoCapturer::AVFoundationVideoCapturer() : _capturer(nil) {
35 _capturer = 35 _capturer =
36 [[RTCAVFoundationVideoCapturerInternal alloc] initWithCapturer:this]; 36 [[RTCAVFoundationVideoCapturerInternal alloc] initWithCapturer:this];
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 rtc::scoped_refptr<VideoFrameBuffer> buffer = 153 rtc::scoped_refptr<VideoFrameBuffer> buffer =
154 new rtc::RefCountedObject<CoreVideoFrameBuffer>( 154 new rtc::RefCountedObject<CoreVideoFrameBuffer>(
155 image_buffer, 155 image_buffer,
156 adapted_width, adapted_height, 156 adapted_width, adapted_height,
157 crop_width, crop_height, 157 crop_width, crop_height,
158 crop_x, crop_y); 158 crop_x, crop_y);
159 159
160 // Applying rotation is only supported for legacy reasons and performance is 160 // Applying rotation is only supported for legacy reasons and performance is
161 // not critical here. 161 // not critical here.
162 if (apply_rotation() && rotation != kVideoRotation_0) { 162 if (apply_rotation() && rotation != kVideoRotation_0) {
163 buffer = buffer->NativeToI420Buffer(); 163 buffer = I420Buffer::Rotate(buffer->NativeToI420Buffer(),
164 rtc::scoped_refptr<I420Buffer> rotated_buffer; 164 rotation);
165 if (rotation == kVideoRotation_0 || rotation == kVideoRotation_180) { 165 if (rotation == kVideoRotation_90 || rotation == kVideoRotation_270) {
166 rotated_buffer = I420Buffer::Create(adapted_width, adapted_height);
167 } else {
168 // Swap width and height.
169 rotated_buffer = I420Buffer::Create(adapted_height, adapted_width);
170 std::swap(captured_width, captured_height); 166 std::swap(captured_width, captured_height);
171 } 167 }
172 libyuv::I420Rotate( 168
173 buffer->DataY(), buffer->StrideY(),
174 buffer->DataU(), buffer->StrideU(),
175 buffer->DataV(), buffer->StrideV(),
176 rotated_buffer->MutableDataY(), rotated_buffer->StrideY(),
177 rotated_buffer->MutableDataU(), rotated_buffer->StrideU(),
178 rotated_buffer->MutableDataV(), rotated_buffer->StrideV(),
179 buffer->width(), buffer->height(),
180 static_cast<libyuv::RotationMode>(rotation));
181 buffer = rotated_buffer;
182 rotation = kVideoRotation_0; 169 rotation = kVideoRotation_0;
183 } 170 }
184 171
185 OnFrame(webrtc::VideoFrame(buffer, rotation, translated_camera_time_us), 172 OnFrame(webrtc::VideoFrame(buffer, rotation, translated_camera_time_us),
186 captured_width, captured_height); 173 captured_width, captured_height);
187 } 174 }
188 175
189 } // namespace webrtc 176 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698