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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::VideoCaptureDevice::Name&)name | 168 + (void)getDevice:(const media::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] == name.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) { |
179 // MediaSubType is a CMPixelFormatType but can be used as CVPixelFormatType | 179 // MediaSubType is a CMPixelFormatType but can be used as CVPixelFormatType |
180 // as well according to CMFormatDescription.h | 180 // as well according to CMFormatDescription.h |
181 const media::VideoPixelFormat pixelFormat = FourCCToChromiumPixelFormat( | 181 const media::VideoPixelFormat pixelFormat = FourCCToChromiumPixelFormat( |
182 CoreMediaGlue::CMFormatDescriptionGetMediaSubType( | 182 CoreMediaGlue::CMFormatDescriptionGetMediaSubType( |
183 [format formatDescription])); | 183 [format formatDescription])); |
184 | 184 |
185 CoreMediaGlue::CMVideoDimensions dimensions = | 185 CoreMediaGlue::CMVideoDimensions dimensions = |
186 CoreMediaGlue::CMVideoFormatDescriptionGetDimensions( | 186 CoreMediaGlue::CMVideoFormatDescriptionGetDimensions( |
187 [format formatDescription]); | 187 [format formatDescription]); |
188 | 188 |
189 for (CrAVFrameRateRange* frameRate in | 189 for (CrAVFrameRateRange* frameRate in |
190 [format videoSupportedFrameRateRanges]) { | 190 [format videoSupportedFrameRateRanges]) { |
191 media::VideoCaptureFormat format( | 191 media::VideoCaptureFormat format( |
192 gfx::Size(dimensions.width, dimensions.height), | 192 gfx::Size(dimensions.width, dimensions.height), |
193 frameRate.maxFrameRate, pixelFormat); | 193 frameRate.maxFrameRate, pixelFormat); |
194 formats->push_back(format); | 194 formats->push_back(format); |
195 DVLOG(2) << name.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:(media::VideoCaptureDeviceMac*)frameReceiver { |
204 if ((self = [super init])) { | 204 if ((self = [super init])) { |
205 DCHECK(main_thread_checker_.CalledOnValidThread()); | 205 DCHECK(main_thread_checker_.CalledOnValidThread()); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |