blob: 89562758389a50f79ec44a6ffcf2385f86029ccb [file] [log] [blame]
sergeyu@chromium.org894e6fe2013-10-12 22:40:05 +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#ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURE_OPTIONS_H_
11#define WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURE_OPTIONS_H_
12
Edward Lemurc20978e2017-07-06 19:44:34 +020013#include "webrtc/rtc_base/constructormagic.h"
14#include "webrtc/rtc_base/scoped_ref_ptr.h"
sergeyu@chromium.org894e6fe2013-10-12 22:40:05 +000015
16#if defined(USE_X11)
17#include "webrtc/modules/desktop_capture/x11/shared_x_display.h"
18#endif
19
jiayl@webrtc.orgcf1b51b2014-01-29 21:59:12 +000020#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
21#include "webrtc/modules/desktop_capture/mac/desktop_configuration_monitor.h"
jiayl@webrtc.org12b4efe2014-07-08 22:05:24 +000022#include "webrtc/modules/desktop_capture/mac/full_screen_chrome_window_detector.h"
jiayl@webrtc.orgcf1b51b2014-01-29 21:59:12 +000023#endif
24
sergeyu@chromium.org894e6fe2013-10-12 22:40:05 +000025namespace webrtc {
26
27// An object that stores initialization parameters for screen and window
28// capturers.
29class DesktopCaptureOptions {
30 public:
sergeyu@chromium.org894e6fe2013-10-12 22:40:05 +000031 // Returns instance of DesktopCaptureOptions with default parameters. On Linux
32 // also initializes X window connection. x_display() will be set to null if
33 // X11 connection failed (e.g. DISPLAY isn't set).
34 static DesktopCaptureOptions CreateDefault();
35
sergeyue1831212016-10-26 13:15:42 -070036 DesktopCaptureOptions();
37 DesktopCaptureOptions(const DesktopCaptureOptions& options);
38 DesktopCaptureOptions(DesktopCaptureOptions&& options);
39 ~DesktopCaptureOptions();
40
41 DesktopCaptureOptions& operator=(const DesktopCaptureOptions& options);
42 DesktopCaptureOptions& operator=(DesktopCaptureOptions&& options);
43
sergeyu@chromium.org894e6fe2013-10-12 22:40:05 +000044#if defined(USE_X11)
45 SharedXDisplay* x_display() const { return x_display_; }
Peter Boström26b08602015-06-04 15:18:17 +020046 void set_x_display(rtc::scoped_refptr<SharedXDisplay> x_display) {
sergeyu@chromium.org894e6fe2013-10-12 22:40:05 +000047 x_display_ = x_display;
48 }
49#endif
50
jiayl@webrtc.orgcf1b51b2014-01-29 21:59:12 +000051#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
Zijie He12827112017-08-29 11:19:13 -070052 // TODO(zijiehe): Remove both DesktopConfigurationMonitor and
53 // FullScreenChromeWindowDetector out of DesktopCaptureOptions. It's not
54 // reasonable for external consumers to set these two parameters.
jiayl@webrtc.orgcf1b51b2014-01-29 21:59:12 +000055 DesktopConfigurationMonitor* configuration_monitor() const {
56 return configuration_monitor_;
57 }
Zijie He12827112017-08-29 11:19:13 -070058 // If nullptr is set, ScreenCapturer won't work and WindowCapturer may return
59 // inaccurate result from IsOccluded() function.
Peter Boström26b08602015-06-04 15:18:17 +020060 void set_configuration_monitor(
61 rtc::scoped_refptr<DesktopConfigurationMonitor> m) {
jiayl@webrtc.orgcf1b51b2014-01-29 21:59:12 +000062 configuration_monitor_ = m;
63 }
jiayl@webrtc.org12b4efe2014-07-08 22:05:24 +000064
Zijie He12827112017-08-29 11:19:13 -070065 // TODO(zijiehe): Instead of FullScreenChromeWindowDetector, provide a
66 // FullScreenWindowDetector for external consumers to detect the target
67 // fullscreen window.
jiayl@webrtc.org12b4efe2014-07-08 22:05:24 +000068 FullScreenChromeWindowDetector* full_screen_chrome_window_detector() const {
69 return full_screen_window_detector_;
70 }
71 void set_full_screen_chrome_window_detector(
Peter Boström26b08602015-06-04 15:18:17 +020072 rtc::scoped_refptr<FullScreenChromeWindowDetector> detector) {
jiayl@webrtc.org12b4efe2014-07-08 22:05:24 +000073 full_screen_window_detector_ = detector;
74 }
jiayl@webrtc.orgcf1b51b2014-01-29 21:59:12 +000075#endif
76
sergeyu@chromium.org894e6fe2013-10-12 22:40:05 +000077 // Flag indicating that the capturer should use screen change notifications.
78 // Enables/disables use of XDAMAGE in the X11 capturer.
79 bool use_update_notifications() const { return use_update_notifications_; }
80 void set_use_update_notifications(bool use_update_notifications) {
81 use_update_notifications_ = use_update_notifications;
82 }
83
84 // Flag indicating if desktop effects (e.g. Aero) should be disabled when the
85 // capturer is active. Currently used only on Windows.
86 bool disable_effects() const { return disable_effects_; }
87 void set_disable_effects(bool disable_effects) {
88 disable_effects_ = disable_effects;
89 }
90
zijiehee9a3c7f2016-09-16 00:03:15 -070091 // Flag that should be set if the consumer uses updated_region() and the
92 // capturer should try to provide correct updated_region() for the frames it
93 // generates (e.g. by comparing each frame with the previous one).
zijiehee9a3c7f2016-09-16 00:03:15 -070094 bool detect_updated_region() const { return detect_updated_region_; }
95 void set_detect_updated_region(bool detect_updated_region) {
96 detect_updated_region_ = detect_updated_region;
97 }
98
jiayl@webrtc.org42204342014-05-05 16:08:47 +000099#if defined(WEBRTC_WIN)
100 bool allow_use_magnification_api() const {
101 return allow_use_magnification_api_;
102 }
103 void set_allow_use_magnification_api(bool allow) {
104 allow_use_magnification_api_ = allow;
105 }
zijiehe2970c2a2016-05-20 22:08:00 -0700106 // Allowing directx based capturer or not, this capturer works on windows 7
107 // with platform update / windows 8 or upper.
108 bool allow_directx_capturer() const {
109 return allow_directx_capturer_;
110 }
111 void set_allow_directx_capturer(bool enabled) {
112 allow_directx_capturer_ = enabled;
113 }
jiayl@webrtc.org42204342014-05-05 16:08:47 +0000114#endif
115
sergeyu@chromium.org894e6fe2013-10-12 22:40:05 +0000116 private:
117#if defined(USE_X11)
Peter Boström26b08602015-06-04 15:18:17 +0200118 rtc::scoped_refptr<SharedXDisplay> x_display_;
sergeyu@chromium.org894e6fe2013-10-12 22:40:05 +0000119#endif
jiayl@webrtc.orgcf1b51b2014-01-29 21:59:12 +0000120
121#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
Peter Boström26b08602015-06-04 15:18:17 +0200122 rtc::scoped_refptr<DesktopConfigurationMonitor> configuration_monitor_;
123 rtc::scoped_refptr<FullScreenChromeWindowDetector>
124 full_screen_window_detector_;
jiayl@webrtc.orgcf1b51b2014-01-29 21:59:12 +0000125#endif
jiayl@webrtc.org42204342014-05-05 16:08:47 +0000126
127#if defined(WEBRTC_WIN)
zijiehe2970c2a2016-05-20 22:08:00 -0700128 bool allow_use_magnification_api_ = false;
129 bool allow_directx_capturer_ = false;
jiayl@webrtc.org42204342014-05-05 16:08:47 +0000130#endif
zijiehe2970c2a2016-05-20 22:08:00 -0700131#if defined(USE_X11)
132 bool use_update_notifications_ = false;
133#else
134 bool use_update_notifications_ = true;
135#endif
136 bool disable_effects_ = true;
zijiehee9a3c7f2016-09-16 00:03:15 -0700137 bool detect_updated_region_ = false;
sergeyu@chromium.org894e6fe2013-10-12 22:40:05 +0000138};
139
140} // namespace webrtc
141
142#endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURE_OPTIONS_H_