sergeyu@chromium.org | 91685dc | 2013-10-12 22:40:05 | [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 | #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURE_OPTIONS_H_ |
| 11 | #define WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURE_OPTIONS_H_ |
| 12 | |
Edward Lemur | 76de83e | 2017-07-06 17:44:34 | [diff] [blame] | 13 | #include "webrtc/rtc_base/constructormagic.h" |
| 14 | #include "webrtc/rtc_base/scoped_ref_ptr.h" |
sergeyu@chromium.org | 91685dc | 2013-10-12 22:40:05 | [diff] [blame] | 15 | |
| 16 | #if defined(USE_X11) |
| 17 | #include "webrtc/modules/desktop_capture/x11/shared_x_display.h" |
| 18 | #endif |
| 19 | |
jiayl@webrtc.org | 54ad929 | 2014-01-29 21:59:12 | [diff] [blame] | 20 | #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) |
| 21 | #include "webrtc/modules/desktop_capture/mac/desktop_configuration_monitor.h" |
jiayl@webrtc.org | 678f190 | 2014-07-08 22:05:24 | [diff] [blame] | 22 | #include "webrtc/modules/desktop_capture/mac/full_screen_chrome_window_detector.h" |
jiayl@webrtc.org | 54ad929 | 2014-01-29 21:59:12 | [diff] [blame] | 23 | #endif |
| 24 | |
sergeyu@chromium.org | 91685dc | 2013-10-12 22:40:05 | [diff] [blame] | 25 | namespace webrtc { |
| 26 | |
| 27 | // An object that stores initialization parameters for screen and window |
| 28 | // capturers. |
| 29 | class DesktopCaptureOptions { |
| 30 | public: |
sergeyu@chromium.org | 91685dc | 2013-10-12 22:40:05 | [diff] [blame] | 31 | // 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 | |
sergeyu | ba5fedd | 2016-10-26 20:15:42 | [diff] [blame] | 36 | 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.org | 91685dc | 2013-10-12 22:40:05 | [diff] [blame] | 44 | #if defined(USE_X11) |
| 45 | SharedXDisplay* x_display() const { return x_display_; } |
Peter Boström | 623f2f0 | 2015-06-04 13:18:17 | [diff] [blame] | 46 | void set_x_display(rtc::scoped_refptr<SharedXDisplay> x_display) { |
sergeyu@chromium.org | 91685dc | 2013-10-12 22:40:05 | [diff] [blame] | 47 | x_display_ = x_display; |
| 48 | } |
| 49 | #endif |
| 50 | |
jiayl@webrtc.org | 54ad929 | 2014-01-29 21:59:12 | [diff] [blame] | 51 | #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) |
Zijie He | c7da798 | 2017-08-29 18:19:13 | [diff] [blame] | 52 | // 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.org | 54ad929 | 2014-01-29 21:59:12 | [diff] [blame] | 55 | DesktopConfigurationMonitor* configuration_monitor() const { |
| 56 | return configuration_monitor_; |
| 57 | } |
Zijie He | c7da798 | 2017-08-29 18:19:13 | [diff] [blame] | 58 | // If nullptr is set, ScreenCapturer won't work and WindowCapturer may return |
| 59 | // inaccurate result from IsOccluded() function. |
Peter Boström | 623f2f0 | 2015-06-04 13:18:17 | [diff] [blame] | 60 | void set_configuration_monitor( |
| 61 | rtc::scoped_refptr<DesktopConfigurationMonitor> m) { |
jiayl@webrtc.org | 54ad929 | 2014-01-29 21:59:12 | [diff] [blame] | 62 | configuration_monitor_ = m; |
| 63 | } |
jiayl@webrtc.org | 678f190 | 2014-07-08 22:05:24 | [diff] [blame] | 64 | |
Zijie He | c7da798 | 2017-08-29 18:19:13 | [diff] [blame] | 65 | // TODO(zijiehe): Instead of FullScreenChromeWindowDetector, provide a |
| 66 | // FullScreenWindowDetector for external consumers to detect the target |
| 67 | // fullscreen window. |
jiayl@webrtc.org | 678f190 | 2014-07-08 22:05:24 | [diff] [blame] | 68 | FullScreenChromeWindowDetector* full_screen_chrome_window_detector() const { |
| 69 | return full_screen_window_detector_; |
| 70 | } |
| 71 | void set_full_screen_chrome_window_detector( |
Peter Boström | 623f2f0 | 2015-06-04 13:18:17 | [diff] [blame] | 72 | rtc::scoped_refptr<FullScreenChromeWindowDetector> detector) { |
jiayl@webrtc.org | 678f190 | 2014-07-08 22:05:24 | [diff] [blame] | 73 | full_screen_window_detector_ = detector; |
| 74 | } |
jiayl@webrtc.org | 54ad929 | 2014-01-29 21:59:12 | [diff] [blame] | 75 | #endif |
| 76 | |
sergeyu@chromium.org | 91685dc | 2013-10-12 22:40:05 | [diff] [blame] | 77 | // 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 | |
zijiehe | 655139d | 2016-09-16 07:03:15 | [diff] [blame] | 91 | // 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). |
zijiehe | 655139d | 2016-09-16 07:03:15 | [diff] [blame] | 94 | 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.org | 6b6e3ea | 2014-05-05 16:08:47 | [diff] [blame] | 99 | #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 | } |
zijiehe | b246c4d | 2016-05-21 05:08:00 | [diff] [blame] | 106 | // 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.org | 6b6e3ea | 2014-05-05 16:08:47 | [diff] [blame] | 114 | #endif |
| 115 | |
sergeyu@chromium.org | 91685dc | 2013-10-12 22:40:05 | [diff] [blame] | 116 | private: |
| 117 | #if defined(USE_X11) |
Peter Boström | 623f2f0 | 2015-06-04 13:18:17 | [diff] [blame] | 118 | rtc::scoped_refptr<SharedXDisplay> x_display_; |
sergeyu@chromium.org | 91685dc | 2013-10-12 22:40:05 | [diff] [blame] | 119 | #endif |
jiayl@webrtc.org | 54ad929 | 2014-01-29 21:59:12 | [diff] [blame] | 120 | |
| 121 | #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) |
Peter Boström | 623f2f0 | 2015-06-04 13:18:17 | [diff] [blame] | 122 | rtc::scoped_refptr<DesktopConfigurationMonitor> configuration_monitor_; |
| 123 | rtc::scoped_refptr<FullScreenChromeWindowDetector> |
| 124 | full_screen_window_detector_; |
jiayl@webrtc.org | 54ad929 | 2014-01-29 21:59:12 | [diff] [blame] | 125 | #endif |
jiayl@webrtc.org | 6b6e3ea | 2014-05-05 16:08:47 | [diff] [blame] | 126 | |
| 127 | #if defined(WEBRTC_WIN) |
zijiehe | b246c4d | 2016-05-21 05:08:00 | [diff] [blame] | 128 | bool allow_use_magnification_api_ = false; |
| 129 | bool allow_directx_capturer_ = false; |
jiayl@webrtc.org | 6b6e3ea | 2014-05-05 16:08:47 | [diff] [blame] | 130 | #endif |
zijiehe | b246c4d | 2016-05-21 05:08:00 | [diff] [blame] | 131 | #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; |
zijiehe | 655139d | 2016-09-16 07:03:15 | [diff] [blame] | 137 | bool detect_updated_region_ = false; |
sergeyu@chromium.org | 91685dc | 2013-10-12 22:40:05 | [diff] [blame] | 138 | }; |
| 139 | |
| 140 | } // namespace webrtc |
| 141 | |
| 142 | #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURE_OPTIONS_H_ |