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/blank_detector_desktop_capturer_wrapper.h" 15 #include "modules/desktop_capture/desktop_capture_options.h" 16 #include "modules/desktop_capture/desktop_capturer.h" 17 #include "modules/desktop_capture/fallback_desktop_capturer_wrapper.h" 18 #include "modules/desktop_capture/rgba_color.h" 19 #include "modules/desktop_capture/win/screen_capturer_win_directx.h" 20 #include "modules/desktop_capture/win/screen_capturer_win_gdi.h" 21 #include "modules/desktop_capture/win/screen_capturer_win_magnifier.h" 22 23 namespace webrtc { 24 25 namespace { 26 CreateScreenCapturerWinDirectx()27std::unique_ptr<DesktopCapturer> CreateScreenCapturerWinDirectx() { 28 std::unique_ptr<DesktopCapturer> capturer(new ScreenCapturerWinDirectx()); 29 capturer.reset(new BlankDetectorDesktopCapturerWrapper( 30 std::move(capturer), RgbaColor(0, 0, 0, 0))); 31 return capturer; 32 } 33 34 } // namespace 35 36 // static CreateRawScreenCapturer(const DesktopCaptureOptions & options)37std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer( 38 const DesktopCaptureOptions& options) { 39 std::unique_ptr<DesktopCapturer> capturer(new ScreenCapturerWinGdi(options)); 40 if (options.allow_directx_capturer()) { 41 // `dxgi_duplicator_controller` should be alive in this scope to ensure it 42 // won't unload DxgiDuplicatorController. 43 auto dxgi_duplicator_controller = DxgiDuplicatorController::Instance(); 44 if (ScreenCapturerWinDirectx::IsSupported()) { 45 capturer.reset(new FallbackDesktopCapturerWrapper( 46 CreateScreenCapturerWinDirectx(), std::move(capturer))); 47 } 48 } 49 50 if (options.allow_use_magnification_api()) { 51 // ScreenCapturerWinMagnifier cannot work on Windows XP or earlier, as well 52 // as 64-bit only Windows, and it may randomly crash on multi-screen 53 // systems. So we may need to fallback to use original capturer. 54 capturer.reset(new FallbackDesktopCapturerWrapper( 55 std::unique_ptr<DesktopCapturer>(new ScreenCapturerWinMagnifier()), 56 std::move(capturer))); 57 } 58 59 return capturer; 60 } 61 62 } // namespace webrtc 63