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" |
11 #include "base/mac/scoped_nsexception_enabler.h" | |
Robert Sesek
2013/12/16 17:20:57
Remove
| |
11 #include "media/video/capture/mac/video_capture_device_mac.h" | 12 #include "media/video/capture/mac/video_capture_device_mac.h" |
12 #include "ui/gfx/size.h" | 13 #include "ui/gfx/size.h" |
13 | 14 |
14 @implementation VideoCaptureDeviceAVFoundation | 15 @implementation VideoCaptureDeviceAVFoundation |
15 | 16 |
16 #pragma mark Class methods | 17 #pragma mark Class methods |
17 | 18 |
18 + (void)getDeviceNames:(NSMutableDictionary*)deviceNames { | 19 + (void)getDeviceNames:(NSMutableDictionary*)deviceNames { |
19 // At this stage we already know that AVFoundation is supported and the whole | 20 // At this stage we already know that AVFoundation is supported and the whole |
20 // library is loaded and initialised, by the device monitoring. | 21 // library is loaded and initialised, by the device monitoring. |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 AVFoundationGlue::AVVideoScalingModeResizeAspect() | 162 AVFoundationGlue::AVVideoScalingModeResizeAspect() |
162 }; | 163 }; |
163 [captureVideoDataOutput_ setVideoSettings:videoSettingsDictionary]; | 164 [captureVideoDataOutput_ setVideoSettings:videoSettingsDictionary]; |
164 | 165 |
165 CrAVCaptureConnection* captureConnection = [captureVideoDataOutput_ | 166 CrAVCaptureConnection* captureConnection = [captureVideoDataOutput_ |
166 connectionWithMediaType:AVFoundationGlue::AVMediaTypeVideo()]; | 167 connectionWithMediaType:AVFoundationGlue::AVMediaTypeVideo()]; |
167 if ([captureConnection isVideoMinFrameDurationSupported]) { | 168 if ([captureConnection isVideoMinFrameDurationSupported]) { |
168 [captureConnection setVideoMinFrameDuration: | 169 [captureConnection setVideoMinFrameDuration: |
169 CoreMediaGlue::CMTimeMake(1, frameRate)]; | 170 CoreMediaGlue::CMTimeMake(1, frameRate)]; |
170 } | 171 } |
171 if ([captureConnection isVideoMaxFrameDurationSupported]) { | 172 // TODO(mcasas): Check selector existence, related to bugs |
173 // http://crbug.com/327532 and http://crbug.com/328096. | |
174 if ([captureConnection | |
175 respondsToSelector:@selector(isVideoMaxFrameDurationSupported)] && | |
176 [captureConnection isVideoMaxFrameDurationSupported]) { | |
172 [captureConnection setVideoMaxFrameDuration: | 177 [captureConnection setVideoMaxFrameDuration: |
173 CoreMediaGlue::CMTimeMake(1, frameRate)]; | 178 CoreMediaGlue::CMTimeMake(1, frameRate)]; |
174 } | 179 } |
175 return YES; | 180 return YES; |
176 } | 181 } |
177 | 182 |
178 - (BOOL)startCapture { | 183 - (BOOL)startCapture { |
179 DCHECK(thread_checker_.CalledOnValidThread()); | 184 DCHECK(thread_checker_.CalledOnValidThread()); |
180 if (!captureSession_) { | 185 if (!captureSession_) { |
181 DLOG(ERROR) << "Video capture session not initialized."; | 186 DLOG(ERROR) << "Video capture session not initialized."; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 | 236 |
232 - (void)onVideoError:(NSNotification*)errorNotification { | 237 - (void)onVideoError:(NSNotification*)errorNotification { |
233 NSError* error = base::mac::ObjCCast<NSError>([[errorNotification userInfo] | 238 NSError* error = base::mac::ObjCCast<NSError>([[errorNotification userInfo] |
234 objectForKey:AVFoundationGlue::AVCaptureSessionErrorKey()]); | 239 objectForKey:AVFoundationGlue::AVCaptureSessionErrorKey()]); |
235 base::AutoLock lock(lock_); | 240 base::AutoLock lock(lock_); |
236 if (frameReceiver_) | 241 if (frameReceiver_) |
237 frameReceiver_->ReceiveError([[error localizedDescription] UTF8String]); | 242 frameReceiver_->ReceiveError([[error localizedDescription] UTF8String]); |
238 } | 243 } |
239 | 244 |
240 @end | 245 @end |
OLD | NEW |