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" | |
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 } |
172 // TODO(mcasas): Allow exceptions in the following call, related to bugs | |
173 // http://crbug.com/327532 and http://crbug.com/328096. | |
174 base::mac::ScopedNSExceptionEnabler enabler; | |
171 if ([captureConnection isVideoMaxFrameDurationSupported]) { | 175 if ([captureConnection isVideoMaxFrameDurationSupported]) { |
Robert Sesek
2013/12/16 15:41:35
Instead, if ([captureConnection respondsToSelector
| |
172 [captureConnection setVideoMaxFrameDuration: | 176 [captureConnection setVideoMaxFrameDuration: |
173 CoreMediaGlue::CMTimeMake(1, frameRate)]; | 177 CoreMediaGlue::CMTimeMake(1, frameRate)]; |
174 } | 178 } |
175 return YES; | 179 return YES; |
176 } | 180 } |
177 | 181 |
178 - (BOOL)startCapture { | 182 - (BOOL)startCapture { |
179 DCHECK(thread_checker_.CalledOnValidThread()); | 183 DCHECK(thread_checker_.CalledOnValidThread()); |
180 if (!captureSession_) { | 184 if (!captureSession_) { |
181 DLOG(ERROR) << "Video capture session not initialized."; | 185 DLOG(ERROR) << "Video capture session not initialized."; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 | 235 |
232 - (void)onVideoError:(NSNotification*)errorNotification { | 236 - (void)onVideoError:(NSNotification*)errorNotification { |
233 NSError* error = base::mac::ObjCCast<NSError>([[errorNotification userInfo] | 237 NSError* error = base::mac::ObjCCast<NSError>([[errorNotification userInfo] |
234 objectForKey:AVFoundationGlue::AVCaptureSessionErrorKey()]); | 238 objectForKey:AVFoundationGlue::AVCaptureSessionErrorKey()]); |
235 base::AutoLock lock(lock_); | 239 base::AutoLock lock(lock_); |
236 if (frameReceiver_) | 240 if (frameReceiver_) |
237 frameReceiver_->ReceiveError([[error localizedDescription] UTF8String]); | 241 frameReceiver_->ReceiveError([[error localizedDescription] UTF8String]); |
238 } | 242 } |
239 | 243 |
240 @end | 244 @end |
OLD | NEW |