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

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

Issue 1853743003: Remove platform_video_capturing_mac and the callback thread checker in VideoCaptureDeviceAVFoundati… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed extra line Created 4 years, 8 months 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
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 <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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 setSampleBufferDelegate:self 244 setSampleBufferDelegate:self
245 queue:dispatch_get_global_queue( 245 queue:dispatch_get_global_queue(
246 DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)]; 246 DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)];
247 [captureSession_ addOutput:captureVideoDataOutput_]; 247 [captureSession_ addOutput:captureVideoDataOutput_];
248 return YES; 248 return YES;
249 } 249 }
250 250
251 - (BOOL)setCaptureHeight:(int)height 251 - (BOOL)setCaptureHeight:(int)height
252 width:(int)width 252 width:(int)width
253 frameRate:(float)frameRate { 253 frameRate:(float)frameRate {
254 // Check if either of VideoCaptureDeviceMac::AllocateAndStart() or 254 DCHECK(![captureSession_ isRunning] &&
255 // VideoCaptureDeviceMac::ReceiveFrame() is calling here, depending on the 255 main_thread_checker_.CalledOnValidThread());
256 // running state. VCDM::ReceiveFrame() calls here to change aspect ratio.
257 DCHECK((![captureSession_ isRunning] &&
258 main_thread_checker_.CalledOnValidThread()) ||
259 callback_thread_checker_.CalledOnValidThread());
260 256
261 frameWidth_ = width; 257 frameWidth_ = width;
262 frameHeight_ = height; 258 frameHeight_ = height;
263 frameRate_ = frameRate; 259 frameRate_ = frameRate;
264 260
265 FourCharCode best_fourcc = kCVPixelFormatType_422YpCbCr8; 261 FourCharCode best_fourcc = kCVPixelFormatType_422YpCbCr8;
266 const bool prefer_mjpeg = 262 const bool prefer_mjpeg =
267 width > kMjpegWidthThreshold || height > kMjpegHeightThreshold; 263 width > kMjpegWidthThreshold || height > kMjpegHeightThreshold;
268 for (CrAVCaptureDeviceFormat* format in captureDevice_.formats) { 264 for (CrAVCaptureDeviceFormat* format in captureDevice_.formats) {
269 const FourCharCode fourcc = 265 const FourCharCode fourcc =
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 - (void)stopCapture { 339 - (void)stopCapture {
344 DCHECK(main_thread_checker_.CalledOnValidThread()); 340 DCHECK(main_thread_checker_.CalledOnValidThread());
345 if ([captureSession_ isRunning]) 341 if ([captureSession_ isRunning])
346 [captureSession_ stopRunning]; // Synchronous. 342 [captureSession_ stopRunning]; // Synchronous.
347 [[NSNotificationCenter defaultCenter] removeObserver:self]; 343 [[NSNotificationCenter defaultCenter] removeObserver:self];
348 } 344 }
349 345
350 #pragma mark Private methods 346 #pragma mark Private methods
351 347
352 // |captureOutput| is called by the capture device to deliver a new frame. 348 // |captureOutput| is called by the capture device to deliver a new frame.
349 // AVFoundation calls from a number of threads, depending on, at least, if
350 // Chrome is on foreground or background.
353 - (void)captureOutput:(CrAVCaptureOutput*)captureOutput 351 - (void)captureOutput:(CrAVCaptureOutput*)captureOutput
354 didOutputSampleBuffer:(CoreMediaGlue::CMSampleBufferRef)sampleBuffer 352 didOutputSampleBuffer:(CoreMediaGlue::CMSampleBufferRef)sampleBuffer
355 fromConnection:(CrAVCaptureConnection*)connection { 353 fromConnection:(CrAVCaptureConnection*)connection {
356 // AVFoundation calls from a number of threads, depending on, at least, if
357 // Chrome is on foreground or background. Sample the actual thread here.
358 callback_thread_checker_.DetachFromThread();
359 CHECK(callback_thread_checker_.CalledOnValidThread());
360
361 const CoreMediaGlue::CMFormatDescriptionRef formatDescription = 354 const CoreMediaGlue::CMFormatDescriptionRef formatDescription =
362 CoreMediaGlue::CMSampleBufferGetFormatDescription(sampleBuffer); 355 CoreMediaGlue::CMSampleBufferGetFormatDescription(sampleBuffer);
363 const FourCharCode fourcc = 356 const FourCharCode fourcc =
364 CoreMediaGlue::CMFormatDescriptionGetMediaSubType(formatDescription); 357 CoreMediaGlue::CMFormatDescriptionGetMediaSubType(formatDescription);
365 const CoreMediaGlue::CMVideoDimensions dimensions = 358 const CoreMediaGlue::CMVideoDimensions dimensions =
366 CoreMediaGlue::CMVideoFormatDescriptionGetDimensions(formatDescription); 359 CoreMediaGlue::CMVideoFormatDescriptionGetDimensions(formatDescription);
367 const media::VideoCaptureFormat captureFormat( 360 const media::VideoCaptureFormat captureFormat(
368 gfx::Size(dimensions.width, dimensions.height), frameRate_, 361 gfx::Size(dimensions.width, dimensions.height), frameRate_,
369 FourCCToChromiumPixelFormat(fourcc)); 362 FourCCToChromiumPixelFormat(fourcc));
370 363
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 } 420 }
428 421
429 - (void)sendErrorString:(NSString*)error { 422 - (void)sendErrorString:(NSString*)error {
430 DLOG(ERROR) << [error UTF8String]; 423 DLOG(ERROR) << [error UTF8String];
431 base::AutoLock lock(lock_); 424 base::AutoLock lock(lock_);
432 if (frameReceiver_) 425 if (frameReceiver_)
433 frameReceiver_->ReceiveError(FROM_HERE, [error UTF8String]); 426 frameReceiver_->ReceiveError(FROM_HERE, [error UTF8String]);
434 } 427 }
435 428
436 @end 429 @end
OLDNEW
« no previous file with comments | « media/capture/video/mac/video_capture_device_avfoundation_mac.h ('k') | media/capture/video/mac/video_capture_device_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698