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 const struct NameAndVid { | 23 const struct NameAndVid { |
24 const char* unique_id_signature; | 24 const char* unique_id_signature; |
25 const char* name; | 25 const char* name; |
26 } kBlacklistedCameras[] = { { "-01FDA82C8A9C", "Blackmagic" } }; | 26 } kBlacklistedCameras[] = { { "-01FDA82C8A9C", "Blackmagic" } }; |
27 | 27 |
28 const gfx::Size kBlackmagicQTKitCaptureResolution = gfx::Size(1280, 720); | |
tommi (sloooow) - chröme
2014/08/13 12:42:28
is this a global that requires construction? (if s
mcasas
2014/08/13 14:04:52
Done.
| |
29 const float kBlackmagicQTKitCaptureFrameRate = 60.0f; | |
tommi (sloooow) - chröme
2014/08/13 12:42:28
These two constants seem specific to blackmagic ca
mcasas
2014/08/13 14:04:52
Done.
| |
30 | |
28 static scoped_ptr<media::VideoCaptureDevice::Names> | 31 static scoped_ptr<media::VideoCaptureDevice::Names> |
29 EnumerateDevicesUsingQTKit() { | 32 EnumerateDevicesUsingQTKit() { |
30 scoped_ptr<VideoCaptureDevice::Names> device_names( | 33 scoped_ptr<VideoCaptureDevice::Names> device_names( |
31 new VideoCaptureDevice::Names()); | 34 new VideoCaptureDevice::Names()); |
32 NSMutableDictionary* capture_devices = | 35 NSMutableDictionary* capture_devices = |
33 [[[NSMutableDictionary alloc] init] autorelease]; | 36 [[[NSMutableDictionary alloc] init] autorelease]; |
34 [VideoCaptureDeviceQTKit getDeviceNames:capture_devices]; | 37 [VideoCaptureDeviceQTKit getDeviceNames:capture_devices]; |
35 for (NSString* key in capture_devices) { | 38 for (NSString* key in capture_devices) { |
36 VideoCaptureDevice::Name name( | 39 VideoCaptureDevice::Name name( |
37 [[[capture_devices valueForKey:key] deviceName] UTF8String], | 40 [[[capture_devices valueForKey:key] deviceName] UTF8String], |
38 [key UTF8String], VideoCaptureDevice::Name::QTKIT); | 41 [key UTF8String], VideoCaptureDevice::Name::QTKIT); |
42 for (size_t i = 0; i < arraysize(kBlacklistedCameras); ++i) { | |
43 if (name.id().find(kBlacklistedCameras[i].name) != std::string::npos) { | |
44 DVLOG(2) << "Found blacklisted camera: " << name.id(); | |
45 name.set_is_blacklisted(true); | |
46 break; | |
47 } | |
48 } | |
39 device_names->push_back(name); | 49 device_names->push_back(name); |
40 } | 50 } |
41 return device_names.Pass(); | 51 return device_names.Pass(); |
42 } | 52 } |
43 | 53 |
44 static void RunDevicesEnumeratedCallback( | 54 static void RunDevicesEnumeratedCallback( |
45 const base::Callback<void(scoped_ptr<media::VideoCaptureDevice::Names>)>& | 55 const base::Callback<void(scoped_ptr<media::VideoCaptureDevice::Names>)>& |
46 callback, | 56 callback, |
47 scoped_ptr<media::VideoCaptureDevice::Names> device_names) { | 57 scoped_ptr<media::VideoCaptureDevice::Names> device_names) { |
48 callback.Run(device_names.Pass()); | 58 callback.Run(device_names.Pass()); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 | 178 |
169 void VideoCaptureDeviceFactoryMac::GetDeviceSupportedFormats( | 179 void VideoCaptureDeviceFactoryMac::GetDeviceSupportedFormats( |
170 const VideoCaptureDevice::Name& device, | 180 const VideoCaptureDevice::Name& device, |
171 VideoCaptureFormats* supported_formats) { | 181 VideoCaptureFormats* supported_formats) { |
172 DCHECK(thread_checker_.CalledOnValidThread()); | 182 DCHECK(thread_checker_.CalledOnValidThread()); |
173 if (device.capture_api_type() == VideoCaptureDevice::Name::AVFOUNDATION) { | 183 if (device.capture_api_type() == VideoCaptureDevice::Name::AVFOUNDATION) { |
174 DVLOG(1) << "Enumerating video capture capabilities, AVFoundation"; | 184 DVLOG(1) << "Enumerating video capture capabilities, AVFoundation"; |
175 [VideoCaptureDeviceAVFoundation getDevice:device | 185 [VideoCaptureDeviceAVFoundation getDevice:device |
176 supportedFormats:supported_formats]; | 186 supportedFormats:supported_formats]; |
177 } else { | 187 } else { |
178 NOTIMPLEMENTED(); | 188 // Some cameras are known to crash if requested with VGA (crbug.com/396812), |
189 // HD is the only supported resolution for them. In any other case, QTKit | |
190 // provides no format information. | |
191 if (device.is_blacklisted()) { | |
192 DVLOG(2) << "Found blacklisted camera with only HD supported format."; | |
193 supported_formats->push_back(media::VideoCaptureFormat( | |
194 kBlackmagicQTKitCaptureResolution, kBlackmagicQTKitCaptureFrameRate, | |
tommi (sloooow) - chröme
2014/08/13 12:42:29
here, there's an assumption that blacklisted==blac
mcasas
2014/08/13 14:04:52
Done.
| |
195 media::PIXEL_FORMAT_UYVY)); | |
196 } | |
179 } | 197 } |
180 } | 198 } |
181 | 199 |
182 } // namespace media | 200 } // namespace media |
OLD | NEW |