Commit c10d6298 authored by Rahul Singh's avatar Rahul Singh Committed by Chromium LUCI CQ

Video Capture: Don't include IR cameras in device enumeration by default

This CL updates the MFAttributes we use for video capture on Windows. By
default, we only include MFAttributes for RGB color cameras. So, the
resulting device enumeration contains only RGB cameras.

When the newly added `kIncludeIRCamerasInDeviceEnumeration` feature flag
is enabled, we also include MFAttributes for IR cameras. The resulting
device enumeration contains both RGB and IR cameras.

Testing:
Created versions of the GetDevicesInfo unittest with the feature flag
enabled, and with it disabled.

Bug: 1144049
Change-Id: Id234413f5125e866be5177141decfc9a68bc2fd8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2631409Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Rahul Singh <rahsin@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#846260}
parent 05999008
......@@ -672,6 +672,11 @@ const base::Feature kDelayCopyNV12Textures{"DelayCopyNV12Textures",
const base::Feature kDirectShowGetPhotoState{"DirectShowGetPhotoState",
base::FEATURE_ENABLED_BY_DEFAULT};
// Includes Infrared cameras in the list returned for EnumerateDevices() on
// Windows.
const base::Feature kIncludeIRCamerasInDeviceEnumeration{
"IncludeIRCamerasInDeviceEnumeration", base::FEATURE_DISABLED_BY_DEFAULT};
// Enables asynchronous H264 HW encode acceleration using Media Foundation for
// Windows.
const base::Feature kMediaFoundationAsyncH264Encoding{
......
......@@ -227,6 +227,7 @@ MEDIA_EXPORT extern const base::Feature kUseAlternateVideoDecoderImplementation;
#if defined(OS_WIN)
MEDIA_EXPORT extern const base::Feature kDelayCopyNV12Textures;
MEDIA_EXPORT extern const base::Feature kDirectShowGetPhotoState;
MEDIA_EXPORT extern const base::Feature kIncludeIRCamerasInDeviceEnumeration;
MEDIA_EXPORT extern const base::Feature kMediaFoundationAsyncH264Encoding;
MEDIA_EXPORT extern const base::Feature kMediaFoundationAV1Decoding;
MEDIA_EXPORT extern const base::Feature kMediaFoundationVideoCapture;
......
......@@ -133,18 +133,30 @@ const char* const kDisplayNamesBlockedForMediaFoundation[] = {
const std::vector<
std::pair<VideoCaptureApi, std::vector<std::pair<GUID, GUID>>>>&
GetMFAttributes() {
if (base::FeatureList::IsEnabled(
media::kIncludeIRCamerasInDeviceEnumeration)) {
static const base::NoDestructor<std::vector<
std::pair<VideoCaptureApi, std::vector<std::pair<GUID, GUID>>>>>
mf_attributes({{{VideoCaptureApi::WIN_MEDIA_FOUNDATION,
{
{MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE,
MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID},
}},
{VideoCaptureApi::WIN_MEDIA_FOUNDATION_SENSOR,
{{MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE,
MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID},
{MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_CATEGORY,
KSCATEGORY_SENSOR_CAMERA}}}}});
return *mf_attributes;
}
static const base::NoDestructor<std::vector<
std::pair<VideoCaptureApi, std::vector<std::pair<GUID, GUID>>>>>
mf_attributes({{{VideoCaptureApi::WIN_MEDIA_FOUNDATION,
{
{MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE,
MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID},
}},
{VideoCaptureApi::WIN_MEDIA_FOUNDATION_SENSOR,
{{MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE,
MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID},
{MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_CATEGORY,
KSCATEGORY_SENSOR_CAMERA}}}}});
mf_attributes({{VideoCaptureApi::WIN_MEDIA_FOUNDATION,
{
{MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE,
MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID},
}}});
return *mf_attributes;
}
......
......@@ -18,8 +18,10 @@
#include "base/run_loop.h"
#include "base/strings/sys_string_conversions.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/win/windows_version.h"
#include "media/base/media_switches.h"
#include "media/capture/video/win/video_capture_device_factory_win.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -1353,6 +1355,104 @@ TEST_P(VideoCaptureDeviceFactoryMFWinTest, GetDevicesInfo) {
}));
run_loop.Run();
EXPECT_EQ(devices_info.size(), 6U);
for (auto it = devices_info.begin(); it != devices_info.end(); it++) {
// Verify that there are no duplicates.
EXPECT_EQ(
FindDeviceInRange(devices_info.begin(), it, it->descriptor.device_id),
it);
}
iterator it = FindDeviceInRange(devices_info.begin(), devices_info.end(),
base::SysWideToUTF8(kMFDeviceId0));
ASSERT_NE(it, devices_info.end());
EXPECT_EQ(it->descriptor.capture_api, VideoCaptureApi::WIN_MEDIA_FOUNDATION);
EXPECT_EQ(it->descriptor.display_name(), base::SysWideToUTF8(kMFDeviceName0));
// No IAMCameraControl and no IAMVideoProcAmp interfaces.
EXPECT_FALSE(it->descriptor.control_support().pan);
EXPECT_FALSE(it->descriptor.control_support().tilt);
EXPECT_FALSE(it->descriptor.control_support().zoom);
it = FindDeviceInRange(devices_info.begin(), devices_info.end(),
base::SysWideToUTF8(kMFDeviceId1));
ASSERT_NE(it, devices_info.end());
EXPECT_EQ(it->descriptor.capture_api, VideoCaptureApi::WIN_MEDIA_FOUNDATION);
EXPECT_EQ(it->descriptor.display_name(), base::SysWideToUTF8(kMFDeviceName1));
// No pan/tilt/zoom in IAMCameraControl interface.
EXPECT_FALSE(it->descriptor.control_support().pan);
EXPECT_FALSE(it->descriptor.control_support().tilt);
EXPECT_FALSE(it->descriptor.control_support().zoom);
it = FindDeviceInRange(devices_info.begin(), devices_info.end(),
base::SysWideToUTF8(kDirectShowDeviceId3));
ASSERT_NE(it, devices_info.end());
EXPECT_EQ(it->descriptor.capture_api, VideoCaptureApi::WIN_DIRECT_SHOW);
EXPECT_EQ(it->descriptor.display_name(),
base::SysWideToUTF8(kDirectShowDeviceName3));
// No ICameraControl interface.
EXPECT_FALSE(it->descriptor.control_support().pan);
EXPECT_FALSE(it->descriptor.control_support().tilt);
EXPECT_FALSE(it->descriptor.control_support().zoom);
it = FindDeviceInRange(devices_info.begin(), devices_info.end(),
base::SysWideToUTF8(kDirectShowDeviceId4));
ASSERT_NE(it, devices_info.end());
EXPECT_EQ(it->descriptor.capture_api, VideoCaptureApi::WIN_DIRECT_SHOW);
EXPECT_EQ(it->descriptor.display_name(),
base::SysWideToUTF8(kDirectShowDeviceName4));
// No IVideoProcAmp interface.
EXPECT_FALSE(it->descriptor.control_support().pan);
EXPECT_FALSE(it->descriptor.control_support().tilt);
EXPECT_FALSE(it->descriptor.control_support().zoom);
// Devices that are listed in MediaFoundation but only report supported
// formats in DirectShow are expected to get enumerated with
// VideoCaptureApi::WIN_DIRECT_SHOW
it = FindDeviceInRange(devices_info.begin(), devices_info.end(),
base::SysWideToUTF8(kDirectShowDeviceId5));
ASSERT_NE(it, devices_info.end());
EXPECT_EQ(it->descriptor.capture_api, VideoCaptureApi::WIN_DIRECT_SHOW);
EXPECT_EQ(it->descriptor.display_name(),
base::SysWideToUTF8(kDirectShowDeviceName5));
// No pan, tilt, or zoom ranges in ICameraControl interface.
EXPECT_FALSE(it->descriptor.control_support().pan);
EXPECT_FALSE(it->descriptor.control_support().tilt);
EXPECT_FALSE(it->descriptor.control_support().zoom);
// Devices that are listed in both MediaFoundation and DirectShow but are
// blocked for use with MediaFoundation are expected to get enumerated with
// VideoCaptureApi::WIN_DIRECT_SHOW.
it = FindDeviceInRange(devices_info.begin(), devices_info.end(),
base::SysWideToUTF8(kDirectShowDeviceId6));
ASSERT_NE(it, devices_info.end());
EXPECT_EQ(it->descriptor.capture_api, VideoCaptureApi::WIN_DIRECT_SHOW);
EXPECT_EQ(it->descriptor.display_name(),
base::SysWideToUTF8(kDirectShowDeviceName6));
EXPECT_TRUE(it->descriptor.control_support().pan);
EXPECT_TRUE(it->descriptor.control_support().tilt);
EXPECT_TRUE(it->descriptor.control_support().zoom);
}
TEST_P(VideoCaptureDeviceFactoryMFWinTest, GetDevicesInfo_IncludeIRCameras) {
base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(kIncludeIRCamerasInDeviceEnumeration);
if (ShouldSkipMFTest())
return;
const bool use_d3d11 = GetParam();
if (use_d3d11 && ShouldSkipD3D11Test())
return;
factory_.set_use_d3d11_with_media_foundation_for_testing(use_d3d11);
std::vector<VideoCaptureDeviceInfo> devices_info;
base::RunLoop run_loop;
factory_.GetDevicesInfo(base::BindLambdaForTesting(
[&devices_info, &run_loop](std::vector<VideoCaptureDeviceInfo> result) {
devices_info = std::move(result);
run_loop.Quit();
}));
run_loop.Run();
EXPECT_EQ(devices_info.size(), 7U);
for (auto it = devices_info.begin(); it != devices_info.end(); it++) {
// Verify that there are no duplicates.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment