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

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

Issue 2214533002: move //media/capture to //device/capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 "device/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>
11 11
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/mac/foundation_util.h" 14 #include "base/mac/foundation_util.h"
15 #include "base/mac/mac_util.h" 15 #include "base/mac/mac_util.h"
16 #include "base/metrics/histogram_macros.h" 16 #include "base/metrics/histogram_macros.h"
17 #include "device/capture/video/mac/video_capture_device_mac.h"
17 #include "media/base/timestamp_constants.h" 18 #include "media/base/timestamp_constants.h"
18 #include "media/base/video_capture_types.h" 19 #include "media/base/video_capture_types.h"
19 #include "media/capture/video/mac/video_capture_device_mac.h"
20 #include "ui/gfx/geometry/size.h" 20 #include "ui/gfx/geometry/size.h"
21 21
22 // Prefer MJPEG if frame width or height is larger than this. 22 // Prefer MJPEG if frame width or height is larger than this.
23 static const int kMjpegWidthThreshold = 640; 23 static const int kMjpegWidthThreshold = 640;
24 static const int kMjpegHeightThreshold = 480; 24 static const int kMjpegHeightThreshold = 480;
25 25
26 namespace { 26 namespace {
27 27
28 enum MacBookVersions { 28 enum MacBookVersions {
29 OTHER = 0, 29 OTHER = 0,
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 158
159 + (NSDictionary*)deviceNames { 159 + (NSDictionary*)deviceNames {
160 NSMutableDictionary* deviceNames = 160 NSMutableDictionary* deviceNames =
161 [[[NSMutableDictionary alloc] init] autorelease]; 161 [[[NSMutableDictionary alloc] init] autorelease];
162 // The device name retrieval is not going to happen in the main thread, and 162 // The device name retrieval is not going to happen in the main thread, and
163 // this might cause instabilities (it did in QTKit), so keep an eye here. 163 // this might cause instabilities (it did in QTKit), so keep an eye here.
164 [self getDeviceNames:deviceNames]; 164 [self getDeviceNames:deviceNames];
165 return deviceNames; 165 return deviceNames;
166 } 166 }
167 167
168 + (void)getDevice:(const media::VideoCaptureDeviceDescriptor&)descriptor 168 + (void)getDevice:(const device::VideoCaptureDeviceDescriptor&)descriptor
169 supportedFormats:(media::VideoCaptureFormats*)formats { 169 supportedFormats:(media::VideoCaptureFormats*)formats {
170 NSArray* devices = [AVCaptureDeviceGlue devices]; 170 NSArray* devices = [AVCaptureDeviceGlue devices];
171 CrAVCaptureDevice* device = nil; 171 CrAVCaptureDevice* device = nil;
172 for (device in devices) { 172 for (device in devices) {
173 if ([[device uniqueID] UTF8String] == descriptor.device_id) 173 if ([[device uniqueID] UTF8String] == descriptor.device_id)
174 break; 174 break;
175 } 175 }
176 if (device == nil) 176 if (device == nil)
177 return; 177 return;
178 for (CrAVCaptureDeviceFormat* format in device.formats) { 178 for (CrAVCaptureDeviceFormat* format in device.formats) {
(...skipping 14 matching lines...) Expand all
193 frameRate.maxFrameRate, pixelFormat); 193 frameRate.maxFrameRate, pixelFormat);
194 formats->push_back(format); 194 formats->push_back(format);
195 DVLOG(2) << descriptor.display_name << " " 195 DVLOG(2) << descriptor.display_name << " "
196 << media::VideoCaptureFormat::ToString(format); 196 << media::VideoCaptureFormat::ToString(format);
197 } 197 }
198 } 198 }
199 } 199 }
200 200
201 #pragma mark Public methods 201 #pragma mark Public methods
202 202
203 - (id)initWithFrameReceiver:(media::VideoCaptureDeviceMac*)frameReceiver { 203 - (id)initWithFrameReceiver:(device::VideoCaptureDeviceMac*)frameReceiver {
204 if ((self = [super init])) { 204 if ((self = [super init])) {
205 DCHECK(main_thread_checker_.CalledOnValidThread()); 205 DCHECK(main_thread_checker_.CalledOnValidThread());
206 DCHECK(frameReceiver); 206 DCHECK(frameReceiver);
207 [self setFrameReceiver:frameReceiver]; 207 [self setFrameReceiver:frameReceiver];
208 captureSession_.reset( 208 captureSession_.reset(
209 [[AVFoundationGlue::AVCaptureSessionClass() alloc] init]); 209 [[AVFoundationGlue::AVCaptureSessionClass() alloc] init]);
210 } 210 }
211 return self; 211 return self;
212 } 212 }
213 213
214 - (void)dealloc { 214 - (void)dealloc {
215 [self stopCapture]; 215 [self stopCapture];
216 [super dealloc]; 216 [super dealloc];
217 } 217 }
218 218
219 - (void)setFrameReceiver:(media::VideoCaptureDeviceMac*)frameReceiver { 219 - (void)setFrameReceiver:(device::VideoCaptureDeviceMac*)frameReceiver {
220 base::AutoLock lock(lock_); 220 base::AutoLock lock(lock_);
221 frameReceiver_ = frameReceiver; 221 frameReceiver_ = frameReceiver;
222 } 222 }
223 223
224 - (BOOL)setCaptureDevice:(NSString*)deviceId { 224 - (BOOL)setCaptureDevice:(NSString*)deviceId {
225 DCHECK(captureSession_); 225 DCHECK(captureSession_);
226 DCHECK(main_thread_checker_.CalledOnValidThread()); 226 DCHECK(main_thread_checker_.CalledOnValidThread());
227 227
228 if (!deviceId) { 228 if (!deviceId) {
229 // First stop the capture session, if it's running. 229 // First stop the capture session, if it's running.
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 } 503 }
504 504
505 - (void)sendErrorString:(NSString*)error { 505 - (void)sendErrorString:(NSString*)error {
506 DLOG(ERROR) << [error UTF8String]; 506 DLOG(ERROR) << [error UTF8String];
507 base::AutoLock lock(lock_); 507 base::AutoLock lock(lock_);
508 if (frameReceiver_) 508 if (frameReceiver_)
509 frameReceiver_->ReceiveError(FROM_HERE, [error UTF8String]); 509 frameReceiver_->ReceiveError(FROM_HERE, [error UTF8String]);
510 } 510 }
511 511
512 @end 512 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698