Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(762)

Unified Diff: media/video/capture/win/video_capture_device_factory_win.cc

Issue 541603002: Fix if-statement in win video capture that ignores fake DirectShow filters (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mcasas@s and tommi@s comments Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f36f4e6a3aec4a6de6e3b66cd64ee53811d5ee8e..606c8f75728426997e4958d41ea0def1557afaa7 100644
--- a/media/video/capture/win/video_capture_device_factory_win.cc
+++ b/media/video/capture/win/video_capture_device_factory_win.cc
@@ -91,7 +91,7 @@ static bool EnumerateVideoDevicesMediaFoundation(IMFActivate*** devices,
}
static void GetDeviceNamesDirectShow(
- const CLSID class_id,
+ const CLSID& class_id,
const Name::CaptureApiType capture_api_type,
Names* device_names) {
DCHECK(device_names);
@@ -110,20 +110,14 @@ static void GetDeviceNamesDirectShow(
if (hr != S_OK)
return;
- // 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) {
+ for (ScopedComPtr<IMoniker> moniker;
tommi (sloooow) - chröme 2014/09/05 09:26:40 nice way of scoping the moniker variable
+ enum_moniker->Next(1, moniker.Receive(), NULL) == S_OK;
+ moniker.Release()) {
ScopedComPtr<IPropertyBag> prop_bag;
hr = moniker->BindToStorage(0, 0, IID_IPropertyBag, prop_bag.ReceiveVoid());
- if (FAILED(hr)) {
- moniker.Release();
- return;
- }
+ if (FAILED(hr))
+ continue;
// Find the description or friendly name.
ScopedVariant name;
@@ -131,31 +125,34 @@ static void GetDeviceNamesDirectShow(
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(Name(device_name, id, capture_api_type));
- }
+ if (FAILED(hr) || name.type() != VT_BSTR)
+ continue;
+
+ // 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);
+ // Name of a fake DirectShow filter that exist on computers with
+ // GTalk installed.
+ static const char kGoogleCameraAdapter[] = "google camera adapter";
magjed_chromium 2014/09/05 09:15:09 Per, can we remove this?
perkj_chrome 2014/09/05 13:52:39 I would keep it for now. I think this is a fake de
+ if (wcsstr(str_ptr, L"(VFW)") != NULL ||
+ LowerCaseEqualsASCII(str_ptr,
+ str_ptr + arraysize(kGoogleCameraAdapter) - 1,
+ kGoogleCameraAdapter)) {
+ continue;
+ }
+
+ const std::string device_name(base::SysWideToUTF8(str_ptr));
+ name.Reset();
+ hr = prop_bag->Read(L"DevicePath", name.Receive(), 0);
+ std::string id;
+ if (FAILED(hr) || name.type() != VT_BSTR) {
+ id = device_name;
+ } else {
+ DCHECK_EQ(name.type(), VT_BSTR);
+ id = base::SysWideToUTF8(V_BSTR(&name));
}
- moniker.Release();
+ device_names->push_back(Name(device_name, id, capture_api_type));
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698