webrtc_m130/modules/desktop_capture/window_capturer_win.cc
Sunggook Chue 347f9b07b9 getDisplayMedia shows black window on Youtube PiP in Windows.
getDisplayMedia capture the view of the screens and windows
in the capture dialog, but the issue is that captured view
of the Youtube somehow is blank. It repros only in certain
circumstances, for example, Canary channel.
If user reinstall the Canary as fresh new, we observed that
it doesn't repro.

Cause:
We aren't sure what's cause of this one yet.

Solution:
We decided to provide fallback WGC capturer when the main
capturer (GDI) shows blank. WGC could show yellow outline
in prior Win11 OS, but yellow outline looks better than
blank.

The blank detector and fallback capturer are what screen capturer
already supported. So, the solution will follow similar
pattern in the window capturer.

Bug: webrtc:13726
Change-Id: I620c817d259d7bb5c295adab11c4444349ab1c6c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252625
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#36224}
2022-03-16 22:06:04 +00:00

49 lines
1.9 KiB
C++

/*
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/desktop_capture/desktop_capture_options.h"
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/win/window_capturer_win_gdi.h"
#if defined(RTC_ENABLE_WIN_WGC)
#include "modules/desktop_capture/blank_detector_desktop_capturer_wrapper.h"
#include "modules/desktop_capture/fallback_desktop_capturer_wrapper.h"
#include "modules/desktop_capture/win/wgc_capturer_win.h"
#include "rtc_base/win/windows_version.h"
#endif // defined(RTC_ENABLE_WIN_WGC)
namespace webrtc {
// static
std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawWindowCapturer(
const DesktopCaptureOptions& options) {
std::unique_ptr<DesktopCapturer> capturer(
WindowCapturerWinGdi::CreateRawWindowCapturer(options));
#if defined(RTC_ENABLE_WIN_WGC)
if (options.allow_wgc_capturer_fallback() &&
rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_WIN10_RS5) {
// BlankDectector capturer will send an error when it detects a failed
// GDI rendering, then Fallback capturer will try to capture it again with
// WGC.
capturer = std::make_unique<BlankDetectorDesktopCapturerWrapper>(
std::move(capturer), RgbaColor(0, 0, 0, 0),
/*check_per_capture*/ true);
capturer = std::make_unique<FallbackDesktopCapturerWrapper>(
std::move(capturer),
WgcCapturerWin::CreateRawWindowCapturer(
options, /*allow_delayed_capturable_check*/ true));
}
#endif // defined(RTC_ENABLE_WIN_WGC)
return capturer;
}
} // namespace webrtc