Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: media/video/capture/mac/video_capture_device_factory_mac.mm

Issue 362323003: Mac AVFoundation: Blackmagic camera blacklisting update (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/task_runner_util.h" 9 #include "base/task_runner_util.h"
10 #import "media/video/capture/mac/avfoundation_glue.h" 10 #import "media/video/capture/mac/avfoundation_glue.h"
11 #include "media/video/capture/mac/video_capture_device_mac.h" 11 #include "media/video/capture/mac/video_capture_device_mac.h"
12 #import "media/video/capture/mac/video_capture_device_avfoundation_mac.h" 12 #import "media/video/capture/mac/video_capture_device_avfoundation_mac.h"
13 #import "media/video/capture/mac/video_capture_device_qtkit_mac.h" 13 #import "media/video/capture/mac/video_capture_device_qtkit_mac.h"
14 14
15 namespace media { 15 namespace media {
16 16
17 // Some devices are not correctly supported in AVFoundation, f.i. Blackmagic, 17 // Some devices are not correctly supported in AVFoundation, f.i. Blackmagic,
18 // see http://crbug.com/347371. The devices are identified by USB Vendor ID and 18 // see http://crbug.com/347371. The devices are identified by characteristic
19 // by a characteristic substring of the name, usually the vendor's name. 19 // substrings of the uniqueId and name, the latter usually the vendor's name.
20 const struct NameAndVid { 20 const struct NameAndVid {
21 const char* vid; 21 const char* unique_id_signature;
22 const char* name; 22 const char* name;
23 } kBlacklistedCameras[] = { { "a82c", "Blackmagic" } }; 23 } kBlacklistedCameras[] = { { "01fda82c8a9c", "Blackmagic" } };
24
25 // In device identifiers, the USB VID and PID are stored in 4 bytes each.
26 const size_t kVidPidSize = 4;
27 24
28 static scoped_ptr<media::VideoCaptureDevice::Names> 25 static scoped_ptr<media::VideoCaptureDevice::Names>
29 EnumerateDevicesUsingQTKit() { 26 EnumerateDevicesUsingQTKit() {
30 scoped_ptr<VideoCaptureDevice::Names> device_names( 27 scoped_ptr<VideoCaptureDevice::Names> device_names(
31 new VideoCaptureDevice::Names()); 28 new VideoCaptureDevice::Names());
32 NSMutableDictionary* capture_devices = 29 NSMutableDictionary* capture_devices =
33 [[[NSMutableDictionary alloc] init] autorelease]; 30 [[[NSMutableDictionary alloc] init] autorelease];
34 [VideoCaptureDeviceQTKit getDeviceNames:capture_devices]; 31 [VideoCaptureDeviceQTKit getDeviceNames:capture_devices];
35 for (NSString* key in capture_devices) { 32 for (NSString* key in capture_devices) {
36 VideoCaptureDevice::Name name( 33 VideoCaptureDevice::Name name(
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 92
96 void VideoCaptureDeviceFactoryMac::GetDeviceNames( 93 void VideoCaptureDeviceFactoryMac::GetDeviceNames(
97 VideoCaptureDevice::Names* device_names) { 94 VideoCaptureDevice::Names* device_names) {
98 DCHECK(thread_checker_.CalledOnValidThread()); 95 DCHECK(thread_checker_.CalledOnValidThread());
99 // Loop through all available devices and add to |device_names|. 96 // Loop through all available devices and add to |device_names|.
100 NSDictionary* capture_devices; 97 NSDictionary* capture_devices;
101 if (AVFoundationGlue::IsAVFoundationSupported()) { 98 if (AVFoundationGlue::IsAVFoundationSupported()) {
102 bool is_any_device_blacklisted = false; 99 bool is_any_device_blacklisted = false;
103 DVLOG(1) << "Enumerating video capture devices using AVFoundation"; 100 DVLOG(1) << "Enumerating video capture devices using AVFoundation";
104 capture_devices = [VideoCaptureDeviceAVFoundation deviceNames]; 101 capture_devices = [VideoCaptureDeviceAVFoundation deviceNames];
105 std::string device_vid;
106 // Enumerate all devices found by AVFoundation, translate the info for each 102 // Enumerate all devices found by AVFoundation, translate the info for each
107 // to class Name and add it to |device_names|. 103 // to class Name and add it to |device_names|.
108 for (NSString* key in capture_devices) { 104 for (NSString* key in capture_devices) {
109 VideoCaptureDevice::Name name( 105 VideoCaptureDevice::Name name(
110 [[capture_devices valueForKey:key] UTF8String], 106 [[capture_devices valueForKey:key] UTF8String],
111 [key UTF8String], VideoCaptureDevice::Name::AVFOUNDATION); 107 [key UTF8String], VideoCaptureDevice::Name::AVFOUNDATION);
112 device_names->push_back(name); 108 device_names->push_back(name);
113 // Extract the device's Vendor ID and compare to all blacklisted ones.
114 device_vid = name.GetModel().substr(0, kVidPidSize);
115 for (size_t i = 0; i < arraysize(kBlacklistedCameras); ++i) { 109 for (size_t i = 0; i < arraysize(kBlacklistedCameras); ++i) {
116 is_any_device_blacklisted |= 110 is_any_device_blacklisted |= (strcasestr(name.id().c_str(),
tommi (sloooow) - chröme 2014/07/03 09:56:56 I don't recall seeing strcasestr being used before
tommi (sloooow) - chröme 2014/07/03 09:56:56 no need for |=. Just use = since you'll break as
mcasas 2014/07/03 12:52:56 Oops, you're right, seems to be BSD-only. I refac
mcasas 2014/07/03 12:52:56 Done.
117 !strcasecmp(device_vid.c_str(), kBlacklistedCameras[i].vid); 111 kBlacklistedCameras[i].unique_id_signature) != NULL);
tommi (sloooow) - chröme 2014/07/03 09:56:56 != 0 (since the function returns int, not a pointe
mcasas 2014/07/03 12:52:56 Done.
118 if (is_any_device_blacklisted) 112 if (is_any_device_blacklisted)
119 break; 113 break;
120 } 114 }
121 } 115 }
122 // If there is any device blacklisted in the system, walk the QTKit device 116 // If there is any device blacklisted in the system, walk the QTKit device
123 // list and add those devices with a blacklisted name to the |device_names|. 117 // list and add those devices with a blacklisted name to the |device_names|.
124 // AVFoundation and QTKit device lists partially overlap, so add a "QTKit" 118 // AVFoundation and QTKit device lists partially overlap, so add a "QTKit"
125 // prefix to the latter ones to distinguish them from the AVFoundation ones. 119 // prefix to the latter ones to distinguish them from the AVFoundation ones.
126 if (is_any_device_blacklisted) { 120 if (is_any_device_blacklisted) {
127 capture_devices = [VideoCaptureDeviceQTKit deviceNames]; 121 capture_devices = [VideoCaptureDeviceQTKit deviceNames];
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 if (device.capture_api_type() == VideoCaptureDevice::Name::AVFOUNDATION) { 162 if (device.capture_api_type() == VideoCaptureDevice::Name::AVFOUNDATION) {
169 DVLOG(1) << "Enumerating video capture capabilities, AVFoundation"; 163 DVLOG(1) << "Enumerating video capture capabilities, AVFoundation";
170 [VideoCaptureDeviceAVFoundation getDevice:device 164 [VideoCaptureDeviceAVFoundation getDevice:device
171 supportedFormats:supported_formats]; 165 supportedFormats:supported_formats];
172 } else { 166 } else {
173 NOTIMPLEMENTED(); 167 NOTIMPLEMENTED();
174 } 168 }
175 } 169 }
176 170
177 } // namespace media 171 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698