Chromium Code Reviews| Index: media/video/capture/win/video_capture_device_win.cc |
| diff --git a/media/video/capture/win/video_capture_device_win.cc b/media/video/capture/win/video_capture_device_win.cc |
| index bd0446c9459717c4a358ad8e49bdf9b2b8bd7088..ebf5d391748afac0657f41db58d1bbf3a05fb7bd 100644 |
| --- a/media/video/capture/win/video_capture_device_win.cc |
| +++ b/media/video/capture/win/video_capture_device_win.cc |
| @@ -149,28 +149,59 @@ namespace media { |
| // static |
| void VideoCaptureDevice::GetDeviceNames(Names* device_names) { |
| + Names::iterator it; |
| + |
| if (VideoCaptureDeviceMFWin::PlatformSupported()) { |
| VideoCaptureDeviceMFWin::GetDeviceNames(device_names); |
| - } else { |
| - VideoCaptureDeviceWin::GetDeviceNames(device_names); |
| + it = device_names->begin(); |
| + for (; it != device_names->end(); ++it) |
| + it->capture_api_type = Name::MEDIA_FOUNDATION; |
| } |
| + // Retrieve the devices with DirectShow (DS) interface. They might (partially) |
| + // overlap with the MediaFoundation (MF), so the list has to be consolidated. |
| + Names temp_names; |
| + VideoCaptureDeviceWin::GetDeviceNames(&temp_names); |
| + it = device_names->begin(); |
| + |
| + // Merge the DS devices into the MF device list, and next remove |
| + // the duplicates, giving priority to the MF "versions". |
| + device_names->merge(temp_names); |
| + device_names->unique(); |
| } |
| // static |
| VideoCaptureDevice* VideoCaptureDevice::Create(const Name& device_name) { |
| VideoCaptureDevice* ret = NULL; |
| + Names::iterator it; |
|
tommi (sloooow) - chröme
2013/06/26 09:57:27
you shouldn't need to do any enumeration or search
mcasas
2013/07/02 12:28:11
Done.
|
| + Names device_names; |
| + |
| + // We search for the device name in the list of devices that MF Api gives. |
| if (VideoCaptureDeviceMFWin::PlatformSupported()) { |
| - scoped_ptr<VideoCaptureDeviceMFWin> device( |
| - new VideoCaptureDeviceMFWin(device_name)); |
| - if (device->Init()) |
| - ret = device.release(); |
| - } else { |
| - scoped_ptr<VideoCaptureDeviceWin> device( |
| - new VideoCaptureDeviceWin(device_name)); |
| - if (device->Init()) |
| - ret = device.release(); |
| + VideoCaptureDeviceMFWin::GetDeviceNames(&device_names); |
| + it = device_names.begin(); |
| + for (; it != device_names.end(); ++it) |
| + if (*it == device_name) { |
| + DLOG(WARNING) << " MediaFoundation Device: " << device_name.device_name; |
| + scoped_ptr<VideoCaptureDeviceMFWin> device( |
| + new VideoCaptureDeviceMFWin(device_name)); |
| + if (device->Init()) |
| + ret = device.release(); |
| + return ret; |
| + } |
| } |
| + VideoCaptureDeviceWin::GetDeviceNames(&device_names); |
| + it = device_names.begin(); |
| + for (; it != device_names.end(); ++it) |
| + if (*it == device_name) { |
| + DLOG(WARNING) << " DirectShow Device: " << device_name.device_name; |
| + scoped_ptr<VideoCaptureDeviceWin> device( |
| + new VideoCaptureDeviceWin(device_name)); |
| + if (device->Init()) |
| + ret = device.release(); |
| + return ret; |
| + } |
| + DLOG(ERROR) << "Couldn't recognize VideoCaptureDevice type!"; |
| return ret; |
| } |
| @@ -575,6 +606,10 @@ bool VideoCaptureDeviceWin::CreateCapabilityMap() { |
| capability.color = VideoCaptureCapability::kYUY2; |
| } else if (media_type->subtype == MEDIASUBTYPE_MJPG) { |
| capability.color = VideoCaptureCapability::kMJPEG; |
| + } else if (media_type->subtype == MEDIASUBTYPE_UYVY) { |
| + capability.color = VideoCaptureCapability::kUYVY; |
| + } else if (media_type->subtype == MEDIASUBTYPE_ARGB32) { |
| + capability.color = VideoCaptureCapability::kARGB; |
| } else { |
| WCHAR guid_str[128]; |
| StringFromGUID2(media_type->subtype, guid_str, arraysize(guid_str)); |
| @@ -596,5 +631,4 @@ void VideoCaptureDeviceWin::SetErrorState(const char* reason) { |
| state_ = kError; |
| observer_->OnError(); |
| } |
| - |
| } // namespace media |