Allow getDisplayMedia capture HDR monitor.

The code uses IDXGIOutput1::DuplicateOutput for screen capture and
it allows only DXGI_FORMAT_B8G8R8A8_UNORM texture format, which
works on most monitor cases except HDR monitor.

HDR mointor returns type of DXGI_FORMAT_R16G16B16A16_FLOAT.

These two types of DXGI_FORMAT_B8G8R8A8_UNORM and
DXGI_FORMAT_R16G16B16A16_FLOAT are all formats that DuplicateOutput
returns based on Windows OS team.

The fix is to add allowed format of DXGI_FORMAT_R16G16B16A16_FLOAT.

Manually repro the issue and validated the fix.

Bug: chromium:40787684
Change-Id: I0a7be38b14a06261d631d2db172f12725edbbf1f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/339621
Reviewed-by: Mark Foltz <mfoltz@chromium.org>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#41749}
This commit is contained in:
Sunggook Chue 2024-02-13 15:52:28 -08:00 committed by WebRTC LUCI CQ
parent 7e0bd7aaaf
commit 62cbdcea05

View File

@ -112,9 +112,13 @@ bool DxgiOutputDuplicator::DuplicateOutput() {
memset(&desc_, 0, sizeof(desc_));
duplication_->GetDesc(&desc_);
if (desc_.ModeDesc.Format != DXGI_FORMAT_B8G8R8A8_UNORM) {
RTC_LOG(LS_ERROR) << "IDXGIDuplicateOutput does not use RGBA (8 bit) "
<< "format, which is required by downstream components, "
// DXGI_FORMAT_R16G16B16A16_FLOAT is returned for HDR monitor,
// DXGI_FORMAT_B8G8R8A8_UNORM for others.
if ((desc_.ModeDesc.Format != DXGI_FORMAT_B8G8R8A8_UNORM) &&
(desc_.ModeDesc.Format != DXGI_FORMAT_R16G16B16A16_FLOAT)) {
RTC_LOG(LS_ERROR) << "IDXGIDuplicateOutput does not use RGBA (8, 16 bit)"
<< "which is required by downstream components"
<< "format is " << desc_.ModeDesc.Format;
return false;
}