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" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/task_runner_util.h" | 12 #include "base/task_runner_util.h" |
13 #import "media/base/mac/avfoundation_glue.h" | 13 #import "media/base/mac/avfoundation_glue.h" |
14 #import "media/video/capture/mac/video_capture_device_avfoundation_mac.h" | 14 #import "media/video/capture/mac/video_capture_device_avfoundation_mac.h" |
15 #include "media/video/capture/mac/video_capture_device_mac.h" | 15 #include "media/video/capture/mac/video_capture_device_mac.h" |
| 16 #import "media/video/capture/mac/video_capture_device_decklink_mac.h" |
16 #import "media/video/capture/mac/video_capture_device_qtkit_mac.h" | 17 #import "media/video/capture/mac/video_capture_device_qtkit_mac.h" |
17 | 18 |
18 namespace media { | 19 namespace media { |
19 | 20 |
20 // Some devices are not correctly supported in AVFoundation, f.i. Blackmagic, | 21 // Some devices are not correctly supported in AVFoundation, f.i. Blackmagic, |
21 // see http://crbug.com/347371. The devices are identified by a characteristic | 22 // see http://crbug.com/347371. The devices are identified by a characteristic |
22 // trailing substring of uniqueId and by (part of) the vendor's name. | 23 // trailing substring of uniqueId and by (part of) the vendor's name. |
23 // Blackmagic cameras are known to crash if VGA is requested , see | 24 // Blackmagic cameras are known to crash if VGA is requested , see |
24 // http://crbug.com/396812; for them HD is the only supported resolution. | 25 // http://crbug.com/396812; for them HD is the only supported resolution. |
25 const struct NameAndVid { | 26 const struct NameAndVid { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 options:NSCaseInsensitiveSearch].length != 0) { | 151 options:NSCaseInsensitiveSearch].length != 0) { |
151 DVLOG(1) << "Enumerated blacklisted " << [device_name UTF8String]; | 152 DVLOG(1) << "Enumerated blacklisted " << [device_name UTF8String]; |
152 VideoCaptureDevice::Name name( | 153 VideoCaptureDevice::Name name( |
153 "QTKit " + std::string([device_name UTF8String]), | 154 "QTKit " + std::string([device_name UTF8String]), |
154 [key UTF8String], VideoCaptureDevice::Name::QTKIT); | 155 [key UTF8String], VideoCaptureDevice::Name::QTKIT); |
155 device_names->push_back(name); | 156 device_names->push_back(name); |
156 } | 157 } |
157 } | 158 } |
158 } | 159 } |
159 } | 160 } |
| 161 |
| 162 // Also retrieve Blackmagic devices, if present, via DeckLink SDK API. |
| 163 VideoCaptureDeviceDeckLinkMac::EnumerateDevices(device_names); |
160 } else { | 164 } else { |
161 // We should not enumerate QTKit devices in Device Thread; | 165 // We should not enumerate QTKit devices in Device Thread; |
162 NOTREACHED(); | 166 NOTREACHED(); |
163 } | 167 } |
164 } | 168 } |
165 | 169 |
166 void VideoCaptureDeviceFactoryMac::EnumerateDeviceNames(const base::Callback< | 170 void VideoCaptureDeviceFactoryMac::EnumerateDeviceNames(const base::Callback< |
167 void(scoped_ptr<media::VideoCaptureDevice::Names>)>& callback) { | 171 void(scoped_ptr<media::VideoCaptureDevice::Names>)>& callback) { |
168 DCHECK(thread_checker_.CalledOnValidThread()); | 172 DCHECK(thread_checker_.CalledOnValidThread()); |
169 if (AVFoundationGlue::IsAVFoundationSupported()) { | 173 if (AVFoundationGlue::IsAVFoundationSupported()) { |
170 scoped_ptr<VideoCaptureDevice::Names> device_names( | 174 scoped_ptr<VideoCaptureDevice::Names> device_names( |
171 new VideoCaptureDevice::Names()); | 175 new VideoCaptureDevice::Names()); |
172 GetDeviceNames(device_names.get()); | 176 GetDeviceNames(device_names.get()); |
173 callback.Run(device_names.Pass()); | 177 callback.Run(device_names.Pass()); |
174 } else { | 178 } else { |
175 DVLOG(1) << "Enumerating video capture devices using QTKit"; | 179 DVLOG(1) << "Enumerating video capture devices using QTKit"; |
176 base::PostTaskAndReplyWithResult( | 180 base::PostTaskAndReplyWithResult( |
177 ui_task_runner_.get(), | 181 ui_task_runner_.get(), |
178 FROM_HERE, | 182 FROM_HERE, |
179 base::Bind(&EnumerateDevicesUsingQTKit), | 183 base::Bind(&EnumerateDevicesUsingQTKit), |
180 base::Bind(&RunDevicesEnumeratedCallback, callback)); | 184 base::Bind(&RunDevicesEnumeratedCallback, callback)); |
181 } | 185 } |
182 } | 186 } |
183 | 187 |
184 void VideoCaptureDeviceFactoryMac::GetDeviceSupportedFormats( | 188 void VideoCaptureDeviceFactoryMac::GetDeviceSupportedFormats( |
185 const VideoCaptureDevice::Name& device, | 189 const VideoCaptureDevice::Name& device, |
186 VideoCaptureFormats* supported_formats) { | 190 VideoCaptureFormats* supported_formats) { |
187 DCHECK(thread_checker_.CalledOnValidThread()); | 191 DCHECK(thread_checker_.CalledOnValidThread()); |
188 if (device.capture_api_type() == VideoCaptureDevice::Name::AVFOUNDATION) { | 192 switch (device.capture_api_type()) { |
| 193 case VideoCaptureDevice::Name::AVFOUNDATION: |
189 DVLOG(1) << "Enumerating video capture capabilities, AVFoundation"; | 194 DVLOG(1) << "Enumerating video capture capabilities, AVFoundation"; |
190 [VideoCaptureDeviceAVFoundation getDevice:device | 195 [VideoCaptureDeviceAVFoundation getDevice:device |
191 supportedFormats:supported_formats]; | 196 supportedFormats:supported_formats]; |
192 } else { | 197 break; |
| 198 case VideoCaptureDevice::Name::QTKIT: |
193 // Blacklisted cameras provide their own supported format(s), otherwise no | 199 // Blacklisted cameras provide their own supported format(s), otherwise no |
194 // such information is provided for QTKit. | 200 // such information is provided for QTKit. |
195 if (device.is_blacklisted()) { | 201 if (device.is_blacklisted()) { |
196 for (size_t i = 0; i < arraysize(kBlacklistedCameras); ++i) { | 202 for (size_t i = 0; i < arraysize(kBlacklistedCameras); ++i) { |
197 if (device.id().find(kBlacklistedCameras[i].name) != | 203 if (device.id().find(kBlacklistedCameras[i].name) != |
198 std::string::npos) { | 204 std::string::npos) { |
199 supported_formats->push_back(media::VideoCaptureFormat( | 205 supported_formats->push_back(media::VideoCaptureFormat( |
200 gfx::Size(kBlacklistedCameras[i].capture_width, | 206 gfx::Size(kBlacklistedCameras[i].capture_width, |
201 kBlacklistedCameras[i].capture_height), | 207 kBlacklistedCameras[i].capture_height), |
202 kBlacklistedCameras[i].capture_frame_rate, | 208 kBlacklistedCameras[i].capture_frame_rate, |
203 media::PIXEL_FORMAT_UYVY)); | 209 media::PIXEL_FORMAT_UYVY)); |
204 break; | 210 break; |
205 } | 211 } |
206 } | 212 } |
207 } | 213 } |
| 214 break; |
| 215 case VideoCaptureDevice::Name::DECKLINK: |
| 216 DVLOG(1) << "Enumerating video capture capabilities " << device.name(); |
| 217 VideoCaptureDeviceDeckLinkMac::EnumerateDeviceCapabilities( |
| 218 device, supported_formats); |
| 219 break; |
| 220 default: |
| 221 NOTREACHED(); |
208 } | 222 } |
209 } | 223 } |
210 | 224 |
211 } // namespace media | 225 } // namespace media |
OLD | NEW |