diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn index 789aac44e3..1cac9420bf 100644 --- a/modules/desktop_capture/BUILD.gn +++ b/modules/desktop_capture/BUILD.gn @@ -13,6 +13,12 @@ import("../../webrtc.gni") use_desktop_capture_differ_sse2 = current_cpu == "x86" || current_cpu == "x64" +config("x11_config") { + if (rtc_use_x11_extensions) { + defines = [ "WEBRTC_USE_X11" ] + } +} + rtc_library("primitives") { visibility = [ "*" ] sources = [ @@ -44,6 +50,7 @@ if (rtc_include_tests) { rtc_library("desktop_capture_modules_tests") { testonly = true + defines = [] sources = [] deps = [ "../../api:function_view", @@ -67,12 +74,14 @@ if (rtc_include_tests) { "screen_drawer_unittest.cc", "window_finder_unittest.cc", ] + public_configs = [ ":x11_config" ] } } rtc_library("desktop_capture_unittests") { testonly = true + defines = [] sources = [ "blank_detector_desktop_capturer_wrapper_unittest.cc", "cropped_desktop_frame_unittest.cc", @@ -116,6 +125,7 @@ if (rtc_include_tests) { "window_capturer_unittest.cc", ] deps += [ ":desktop_capture_mock" ] + public_configs = [ ":x11_config" ] } } @@ -267,6 +277,8 @@ if (is_mac) { } rtc_library("desktop_capture_generic") { + defines = [] + public_configs = [ ":x11_config" ] visibility = [ ":desktop_capture", ":desktop_capture_objc", diff --git a/modules/desktop_capture/desktop_capture_options.cc b/modules/desktop_capture/desktop_capture_options.cc index ee1e4775cc..c89896d5fd 100644 --- a/modules/desktop_capture/desktop_capture_options.cc +++ b/modules/desktop_capture/desktop_capture_options.cc @@ -32,7 +32,7 @@ DesktopCaptureOptions& DesktopCaptureOptions::operator=( // static DesktopCaptureOptions DesktopCaptureOptions::CreateDefault() { DesktopCaptureOptions result; -#if defined(USE_X11) +#if defined(WEBRTC_USE_X11) result.set_x_display(SharedXDisplay::CreateDefault()); #endif #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) diff --git a/modules/desktop_capture/desktop_capture_options.h b/modules/desktop_capture/desktop_capture_options.h index d7dac1f0eb..521c80b5c5 100644 --- a/modules/desktop_capture/desktop_capture_options.h +++ b/modules/desktop_capture/desktop_capture_options.h @@ -13,7 +13,7 @@ #include "api/scoped_refptr.h" #include "rtc_base/system/rtc_export.h" -#if defined(USE_X11) +#if defined(WEBRTC_USE_X11) #include "modules/desktop_capture/linux/shared_x_display.h" #endif @@ -42,7 +42,7 @@ class RTC_EXPORT DesktopCaptureOptions { DesktopCaptureOptions& operator=(const DesktopCaptureOptions& options); DesktopCaptureOptions& operator=(DesktopCaptureOptions&& options); -#if defined(USE_X11) +#if defined(WEBRTC_USE_X11) SharedXDisplay* x_display() const { return x_display_; } void set_x_display(rtc::scoped_refptr x_display) { x_display_ = x_display; @@ -134,7 +134,7 @@ class RTC_EXPORT DesktopCaptureOptions { #endif private: -#if defined(USE_X11) +#if defined(WEBRTC_USE_X11) rtc::scoped_refptr x_display_; #endif @@ -150,7 +150,7 @@ class RTC_EXPORT DesktopCaptureOptions { bool allow_directx_capturer_ = false; bool allow_cropping_window_capturer_ = false; #endif -#if defined(USE_X11) +#if defined(WEBRTC_USE_X11) bool use_update_notifications_ = false; #else bool use_update_notifications_ = true; diff --git a/modules/desktop_capture/desktop_capturer.cc b/modules/desktop_capture/desktop_capturer.cc index df625e955a..61926a6023 100644 --- a/modules/desktop_capture/desktop_capturer.cc +++ b/modules/desktop_capture/desktop_capturer.cc @@ -73,7 +73,7 @@ std::unique_ptr DesktopCapturer::CreateScreenCapturer( return capturer; } -#if defined(WEBRTC_USE_PIPEWIRE) || defined(USE_X11) +#if defined(WEBRTC_USE_PIPEWIRE) || defined(WEBRTC_USE_X11) bool DesktopCapturer::IsRunningUnderWayland() { const char* xdg_session_type = getenv("XDG_SESSION_TYPE"); if (!xdg_session_type || strncmp(xdg_session_type, "wayland", 7) != 0) @@ -84,6 +84,6 @@ bool DesktopCapturer::IsRunningUnderWayland() { return true; } -#endif // defined(WEBRTC_USE_PIPEWIRE) || defined(USE_X11) +#endif // defined(WEBRTC_USE_PIPEWIRE) || defined(WEBRTC_USE_X11) } // namespace webrtc diff --git a/modules/desktop_capture/desktop_capturer.h b/modules/desktop_capture/desktop_capturer.h index f9dacc1f7a..64339c0ca6 100644 --- a/modules/desktop_capture/desktop_capturer.h +++ b/modules/desktop_capture/desktop_capturer.h @@ -135,9 +135,9 @@ class RTC_EXPORT DesktopCapturer { static std::unique_ptr CreateScreenCapturer( const DesktopCaptureOptions& options); -#if defined(WEBRTC_USE_PIPEWIRE) || defined(USE_X11) +#if defined(WEBRTC_USE_PIPEWIRE) || defined(WEBRTC_USE_X11) static bool IsRunningUnderWayland(); -#endif // defined(WEBRTC_USE_PIPEWIRE) || defined(USE_X11) +#endif // defined(WEBRTC_USE_PIPEWIRE) || defined(WEBRTC_USE_X11) protected: // CroppingWindowCapturer needs to create raw capturers without wrappers, so diff --git a/modules/desktop_capture/mouse_cursor_monitor_linux.cc b/modules/desktop_capture/mouse_cursor_monitor_linux.cc index 456459b0b6..e569f6ef35 100644 --- a/modules/desktop_capture/mouse_cursor_monitor_linux.cc +++ b/modules/desktop_capture/mouse_cursor_monitor_linux.cc @@ -13,9 +13,9 @@ #include "modules/desktop_capture/desktop_capture_types.h" #include "modules/desktop_capture/mouse_cursor_monitor.h" -#if defined(USE_X11) +#if defined(WEBRTC_USE_X11) #include "modules/desktop_capture/linux/mouse_cursor_monitor_x11.h" -#endif // defined(USE_X11) +#endif // defined(WEBRTC_USE_X11) namespace webrtc { @@ -23,32 +23,32 @@ namespace webrtc { MouseCursorMonitor* MouseCursorMonitor::CreateForWindow( const DesktopCaptureOptions& options, WindowId window) { -#if defined(USE_X11) +#if defined(WEBRTC_USE_X11) return MouseCursorMonitorX11::CreateForWindow(options, window); #else return nullptr; -#endif // defined(USE_X11) +#endif // defined(WEBRTC_USE_X11) } // static MouseCursorMonitor* MouseCursorMonitor::CreateForScreen( const DesktopCaptureOptions& options, ScreenId screen) { -#if defined(USE_X11) +#if defined(WEBRTC_USE_X11) return MouseCursorMonitorX11::CreateForScreen(options, screen); #else return nullptr; -#endif // defined(USE_X11) +#endif // defined(WEBRTC_USE_X11) } // static std::unique_ptr MouseCursorMonitor::Create( const DesktopCaptureOptions& options) { -#if defined(USE_X11) +#if defined(WEBRTC_USE_X11) return MouseCursorMonitorX11::Create(options); #else return nullptr; -#endif // defined(USE_X11) +#endif // defined(WEBRTC_USE_X11) } } // namespace webrtc diff --git a/modules/desktop_capture/screen_capturer_linux.cc b/modules/desktop_capture/screen_capturer_linux.cc index dfb73afa08..82dbae4813 100644 --- a/modules/desktop_capture/screen_capturer_linux.cc +++ b/modules/desktop_capture/screen_capturer_linux.cc @@ -17,9 +17,9 @@ #include "modules/desktop_capture/linux/screen_capturer_pipewire.h" #endif // defined(WEBRTC_USE_PIPEWIRE) -#if defined(USE_X11) +#if defined(WEBRTC_USE_X11) #include "modules/desktop_capture/linux/screen_capturer_x11.h" -#endif // defined(USE_X11) +#endif // defined(WEBRTC_USE_X11) namespace webrtc { @@ -32,9 +32,9 @@ std::unique_ptr DesktopCapturer::CreateRawScreenCapturer( } #endif // defined(WEBRTC_USE_PIPEWIRE) -#if defined(USE_X11) +#if defined(WEBRTC_USE_X11) return ScreenCapturerX11::CreateRawScreenCapturer(options); -#endif // defined(USE_X11) +#endif // defined(WEBRTC_USE_X11) return nullptr; } diff --git a/modules/desktop_capture/window_capturer_linux.cc b/modules/desktop_capture/window_capturer_linux.cc index 74b96b37e0..41dbf836b0 100644 --- a/modules/desktop_capture/window_capturer_linux.cc +++ b/modules/desktop_capture/window_capturer_linux.cc @@ -17,9 +17,9 @@ #include "modules/desktop_capture/linux/window_capturer_pipewire.h" #endif // defined(WEBRTC_USE_PIPEWIRE) -#if defined(USE_X11) +#if defined(WEBRTC_USE_X11) #include "modules/desktop_capture/linux/window_capturer_x11.h" -#endif // defined(USE_X11) +#endif // defined(WEBRTC_USE_X11) namespace webrtc { @@ -32,9 +32,9 @@ std::unique_ptr DesktopCapturer::CreateRawWindowCapturer( } #endif // defined(WEBRTC_USE_PIPEWIRE) -#if defined(USE_X11) +#if defined(WEBRTC_USE_X11) return WindowCapturerX11::CreateRawWindowCapturer(options); -#endif // defined(USE_X11) +#endif // defined(WEBRTC_USE_X11) return nullptr; } diff --git a/modules/desktop_capture/window_finder.h b/modules/desktop_capture/window_finder.h index 4b88bb8e4d..0d346640a2 100644 --- a/modules/desktop_capture/window_finder.h +++ b/modules/desktop_capture/window_finder.h @@ -23,7 +23,7 @@ namespace webrtc { -#if defined(USE_X11) +#if defined(WEBRTC_USE_X11) class XAtomCache; #endif @@ -46,7 +46,7 @@ class WindowFinder { Options(const Options& other); Options(Options&& other); -#if defined(USE_X11) +#if defined(WEBRTC_USE_X11) XAtomCache* cache = nullptr; #endif #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) diff --git a/modules/desktop_capture/window_finder_unittest.cc b/modules/desktop_capture/window_finder_unittest.cc index df4d65c2b5..7a586c7361 100644 --- a/modules/desktop_capture/window_finder_unittest.cc +++ b/modules/desktop_capture/window_finder_unittest.cc @@ -20,7 +20,7 @@ #include "rtc_base/logging.h" #include "test/gtest.h" -#if defined(USE_X11) +#if defined(WEBRTC_USE_X11) #include "modules/desktop_capture/linux/shared_x_display.h" #include "modules/desktop_capture/linux/x_atom_cache.h" #endif @@ -92,7 +92,7 @@ TEST(WindowFinderTest, FindConsoleWindow) { #else TEST(WindowFinderTest, FindDrawerWindow) { WindowFinder::Options options; -#if defined(USE_X11) +#if defined(WEBRTC_USE_X11) std::unique_ptr cache; const auto shared_x_display = SharedXDisplay::CreateDefault(); if (shared_x_display) { @@ -148,7 +148,7 @@ TEST(WindowFinderTest, FindDrawerWindow) { TEST(WindowFinderTest, ShouldReturnNullWindowIfSpotIsOutOfScreen) { WindowFinder::Options options; -#if defined(USE_X11) +#if defined(WEBRTC_USE_X11) std::unique_ptr cache; const auto shared_x_display = SharedXDisplay::CreateDefault(); if (shared_x_display) {