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

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: tommi@s comments 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/strings/string_util.h"
9 #include "base/task_runner_util.h" 10 #include "base/task_runner_util.h"
10 #import "media/video/capture/mac/avfoundation_glue.h" 11 #import "media/video/capture/mac/avfoundation_glue.h"
11 #include "media/video/capture/mac/video_capture_device_mac.h" 12 #include "media/video/capture/mac/video_capture_device_mac.h"
12 #import "media/video/capture/mac/video_capture_device_avfoundation_mac.h" 13 #import "media/video/capture/mac/video_capture_device_avfoundation_mac.h"
13 #import "media/video/capture/mac/video_capture_device_qtkit_mac.h" 14 #import "media/video/capture/mac/video_capture_device_qtkit_mac.h"
14 15
15 namespace media { 16 namespace media {
16 17
17 // Some devices are not correctly supported in AVFoundation, f.i. Blackmagic, 18 // 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 19 // see http://crbug.com/347371. The devices are identified by characteristic
19 // by a characteristic substring of the name, usually the vendor's name. 20 // substrings of the uniqueId and name, the latter usually the vendor's name.
tommi (sloooow) - chröme 2014/07/03 14:06:33 nit: change 'characteristic substrings' to ... hmm
mcasas 2014/07/03 16:07:38 Done.
20 const struct NameAndVid { 21 const struct NameAndVid {
21 const char* vid; 22 const char* unique_id_signature;
22 const char* name; 23 const char* name;
23 } kBlacklistedCameras[] = { { "a82c", "Blackmagic" } }; 24 } 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 25
28 static scoped_ptr<media::VideoCaptureDevice::Names> 26 static scoped_ptr<media::VideoCaptureDevice::Names>
29 EnumerateDevicesUsingQTKit() { 27 EnumerateDevicesUsingQTKit() {
30 scoped_ptr<VideoCaptureDevice::Names> device_names( 28 scoped_ptr<VideoCaptureDevice::Names> device_names(
31 new VideoCaptureDevice::Names()); 29 new VideoCaptureDevice::Names());
32 NSMutableDictionary* capture_devices = 30 NSMutableDictionary* capture_devices =
33 [[[NSMutableDictionary alloc] init] autorelease]; 31 [[[NSMutableDictionary alloc] init] autorelease];
34 [VideoCaptureDeviceQTKit getDeviceNames:capture_devices]; 32 [VideoCaptureDeviceQTKit getDeviceNames:capture_devices];
35 for (NSString* key in capture_devices) { 33 for (NSString* key in capture_devices) {
36 VideoCaptureDevice::Name name( 34 VideoCaptureDevice::Name name(
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 93
96 void VideoCaptureDeviceFactoryMac::GetDeviceNames( 94 void VideoCaptureDeviceFactoryMac::GetDeviceNames(
97 VideoCaptureDevice::Names* device_names) { 95 VideoCaptureDevice::Names* device_names) {
98 DCHECK(thread_checker_.CalledOnValidThread()); 96 DCHECK(thread_checker_.CalledOnValidThread());
99 // Loop through all available devices and add to |device_names|. 97 // Loop through all available devices and add to |device_names|.
100 NSDictionary* capture_devices; 98 NSDictionary* capture_devices;
101 if (AVFoundationGlue::IsAVFoundationSupported()) { 99 if (AVFoundationGlue::IsAVFoundationSupported()) {
102 bool is_any_device_blacklisted = false; 100 bool is_any_device_blacklisted = false;
103 DVLOG(1) << "Enumerating video capture devices using AVFoundation"; 101 DVLOG(1) << "Enumerating video capture devices using AVFoundation";
104 capture_devices = [VideoCaptureDeviceAVFoundation deviceNames]; 102 capture_devices = [VideoCaptureDeviceAVFoundation deviceNames];
105 std::string device_vid;
106 // Enumerate all devices found by AVFoundation, translate the info for each 103 // Enumerate all devices found by AVFoundation, translate the info for each
107 // to class Name and add it to |device_names|. 104 // to class Name and add it to |device_names|.
108 for (NSString* key in capture_devices) { 105 for (NSString* key in capture_devices) {
109 VideoCaptureDevice::Name name( 106 VideoCaptureDevice::Name name(
110 [[capture_devices valueForKey:key] UTF8String], 107 [[capture_devices valueForKey:key] UTF8String],
111 [key UTF8String], VideoCaptureDevice::Name::AVFOUNDATION); 108 [key UTF8String], VideoCaptureDevice::Name::AVFOUNDATION);
112 device_names->push_back(name); 109 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) { 110 for (size_t i = 0; i < arraysize(kBlacklistedCameras); ++i) {
116 is_any_device_blacklisted |= 111 const bool kCaseInsensitive = false;
tommi (sloooow) - chröme 2014/07/03 14:06:34 uhm... kCaseInsensitive = false, meanse case sensi
mcasas 2014/07/03 16:07:38 Yeah, the clarification didn't clarify much :) Don
117 !strcasecmp(device_vid.c_str(), kBlacklistedCameras[i].vid); 112 is_any_device_blacklisted = EndsWith(name.id(),
113 kBlacklistedCameras[i].unique_id_signature, kCaseInsensitive);
118 if (is_any_device_blacklisted) 114 if (is_any_device_blacklisted)
119 break; 115 break;
120 } 116 }
121 } 117 }
122 // If there is any device blacklisted in the system, walk the QTKit device 118 // 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|. 119 // 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" 120 // AVFoundation and QTKit device lists partially overlap, so add a "QTKit"
125 // prefix to the latter ones to distinguish them from the AVFoundation ones. 121 // prefix to the latter ones to distinguish them from the AVFoundation ones.
126 if (is_any_device_blacklisted) { 122 if (is_any_device_blacklisted) {
127 capture_devices = [VideoCaptureDeviceQTKit deviceNames]; 123 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) { 164 if (device.capture_api_type() == VideoCaptureDevice::Name::AVFOUNDATION) {
169 DVLOG(1) << "Enumerating video capture capabilities, AVFoundation"; 165 DVLOG(1) << "Enumerating video capture capabilities, AVFoundation";
170 [VideoCaptureDeviceAVFoundation getDevice:device 166 [VideoCaptureDeviceAVFoundation getDevice:device
171 supportedFormats:supported_formats]; 167 supportedFormats:supported_formats];
172 } else { 168 } else {
173 NOTIMPLEMENTED(); 169 NOTIMPLEMENTED();
174 } 170 }
175 } 171 }
176 172
177 } // namespace media 173 } // 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