firefox/firefox-pipewire.patch

2509 lines
92 KiB
Diff
Raw Normal View History

2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/config/system-headers.mozbuild.firefox-pipewire firefox-66.0/config/system-headers.mozbuild
--- firefox-66.0/config/system-headers.mozbuild.firefox-pipewire 2019-03-12 01:22:15.000000000 +0100
+++ firefox-66.0/config/system-headers.mozbuild 2019-03-12 15:27:37.675285710 +0100
2019-01-30 13:03:47 +00:00
@@ -314,6 +314,7 @@ system_headers = [
'Gestalt.h',
'getopt.h',
'gio/gio.h',
+ 'gio/gunixfdlist.h',
'glibconfig.h',
'glib.h',
'glib-object.h',
2019-01-30 13:03:47 +00:00
@@ -607,6 +608,7 @@ system_headers = [
'Pgenerr.h',
'PGenErr.h',
'Ph.h',
+ 'pipewire/pipewire.h',
'pixman.h',
'pk11func.h',
'pk11pqg.h',
2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/app_capturer_linux.cc.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/app_capturer_linux.cc
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/app_capturer_linux.cc.firefox-pipewire 2019-03-12 15:27:37.675285710 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/app_capturer_linux.cc 2019-03-12 15:27:37.675285710 +0100
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2018 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.
+ */
+
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/desktop_capture_options.h"
+#include "modules/desktop_capture/desktop_capturer.h"
+
+#if defined(USE_X11)
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/app_capturer_x11.h"
+#endif // defined(USE_X11)
+
+namespace webrtc {
+
+// static
+AppCapturer* AppCapturer::Create(const DesktopCaptureOptions& options) {
+#if defined(USE_X11)
+ return AppCapturerX11::Create(options);
+#endif // defined(USE_X11)
+
+ return nullptr;
+}
+
+// static
+std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawAppCapturer(
+ const DesktopCaptureOptions& options) {
+#if defined(USE_X11)
+ return AppCapturerX11::CreateRawAppCapturer(options);
+#endif // defined(USE_X11)
+
+ return nullptr;
+}
+
+} // namespace webrtc
2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/app_capturer_x11.cc.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/app_capturer_x11.cc
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/app_capturer_x11.cc.firefox-pipewire 2019-03-12 01:22:20.000000000 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/app_capturer_x11.cc 2019-03-12 15:27:37.675285710 +0100
@@ -7,9 +7,6 @@
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
2019-01-30 13:03:47 +00:00
-#include "modules/desktop_capture/app_capturer.h"
-#include "modules/desktop_capture/shared_desktop_frame.h"
-#include "modules/desktop_capture/x11/shared_x_util.h"
2018-10-18 10:19:30 +00:00
#include <assert.h>
#include <string.h>
2019-03-13 08:21:33 +00:00
@@ -21,79 +18,18 @@
2018-10-18 10:19:30 +00:00
#include <algorithm>
2018-10-18 10:19:30 +00:00
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/app_capturer_x11.h"
#include "modules/desktop_capture/desktop_capture_options.h"
#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/x11/shared_x_display.h"
+#include "modules/desktop_capture/x11/shared_x_util.h"
#include "modules/desktop_capture/x11/x_error_trap.h"
#include "modules/desktop_capture/x11/x_server_pixel_buffer.h"
#include "rtc_base/logging.h"
2018-10-18 10:19:30 +00:00
namespace webrtc {
2018-10-18 10:19:30 +00:00
-namespace {
-
-class ScreenCapturerProxy : DesktopCapturer::Callback {
-public:
- ScreenCapturerProxy()
- : screen_capturer_(DesktopCapturer::CreateScreenCapturer(DesktopCaptureOptions::CreateDefault())) {
- screen_capturer_->SelectSource(kFullDesktopScreenId);
- screen_capturer_->Start(this);
- }
- void CaptureFrame() { screen_capturer_->CaptureFrame(); }
- std::unique_ptr<DesktopFrame> GetFrame() { return std::move(frame_); }
-
- // Callback interface
- virtual void OnCaptureResult(DesktopCapturer::Result result,
- std::unique_ptr<DesktopFrame> frame) {
- frame_ = std::move(frame);
- }
-
-protected:
- std::unique_ptr<DesktopCapturer> screen_capturer_;
- std::unique_ptr<DesktopFrame> frame_;
-};
-
-class AppCapturerLinux : public AppCapturer {
-public:
- AppCapturerLinux(const DesktopCaptureOptions& options);
- virtual ~AppCapturerLinux();
-
- // AppCapturer interface.
- virtual bool GetAppList(AppList* apps) override;
- virtual bool SelectApp(ProcessId processId) override;
- virtual bool BringAppToFront() override;
-
- // DesktopCapturer interface.
- virtual void Start(Callback* callback) override;
- virtual void CaptureFrame() override;
- virtual bool SelectSource(SourceId id) override
- {
- return SelectApp(static_cast<ProcessId>(id));
- }
-
-protected:
- Display* GetDisplay() { return x_display_->display(); }
- bool UpdateRegions();
-
- void FillDesktopFrameRegionWithColor(DesktopFrame* pDesktopFrame,Region rgn, uint32_t color);
-private:
- Callback* callback_;
- ProcessId selected_process_;
-
- // Sample Mode
- ScreenCapturerProxy screen_capturer_proxy_;
- // Mask of foreground (non-app windows in front of selected)
- Region rgn_mask_;
- // Region of selected windows
- Region rgn_visual_;
- // Mask of background (desktop, non-app windows behind selected)
- Region rgn_background_;
-
- rtc::scoped_refptr<SharedXDisplay> x_display_;
- RTC_DISALLOW_COPY_AND_ASSIGN(AppCapturerLinux);
-};
-
-AppCapturerLinux::AppCapturerLinux(const DesktopCaptureOptions& options)
+AppCapturerX11::AppCapturerX11(const DesktopCaptureOptions& options)
: callback_(NULL),
selected_process_(0),
x_display_(options.x_display()) {
2019-03-13 08:21:33 +00:00
@@ -102,7 +38,7 @@ AppCapturerLinux::AppCapturerLinux(const
rgn_background_ = XCreateRegion();
}
2018-10-18 10:19:30 +00:00
-AppCapturerLinux::~AppCapturerLinux() {
+AppCapturerX11::~AppCapturerX11() {
if (rgn_mask_) {
XDestroyRegion(rgn_mask_);
}
2019-03-13 08:21:33 +00:00
@@ -115,28 +51,28 @@ AppCapturerLinux::~AppCapturerLinux() {
}
2018-10-18 10:19:30 +00:00
// AppCapturer interface.
-bool AppCapturerLinux::GetAppList(AppList* apps) {
+bool AppCapturerX11::GetAppList(AppList* apps) {
// Implemented in DesktopDeviceInfo
return true;
}
-bool AppCapturerLinux::SelectApp(ProcessId processId) {
+bool AppCapturerX11::SelectApp(ProcessId processId) {
selected_process_ = processId;
return true;
}
-bool AppCapturerLinux::BringAppToFront() {
+bool AppCapturerX11::BringAppToFront() {
// Not implemented yet: See Bug 1036653
return true;
}
2018-10-18 10:19:30 +00:00
// DesktopCapturer interface.
-void AppCapturerLinux::Start(Callback* callback) {
+void AppCapturerX11::Start(Callback* callback) {
assert(!callback_);
assert(callback);
2018-10-18 10:19:30 +00:00
callback_ = callback;
}
2018-10-18 10:19:30 +00:00
-void AppCapturerLinux::CaptureFrame() {
+void AppCapturerX11::CaptureFrame() {
XErrorTrap error_trap(GetDisplay());
2018-10-18 10:19:30 +00:00
//Capture screen >> set root window as capture window
2019-03-13 08:21:33 +00:00
@@ -164,7 +100,7 @@ void AppCapturerLinux::CaptureFrame() {
}
}
2018-10-18 10:19:30 +00:00
-void AppCapturerLinux::FillDesktopFrameRegionWithColor(DesktopFrame* pDesktopFrame, Region rgn, uint32_t color) {
+void AppCapturerX11::FillDesktopFrameRegionWithColor(DesktopFrame* pDesktopFrame, Region rgn, uint32_t color) {
XErrorTrap error_trap(GetDisplay());
2018-10-18 10:19:30 +00:00
if (!pDesktopFrame) {
2019-03-13 08:21:33 +00:00
@@ -187,7 +123,7 @@ void AppCapturerLinux::FillDesktopFrameR
}
}
2018-10-18 10:19:30 +00:00
-bool AppCapturerLinux::UpdateRegions() {
+bool AppCapturerX11::UpdateRegions() {
XErrorTrap error_trap(GetDisplay());
2018-10-18 10:19:30 +00:00
XSubtractRegion(rgn_visual_, rgn_visual_, rgn_visual_);
2019-03-13 08:21:33 +00:00
@@ -264,21 +200,19 @@ bool AppCapturerLinux::UpdateRegions() {
return true;
}
2018-10-18 10:19:30 +00:00
-} // namespace
-
// static
-AppCapturer* AppCapturer::Create(const DesktopCaptureOptions& options) {
- return new AppCapturerLinux(options);
+AppCapturer* AppCapturerX11::Create(const DesktopCaptureOptions& options) {
+ return new AppCapturerX11(options);
}
2018-10-18 10:19:30 +00:00
// static
-std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawAppCapturer(
+std::unique_ptr<DesktopCapturer> AppCapturerX11::CreateRawAppCapturer(
const DesktopCaptureOptions& options) {
2018-10-18 10:19:30 +00:00
if (!options.x_display())
return nullptr;
2018-10-18 10:19:30 +00:00
- std::unique_ptr<AppCapturerLinux> capturer(new AppCapturerLinux(options));
+ std::unique_ptr<AppCapturerX11> capturer(new AppCapturerX11(options));
2018-10-18 10:19:30 +00:00
return std::unique_ptr<DesktopCapturer>(std::move(capturer));
}
2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/app_capturer_x11.h.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/app_capturer_x11.h
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/app_capturer_x11.h.firefox-pipewire 2019-03-12 15:27:37.676285720 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/app_capturer_x11.h 2019-03-12 16:08:04.440031789 +0100
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2018 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_APP_CAPTURER_X11_H_
+#define MODULES_DESKTOP_CAPTURE_APP_CAPTURER_X11_H_
+
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#include <memory>
+#include <string>
+
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/app_capturer.h"
+#include "modules/desktop_capture/shared_desktop_frame.h"
+#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/x11/shared_x_display.h"
+#include "modules/desktop_capture/x11/x_server_pixel_buffer.h"
+#include "rtc_base/constructormagic.h"
+#include "rtc_base/scoped_ref_ptr.h"
+
+namespace webrtc {
+
+class ScreenCapturerProxy : DesktopCapturer::Callback {
+public:
+ ScreenCapturerProxy()
+ : screen_capturer_(DesktopCapturer::CreateScreenCapturer(DesktopCaptureOptions::CreateDefault())) {
+ screen_capturer_->SelectSource(kFullDesktopScreenId);
+ screen_capturer_->Start(this);
+ }
+ void CaptureFrame() { screen_capturer_->CaptureFrame(); }
+ std::unique_ptr<DesktopFrame> GetFrame() { return std::move(frame_); }
+
+ // Callback interface
+ virtual void OnCaptureResult(DesktopCapturer::Result result,
+ std::unique_ptr<DesktopFrame> frame) {
+ frame_ = std::move(frame);
+ }
+
+protected:
+ std::unique_ptr<DesktopCapturer> screen_capturer_;
+ std::unique_ptr<DesktopFrame> frame_;
+};
+
+class AppCapturerX11 : public AppCapturer {
+public:
+ AppCapturerX11(const DesktopCaptureOptions& options);
+ virtual ~AppCapturerX11();
+
+ static AppCapturer* Create(const DesktopCaptureOptions& options);
+ static std::unique_ptr<DesktopCapturer> CreateRawAppCapturer(const DesktopCaptureOptions& options);
+
+ // AppCapturer interface.
+ virtual bool GetAppList(AppList* apps) override;
+ virtual bool SelectApp(ProcessId processId) override;
+ virtual bool BringAppToFront() override;
+
+ // DesktopCapturer interface.
+ virtual void Start(Callback* callback) override;
+ virtual void CaptureFrame() override;
+ virtual bool SelectSource(SourceId id) override
+ {
+ return SelectApp(static_cast<ProcessId>(id));
+ }
+
+protected:
+ Display* GetDisplay() { return x_display_->display(); }
+ bool UpdateRegions();
+
+ void FillDesktopFrameRegionWithColor(DesktopFrame* pDesktopFrame,Region rgn, uint32_t color);
+private:
+ Callback* callback_;
+ ProcessId selected_process_;
+
+ // Sample Mode
+ ScreenCapturerProxy screen_capturer_proxy_;
+ // Mask of foreground (non-app windows in front of selected)
+ Region rgn_mask_;
+ // Region of selected windows
+ Region rgn_visual_;
+ // Mask of background (desktop, non-app windows behind selected)
+ Region rgn_background_;
+
+ rtc::scoped_refptr<SharedXDisplay> x_display_;
+ RTC_DISALLOW_COPY_AND_ASSIGN(AppCapturerX11);
+};
+
+} // namespace webrtc
+
+#endif // MODULES_DESKTOP_CAPTURE_APP_CAPTURER_X11_H_
2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/base_capturer_pipewire.cc.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/base_capturer_pipewire.cc
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/base_capturer_pipewire.cc.firefox-pipewire 2019-03-12 15:27:37.676285720 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/base_capturer_pipewire.cc 2019-03-12 15:27:37.676285720 +0100
2018-10-18 10:19:30 +00:00
@@ -0,0 +1,849 @@
+/*
2018-10-18 10:19:30 +00:00
+ * Copyright 2018 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.
+ */
+
2018-10-18 10:19:30 +00:00
+#include <cstring>
+#include <gio/gunixfdlist.h>
+#include <glib-object.h>
+
2018-10-18 10:19:30 +00:00
+#include <spa/param/format-utils.h>
+#include <spa/param/props.h>
+#include <spa/param/video/raw-utils.h>
+#include <spa/support/type-map.h>
+
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/base_capturer_pipewire.h"
2018-10-18 10:19:30 +00:00
+
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/desktop_capture_options.h"
+#include "modules/desktop_capture/desktop_capturer.h"
+#include "rtc_base/checks.h"
+#include "rtc_base/logging.h"
+
+namespace webrtc {
+
2018-10-18 10:19:30 +00:00
+const char kDesktopBusName[] = "org.freedesktop.portal.Desktop";
+const char kDesktopObjectPath[] = "/org/freedesktop/portal/desktop";
+const char kDesktopRequestObjectPath[] =
+ "/org/freedesktop/portal/desktop/request";
+const char kSessionInterfaceName[] = "org.freedesktop.portal.Session";
+const char kRequestInterfaceName[] = "org.freedesktop.portal.Request";
+const char kScreenCastInterfaceName[] = "org.freedesktop.portal.ScreenCast";
+
+const int kBytesPerPixelPw = 4;
+
+// static
2018-10-18 10:19:30 +00:00
+void BaseCapturerPipeWire::OnStateChanged(void* data,
+ pw_remote_state old_state,
+ pw_remote_state state,
+ const char* error_message) {
+ BaseCapturerPipeWire* that = static_cast<BaseCapturerPipeWire*>(data);
+ RTC_DCHECK(that);
+
+ switch (state) {
+ case PW_REMOTE_STATE_ERROR:
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_ERROR) << "PipeWire remote state error: " << error_message;
2018-10-18 10:19:30 +00:00
+ break;
+ case PW_REMOTE_STATE_CONNECTED:
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_INFO) << "PipeWire remote state: connected.";
2018-10-18 10:19:30 +00:00
+ that->CreateReceivingStream();
+ break;
+ case PW_REMOTE_STATE_CONNECTING:
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_INFO) << "PipeWire remote state: connecting.";
2018-10-18 10:19:30 +00:00
+ break;
+ case PW_REMOTE_STATE_UNCONNECTED:
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_INFO) << "PipeWire remote state: unconnected.";
2018-10-18 10:19:30 +00:00
+ break;
+ }
+}
+
+// static
2018-10-18 10:19:30 +00:00
+void BaseCapturerPipeWire::OnStreamStateChanged(void* data,
+ pw_stream_state old_state,
+ pw_stream_state state,
+ const char* error_message) {
+ BaseCapturerPipeWire* that = static_cast<BaseCapturerPipeWire*>(data);
+ RTC_DCHECK(that);
+
+ switch (state) {
+ case PW_STREAM_STATE_ERROR:
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_ERROR) << "PipeWire stream state error: " << error_message;
2018-10-18 10:19:30 +00:00
+ break;
+ case PW_STREAM_STATE_CONFIGURE:
+ pw_stream_set_active(that->pw_stream_, true);
+ break;
+ case PW_STREAM_STATE_UNCONNECTED:
+ case PW_STREAM_STATE_CONNECTING:
+ case PW_STREAM_STATE_READY:
+ case PW_STREAM_STATE_PAUSED:
+ case PW_STREAM_STATE_STREAMING:
+ break;
+ }
+}
+
2018-10-18 10:19:30 +00:00
+// static
+void BaseCapturerPipeWire::OnStreamFormatChanged(
+ void* data,
+ const struct spa_pod* format) {
+ BaseCapturerPipeWire* that = static_cast<BaseCapturerPipeWire*>(data);
+ RTC_DCHECK(that);
+
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_INFO) << "PipeWire stream format changed.";
+
2018-10-18 10:19:30 +00:00
+ if (!format) {
+ pw_stream_finish_format(that->pw_stream_, /*res=*/0, /*params=*/nullptr,
+ /*n_params=*/0);
+ return;
+ }
+
2018-10-18 10:19:30 +00:00
+ that->spa_video_format_ = new spa_video_info_raw();
+ spa_format_video_raw_parse(format, that->spa_video_format_,
+ &that->pw_type_->format_video);
+
2018-10-18 10:19:30 +00:00
+ auto width = that->spa_video_format_->size.width;
+ auto height = that->spa_video_format_->size.height;
+ auto stride = SPA_ROUND_UP_N(width * kBytesPerPixelPw, 4);
+ auto size = height * stride;
+
2018-10-18 10:19:30 +00:00
+ uint8_t buffer[1024] = {};
+ auto builder = spa_pod_builder{buffer, sizeof(buffer)};
+
2018-10-18 10:19:30 +00:00
+ // Setup buffers and meta header for new format.
+ const struct spa_pod* params[2];
+ params[0] = reinterpret_cast<spa_pod*>(spa_pod_builder_object(
+ &builder,
+ // id to enumerate buffer requirements
+ that->pw_core_type_->param.idBuffers,
+ that->pw_core_type_->param_buffers.Buffers,
+ // Size: specified as integer (i) and set to specified size
+ ":", that->pw_core_type_->param_buffers.size, "i", size,
+ // Stride: specified as integer (i) and set to specified stride
+ ":", that->pw_core_type_->param_buffers.stride, "i", stride,
+ // Buffers: specifies how many buffers we want to deal with, set as
+ // integer (i) where preferred number is 8, then allowed number is defined
+ // as range (r) from min and max values and it is undecided (u) to allow
+ // negotiation
+ ":", that->pw_core_type_->param_buffers.buffers, "iru", 8,
+ SPA_POD_PROP_MIN_MAX(1, 32),
+ // Align: memory alignment of the buffer, set as integer (i) to specified
+ // value
+ ":", that->pw_core_type_->param_buffers.align, "i", 16));
+ params[1] = reinterpret_cast<spa_pod*>(spa_pod_builder_object(
+ &builder,
+ // id to enumerate supported metadata
+ that->pw_core_type_->param.idMeta, that->pw_core_type_->param_meta.Meta,
+ // Type: specified as id or enum (I)
+ ":", that->pw_core_type_->param_meta.type, "I",
+ that->pw_core_type_->meta.Header,
+ // Size: size of the metadata, specified as integer (i)
+ ":", that->pw_core_type_->param_meta.size, "i",
+ sizeof(struct spa_meta_header)));
+
+ pw_stream_finish_format(that->pw_stream_, /*res=*/0, params, /*n_params=*/2);
+}
+
+// static
2018-10-18 10:19:30 +00:00
+void BaseCapturerPipeWire::OnStreamProcess(void* data) {
+ BaseCapturerPipeWire* that = static_cast<BaseCapturerPipeWire*>(data);
+ RTC_DCHECK(that);
+
+ pw_buffer* buf = nullptr;
+
+ if (!(buf = pw_stream_dequeue_buffer(that->pw_stream_))) {
+ return;
+ }
+
2018-10-18 10:19:30 +00:00
+ that->HandleBuffer(buf);
+
2018-10-18 10:19:30 +00:00
+ pw_stream_queue_buffer(that->pw_stream_, buf);
+}
+
2018-10-18 10:19:30 +00:00
+BaseCapturerPipeWire::BaseCapturerPipeWire(CaptureSourceType source_type)
+ : capture_source_type_(source_type) {}
+
2018-10-18 10:19:30 +00:00
+BaseCapturerPipeWire::~BaseCapturerPipeWire() {
+ if (pw_main_loop_) {
+ pw_thread_loop_stop(pw_main_loop_);
+ }
+
2018-10-18 10:19:30 +00:00
+ if (pw_type_) {
+ delete pw_type_;
+ }
+
2018-10-18 10:19:30 +00:00
+ if (spa_video_format_) {
+ delete spa_video_format_;
+ }
+
2018-10-18 10:19:30 +00:00
+ if (pw_stream_) {
+ pw_stream_destroy(pw_stream_);
+ }
+
2018-10-18 10:19:30 +00:00
+ if (pw_remote_) {
+ pw_remote_destroy(pw_remote_);
+ }
+
2018-10-18 10:19:30 +00:00
+ if (pw_core_) {
+ pw_core_destroy(pw_core_);
+ }
+
2018-10-18 10:19:30 +00:00
+ if (pw_main_loop_) {
+ pw_thread_loop_destroy(pw_main_loop_);
+ }
+
2018-10-18 10:19:30 +00:00
+ if (pw_loop_) {
+ pw_loop_destroy(pw_loop_);
+ }
+
2018-10-18 10:19:30 +00:00
+ if (current_frame_) {
+ free(current_frame_);
+ }
+
2018-10-18 10:19:30 +00:00
+ if (start_request_signal_id_) {
+ g_dbus_connection_signal_unsubscribe(connection_, start_request_signal_id_);
+ }
+ if (sources_request_signal_id_) {
+ g_dbus_connection_signal_unsubscribe(connection_,
+ sources_request_signal_id_);
+ }
+ if (session_request_signal_id_) {
+ g_dbus_connection_signal_unsubscribe(connection_,
+ session_request_signal_id_);
+ }
+
2018-10-18 10:19:30 +00:00
+ if (session_handle_) {
+ GDBusMessage* message = g_dbus_message_new_method_call(
+ kDesktopBusName, session_handle_, kSessionInterfaceName, "Close");
+ if (message) {
+ GError* error = nullptr;
+ g_dbus_connection_send_message(connection_, message,
+ G_DBUS_SEND_MESSAGE_FLAGS_NONE,
+ /*out_serial=*/nullptr, &error);
+ if (error) {
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_ERROR) << "Failed to close the session: " << error->message;
2018-10-18 10:19:30 +00:00
+ g_error_free(error);
+ }
+ g_object_unref(message);
+ }
+ }
+
2018-10-18 10:19:30 +00:00
+ g_free(start_handle_);
+ g_free(sources_handle_);
+ g_free(session_handle_);
+ g_free(portal_handle_);
+
2018-10-18 10:19:30 +00:00
+ if (proxy_) {
+ g_clear_object(&proxy_);
+ }
+}
+
2018-10-18 10:19:30 +00:00
+void BaseCapturerPipeWire::InitPortals() {
+ g_dbus_proxy_new_for_bus(
+ G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, /*info=*/nullptr,
+ kDesktopBusName, kDesktopObjectPath, kScreenCastInterfaceName,
+ /*cancellable=*/nullptr,
+ reinterpret_cast<GAsyncReadyCallback>(OnProxyRequested), this);
+}
+
2018-10-18 10:19:30 +00:00
+void BaseCapturerPipeWire::InitPipeWire() {
+ pw_init(/*argc=*/nullptr, /*argc=*/nullptr);
+
2018-10-18 10:19:30 +00:00
+ pw_loop_ = pw_loop_new(/*properties=*/nullptr);
+ pw_main_loop_ = pw_thread_loop_new(pw_loop_, "pipewire-main-loop");
+
2018-10-18 10:19:30 +00:00
+ pw_core_ = pw_core_new(pw_loop_, /*properties=*/nullptr);
+ pw_core_type_ = pw_core_get_type(pw_core_);
+ pw_remote_ = pw_remote_new(pw_core_, nullptr, /*user_data_size=*/0);
+
2018-10-18 10:19:30 +00:00
+ InitPipeWireTypes();
+
2018-10-18 10:19:30 +00:00
+ // Initialize event handlers, remote end and stream-related.
+ pw_remote_events_.version = PW_VERSION_REMOTE_EVENTS;
+ pw_remote_events_.state_changed = &OnStateChanged;
+
2018-10-18 10:19:30 +00:00
+ pw_stream_events_.version = PW_VERSION_STREAM_EVENTS;
+ pw_stream_events_.state_changed = &OnStreamStateChanged;
+ pw_stream_events_.format_changed = &OnStreamFormatChanged;
+ pw_stream_events_.process = &OnStreamProcess;
+
2018-10-18 10:19:30 +00:00
+ pw_remote_add_listener(pw_remote_, &spa_remote_listener_, &pw_remote_events_,
+ this);
+ pw_remote_connect_fd(pw_remote_, pw_fd_);
+
2018-10-18 10:19:30 +00:00
+ if (pw_thread_loop_start(pw_main_loop_) < 0) {
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_ERROR) << "Failed to start main PipeWire loop";
2018-10-18 10:19:30 +00:00
+ portal_init_failed_ = true;
+ }
+}
+
2018-10-18 10:19:30 +00:00
+void BaseCapturerPipeWire::InitPipeWireTypes() {
+ spa_type_map* map = pw_core_type_->map;
+ pw_type_ = new PipeWireType();
+
2018-10-18 10:19:30 +00:00
+ spa_type_media_type_map(map, &pw_type_->media_type);
+ spa_type_media_subtype_map(map, &pw_type_->media_subtype);
+ spa_type_format_video_map(map, &pw_type_->format_video);
+ spa_type_video_format_map(map, &pw_type_->video_format);
+}
+
2018-10-18 10:19:30 +00:00
+void BaseCapturerPipeWire::CreateReceivingStream() {
+ spa_rectangle pwMinScreenBounds = spa_rectangle{1, 1};
+ spa_rectangle pwScreenBounds =
+ spa_rectangle{static_cast<uint32_t>(desktop_size_.width()),
+ static_cast<uint32_t>(desktop_size_.height())};
+
2018-10-18 10:19:30 +00:00
+ spa_fraction pwFrameRateMin = spa_fraction{0, 1};
+ spa_fraction pwFrameRateMax = spa_fraction{60, 1};
+
2018-10-18 10:19:30 +00:00
+ pw_properties* reuseProps = pw_properties_new("pipewire.client.reuse", "1",
+ /*end of varargs*/ nullptr);
+ pw_stream_ = pw_stream_new(pw_remote_, "webrtc-consume-stream", reuseProps);
+
2018-10-18 10:19:30 +00:00
+ uint8_t buffer[1024] = {};
+ const spa_pod* params[1];
+ spa_pod_builder builder = spa_pod_builder{buffer, sizeof(buffer)};
+ params[0] = reinterpret_cast<spa_pod*>(spa_pod_builder_object(
+ &builder,
+ // id to enumerate formats
+ pw_core_type_->param.idEnumFormat, pw_core_type_->spa_format, "I",
+ pw_type_->media_type.video, "I", pw_type_->media_subtype.raw,
+ // Video format: specified as id or enum (I), preferred format is BGRx,
+ // then allowed formats are enumerated (e) and the format is undecided (u)
+ // to allow negotiation
+ ":", pw_type_->format_video.format, "Ieu", pw_type_->video_format.BGRx,
+ SPA_POD_PROP_ENUM(2, pw_type_->video_format.RGBx,
+ pw_type_->video_format.BGRx),
+ // Video size: specified as rectangle (R), preferred size is specified as
+ // first parameter, then allowed size is defined as range (r) from min and
+ // max values and the format is undecided (u) to allow negotiation
+ ":", pw_type_->format_video.size, "Rru", &pwScreenBounds, 2,
+ &pwMinScreenBounds, &pwScreenBounds,
+ // Frame rate: specified as fraction (F) and set to minimum frame rate
+ // value
+ ":", pw_type_->format_video.framerate, "F", &pwFrameRateMin,
+ // Max frame rate: specified as fraction (F), preferred frame rate is set
+ // to maximum value, then allowed frame rate is defined as range (r) from
+ // min and max values and it is undecided (u) to allow negotiation
+ ":", pw_type_->format_video.max_framerate, "Fru", &pwFrameRateMax, 2,
+ &pwFrameRateMin, &pwFrameRateMax));
+
2018-10-18 10:19:30 +00:00
+ pw_stream_add_listener(pw_stream_, &spa_stream_listener_, &pw_stream_events_,
+ this);
+ pw_stream_flags flags = static_cast<pw_stream_flags>(
+ PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_INACTIVE |
+ PW_STREAM_FLAG_MAP_BUFFERS);
+ if (pw_stream_connect(pw_stream_, PW_DIRECTION_INPUT, /*port_path=*/nullptr,
+ flags, params,
+ /*n_params=*/1) != 0) {
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_ERROR) << "Could not connect receiving stream.";
2018-10-18 10:19:30 +00:00
+ portal_init_failed_ = true;
+ return;
+ }
+}
+
2018-10-18 10:19:30 +00:00
+void BaseCapturerPipeWire::HandleBuffer(pw_buffer* buffer) {
+ spa_buffer* spaBuffer = buffer->buffer;
+ void* src = nullptr;
+
2018-10-18 10:19:30 +00:00
+ if (!(src = spaBuffer->datas[0].data)) {
+ return;
+ }
+
2018-10-18 10:19:30 +00:00
+ uint32_t maxSize = spaBuffer->datas[0].maxsize;
+ int32_t srcStride = spaBuffer->datas[0].chunk->stride;
+ if (srcStride != (desktop_size_.width() * kBytesPerPixelPw)) {
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_ERROR) << "Got buffer with stride different from screen stride: "
2018-10-18 10:19:30 +00:00
+ << srcStride
+ << " != " << (desktop_size_.width() * kBytesPerPixelPw);
+ portal_init_failed_ = true;
+ return;
+ }
+
2018-10-18 10:19:30 +00:00
+ if (!current_frame_) {
+ current_frame_ = static_cast<uint8_t*>(malloc(maxSize));
+ }
+ RTC_DCHECK(current_frame_ != nullptr);
+
2018-10-18 10:19:30 +00:00
+ // If both sides decided to go with the RGBx format we need to convert it to
+ // BGRx to match color format expected by WebRTC.
+ if (spa_video_format_->format == pw_type_->video_format.RGBx) {
+ uint8_t* tempFrame = static_cast<uint8_t*>(malloc(maxSize));
+ std::memcpy(tempFrame, src, maxSize);
+ ConvertRGBxToBGRx(tempFrame, maxSize);
+ std::memcpy(current_frame_, tempFrame, maxSize);
+ free(tempFrame);
+ } else {
+ std::memcpy(current_frame_, src, maxSize);
+ }
+}
+
2018-10-18 10:19:30 +00:00
+void BaseCapturerPipeWire::ConvertRGBxToBGRx(uint8_t* frame, uint32_t size) {
+ // Change color format for KDE KWin which uses RGBx and not BGRx
+ for (uint32_t i = 0; i < size; i += 4) {
+ uint8_t tempR = frame[i];
+ uint8_t tempB = frame[i + 2];
+ frame[i] = tempB;
+ frame[i + 2] = tempR;
+ }
+}
+
2018-10-18 10:19:30 +00:00
+guint BaseCapturerPipeWire::SetupRequestResponseSignal(
+ const gchar* object_path,
+ GDBusSignalCallback callback) {
+ return g_dbus_connection_signal_subscribe(
+ connection_, kDesktopBusName, kRequestInterfaceName, "Response",
+ object_path, /*arg0=*/nullptr, G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE,
+ callback, this, /*user_data_free_func=*/nullptr);
+}
+
+// static
2018-10-18 10:19:30 +00:00
+void BaseCapturerPipeWire::OnProxyRequested(GObject* /*object*/,
+ GAsyncResult* result,
+ gpointer user_data) {
+ BaseCapturerPipeWire* that =
+ static_cast<BaseCapturerPipeWire*>(user_data);
+ RTC_DCHECK(that);
+
2018-10-18 10:19:30 +00:00
+ GError* error = nullptr;
+ that->proxy_ = g_dbus_proxy_new_finish(result, &error);
+ if (!that->proxy_) {
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_ERROR) << "Failed to create a proxy for the screen cast portal: "
2018-10-18 10:19:30 +00:00
+ << error->message;
+ g_error_free(error);
+ that->portal_init_failed_ = true;
+ return;
+ }
2018-10-18 10:19:30 +00:00
+ that->connection_ = g_dbus_proxy_get_connection(that->proxy_);
+
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_INFO) << "Created proxy for the screen cast portal.";
2018-10-18 10:19:30 +00:00
+ that->SessionRequest();
+}
+
2018-10-18 10:19:30 +00:00
+// static
+gchar* BaseCapturerPipeWire::PrepareSignalHandle(GDBusConnection* connection,
+ const gchar* token) {
+ gchar* sender = g_strdup(g_dbus_connection_get_unique_name(connection) + 1);
+ for (int i = 0; sender[i]; i++) {
+ if (sender[i] == '.') {
+ sender[i] = '_';
+ }
+ }
+
2018-10-18 10:19:30 +00:00
+ gchar* handle = g_strconcat(kDesktopRequestObjectPath, "/", sender, "/",
+ token, /*end of varargs*/ nullptr);
+ g_free(sender);
+
2018-10-18 10:19:30 +00:00
+ return handle;
+}
+
2018-10-18 10:19:30 +00:00
+void BaseCapturerPipeWire::SessionRequest() {
+ GVariantBuilder builder;
+ gchar* variant_string;
+
+ g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
+ variant_string =
+ g_strdup_printf("webrtc_session%d", g_random_int_range(0, G_MAXINT));
+ g_variant_builder_add(&builder, "{sv}", "session_handle_token",
+ g_variant_new_string(variant_string));
+ g_free(variant_string);
+ variant_string = g_strdup_printf("webrtc%d", g_random_int_range(0, G_MAXINT));
+ g_variant_builder_add(&builder, "{sv}", "handle_token",
+ g_variant_new_string(variant_string));
+
+ portal_handle_ = PrepareSignalHandle(connection_, variant_string);
+ session_request_signal_id_ = SetupRequestResponseSignal(
+ portal_handle_, OnSessionRequestResponseSignal);
+ g_free(variant_string);
+
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_INFO) << "Screen cast session requested.";
2018-10-18 10:19:30 +00:00
+ g_dbus_proxy_call(
+ proxy_, "CreateSession", g_variant_new("(a{sv})", &builder),
+ G_DBUS_CALL_FLAGS_NONE, /*timeout=*/-1, /*cancellable=*/nullptr,
+ reinterpret_cast<GAsyncReadyCallback>(OnSessionRequested), this);
+}
+
+// static
2018-10-18 10:19:30 +00:00
+void BaseCapturerPipeWire::OnSessionRequested(GDBusConnection* connection,
+ GAsyncResult* result,
+ gpointer user_data) {
+ BaseCapturerPipeWire* that =
+ static_cast<BaseCapturerPipeWire*>(user_data);
+ RTC_DCHECK(that);
+
2018-10-18 10:19:30 +00:00
+ GError* error = nullptr;
+ GVariant* variant = g_dbus_proxy_call_finish(that->proxy_, result, &error);
+ if (!variant) {
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_ERROR) << "Failed to create a screen cast session: "
2018-10-18 10:19:30 +00:00
+ << error->message;
+ g_error_free(error);
+ that->portal_init_failed_ = true;
+ return;
+ }
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_INFO) << "Initializing the screen cast session.";
+
2018-10-18 10:19:30 +00:00
+ gchar* handle = nullptr;
+ g_variant_get_child(variant, 0, "o", &handle);
+ g_variant_unref(variant);
+ if (!handle) {
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_ERROR) << "Failed to initialize the screen cast session.";
2018-10-18 10:19:30 +00:00
+ if (that->session_request_signal_id_) {
+ g_dbus_connection_signal_unsubscribe(connection,
+ that->session_request_signal_id_);
+ that->session_request_signal_id_ = 0;
+ }
+ that->portal_init_failed_ = true;
+ return;
+ }
+
2018-10-18 10:19:30 +00:00
+ g_free(handle);
+
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_INFO) << "Subscribing to the screen cast session.";
+}
+
2018-10-18 10:19:30 +00:00
+// static
+void BaseCapturerPipeWire::OnSessionRequestResponseSignal(
+ GDBusConnection* connection,
+ const gchar* sender_name,
+ const gchar* object_path,
+ const gchar* interface_name,
+ const gchar* signal_name,
+ GVariant* parameters,
+ gpointer user_data) {
+ BaseCapturerPipeWire* that =
+ static_cast<BaseCapturerPipeWire*>(user_data);
+ RTC_DCHECK(that);
+
+
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_INFO)
2018-10-18 10:19:30 +00:00
+ << "Received response for the screen cast session subscription.";
+
2018-10-18 10:19:30 +00:00
+ guint32 portal_response;
+ GVariant* response_data;
+ g_variant_get(parameters, "(u@a{sv})", &portal_response, &response_data);
+ g_variant_lookup(response_data, "session_handle", "s",
+ &that->session_handle_);
+ g_variant_unref(response_data);
+
2018-10-18 10:19:30 +00:00
+ if (!that->session_handle_ || portal_response) {
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_ERROR)
2018-10-18 10:19:30 +00:00
+ << "Failed to request the screen cast session subscription.";
+ that->portal_init_failed_ = true;
+ return;
+ }
+
2018-10-18 10:19:30 +00:00
+ that->SourcesRequest();
+}
+
2018-10-18 10:19:30 +00:00
+void BaseCapturerPipeWire::SourcesRequest() {
+ GVariantBuilder builder;
+ gchar* variant_string;
+
+ g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
2018-10-18 10:19:30 +00:00
+ // We want to record monitor content.
+ g_variant_builder_add(&builder, "{sv}", "types",
+ g_variant_new_uint32(capture_source_type_));
+ // We don't want to allow selection of multiple sources.
+ g_variant_builder_add(&builder, "{sv}", "multiple",
+ g_variant_new_boolean(false));
+ variant_string = g_strdup_printf("webrtc%d", g_random_int_range(0, G_MAXINT));
+ g_variant_builder_add(&builder, "{sv}", "handle_token",
+ g_variant_new_string(variant_string));
+
2018-10-18 10:19:30 +00:00
+ sources_handle_ = PrepareSignalHandle(connection_, variant_string);
+ sources_request_signal_id_ = SetupRequestResponseSignal(
+ sources_handle_, OnSourcesRequestResponseSignal);
+ g_free(variant_string);
+
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_INFO) << "Requesting sources from the screen cast session.";
+ g_dbus_proxy_call(
2018-10-18 10:19:30 +00:00
+ proxy_, "SelectSources",
+ g_variant_new("(oa{sv})", session_handle_, &builder),
+ G_DBUS_CALL_FLAGS_NONE, /*timeout=*/-1, /*cancellable=*/nullptr,
2018-10-18 10:19:30 +00:00
+ reinterpret_cast<GAsyncReadyCallback>(OnSourcesRequested), this);
+}
+
+// static
2018-10-18 10:19:30 +00:00
+void BaseCapturerPipeWire::OnSourcesRequested(GDBusConnection* connection,
+ GAsyncResult* result,
+ gpointer user_data) {
2018-10-18 10:19:30 +00:00
+ BaseCapturerPipeWire* that =
+ static_cast<BaseCapturerPipeWire*>(user_data);
+ RTC_DCHECK(that);
+
+ GError* error = nullptr;
+ GVariant* variant = g_dbus_proxy_call_finish(that->proxy_, result, &error);
+ if (!variant) {
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_ERROR) << "Failed to request the sources: " << error->message;
+ g_error_free(error);
2018-10-18 10:19:30 +00:00
+ that->portal_init_failed_ = true;
+ return;
+ }
2018-10-18 10:19:30 +00:00
+
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_INFO) << "Sources requested from the screen cast session.";
+
+ gchar* handle = nullptr;
+ g_variant_get_child(variant, 0, "o", &handle);
+ g_variant_unref(variant);
+ if (!handle) {
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_ERROR) << "Failed to initialize the screen cast session.";
2018-10-18 10:19:30 +00:00
+ if (that->sources_request_signal_id_) {
+ g_dbus_connection_signal_unsubscribe(connection,
2018-10-18 10:19:30 +00:00
+ that->sources_request_signal_id_);
+ that->sources_request_signal_id_ = 0;
+ }
2018-10-18 10:19:30 +00:00
+ that->portal_init_failed_ = true;
+ return;
+ }
+
+ g_free(handle);
+
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_INFO) << "Subscribed to sources signal.";
+}
+
+// static
2018-10-18 10:19:30 +00:00
+void BaseCapturerPipeWire::OnSourcesRequestResponseSignal(
+ GDBusConnection* connection,
+ const gchar* sender_name,
+ const gchar* object_path,
+ const gchar* interface_name,
+ const gchar* signal_name,
+ GVariant* parameters,
+ gpointer user_data) {
2018-10-18 10:19:30 +00:00
+ BaseCapturerPipeWire* that =
+ static_cast<BaseCapturerPipeWire*>(user_data);
+ RTC_DCHECK(that);
+
+ guint32 portal_response;
2018-10-18 10:19:30 +00:00
+ g_variant_get(parameters, "(u@a{sv})", &portal_response, nullptr);
+ if (portal_response) {
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_ERROR)
2018-10-18 10:19:30 +00:00
+ << "Failed to select sources for the screen cast session.";
+ that->portal_init_failed_ = true;
+ return;
+ }
+
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_INFO) << "Received sources signal from session.";
2018-10-18 10:19:30 +00:00
+ that->StartRequest();
+}
+
2018-10-18 10:19:30 +00:00
+void BaseCapturerPipeWire::StartRequest() {
+ GVariantBuilder builder;
+ gchar* variant_string;
+
+ g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
+ variant_string = g_strdup_printf("webrtc%d", g_random_int_range(0, G_MAXINT));
+ g_variant_builder_add(&builder, "{sv}", "handle_token",
+ g_variant_new_string(variant_string));
+
+ start_handle_ = PrepareSignalHandle(connection_, variant_string);
+ start_request_signal_id_ =
+ SetupRequestResponseSignal(start_handle_, OnStartRequestResponseSignal);
+ g_free(variant_string);
+
+ // "Identifier for the application window", this is Wayland, so not "x11:...".
+ const gchar parent_window[] = "";
+
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_INFO) << "Starting the screen cast session.";
+ g_dbus_proxy_call(
+ proxy_, "Start",
+ g_variant_new("(osa{sv})", session_handle_, parent_window, &builder),
+ G_DBUS_CALL_FLAGS_NONE, /*timeout=*/-1, /*cancellable=*/nullptr,
+ reinterpret_cast<GAsyncReadyCallback>(OnStartRequested), this);
+}
+
+// static
2018-10-18 10:19:30 +00:00
+void BaseCapturerPipeWire::OnStartRequested(GDBusConnection* connection,
+ GAsyncResult* result,
+ gpointer user_data) {
2018-10-18 10:19:30 +00:00
+ BaseCapturerPipeWire* that =
+ static_cast<BaseCapturerPipeWire*>(user_data);
+ RTC_DCHECK(that);
+
+ GError* error = nullptr;
+ GVariant* variant = g_dbus_proxy_call_finish(that->proxy_, result, &error);
+ if (!variant) {
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_ERROR) << "Failed to start the screen cast session: "
2018-10-18 10:19:30 +00:00
+ << error->message;
+ g_error_free(error);
2018-10-18 10:19:30 +00:00
+ that->portal_init_failed_ = true;
+ return;
+ }
+
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_INFO) << "Initializing the start of the screen cast session.";
+
+ gchar* handle = nullptr;
+ g_variant_get_child(variant, 0, "o", &handle);
+ g_variant_unref(variant);
+ if (!handle) {
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_ERROR)
+ << "Failed to initialize the start of the screen cast session.";
+ if (that->start_request_signal_id_) {
+ g_dbus_connection_signal_unsubscribe(connection,
+ that->start_request_signal_id_);
+ that->start_request_signal_id_ = 0;
+ }
2018-10-18 10:19:30 +00:00
+ that->portal_init_failed_ = true;
+ return;
+ }
+
+ g_free(handle);
+
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_INFO) << "Subscribed to the start signal.";
+}
+
+// static
2018-10-18 10:19:30 +00:00
+void BaseCapturerPipeWire::OnStartRequestResponseSignal(
+ GDBusConnection* connection,
+ const gchar* sender_name,
+ const gchar* object_path,
+ const gchar* interface_name,
+ const gchar* signal_name,
+ GVariant* parameters,
+ gpointer user_data) {
2018-10-18 10:19:30 +00:00
+ BaseCapturerPipeWire* that =
+ static_cast<BaseCapturerPipeWire*>(user_data);
+ RTC_DCHECK(that);
+
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_INFO) << "Start signal received.";
+ guint32 portal_response;
+ GVariant* response_data;
+ GVariantIter* iter = nullptr;
+ g_variant_get(parameters, "(u@a{sv})", &portal_response, &response_data);
+ if (portal_response || !response_data) {
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_ERROR) << "Failed to start the screen cast session.";
2018-10-18 10:19:30 +00:00
+ that->portal_init_failed_ = true;
+ return;
+ }
+
+ // Array of PipeWire streams. See
+ // https://github.com/flatpak/xdg-desktop-portal/blob/master/data/org.freedesktop.portal.ScreenCast.xml
+ // documentation for <method name="Start">.
+ if (g_variant_lookup(response_data, "streams", "a(ua{sv})", &iter)) {
+ GVariant* variant;
+
+ while (g_variant_iter_next(iter, "@(ua{sv})", &variant)) {
+ guint32 stream_id;
+ gint32 width;
+ gint32 height;
+ GVariant* options;
+
+ g_variant_get(variant, "(u@a{sv})", &stream_id, &options);
+ RTC_DCHECK(options != nullptr);
+
+ g_variant_lookup(options, "size", "(ii)", &width, &height);
+
+ that->desktop_size_.set(width, height);
+
+ g_variant_unref(options);
+ g_variant_unref(variant);
+ }
+ }
+ g_variant_iter_free(iter);
+ g_variant_unref(response_data);
+
2018-10-18 10:19:30 +00:00
+ that->OpenPipeWireRemote();
+}
+
+void BaseCapturerPipeWire::OpenPipeWireRemote() {
+ GVariantBuilder builder;
+ g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
+
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_INFO) << "Opening the PipeWire remote.";
2018-10-18 10:19:30 +00:00
+
+ 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=*/nullptr,
+ reinterpret_cast<GAsyncReadyCallback>(OnOpenPipeWireRemoteRequested),
+ this);
+}
+
+// static
+void BaseCapturerPipeWire::OnOpenPipeWireRemoteRequested(
+ GDBusConnection* connection,
+ GAsyncResult* result,
+ gpointer user_data) {
+ BaseCapturerPipeWire* that =
+ static_cast<BaseCapturerPipeWire*>(user_data);
+ RTC_DCHECK(that);
+
+ GError* error = nullptr;
+ GUnixFDList* outlist = nullptr;
+ GVariant* variant = g_dbus_proxy_call_with_unix_fd_list_finish(
+ that->proxy_, &outlist, result, &error);
+ if (!variant) {
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_ERROR) << "Failed to open the PipeWire remote: "
2018-10-18 10:19:30 +00:00
+ << error->message;
+ g_error_free(error);
+ that->portal_init_failed_ = true;
+ return;
+ }
+
+ gint32 index;
+ g_variant_get(variant, "(h)", &index);
+
+ if ((that->pw_fd_ = g_unix_fd_list_get(outlist, index, &error)) == -1) {
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_ERROR) << "Failed to get file descriptor from the list: "
2018-10-18 10:19:30 +00:00
+ << error->message;
+ g_error_free(error);
+ g_variant_unref(variant);
+ that->portal_init_failed_ = true;
+ return;
+ }
+
+ g_variant_unref(variant);
+ g_object_unref(outlist);
+
+ that->InitPipeWire();
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_INFO) << "PipeWire remote opened.";
2018-10-18 10:19:30 +00:00
+}
+
+void BaseCapturerPipeWire::Start(Callback* callback) {
+ RTC_DCHECK(!callback_);
+ RTC_DCHECK(callback);
+
+ InitPortals();
+
+ callback_ = callback;
+}
+
+void BaseCapturerPipeWire::CaptureFrame() {
+ if (portal_init_failed_) {
+ callback_->OnCaptureResult(Result::ERROR_PERMANENT, nullptr);
+ return;
+ }
+
+ if (!current_frame_) {
+ callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr);
+ return;
+ }
+
+ std::unique_ptr<DesktopFrame> result(new BasicDesktopFrame(desktop_size_));
+ result->CopyPixelsFrom(
+ current_frame_, (desktop_size_.width() * kBytesPerPixelPw),
+ DesktopRect::MakeWH(desktop_size_.width(), desktop_size_.height()));
+ if (!result) {
+ callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr);
+ return;
+ }
+ callback_->OnCaptureResult(Result::SUCCESS, std::move(result));
+}
+
+bool BaseCapturerPipeWire::GetSourceList(SourceList* sources) {
+ RTC_DCHECK(sources->size() == 0);
+ // List of available screens is already presented by the xdg-desktop-portal.
+ // But we have to add an empty source as the code expects it.
+ sources->push_back({0});
+ return true;
+}
+
+bool BaseCapturerPipeWire::SelectSource(SourceId id) {
+ // Screen selection is handled by the xdg-desktop-portal.
+ return true;
+}
+
+} // namespace webrtc
2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/base_capturer_pipewire.h.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/base_capturer_pipewire.h
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/base_capturer_pipewire.h.firefox-pipewire 2019-03-12 15:27:37.676285720 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/base_capturer_pipewire.h 2019-03-12 16:08:26.294298896 +0100
@@ -0,0 +1,166 @@
2018-10-18 10:19:30 +00:00
+/*
+ * Copyright 2018 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_BASE_CAPTURER_PIPEWIRE_H_
+#define MODULES_DESKTOP_CAPTURE_BASE_CAPTURER_PIPEWIRE_H_
2018-10-18 10:19:30 +00:00
+
+#include <gio/gio.h>
+#define typeof __typeof__
+#include <pipewire/pipewire.h>
+#include <spa/param/video/format-utils.h>
+
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/desktop_capture_options.h"
+#include "modules/desktop_capture/desktop_capturer.h"
2018-10-18 10:19:30 +00:00
+
+namespace webrtc {
+
+class PipeWireType {
+ public:
+ spa_type_media_type media_type;
+ spa_type_media_subtype media_subtype;
+ spa_type_format_video format_video;
+ spa_type_video_format video_format;
+};
+
+class BaseCapturerPipeWire : public DesktopCapturer {
+ public:
+ enum CaptureSourceType { Screen = 1, Window };
+
+ explicit BaseCapturerPipeWire(CaptureSourceType source_type);
+ ~BaseCapturerPipeWire() override;
+
+ // DesktopCapturer interface.
+ void Start(Callback* delegate) override;
+ void CaptureFrame() override;
+ bool GetSourceList(SourceList* sources) override;
+ bool SelectSource(SourceId id) override;
+
+ private:
+ // PipeWire types -->
+ pw_core* pw_core_ = nullptr;
+ pw_type* pw_core_type_ = nullptr;
+ pw_stream* pw_stream_ = nullptr;
+ pw_remote* pw_remote_ = nullptr;
+ pw_loop* pw_loop_ = nullptr;
+ pw_thread_loop* pw_main_loop_ = nullptr;
+ PipeWireType* pw_type_ = nullptr;
+
+ spa_hook spa_stream_listener_ = {};
+ spa_hook spa_remote_listener_ = {};
+
+ pw_stream_events pw_stream_events_ = {};
+ pw_remote_events pw_remote_events_ = {};
+
+ spa_video_info_raw* spa_video_format_ = nullptr;
+
+ gint32 pw_fd_ = -1;
+
+ CaptureSourceType capture_source_type_ =
+ BaseCapturerPipeWire::CaptureSourceType::Screen;
+
+ // <-- end of PipeWire types
+
+ GDBusConnection* connection_ = nullptr;
+ GDBusProxy* proxy_ = nullptr;
+ gchar* portal_handle_ = nullptr;
+ gchar* session_handle_ = nullptr;
+ gchar* sources_handle_ = nullptr;
+ gchar* start_handle_ = nullptr;
+ guint session_request_signal_id_ = 0;
+ guint sources_request_signal_id_ = 0;
+ guint start_request_signal_id_ = 0;
+
+ DesktopSize desktop_size_ = {};
+ DesktopCaptureOptions options_ = {};
+
+ uint8_t* current_frame_ = nullptr;
+ Callback* callback_ = nullptr;
+
+ bool portal_init_failed_ = false;
+
+ void InitPortals();
+ void InitPipeWire();
+ void InitPipeWireTypes();
+
+ void CreateReceivingStream();
+ void HandleBuffer(pw_buffer* buffer);
+
+ void ConvertRGBxToBGRx(uint8_t* frame, uint32_t size);
+
+ static void OnStateChanged(void* data,
+ pw_remote_state old_state,
+ pw_remote_state state,
+ const char* error);
+ static void OnStreamStateChanged(void* data,
+ pw_stream_state old_state,
+ pw_stream_state state,
+ const char* error_message);
+
+ static void OnStreamFormatChanged(void* data, const struct spa_pod* format);
+ static void OnStreamProcess(void* data);
+ static void OnNewBuffer(void* data, uint32_t id);
+
+ guint SetupRequestResponseSignal(const gchar* object_path,
+ GDBusSignalCallback callback);
+
+ static void OnProxyRequested(GObject* object,
+ GAsyncResult* result,
+ gpointer user_data);
+
+ static gchar* PrepareSignalHandle(GDBusConnection* connection,
+ const gchar* token);
+
+ void SessionRequest();
+ static void OnSessionRequested(GDBusConnection* connection,
+ GAsyncResult* result,
+ gpointer user_data);
+ static void OnSessionRequestResponseSignal(GDBusConnection* connection,
+ const gchar* sender_name,
+ const gchar* object_path,
+ const gchar* interface_name,
+ const gchar* signal_name,
+ GVariant* parameters,
+ gpointer user_data);
+
+ void SourcesRequest();
+ static void OnSourcesRequested(GDBusConnection* connection,
+ GAsyncResult* result,
+ gpointer user_data);
+ static void OnSourcesRequestResponseSignal(GDBusConnection* connection,
+ const gchar* sender_name,
+ const gchar* object_path,
+ const gchar* interface_name,
+ const gchar* signal_name,
+ GVariant* parameters,
+ gpointer user_data);
+
+ void StartRequest();
+ static void OnStartRequested(GDBusConnection* connection,
+ GAsyncResult* result,
+ gpointer user_data);
+ static void OnStartRequestResponseSignal(GDBusConnection* connection,
+ const gchar* sender_name,
+ const gchar* object_path,
+ const gchar* interface_name,
+ const gchar* signal_name,
+ GVariant* parameters,
+ gpointer user_data);
+
+ void OpenPipeWireRemote();
+ static void OnOpenPipeWireRemoteRequested(GDBusConnection* connection,
+ GAsyncResult* result,
+ gpointer user_data);
+
+ RTC_DISALLOW_COPY_AND_ASSIGN(BaseCapturerPipeWire);
+};
+
+} // namespace webrtc
+
+#endif // MODULES_DESKTOP_CAPTURE_BASE_CAPTURER_PIPEWIRE_H_
2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build.firefox-pipewire 2019-03-12 01:22:20.000000000 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_generic_gn/moz.build 2019-03-12 15:27:37.676285720 +0100
2019-01-30 13:03:47 +00:00
@@ -152,10 +152,10 @@ if CONFIG["OS_TARGET"] == "FreeBSD":
"/media/webrtc/trunk/webrtc/modules/desktop_capture/x11/x_server_pixel_buffer.cc"
]
+# Common Linux stuff between X11 and PipeWire
2019-01-30 13:03:47 +00:00
if CONFIG["OS_TARGET"] == "Linux":
DEFINES["USE_NSS_CERTS"] = "1"
- DEFINES["USE_X11"] = "1"
DEFINES["WEBRTC_LINUX"] = True
DEFINES["WEBRTC_POSIX"] = True
DEFINES["_FILE_OFFSET_BITS"] = "64"
2019-03-13 08:21:33 +00:00
@@ -175,6 +175,18 @@ if CONFIG["OS_TARGET"] == "Linux":
2019-01-30 13:03:47 +00:00
]
2019-03-13 08:21:33 +00:00
UNIFIED_SOURCES += [
+ "/media/webrtc/trunk/webrtc/modules/desktop_capture/app_capturer_linux.cc",
+ "/media/webrtc/trunk/webrtc/modules/desktop_capture/mouse_cursor_monitor_linux.cc",
+ "/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_linux.cc",
+ "/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_linux.cc",
+ ]
+
+# X11 specific files
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["USE_X11"] = "1"
+
2019-03-13 08:21:33 +00:00
+ UNIFIED_SOURCES += [
2019-01-30 13:03:47 +00:00
"/media/webrtc/trunk/webrtc/modules/desktop_capture/app_capturer_x11.cc",
"/media/webrtc/trunk/webrtc/modules/desktop_capture/mouse_cursor_monitor_x11.cc",
2019-03-13 08:21:33 +00:00
"/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_x11.cc",
2019-01-30 13:03:47 +00:00
@@ -189,6 +201,27 @@ if CONFIG["OS_TARGET"] == "Linux":
"/media/webrtc/trunk/webrtc/modules/desktop_capture/x11/x_server_pixel_buffer.cc"
]
+# PipeWire specific files
+if CONFIG["OS_TARGET"] == "Linux":
+
+ DEFINES["WEBRTC_USE_PIPEWIRE"] = "1"
+
+ OS_LIBS += [
+ "rt",
+ "pipewire-0.2",
+ "glib-2.0",
+ "gio-2.0",
+ "gobject-2.0"
+ ]
+
+ CXXFLAGS += CONFIG['TK_CFLAGS']
+
+ UNIFIED_SOURCES += [
+ "/media/webrtc/trunk/webrtc/modules/desktop_capture/base_capturer_pipewire.cc",
+ "/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_pipewire.cc",
+ "/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_pipewire.cc"
+ ]
+
2019-01-30 13:03:47 +00:00
if CONFIG["OS_TARGET"] == "NetBSD":
DEFINES["USE_X11"] = "1"
2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_options.h.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_options.h
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_options.h.firefox-pipewire 2019-03-12 01:22:21.000000000 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capture_options.h 2019-03-12 15:27:37.677285729 +0100
2019-01-30 13:03:47 +00:00
@@ -113,6 +113,11 @@ class DesktopCaptureOptions {
}
#endif
+#if defined(WEBRTC_USE_PIPEWIRE)
+ bool allow_pipewire() const { return allow_pipewire_; }
+ void set_allow_pipewire(bool allow) { allow_pipewire_ = allow; }
+#endif
+
private:
#if defined(USE_X11)
rtc::scoped_refptr<SharedXDisplay> x_display_;
2019-01-30 13:03:47 +00:00
@@ -135,6 +140,9 @@ class DesktopCaptureOptions {
#endif
bool disable_effects_ = true;
bool detect_updated_region_ = false;
+#if defined(WEBRTC_USE_PIPEWIRE)
+ bool allow_pipewire_ = true;
+#endif
};
} // namespace webrtc
2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capturer.cc.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capturer.cc
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capturer.cc.firefox-pipewire 2019-03-12 01:22:21.000000000 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capturer.cc 2019-03-12 15:27:37.677285729 +0100
@@ -70,4 +70,17 @@ std::unique_ptr<DesktopCapturer> Desktop
2018-10-18 10:19:30 +00:00
return capturer;
}
+#if defined(WEBRTC_USE_PIPEWIRE) || defined(USE_X11)
2018-10-18 10:19:30 +00:00
+bool DesktopCapturer::IsRunningUnderWayland() {
+ const char* xdg_session_type = getenv("XDG_SESSION_TYPE");
+ if (!xdg_session_type || strncmp(xdg_session_type, "wayland", 7) != 0)
+ return false;
+
+ if (!(getenv("WAYLAND_DISPLAY")))
+ return false;
+
+ return true;
+}
+#endif
+
} // namespace webrtc
2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capturer.h.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capturer.h
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capturer.h.firefox-pipewire 2019-03-12 01:22:20.000000000 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/desktop_capturer.h 2019-03-12 15:27:37.677285729 +0100
@@ -139,6 +139,10 @@ class DesktopCapturer {
2018-10-18 10:19:30 +00:00
static std::unique_ptr<DesktopCapturer> CreateAppCapturer(
const DesktopCaptureOptions& options);
+#if defined(WEBRTC_USE_PIPEWIRE) || defined(USE_X11)
2018-10-18 10:19:30 +00:00
+ static bool IsRunningUnderWayland();
+#endif
+
protected:
// CroppingWindowCapturer needs to create raw capturers without wrappers, so
// the following two functions are protected.
2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/mouse_cursor_monitor_linux.cc.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/mouse_cursor_monitor_linux.cc
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/mouse_cursor_monitor_linux.cc.firefox-pipewire 2019-03-12 15:27:37.677285729 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/mouse_cursor_monitor_linux.cc 2019-03-12 15:27:37.677285729 +0100
@@ -0,0 +1,40 @@
2018-10-18 10:19:30 +00:00
+/*
+ * Copyright (c) 2018 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.
+ */
+
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/mouse_cursor_monitor.h"
2018-10-18 10:19:30 +00:00
+
+#if defined(USE_X11)
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/mouse_cursor_monitor_x11.h"
2018-10-18 10:19:30 +00:00
+#endif // defined(USE_X11)
+
+namespace webrtc {
+
+// static
+MouseCursorMonitor* MouseCursorMonitor::CreateForWindow(
+ const DesktopCaptureOptions& options, WindowId window) {
+#if defined(USE_X11)
+ return MouseCursorMonitorX11::CreateForWindow(options, window);
+#else
+ return nullptr;
+#endif // defined(USE_X11)
+}
+
+// static
+MouseCursorMonitor* MouseCursorMonitor::CreateForScreen(
+ const DesktopCaptureOptions& options,
+ ScreenId screen) {
+#if defined(USE_X11)
+ return MouseCursorMonitorX11::CreateForScreen(options, screen);
+#else
+ return nullptr;
+#endif // defined(USE_X11)
+}
+
+} // namespace webrtc
2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/mouse_cursor_monitor_x11.cc.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/mouse_cursor_monitor_x11.cc
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/mouse_cursor_monitor_x11.cc.firefox-pipewire 2019-03-12 01:22:21.000000000 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/mouse_cursor_monitor_x11.cc 2019-03-12 15:27:37.678285739 +0100
@@ -16,6 +16,8 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/mouse_cursor_monitor_x11.h"
+
2019-01-30 13:03:47 +00:00
#include "modules/desktop_capture/desktop_capture_options.h"
#include "modules/desktop_capture/desktop_capture_types.h"
#include "modules/desktop_capture/desktop_frame.h"
2019-03-13 08:21:33 +00:00
@@ -60,37 +62,6 @@ Window GetTopLevelWindow(Display* displa
2018-10-18 10:19:30 +00:00
namespace webrtc {
-class MouseCursorMonitorX11 : public MouseCursorMonitor,
- public SharedXDisplay::XEventHandler {
- public:
- MouseCursorMonitorX11(const DesktopCaptureOptions& options, Window window, Window inner_window);
- ~MouseCursorMonitorX11() override;
-
2019-01-30 13:03:47 +00:00
- void Init(Callback* callback, Mode mode) override;
- void Capture() override;
-
- private:
- // SharedXDisplay::XEventHandler interface.
- bool HandleXEvent(const XEvent& event) override;
-
- Display* display() { return x_display_->display(); }
-
- // Captures current cursor shape and stores it in |cursor_shape_|.
- void CaptureCursor();
-
- rtc::scoped_refptr<SharedXDisplay> x_display_;
- Callback* callback_;
- Mode mode_;
- Window window_;
- Window inner_window_;
-
- bool have_xfixes_;
- int xfixes_event_base_;
- int xfixes_error_base_;
-
- std::unique_ptr<MouseCursor> cursor_shape_;
-};
-
MouseCursorMonitorX11::MouseCursorMonitorX11(
2018-10-18 10:19:30 +00:00
const DesktopCaptureOptions& options,
Window window, Window inner_window)
2019-03-13 08:21:33 +00:00
@@ -257,7 +228,7 @@ void MouseCursorMonitorX11::CaptureCurso
2018-10-18 10:19:30 +00:00
}
// static
-MouseCursorMonitor* MouseCursorMonitor::CreateForWindow(
+MouseCursorMonitor* MouseCursorMonitorX11::CreateForWindow(
const DesktopCaptureOptions& options, WindowId window) {
if (!options.x_display())
return NULL;
2019-03-13 08:21:33 +00:00
@@ -267,7 +238,7 @@ MouseCursorMonitor* MouseCursorMonitor::
2018-10-18 10:19:30 +00:00
return new MouseCursorMonitorX11(options, outer_window, window);
}
-MouseCursorMonitor* MouseCursorMonitor::CreateForScreen(
+MouseCursorMonitor* MouseCursorMonitorX11::CreateForScreen(
const DesktopCaptureOptions& options,
ScreenId screen) {
if (!options.x_display())
2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/mouse_cursor_monitor_x11.h.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/mouse_cursor_monitor_x11.h
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/mouse_cursor_monitor_x11.h.firefox-pipewire 2019-03-12 15:27:37.678285739 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/mouse_cursor_monitor_x11.h 2019-03-13 08:06:28.525517995 +0100
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2018 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_MOUSE_CURSOR_MONITOR_X11_H_
+#define MODULES_DESKTOP_CAPTURE_MOUSE_CURSOR_MONITOR_X11_H_
+
+#include <X11/X.h>
+#include <memory>
+
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/desktop_capture_options.h"
+#include "modules/desktop_capture/desktop_capture_types.h"
+#include "modules/desktop_capture/x11/shared_x_display.h"
+#include "modules/desktop_capture/mouse_cursor.h"
+#include "modules/desktop_capture/mouse_cursor_monitor.h"
+#include "rtc_base/scoped_ref_ptr.h"
+
+namespace webrtc {
+
+class MouseCursorMonitorX11 : public MouseCursorMonitor,
+ public SharedXDisplay::XEventHandler {
+ public:
+ MouseCursorMonitorX11(const DesktopCaptureOptions& options, Window window, Window inner_window);
+ ~MouseCursorMonitorX11() override;
+
2019-01-30 13:03:47 +00:00
+ void Init(Callback* callback, Mode mode) override;
+ void Capture() override;
+
+ static MouseCursorMonitor* CreateForWindow(const DesktopCaptureOptions& options, WindowId window);
+ static MouseCursorMonitor* CreateForScreen(const DesktopCaptureOptions& options, ScreenId screen);
+
+ private:
+ // SharedXDisplay::XEventHandler interface.
+ bool HandleXEvent(const XEvent& event) override;
+
+ Display* display() { return x_display_->display(); }
+
+ // Captures current cursor shape and stores it in |cursor_shape_|.
+ void CaptureCursor();
+
+ rtc::scoped_refptr<SharedXDisplay> x_display_;
+ Callback* callback_;
+ Mode mode_;
+ Window window_;
+ Window inner_window_;
+
+ bool have_xfixes_;
+ int xfixes_event_base_;
+ int xfixes_error_base_;
+
+ std::unique_ptr<MouseCursor> cursor_shape_;
+};
+
+} // namespace webrtc
+
+#endif // MODULES_DESKTOP_CAPTURE_MOUSE_CURSOR_MONITOR_X11_H_
2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_linux.cc.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_linux.cc
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_linux.cc.firefox-pipewire 2019-03-12 15:27:37.678285739 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_linux.cc 2019-03-12 15:27:37.678285739 +0100
2018-10-18 10:19:30 +00:00
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2018 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.
+ */
+
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/desktop_capture_options.h"
+#include "modules/desktop_capture/desktop_capturer.h"
+
+#if defined(WEBRTC_USE_PIPEWIRE)
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/screen_capturer_pipewire.h"
+#endif // defined(WEBRTC_USE_PIPEWIRE)
+
2018-10-18 10:19:30 +00:00
+#if defined(USE_X11)
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/screen_capturer_x11.h"
2018-10-18 10:19:30 +00:00
+#endif // defined(USE_X11)
+
2018-10-18 10:19:30 +00:00
+namespace webrtc {
+
+// static
2018-10-18 10:19:30 +00:00
+std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer(
+ const DesktopCaptureOptions& options) {
+#if defined(WEBRTC_USE_PIPEWIRE)
+ if (options.allow_pipewire() && DesktopCapturer::IsRunningUnderWayland()) {
2018-10-18 10:19:30 +00:00
+ return ScreenCapturerPipeWire::CreateRawScreenCapturer(options);
+ }
+#endif // defined(WEBRTC_USE_PIPEWIRE)
+
2018-10-18 10:19:30 +00:00
+#if defined(USE_X11)
+ return ScreenCapturerX11::CreateRawScreenCapturer(options);
+#endif // defined(USE_X11)
+
2018-10-18 10:19:30 +00:00
+ return nullptr;
+}
+
2018-10-18 10:19:30 +00:00
+} // namespace webrtc
2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_pipewire.cc.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_pipewire.cc
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_pipewire.cc.firefox-pipewire 2019-03-12 15:27:37.678285739 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_pipewire.cc 2019-03-12 15:27:37.678285739 +0100
2018-10-18 10:19:30 +00:00
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2018 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.
+ */
+
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/screen_capturer_pipewire.h"
+
2018-10-18 10:19:30 +00:00
+#include <memory>
+
2018-10-18 10:19:30 +00:00
+namespace webrtc {
+
2018-10-18 10:19:30 +00:00
+ScreenCapturerPipeWire::ScreenCapturerPipeWire()
+ : BaseCapturerPipeWire(BaseCapturerPipeWire::CaptureSourceType::Screen) {}
+ScreenCapturerPipeWire::~ScreenCapturerPipeWire() {}
+
+// static
+std::unique_ptr<DesktopCapturer>
+ScreenCapturerPipeWire::CreateRawScreenCapturer(
+ const DesktopCaptureOptions& options) {
+ std::unique_ptr<ScreenCapturerPipeWire> capturer(
+ new ScreenCapturerPipeWire());
+
+ return std::move(capturer);
+}
+
+} // namespace webrtc
2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_pipewire.h.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_pipewire.h
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_pipewire.h.firefox-pipewire 2019-03-12 15:27:37.679285748 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_pipewire.h 2019-03-12 15:27:37.679285748 +0100
2018-10-18 10:19:30 +00:00
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2018 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_SCREEN_CAPTURER_PIPEWIRE_H_
+#define MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_PIPEWIRE_H_
2018-10-18 10:19:30 +00:00
+
+#include <memory>
+
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/base_capturer_pipewire.h"
2018-10-18 10:19:30 +00:00
+
+namespace webrtc {
+
+class ScreenCapturerPipeWire : public BaseCapturerPipeWire {
+ public:
+ ScreenCapturerPipeWire();
+ ~ScreenCapturerPipeWire() override;
+
+ static std::unique_ptr<DesktopCapturer> CreateRawScreenCapturer(
+ const DesktopCaptureOptions& options);
+
+ RTC_DISALLOW_COPY_AND_ASSIGN(ScreenCapturerPipeWire);
+};
+
+} // namespace webrtc
+
+#endif // MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_PIPEWIRE_H_
2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_x11.cc.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_x11.cc
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_x11.cc.firefox-pipewire 2019-03-12 01:22:21.000000000 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_x11.cc 2019-03-12 15:27:37.679285748 +0100
@@ -19,6 +19,8 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/screen_capturer_x11.h"
+
2019-01-30 13:03:47 +00:00
#include "modules/desktop_capture/desktop_capture_options.h"
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_frame.h"
2019-03-13 08:21:33 +00:00
@@ -32,99 +34,12 @@
2019-01-30 13:03:47 +00:00
#include "rtc_base/timeutils.h"
2018-10-18 10:19:30 +00:00
namespace webrtc {
-namespace {
-
-// A class to perform video frame capturing for Linux.
-//
-// If XDamage is used, this class sets DesktopFrame::updated_region() according
-// to the areas reported by XDamage. Otherwise this class does not detect
-// DesktopFrame::updated_region(), the field is always set to the entire frame
-// rectangle. ScreenCapturerDifferWrapper should be used if that functionality
-// is necessary.
-class ScreenCapturerLinux : public DesktopCapturer,
- public SharedXDisplay::XEventHandler {
- public:
- ScreenCapturerLinux();
- ~ScreenCapturerLinux() override;
-
- // TODO(ajwong): Do we really want this to be synchronous?
- bool Init(const DesktopCaptureOptions& options);
-
- // DesktopCapturer interface.
- void Start(Callback* delegate) override;
- void CaptureFrame() override;
- bool GetSourceList(SourceList* sources) override;
- bool SelectSource(SourceId id) override;
-
- private:
- Display* display() { return options_.x_display()->display(); }
-
- // SharedXDisplay::XEventHandler interface.
- bool HandleXEvent(const XEvent& event) override;
-
- void InitXDamage();
-
- // Capture screen pixels to the current buffer in the queue. In the DAMAGE
- // case, the ScreenCapturerHelper already holds the list of invalid rectangles
- // from HandleXEvent(). In the non-DAMAGE case, this captures the
- // whole screen, then calculates some invalid rectangles that include any
- // differences between this and the previous capture.
- std::unique_ptr<DesktopFrame> CaptureScreen();
-
- // Called when the screen configuration is changed.
- void ScreenConfigurationChanged();
-
- // Synchronize the current buffer with |last_buffer_|, by copying pixels from
- // the area of |last_invalid_rects|.
- // Note this only works on the assumption that kNumBuffers == 2, as
- // |last_invalid_rects| holds the differences from the previous buffer and
- // the one prior to that (which will then be the current buffer).
- void SynchronizeFrame();
-
- void DeinitXlib();
-
- DesktopCaptureOptions options_;
-
- Callback* callback_ = nullptr;
-
- // X11 graphics context.
- GC gc_ = nullptr;
- Window root_window_ = BadValue;
-
- // XFixes.
- bool has_xfixes_ = false;
- int xfixes_event_base_ = -1;
- int xfixes_error_base_ = -1;
-
- // XDamage information.
- bool use_damage_ = false;
- Damage damage_handle_ = 0;
- int damage_event_base_ = -1;
- int damage_error_base_ = -1;
- XserverRegion damage_region_ = 0;
-
- // Access to the X Server's pixel buffer.
- XServerPixelBuffer x_server_pixel_buffer_;
-
- // A thread-safe list of invalid rectangles, and the size of the most
- // recently captured screen.
- ScreenCapturerHelper helper_;
-
- // Queue of the frames buffers.
- ScreenCaptureFrameQueue<SharedDesktopFrame> queue_;
-
- // Invalid region from the previous capture. This is used to synchronize the
- // current with the last buffer used.
- DesktopRegion last_invalid_region_;
2019-03-13 08:21:33 +00:00
- RTC_DISALLOW_COPY_AND_ASSIGN(ScreenCapturerLinux);
-};
2019-01-30 13:03:47 +00:00
-
-ScreenCapturerLinux::ScreenCapturerLinux() {
+ScreenCapturerX11::ScreenCapturerX11() {
helper_.SetLogGridSize(4);
}
2018-10-18 10:19:30 +00:00
-ScreenCapturerLinux::~ScreenCapturerLinux() {
+ScreenCapturerX11::~ScreenCapturerX11() {
options_.x_display()->RemoveEventHandler(ConfigureNotify, this);
if (use_damage_) {
options_.x_display()->RemoveEventHandler(
2019-03-13 08:21:33 +00:00
@@ -133,7 +48,7 @@ ScreenCapturerLinux::~ScreenCapturerLinu
DeinitXlib();
}
2018-10-18 10:19:30 +00:00
-bool ScreenCapturerLinux::Init(const DesktopCaptureOptions& options) {
+bool ScreenCapturerX11::Init(const DesktopCaptureOptions& options) {
options_ = options;
2018-10-18 10:19:30 +00:00
root_window_ = RootWindow(display(), DefaultScreen(display()));
2019-03-13 08:21:33 +00:00
@@ -176,7 +91,7 @@ bool ScreenCapturerLinux::Init(const Des
return true;
}
2018-10-18 10:19:30 +00:00
-void ScreenCapturerLinux::InitXDamage() {
+void ScreenCapturerX11::InitXDamage() {
// Our use of XDamage requires XFixes.
if (!has_xfixes_) {
return;
2019-03-13 08:21:33 +00:00
@@ -217,14 +132,14 @@ void ScreenCapturerLinux::InitXDamage()
2019-01-30 13:03:47 +00:00
RTC_LOG(LS_INFO) << "Using XDamage extension.";
}
2018-10-18 10:19:30 +00:00
-void ScreenCapturerLinux::Start(Callback* callback) {
+void ScreenCapturerX11::Start(Callback* callback) {
RTC_DCHECK(!callback_);
RTC_DCHECK(callback);
2018-10-18 10:19:30 +00:00
callback_ = callback;
}
2018-10-18 10:19:30 +00:00
-void ScreenCapturerLinux::CaptureFrame() {
+void ScreenCapturerX11::CaptureFrame() {
int64_t capture_start_time_nanos = rtc::TimeNanos();
2018-10-18 10:19:30 +00:00
queue_.MoveToNextFrame();
2019-03-13 08:21:33 +00:00
@@ -238,6 +153,7 @@ void ScreenCapturerLinux::CaptureFrame()
// in a good shape.
if (!x_server_pixel_buffer_.is_initialized()) {
// We failed to initialize pixel buffer.
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_ERROR) << "Pixel buffer is not initialized.";
callback_->OnCaptureResult(Result::ERROR_PERMANENT, nullptr);
return;
}
2019-03-13 08:21:33 +00:00
@@ -253,6 +169,7 @@ void ScreenCapturerLinux::CaptureFrame()
2018-10-18 10:19:30 +00:00
std::unique_ptr<DesktopFrame> result = CaptureScreen();
if (!result) {
2019-01-30 13:03:47 +00:00
+ RTC_LOG(LS_WARNING) << "Temporarily failed to capture screen.";
callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr);
return;
}
2019-03-13 08:21:33 +00:00
@@ -263,19 +180,19 @@ void ScreenCapturerLinux::CaptureFrame()
callback_->OnCaptureResult(Result::SUCCESS, std::move(result));
}
2018-10-18 10:19:30 +00:00
-bool ScreenCapturerLinux::GetSourceList(SourceList* sources) {
+bool ScreenCapturerX11::GetSourceList(SourceList* sources) {
RTC_DCHECK(sources->size() == 0);
// TODO(jiayl): implement screen enumeration.
sources->push_back({0});
return true;
}
2018-10-18 10:19:30 +00:00
-bool ScreenCapturerLinux::SelectSource(SourceId id) {
+bool ScreenCapturerX11::SelectSource(SourceId id) {
// TODO(jiayl): implement screen selection.
return true;
}
2018-10-18 10:19:30 +00:00
-bool ScreenCapturerLinux::HandleXEvent(const XEvent& event) {
+bool ScreenCapturerX11::HandleXEvent(const XEvent& event) {
if (use_damage_ && (event.type == damage_event_base_ + XDamageNotify)) {
const XDamageNotifyEvent* damage_event =
reinterpret_cast<const XDamageNotifyEvent*>(&event);
2019-03-13 08:21:33 +00:00
@@ -290,7 +207,7 @@ bool ScreenCapturerLinux::HandleXEvent(c
return false;
}
2018-10-18 10:19:30 +00:00
-std::unique_ptr<DesktopFrame> ScreenCapturerLinux::CaptureScreen() {
+std::unique_ptr<DesktopFrame> ScreenCapturerX11::CaptureScreen() {
std::unique_ptr<SharedDesktopFrame> frame = queue_.current_frame()->Share();
RTC_DCHECK(x_server_pixel_buffer_.window_size().equals(frame->size()));
2018-10-18 10:19:30 +00:00
2019-03-13 08:21:33 +00:00
@@ -348,7 +265,7 @@ std::unique_ptr<DesktopFrame> ScreenCapt
return std::move(frame);
}
2018-10-18 10:19:30 +00:00
-void ScreenCapturerLinux::ScreenConfigurationChanged() {
+void ScreenCapturerX11::ScreenConfigurationChanged() {
// Make sure the frame buffers will be reallocated.
queue_.Reset();
2018-10-18 10:19:30 +00:00
2019-03-13 08:21:33 +00:00
@@ -359,7 +276,7 @@ void ScreenCapturerLinux::ScreenConfigur
}
}
2018-10-18 10:19:30 +00:00
-void ScreenCapturerLinux::SynchronizeFrame() {
+void ScreenCapturerX11::SynchronizeFrame() {
// Synchronize the current buffer with the previous one since we do not
// capture the entire desktop. Note that encoder may be reading from the
// previous buffer at this time so thread access complaints are false
2019-03-13 08:21:33 +00:00
@@ -379,7 +296,7 @@ void ScreenCapturerLinux::SynchronizeFra
}
}
2018-10-18 10:19:30 +00:00
-void ScreenCapturerLinux::DeinitXlib() {
+void ScreenCapturerX11::DeinitXlib() {
if (gc_) {
XFreeGC(display(), gc_);
gc_ = nullptr;
2019-03-13 08:21:33 +00:00
@@ -400,15 +317,13 @@ void ScreenCapturerLinux::DeinitXlib() {
}
}
2018-10-18 10:19:30 +00:00
-} // namespace
-
// static
-std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer(
+std::unique_ptr<DesktopCapturer> ScreenCapturerX11::CreateRawScreenCapturer(
const DesktopCaptureOptions& options) {
if (!options.x_display())
return nullptr;
2018-10-18 10:19:30 +00:00
- std::unique_ptr<ScreenCapturerLinux> capturer(new ScreenCapturerLinux());
+ std::unique_ptr<ScreenCapturerX11> capturer(new ScreenCapturerX11());
if (!capturer.get()->Init(options)) {
return nullptr;
}
2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_x11.h.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_x11.h
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_x11.h.firefox-pipewire 2019-03-12 15:27:37.679285748 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/screen_capturer_x11.h 2019-03-13 08:06:40.412607602 +0100
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2018 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_SCREEN_CAPTURER_X11_H_
+#define MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_X11_H_
+
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/Xdamage.h>
+#include <X11/extensions/Xfixes.h>
+#include <memory>
+
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/desktop_capture_options.h"
+#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/x11/shared_x_display.h"
+#include "modules/desktop_capture/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"
+#include "rtc_base/constructormagic.h"
+
+namespace webrtc {
+
+// A class to perform video frame capturing for Linux on X11.
+//
+// If XDamage is used, this class sets DesktopFrame::updated_region() according
+// to the areas reported by XDamage. Otherwise this class does not detect
+// DesktopFrame::updated_region(), the field is always set to the entire frame
+// rectangle. ScreenCapturerDifferWrapper should be used if that functionality
+// is necessary.
+class ScreenCapturerX11 : public DesktopCapturer,
+ public SharedXDisplay::XEventHandler {
+ public:
+ ScreenCapturerX11();
+ ~ScreenCapturerX11() override;
+
+ static std::unique_ptr<DesktopCapturer> CreateRawScreenCapturer(const DesktopCaptureOptions& options);
+
+ // TODO(ajwong): Do we really want this to be synchronous?
+ bool Init(const DesktopCaptureOptions& options);
+
+ // DesktopCapturer interface.
+ void Start(Callback* delegate) override;
+ void CaptureFrame() override;
+ bool GetSourceList(SourceList* sources) override;
+ bool SelectSource(SourceId id) override;
+
+ private:
+ Display* display() { return options_.x_display()->display(); }
+
+ // SharedXDisplay::XEventHandler interface.
+ bool HandleXEvent(const XEvent& event) override;
+
+ void InitXDamage();
+
+ // Capture screen pixels to the current buffer in the queue. In the DAMAGE
+ // case, the ScreenCapturerHelper already holds the list of invalid rectangles
+ // from HandleXEvent(). In the non-DAMAGE case, this captures the
+ // whole screen, then calculates some invalid rectangles that include any
+ // differences between this and the previous capture.
+ std::unique_ptr<DesktopFrame> CaptureScreen();
+
+ // Called when the screen configuration is changed.
+ void ScreenConfigurationChanged();
+
+ // Synchronize the current buffer with |last_buffer_|, by copying pixels from
+ // the area of |last_invalid_rects|.
+ // Note this only works on the assumption that kNumBuffers == 2, as
+ // |last_invalid_rects| holds the differences from the previous buffer and
+ // the one prior to that (which will then be the current buffer).
+ void SynchronizeFrame();
+
+ void DeinitXlib();
+
+ DesktopCaptureOptions options_;
+
+ Callback* callback_ = nullptr;
+
+ // X11 graphics context.
+ GC gc_ = nullptr;
+ Window root_window_ = BadValue;
+
+ // XFixes.
+ bool has_xfixes_ = false;
+ int xfixes_event_base_ = -1;
+ int xfixes_error_base_ = -1;
+
+ // XDamage information.
+ bool use_damage_ = false;
+ Damage damage_handle_ = 0;
+ int damage_event_base_ = -1;
+ int damage_error_base_ = -1;
+ XserverRegion damage_region_ = 0;
+
+ // Access to the X Server's pixel buffer.
+ XServerPixelBuffer x_server_pixel_buffer_;
+
+ // A thread-safe list of invalid rectangles, and the size of the most
+ // recently captured screen.
+ ScreenCapturerHelper helper_;
+
+ // Queue of the frames buffers.
+ ScreenCaptureFrameQueue<SharedDesktopFrame> queue_;
+
+ // Invalid region from the previous capture. This is used to synchronize the
+ // current with the last buffer used.
+ DesktopRegion last_invalid_region_;
+
+ RTC_DISALLOW_COPY_AND_ASSIGN(ScreenCapturerX11);
+};
+
+} // namespace webrtc
+
+#endif // MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_X11_H_
2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_linux.cc.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_linux.cc
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_linux.cc.firefox-pipewire 2019-03-12 15:27:37.679285748 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_linux.cc 2019-03-12 15:27:37.679285748 +0100
@@ -0,0 +1,40 @@
+/*
2018-10-18 10:19:30 +00:00
+ * Copyright 2018 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.
+ */
+
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/desktop_capture_options.h"
+#include "modules/desktop_capture/desktop_capturer.h"
+
+#if defined(WEBRTC_USE_PIPEWIRE)
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/window_capturer_pipewire.h"
+#endif // defined(WEBRTC_USE_PIPEWIRE)
+
+#if defined(USE_X11)
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/window_capturer_x11.h"
2018-10-18 10:19:30 +00:00
+#endif // defined(USE_X11)
+
+namespace webrtc {
+
+// static
+std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawWindowCapturer(
+ const DesktopCaptureOptions& options) {
+#if defined(WEBRTC_USE_PIPEWIRE)
+ if (options.allow_pipewire() && DesktopCapturer::IsRunningUnderWayland()) {
2018-10-18 10:19:30 +00:00
+ return WindowCapturerPipeWire::CreateRawWindowCapturer(options);
+ }
+#endif // defined(WEBRTC_USE_PIPEWIRE)
+
+#if defined(USE_X11)
+ return WindowCapturerX11::CreateRawWindowCapturer(options);
2018-10-18 10:19:30 +00:00
+#endif // defined(USE_X11)
+
+ return nullptr;
+}
+
+} // namespace webrtc
2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_pipewire.cc.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_pipewire.cc
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_pipewire.cc.firefox-pipewire 2019-03-12 15:27:37.680285758 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_pipewire.cc 2019-03-12 15:27:37.680285758 +0100
2018-10-18 10:19:30 +00:00
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2018 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.
+ */
+
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/window_capturer_pipewire.h"
2018-10-18 10:19:30 +00:00
+
+namespace webrtc {
+
+WindowCapturerPipeWire::WindowCapturerPipeWire()
+ : BaseCapturerPipeWire(BaseCapturerPipeWire::CaptureSourceType::Window) {}
+WindowCapturerPipeWire::~WindowCapturerPipeWire() {}
+
+// static
+std::unique_ptr<DesktopCapturer>
+WindowCapturerPipeWire::CreateRawWindowCapturer(
+ const DesktopCaptureOptions& options) {
+ std::unique_ptr<WindowCapturerPipeWire> capturer(
+ new WindowCapturerPipeWire());
+
+ return std::move(capturer);
+}
+} // namespace webrtc
2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_pipewire.h.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_pipewire.h
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_pipewire.h.firefox-pipewire 2019-03-12 15:27:37.680285758 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_pipewire.h 2019-03-12 15:27:37.680285758 +0100
2018-10-18 10:19:30 +00:00
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2018 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_WINDOW_CAPTURER_PIPEWIRE_H_
+#define MODULES_DESKTOP_CAPTURE_WINDOW_CAPTURER_PIPEWIRE_H_
2018-10-18 10:19:30 +00:00
+
+#include <memory>
+
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/base_capturer_pipewire.h"
2018-10-18 10:19:30 +00:00
+
+namespace webrtc {
+
+class WindowCapturerPipeWire : public BaseCapturerPipeWire {
+ public:
+ WindowCapturerPipeWire();
+ ~WindowCapturerPipeWire() override;
+
+ static std::unique_ptr<DesktopCapturer> CreateRawWindowCapturer(
+ const DesktopCaptureOptions& options);
+
+ RTC_DISALLOW_COPY_AND_ASSIGN(WindowCapturerPipeWire);
+};
+
+} // namespace webrtc
+
+#endif // MODULES_DESKTOP_CAPTURE_WINDOW_CAPTURER_PIPEWIRE_H_
2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_x11.cc.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_x11.cc
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_x11.cc.firefox-pipewire 2019-03-12 01:22:21.000000000 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_x11.cc 2019-03-12 15:27:37.680285758 +0100
2019-01-30 13:03:47 +00:00
@@ -16,6 +16,8 @@
2018-10-18 10:19:30 +00:00
2019-01-30 13:03:47 +00:00
#include <utility>
2018-10-18 10:19:30 +00:00
2019-01-30 13:03:47 +00:00
+#include "modules/desktop_capture/window_capturer_x11.h"
+
2019-01-30 13:03:47 +00:00
#include "modules/desktop_capture/desktop_capture_options.h"
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_frame.h"
2019-03-13 08:21:33 +00:00
@@ -32,49 +34,7 @@
2018-10-18 10:19:30 +00:00
namespace webrtc {
2018-10-18 10:19:30 +00:00
-namespace {
-
-class WindowCapturerLinux : public DesktopCapturer,
- public SharedXDisplay::XEventHandler {
- public:
- WindowCapturerLinux(const DesktopCaptureOptions& options);
- ~WindowCapturerLinux() override;
-
- // DesktopCapturer interface.
- void Start(Callback* callback) override;
- void CaptureFrame() override;
- bool GetSourceList(SourceList* sources) override;
- bool SelectSource(SourceId id) override;
- bool FocusOnSelectedSource() override;
2019-01-30 13:03:47 +00:00
- bool IsOccluded(const DesktopVector& pos) override;
-
- // SharedXDisplay::XEventHandler interface.
- bool HandleXEvent(const XEvent& event) override;
-
- private:
- Display* display() { return x_display_->display(); }
-
- // Returns window title for the specified X |window|.
- bool GetWindowTitle(::Window window, std::string* title);
-
- // Returns the id of the owning process.
- int GetWindowProcessID(::Window window);
-
- Callback* callback_ = nullptr;
-
- rtc::scoped_refptr<SharedXDisplay> x_display_;
-
- bool has_composite_extension_ = false;
-
- ::Window selected_window_ = 0;
- XServerPixelBuffer x_server_pixel_buffer_;
2019-01-30 13:03:47 +00:00
- XAtomCache atom_cache_;
- WindowFinderX11 window_finder_;
-
- RTC_DISALLOW_COPY_AND_ASSIGN(WindowCapturerLinux);
-};
-
-WindowCapturerLinux::WindowCapturerLinux(const DesktopCaptureOptions& options)
+WindowCapturerX11::WindowCapturerX11(const DesktopCaptureOptions& options)
2019-01-30 13:03:47 +00:00
: x_display_(options.x_display()),
atom_cache_(display()),
window_finder_(&atom_cache_) {
2019-03-13 08:21:33 +00:00
@@ -91,11 +51,11 @@ WindowCapturerLinux::WindowCapturerLinux
x_display_->AddEventHandler(ConfigureNotify, this);
}
2018-10-18 10:19:30 +00:00
-WindowCapturerLinux::~WindowCapturerLinux() {
+WindowCapturerX11::~WindowCapturerX11() {
x_display_->RemoveEventHandler(ConfigureNotify, this);
}
2018-10-18 10:19:30 +00:00
-bool WindowCapturerLinux::GetSourceList(SourceList* sources) {
+bool WindowCapturerX11::GetSourceList(SourceList* sources) {
2019-01-30 13:03:47 +00:00
return GetWindowList(&atom_cache_,
[this, sources](::Window window) {
Source w;
2019-03-13 08:21:33 +00:00
@@ -108,7 +68,7 @@ bool WindowCapturerLinux::GetSourceList(
2019-01-30 13:03:47 +00:00
});
}
2018-10-18 10:19:30 +00:00
-bool WindowCapturerLinux::SelectSource(SourceId id) {
+bool WindowCapturerX11::SelectSource(SourceId id) {
if (!x_server_pixel_buffer_.Init(display(), id))
return false;
2018-10-18 10:19:30 +00:00
2019-03-13 08:21:33 +00:00
@@ -129,7 +89,7 @@ bool WindowCapturerLinux::SelectSource(S
return true;
}
2018-10-18 10:19:30 +00:00
-bool WindowCapturerLinux::FocusOnSelectedSource() {
+bool WindowCapturerX11::FocusOnSelectedSource() {
if (!selected_window_)
return false;
2018-10-18 10:19:30 +00:00
2019-03-13 08:21:33 +00:00
@@ -178,14 +138,14 @@ bool WindowCapturerLinux::FocusOnSelecte
return true;
}
2018-10-18 10:19:30 +00:00
-void WindowCapturerLinux::Start(Callback* callback) {
+void WindowCapturerX11::Start(Callback* callback) {
2019-01-30 13:03:47 +00:00
RTC_DCHECK(!callback_);
RTC_DCHECK(callback);
2018-10-18 10:19:30 +00:00
callback_ = callback;
}
2018-10-18 10:19:30 +00:00
-void WindowCapturerLinux::CaptureFrame() {
+void WindowCapturerX11::CaptureFrame() {
x_display_->ProcessPendingXEvents();
2018-10-18 10:19:30 +00:00
if (!x_server_pixel_buffer_.IsWindowValid()) {
2019-03-13 08:21:33 +00:00
@@ -228,12 +188,12 @@ void WindowCapturerLinux::CaptureFrame()
callback_->OnCaptureResult(Result::SUCCESS, std::move(frame));
}
2018-10-18 10:19:30 +00:00
2019-01-30 13:03:47 +00:00
-bool WindowCapturerLinux::IsOccluded(const DesktopVector& pos) {
+bool WindowCapturerX11::IsOccluded(const DesktopVector& pos) {
return window_finder_.GetWindowUnderPoint(pos) !=
static_cast<WindowId>(selected_window_);
}
-bool WindowCapturerLinux::HandleXEvent(const XEvent& event) {
+bool WindowCapturerX11::HandleXEvent(const XEvent& event) {
if (event.type == ConfigureNotify) {
XConfigureEvent xce = event.xconfigure;
2019-01-30 13:03:47 +00:00
if (xce.window == selected_window_) {
2019-03-13 08:21:33 +00:00
@@ -251,7 +211,7 @@ bool WindowCapturerLinux::HandleXEvent(c
return false;
}
2018-10-18 10:19:30 +00:00
-bool WindowCapturerLinux::GetWindowTitle(::Window window, std::string* title) {
+bool WindowCapturerX11::GetWindowTitle(::Window window, std::string* title) {
int status;
bool result = false;
XTextProperty window_name;
2019-03-13 08:21:33 +00:00
@@ -280,9 +240,7 @@ bool WindowCapturerLinux::GetWindowTitle
return result;
}
2018-10-18 10:19:30 +00:00
-} // namespace
-
-int WindowCapturerLinux::GetWindowProcessID(::Window window) {
+int WindowCapturerX11::GetWindowProcessID(::Window window) {
// Get _NET_WM_PID property of the window.
Atom process_atom = XInternAtom(display(), "_NET_WM_PID", True);
XWindowProperty<uint32_t> process_id(display(), window, process_atom);
2019-03-13 08:21:33 +00:00
@@ -291,11 +249,11 @@ int WindowCapturerLinux::GetWindowProces
}
2018-10-18 10:19:30 +00:00
// static
-std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawWindowCapturer(
+std::unique_ptr<DesktopCapturer> WindowCapturerX11::CreateRawWindowCapturer(
const DesktopCaptureOptions& options) {
if (!options.x_display())
return nullptr;
- return std::unique_ptr<DesktopCapturer>(new WindowCapturerLinux(options));
+ return std::unique_ptr<DesktopCapturer>(new WindowCapturerX11(options));
}
2018-10-18 10:19:30 +00:00
} // namespace webrtc
2019-03-13 08:21:33 +00:00
diff -up firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_x11.h.firefox-pipewire firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_x11.h
--- firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_x11.h.firefox-pipewire 2019-03-12 15:27:37.680285758 +0100
+++ firefox-66.0/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_x11.h 2019-03-13 08:06:55.974724907 +0100
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2018 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_WINDOW_CAPTURER_X11_H_
+#define MODULES_DESKTOP_CAPTURE_WINDOW_CAPTURER_X11_H_
+
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#include <memory>
+#include <string>
+
2019-01-30 13:03:47 +00:00
+#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/window_finder_x11.h"
+#include "modules/desktop_capture/x11/x_atom_cache.h"
+#include "modules/desktop_capture/x11/shared_x_display.h"
+#include "modules/desktop_capture/x11/x_server_pixel_buffer.h"
+#include "rtc_base/constructormagic.h"
+#include "rtc_base/scoped_ref_ptr.h"
+
+namespace webrtc {
+
+class WindowCapturerX11 : public DesktopCapturer,
+ public SharedXDisplay::XEventHandler {
+ public:
+ explicit WindowCapturerX11(const DesktopCaptureOptions& options);
+ ~WindowCapturerX11() override;
+
+ static std::unique_ptr<DesktopCapturer> CreateRawWindowCapturer(
+ const DesktopCaptureOptions& options);
+
+ // DesktopCapturer interface.
+ void Start(Callback* callback) override;
+ void CaptureFrame() override;
+ bool GetSourceList(SourceList* sources) override;
+ bool SelectSource(SourceId id) override;
+ bool FocusOnSelectedSource() override;
2019-01-30 13:03:47 +00:00
+ bool IsOccluded(const DesktopVector& pos) override;
+
+ // SharedXDisplay::XEventHandler interface.
+ bool HandleXEvent(const XEvent& event) override;
+
+ private:
+ Display* display() { return x_display_->display(); }
+
+ // Returns window title for the specified X |window|.
+ bool GetWindowTitle(::Window window, std::string* title);
+
+ // Returns the id of the owning process.
+ int GetWindowProcessID(::Window window);
+
+ Callback* callback_ = nullptr;
+
+ rtc::scoped_refptr<SharedXDisplay> x_display_;
+
+ bool has_composite_extension_ = false;
+
+ ::Window selected_window_ = 0;
+ XServerPixelBuffer x_server_pixel_buffer_;
2019-01-30 13:03:47 +00:00
+ XAtomCache atom_cache_;
+ WindowFinderX11 window_finder_;
+
+ RTC_DISALLOW_COPY_AND_ASSIGN(WindowCapturerX11);
+};
+
+} // namespace webrtc
+
+#endif // MODULES_DESKTOP_CAPTURE_WINDOW_CAPTURER_X11_H_