window_capturer_win.cc (2448B)
1 /* 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #include <memory> 12 #include <utility> 13 14 #include "modules/desktop_capture/desktop_capture_options.h" 15 #include "modules/desktop_capture/desktop_capturer.h" 16 #include "modules/desktop_capture/rgba_color.h" 17 #include "modules/desktop_capture/win/window_capturer_win_gdi.h" 18 #include "rtc_base/logging.h" 19 20 #if defined(RTC_ENABLE_WIN_WGC) 21 #include "modules/desktop_capture/blank_detector_desktop_capturer_wrapper.h" 22 #include "modules/desktop_capture/fallback_desktop_capturer_wrapper.h" 23 #include "modules/desktop_capture/win/wgc_capturer_win.h" 24 #include "rtc_base/win/windows_version.h" 25 #endif // defined(RTC_ENABLE_WIN_WGC) 26 27 namespace webrtc { 28 29 // static 30 std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawWindowCapturer( 31 const DesktopCaptureOptions& options) { 32 RTC_LOG(LS_INFO) << "video capture: DesktopCapturer::CreateRawWindowCapturer " 33 "creates DesktopCapturer of type WindowCapturerWinGdi"; 34 std::unique_ptr<DesktopCapturer> capturer( 35 WindowCapturerWinGdi::CreateRawWindowCapturer(options)); 36 #if defined(RTC_ENABLE_WIN_WGC) 37 if (options.allow_wgc_capturer_fallback() && 38 rtc_win::GetVersion() >= rtc_win::Version::VERSION_WIN11) { 39 // BlankDectector capturer will send an error when it detects a failed 40 // GDI rendering, then Fallback capturer will try to capture it again with 41 // WGC. 42 RTC_LOG(LS_INFO) 43 << "video capture: DesktopCapturer::CreateRawWindowCapturer creates " 44 "DesktopCapturer of type FallbackDesktopCapturerWrapper which has a " 45 "fallback capturer of type WgcCapturerWin"; 46 capturer = std::make_unique<BlankDetectorDesktopCapturerWrapper>( 47 std::move(capturer), RgbaColor(0, 0, 0, 0), 48 /*check_per_capture*/ true); 49 50 capturer = std::make_unique<FallbackDesktopCapturerWrapper>( 51 std::move(capturer), 52 WgcCapturerWin::CreateRawWindowCapturer( 53 options, /*allow_delayed_capturable_check*/ true)); 54 } 55 #endif // defined(RTC_ENABLE_WIN_WGC) 56 return capturer; 57 } 58 59 } // namespace webrtc