From 62cbdcea050529a5cd18d5e82dc3c8f6997b09fc Mon Sep 17 00:00:00 2001 From: Sunggook Chue Date: Tue, 13 Feb 2024 15:52:28 -0800 Subject: [PATCH] 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 Reviewed-by: Alexander Cooper Commit-Queue: Alexander Cooper Cr-Commit-Position: refs/heads/main@{#41749} --- modules/desktop_capture/win/dxgi_output_duplicator.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/desktop_capture/win/dxgi_output_duplicator.cc b/modules/desktop_capture/win/dxgi_output_duplicator.cc index 9c64125b4e..ac028ce38b 100644 --- a/modules/desktop_capture/win/dxgi_output_duplicator.cc +++ b/modules/desktop_capture/win/dxgi_output_duplicator.cc @@ -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; }