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/video/capture/mac/avfoundation_glue.h" | 13 #import "media/video/capture/mac/avfoundation_glue.h" |
14 #include "media/video/capture/mac/video_capture_device_mac.h" | 14 #include "media/video/capture/mac/video_capture_device_mac.h" |
15 #import "media/video/capture/mac/video_capture_device_avfoundation_mac.h" | 15 #import "media/video/capture/mac/video_capture_device_avfoundation_mac.h" |
16 #import "media/video/capture/mac/video_capture_device_qtkit_mac.h" | 16 #import "media/video/capture/mac/video_capture_device_qtkit_mac.h" |
17 | 17 |
18 namespace media { | 18 namespace media { |
19 | 19 |
20 // Some devices are not correctly supported in AVFoundation, f.i. Blackmagic, | 20 // Some devices are not correctly supported in AVFoundation, f.i. Blackmagic, |
21 // see http://crbug.com/347371. The devices are identified by a characteristic | 21 // 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. | 22 // 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 // http://crbug.com/396812; for them HD is the only supported resolution. | |
23 const struct NameAndVid { | 25 const struct NameAndVid { |
24 const char* unique_id_signature; | 26 const char* unique_id_signature; |
25 const char* name; | 27 const char* name; |
26 } kBlacklistedCameras[] = { { "-01FDA82C8A9C", "Blackmagic" } }; | 28 const int capture_width; |
29 const int capture_height; | |
30 const float capture_frame_rate; | |
31 } kBlacklistedCameras[] = { | |
32 { "-01FDA82C8A9C", "Blackmagic", 1280, 720, 60.0f } }; | |
27 | 33 |
28 static scoped_ptr<media::VideoCaptureDevice::Names> | 34 static scoped_ptr<media::VideoCaptureDevice::Names> |
29 EnumerateDevicesUsingQTKit() { | 35 EnumerateDevicesUsingQTKit() { |
30 scoped_ptr<VideoCaptureDevice::Names> device_names( | 36 scoped_ptr<VideoCaptureDevice::Names> device_names( |
31 new VideoCaptureDevice::Names()); | 37 new VideoCaptureDevice::Names()); |
32 NSMutableDictionary* capture_devices = | 38 NSMutableDictionary* capture_devices = |
33 [[[NSMutableDictionary alloc] init] autorelease]; | 39 [[[NSMutableDictionary alloc] init] autorelease]; |
34 [VideoCaptureDeviceQTKit getDeviceNames:capture_devices]; | 40 [VideoCaptureDeviceQTKit getDeviceNames:capture_devices]; |
35 for (NSString* key in capture_devices) { | 41 for (NSString* key in capture_devices) { |
36 VideoCaptureDevice::Name name( | 42 VideoCaptureDevice::Name name( |
37 [[[capture_devices valueForKey:key] deviceName] UTF8String], | 43 [[[capture_devices valueForKey:key] deviceName] UTF8String], |
38 [key UTF8String], VideoCaptureDevice::Name::QTKIT); | 44 [key UTF8String], VideoCaptureDevice::Name::QTKIT); |
45 for (size_t i = 0; i < arraysize(kBlacklistedCameras); ++i) { | |
46 if (name.id().find(kBlacklistedCameras[i].name) != std::string::npos) { | |
vrk (LEFT CHROMIUM)
2014/08/14 02:50:54
Does case sensitivity matter?
mcasas
2014/08/14 07:36:06
ATM I've have always seen "Blackmagic" as part of
| |
47 DVLOG(2) << "Found blacklisted camera: " << name.id(); | |
48 name.set_is_blacklisted(true); | |
49 break; | |
50 } | |
51 } | |
39 device_names->push_back(name); | 52 device_names->push_back(name); |
40 } | 53 } |
41 return device_names.Pass(); | 54 return device_names.Pass(); |
42 } | 55 } |
43 | 56 |
44 static void RunDevicesEnumeratedCallback( | 57 static void RunDevicesEnumeratedCallback( |
45 const base::Callback<void(scoped_ptr<media::VideoCaptureDevice::Names>)>& | 58 const base::Callback<void(scoped_ptr<media::VideoCaptureDevice::Names>)>& |
46 callback, | 59 callback, |
47 scoped_ptr<media::VideoCaptureDevice::Names> device_names) { | 60 scoped_ptr<media::VideoCaptureDevice::Names> device_names) { |
48 callback.Run(device_names.Pass()); | 61 callback.Run(device_names.Pass()); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 | 181 |
169 void VideoCaptureDeviceFactoryMac::GetDeviceSupportedFormats( | 182 void VideoCaptureDeviceFactoryMac::GetDeviceSupportedFormats( |
170 const VideoCaptureDevice::Name& device, | 183 const VideoCaptureDevice::Name& device, |
171 VideoCaptureFormats* supported_formats) { | 184 VideoCaptureFormats* supported_formats) { |
172 DCHECK(thread_checker_.CalledOnValidThread()); | 185 DCHECK(thread_checker_.CalledOnValidThread()); |
173 if (device.capture_api_type() == VideoCaptureDevice::Name::AVFOUNDATION) { | 186 if (device.capture_api_type() == VideoCaptureDevice::Name::AVFOUNDATION) { |
174 DVLOG(1) << "Enumerating video capture capabilities, AVFoundation"; | 187 DVLOG(1) << "Enumerating video capture capabilities, AVFoundation"; |
175 [VideoCaptureDeviceAVFoundation getDevice:device | 188 [VideoCaptureDeviceAVFoundation getDevice:device |
176 supportedFormats:supported_formats]; | 189 supportedFormats:supported_formats]; |
177 } else { | 190 } else { |
178 NOTIMPLEMENTED(); | 191 // Blacklisted cameras provide their own supported format(s), otherwise no |
192 // such information is provided for QTKit. | |
193 if (device.is_blacklisted()) { | |
194 for (size_t i = 0; i < arraysize(kBlacklistedCameras); ++i) { | |
195 if (device.id().find(kBlacklistedCameras[i].name) != | |
196 std::string::npos) { | |
197 supported_formats->push_back(media::VideoCaptureFormat( | |
198 gfx::Size(kBlacklistedCameras[i].capture_width, | |
199 kBlacklistedCameras[i].capture_height), | |
200 kBlacklistedCameras[i].capture_frame_rate, | |
201 media::PIXEL_FORMAT_UYVY)); | |
202 break; | |
203 } | |
204 } | |
205 } | |
179 } | 206 } |
180 } | 207 } |
181 | 208 |
182 } // namespace media | 209 } // namespace media |
OLD | NEW |