Reland "Linux capturers: organize X11 and Wayland implementations into separate folders"

Bug: webrtc:13429
Change-Id: Ibc7488cde807f859ee82a60fe47a7e21c148764e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/240460
Reviewed-by: Mark Foltz <mfoltz@chromium.org>
Commit-Queue: Mark Foltz <mfoltz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#35527}
This commit is contained in:
Jan Grulich 2021-12-09 09:57:56 +01:00 committed by WebRTC LUCI CQ
parent 7e8794e5a4
commit 9cb24b8396
35 changed files with 228 additions and 217 deletions

View file

@ -249,14 +249,14 @@ if (is_linux || is_chromeos) {
":libdrm",
]
deps = [ "../../rtc_base" ]
extra_header = "linux/pipewire_stub_header.fragment"
extra_header = "linux/wayland/pipewire_stub_header.fragment"
logging_function = "RTC_LOG(LS_VERBOSE)"
logging_include = "rtc_base/logging.h"
output_name = "linux/pipewire_stubs"
path_from_source = "modules/desktop_capture/linux"
output_name = "linux/wayland/pipewire_stubs"
path_from_source = "modules/desktop_capture/linux/wayland"
sigs = [
"linux/pipewire.sigs",
"linux/drm.sigs",
"linux/wayland/pipewire.sigs",
"linux/wayland/drm.sigs",
]
}
}
@ -406,37 +406,38 @@ rtc_library("desktop_capture_generic") {
if (build_with_mozilla && (is_linux || is_chromeos)) {
sources += [
"app_capturer_linux.cc",
"linux/app_capturer_x11.cc",
"linux/desktop_device_info_linux.cc",
"linux/desktop_device_info_linux.h",
"linux/shared_x_util.cc",
"linux/shared_x_util.h",
"linux/x11/app_capturer_x11.cc",
"linux/x11/desktop_device_info_linux.cc",
"linux/x11/desktop_device_info_linux.h",
"linux/x11/shared_x_util.cc",
"linux/x11/shared_x_util.h",
]
}
}
if (rtc_use_x11_extensions) {
sources += [
"linux/mouse_cursor_monitor_x11.cc",
"linux/mouse_cursor_monitor_x11.h",
"linux/screen_capturer_x11.cc",
"linux/screen_capturer_x11.h",
"linux/shared_x_display.cc",
"linux/shared_x_display.h",
"linux/window_capturer_x11.cc",
"linux/window_capturer_x11.h",
"linux/window_finder_x11.cc",
"linux/window_finder_x11.h",
"linux/window_list_utils.cc",
"linux/window_list_utils.h",
"linux/x_atom_cache.cc",
"linux/x_atom_cache.h",
"linux/x_error_trap.cc",
"linux/x_error_trap.h",
"linux/x_server_pixel_buffer.cc",
"linux/x_server_pixel_buffer.h",
"linux/x_window_property.cc",
"linux/x_window_property.h",
"linux/x11/mouse_cursor_monitor_x11.cc",
"linux/x11/mouse_cursor_monitor_x11.h",
"linux/x11/screen_capturer_x11.cc",
"linux/x11/screen_capturer_x11.h",
"linux/x11/shared_x_display.cc",
"linux/x11/shared_x_display.h",
"linux/x11/window_capturer_x11.cc",
"linux/x11/window_capturer_x11.h",
"linux/x11/window_finder_x11.cc",
"linux/x11/window_finder_x11.h",
"linux/x11/window_list_utils.cc",
"linux/x11/window_list_utils.h",
"linux/x11/x_atom_cache.cc",
"linux/x11/x_atom_cache.h",
"linux/x11/x_error_trap.cc",
"linux/x11/x_error_trap.h",
"linux/x11/x_server_pixel_buffer.cc",
"linux/x11/x_server_pixel_buffer.h",
"linux/x11/x_window_property.cc",
"linux/x11/x_window_property.h",
]
libs = [
"X11",
@ -561,10 +562,10 @@ rtc_library("desktop_capture_generic") {
if (rtc_use_pipewire) {
sources += [
"linux/base_capturer_pipewire.cc",
"linux/base_capturer_pipewire.h",
"linux/egl_dmabuf.cc",
"linux/egl_dmabuf.h",
"linux/wayland/base_capturer_pipewire.cc",
"linux/wayland/base_capturer_pipewire.h",
"linux/wayland/egl_dmabuf.cc",
"linux/wayland/egl_dmabuf.h",
]
configs += [

View file

@ -14,7 +14,7 @@
#include "rtc_base/system/rtc_export.h"
#if defined(WEBRTC_USE_X11)
#include "modules/desktop_capture/linux/shared_x_display.h"
#include "modules/desktop_capture/linux/x11/shared_x_display.h"
#endif
#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)

View file

@ -8,77 +8,4 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_SHARED_X_DISPLAY_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_SHARED_X_DISPLAY_H_
#include <map>
#include <string>
#include <vector>
#include "api/ref_counted_base.h"
#include "api/scoped_refptr.h"
#include "rtc_base/constructor_magic.h"
#include "rtc_base/system/rtc_export.h"
// Including Xlib.h will involve evil defines (Bool, Status, True, False), which
// easily conflict with other headers.
typedef struct _XDisplay Display;
typedef union _XEvent XEvent;
namespace webrtc {
// A ref-counted object to store XDisplay connection.
class RTC_EXPORT SharedXDisplay
: public rtc::RefCountedNonVirtual<SharedXDisplay> {
public:
class XEventHandler {
public:
virtual ~XEventHandler() {}
// Processes XEvent. Returns true if the event has been handled.
virtual bool HandleXEvent(const XEvent& event) = 0;
};
// Creates a new X11 Display for the `display_name`. NULL is returned if X11
// connection failed. Equivalent to CreateDefault() when `display_name` is
// empty.
static rtc::scoped_refptr<SharedXDisplay> Create(
const std::string& display_name);
// Creates X11 Display connection for the default display (e.g. specified in
// DISPLAY). NULL is returned if X11 connection failed.
static rtc::scoped_refptr<SharedXDisplay> CreateDefault();
Display* display() { return display_; }
// Adds a new event `handler` for XEvent's of `type`.
void AddEventHandler(int type, XEventHandler* handler);
// Removes event `handler` added using `AddEventHandler`. Doesn't do anything
// if `handler` is not registered.
void RemoveEventHandler(int type, XEventHandler* handler);
// Processes pending XEvents, calling corresponding event handlers.
void ProcessPendingXEvents();
void IgnoreXServerGrabs();
~SharedXDisplay();
protected:
// Takes ownership of `display`.
explicit SharedXDisplay(Display* display);
private:
typedef std::map<int, std::vector<XEventHandler*> > EventHandlersMap;
Display* display_;
EventHandlersMap event_handlers_;
RTC_DISALLOW_COPY_AND_ASSIGN(SharedXDisplay);
};
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_LINUX_SHARED_X_DISPLAY_H_
#include "modules/desktop_capture/linux/x11/shared_x_display.h"

View file

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/desktop_capture/linux/base_capturer_pipewire.h"
#include "modules/desktop_capture/linux/wayland/base_capturer_pipewire.h"
#include <gio/gunixfdlist.h>
#include <glib-object.h>
@ -19,9 +19,9 @@
#include <sys/syscall.h>
#include <unistd.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "absl/memory/memory.h"
#include "modules/desktop_capture/desktop_capture_options.h"
@ -31,11 +31,11 @@
#include "rtc_base/string_encode.h"
#if defined(WEBRTC_DLOPEN_PIPEWIRE)
#include "modules/desktop_capture/linux/pipewire_stubs.h"
using modules_desktop_capture_linux::InitializeStubs;
using modules_desktop_capture_linux::kModuleDrm;
using modules_desktop_capture_linux::kModulePipewire;
using modules_desktop_capture_linux::StubPathMap;
#include "modules/desktop_capture/linux/wayland/pipewire_stubs.h"
using modules_desktop_capture_linux_wayland::InitializeStubs;
using modules_desktop_capture_linux_wayland::kModuleDrm;
using modules_desktop_capture_linux_wayland::kModulePipewire;
using modules_desktop_capture_linux_wayland::StubPathMap;
#endif // defined(WEBRTC_DLOPEN_PIPEWIRE)
namespace webrtc {
@ -420,8 +420,8 @@ void BaseCapturerPipeWire::InitPortal() {
g_dbus_proxy_new_for_bus(
G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, /*info=*/nullptr,
kDesktopBusName, kDesktopObjectPath, kScreenCastInterfaceName,
cancellable_,
reinterpret_cast<GAsyncReadyCallback>(OnProxyRequested), this);
cancellable_, reinterpret_cast<GAsyncReadyCallback>(OnProxyRequested),
this);
}
void BaseCapturerPipeWire::Init() {
@ -569,9 +569,8 @@ void BaseCapturerPipeWire::HandleBuffer(pw_buffer* buffer) {
plane_datas.push_back(data);
}
src_unique_ptr =
egl_dmabuf_->ImageFromDmaBuf(desktop_size_, spa_video_format_.format,
plane_datas, modifier_);
src_unique_ptr = egl_dmabuf_->ImageFromDmaBuf(
desktop_size_, spa_video_format_.format, plane_datas, modifier_);
src = src_unique_ptr.get();
} else if (spa_buffer->datas[0].type == SPA_DATA_MemPtr) {
src = static_cast<uint8_t*>(spa_buffer->datas[0].data);
@ -728,14 +727,14 @@ void BaseCapturerPipeWire::SessionRequest() {
portal_handle_, OnSessionRequestResponseSignal);
RTC_LOG(LS_INFO) << "Screen cast session requested.";
g_dbus_proxy_call(
proxy_, "CreateSession", g_variant_new("(a{sv})", &builder),
G_DBUS_CALL_FLAGS_NONE, /*timeout=*/-1, cancellable_,
reinterpret_cast<GAsyncReadyCallback>(OnSessionRequested), this);
g_dbus_proxy_call(proxy_, "CreateSession", g_variant_new("(a{sv})", &builder),
G_DBUS_CALL_FLAGS_NONE, /*timeout=*/-1, cancellable_,
reinterpret_cast<GAsyncReadyCallback>(OnSessionRequested),
this);
}
// static
void BaseCapturerPipeWire::OnSessionRequested(GDBusProxy *proxy,
void BaseCapturerPipeWire::OnSessionRequested(GDBusProxy* proxy,
GAsyncResult* result,
gpointer user_data) {
BaseCapturerPipeWire* that = static_cast<BaseCapturerPipeWire*>(user_data);
@ -841,15 +840,15 @@ void BaseCapturerPipeWire::SourcesRequest() {
sources_handle_, OnSourcesRequestResponseSignal);
RTC_LOG(LS_INFO) << "Requesting sources from the screen cast session.";
g_dbus_proxy_call(
proxy_, "SelectSources",
g_variant_new("(oa{sv})", session_handle_, &builder),
G_DBUS_CALL_FLAGS_NONE, /*timeout=*/-1, cancellable_,
reinterpret_cast<GAsyncReadyCallback>(OnSourcesRequested), this);
g_dbus_proxy_call(proxy_, "SelectSources",
g_variant_new("(oa{sv})", session_handle_, &builder),
G_DBUS_CALL_FLAGS_NONE, /*timeout=*/-1, cancellable_,
reinterpret_cast<GAsyncReadyCallback>(OnSourcesRequested),
this);
}
// static
void BaseCapturerPipeWire::OnSourcesRequested(GDBusProxy *proxy,
void BaseCapturerPipeWire::OnSourcesRequested(GDBusProxy* proxy,
GAsyncResult* result,
gpointer user_data) {
BaseCapturerPipeWire* that = static_cast<BaseCapturerPipeWire*>(user_data);
@ -935,7 +934,7 @@ void BaseCapturerPipeWire::StartRequest() {
}
// static
void BaseCapturerPipeWire::OnStartRequested(GDBusProxy *proxy,
void BaseCapturerPipeWire::OnStartRequested(GDBusProxy* proxy,
GAsyncResult* result,
gpointer user_data) {
BaseCapturerPipeWire* that = static_cast<BaseCapturerPipeWire*>(user_data);
@ -1034,17 +1033,15 @@ void BaseCapturerPipeWire::OpenPipeWireRemote() {
g_dbus_proxy_call_with_unix_fd_list(
proxy_, "OpenPipeWireRemote",
g_variant_new("(oa{sv})", session_handle_, &builder),
G_DBUS_CALL_FLAGS_NONE, /*timeout=*/-1, /*fd_list=*/nullptr,
cancellable_,
G_DBUS_CALL_FLAGS_NONE, /*timeout=*/-1, /*fd_list=*/nullptr, cancellable_,
reinterpret_cast<GAsyncReadyCallback>(OnOpenPipeWireRemoteRequested),
this);
}
// static
void BaseCapturerPipeWire::OnOpenPipeWireRemoteRequested(
GDBusProxy *proxy,
GAsyncResult* result,
gpointer user_data) {
void BaseCapturerPipeWire::OnOpenPipeWireRemoteRequested(GDBusProxy* proxy,
GAsyncResult* result,
gpointer user_data) {
BaseCapturerPipeWire* that = static_cast<BaseCapturerPipeWire*>(user_data);
RTC_DCHECK(that);

View file

@ -8,18 +8,20 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_BASE_CAPTURER_PIPEWIRE_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_BASE_CAPTURER_PIPEWIRE_H_
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_BASE_CAPTURER_PIPEWIRE_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_BASE_CAPTURER_PIPEWIRE_H_
#include <gio/gio.h>
#define typeof __typeof__
#include <pipewire/pipewire.h>
#include <spa/param/video/format-utils.h>
#include <spa/utils/result.h>
#include <memory>
#include "absl/types/optional.h"
#include "modules/desktop_capture/desktop_capture_options.h"
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/linux/egl_dmabuf.h"
#include "modules/desktop_capture/linux/wayland/egl_dmabuf.h"
#include "rtc_base/constructor_magic.h"
#include "rtc_base/synchronization/mutex.h"
@ -80,7 +82,7 @@ class BaseCapturerPipeWire : public DesktopCapturer {
GDBusConnection* connection_ = nullptr;
GDBusProxy* proxy_ = nullptr;
GCancellable *cancellable_ = nullptr;
GCancellable* cancellable_ = nullptr;
gchar* portal_handle_ = nullptr;
gchar* session_handle_ = nullptr;
gchar* sources_handle_ = nullptr;
@ -138,7 +140,7 @@ class BaseCapturerPipeWire : public DesktopCapturer {
const gchar* token);
void SessionRequest();
static void OnSessionRequested(GDBusProxy *proxy,
static void OnSessionRequested(GDBusProxy* proxy,
GAsyncResult* result,
gpointer user_data);
static void OnSessionRequestResponseSignal(GDBusConnection* connection,
@ -150,7 +152,7 @@ class BaseCapturerPipeWire : public DesktopCapturer {
gpointer user_data);
void SourcesRequest();
static void OnSourcesRequested(GDBusProxy *proxy,
static void OnSourcesRequested(GDBusProxy* proxy,
GAsyncResult* result,
gpointer user_data);
static void OnSourcesRequestResponseSignal(GDBusConnection* connection,
@ -162,7 +164,7 @@ class BaseCapturerPipeWire : public DesktopCapturer {
gpointer user_data);
void StartRequest();
static void OnStartRequested(GDBusProxy *proxy,
static void OnStartRequested(GDBusProxy* proxy,
GAsyncResult* result,
gpointer user_data);
static void OnStartRequestResponseSignal(GDBusConnection* connection,
@ -174,7 +176,7 @@ class BaseCapturerPipeWire : public DesktopCapturer {
gpointer user_data);
void OpenPipeWireRemote();
static void OnOpenPipeWireRemoteRequested(GDBusProxy *proxy,
static void OnOpenPipeWireRemoteRequested(GDBusProxy* proxy,
GAsyncResult* result,
gpointer user_data);
@ -183,4 +185,4 @@ class BaseCapturerPipeWire : public DesktopCapturer {
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_LINUX_BASE_CAPTURER_PIPEWIRE_H_
#endif // MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_BASE_CAPTURER_PIPEWIRE_H_

View file

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/desktop_capture/linux/egl_dmabuf.h"
#include "modules/desktop_capture/linux/wayland/egl_dmabuf.h"
#include <asm/ioctl.h>
#include <dlfcn.h>

View file

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_EGL_DMABUF_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_EGL_DMABUF_H_
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_EGL_DMABUF_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_EGL_DMABUF_H_
#include <epoxy/egl.h>
#include <epoxy/gl.h>
@ -62,4 +62,4 @@ class EglDmaBuf {
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_LINUX_EGL_DMABUF_H_
#endif // MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_EGL_DMABUF_H_

View file

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/desktop_capture/linux/mouse_cursor_monitor_x11.h"
#include "modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.h"
#include <X11/Xlib.h>
#include <X11/extensions/Xfixes.h>
@ -23,7 +23,7 @@
#include "modules/desktop_capture/desktop_capture_types.h"
#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/desktop_geometry.h"
#include "modules/desktop_capture/linux/x_error_trap.h"
#include "modules/desktop_capture/linux/x11/x_error_trap.h"
#include "modules/desktop_capture/mouse_cursor.h"
#include "modules/desktop_capture/mouse_cursor_monitor.h"
#include "rtc_base/checks.h"
@ -208,7 +208,7 @@ void MouseCursorMonitorX11::CaptureCursor() {
new BasicDesktopFrame(DesktopSize(img->width, img->height)));
// Xlib stores 32-bit data in longs, even if longs are 64-bits long.
unsigned long* src = img->pixels;
unsigned long* src = img->pixels; // NOLINT(runtime/int)
uint32_t* dst = reinterpret_cast<uint32_t*>(image->data());
uint32_t* dst_end = dst + (img->width * img->height);
while (dst < dst_end) {

View file

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_MOUSE_CURSOR_MONITOR_X11_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_MOUSE_CURSOR_MONITOR_X11_H_
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_X11_MOUSE_CURSOR_MONITOR_X11_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_X11_MOUSE_CURSOR_MONITOR_X11_H_
#include <X11/X.h>
@ -18,7 +18,7 @@
#include "api/scoped_refptr.h"
#include "modules/desktop_capture/desktop_capture_options.h"
#include "modules/desktop_capture/desktop_capture_types.h"
#include "modules/desktop_capture/linux/shared_x_display.h"
#include "modules/desktop_capture/linux/x11/shared_x_display.h"
#include "modules/desktop_capture/mouse_cursor.h"
#include "modules/desktop_capture/mouse_cursor_monitor.h"
@ -65,4 +65,4 @@ class MouseCursorMonitorX11 : public MouseCursorMonitor,
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_LINUX_MOUSE_CURSOR_MONITOR_X11_H_
#endif // MODULES_DESKTOP_CAPTURE_LINUX_X11_MOUSE_CURSOR_MONITOR_X11_H_

View file

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/desktop_capture/linux/screen_capturer_x11.h"
#include "modules/desktop_capture/linux/x11/screen_capturer_x11.h"
#include <X11/Xlib.h>
#include <X11/extensions/Xdamage.h>
@ -25,7 +25,7 @@
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/desktop_geometry.h"
#include "modules/desktop_capture/linux/x_server_pixel_buffer.h"
#include "modules/desktop_capture/linux/x11/x_server_pixel_buffer.h"
#include "modules/desktop_capture/screen_capture_frame_queue.h"
#include "modules/desktop_capture/screen_capturer_helper.h"
#include "modules/desktop_capture/shared_desktop_frame.h"

View file

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_SCREEN_CAPTURER_X11_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_SCREEN_CAPTURER_X11_H_
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_X11_SCREEN_CAPTURER_X11_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_X11_SCREEN_CAPTURER_X11_H_
#include <X11/X.h>
#include <X11/Xlib.h>
@ -23,9 +23,9 @@
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/desktop_region.h"
#include "modules/desktop_capture/linux/shared_x_display.h"
#include "modules/desktop_capture/linux/x_atom_cache.h"
#include "modules/desktop_capture/linux/x_server_pixel_buffer.h"
#include "modules/desktop_capture/linux/x11/shared_x_display.h"
#include "modules/desktop_capture/linux/x11/x_atom_cache.h"
#include "modules/desktop_capture/linux/x11/x_server_pixel_buffer.h"
#include "modules/desktop_capture/screen_capture_frame_queue.h"
#include "modules/desktop_capture/screen_capturer_helper.h"
#include "modules/desktop_capture/shared_desktop_frame.h"
@ -144,4 +144,4 @@ class ScreenCapturerX11 : public DesktopCapturer,
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_LINUX_SCREEN_CAPTURER_X11_H_
#endif // MODULES_DESKTOP_CAPTURE_LINUX_X11_SCREEN_CAPTURER_X11_H_

View file

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/desktop_capture/linux/shared_x_display.h"
#include "modules/desktop_capture/linux/x11/shared_x_display.h"
#include <X11/Xlib.h>
#include <X11/extensions/XTest.h>

View file

@ -0,0 +1,84 @@
/*
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_X11_SHARED_X_DISPLAY_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_X11_SHARED_X_DISPLAY_H_
#include <map>
#include <string>
#include <vector>
#include "api/ref_counted_base.h"
#include "api/scoped_refptr.h"
#include "rtc_base/constructor_magic.h"
#include "rtc_base/system/rtc_export.h"
// Including Xlib.h will involve evil defines (Bool, Status, True, False), which
// easily conflict with other headers.
typedef struct _XDisplay Display;
typedef union _XEvent XEvent;
namespace webrtc {
// A ref-counted object to store XDisplay connection.
class RTC_EXPORT SharedXDisplay
: public rtc::RefCountedNonVirtual<SharedXDisplay> {
public:
class XEventHandler {
public:
virtual ~XEventHandler() {}
// Processes XEvent. Returns true if the event has been handled.
virtual bool HandleXEvent(const XEvent& event) = 0;
};
// Creates a new X11 Display for the `display_name`. NULL is returned if X11
// connection failed. Equivalent to CreateDefault() when `display_name` is
// empty.
static rtc::scoped_refptr<SharedXDisplay> Create(
const std::string& display_name);
// Creates X11 Display connection for the default display (e.g. specified in
// DISPLAY). NULL is returned if X11 connection failed.
static rtc::scoped_refptr<SharedXDisplay> CreateDefault();
Display* display() { return display_; }
// Adds a new event `handler` for XEvent's of `type`.
void AddEventHandler(int type, XEventHandler* handler);
// Removes event `handler` added using `AddEventHandler`. Doesn't do anything
// if `handler` is not registered.
void RemoveEventHandler(int type, XEventHandler* handler);
// Processes pending XEvents, calling corresponding event handlers.
void ProcessPendingXEvents();
void IgnoreXServerGrabs();
~SharedXDisplay();
protected:
// Takes ownership of `display`.
explicit SharedXDisplay(Display* display);
private:
typedef std::map<int, std::vector<XEventHandler*> > EventHandlersMap;
Display* display_;
EventHandlersMap event_handlers_;
RTC_DISALLOW_COPY_AND_ASSIGN(SharedXDisplay);
};
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_LINUX_X11_SHARED_X_DISPLAY_H_

View file

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/desktop_capture/linux/window_capturer_x11.h"
#include "modules/desktop_capture/linux/x11/window_capturer_x11.h"
#include <X11/Xutil.h>
#include <X11/extensions/Xcomposite.h>
@ -23,9 +23,9 @@
#include "modules/desktop_capture/desktop_capture_types.h"
#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/desktop_region.h"
#include "modules/desktop_capture/linux/shared_x_display.h"
#include "modules/desktop_capture/linux/window_finder_x11.h"
#include "modules/desktop_capture/linux/window_list_utils.h"
#include "modules/desktop_capture/linux/x11/shared_x_display.h"
#include "modules/desktop_capture/linux/x11/window_finder_x11.h"
#include "modules/desktop_capture/linux/x11/window_list_utils.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/trace_event.h"

View file

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_WINDOW_CAPTURER_X11_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_WINDOW_CAPTURER_X11_H_
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_X11_WINDOW_CAPTURER_X11_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_X11_WINDOW_CAPTURER_X11_H_
#include <X11/X.h>
#include <X11/Xlib.h>
@ -21,10 +21,10 @@
#include "modules/desktop_capture/desktop_capture_options.h"
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_geometry.h"
#include "modules/desktop_capture/linux/shared_x_display.h"
#include "modules/desktop_capture/linux/window_finder_x11.h"
#include "modules/desktop_capture/linux/x_atom_cache.h"
#include "modules/desktop_capture/linux/x_server_pixel_buffer.h"
#include "modules/desktop_capture/linux/x11/shared_x_display.h"
#include "modules/desktop_capture/linux/x11/window_finder_x11.h"
#include "modules/desktop_capture/linux/x11/x_atom_cache.h"
#include "modules/desktop_capture/linux/x11/x_server_pixel_buffer.h"
#include "rtc_base/constructor_magic.h"
namespace webrtc {
@ -71,4 +71,4 @@ class WindowCapturerX11 : public DesktopCapturer,
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_LINUX_WINDOW_CAPTURER_X11_H_
#endif // MODULES_DESKTOP_CAPTURE_LINUX_X11_WINDOW_CAPTURER_X11_H_

View file

@ -8,13 +8,13 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/desktop_capture/linux/window_finder_x11.h"
#include "modules/desktop_capture/linux/x11/window_finder_x11.h"
#include <X11/X.h>
#include <memory>
#include "modules/desktop_capture/linux/window_list_utils.h"
#include "modules/desktop_capture/linux/x11/window_list_utils.h"
#include "rtc_base/checks.h"
namespace webrtc {

View file

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_WINDOW_FINDER_X11_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_WINDOW_FINDER_X11_H_
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_X11_WINDOW_FINDER_X11_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_X11_WINDOW_FINDER_X11_H_
#include "modules/desktop_capture/window_finder.h"
@ -32,4 +32,4 @@ class WindowFinderX11 final : public WindowFinder {
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_LINUX_WINDOW_FINDER_X11_H_
#endif // MODULES_DESKTOP_CAPTURE_LINUX_X11_WINDOW_FINDER_X11_H_

View file

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/desktop_capture/linux/window_list_utils.h"
#include "modules/desktop_capture/linux/x11/window_list_utils.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@ -16,8 +16,8 @@
#include <algorithm>
#include "modules/desktop_capture/linux/x_error_trap.h"
#include "modules/desktop_capture/linux/x_window_property.h"
#include "modules/desktop_capture/linux/x11/x_error_trap.h"
#include "modules/desktop_capture/linux/x11/x_window_property.h"
#include "rtc_base/checks.h"
#include "rtc_base/constructor_magic.h"
#include "rtc_base/logging.h"

View file

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_WINDOW_LIST_UTILS_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_WINDOW_LIST_UTILS_H_
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_X11_WINDOW_LIST_UTILS_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_X11_WINDOW_LIST_UTILS_H_
#include <X11/X.h>
#include <X11/Xlib.h>
@ -17,7 +17,7 @@
#include "api/function_view.h"
#include "modules/desktop_capture/desktop_geometry.h"
#include "modules/desktop_capture/linux/x_atom_cache.h"
#include "modules/desktop_capture/linux/x11/x_atom_cache.h"
namespace webrtc {
@ -53,4 +53,4 @@ DesktopRect DesktopRectFromXAttributes(const T& attributes) {
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_LINUX_WINDOW_LIST_UTILS_H_
#endif // MODULES_DESKTOP_CAPTURE_LINUX_X11_WINDOW_LIST_UTILS_H_

View file

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/desktop_capture/linux/x_atom_cache.h"
#include "modules/desktop_capture/linux/x11/x_atom_cache.h"
#include "rtc_base/checks.h"

View file

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_X_ATOM_CACHE_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_X_ATOM_CACHE_H_
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_X11_X_ATOM_CACHE_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_X11_X_ATOM_CACHE_H_
#include <X11/X.h>
#include <X11/Xlib.h>
@ -42,4 +42,4 @@ class XAtomCache final {
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_LINUX_X_ATOM_CACHE_H_
#endif // MODULES_DESKTOP_CAPTURE_LINUX_X11_X_ATOM_CACHE_H_

View file

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/desktop_capture/linux/x_error_trap.h"
#include "modules/desktop_capture/linux/x11/x_error_trap.h"
#include <stddef.h>

View file

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_X_ERROR_TRAP_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_X_ERROR_TRAP_H_
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_X11_X_ERROR_TRAP_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_X11_X_ERROR_TRAP_H_
#include <X11/Xlib.h>
@ -36,4 +36,4 @@ class XErrorTrap {
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_LINUX_X_ERROR_TRAP_H_
#endif // MODULES_DESKTOP_CAPTURE_LINUX_X11_X_ERROR_TRAP_H_

View file

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/desktop_capture/linux/x_server_pixel_buffer.h"
#include "modules/desktop_capture/linux/x11/x_server_pixel_buffer.h"
#include <X11/Xutil.h>
#include <stdint.h>
@ -17,9 +17,9 @@
#include <sys/shm.h>
#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/linux/window_list_utils.h"
#include "modules/desktop_capture/linux/x_error_trap.h"
#include "modules/desktop_capture/linux/x_window_property.h"
#include "modules/desktop_capture/linux/x11/window_list_utils.h"
#include "modules/desktop_capture/linux/x11/x_error_trap.h"
#include "modules/desktop_capture/linux/x11/x_window_property.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"

View file

@ -10,8 +10,8 @@
// Don't include this file in any .h files because it pulls in some X headers.
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_X_SERVER_PIXEL_BUFFER_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_X_SERVER_PIXEL_BUFFER_H_
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_X11_X_SERVER_PIXEL_BUFFER_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_X11_X_SERVER_PIXEL_BUFFER_H_
#include <X11/Xutil.h>
#include <X11/extensions/XShm.h>
@ -86,4 +86,4 @@ class XServerPixelBuffer {
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_LINUX_X_SERVER_PIXEL_BUFFER_H_
#endif // MODULES_DESKTOP_CAPTURE_LINUX_X11_X_SERVER_PIXEL_BUFFER_H_

View file

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/desktop_capture/linux/x_window_property.h"
#include "modules/desktop_capture/linux/x11/x_window_property.h"
namespace webrtc {

View file

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_X_WINDOW_PROPERTY_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_X_WINDOW_PROPERTY_H_
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_X11_X_WINDOW_PROPERTY_H_
#define MODULES_DESKTOP_CAPTURE_LINUX_X11_X_WINDOW_PROPERTY_H_
#include <X11/X.h>
#include <X11/Xlib.h>
@ -60,4 +60,4 @@ class XWindowProperty : public XWindowPropertyBase {
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_LINUX_X_WINDOW_PROPERTY_H_
#endif // MODULES_DESKTOP_CAPTURE_LINUX_X11_X_WINDOW_PROPERTY_H_

View file

@ -14,7 +14,7 @@
#include "modules/desktop_capture/mouse_cursor_monitor.h"
#if defined(WEBRTC_USE_X11)
#include "modules/desktop_capture/linux/mouse_cursor_monitor_x11.h"
#include "modules/desktop_capture/linux/x11/mouse_cursor_monitor_x11.h"
#endif // defined(WEBRTC_USE_X11)
namespace webrtc {

View file

@ -14,11 +14,11 @@
#include "modules/desktop_capture/desktop_capturer.h"
#if defined(WEBRTC_USE_PIPEWIRE)
#include "modules/desktop_capture/linux/base_capturer_pipewire.h"
#include "modules/desktop_capture/linux/wayland/base_capturer_pipewire.h"
#endif // defined(WEBRTC_USE_PIPEWIRE)
#if defined(WEBRTC_USE_X11)
#include "modules/desktop_capture/linux/screen_capturer_x11.h"
#include "modules/desktop_capture/linux/x11/screen_capturer_x11.h"
#endif // defined(WEBRTC_USE_X11)
namespace webrtc {

View file

@ -17,7 +17,7 @@
#include "api/scoped_refptr.h"
#include "modules/desktop_capture/desktop_capture_types.h"
#include "modules/desktop_capture/desktop_geometry.h"
#include "modules/desktop_capture/linux/shared_x_display.h"
#include "modules/desktop_capture/linux/x11/shared_x_display.h"
#include "modules/desktop_capture/rgba_color.h"
#include "modules/desktop_capture/screen_drawer.h"
#include "modules/desktop_capture/screen_drawer_lock_posix.h"

View file

@ -14,11 +14,11 @@
#include "modules/desktop_capture/desktop_capturer.h"
#if defined(WEBRTC_USE_PIPEWIRE)
#include "modules/desktop_capture/linux/base_capturer_pipewire.h"
#include "modules/desktop_capture/linux/wayland/base_capturer_pipewire.h"
#endif // defined(WEBRTC_USE_PIPEWIRE)
#if defined(WEBRTC_USE_X11)
#include "modules/desktop_capture/linux/window_capturer_x11.h"
#include "modules/desktop_capture/linux/x11/window_capturer_x11.h"
#endif // defined(WEBRTC_USE_X11)
namespace webrtc {

View file

@ -21,8 +21,8 @@
#include "test/gtest.h"
#if defined(WEBRTC_USE_X11)
#include "modules/desktop_capture/linux/shared_x_display.h"
#include "modules/desktop_capture/linux/x_atom_cache.h"
#include "modules/desktop_capture/linux/x11/shared_x_display.h"
#include "modules/desktop_capture/linux/x11/x_atom_cache.h"
#endif
#if defined(WEBRTC_WIN)