Fix streaming with non-B8G8R8A8 desktop mode (#609)

This commit is contained in:
Cameron Gutman 2022-12-22 19:48:31 -06:00 committed by GitHub
parent 1041f87a5d
commit bb092c0723
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -318,9 +318,17 @@ int display_base_t::init(int framerate, const std::string &display_name) {
DXGI_OUTDUPL_DESC dup_desc;
dup.dup->GetDesc(&dup_desc);
format = dup_desc.ModeDesc.Format;
BOOST_LOG(info) << "Desktop resolution ["sv << dup_desc.ModeDesc.Width << 'x' << dup_desc.ModeDesc.Height << ']';
BOOST_LOG(info) << "Desktop format ["sv << format_str[dup_desc.ModeDesc.Format] << ']';
BOOST_LOG(debug) << "Source format ["sv << format_str[dup_desc.ModeDesc.Format] << ']';
// For IDXGIOutput1::DuplicateOutput(), the format of the desktop image we receive from AcquireNextFrame() is
// converted to DXGI_FORMAT_B8G8R8A8_UNORM, even if the current mode (as returned in dup_desc) differs.
// See https://learn.microsoft.com/en-us/windows/win32/direct3ddxgi/desktop-dup-api for details.
//
// TODO: When we implement IDXGIOutput5, we will need to actually call AcquireNextFrame(), then call GetDesc()
// on the the texture we receive to determine which format in our list that it has decided to use.
format = DXGI_FORMAT_B8G8R8A8_UNORM;
BOOST_LOG(info) << "Capture format ["sv << format_str[format] << ']';
return 0;
}