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 75ee59d3bf495be332468550d2bb9ef22a16ef5d..afbec47e836e4de9d34a2bb41836dad12f75ac9b 100644 |
--- a/media/video/capture/win/video_capture_device_factory_win.cc |
+++ b/media/video/capture/win/video_capture_device_factory_win.cc |
@@ -98,64 +98,77 @@ static void GetDeviceNamesDirectShow(VideoCaptureDevice::Names* device_names) { |
if (FAILED(hr)) |
return; |
- ScopedComPtr<IEnumMoniker> enum_moniker; |
- hr = dev_enum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, |
- enum_moniker.Receive(), 0); |
- // CreateClassEnumerator returns S_FALSE on some Windows OS |
- // when no camera exist. Therefore the FAILED macro can't be used. |
- if (hr != S_OK) |
- return; |
- |
- device_names->clear(); |
+ static const struct{ |
+ CLSID class_id; |
+ VideoCaptureDevice::Name::CaptureApiType capture_api_type; |
+ } kDirectShowFilterClasses[] = { |
+ { CLSID_VideoInputDeviceCategory, VideoCaptureDevice::Name::DIRECT_SHOW }, |
+ { AM_KSCATEGORY_CROSSBAR, VideoCaptureDevice::Name::DIRECT_SHOW_WDM} |
+ }; |
- // Name of a fake DirectShow filter that exist on computers with |
- // GTalk installed. |
- static const char kGoogleCameraAdapter[] = "google camera adapter"; |
- // Enumerate all video capture devices. |
- ScopedComPtr<IMoniker> moniker; |
- int index = 0; |
- while (enum_moniker->Next(1, moniker.Receive(), NULL) == S_OK) { |
- ScopedComPtr<IPropertyBag> prop_bag; |
- hr = moniker->BindToStorage(0, 0, IID_IPropertyBag, prop_bag.ReceiveVoid()); |
- if (FAILED(hr)) { |
- moniker.Release(); |
+ device_names->clear(); |
+ for (int class_index = 0; class_index < arraysize(kDirectShowFilterClasses); |
+ ++class_index) { |
+ ScopedComPtr<IEnumMoniker> enum_moniker; |
+ hr = dev_enum->CreateClassEnumerator( |
+ kDirectShowFilterClasses[class_index].class_id, |
+ enum_moniker.Receive(), |
+ 0); |
+ // CreateClassEnumerator returns S_FALSE on some Windows OS |
+ // when no camera exist. Therefore the FAILED macro can't be used. |
+ if (hr != S_OK) |
continue; |
- } |
- // Find the description or friendly name. |
- ScopedVariant name; |
- hr = prop_bag->Read(L"Description", name.Receive(), 0); |
- if (FAILED(hr)) |
- hr = prop_bag->Read(L"FriendlyName", name.Receive(), 0); |
- |
- if (SUCCEEDED(hr) && name.type() == VT_BSTR) { |
- // Ignore all VFW drivers and the special Google Camera Adapter. |
- // Google Camera Adapter is not a real DirectShow camera device. |
- // VFW are very old Video for Windows drivers that can not be used. |
- const wchar_t* str_ptr = V_BSTR(&name); |
- const int name_length = arraysize(kGoogleCameraAdapter) - 1; |
- |
- if ((wcsstr(str_ptr, L"(VFW)") == NULL) && |
- lstrlenW(str_ptr) < name_length || |
- (!(LowerCaseEqualsASCII(str_ptr, str_ptr + name_length, |
- kGoogleCameraAdapter)))) { |
- std::string id; |
- std::string device_name(base::SysWideToUTF8(str_ptr)); |
- name.Reset(); |
- hr = prop_bag->Read(L"DevicePath", name.Receive(), 0); |
- if (FAILED(hr) || name.type() != VT_BSTR) { |
- id = device_name; |
- } else { |
- DCHECK_EQ(name.type(), VT_BSTR); |
- id = base::SysWideToUTF8(V_BSTR(&name)); |
- } |
+ // Name of a fake DirectShow filter that exist on computers with |
+ // GTalk installed. |
+ static const char kGoogleCameraAdapter[] = "google camera adapter"; |
+ |
+ // Enumerate all video capture devices. |
+ ScopedComPtr<IMoniker> moniker; |
+ int index = 0; |
+ while (enum_moniker->Next(1, moniker.Receive(), NULL) == S_OK) { |
+ ScopedComPtr<IPropertyBag> prop_bag; |
+ hr = moniker->BindToStorage(0, 0, IID_IPropertyBag, |
+ prop_bag.ReceiveVoid()); |
+ if (FAILED(hr)) { |
+ moniker.Release(); |
+ continue; |
+ } |
- device_names->push_back(VideoCaptureDevice::Name(device_name, id, |
- VideoCaptureDevice::Name::DIRECT_SHOW)); |
+ // Find the description or friendly name. |
+ ScopedVariant name; |
+ hr = prop_bag->Read(L"Description", name.Receive(), 0); |
+ if (FAILED(hr)) |
+ hr = prop_bag->Read(L"FriendlyName", name.Receive(), 0); |
+ |
+ if (SUCCEEDED(hr) && name.type() == VT_BSTR) { |
+ // Ignore all VFW drivers and the special Google Camera Adapter. |
+ // Google Camera Adapter is not a real DirectShow camera device. |
+ // VFW are very old Video for Windows drivers that can not be used. |
+ const wchar_t* str_ptr = V_BSTR(&name); |
+ const int name_length = arraysize(kGoogleCameraAdapter) - 1; |
+ |
+ if ((wcsstr(str_ptr, L"(VFW)") == NULL) && |
+ lstrlenW(str_ptr) < name_length || |
+ (!(LowerCaseEqualsASCII(str_ptr, str_ptr + name_length, |
+ kGoogleCameraAdapter)))) { |
+ std::string id; |
+ std::string device_name(base::SysWideToUTF8(str_ptr)); |
+ name.Reset(); |
+ hr = prop_bag->Read(L"DevicePath", name.Receive(), 0); |
+ if (FAILED(hr) || name.type() != VT_BSTR) { |
+ id = device_name; |
+ } else { |
+ DCHECK_EQ(name.type(), VT_BSTR); |
+ id = base::SysWideToUTF8(V_BSTR(&name)); |
+ } |
+ device_names->push_back(VideoCaptureDevice::Name(device_name, id, |
+ kDirectShowFilterClasses[class_index].capture_api_type)); |
+ } |
} |
+ moniker.Release(); |
} |
- moniker.Release(); |
} |
} |
@@ -387,8 +400,10 @@ scoped_ptr<VideoCaptureDevice> VideoCaptureDeviceFactoryWin::Create( |
if (!static_cast<VideoCaptureDeviceMFWin*>(device.get())->Init(source)) |
device.reset(); |
} else { |
- DCHECK_EQ(device_name.capture_api_type(), |
- VideoCaptureDevice::Name::DIRECT_SHOW); |
+ DCHECK(device_name.capture_api_type() == |
+ VideoCaptureDevice::Name::DIRECT_SHOW || |
perkj_chrome
2014/08/28 09:47:02
nit indentation
|
+ device_name.capture_api_type() == |
+ VideoCaptureDevice::Name::DIRECT_SHOW_WDM); |
device.reset(new VideoCaptureDeviceWin(device_name)); |
DVLOG(1) << " DirectShow Device: " << device_name.name(); |
if (!static_cast<VideoCaptureDeviceWin*>(device.get())->Init()) |