Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: media/capture/video/mac/video_capture_device_avfoundation_mac.mm

Issue 2585383002: Fix low frame rate problems in high resolution USB cameras using AVFoundation (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <AVFoundation/AVFoundation.h> 7 #import <AVFoundation/AVFoundation.h>
8 #import <CoreMedia/CoreMedia.h> 8 #import <CoreMedia/CoreMedia.h>
9 #import <CoreVideo/CoreVideo.h> 9 #import <CoreVideo/CoreVideo.h>
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 captureDevice_ = nil; 254 captureDevice_ = nil;
255 [self sendErrorString: 255 [self sendErrorString:
256 [NSString stringWithFormat: 256 [NSString stringWithFormat:
257 @"Could not create video capture input (%@): %@", 257 @"Could not create video capture input (%@): %@",
258 [error localizedDescription], 258 [error localizedDescription],
259 [error localizedFailureReason]]]; 259 [error localizedFailureReason]]];
260 return NO; 260 return NO;
261 } 261 }
262 [captureSession_ addInput:captureDeviceInput_]; 262 [captureSession_ addInput:captureDeviceInput_];
263 263
264 // Create and plug the still image capture output. This should happen in
265 // advance of the actual picture to allow for the 3A to stabilize.
266 stillImageOutput_.reset([[AVCaptureStillImageOutput alloc] init]);
267 if (stillImageOutput_ && [captureSession_ canAddOutput:stillImageOutput_])
268 [captureSession_ addOutput:stillImageOutput_];
269
264 // Create a new data output for video. The data output is configured to 270 // Create a new data output for video. The data output is configured to
265 // discard late frames by default. 271 // discard late frames by default.
266 captureVideoDataOutput_.reset([[AVCaptureVideoDataOutput alloc] init]); 272 captureVideoDataOutput_.reset([[AVCaptureVideoDataOutput alloc] init]);
267 if (!captureVideoDataOutput_) { 273 if (!captureVideoDataOutput_) {
268 [captureSession_ removeInput:captureDeviceInput_]; 274 [captureSession_ removeInput:captureDeviceInput_];
269 [self sendErrorString:[NSString stringWithUTF8String: 275 [self sendErrorString:[NSString stringWithUTF8String:
270 "Could not create video data output."]]; 276 "Could not create video data output."]];
271 return NO; 277 return NO;
272 } 278 }
273 [captureVideoDataOutput_ setAlwaysDiscardsLateVideoFrames:true]; 279 [captureVideoDataOutput_ setAlwaysDiscardsLateVideoFrames:true];
274 [captureVideoDataOutput_ 280 [captureVideoDataOutput_
275 setSampleBufferDelegate:self 281 setSampleBufferDelegate:self
276 queue:dispatch_get_global_queue( 282 queue:dispatch_get_global_queue(
277 DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)]; 283 DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)];
278 [captureSession_ addOutput:captureVideoDataOutput_]; 284 [captureSession_ addOutput:captureVideoDataOutput_];
279 285
280 // Create and plug the still image capture output. This should happen in
281 // advance of the actual picture to allow for the 3A to stabilize.
282 stillImageOutput_.reset([[AVCaptureStillImageOutput alloc] init]);
283 if (stillImageOutput_ && [captureSession_ canAddOutput:stillImageOutput_])
284 [captureSession_ addOutput:stillImageOutput_];
285
286 return YES; 286 return YES;
287 } 287 }
288 288
289 - (BOOL)setCaptureHeight:(int)height 289 - (BOOL)setCaptureHeight:(int)height
290 width:(int)width 290 width:(int)width
291 frameRate:(float)frameRate { 291 frameRate:(float)frameRate {
292 DCHECK(![captureSession_ isRunning] && 292 DCHECK(![captureSession_ isRunning] &&
293 main_thread_checker_.CalledOnValidThread()); 293 main_thread_checker_.CalledOnValidThread());
294 294
295 frameWidth_ = width; 295 frameWidth_ = width;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 } 490 }
491 491
492 - (void)sendErrorString:(NSString*)error { 492 - (void)sendErrorString:(NSString*)error {
493 DLOG(ERROR) << [error UTF8String]; 493 DLOG(ERROR) << [error UTF8String];
494 base::AutoLock lock(lock_); 494 base::AutoLock lock(lock_);
495 if (frameReceiver_) 495 if (frameReceiver_)
496 frameReceiver_->ReceiveError(FROM_HERE, [error UTF8String]); 496 frameReceiver_->ReceiveError(FROM_HERE, [error UTF8String]);
497 } 497 }
498 498
499 @end 499 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698