OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 #include <utility> | 12 #include <utility> |
13 | 13 |
14 #include "webrtc/modules/desktop_capture/blank_detector_desktop_capturer_wrapper
.h" | 14 #include "webrtc/modules/desktop_capture/blank_detector_desktop_capturer_wrapper
.h" |
15 #include "webrtc/modules/desktop_capture/desktop_capturer.h" | 15 #include "webrtc/modules/desktop_capture/desktop_capturer.h" |
16 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" | 16 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" |
17 #include "webrtc/modules/desktop_capture/fallback_desktop_capturer_wrapper.h" | 17 #include "webrtc/modules/desktop_capture/fallback_desktop_capturer_wrapper.h" |
18 #include "webrtc/modules/desktop_capture/rgba_color.h" | 18 #include "webrtc/modules/desktop_capture/rgba_color.h" |
19 #include "webrtc/modules/desktop_capture/win/screen_capturer_win_directx.h" | 19 #include "webrtc/modules/desktop_capture/win/screen_capturer_win_directx.h" |
20 #include "webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.h" | 20 #include "webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.h" |
21 #include "webrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.h" | 21 #include "webrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.h" |
22 | 22 |
23 namespace webrtc { | 23 namespace webrtc { |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 std::unique_ptr<DesktopCapturer> CreateScreenCapturerWinDirectx( | 27 std::unique_ptr<DesktopCapturer> CreateScreenCapturerWinDirectx() { |
28 const DesktopCaptureOptions& options) { | |
29 std::unique_ptr<DesktopCapturer> capturer( | 28 std::unique_ptr<DesktopCapturer> capturer( |
30 new ScreenCapturerWinDirectx(options)); | 29 new ScreenCapturerWinDirectx()); |
31 capturer.reset(new BlankDetectorDesktopCapturerWrapper( | 30 capturer.reset(new BlankDetectorDesktopCapturerWrapper( |
32 std::move(capturer), RgbaColor(0, 0, 0, 0))); | 31 std::move(capturer), RgbaColor(0, 0, 0, 0))); |
33 return capturer; | 32 return capturer; |
34 } | 33 } |
35 | 34 |
36 } // namespace | 35 } // namespace |
37 | 36 |
38 // static | 37 // static |
39 std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer( | 38 std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer( |
40 const DesktopCaptureOptions& options) { | 39 const DesktopCaptureOptions& options) { |
41 std::unique_ptr<DesktopCapturer> capturer(new ScreenCapturerWinGdi(options)); | 40 std::unique_ptr<DesktopCapturer> capturer(new ScreenCapturerWinGdi(options)); |
42 if (options.allow_directx_capturer() && | 41 if (options.allow_directx_capturer()) { |
43 ScreenCapturerWinDirectx::IsSupported()) { | 42 // |dxgi_duplicator_controller| should be alive in this scope to ensure it |
44 capturer.reset(new FallbackDesktopCapturerWrapper( | 43 // won't unload DxgiDuplicatorController. |
45 CreateScreenCapturerWinDirectx(options), std::move(capturer))); | 44 auto dxgi_duplicator_controller = DxgiDuplicatorController::Instance(); |
| 45 if (ScreenCapturerWinDirectx::IsSupported()) { |
| 46 capturer.reset(new FallbackDesktopCapturerWrapper( |
| 47 CreateScreenCapturerWinDirectx(), std::move(capturer))); |
| 48 } |
46 } | 49 } |
47 | 50 |
48 if (options.allow_use_magnification_api()) { | 51 if (options.allow_use_magnification_api()) { |
49 // ScreenCapturerWinMagnifier cannot work on Windows XP or earlier, as well | 52 // ScreenCapturerWinMagnifier cannot work on Windows XP or earlier, as well |
50 // as 64-bit only Windows, and it may randomly crash on multi-screen | 53 // as 64-bit only Windows, and it may randomly crash on multi-screen |
51 // systems. So we may need to fallback to use original capturer. | 54 // systems. So we may need to fallback to use original capturer. |
52 capturer.reset(new FallbackDesktopCapturerWrapper( | 55 capturer.reset(new FallbackDesktopCapturerWrapper( |
53 std::unique_ptr<DesktopCapturer>(new ScreenCapturerWinMagnifier()), | 56 std::unique_ptr<DesktopCapturer>(new ScreenCapturerWinMagnifier()), |
54 std::move(capturer))); | 57 std::move(capturer))); |
55 } | 58 } |
56 | 59 |
57 return capturer; | 60 return capturer; |
58 } | 61 } |
59 | 62 |
60 } // namespace webrtc | 63 } // namespace webrtc |
OLD | NEW |