OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_qtkit_mac.h" | 5 #import "media/video/capture/mac/video_capture_device_qtkit_mac.h" |
6 | 6 |
7 #import <QTKit/QTKit.h> | 7 #import <QTKit/QTKit.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "media/video/capture/mac/video_capture_device_mac.h" | 10 #include "media/video/capture/mac/video_capture_device_mac.h" |
11 #include "media/video/capture/video_capture_device.h" | 11 #include "media/video/capture/video_capture_device.h" |
12 #include "media/video/capture/video_capture_types.h" | 12 #include "media/video/capture/video_capture_types.h" |
13 | 13 |
14 @implementation VideoCaptureDeviceQTKit | 14 @implementation VideoCaptureDeviceQTKit |
15 | 15 |
16 #pragma mark Class methods | 16 #pragma mark Class methods |
17 | 17 |
18 + (NSDictionary *)deviceNames { | 18 + (void)getDeviceNames:(NSMutableDictionary*)deviceNames { |
19 NSArray *captureDevices = | 19 NSArray *captureDevices = |
20 [QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeVideo]; | 20 [QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeVideo]; |
21 | |
22 for (QTCaptureDevice* device in captureDevices) { | |
23 [deviceNames setObject:[device localizedDisplayName] | |
24 forKey:[device uniqueID]]; | |
25 } | |
26 } | |
27 | |
28 + (NSDictionary *)deviceNames { | |
sail
2012/10/09 23:53:39
no space before *
| |
21 NSMutableDictionary *deviceNames = | 29 NSMutableDictionary *deviceNames = |
22 [[[NSMutableDictionary alloc] init] autorelease]; | 30 [[[NSMutableDictionary alloc] init] autorelease]; |
23 | 31 |
24 for (QTCaptureDevice* device in captureDevices) { | 32 // TODO(shess): Post to the main thread to see if that helps |
25 NSString* qtDeviceName = [device localizedDisplayName]; | 33 // http://crbug.com/139164 |
26 NSString* qtUniqueId = [device uniqueID]; | 34 [self performSelectorOnMainThread:@selector(getDeviceNames:) |
27 [deviceNames setObject:qtDeviceName forKey:qtUniqueId]; | 35 withObject:deviceNames |
28 } | 36 waitUntilDone:YES]; |
29 return deviceNames; | 37 return deviceNames; |
30 } | 38 } |
31 | 39 |
32 #pragma mark Public methods | 40 #pragma mark Public methods |
33 | 41 |
34 - (id)initWithFrameReceiver:(media::VideoCaptureDeviceMac *)frameReceiver { | 42 - (id)initWithFrameReceiver:(media::VideoCaptureDeviceMac *)frameReceiver { |
35 self = [super init]; | 43 self = [super init]; |
36 if (self) { | 44 if (self) { |
37 frameReceiver_ = frameReceiver; | 45 frameReceiver_ = frameReceiver; |
38 lock_ = [[NSLock alloc] init]; | 46 lock_ = [[NSLock alloc] init]; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 | 228 |
221 // Deliver the captured video frame. | 229 // Deliver the captured video frame. |
222 frameReceiver_->ReceiveFrame(addressToPass, frameSize, captureCapability); | 230 frameReceiver_->ReceiveFrame(addressToPass, frameSize, captureCapability); |
223 | 231 |
224 CVPixelBufferUnlockBaseAddress(videoFrame, kLockFlags); | 232 CVPixelBufferUnlockBaseAddress(videoFrame, kLockFlags); |
225 } | 233 } |
226 [lock_ unlock]; | 234 [lock_ unlock]; |
227 } | 235 } |
228 | 236 |
229 @end | 237 @end |
OLD | NEW |