blob: 9e74aabca6640c851be4977ba590feb21644f0f0 [file] [log] [blame]
sergeyu@chromium.org3d34f662013-06-04 18:51:23 +00001/*
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
kwiberg2bb3afa2016-03-16 15:58:08 -070011#include <memory>
kwiberg0eb15ed2015-12-17 03:04:15 -080012#include <utility>
13
zijieheccf57a72017-03-03 14:40:15 -080014#include "webrtc/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.h"
zijiehe98903d22016-11-10 21:57:10 -080015#include "webrtc/modules/desktop_capture/desktop_capturer.h"
sergeyu@chromium.org894e6fe2013-10-12 22:40:05 +000016#include "webrtc/modules/desktop_capture/desktop_capture_options.h"
zijiehe3fa87f72017-02-22 13:47:00 -080017#include "webrtc/modules/desktop_capture/fallback_desktop_capturer_wrapper.h"
zijieheccf57a72017-03-03 14:40:15 -080018#include "webrtc/modules/desktop_capture/rgba_color.h"
zijiehe2970c2a2016-05-20 22:08:00 -070019#include "webrtc/modules/desktop_capture/win/screen_capturer_win_directx.h"
jiayl@webrtc.org42204342014-05-05 16:08:47 +000020#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.org3d34f662013-06-04 18:51:23 +000022
23namespace webrtc {
24
zijieheccf57a72017-03-03 14:40:15 -080025namespace {
26
zijiehe6dd77c42017-06-19 13:59:42 -070027std::unique_ptr<DesktopCapturer> CreateScreenCapturerWinDirectx() {
zijieheccf57a72017-03-03 14:40:15 -080028 std::unique_ptr<DesktopCapturer> capturer(
zijiehe6dd77c42017-06-19 13:59:42 -070029 new ScreenCapturerWinDirectx());
zijieheccf57a72017-03-03 14:40:15 -080030 capturer.reset(new BlankDetectorDesktopCapturerWrapper(
31 std::move(capturer), RgbaColor(0, 0, 0, 0)));
32 return capturer;
33}
34
35} // namespace
36
sergeyu@chromium.org3d34f662013-06-04 18:51:23 +000037// static
zijiehe54fd5792016-11-02 14:49:35 -070038std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer(
39 const DesktopCaptureOptions& options) {
zijieheccf57a72017-03-03 14:40:15 -080040 std::unique_ptr<DesktopCapturer> capturer(new ScreenCapturerWinGdi(options));
zijiehe6dd77c42017-06-19 13:59:42 -070041 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 }
zijiehe54fd5792016-11-02 14:49:35 -070049 }
50
51 if (options.allow_use_magnification_api()) {
zijiehe3fa87f72017-02-22 13:47:00 -080052 // 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)));
zijiehe54fd5792016-11-02 14:49:35 -070058 }
59
60 return capturer;
61}
62
sergeyu@chromium.org3d34f662013-06-04 18:51:23 +000063} // namespace webrtc