OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "media/video/capture/mac/video_capture_device_avfoundation_mac.h" | 5 #import "media/video/capture/mac/video_capture_device_avfoundation_mac.h" |
6 | 6 |
7 #import <CoreVideo/CoreVideo.h> | 7 #import <CoreVideo/CoreVideo.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 DLOG(ERROR) << "Video capture device does not support current preset"; | 200 DLOG(ERROR) << "Video capture device does not support current preset"; |
201 return NO; | 201 return NO; |
202 } | 202 } |
203 | 203 |
204 // Despite all Mac documentation detailing that setting the sessionPreset is | 204 // Despite all Mac documentation detailing that setting the sessionPreset is |
205 // enough, that is not the case for, at least, the MacBook Air built-in | 205 // enough, that is not the case for, at least, the MacBook Air built-in |
206 // FaceTime HD Camera, and the capture output has to be configured as well. | 206 // FaceTime HD Camera, and the capture output has to be configured as well. |
207 // The reason for this mismatch is probably because most of the AVFoundation | 207 // The reason for this mismatch is probably because most of the AVFoundation |
208 // docs are written for iOS and not for MacOsX. | 208 // docs are written for iOS and not for MacOsX. |
209 // AVVideoScalingModeKey() refers to letterboxing yes/no and preserve aspect | 209 // AVVideoScalingModeKey() refers to letterboxing yes/no and preserve aspect |
210 // ratio yes/no when scaling. Currently we set letterbox and preservation. | 210 // ratio yes/no when scaling. Currently we set cropping and preservation. |
211 NSDictionary* videoSettingsDictionary = @{ | 211 NSDictionary* videoSettingsDictionary = @{ |
212 (id)kCVPixelBufferWidthKey : @(width), | 212 (id)kCVPixelBufferWidthKey : @(width), |
213 (id)kCVPixelBufferHeightKey : @(height), | 213 (id)kCVPixelBufferHeightKey : @(height), |
214 (id)kCVPixelBufferPixelFormatTypeKey : @(kCVPixelFormatType_422YpCbCr8), | 214 (id)kCVPixelBufferPixelFormatTypeKey : @(kCVPixelFormatType_422YpCbCr8), |
215 AVFoundationGlue::AVVideoScalingModeKey() : | 215 AVFoundationGlue::AVVideoScalingModeKey() : |
216 AVFoundationGlue::AVVideoScalingModeResizeAspect() | 216 AVFoundationGlue::AVVideoScalingModeResizeAspectFill() |
217 }; | 217 }; |
218 [captureVideoDataOutput_ setVideoSettings:videoSettingsDictionary]; | 218 [captureVideoDataOutput_ setVideoSettings:videoSettingsDictionary]; |
219 | 219 |
220 CrAVCaptureConnection* captureConnection = [captureVideoDataOutput_ | 220 CrAVCaptureConnection* captureConnection = [captureVideoDataOutput_ |
221 connectionWithMediaType:AVFoundationGlue::AVMediaTypeVideo()]; | 221 connectionWithMediaType:AVFoundationGlue::AVMediaTypeVideo()]; |
222 // Check selector existence, related to bugs http://crbug.com/327532 and | 222 // Check selector existence, related to bugs http://crbug.com/327532 and |
223 // http://crbug.com/328096. | 223 // http://crbug.com/328096. |
224 if ([captureConnection | 224 if ([captureConnection |
225 respondsToSelector:@selector(isVideoMinFrameDurationSupported)] && | 225 respondsToSelector:@selector(isVideoMinFrameDurationSupported)] && |
226 [captureConnection isVideoMinFrameDurationSupported]) { | 226 [captureConnection isVideoMinFrameDurationSupported]) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 296 |
297 - (void)onVideoError:(NSNotification*)errorNotification { | 297 - (void)onVideoError:(NSNotification*)errorNotification { |
298 NSError* error = base::mac::ObjCCast<NSError>([[errorNotification userInfo] | 298 NSError* error = base::mac::ObjCCast<NSError>([[errorNotification userInfo] |
299 objectForKey:AVFoundationGlue::AVCaptureSessionErrorKey()]); | 299 objectForKey:AVFoundationGlue::AVCaptureSessionErrorKey()]); |
300 base::AutoLock lock(lock_); | 300 base::AutoLock lock(lock_); |
301 if (frameReceiver_) | 301 if (frameReceiver_) |
302 frameReceiver_->ReceiveError([[error localizedDescription] UTF8String]); | 302 frameReceiver_->ReceiveError([[error localizedDescription] UTF8String]); |
303 } | 303 } |
304 | 304 |
305 @end | 305 @end |
OLD | NEW |