This reverts commit 84524e6b196153e35910111f61c36489ec2bd1d7. Reason for revert: https://webrtc-review.googlesource.com/c/src/+/160649/33#message-a83e8959e03a274642ca2ce1abb9ea0099f08097 + suspected in breaking WebRTC to Chromium rolls https://chromium-review.googlesource.com/c/chromium/src/+/2468139 Original change's description: > Improve screen sharing with PipeWire on Wayland > > Currently, sharing a screen or a window on Wayland opens unnecessary > preview dialog on Chromium side, which is then followed by a similar > dialog on xdg-desktop-portal side. The Chromium dialog is useless on > Wayland, as it doesn't show anything. This is because Chromium doesn't > have access to screen content as in case of X11 session. To fix this, we > want to avoid showing the preview dialog in case we find that we run on > Wayland and only pick a screen or a window from the dialog that comes > from xdg-desktop-portal. > > This patch splits BaseCapturerPipeWire class, moving portal related code > into XdgPortalBase, which does all the DBus communication and which is > supposed to be reused by BaseCapturerPipeWire when the user confirms > the dialog from xdg-desktop-portal. The XdgPortalBase is extended to > support multiple calls at once, where each call is identified by Id. > > Relevant change on Chromium side will be in a different review. > > Bug: chromium:682122 > Change-Id: I2bcd07d16a5eb3b902db63ea9a164c5bd39c23a0 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/187492 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Reviewed-by: Tommi <tommi@webrtc.org> > Commit-Queue: Tommi <tommi@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#32388} TBR=mbonadei@webrtc.org,tommi@webrtc.org,sprang@webrtc.org,guidou@webrtc.org,mfoltz@chromium.org,grulja@gmail.com Change-Id: I1a9748ced5626903b12214d677c7b8919c2ac385 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: chromium:682122 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/188380 Reviewed-by: Olga Sharonova <olka@webrtc.org> Commit-Queue: Olga Sharonova <olka@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32398}
169 lines
6.1 KiB
C++
169 lines
6.1 KiB
C++
/*
|
|
* 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_LINUX_BASE_CAPTURER_PIPEWIRE_H_
|
|
#define MODULES_DESKTOP_CAPTURE_LINUX_BASE_CAPTURER_PIPEWIRE_H_
|
|
|
|
#include <gio/gio.h>
|
|
#define typeof __typeof__
|
|
#include <pipewire/pipewire.h>
|
|
#include <spa/param/video/format-utils.h>
|
|
|
|
#include "modules/desktop_capture/desktop_capture_options.h"
|
|
#include "modules/desktop_capture/desktop_capturer.h"
|
|
#include "rtc_base/constructor_magic.h"
|
|
|
|
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;
|
|
GCancellable *cancellable_ = 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 InitPortal();
|
|
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(GDBusProxy *proxy,
|
|
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(GDBusProxy *proxy,
|
|
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(GDBusProxy *proxy,
|
|
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(GDBusProxy *proxy,
|
|
GAsyncResult* result,
|
|
gpointer user_data);
|
|
|
|
RTC_DISALLOW_COPY_AND_ASSIGN(BaseCapturerPipeWire);
|
|
};
|
|
|
|
} // namespace webrtc
|
|
|
|
#endif // MODULES_DESKTOP_CAPTURE_LINUX_BASE_CAPTURER_PIPEWIRE_H_
|