Add DesktopCaptureOptions to allow WGC capturer.

This changes add two new options to the DesktopCaptureOptions class so
consumers can opt in to using the WGC capturer. The capturer is still
behind the RTC_ENABLE_WIN_WGC build flag which is off by default, so
these options will have no affect until that flag is enabled.

Bug: webrtc:11760
Change-Id: Ib7166f3bb335f29aeff8cb5d2bebea2c06c14d4c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215243
Commit-Queue: Austin Orion <auorion@microsoft.com>
Reviewed-by: Jamie Walch <jamiewalch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#33837}
This commit is contained in:
Austin Orion 2021-04-23 14:07:51 -07:00 committed by Commit Bot
parent af366443b7
commit 0548d18510
3 changed files with 21 additions and 10 deletions

View File

@ -126,7 +126,19 @@ class RTC_EXPORT DesktopCaptureOptions {
void set_allow_cropping_window_capturer(bool allow) {
allow_cropping_window_capturer_ = allow;
}
#endif
#if defined(RTC_ENABLE_WIN_WGC)
// This flag enables the WGC capturer for both window and screen capture.
// This capturer should offer similar or better performance than the cropping
// capturer without the disadvantages listed above. However, the WGC capturer
// is only available on Windows 10 version 1809 (Redstone 5) and up. This flag
// will have no affect on older versions.
// If set, and running a supported version of Win10, this flag will take
// precedence over the cropping, directx, and magnification flags.
bool allow_wgc_capturer() const { return allow_wgc_capturer_; }
void set_allow_wgc_capturer(bool allow) { allow_wgc_capturer_ = allow; }
#endif // defined(RTC_ENABLE_WIN_WGC)
#endif // defined(WEBRTC_WIN)
#if defined(WEBRTC_USE_PIPEWIRE)
bool allow_pipewire() const { return allow_pipewire_; }
@ -149,6 +161,9 @@ class RTC_EXPORT DesktopCaptureOptions {
bool allow_use_magnification_api_ = false;
bool allow_directx_capturer_ = false;
bool allow_cropping_window_capturer_ = false;
#if defined(RTC_ENABLE_WIN_WGC)
bool allow_wgc_capturer_ = false;
#endif
#endif
#if defined(WEBRTC_USE_X11)
bool use_update_notifications_ = false;

View File

@ -54,10 +54,8 @@ bool DesktopCapturer::IsOccluded(const DesktopVector& pos) {
std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateWindowCapturer(
const DesktopCaptureOptions& options) {
#if defined(RTC_ENABLE_WIN_WGC)
// TODO(bugs.webrtc.org/11760): Add a WebRTC field trial (or similar
// mechanism) check here that leads to use of the WGC capturer once it is
// fully implemented.
if (rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_WIN10_RS5) {
if (options.allow_wgc_capturer() &&
rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_WIN10_RS5) {
return WgcCapturerWin::CreateRawWindowCapturer(options);
}
#endif // defined(RTC_ENABLE_WIN_WGC)
@ -80,10 +78,8 @@ std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateWindowCapturer(
std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateScreenCapturer(
const DesktopCaptureOptions& options) {
#if defined(RTC_ENABLE_WIN_WGC)
// TODO(bugs.webrtc.org/11760): Add a WebRTC field trial (or similar
// mechanism) check here that leads to use of the WGC capturer once it is
// fully implemented.
if (rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_WIN10_RS5) {
if (options.allow_wgc_capturer() &&
rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_WIN10_RS5) {
return WgcCapturerWin::CreateRawScreenCapturer(options);
}
#endif // defined(RTC_ENABLE_WIN_WGC)

View File

@ -135,7 +135,7 @@ DesktopVector WgcScreenSource::GetTopLeft() {
if (!hmonitor_)
return DesktopVector();
return GetMonitorRect(*hmonitor_)->top_left();
return GetMonitorRect(*hmonitor_).top_left();
}
bool WgcScreenSource::IsCapturable() {