| 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 bc3d54153c5bd355e01d6f18181546f8832d01e1..e2e2dfb45166a6dd0036a337c96a5da66fd146b6 100644
|
| --- a/media/video/capture/mac/video_capture_device_mac.mm
|
| +++ b/media/video/capture/mac/video_capture_device_mac.mm
|
| @@ -22,14 +22,6 @@ const int kMaxFrameRate = 30;
|
| // In device identifiers, the USB VID and PID are stored in 4 bytes each.
|
| const size_t kVidPidSize = 4;
|
|
|
| -// 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;
|
| @@ -69,72 +61,6 @@ void GetBestMatchSupportedResolution(int* width, int* height) {
|
| *height = matched_height;
|
| }
|
|
|
| -//static
|
| -void VideoCaptureDevice::GetDeviceNames(Names* device_names) {
|
| - // Loop through all available devices and add to |device_names|.
|
| - NSDictionary* capture_devices;
|
| - if (AVFoundationGlue::IsAVFoundationSupported()) {
|
| - bool is_any_device_blacklisted = false;
|
| - DVLOG(1) << "Enumerating video capture devices using AVFoundation";
|
| - capture_devices = [VideoCaptureDeviceAVFoundation deviceNames];
|
| - std::string device_vid;
|
| - // Enumerate all devices found by AVFoundation, translate the info for each
|
| - // to class Name and add it to |device_names|.
|
| - for (NSString* key in capture_devices) {
|
| - Name name([[capture_devices valueForKey:key] UTF8String],
|
| - [key UTF8String], Name::AVFOUNDATION);
|
| - device_names->push_back(name);
|
| - // Extract the device's Vendor ID and compare to all blacklisted ones.
|
| - device_vid = name.GetModel().substr(0, kVidPidSize);
|
| - for (size_t i = 0; i < arraysize(kBlacklistedCameras); ++i) {
|
| - is_any_device_blacklisted |=
|
| - !strcasecmp(device_vid.c_str(), kBlacklistedCameras[i].vid);
|
| - if (is_any_device_blacklisted)
|
| - break;
|
| - }
|
| - }
|
| - // If there is any device blacklisted in the system, walk the QTKit device
|
| - // list and add those devices with a blacklisted name to the |device_names|.
|
| - // AVFoundation and QTKit device lists partially overlap, so add a "QTKit"
|
| - // prefix to the latter ones to distinguish them from the AVFoundation ones.
|
| - if (is_any_device_blacklisted) {
|
| - capture_devices = [VideoCaptureDeviceQTKit deviceNames];
|
| - for (NSString* key in capture_devices) {
|
| - NSString* 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);
|
| - }
|
| - }
|
| - }
|
| - }
|
| - } 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);
|
| - }
|
| - }
|
| -}
|
| -
|
| -// static
|
| -void VideoCaptureDevice::GetDeviceSupportedFormats(const Name& device,
|
| - VideoCaptureFormats* formats) {
|
| - if (device.capture_api_type() == Name::AVFOUNDATION) {
|
| - DVLOG(1) << "Enumerating video capture capabilities, AVFoundation";
|
| - [VideoCaptureDeviceAVFoundation getDevice:device
|
| - supportedFormats:formats];
|
| - } else {
|
| - NOTIMPLEMENTED();
|
| - }
|
| -}
|
| -
|
| const std::string VideoCaptureDevice::Name::GetModel() const {
|
| // Both PID and VID are 4 characters.
|
| if (unique_id_.size() < 2 * kVidPidSize) {
|
| @@ -150,17 +76,6 @@ const std::string VideoCaptureDevice::Name::GetModel() const {
|
| return id_vendor + ":" + id_product;
|
| }
|
|
|
| -VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) {
|
| - VideoCaptureDeviceMac* capture_device =
|
| - new VideoCaptureDeviceMac(device_name);
|
| - if (!capture_device->Init()) {
|
| - LOG(ERROR) << "Could not initialize VideoCaptureDevice.";
|
| - delete capture_device;
|
| - capture_device = NULL;
|
| - }
|
| - return capture_device;
|
| -}
|
| -
|
| VideoCaptureDeviceMac::VideoCaptureDeviceMac(const Name& device_name)
|
| : device_name_(device_name),
|
| tried_to_square_pixels_(false),
|
| @@ -244,25 +159,12 @@ void VideoCaptureDeviceMac::StopAndDeAllocate() {
|
| tried_to_square_pixels_ = false;
|
| }
|
|
|
| -bool VideoCaptureDeviceMac::Init() {
|
| +bool VideoCaptureDeviceMac::Init(
|
| + VideoCaptureDevice::Name::CaptureApiType capture_api_type) {
|
| DCHECK(task_runner_->BelongsToCurrentThread());
|
| DCHECK_EQ(state_, kNotInitialized);
|
|
|
| - // TODO(mcasas): The following check might not be necessary; if the device has
|
| - // disappeared after enumeration and before coming here, opening would just
|
| - // fail but not necessarily produce a crash.
|
| - Names device_names;
|
| - GetDeviceNames(&device_names);
|
| - Names::iterator it = device_names.begin();
|
| - for (; it != device_names.end(); ++it) {
|
| - if (it->id() == device_name_.id())
|
| - break;
|
| - }
|
| - if (it == device_names.end())
|
| - return false;
|
| -
|
| - DCHECK_NE(it->capture_api_type(), Name::API_TYPE_UNKNOWN);
|
| - if (it->capture_api_type() == Name::AVFOUNDATION) {
|
| + if (capture_api_type == Name::AVFOUNDATION) {
|
| capture_device_ =
|
| [[VideoCaptureDeviceAVFoundation alloc] initWithFrameReceiver:this];
|
| } else {
|
|
|