| 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/capture/video/mac/video_capture_device_avfoundation_mac.h" | 5 #import "media/capture/video/mac/video_capture_device_avfoundation_mac.h" |
| 6 | 6 |
| 7 #import <CoreMedia/CoreMedia.h> | 7 #import <CoreMedia/CoreMedia.h> |
| 8 #import <CoreVideo/CoreVideo.h> | 8 #import <CoreVideo/CoreVideo.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 captureDevice_ = nil; | 259 captureDevice_ = nil; |
| 260 [self sendErrorString: | 260 [self sendErrorString: |
| 261 [NSString stringWithFormat: | 261 [NSString stringWithFormat: |
| 262 @"Could not create video capture input (%@): %@", | 262 @"Could not create video capture input (%@): %@", |
| 263 [error localizedDescription], | 263 [error localizedDescription], |
| 264 [error localizedFailureReason]]]; | 264 [error localizedFailureReason]]]; |
| 265 return NO; | 265 return NO; |
| 266 } | 266 } |
| 267 [captureSession_ addInput:captureDeviceInput_]; | 267 [captureSession_ addInput:captureDeviceInput_]; |
| 268 | 268 |
| 269 // Create and plug the still image capture output. This should happen in |
| 270 // advance of the actual picture to allow for the 3A to stabilize. |
| 271 stillImageOutput_.reset( |
| 272 [[AVFoundationGlue::AVCaptureStillImageOutputClass() alloc] init]); |
| 273 if (stillImageOutput_ && [captureSession_ canAddOutput:stillImageOutput_]) |
| 274 [captureSession_ addOutput:stillImageOutput_]; |
| 275 |
| 269 // Create a new data output for video. The data output is configured to | 276 // Create a new data output for video. The data output is configured to |
| 270 // discard late frames by default. | 277 // discard late frames by default. |
| 271 captureVideoDataOutput_.reset( | 278 captureVideoDataOutput_.reset( |
| 272 [[AVFoundationGlue::AVCaptureVideoDataOutputClass() alloc] init]); | 279 [[AVFoundationGlue::AVCaptureVideoDataOutputClass() alloc] init]); |
| 273 if (!captureVideoDataOutput_) { | 280 if (!captureVideoDataOutput_) { |
| 274 [captureSession_ removeInput:captureDeviceInput_]; | 281 [captureSession_ removeInput:captureDeviceInput_]; |
| 275 [self sendErrorString:[NSString stringWithUTF8String: | 282 [self sendErrorString:[NSString stringWithUTF8String: |
| 276 "Could not create video data output."]]; | 283 "Could not create video data output."]]; |
| 277 return NO; | 284 return NO; |
| 278 } | 285 } |
| 279 [captureVideoDataOutput_ setAlwaysDiscardsLateVideoFrames:true]; | 286 [captureVideoDataOutput_ setAlwaysDiscardsLateVideoFrames:true]; |
| 280 [captureVideoDataOutput_ | 287 [captureVideoDataOutput_ |
| 281 setSampleBufferDelegate:self | 288 setSampleBufferDelegate:self |
| 282 queue:dispatch_get_global_queue( | 289 queue:dispatch_get_global_queue( |
| 283 DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)]; | 290 DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)]; |
| 284 [captureSession_ addOutput:captureVideoDataOutput_]; | 291 [captureSession_ addOutput:captureVideoDataOutput_]; |
| 285 | 292 |
| 286 // Create and plug the still image capture output. This should happen in | |
| 287 // advance of the actual picture to allow for the 3A to stabilize. | |
| 288 stillImageOutput_.reset( | |
| 289 [[AVFoundationGlue::AVCaptureStillImageOutputClass() alloc] init]); | |
| 290 if (stillImageOutput_ && [captureSession_ canAddOutput:stillImageOutput_]) | |
| 291 [captureSession_ addOutput:stillImageOutput_]; | |
| 292 | |
| 293 return YES; | 293 return YES; |
| 294 } | 294 } |
| 295 | 295 |
| 296 - (BOOL)setCaptureHeight:(int)height | 296 - (BOOL)setCaptureHeight:(int)height |
| 297 width:(int)width | 297 width:(int)width |
| 298 frameRate:(float)frameRate { | 298 frameRate:(float)frameRate { |
| 299 DCHECK(![captureSession_ isRunning] && | 299 DCHECK(![captureSession_ isRunning] && |
| 300 main_thread_checker_.CalledOnValidThread()); | 300 main_thread_checker_.CalledOnValidThread()); |
| 301 | 301 |
| 302 frameWidth_ = width; | 302 frameWidth_ = width; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 } | 504 } |
| 505 | 505 |
| 506 - (void)sendErrorString:(NSString*)error { | 506 - (void)sendErrorString:(NSString*)error { |
| 507 DLOG(ERROR) << [error UTF8String]; | 507 DLOG(ERROR) << [error UTF8String]; |
| 508 base::AutoLock lock(lock_); | 508 base::AutoLock lock(lock_); |
| 509 if (frameReceiver_) | 509 if (frameReceiver_) |
| 510 frameReceiver_->ReceiveError(FROM_HERE, [error UTF8String]); | 510 frameReceiver_->ReceiveError(FROM_HERE, [error UTF8String]); |
| 511 } | 511 } |
| 512 | 512 |
| 513 @end | 513 @end |
| OLD | NEW |