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_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 Loading... | |
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); | |
perkj_chrome
2014/09/01 09:50:41
Isn't there a risk that we enumerate BM devices tw
mcasas
2014/09/01 14:04:50
Short answer: _not_ in 64bit builds.
Long answer:
| |
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()) { |
(...skipping 10 matching lines...) Expand all Loading... | |
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) { |
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 { | |
211 DCHECK_EQ(device.capture_api_type(), VideoCaptureDevice::Name::DECKLINK); | |
perkj_chrome
2014/09/01 09:50:41
How do we now that |device| is Declink?
mcasas
2014/09/01 14:04:50
Missed this one, should check in l.210.
| |
212 DVLOG(1) << "Enumerating video capture capabilities, Blackmagic"; | |
213 VideoCaptureDeviceDeckLinkMac::EnumerateDeviceCapabilities( | |
214 device, supported_formats); | |
206 } | 215 } |
207 } | 216 } |
208 | 217 |
209 } // namespace media | 218 } // namespace media |
OLD | NEW |