desktop_capture_options.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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 MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURE_OPTIONS_H_
  11. #define MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURE_OPTIONS_H_
  12. #include "api/scoped_refptr.h"
  13. #include "rtc_base/system/rtc_export.h"
  14. #if defined(WEBRTC_USE_X11)
  15. #include "modules/desktop_capture/linux/shared_x_display.h"
  16. #endif
  17. #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
  18. #include "modules/desktop_capture/mac/desktop_configuration_monitor.h"
  19. #endif
  20. #include "modules/desktop_capture/full_screen_window_detector.h"
  21. namespace webrtc {
  22. // An object that stores initialization parameters for screen and window
  23. // capturers.
  24. class RTC_EXPORT DesktopCaptureOptions {
  25. public:
  26. // Returns instance of DesktopCaptureOptions with default parameters. On Linux
  27. // also initializes X window connection. x_display() will be set to null if
  28. // X11 connection failed (e.g. DISPLAY isn't set).
  29. static DesktopCaptureOptions CreateDefault();
  30. DesktopCaptureOptions();
  31. DesktopCaptureOptions(const DesktopCaptureOptions& options);
  32. DesktopCaptureOptions(DesktopCaptureOptions&& options);
  33. ~DesktopCaptureOptions();
  34. DesktopCaptureOptions& operator=(const DesktopCaptureOptions& options);
  35. DesktopCaptureOptions& operator=(DesktopCaptureOptions&& options);
  36. #if defined(WEBRTC_USE_X11)
  37. SharedXDisplay* x_display() const { return x_display_; }
  38. void set_x_display(rtc::scoped_refptr<SharedXDisplay> x_display) {
  39. x_display_ = x_display;
  40. }
  41. #endif
  42. #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
  43. // TODO(zijiehe): Remove both DesktopConfigurationMonitor and
  44. // FullScreenChromeWindowDetector out of DesktopCaptureOptions. It's not
  45. // reasonable for external consumers to set these two parameters.
  46. DesktopConfigurationMonitor* configuration_monitor() const {
  47. return configuration_monitor_;
  48. }
  49. // If nullptr is set, ScreenCapturer won't work and WindowCapturer may return
  50. // inaccurate result from IsOccluded() function.
  51. void set_configuration_monitor(
  52. rtc::scoped_refptr<DesktopConfigurationMonitor> m) {
  53. configuration_monitor_ = m;
  54. }
  55. bool allow_iosurface() const { return allow_iosurface_; }
  56. void set_allow_iosurface(bool allow) { allow_iosurface_ = allow; }
  57. #endif
  58. FullScreenWindowDetector* full_screen_window_detector() const {
  59. return full_screen_window_detector_;
  60. }
  61. void set_full_screen_window_detector(
  62. rtc::scoped_refptr<FullScreenWindowDetector> detector) {
  63. full_screen_window_detector_ = detector;
  64. }
  65. // Flag indicating that the capturer should use screen change notifications.
  66. // Enables/disables use of XDAMAGE in the X11 capturer.
  67. bool use_update_notifications() const { return use_update_notifications_; }
  68. void set_use_update_notifications(bool use_update_notifications) {
  69. use_update_notifications_ = use_update_notifications;
  70. }
  71. // Flag indicating if desktop effects (e.g. Aero) should be disabled when the
  72. // capturer is active. Currently used only on Windows.
  73. bool disable_effects() const { return disable_effects_; }
  74. void set_disable_effects(bool disable_effects) {
  75. disable_effects_ = disable_effects;
  76. }
  77. // Flag that should be set if the consumer uses updated_region() and the
  78. // capturer should try to provide correct updated_region() for the frames it
  79. // generates (e.g. by comparing each frame with the previous one).
  80. bool detect_updated_region() const { return detect_updated_region_; }
  81. void set_detect_updated_region(bool detect_updated_region) {
  82. detect_updated_region_ = detect_updated_region;
  83. }
  84. #if defined(WEBRTC_WIN)
  85. bool allow_use_magnification_api() const {
  86. return allow_use_magnification_api_;
  87. }
  88. void set_allow_use_magnification_api(bool allow) {
  89. allow_use_magnification_api_ = allow;
  90. }
  91. // Allowing directx based capturer or not, this capturer works on windows 7
  92. // with platform update / windows 8 or upper.
  93. bool allow_directx_capturer() const { return allow_directx_capturer_; }
  94. void set_allow_directx_capturer(bool enabled) {
  95. allow_directx_capturer_ = enabled;
  96. }
  97. // Flag that may be set to allow use of the cropping window capturer (which
  98. // captures the screen & crops that to the window region in some cases). An
  99. // advantage of using this is significantly higher capture frame rates than
  100. // capturing the window directly. A disadvantage of using this is the
  101. // possibility of capturing unrelated content (e.g. overlapping windows that
  102. // aren't detected properly, or neighboring regions when moving/resizing the
  103. // captured window). Note: this flag influences the behavior of calls to
  104. // DesktopCapturer::CreateWindowCapturer; calls to
  105. // CroppingWindowCapturer::CreateCapturer ignore the flag (treat it as true).
  106. bool allow_cropping_window_capturer() const {
  107. return allow_cropping_window_capturer_;
  108. }
  109. void set_allow_cropping_window_capturer(bool allow) {
  110. allow_cropping_window_capturer_ = allow;
  111. }
  112. #endif
  113. #if defined(WEBRTC_USE_PIPEWIRE)
  114. bool allow_pipewire() const { return allow_pipewire_; }
  115. void set_allow_pipewire(bool allow) { allow_pipewire_ = allow; }
  116. #endif
  117. private:
  118. #if defined(WEBRTC_USE_X11)
  119. rtc::scoped_refptr<SharedXDisplay> x_display_;
  120. #endif
  121. #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
  122. rtc::scoped_refptr<DesktopConfigurationMonitor> configuration_monitor_;
  123. bool allow_iosurface_ = false;
  124. #endif
  125. rtc::scoped_refptr<FullScreenWindowDetector> full_screen_window_detector_;
  126. #if defined(WEBRTC_WIN)
  127. bool allow_use_magnification_api_ = false;
  128. bool allow_directx_capturer_ = false;
  129. bool allow_cropping_window_capturer_ = false;
  130. #endif
  131. #if defined(WEBRTC_USE_X11)
  132. bool use_update_notifications_ = false;
  133. #else
  134. bool use_update_notifications_ = true;
  135. #endif
  136. bool disable_effects_ = true;
  137. bool detect_updated_region_ = false;
  138. #if defined(WEBRTC_USE_PIPEWIRE)
  139. bool allow_pipewire_ = false;
  140. #endif
  141. };
  142. } // namespace webrtc
  143. #endif // MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURE_OPTIONS_H_