diff --git a/modules/desktop_capture/desktop_capture_options.h b/modules/desktop_capture/desktop_capture_options.h index 521c80b5c5..4cb19a56d6 100644 --- a/modules/desktop_capture/desktop_capture_options.h +++ b/modules/desktop_capture/desktop_capture_options.h @@ -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; diff --git a/modules/desktop_capture/desktop_capturer.cc b/modules/desktop_capture/desktop_capturer.cc index 8d8bdd5835..735aa4d530 100644 --- a/modules/desktop_capture/desktop_capturer.cc +++ b/modules/desktop_capture/desktop_capturer.cc @@ -54,10 +54,8 @@ bool DesktopCapturer::IsOccluded(const DesktopVector& pos) { std::unique_ptr 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::CreateWindowCapturer( std::unique_ptr 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) diff --git a/modules/desktop_capture/win/wgc_capture_source.cc b/modules/desktop_capture/win/wgc_capture_source.cc index 93c49f5090..9786ca67b5 100644 --- a/modules/desktop_capture/win/wgc_capture_source.cc +++ b/modules/desktop_capture/win/wgc_capture_source.cc @@ -135,7 +135,7 @@ DesktopVector WgcScreenSource::GetTopLeft() { if (!hmonitor_) return DesktopVector(); - return GetMonitorRect(*hmonitor_)->top_left(); + return GetMonitorRect(*hmonitor_).top_left(); } bool WgcScreenSource::IsCapturable() {