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

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

Issue 518073002: Mac VideoCapture: Support for Blackmagic DeckLink device & capabilities enumeration, using SDK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: perkj@ and magjed@s comments Created 6 years, 3 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
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 #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_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
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(ui_task_runner_, FROM_HERE, 180 base::PostTaskAndReplyWithResult(ui_task_runner_, FROM_HERE,
177 base::Bind(&EnumerateDevicesUsingQTKit), 181 base::Bind(&EnumerateDevicesUsingQTKit),
178 base::Bind(&RunDevicesEnumeratedCallback, callback)); 182 base::Bind(&RunDevicesEnumeratedCallback, callback));
179 } 183 }
180 } 184 }
181 185
182 void VideoCaptureDeviceFactoryMac::GetDeviceSupportedFormats( 186 void VideoCaptureDeviceFactoryMac::GetDeviceSupportedFormats(
183 const VideoCaptureDevice::Name& device, 187 const VideoCaptureDevice::Name& device,
184 VideoCaptureFormats* supported_formats) { 188 VideoCaptureFormats* supported_formats) {
185 DCHECK(thread_checker_.CalledOnValidThread()); 189 DCHECK(thread_checker_.CalledOnValidThread());
186 if (device.capture_api_type() == VideoCaptureDevice::Name::AVFOUNDATION) { 190 if (device.capture_api_type() == VideoCaptureDevice::Name::AVFOUNDATION) {
perkj_chrome 2014/09/01 14:44:08 nit switch(device.capture_api_type()) ?
mcasas 2014/09/02 12:45:53 Done.
187 DVLOG(1) << "Enumerating video capture capabilities, AVFoundation"; 191 DVLOG(1) << "Enumerating video capture capabilities, AVFoundation";
188 [VideoCaptureDeviceAVFoundation getDevice:device 192 [VideoCaptureDeviceAVFoundation getDevice:device
189 supportedFormats:supported_formats]; 193 supportedFormats:supported_formats];
190 } else { 194 } else if (device.capture_api_type() == VideoCaptureDevice::Name::QTKIT) {
191 // Blacklisted cameras provide their own supported format(s), otherwise no 195 // Blacklisted cameras provide their own supported format(s), otherwise no
192 // such information is provided for QTKit. 196 // such information is provided for QTKit.
193 if (device.is_blacklisted()) { 197 if (device.is_blacklisted()) {
194 for (size_t i = 0; i < arraysize(kBlacklistedCameras); ++i) { 198 for (size_t i = 0; i < arraysize(kBlacklistedCameras); ++i) {
195 if (device.id().find(kBlacklistedCameras[i].name) != 199 if (device.id().find(kBlacklistedCameras[i].name) !=
196 std::string::npos) { 200 std::string::npos) {
197 supported_formats->push_back(media::VideoCaptureFormat( 201 supported_formats->push_back(media::VideoCaptureFormat(
198 gfx::Size(kBlacklistedCameras[i].capture_width, 202 gfx::Size(kBlacklistedCameras[i].capture_width,
199 kBlacklistedCameras[i].capture_height), 203 kBlacklistedCameras[i].capture_height),
200 kBlacklistedCameras[i].capture_frame_rate, 204 kBlacklistedCameras[i].capture_frame_rate,
201 media::PIXEL_FORMAT_UYVY)); 205 media::PIXEL_FORMAT_UYVY));
202 break; 206 break;
203 } 207 }
204 } 208 }
205 } 209 }
210 } else if (device.capture_api_type() == VideoCaptureDevice::Name::DECKLINK) {
211 DVLOG(1) << "Enumerating video capture capabilities, Blackmagic";
212 VideoCaptureDeviceDeckLinkMac::EnumerateDeviceCapabilities(
213 device, supported_formats);
214 } else {
215 DCHECK(false);
perkj_chrome 2014/09/01 14:44:08 NOTREACHED()
mcasas 2014/09/02 12:45:54 Done.
206 } 216 }
207 } 217 }
208 218
209 } // namespace media 219 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698