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 | 222 [captureSession_ removeInput:captureDeviceInput_]; |
223 // with device enumeration when the active camera is unplugged. | |
224 [captureSession_ stopRunning]; | 223 [captureSession_ stopRunning]; |
225 [captureSession_ removeInput:captureDeviceInput_]; | |
226 } | 224 } |
227 | 225 |
228 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 226 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
229 } | 227 } |
230 | 228 |
231 // |captureOutput| is called by the capture device to deliver a new frame. | 229 // |captureOutput| is called by the capture device to deliver a new frame. |
232 - (void)captureOutput:(QTCaptureOutput*)captureOutput | 230 - (void)captureOutput:(QTCaptureOutput*)captureOutput |
233 didOutputVideoFrame:(CVImageBufferRef)videoFrame | 231 didOutputVideoFrame:(CVImageBufferRef)videoFrame |
234 withSampleBuffer:(QTSampleBuffer*)sampleBuffer | 232 withSampleBuffer:(QTSampleBuffer*)sampleBuffer |
235 fromConnection:(QTCaptureConnection*)connection { | 233 fromConnection:(QTCaptureConnection*)connection { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 [lock_ unlock]; | 306 [lock_ unlock]; |
309 } | 307 } |
310 | 308 |
311 - (void)handleNotification:(NSNotification*)errorNotification { | 309 - (void)handleNotification:(NSNotification*)errorNotification { |
312 NSError * error = (NSError*)[[errorNotification userInfo] | 310 NSError * error = (NSError*)[[errorNotification userInfo] |
313 objectForKey:QTCaptureSessionErrorKey]; | 311 objectForKey:QTCaptureSessionErrorKey]; |
314 frameReceiver_->ReceiveError([[error localizedDescription] UTF8String]); | 312 frameReceiver_->ReceiveError([[error localizedDescription] UTF8String]); |
315 } | 313 } |
316 | 314 |
317 @end | 315 @end |
OLD | NEW |