OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_qtkit_mac.h" | 5 #import "media/video/capture/mac/video_capture_device_qtkit_mac.h" |
6 | 6 |
7 #import <QTKit/QTKit.h> | 7 #import <QTKit/QTKit.h> |
8 | 8 |
9 #include "base/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 selector:@selector(handleNotification:) | 212 selector:@selector(handleNotification:) |
213 name:QTCaptureSessionRuntimeErrorNotification | 213 name:QTCaptureSessionRuntimeErrorNotification |
214 object:captureSession_]; | 214 object:captureSession_]; |
215 [captureSession_ startRunning]; | 215 [captureSession_ startRunning]; |
216 } | 216 } |
217 return YES; | 217 return YES; |
218 } | 218 } |
219 | 219 |
220 - (void)stopCapture { | 220 - (void)stopCapture { |
221 if ([[captureSession_ inputs] count] == 1) { | 221 if ([[captureSession_ inputs] count] == 1) { |
| 222 // |stopRunning| must be called before |removeInput:| to avoid a deadlock |
| 223 // with device enumeration when the active camera is unplugged. |
| 224 [captureSession_ stopRunning]; |
222 [captureSession_ removeInput:captureDeviceInput_]; | 225 [captureSession_ removeInput:captureDeviceInput_]; |
223 [captureSession_ stopRunning]; | |
224 } | 226 } |
225 | 227 |
226 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 228 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
227 } | 229 } |
228 | 230 |
229 // |captureOutput| is called by the capture device to deliver a new frame. | 231 // |captureOutput| is called by the capture device to deliver a new frame. |
230 - (void)captureOutput:(QTCaptureOutput*)captureOutput | 232 - (void)captureOutput:(QTCaptureOutput*)captureOutput |
231 didOutputVideoFrame:(CVImageBufferRef)videoFrame | 233 didOutputVideoFrame:(CVImageBufferRef)videoFrame |
232 withSampleBuffer:(QTSampleBuffer*)sampleBuffer | 234 withSampleBuffer:(QTSampleBuffer*)sampleBuffer |
233 fromConnection:(QTCaptureConnection*)connection { | 235 fromConnection:(QTCaptureConnection*)connection { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 [lock_ unlock]; | 308 [lock_ unlock]; |
307 } | 309 } |
308 | 310 |
309 - (void)handleNotification:(NSNotification*)errorNotification { | 311 - (void)handleNotification:(NSNotification*)errorNotification { |
310 NSError * error = (NSError*)[[errorNotification userInfo] | 312 NSError * error = (NSError*)[[errorNotification userInfo] |
311 objectForKey:QTCaptureSessionErrorKey]; | 313 objectForKey:QTCaptureSessionErrorKey]; |
312 frameReceiver_->ReceiveError([[error localizedDescription] UTF8String]); | 314 frameReceiver_->ReceiveError([[error localizedDescription] UTF8String]); |
313 } | 315 } |
314 | 316 |
315 @end | 317 @end |
OLD | NEW |