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/video/capture/mac/video_capture_device_avfoundation_mac.h" | 5 #import "media/video/capture/mac/video_capture_device_avfoundation_mac.h" |
6 | 6 |
7 #import <CoreVideo/CoreVideo.h> | 7 #import <CoreVideo/CoreVideo.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
11 #include "media/video/capture/mac/video_capture_device_mac.h" | 11 #include "media/video/capture/mac/video_capture_device_mac.h" |
12 #include "ui/gfx/size.h" | 12 #include "ui/gfx/size.h" |
13 | 13 |
14 @implementation VideoCaptureDeviceAVFoundation | 14 @implementation VideoCaptureDeviceAVFoundation |
15 | 15 |
16 #pragma mark Class methods | 16 #pragma mark Class methods |
17 | 17 |
18 + (void)getDeviceNames:(NSMutableDictionary*)deviceNames { | 18 + (void)getDeviceNames:(NSMutableDictionary*)deviceNames { |
19 // At this stage we already know that AVFoundation is supported and the whole | 19 // At this stage we already know that AVFoundation is supported and the whole |
20 // library is loaded and initialised, by the device monitoring. | 20 // library is loaded and initialised, by the device monitoring. |
21 NSArray* devices = [AVCaptureDeviceGlue devices]; | 21 NSArray* devices = [AVCaptureDeviceGlue devices]; |
22 for (CrAVCaptureDevice* device in devices) { | 22 for (CrAVCaptureDevice* device in devices) { |
23 if (([device hasMediaType:AVFoundationGlue::AVMediaTypeVideo()] || | 23 if (([device hasMediaType:AVFoundationGlue::AVMediaTypeVideo()] || |
24 [device hasMediaType:AVFoundationGlue::AVMediaTypeMuxed()]) && | 24 [device hasMediaType:AVFoundationGlue::AVMediaTypeMuxed()]) && |
25 ![device isSuspended]) { | 25 ![device isSuspended]) { |
26 [deviceNames setObject:[device localizedName] | 26 DeviceNameAndTransportType* nameAndTransportType = |
| 27 [[[DeviceNameAndTransportType alloc] |
| 28 initWithName:[device localizedName] |
| 29 transportType:[device transportType]] autorelease]; |
| 30 [deviceNames setObject:nameAndTransportType |
27 forKey:[device uniqueID]]; | 31 forKey:[device uniqueID]]; |
28 } | 32 } |
29 } | 33 } |
30 } | 34 } |
31 | 35 |
32 + (NSDictionary*)deviceNames { | 36 + (NSDictionary*)deviceNames { |
33 NSMutableDictionary* deviceNames = | 37 NSMutableDictionary* deviceNames = |
34 [[[NSMutableDictionary alloc] init] autorelease]; | 38 [[[NSMutableDictionary alloc] init] autorelease]; |
35 // The device name retrieval is not going to happen in the main thread, and | 39 // The device name retrieval is not going to happen in the main thread, and |
36 // this might cause instabilities (it did in QTKit), so keep an eye here. | 40 // this might cause instabilities (it did in QTKit), so keep an eye here. |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 } | 288 } |
285 | 289 |
286 - (void)sendErrorString:(NSString*)error { | 290 - (void)sendErrorString:(NSString*)error { |
287 DLOG(ERROR) << [error UTF8String]; | 291 DLOG(ERROR) << [error UTF8String]; |
288 base::AutoLock lock(lock_); | 292 base::AutoLock lock(lock_); |
289 if (frameReceiver_) | 293 if (frameReceiver_) |
290 frameReceiver_->ReceiveError([error UTF8String]); | 294 frameReceiver_->ReceiveError([error UTF8String]); |
291 } | 295 } |
292 | 296 |
293 @end | 297 @end |
OLD | NEW |