Chromium Code Reviews| 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 4f68c6edb3841a622246848f9dd42562e1e96d3c..7954c2dee8621131a2f6e7339caf0dbfebec7aac 100644 |
| --- a/media/video/capture/win/video_capture_device_factory_win.cc |
| +++ b/media/video/capture/win/video_capture_device_factory_win.cc |
| @@ -9,6 +9,7 @@ |
| #include "base/command_line.h" |
| #include "base/lazy_instance.h" |
| +#include "base/metrics/histogram.h" |
| #include "base/strings/string_util.h" |
| #include "base/strings/sys_string_conversions.h" |
| #include "base/win/metro.h" |
| @@ -27,6 +28,14 @@ using Names = media::VideoCaptureDevice::Names; |
| namespace media { |
| +// Some devices cause crashes when trying to be enumerated. This enum is defined |
| +// for the purposes of UMA collection. Existing entries cannot be removed. |
| +enum BlacklistedCameraNames{ |
| + BLACKLISTED_CAMERA_IP_CAMERA, |
| + BLACKLISTED_CAMERA_CYBERLINK_WEBCAM_SPLITTER, |
| + BLACKLISTED_CAMERA_MAX // This one must be last. |
| +}; |
| + |
| // Lazy Instance to initialize the MediaFoundation Library. |
| class MFInitializerSingleton { |
| public: |
| @@ -37,6 +46,12 @@ class MFInitializerSingleton { |
| static base::LazyInstance<MFInitializerSingleton> g_mf_initialize = |
| LAZY_INSTANCE_INITIALIZER; |
| +// Blacklisted devices are identified by a characteristic substring of the name. |
| +static const char* kBlacklistedCameraNames[] = { |
| + {"IP Camera [JPEG/MJPEG]" }, |
|
tommi (sloooow) - chröme
2014/10/12 09:46:03
nit: no space before } (for consistency)
mcasas
2014/10/12 14:45:39
Done.
|
| + {"CyberLink Webcam Splitter"} |
|
tommi (sloooow) - chröme
2014/10/12 09:46:03
Can you point me to a report where we encountered
mcasas
2014/10/12 14:45:39
Sure, there are a few in the other bug linked to t
|
| +}; |
| + |
| static void EnsureMediaFoundationInit() { |
| g_mf_initialize.Get(); |
| } |
| @@ -90,6 +105,20 @@ static bool EnumerateVideoDevicesMediaFoundation(IMFActivate*** devices, |
| return SUCCEEDED(MFEnumDeviceSources(attributes, devices, count)); |
| } |
| +static bool IsDeviceBlackListed(const std::string& name) { |
| + DCHECK_EQ(static_cast<int>(arraysize(kBlacklistedCameraNames)), |
| + BLACKLISTED_CAMERA_MAX); |
| + for (size_t i = 0; i < arraysize(kBlacklistedCameraNames); ++i) { |
| + if (name.find (kBlacklistedCameraNames[i]) != std::string::npos) { |
|
tommi (sloooow) - chröme
2014/10/12 09:46:03
no space before (
What about StartsWith? (string_
mcasas
2014/10/12 14:45:39
Done.
|
| + DVLOG(1) << "Enumerated blacklisted device: " << name; |
| + UMA_HISTOGRAM_ENUMERATION("Media.VideoCapture.BlacklistedDevice", |
| + i, BLACKLISTED_CAMERA_MAX + 1); |
| + return true; |
| + } |
| + } |
| + return false; |
| +} |
| + |
| static void GetDeviceNamesDirectShow( |
| const CLSID& class_id, |
| const Name::CaptureApiType capture_api_type, |
| @@ -143,6 +172,8 @@ static void GetDeviceNamesDirectShow( |
| } |
| const std::string device_name(base::SysWideToUTF8(str_ptr)); |
| + if (IsDeviceBlackListed(device_name)) |
| + continue; |
| name.Reset(); |
| hr = prop_bag->Read(L"DevicePath", name.Receive(), 0); |
| std::string id; |