Commit 679e60e7 authored by Rahul Singh's avatar Rahul Singh Committed by Commit Bot

Video Capture: Fix VideoFacingMode & rotation for IR cameras on Windows

Problem:
Currently in VideoCaptureDeviceFactoryWin::GetDevicesInfoMediaFoundation
we generate |devices_info| with MFAttributes for both
KSCATEGORY_VIDEO_CAMERA and KSCATEGORY_SENSOR_CAMERA. The latter
attribute adds IR cameras (used for Windows Hello) to |devices_info|.

However, in VideoCaptureDeviceFactoryWin::EnumerateDevicesUWP we use
FindAllAsyncDeviceClass() to get Device Information for only video
capture devices. As a result, we never get_EnclosureLocation() for IR
cameras. Consequently, their VideoFacingMode is never set. This results
in incorrect camera rotation for IR cameras on pages like:
https://webrtc.github.io/samples/src/content/devices/input-output/

Fix:
This CL changes the Windows API used in
VideoCaptureDeviceFactoryWin::EnumerateDevicesUWP from
FindAllAsyncDeviceClass() to FindAllAsyncAqsFilter(). The latter allows
us to provide an AQS selector string to filter devices for which
DeviceInformation is returned to both KSCATEGORY_VIDEO_CAMERA and
KSCATEGORY_SENSOR_CAMERA.

Testing:
Verified that the above change fixes rotation for IR cameras while
keeping rotation behavior for Video cameras the same.

Bug: 1090754
Change-Id: I0420cc2034be905e188d7e94f51eed298cdeaa7e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2366035Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Rahul Singh <rahsin@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#801408}
parent 2b06a2b4
......@@ -50,6 +50,18 @@ const char kVidPrefix[] = "vid_"; // Also contains '\0'.
const char kPidPrefix[] = "pid_"; // Also contains '\0'.
const size_t kVidPidSize = 4;
// AQS device selector string to filter enumerated DeviceInformation objects to
// KSCATEGORY_SENSOR_CAMERA (Class GUID 24e552d7-6523-47F7-a647-d3465bf1f5ca)
// OR KSCATEGORY_VIDEO_CAMERA (Class GUID e5323777-f976-4f5b-9b55-b94699c46e44).
const wchar_t* kVideoAndSensorCamerasAqsString =
L"(System.Devices.InterfaceClassGuid:="
L"\"{e5323777-f976-4f5b-9b55-b94699c46e44}\" AND "
L"(System.Devices.WinPhone8CameraFlags:=[] OR "
L"System.Devices.WinPhone8CameraFlags:<4096)) OR "
L"System.Devices.InterfaceClassGuid:="
L"\"{24e552d7-6523-47f7-a647-d3465bf1f5ca}\" AND "
L"System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#True";
// Avoid enumerating and/or using certain devices due to they provoking crashes
// or any other reason (http://crbug.com/378494). This enum is defined for the
// purposes of UMA collection. Existing entries cannot be removed.
......@@ -542,8 +554,9 @@ void VideoCaptureDeviceFactoryWin::EnumerateDevicesUWP(
}
IAsyncOperation<DeviceInformationCollection*>* async_op;
hr = dev_info_statics->FindAllAsyncDeviceClass(
ABI::Windows::Devices::Enumeration::DeviceClass_VideoCapture, &async_op);
ScopedHString aqs_filter =
ScopedHString::Create(kVideoAndSensorCamerasAqsString);
hr = dev_info_statics->FindAllAsyncAqsFilter(aqs_filter.get(), &async_op);
if (FAILED(hr)) {
UWP_ENUM_ERROR_HANDLER(hr, "Find all devices asynchronously failed: ");
return;
......
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