OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "media/video/capture/mac/video_capture_device_mac.h" | 5 #include "media/video/capture/mac/video_capture_device_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 "base/time.h" | 10 #include "base/time.h" |
11 #include "media/video/capture/mac/video_capture_device_qtkit_mac.h" | 11 #include "media/video/capture/mac/video_capture_device_qtkit_mac.h" |
12 | 12 |
13 namespace media { | 13 namespace media { |
14 | 14 |
15 void VideoCaptureDevice::GetDeviceNames(Names* device_names) { | 15 void VideoCaptureDevice::GetDeviceNames(Names* device_names) { |
16 // Loop through all available devices and add to |device_names|. | 16 // Loop through all available devices and add to |device_names|. |
17 device_names->clear(); | 17 device_names->clear(); |
18 | 18 |
19 // TODO(mflodman) Return name and id as NSArray* instead of QTCaptureDevice*. | 19 NSDictionary* capture_devices = [VideoCaptureDeviceQTKit deviceNames]; |
20 for (QTCaptureDevice* device in [VideoCaptureDeviceQTKit deviceNames]) { | 20 for (NSString* key in capture_devices) { |
21 Name name; | 21 Name name; |
22 NSString* qt_device_name = [device localizedDisplayName]; | 22 name.device_name = [[capture_devices valueForKey:key] UTF8String]; |
23 name.device_name = [qt_device_name UTF8String]; | 23 name.unique_id = [key UTF8String]; |
24 NSString* qt_unique_id = [device uniqueID]; | |
25 name.unique_id = [qt_unique_id UTF8String]; | |
26 device_names->push_back(name); | 24 device_names->push_back(name); |
27 } | 25 } |
28 } | 26 } |
29 | 27 |
30 VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) { | 28 VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) { |
31 VideoCaptureDeviceMac* capture_device = | 29 VideoCaptureDeviceMac* capture_device = |
32 new VideoCaptureDeviceMac(device_name); | 30 new VideoCaptureDeviceMac(device_name); |
33 if (!capture_device->Init()) { | 31 if (!capture_device->Init()) { |
34 LOG(ERROR) << "Could not initialize VideoCaptureDevice."; | 32 LOG(ERROR) << "Could not initialize VideoCaptureDevice."; |
35 delete capture_device; | 33 delete capture_device; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 base::Time::Now()); | 135 base::Time::Now()); |
138 } | 136 } |
139 | 137 |
140 void VideoCaptureDeviceMac::SetErrorState(const std::string& reason) { | 138 void VideoCaptureDeviceMac::SetErrorState(const std::string& reason) { |
141 DLOG(ERROR) << reason; | 139 DLOG(ERROR) << reason; |
142 state_ = kError; | 140 state_ = kError; |
143 observer_->OnError(); | 141 observer_->OnError(); |
144 } | 142 } |
145 | 143 |
146 } // namespace media | 144 } // namespace media |
OLD | NEW |