| Index: media/video/capture/mac/video_capture_device_mac.mm
|
| diff --git a/media/video/capture/mac/video_capture_device_mac.mm b/media/video/capture/mac/video_capture_device_mac.mm
|
| index 75f3937e894355b1cce4dc8274dad0586209b276..1fa011f771d15c6536a09f38152b965dcedde816 100644
|
| --- a/media/video/capture/mac/video_capture_device_mac.mm
|
| +++ b/media/video/capture/mac/video_capture_device_mac.mm
|
| @@ -19,27 +19,33 @@ namespace media {
|
| const int kMinFrameRate = 1;
|
| const int kMaxFrameRate = 30;
|
|
|
| -// In QT device identifiers, the USB VID and PID are stored in 4 bytes each.
|
| +// In device identifiers, the USB VID and PID are stored in 4 bytes each.
|
| const size_t kVidPidSize = 4;
|
|
|
| -struct Resolution {
|
| - int width;
|
| - int height;
|
| -};
|
| -
|
| -const Resolution kQVGA = { 320, 240 },
|
| - kVGA = { 640, 480 },
|
| - kHD = { 1280, 720 };
|
| -
|
| -const Resolution* const kWellSupportedResolutions[] = {
|
| - &kQVGA,
|
| - &kVGA,
|
| - &kHD,
|
| +// Some devices are not correctly supported in AVFoundation, f.i. Blackmagic,
|
| +// see http://crbug.com/347371. The devices are identified by USB Vendor ID and
|
| +// by a characteristic substring of the name, usually the vendor's name.
|
| +const struct NameAndVid {
|
| + const char* vid;
|
| + const char* name;
|
| +} kBlacklistedCameras[] = { { "a82c", "Blackmagic" } };
|
| +
|
| +const struct Resolution {
|
| + const int width;
|
| + const int height;
|
| +} kQVGA = { 320, 240 },
|
| + kVGA = { 640, 480 },
|
| + kHD = { 1280, 720 };
|
| +
|
| +const struct Resolution* const kWellSupportedResolutions[] = {
|
| + &kQVGA,
|
| + &kVGA,
|
| + &kHD,
|
| };
|
|
|
| // Rescaling the image to fix the pixel aspect ratio runs the risk of making
|
| // the aspect ratio worse, if QTKit selects a new source mode with a different
|
| -// shape. This constant ensures that we don't take this risk if the current
|
| +// shape. This constant ensures that we don't take this risk if the current
|
| // aspect ratio is tolerable.
|
| const float kMaxPixelAspectRatio = 1.15;
|
|
|
| @@ -68,24 +74,58 @@ void VideoCaptureDevice::GetDeviceNames(Names* device_names) {
|
| device_names->clear();
|
|
|
| NSDictionary* capture_devices;
|
| + bool is_blacklisted_device = false;
|
| if (AVFoundationGlue::IsAVFoundationSupported()) {
|
| DVLOG(1) << "Enumerating video capture devices using AVFoundation";
|
| capture_devices = [VideoCaptureDeviceAVFoundation deviceNames];
|
| + std::string device_vid;
|
| + for (NSString* key in capture_devices) {
|
| + Name name([[capture_devices valueForKey:key] UTF8String],
|
| + [key UTF8String], Name::AVFOUNDATION);
|
| + device_names->push_back(name);
|
| + device_vid = name.GetModel().substr(0, kVidPidSize);
|
| + // Compare the USB VendorID of the device to the blacklisted ones.
|
| + for (size_t i = 0; i < arraysize(kBlacklistedCameras); ++i) {
|
| + is_blacklisted_device |= (device_vid == kBlacklistedCameras[i].vid);
|
| + if (is_blacklisted_device)
|
| + continue;
|
| + }
|
| + }
|
| } else {
|
| DVLOG(1) << "Enumerating video capture devices using QTKit";
|
| capture_devices = [VideoCaptureDeviceQTKit deviceNames];
|
| + for (NSString* key in capture_devices) {
|
| + Name name([[capture_devices valueForKey:key] UTF8String],
|
| + [key UTF8String], Name::QTKIT);
|
| + device_names->push_back(name);
|
| + }
|
| }
|
| - for (NSString* key in capture_devices) {
|
| - Name name([[capture_devices valueForKey:key] UTF8String],
|
| - [key UTF8String]);
|
| - device_names->push_back(name);
|
| +
|
| + if (is_blacklisted_device) {
|
| + // Walk the QTKit device list and add those devices with a blacklisted name
|
| + // to the |device_names|, with a "QTKit" prefix to distinguish them from the
|
| + // AVFoundation ones.
|
| + capture_devices = [VideoCaptureDeviceQTKit deviceNames];
|
| + NSString* device_name;
|
| + for (NSString* key in capture_devices) {
|
| + device_name = [capture_devices valueForKey:key];
|
| + for (size_t i = 0; i < arraysize(kBlacklistedCameras); ++i) {
|
| + if ([device_name rangeOfString:@(kBlacklistedCameras[i].name)
|
| + options:NSCaseInsensitiveSearch].length != 0) {
|
| + DVLOG(1) << "Enumerated blacklisted " << [device_name UTF8String];
|
| + Name name("QTKit " + std::string([device_name UTF8String]),
|
| + [key UTF8String], Name::QTKIT);
|
| + device_names->push_back(name);
|
| + }
|
| + }
|
| + }
|
| }
|
| }
|
|
|
| // static
|
| void VideoCaptureDevice::GetDeviceSupportedFormats(const Name& device,
|
| VideoCaptureFormats* formats) {
|
| - if (AVFoundationGlue::IsAVFoundationSupported()) {
|
| + if (device.capture_api_type() == Name::AVFOUNDATION) {
|
| DVLOG(1) << "Enumerating video capture capabilities, AVFoundation";
|
| [VideoCaptureDeviceAVFoundation getDevice:device
|
| supportedFormats:formats];
|
| @@ -219,7 +259,8 @@ bool VideoCaptureDeviceMac::Init() {
|
| if (it == device_names.end())
|
| return false;
|
|
|
| - if (AVFoundationGlue::IsAVFoundationSupported()) {
|
| + DCHECK_NE(it->capture_api_type(), Name::API_TYPE_UNKNOWN);
|
| + if (it->capture_api_type() == Name::AVFOUNDATION) {
|
| capture_device_ =
|
| [[VideoCaptureDeviceAVFoundation alloc] initWithFrameReceiver:this];
|
| } else {
|
|
|