Commit 41874c23 authored by mcasas@chromium.org's avatar mcasas@chromium.org

Mac QTKit Video Capture: Force BlackMagic cameras to be opened in HD

This is a refry of http://crrev.com/410363002, original description:
>Force BlackMagic cameras to be opened in HD
>
>The Blackmagic driver causes a crash in QTKit when opened in VGA
>when NTSC/PAL 10-bit is selected.  QTKit does not allow us to query a
>device's supported resolution, so this change adds BlackMagic to another
>blacklist so that it is always opened in HD.

In this continuation CL, Blacklisted QTKit devices are found during
enumeration and flagged, so
a) a special capability list is cooked for them, only including HD,
b) they are not reconfigured on opening/capturing.

BUG=396812, 347371
COLLABORATOR= vrk@chromium.org
R=tommi@chromium.org, vrk@chromium.org

Review URL: https://codereview.chromium.org/468833002

Cr-Commit-Position: refs/heads/master@{#289552}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289552 0039d316-1c4b-4281-b951-d872f2087c98
parent 10d65b16
...@@ -20,10 +20,16 @@ namespace media { ...@@ -20,10 +20,16 @@ namespace media {
// Some devices are not correctly supported in AVFoundation, f.i. Blackmagic, // Some devices are not correctly supported in AVFoundation, f.i. Blackmagic,
// see http://crbug.com/347371. The devices are identified by a characteristic // see http://crbug.com/347371. The devices are identified by a characteristic
// trailing substring of uniqueId and by (part of) the vendor's name. // trailing substring of uniqueId and by (part of) the vendor's name.
// Blackmagic cameras are known to crash if VGA is requested , see
// http://crbug.com/396812; for them HD is the only supported resolution.
const struct NameAndVid { const struct NameAndVid {
const char* unique_id_signature; const char* unique_id_signature;
const char* name; const char* name;
} kBlacklistedCameras[] = { { "-01FDA82C8A9C", "Blackmagic" } }; const int capture_width;
const int capture_height;
const float capture_frame_rate;
} kBlacklistedCameras[] = {
{ "-01FDA82C8A9C", "Blackmagic", 1280, 720, 60.0f } };
static scoped_ptr<media::VideoCaptureDevice::Names> static scoped_ptr<media::VideoCaptureDevice::Names>
EnumerateDevicesUsingQTKit() { EnumerateDevicesUsingQTKit() {
...@@ -36,6 +42,13 @@ EnumerateDevicesUsingQTKit() { ...@@ -36,6 +42,13 @@ EnumerateDevicesUsingQTKit() {
VideoCaptureDevice::Name name( VideoCaptureDevice::Name name(
[[[capture_devices valueForKey:key] deviceName] UTF8String], [[[capture_devices valueForKey:key] deviceName] UTF8String],
[key UTF8String], VideoCaptureDevice::Name::QTKIT); [key UTF8String], VideoCaptureDevice::Name::QTKIT);
for (size_t i = 0; i < arraysize(kBlacklistedCameras); ++i) {
if (name.id().find(kBlacklistedCameras[i].name) != std::string::npos) {
DVLOG(2) << "Found blacklisted camera: " << name.id();
name.set_is_blacklisted(true);
break;
}
}
device_names->push_back(name); device_names->push_back(name);
} }
return device_names.Pass(); return device_names.Pass();
...@@ -175,7 +188,21 @@ void VideoCaptureDeviceFactoryMac::GetDeviceSupportedFormats( ...@@ -175,7 +188,21 @@ void VideoCaptureDeviceFactoryMac::GetDeviceSupportedFormats(
[VideoCaptureDeviceAVFoundation getDevice:device [VideoCaptureDeviceAVFoundation getDevice:device
supportedFormats:supported_formats]; supportedFormats:supported_formats];
} else { } else {
NOTIMPLEMENTED(); // Blacklisted cameras provide their own supported format(s), otherwise no
// such information is provided for QTKit.
if (device.is_blacklisted()) {
for (size_t i = 0; i < arraysize(kBlacklistedCameras); ++i) {
if (device.id().find(kBlacklistedCameras[i].name) !=
std::string::npos) {
supported_formats->push_back(media::VideoCaptureFormat(
gfx::Size(kBlacklistedCameras[i].capture_width,
kBlacklistedCameras[i].capture_height),
kBlacklistedCameras[i].capture_frame_rate,
media::PIXEL_FORMAT_UYVY));
break;
}
}
}
} }
} }
......
...@@ -43,8 +43,9 @@ ...@@ -43,8 +43,9 @@
namespace media { namespace media {
const int kMinFrameRate = 1; // Mac specific limits for minimum and maximum frame rate.
const int kMaxFrameRate = 30; const float kMinFrameRate = 1.0f;
const float kMaxFrameRate = 30.0f;
// In 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; const size_t kVidPidSize = 4;
...@@ -350,7 +351,9 @@ VideoCaptureDeviceMac::VideoCaptureDeviceMac(const Name& device_name) ...@@ -350,7 +351,9 @@ VideoCaptureDeviceMac::VideoCaptureDeviceMac(const Name& device_name)
state_(kNotInitialized), state_(kNotInitialized),
capture_device_(nil), capture_device_(nil),
weak_factory_(this) { weak_factory_(this) {
final_resolution_selected_ = AVFoundationGlue::IsAVFoundationSupported(); // Avoid reconfiguring AVFoundation or blacklisted devices.
final_resolution_selected_ = AVFoundationGlue::IsAVFoundationSupported() ||
device_name.is_blacklisted();
} }
VideoCaptureDeviceMac::~VideoCaptureDeviceMac() { VideoCaptureDeviceMac::~VideoCaptureDeviceMac() {
...@@ -569,13 +572,13 @@ void VideoCaptureDeviceMac::LogMessage(const std::string& message) { ...@@ -569,13 +572,13 @@ void VideoCaptureDeviceMac::LogMessage(const std::string& message) {
} }
bool VideoCaptureDeviceMac::UpdateCaptureResolution() { bool VideoCaptureDeviceMac::UpdateCaptureResolution() {
if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height() if (![capture_device_ setCaptureHeight:capture_format_.frame_size.height()
width:capture_format_.frame_size.width() width:capture_format_.frame_size.width()
frameRate:capture_format_.frame_rate]) { frameRate:capture_format_.frame_rate]) {
ReceiveError("Could not configure capture device."); ReceiveError("Could not configure capture device.");
return false; return false;
} }
return true; return true;
} }
} // namespace media } // namespace media
...@@ -38,7 +38,8 @@ VideoCaptureDevice::Name::Name(const std::string& name, ...@@ -38,7 +38,8 @@ VideoCaptureDevice::Name::Name(const std::string& name,
: device_name_(name), : device_name_(name),
unique_id_(id), unique_id_(id),
capture_api_class_(api_type), capture_api_class_(api_type),
transport_type_(OTHER_TRANSPORT) {} transport_type_(OTHER_TRANSPORT),
is_blacklisted_(false) {}
VideoCaptureDevice::Name::Name(const std::string& name, VideoCaptureDevice::Name::Name(const std::string& name,
const std::string& id, const std::string& id,
...@@ -47,7 +48,8 @@ VideoCaptureDevice::Name::Name(const std::string& name, ...@@ -47,7 +48,8 @@ VideoCaptureDevice::Name::Name(const std::string& name,
: device_name_(name), : device_name_(name),
unique_id_(id), unique_id_(id),
capture_api_class_(api_type), capture_api_class_(api_type),
transport_type_(transport_type) {} transport_type_(transport_type),
is_blacklisted_(false) {}
#endif #endif
VideoCaptureDevice::Name::~Name() {} VideoCaptureDevice::Name::~Name() {}
......
...@@ -109,6 +109,12 @@ class MEDIA_EXPORT VideoCaptureDevice { ...@@ -109,6 +109,12 @@ class MEDIA_EXPORT VideoCaptureDevice {
TransportType transport_type() const { TransportType transport_type() const {
return transport_type_; return transport_type_;
} }
bool is_blacklisted() const {
return is_blacklisted_;
}
void set_is_blacklisted(bool is_blacklisted) {
is_blacklisted_ = is_blacklisted;
}
#endif // if defined(OS_WIN) #endif // if defined(OS_WIN)
private: private:
...@@ -134,6 +140,8 @@ class MEDIA_EXPORT VideoCaptureDevice { ...@@ -134,6 +140,8 @@ class MEDIA_EXPORT VideoCaptureDevice {
#endif #endif
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
TransportType transport_type_; TransportType transport_type_;
// Flag used to mark blacklisted devices for QTKit Api.
bool is_blacklisted_;
#endif #endif
// Allow generated copy constructor and assignment. // Allow generated copy constructor and assignment.
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment