OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_factory_mac.h" | 5 #include "media/video/capture/mac/video_capture_device_factory_mac.h" |
6 | 6 |
7 #import <IOKit/audio/IOAudioTypes.h> | 7 #import <IOKit/audio/IOAudioTypes.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 VideoCaptureDevice::Names::iterator it = device_names->begin(); | 92 VideoCaptureDevice::Names::iterator it = device_names->begin(); |
93 for (; it != device_names->end(); ++it) { | 93 for (; it != device_names->end(); ++it) { |
94 if (it->id() == device_name.id()) | 94 if (it->id() == device_name.id()) |
95 break; | 95 break; |
96 } | 96 } |
97 if (it == device_names->end()) | 97 if (it == device_names->end()) |
98 return scoped_ptr<VideoCaptureDevice>(); | 98 return scoped_ptr<VideoCaptureDevice>(); |
99 } | 99 } |
100 | 100 |
101 scoped_ptr<VideoCaptureDeviceMac> capture_device( | 101 scoped_ptr<VideoCaptureDevice> capture_device; |
102 new VideoCaptureDeviceMac(device_name)); | 102 if (device_name.capture_api_type() == VideoCaptureDevice::Name::DECKLINK) { |
103 if (!capture_device->Init(device_name.capture_api_type())) { | 103 capture_device.reset(new VideoCaptureDeviceDeckLinkMac(device_name)); |
104 LOG(ERROR) << "Could not initialize VideoCaptureDevice."; | 104 } else { |
105 capture_device.reset(); | 105 VideoCaptureDeviceMac* device = new VideoCaptureDeviceMac(device_name); |
| 106 capture_device.reset(device); |
| 107 if (!device->Init(device_name.capture_api_type())) { |
| 108 LOG(ERROR) << "Could not initialize VideoCaptureDevice."; |
| 109 capture_device.reset(); |
| 110 } |
106 } | 111 } |
107 return scoped_ptr<VideoCaptureDevice>(capture_device.Pass()); | 112 return scoped_ptr<VideoCaptureDevice>(capture_device.Pass()); |
108 } | 113 } |
109 | 114 |
110 void VideoCaptureDeviceFactoryMac::GetDeviceNames( | 115 void VideoCaptureDeviceFactoryMac::GetDeviceNames( |
111 VideoCaptureDevice::Names* device_names) { | 116 VideoCaptureDevice::Names* device_names) { |
112 DCHECK(thread_checker_.CalledOnValidThread()); | 117 DCHECK(thread_checker_.CalledOnValidThread()); |
113 // Loop through all available devices and add to |device_names|. | 118 // Loop through all available devices and add to |device_names|. |
114 NSDictionary* capture_devices; | 119 NSDictionary* capture_devices; |
115 if (AVFoundationGlue::IsAVFoundationSupported()) { | 120 if (AVFoundationGlue::IsAVFoundationSupported()) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 void VideoCaptureDeviceFactoryMac::EnumerateDeviceNames(const base::Callback< | 175 void VideoCaptureDeviceFactoryMac::EnumerateDeviceNames(const base::Callback< |
171 void(scoped_ptr<media::VideoCaptureDevice::Names>)>& callback) { | 176 void(scoped_ptr<media::VideoCaptureDevice::Names>)>& callback) { |
172 DCHECK(thread_checker_.CalledOnValidThread()); | 177 DCHECK(thread_checker_.CalledOnValidThread()); |
173 if (AVFoundationGlue::IsAVFoundationSupported()) { | 178 if (AVFoundationGlue::IsAVFoundationSupported()) { |
174 scoped_ptr<VideoCaptureDevice::Names> device_names( | 179 scoped_ptr<VideoCaptureDevice::Names> device_names( |
175 new VideoCaptureDevice::Names()); | 180 new VideoCaptureDevice::Names()); |
176 GetDeviceNames(device_names.get()); | 181 GetDeviceNames(device_names.get()); |
177 callback.Run(device_names.Pass()); | 182 callback.Run(device_names.Pass()); |
178 } else { | 183 } else { |
179 DVLOG(1) << "Enumerating video capture devices using QTKit"; | 184 DVLOG(1) << "Enumerating video capture devices using QTKit"; |
180 base::PostTaskAndReplyWithResult( | 185 base::PostTaskAndReplyWithResult(ui_task_runner_.get(), FROM_HERE, |
181 ui_task_runner_.get(), | |
182 FROM_HERE, | |
183 base::Bind(&EnumerateDevicesUsingQTKit), | 186 base::Bind(&EnumerateDevicesUsingQTKit), |
184 base::Bind(&RunDevicesEnumeratedCallback, callback)); | 187 base::Bind(&RunDevicesEnumeratedCallback, callback)); |
185 } | 188 } |
186 } | 189 } |
187 | 190 |
188 void VideoCaptureDeviceFactoryMac::GetDeviceSupportedFormats( | 191 void VideoCaptureDeviceFactoryMac::GetDeviceSupportedFormats( |
189 const VideoCaptureDevice::Name& device, | 192 const VideoCaptureDevice::Name& device, |
190 VideoCaptureFormats* supported_formats) { | 193 VideoCaptureFormats* supported_formats) { |
191 DCHECK(thread_checker_.CalledOnValidThread()); | 194 DCHECK(thread_checker_.CalledOnValidThread()); |
192 switch (device.capture_api_type()) { | 195 switch (device.capture_api_type()) { |
(...skipping 23 matching lines...) Expand all Loading... |
216 DVLOG(1) << "Enumerating video capture capabilities " << device.name(); | 219 DVLOG(1) << "Enumerating video capture capabilities " << device.name(); |
217 VideoCaptureDeviceDeckLinkMac::EnumerateDeviceCapabilities( | 220 VideoCaptureDeviceDeckLinkMac::EnumerateDeviceCapabilities( |
218 device, supported_formats); | 221 device, supported_formats); |
219 break; | 222 break; |
220 default: | 223 default: |
221 NOTREACHED(); | 224 NOTREACHED(); |
222 } | 225 } |
223 } | 226 } |
224 | 227 |
225 } // namespace media | 228 } // namespace media |
OLD | NEW |