blob: 89562758389a50f79ec44a6ffcf2385f86029ccb [file] [log] [blame]
sergeyu@chromium.org91685dc2013-10-12 22:40:051/*
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 Lemur76de83e2017-07-06 17:44:3413#include "webrtc/rtc_base/constructormagic.h"
14#include "webrtc/rtc_base/scoped_ref_ptr.h"
sergeyu@chromium.org91685dc2013-10-12 22:40:0515
16#if defined(USE_X11)
17#include "webrtc/modules/desktop_capture/x11/shared_x_display.h"
18#endif
19
jiayl@webrtc.org54ad9292014-01-29 21:59:1220#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
21#include "webrtc/modules/desktop_capture/mac/desktop_configuration_monitor.h"
jiayl@webrtc.org678f1902014-07-08 22:05:2422#include "webrtc/modules/desktop_capture/mac/full_screen_chrome_window_detector.h"
jiayl@webrtc.org54ad9292014-01-29 21:59:1223#endif
24
sergeyu@chromium.org91685dc2013-10-12 22:40:0525namespace webrtc {
26
27// An object that stores initialization parameters for screen and window
28// capturers.
29class DesktopCaptureOptions {
30 public:
sergeyu@chromium.org91685dc2013-10-12 22:40:0531 // 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
sergeyuba5fedd2016-10-26 20:15:4236 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.org91685dc2013-10-12 22:40:0544#if defined(USE_X11)
45 SharedXDisplay* x_display() const { return x_display_; }
Peter Boström623f2f02015-06-04 13:18:1746 void set_x_display(rtc::scoped_refptr<SharedXDisplay> x_display) {
sergeyu@chromium.org91685dc2013-10-12 22:40:0547 x_display_ = x_display;
48 }
49#endif
50
jiayl@webrtc.org54ad9292014-01-29 21:59:1251#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
Zijie Hec7da7982017-08-29 18:19:1352 // 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.org54ad9292014-01-29 21:59:1255 DesktopConfigurationMonitor* configuration_monitor() const {
56 return configuration_monitor_;
57 }
Zijie Hec7da7982017-08-29 18:19:1358 // If nullptr is set, ScreenCapturer won't work and WindowCapturer may return
59 // inaccurate result from IsOccluded() function.
Peter Boström623f2f02015-06-04 13:18:1760 void set_configuration_monitor(
61 rtc::scoped_refptr<DesktopConfigurationMonitor> m) {
jiayl@webrtc.org54ad9292014-01-29 21:59:1262 configuration_monitor_ = m;
63 }
jiayl@webrtc.org678f1902014-07-08 22:05:2464
Zijie Hec7da7982017-08-29 18:19:1365 // TODO(zijiehe): Instead of FullScreenChromeWindowDetector, provide a
66 // FullScreenWindowDetector for external consumers to detect the target
67 // fullscreen window.
jiayl@webrtc.org678f1902014-07-08 22:05:2468 FullScreenChromeWindowDetector* full_screen_chrome_window_detector() const {
69 return full_screen_window_detector_;
70 }
71 void set_full_screen_chrome_window_detector(
Peter Boström623f2f02015-06-04 13:18:1772 rtc::scoped_refptr<FullScreenChromeWindowDetector> detector) {
jiayl@webrtc.org678f1902014-07-08 22:05:2473 full_screen_window_detector_ = detector;
74 }
jiayl@webrtc.org54ad9292014-01-29 21:59:1275#endif
76
sergeyu@chromium.org91685dc2013-10-12 22:40:0577 // 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
zijiehe655139d2016-09-16 07:03:1591 // 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).
zijiehe655139d2016-09-16 07:03:1594 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.org6b6e3ea2014-05-05 16:08:4799#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 }
zijieheb246c4d2016-05-21 05:08:00106 // 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.org6b6e3ea2014-05-05 16:08:47114#endif
115
sergeyu@chromium.org91685dc2013-10-12 22:40:05116 private:
117#if defined(USE_X11)
Peter Boström623f2f02015-06-04 13:18:17118 rtc::scoped_refptr<SharedXDisplay> x_display_;
sergeyu@chromium.org91685dc2013-10-12 22:40:05119#endif
jiayl@webrtc.org54ad9292014-01-29 21:59:12120
121#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
Peter Boström623f2f02015-06-04 13:18:17122 rtc::scoped_refptr<DesktopConfigurationMonitor> configuration_monitor_;
123 rtc::scoped_refptr<FullScreenChromeWindowDetector>
124 full_screen_window_detector_;
jiayl@webrtc.org54ad9292014-01-29 21:59:12125#endif
jiayl@webrtc.org6b6e3ea2014-05-05 16:08:47126
127#if defined(WEBRTC_WIN)
zijieheb246c4d2016-05-21 05:08:00128 bool allow_use_magnification_api_ = false;
129 bool allow_directx_capturer_ = false;
jiayl@webrtc.org6b6e3ea2014-05-05 16:08:47130#endif
zijieheb246c4d2016-05-21 05:08:00131#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;
zijiehe655139d2016-09-16 07:03:15137 bool detect_updated_region_ = false;
sergeyu@chromium.org91685dc2013-10-12 22:40:05138};
139
140} // namespace webrtc
141
142#endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURE_OPTIONS_H_