sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 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 | |
kwiberg | 2bb3afa | 2016-03-16 15:58:08 -0700 | [diff] [blame] | 11 | #include <memory> |
kwiberg | 0eb15ed | 2015-12-17 03:04:15 -0800 | [diff] [blame] | 12 | #include <utility> |
| 13 | |
zijiehe | ccf57a7 | 2017-03-03 14:40:15 -0800 | [diff] [blame] | 14 | #include "webrtc/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.h" |
zijiehe | 98903d2 | 2016-11-10 21:57:10 -0800 | [diff] [blame] | 15 | #include "webrtc/modules/desktop_capture/desktop_capturer.h" |
sergeyu@chromium.org | 894e6fe | 2013-10-12 22:40:05 +0000 | [diff] [blame] | 16 | #include "webrtc/modules/desktop_capture/desktop_capture_options.h" |
zijiehe | 3fa87f7 | 2017-02-22 13:47:00 -0800 | [diff] [blame] | 17 | #include "webrtc/modules/desktop_capture/fallback_desktop_capturer_wrapper.h" |
zijiehe | ccf57a7 | 2017-03-03 14:40:15 -0800 | [diff] [blame] | 18 | #include "webrtc/modules/desktop_capture/rgba_color.h" |
zijiehe | 2970c2a | 2016-05-20 22:08:00 -0700 | [diff] [blame] | 19 | #include "webrtc/modules/desktop_capture/win/screen_capturer_win_directx.h" |
jiayl@webrtc.org | 4220434 | 2014-05-05 16:08:47 +0000 | [diff] [blame] | 20 | #include "webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.h" |
| 21 | #include "webrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.h" |
sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 22 | |
| 23 | namespace webrtc { |
| 24 | |
zijiehe | ccf57a7 | 2017-03-03 14:40:15 -0800 | [diff] [blame] | 25 | namespace { |
| 26 | |
zijiehe | 6dd77c4 | 2017-06-19 13:59:42 -0700 | [diff] [blame] | 27 | std::unique_ptr<DesktopCapturer> CreateScreenCapturerWinDirectx() { |
zijiehe | ccf57a7 | 2017-03-03 14:40:15 -0800 | [diff] [blame] | 28 | std::unique_ptr<DesktopCapturer> capturer( |
zijiehe | 6dd77c4 | 2017-06-19 13:59:42 -0700 | [diff] [blame] | 29 | new ScreenCapturerWinDirectx()); |
zijiehe | ccf57a7 | 2017-03-03 14:40:15 -0800 | [diff] [blame] | 30 | capturer.reset(new BlankDetectorDesktopCapturerWrapper( |
| 31 | std::move(capturer), RgbaColor(0, 0, 0, 0))); |
| 32 | return capturer; |
| 33 | } |
| 34 | |
| 35 | } // namespace |
| 36 | |
sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 37 | // static |
zijiehe | 54fd579 | 2016-11-02 14:49:35 -0700 | [diff] [blame] | 38 | std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer( |
| 39 | const DesktopCaptureOptions& options) { |
zijiehe | ccf57a7 | 2017-03-03 14:40:15 -0800 | [diff] [blame] | 40 | std::unique_ptr<DesktopCapturer> capturer(new ScreenCapturerWinGdi(options)); |
zijiehe | 6dd77c4 | 2017-06-19 13:59:42 -0700 | [diff] [blame] | 41 | if (options.allow_directx_capturer()) { |
| 42 | // |dxgi_duplicator_controller| should be alive in this scope to ensure it |
| 43 | // won't unload DxgiDuplicatorController. |
| 44 | auto dxgi_duplicator_controller = DxgiDuplicatorController::Instance(); |
| 45 | if (ScreenCapturerWinDirectx::IsSupported()) { |
| 46 | capturer.reset(new FallbackDesktopCapturerWrapper( |
| 47 | CreateScreenCapturerWinDirectx(), std::move(capturer))); |
| 48 | } |
zijiehe | 54fd579 | 2016-11-02 14:49:35 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | if (options.allow_use_magnification_api()) { |
zijiehe | 3fa87f7 | 2017-02-22 13:47:00 -0800 | [diff] [blame] | 52 | // ScreenCapturerWinMagnifier cannot work on Windows XP or earlier, as well |
| 53 | // as 64-bit only Windows, and it may randomly crash on multi-screen |
| 54 | // systems. So we may need to fallback to use original capturer. |
| 55 | capturer.reset(new FallbackDesktopCapturerWrapper( |
| 56 | std::unique_ptr<DesktopCapturer>(new ScreenCapturerWinMagnifier()), |
| 57 | std::move(capturer))); |
zijiehe | 54fd579 | 2016-11-02 14:49:35 -0700 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | return capturer; |
| 61 | } |
| 62 | |
sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 63 | } // namespace webrtc |