Index: media/video/capture/win/video_capture_device_factory_win.cc |
diff --git a/media/video/capture/win/video_capture_device_factory_win.cc b/media/video/capture/win/video_capture_device_factory_win.cc |
index ad2922bd94ea48cdd1d2cbc7be1734daa755a48f..80cfd5da5c2d0b0cd79a51fa78c2f3b37e3d085d 100644 |
--- a/media/video/capture/win/video_capture_device_factory_win.cc |
+++ b/media/video/capture/win/video_capture_device_factory_win.cc |
@@ -92,6 +92,7 @@ static bool EnumerateVideoDevicesMediaFoundation(IMFActivate*** devices, |
static void GetDeviceNamesDirectShow(Names* device_names) { |
DCHECK(device_names); |
+ DCHECK(device_names->empty()); |
DVLOG(1) << " GetDeviceNamesDirectShow"; |
ScopedComPtr<ICreateDevEnum> dev_enum; |
@@ -105,11 +106,9 @@ static void GetDeviceNamesDirectShow(Names* device_names) { |
Name::CaptureApiType capture_api_type; |
} kDirectShowFilterClasses[] = { |
{ CLSID_VideoInputDeviceCategory, Name::DIRECT_SHOW }, |
- { AM_KSCATEGORY_CROSSBAR, Name::DIRECT_SHOW_WDM} |
+ { AM_KSCATEGORY_CROSSBAR, Name::DIRECT_SHOW_WDM} // Must be the last entry. |
perkj_chrome
2014/09/02 09:22:03
http://msdn.microsoft.com/en-us/library/windows/de
mcasas
2014/09/02 15:13:41
Done.
|
}; |
- |
- device_names->clear(); |
for (int class_index = 0; class_index < arraysize(kDirectShowFilterClasses); |
perkj_chrome
2014/09/02 09:22:03
instead of a for loop- would it make sence to put
mcasas
2014/09/02 15:13:41
Done.
|
++class_index) { |
ScopedComPtr<IEnumMoniker> enum_moniker; |
@@ -165,8 +164,21 @@ static void GetDeviceNamesDirectShow(Names* device_names) { |
DCHECK_EQ(name.type(), VT_BSTR); |
id = base::SysWideToUTF8(V_BSTR(&name)); |
} |
- device_names->push_back(Name(device_name, id, |
- kDirectShowFilterClasses[class_index].capture_api_type)); |
+ Name device(device_name, id, |
magjed_chromium
2014/09/02 15:14:41
device can be made const
|
+ kDirectShowFilterClasses[class_index].capture_api_type); |
+ // For WDM devices, we need to search in the listed |device_names| to |
+ // find a device with matching USB ID. |
perkj_chrome
2014/09/02 09:22:03
you are comparing GetModel() to find the USB id o
mcasas
2014/09/02 15:13:41
Clarified.
|
+ if (device.capture_api_type() == Name::DIRECT_SHOW_WDM) { |
+ const std::string& device_model = device.GetModel(); |
+ Names::const_iterator iter = device_names->begin(); |
+ for (; iter != device_names->end(); ++iter) { |
+ if (device_model.compare(iter->GetModel()) == 0) { |
perkj_chrome
2014/09/02 09:22:03
prefer ==
mcasas
2014/09/02 15:13:41
Not sure I understand. Can you please clarify?
|
+ device.set_capabilities_unique_id(iter->id()); |
perkj_chrome
2014/09/02 09:22:03
Do you know what happens if you have two capture c
mcasas
2014/09/02 15:13:41
Yes.
|
+ break; |
+ } |
+ } |
+ } |
+ device_names->push_back(device); |
} |
} |
moniker.Release(); |
@@ -222,14 +234,14 @@ static void GetDeviceSupportedFormatsDirectShow(const Name& device, |
if (hr != S_OK) |
return; |
- // Walk the capture devices. No need to check for device presence again, that |
- // is caught in GetDeviceFilter(). "google camera adapter" and old VFW devices |
- // are already skipped in the previous GetDeviceNames() enumeration. |
+ // Walk the capture devices. No need to check for device presence again since |
+ // that is anyway needed in GetDeviceFilter(). "google camera adapter" and old |
+ // VFW devices are already skipped previously in GetDeviceNames() enumeration. |
base::win::ScopedComPtr<IBaseFilter> capture_filter; |
- hr = VideoCaptureDeviceWin::GetDeviceFilter(device, |
+ hr = VideoCaptureDeviceWin::GetDeviceFilter(device.capabilities_unique_id(), |
capture_filter.Receive()); |
if (!capture_filter) { |
- DVLOG(2) << "Failed to create capture filter."; |
+ DVLOG(2) << "Failed to create capture filter." ; |
magjed_chromium
2014/09/02 15:14:41
Unnecessary space after string :)
|
return; |
} |