mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-19 00:27:51 +01:00
Reland "Split out generic portal / pipewire code"
This is a reland of commit e6ec81a89c
Updated to ensure that the portal code can be built with is_chromeos.
Original change's description:
> Split out generic portal / pipewire code
>
> It will be reused by the video capture portal / pipewire backend.
>
> Bug: webrtc:13177
> Change-Id: Ia1a77f1c6e289149cd8a1d54b550754bf192e62e
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/263721
> Reviewed-by: Mark Foltz <mfoltz@chromium.org>
> Commit-Queue: Alexander Cooper <alcooper@chromium.org>
> Reviewed-by: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
> Reviewed-by: Salman Malik <salmanmalik@google.com>
> Cr-Commit-Position: refs/heads/main@{#38487}
Bug: webrtc:13177
Change-Id: I2c890c83c86ad60fa30f63dcf6fa90510d46009e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/281661
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#38620}
This commit is contained in:
parent
5f42cdcb31
commit
b21c979691
28 changed files with 445 additions and 334 deletions
|
@ -7,9 +7,7 @@
|
||||||
# be found in the AUTHORS file in the root of the source tree.
|
# be found in the AUTHORS file in the root of the source tree.
|
||||||
|
|
||||||
import("//build/config/linux/gtk/gtk.gni")
|
import("//build/config/linux/gtk/gtk.gni")
|
||||||
import("//build/config/linux/pkg_config.gni")
|
|
||||||
import("//build/config/ui.gni")
|
import("//build/config/ui.gni")
|
||||||
import("//tools/generate_stubs/rules.gni")
|
|
||||||
import("../../webrtc.gni")
|
import("../../webrtc.gni")
|
||||||
|
|
||||||
use_desktop_capture_differ_sse2 = current_cpu == "x86" || current_cpu == "x64"
|
use_desktop_capture_differ_sse2 = current_cpu == "x86" || current_cpu == "x64"
|
||||||
|
@ -84,7 +82,7 @@ if (rtc_include_tests) {
|
||||||
]
|
]
|
||||||
|
|
||||||
if ((is_linux || is_chromeos) && rtc_use_pipewire) {
|
if ((is_linux || is_chromeos) && rtc_use_pipewire) {
|
||||||
configs += [ ":gio" ]
|
configs += [ "../portal:gio" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
public_configs = [ ":x11_config" ]
|
public_configs = [ ":x11_config" ]
|
||||||
|
@ -105,14 +103,7 @@ if (rtc_include_tests) {
|
||||||
"linux/wayland/test/test_screencast_stream_provider.h",
|
"linux/wayland/test/test_screencast_stream_provider.h",
|
||||||
]
|
]
|
||||||
|
|
||||||
configs += [
|
configs += [ "../portal:pipewire_all" ]
|
||||||
":gio",
|
|
||||||
":pipewire",
|
|
||||||
":gbm",
|
|
||||||
":egl",
|
|
||||||
":epoxy",
|
|
||||||
":libdrm",
|
|
||||||
]
|
|
||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
":desktop_capture",
|
":desktop_capture",
|
||||||
|
@ -122,6 +113,7 @@ if (rtc_include_tests) {
|
||||||
"../../rtc_base:logging",
|
"../../rtc_base:logging",
|
||||||
"../../rtc_base:random",
|
"../../rtc_base:random",
|
||||||
"../../rtc_base:timeutils",
|
"../../rtc_base:timeutils",
|
||||||
|
"../portal",
|
||||||
|
|
||||||
# TODO(bugs.webrtc.org/9987): Remove this dep on rtc_base:rtc_base once
|
# TODO(bugs.webrtc.org/9987): Remove this dep on rtc_base:rtc_base once
|
||||||
# rtc_base:threading is fully defined.
|
# rtc_base:threading is fully defined.
|
||||||
|
@ -135,12 +127,8 @@ if (rtc_include_tests) {
|
||||||
"//rtc_base:rtc_event",
|
"//rtc_base:rtc_event",
|
||||||
]
|
]
|
||||||
|
|
||||||
if (!rtc_link_pipewire) {
|
|
||||||
deps += [ ":pipewire_stubs" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
data = [ "../../third_party/pipewire" ]
|
data = [ "../../third_party/pipewire" ]
|
||||||
public_configs = [ ":pipewire_config" ]
|
public_configs = [ "../portal:pipewire_config" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +155,7 @@ if (rtc_include_tests) {
|
||||||
]
|
]
|
||||||
|
|
||||||
if ((is_linux || is_chromeos) && rtc_use_pipewire) {
|
if ((is_linux || is_chromeos) && rtc_use_pipewire) {
|
||||||
configs += [ ":gio" ]
|
configs += [ "../portal:gio" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
|
@ -277,7 +265,7 @@ if (rtc_include_tests) {
|
||||||
]
|
]
|
||||||
|
|
||||||
if ((is_linux || is_chromeos) && rtc_use_pipewire) {
|
if ((is_linux || is_chromeos) && rtc_use_pipewire) {
|
||||||
configs += [ ":gio" ]
|
configs += [ "../portal:gio" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
|
@ -288,71 +276,10 @@ if (rtc_include_tests) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_linux || is_chromeos) {
|
# TODO(bugs.webrtc.org/14187): remove when all users are gone
|
||||||
if (rtc_use_pipewire) {
|
if ((is_linux || is_chromeos) && rtc_use_pipewire) {
|
||||||
pkg_config("gio") {
|
config("pipewire_config") {
|
||||||
packages = [
|
configs = [ "../portal:pipewire_config" ]
|
||||||
"gio-2.0",
|
|
||||||
"gio-unix-2.0",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
pkg_config("pipewire") {
|
|
||||||
packages = [ "libpipewire-0.3" ]
|
|
||||||
if (!rtc_link_pipewire) {
|
|
||||||
ignore_libs = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pkg_config("gbm") {
|
|
||||||
packages = [ "gbm" ]
|
|
||||||
}
|
|
||||||
pkg_config("egl") {
|
|
||||||
packages = [ "egl" ]
|
|
||||||
}
|
|
||||||
pkg_config("epoxy") {
|
|
||||||
packages = [ "epoxy" ]
|
|
||||||
ignore_libs = true
|
|
||||||
}
|
|
||||||
pkg_config("libdrm") {
|
|
||||||
packages = [ "libdrm" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!rtc_link_pipewire) {
|
|
||||||
# When libpipewire is not directly linked, use stubs to allow for dlopening of
|
|
||||||
# the binary.
|
|
||||||
generate_stubs("pipewire_stubs") {
|
|
||||||
configs = [
|
|
||||||
"../../:common_config",
|
|
||||||
":pipewire",
|
|
||||||
]
|
|
||||||
deps = [ "../../rtc_base" ]
|
|
||||||
extra_header = "linux/wayland/pipewire_stub_header.fragment"
|
|
||||||
logging_function = "RTC_LOG(LS_VERBOSE)"
|
|
||||||
logging_include = "rtc_base/logging.h"
|
|
||||||
output_name = "linux/wayland/pipewire_stubs"
|
|
||||||
path_from_source = "modules/desktop_capture/linux/wayland"
|
|
||||||
sigs = [ "linux/wayland/pipewire.sigs" ]
|
|
||||||
if (!build_with_chromium) {
|
|
||||||
macro_include = "rtc_base/system/no_cfi_icall.h"
|
|
||||||
macro_deps = [ "../../rtc_base/system:no_cfi_icall" ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
config("pipewire_config") {
|
|
||||||
defines = [ "WEBRTC_USE_PIPEWIRE" ]
|
|
||||||
if (!rtc_link_pipewire) {
|
|
||||||
defines += [ "WEBRTC_DLOPEN_PIPEWIRE" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
# Chromecast build config overrides `WEBRTC_USE_PIPEWIRE` even when
|
|
||||||
# `rtc_use_pipewire` is not set, which causes pipewire_config to not be
|
|
||||||
# included in targets. More details in: webrtc:13898
|
|
||||||
if (is_linux && !is_castos) {
|
|
||||||
defines += [ "WEBRTC_USE_GIO" ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -633,12 +560,9 @@ rtc_library("desktop_capture") {
|
||||||
"linux/wayland/egl_dmabuf.h",
|
"linux/wayland/egl_dmabuf.h",
|
||||||
"linux/wayland/mouse_cursor_monitor_pipewire.cc",
|
"linux/wayland/mouse_cursor_monitor_pipewire.cc",
|
||||||
"linux/wayland/mouse_cursor_monitor_pipewire.h",
|
"linux/wayland/mouse_cursor_monitor_pipewire.h",
|
||||||
"linux/wayland/pipewire_utils.cc",
|
|
||||||
"linux/wayland/pipewire_utils.h",
|
|
||||||
"linux/wayland/portal_request_response.h",
|
"linux/wayland/portal_request_response.h",
|
||||||
"linux/wayland/restore_token_manager.cc",
|
"linux/wayland/restore_token_manager.cc",
|
||||||
"linux/wayland/restore_token_manager.h",
|
"linux/wayland/restore_token_manager.h",
|
||||||
"linux/wayland/scoped_glib.cc",
|
|
||||||
"linux/wayland/scoped_glib.h",
|
"linux/wayland/scoped_glib.h",
|
||||||
"linux/wayland/screen_capture_portal_interface.cc",
|
"linux/wayland/screen_capture_portal_interface.cc",
|
||||||
"linux/wayland/screen_capture_portal_interface.h",
|
"linux/wayland/screen_capture_portal_interface.h",
|
||||||
|
@ -648,27 +572,18 @@ rtc_library("desktop_capture") {
|
||||||
"linux/wayland/screencast_stream_utils.h",
|
"linux/wayland/screencast_stream_utils.h",
|
||||||
"linux/wayland/shared_screencast_stream.cc",
|
"linux/wayland/shared_screencast_stream.cc",
|
||||||
"linux/wayland/shared_screencast_stream.h",
|
"linux/wayland/shared_screencast_stream.h",
|
||||||
"linux/wayland/xdg_desktop_portal_utils.cc",
|
|
||||||
"linux/wayland/xdg_desktop_portal_utils.h",
|
"linux/wayland/xdg_desktop_portal_utils.h",
|
||||||
"linux/wayland/xdg_session_details.h",
|
"linux/wayland/xdg_session_details.h",
|
||||||
]
|
]
|
||||||
|
|
||||||
configs += [
|
configs += [ "../portal:pipewire_all" ]
|
||||||
":gio",
|
|
||||||
":pipewire",
|
public_configs += [ "../portal:pipewire_config" ]
|
||||||
":gbm",
|
|
||||||
":egl",
|
deps += [
|
||||||
":epoxy",
|
"../../rtc_base:sanitizer",
|
||||||
":libdrm",
|
"../portal",
|
||||||
]
|
]
|
||||||
|
|
||||||
if (!rtc_link_pipewire) {
|
|
||||||
deps += [ ":pipewire_stubs" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
public_configs += [ ":pipewire_config" ]
|
|
||||||
|
|
||||||
deps += [ "../../rtc_base:sanitizer" ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rtc_enable_win_wgc) {
|
if (rtc_enable_win_wgc) {
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#define MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURE_METADATA_H_
|
#define MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURE_METADATA_H_
|
||||||
|
|
||||||
#if defined(WEBRTC_USE_GIO)
|
#if defined(WEBRTC_USE_GIO)
|
||||||
#include "modules/desktop_capture/linux/wayland/xdg_session_details.h"
|
#include "modules/portal/xdg_session_details.h"
|
||||||
#endif // defined(WEBRTC_USE_GIO)
|
#endif // defined(WEBRTC_USE_GIO)
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
|
|
||||||
#include "modules/desktop_capture/desktop_capture_options.h"
|
#include "modules/desktop_capture/desktop_capture_options.h"
|
||||||
#include "modules/desktop_capture/desktop_capturer.h"
|
#include "modules/desktop_capture/desktop_capturer.h"
|
||||||
#include "modules/desktop_capture/linux/wayland/pipewire_utils.h"
|
|
||||||
#include "modules/desktop_capture/linux/wayland/restore_token_manager.h"
|
#include "modules/desktop_capture/linux/wayland/restore_token_manager.h"
|
||||||
#include "modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h"
|
#include "modules/portal/pipewire_utils.h"
|
||||||
|
#include "modules/portal/xdg_desktop_portal_utils.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
|
|
||||||
|
|
|
@ -14,12 +14,12 @@
|
||||||
#include "modules/desktop_capture/delegated_source_list_controller.h"
|
#include "modules/desktop_capture/delegated_source_list_controller.h"
|
||||||
#include "modules/desktop_capture/desktop_capture_options.h"
|
#include "modules/desktop_capture/desktop_capture_options.h"
|
||||||
#include "modules/desktop_capture/desktop_capturer.h"
|
#include "modules/desktop_capture/desktop_capturer.h"
|
||||||
#include "modules/desktop_capture/linux/wayland/portal_request_response.h"
|
|
||||||
#include "modules/desktop_capture/linux/wayland/screen_capture_portal_interface.h"
|
#include "modules/desktop_capture/linux/wayland/screen_capture_portal_interface.h"
|
||||||
#include "modules/desktop_capture/linux/wayland/screencast_portal.h"
|
#include "modules/desktop_capture/linux/wayland/screencast_portal.h"
|
||||||
#include "modules/desktop_capture/linux/wayland/shared_screencast_stream.h"
|
#include "modules/desktop_capture/linux/wayland/shared_screencast_stream.h"
|
||||||
#include "modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h"
|
#include "modules/portal/portal_request_response.h"
|
||||||
#include "modules/desktop_capture/linux/wayland/xdg_session_details.h"
|
#include "modules/portal/xdg_desktop_portal_utils.h"
|
||||||
|
#include "modules/portal/xdg_session_details.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
|
|
|
@ -11,24 +11,7 @@
|
||||||
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_PORTAL_REQUEST_RESPONSE_H_
|
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_PORTAL_REQUEST_RESPONSE_H_
|
||||||
#define MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_PORTAL_REQUEST_RESPONSE_H_
|
#define MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_PORTAL_REQUEST_RESPONSE_H_
|
||||||
|
|
||||||
namespace webrtc {
|
// TODO(bugs.webrtc.org/14187): remove when all users are gone
|
||||||
namespace xdg_portal {
|
#include "modules/portal/portal_request_response.h"
|
||||||
|
|
||||||
// Contains type of responses that can be observed when making a request to
|
|
||||||
// a desktop portal interface.
|
|
||||||
enum class RequestResponse {
|
|
||||||
// Unknown, the initialized status.
|
|
||||||
kUnknown,
|
|
||||||
// Success, the request is carried out.
|
|
||||||
kSuccess,
|
|
||||||
// The user cancelled the interaction.
|
|
||||||
kUserCancelled,
|
|
||||||
// The user interaction was ended in some other way.
|
|
||||||
kError,
|
|
||||||
|
|
||||||
kMaxValue = kError,
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace xdg_portal
|
|
||||||
} // namespace webrtc
|
|
||||||
#endif // MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_PORTAL_REQUEST_RESPONSE_H_
|
#endif // MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_PORTAL_REQUEST_RESPONSE_H_
|
||||||
|
|
|
@ -11,55 +11,7 @@
|
||||||
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_SCOPED_GLIB_H_
|
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_SCOPED_GLIB_H_
|
||||||
#define MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_SCOPED_GLIB_H_
|
#define MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_SCOPED_GLIB_H_
|
||||||
|
|
||||||
#include <gio/gio.h>
|
// TODO(bugs.webrtc.org/14187): remove when all users are gone
|
||||||
|
#include "modules/portal/scoped_glib.h"
|
||||||
#include "rtc_base/checks.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
class Scoped {
|
|
||||||
public:
|
|
||||||
Scoped() {}
|
|
||||||
explicit Scoped(T* val) { ptr_ = val; }
|
|
||||||
~Scoped() { RTC_DCHECK_NOTREACHED(); }
|
|
||||||
|
|
||||||
T* operator->() const { return ptr_; }
|
|
||||||
|
|
||||||
explicit operator bool() const { return ptr_ != nullptr; }
|
|
||||||
|
|
||||||
bool operator!() const { return ptr_ == nullptr; }
|
|
||||||
|
|
||||||
T* get() const { return ptr_; }
|
|
||||||
|
|
||||||
T** receive() {
|
|
||||||
RTC_CHECK(!ptr_);
|
|
||||||
return &ptr_;
|
|
||||||
}
|
|
||||||
|
|
||||||
Scoped& operator=(T* val) {
|
|
||||||
RTC_DCHECK(val);
|
|
||||||
ptr_ = val;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
T* ptr_ = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
Scoped<GError>::~Scoped();
|
|
||||||
template <>
|
|
||||||
Scoped<char>::~Scoped();
|
|
||||||
template <>
|
|
||||||
Scoped<GVariant>::~Scoped();
|
|
||||||
template <>
|
|
||||||
Scoped<GVariantIter>::~Scoped();
|
|
||||||
template <>
|
|
||||||
Scoped<GDBusMessage>::~Scoped();
|
|
||||||
template <>
|
|
||||||
Scoped<GUnixFDList>::~Scoped();
|
|
||||||
|
|
||||||
} // namespace webrtc
|
|
||||||
|
|
||||||
#endif // MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_SCOPED_GLIB_H_
|
#endif // MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_SCOPED_GLIB_H_
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
#include "modules/desktop_capture/linux/wayland/screen_capture_portal_interface.h"
|
#include "modules/desktop_capture/linux/wayland/screen_capture_portal_interface.h"
|
||||||
#include "modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h"
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "modules/portal/xdg_desktop_portal_utils.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
|
@ -15,10 +15,10 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "modules/desktop_capture/linux/wayland/portal_request_response.h"
|
#include "modules/portal/portal_request_response.h"
|
||||||
#include "modules/desktop_capture/linux/wayland/scoped_glib.h"
|
#include "modules/portal/scoped_glib.h"
|
||||||
#include "modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h"
|
#include "modules/portal/xdg_desktop_portal_utils.h"
|
||||||
#include "modules/desktop_capture/linux/wayland/xdg_session_details.h"
|
#include "modules/portal/xdg_session_details.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace xdg_portal {
|
namespace xdg_portal {
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
#include <gio/gunixfdlist.h>
|
#include <gio/gunixfdlist.h>
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
|
||||||
#include "modules/desktop_capture/linux/wayland/scoped_glib.h"
|
#include "modules/portal/scoped_glib.h"
|
||||||
#include "modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h"
|
#include "modules/portal/xdg_desktop_portal_utils.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "modules/desktop_capture/desktop_capture_types.h"
|
#include "modules/desktop_capture/desktop_capture_types.h"
|
||||||
#include "modules/desktop_capture/linux/wayland/portal_request_response.h"
|
|
||||||
#include "modules/desktop_capture/linux/wayland/screen_capture_portal_interface.h"
|
#include "modules/desktop_capture/linux/wayland/screen_capture_portal_interface.h"
|
||||||
#include "modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h"
|
#include "modules/portal/portal_request_response.h"
|
||||||
#include "modules/desktop_capture/linux/wayland/xdg_session_details.h"
|
#include "modules/portal/xdg_desktop_portal_utils.h"
|
||||||
|
#include "modules/portal/xdg_session_details.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
|
|
|
@ -27,15 +27,6 @@
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
PipeWireThreadLoopLock::PipeWireThreadLoopLock(pw_thread_loop* loop)
|
|
||||||
: loop_(loop) {
|
|
||||||
pw_thread_loop_lock(loop_);
|
|
||||||
}
|
|
||||||
|
|
||||||
PipeWireThreadLoopLock::~PipeWireThreadLoopLock() {
|
|
||||||
pw_thread_loop_unlock(loop_);
|
|
||||||
}
|
|
||||||
|
|
||||||
PipeWireVersion PipeWireVersion::Parse(const absl::string_view& version) {
|
PipeWireVersion PipeWireVersion::Parse(const absl::string_view& version) {
|
||||||
std::vector<absl::string_view> parsed_version = rtc::split(version, '.');
|
std::vector<absl::string_view> parsed_version = rtc::split(version, '.');
|
||||||
|
|
||||||
|
|
|
@ -18,23 +18,12 @@
|
||||||
|
|
||||||
#include "rtc_base/string_encode.h"
|
#include "rtc_base/string_encode.h"
|
||||||
|
|
||||||
struct pw_thread_loop;
|
|
||||||
struct spa_pod;
|
struct spa_pod;
|
||||||
struct spa_pod_builder;
|
struct spa_pod_builder;
|
||||||
struct spa_rectangle;
|
struct spa_rectangle;
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
// Locks pw_thread_loop in the current scope
|
|
||||||
class PipeWireThreadLoopLock {
|
|
||||||
public:
|
|
||||||
explicit PipeWireThreadLoopLock(pw_thread_loop* loop);
|
|
||||||
~PipeWireThreadLoopLock();
|
|
||||||
|
|
||||||
private:
|
|
||||||
pw_thread_loop* const loop_;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct PipeWireVersion {
|
struct PipeWireVersion {
|
||||||
static PipeWireVersion Parse(const absl::string_view& version);
|
static PipeWireVersion Parse(const absl::string_view& version);
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
|
|
||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "modules/desktop_capture/linux/wayland/egl_dmabuf.h"
|
#include "modules/desktop_capture/linux/wayland/egl_dmabuf.h"
|
||||||
#include "modules/desktop_capture/linux/wayland/pipewire_utils.h"
|
|
||||||
#include "modules/desktop_capture/linux/wayland/screencast_stream_utils.h"
|
#include "modules/desktop_capture/linux/wayland/screencast_stream_utils.h"
|
||||||
|
#include "modules/portal/pipewire_utils.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
#include "rtc_base/sanitizer.h"
|
#include "rtc_base/sanitizer.h"
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "modules/desktop_capture/linux/wayland/pipewire_utils.h"
|
#include "modules/portal/pipewire_utils.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
|
@ -11,101 +11,7 @@
|
||||||
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_XDG_DESKTOP_PORTAL_UTILS_H_
|
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_XDG_DESKTOP_PORTAL_UTILS_H_
|
||||||
#define MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_XDG_DESKTOP_PORTAL_UTILS_H_
|
#define MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_XDG_DESKTOP_PORTAL_UTILS_H_
|
||||||
|
|
||||||
#include <gio/gio.h>
|
// TODO(bugs.webrtc.org/14187): remove when all users are gone
|
||||||
#include <stdint.h>
|
#include "modules/portal/xdg_desktop_portal_utils.h"
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "absl/strings/string_view.h"
|
|
||||||
#include "modules/desktop_capture/linux/wayland/portal_request_response.h"
|
|
||||||
#include "modules/desktop_capture/linux/wayland/scoped_glib.h"
|
|
||||||
#include "modules/desktop_capture/linux/wayland/xdg_session_details.h"
|
|
||||||
#include "rtc_base/checks.h"
|
|
||||||
#include "rtc_base/logging.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
|
||||||
namespace xdg_portal {
|
|
||||||
|
|
||||||
constexpr char kDesktopBusName[] = "org.freedesktop.portal.Desktop";
|
|
||||||
constexpr char kDesktopObjectPath[] = "/org/freedesktop/portal/desktop";
|
|
||||||
constexpr char kDesktopRequestObjectPath[] =
|
|
||||||
"/org/freedesktop/portal/desktop/request";
|
|
||||||
constexpr char kSessionInterfaceName[] = "org.freedesktop.portal.Session";
|
|
||||||
constexpr char kRequestInterfaceName[] = "org.freedesktop.portal.Request";
|
|
||||||
constexpr char kScreenCastInterfaceName[] = "org.freedesktop.portal.ScreenCast";
|
|
||||||
|
|
||||||
using ProxyRequestCallback = void (*)(GObject*, GAsyncResult*, gpointer);
|
|
||||||
using SessionRequestCallback = void (*)(GDBusProxy*, GAsyncResult*, gpointer);
|
|
||||||
using SessionRequestResponseSignalHandler = void (*)(GDBusConnection*,
|
|
||||||
const char*,
|
|
||||||
const char*,
|
|
||||||
const char*,
|
|
||||||
const char*,
|
|
||||||
GVariant*,
|
|
||||||
gpointer);
|
|
||||||
using StartRequestResponseSignalHandler = void (*)(GDBusConnection*,
|
|
||||||
const char*,
|
|
||||||
const char*,
|
|
||||||
const char*,
|
|
||||||
const char*,
|
|
||||||
GVariant*,
|
|
||||||
gpointer);
|
|
||||||
using SessionStartRequestedHandler = void (*)(GDBusProxy*,
|
|
||||||
GAsyncResult*,
|
|
||||||
gpointer);
|
|
||||||
|
|
||||||
std::string RequestResponseToString(RequestResponse request);
|
|
||||||
|
|
||||||
RequestResponse RequestResponseFromPortalResponse(uint32_t portal_response);
|
|
||||||
|
|
||||||
// Returns a string path for signal handle based on the provided connection and
|
|
||||||
// token.
|
|
||||||
std::string PrepareSignalHandle(absl::string_view token,
|
|
||||||
GDBusConnection* connection);
|
|
||||||
|
|
||||||
// Sets up the callback to execute when a response signal is received for the
|
|
||||||
// given object.
|
|
||||||
uint32_t SetupRequestResponseSignal(absl::string_view object_path,
|
|
||||||
const GDBusSignalCallback callback,
|
|
||||||
gpointer user_data,
|
|
||||||
GDBusConnection* connection);
|
|
||||||
|
|
||||||
void RequestSessionProxy(absl::string_view interface_name,
|
|
||||||
const ProxyRequestCallback proxy_request_callback,
|
|
||||||
GCancellable* cancellable,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void SetupSessionRequestHandlers(
|
|
||||||
absl::string_view portal_prefix,
|
|
||||||
const SessionRequestCallback session_request_callback,
|
|
||||||
const SessionRequestResponseSignalHandler request_response_signale_handler,
|
|
||||||
GDBusConnection* connection,
|
|
||||||
GDBusProxy* proxy,
|
|
||||||
GCancellable* cancellable,
|
|
||||||
std::string& portal_handle,
|
|
||||||
guint& session_request_signal_id,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void StartSessionRequest(
|
|
||||||
absl::string_view prefix,
|
|
||||||
absl::string_view session_handle,
|
|
||||||
const StartRequestResponseSignalHandler signal_handler,
|
|
||||||
const SessionStartRequestedHandler session_started_handler,
|
|
||||||
GDBusProxy* proxy,
|
|
||||||
GDBusConnection* connection,
|
|
||||||
GCancellable* cancellable,
|
|
||||||
guint& start_request_signal_id,
|
|
||||||
std::string& start_handle,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
// Tears down the portal session and cleans up related objects.
|
|
||||||
void TearDownSession(absl::string_view session_handle,
|
|
||||||
GDBusProxy* proxy,
|
|
||||||
GCancellable* cancellable,
|
|
||||||
GDBusConnection* connection);
|
|
||||||
|
|
||||||
} // namespace xdg_portal
|
|
||||||
} // namespace webrtc
|
|
||||||
|
|
||||||
#endif // MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_XDG_DESKTOP_PORTAL_UTILS_H_
|
#endif // MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_XDG_DESKTOP_PORTAL_UTILS_H_
|
||||||
|
|
|
@ -11,23 +11,7 @@
|
||||||
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_XDG_SESSION_DETAILS_H_
|
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_XDG_SESSION_DETAILS_H_
|
||||||
#define MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_XDG_SESSION_DETAILS_H_
|
#define MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_XDG_SESSION_DETAILS_H_
|
||||||
|
|
||||||
#include <gio/gio.h>
|
// TODO(bugs.webrtc.org/14187): remove when all users are gone
|
||||||
|
#include "modules/portal/xdg_session_details.h"
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace webrtc {
|
|
||||||
namespace xdg_portal {
|
|
||||||
|
|
||||||
// Details of the session associated with XDG desktop portal session. Portal API
|
|
||||||
// calls can be invoked by utilizing the information here.
|
|
||||||
struct SessionDetails {
|
|
||||||
GDBusProxy* proxy = nullptr;
|
|
||||||
GCancellable* cancellable = nullptr;
|
|
||||||
std::string session_handle;
|
|
||||||
uint32_t pipewire_stream_node_id = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace xdg_portal
|
|
||||||
} // namespace webrtc
|
|
||||||
|
|
||||||
#endif // MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_XDG_SESSION_DETAILS_H_
|
#endif // MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_XDG_SESSION_DETAILS_H_
|
||||||
|
|
123
modules/portal/BUILD.gn
Normal file
123
modules/portal/BUILD.gn
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
# Copyright (c) 2022 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.
|
||||||
|
|
||||||
|
import("//build/config/linux/pkg_config.gni")
|
||||||
|
import("//tools/generate_stubs/rules.gni")
|
||||||
|
import("../../webrtc.gni")
|
||||||
|
|
||||||
|
if ((is_linux || is_chromeos) && rtc_use_pipewire) {
|
||||||
|
pkg_config("gio") {
|
||||||
|
packages = [
|
||||||
|
"gio-2.0",
|
||||||
|
"gio-unix-2.0",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
pkg_config("pipewire") {
|
||||||
|
packages = [ "libpipewire-0.3" ]
|
||||||
|
if (!rtc_link_pipewire) {
|
||||||
|
ignore_libs = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pkg_config("gbm") {
|
||||||
|
packages = [ "gbm" ]
|
||||||
|
}
|
||||||
|
pkg_config("egl") {
|
||||||
|
packages = [ "egl" ]
|
||||||
|
}
|
||||||
|
pkg_config("epoxy") {
|
||||||
|
packages = [ "epoxy" ]
|
||||||
|
ignore_libs = true
|
||||||
|
}
|
||||||
|
pkg_config("libdrm") {
|
||||||
|
packages = [ "libdrm" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!rtc_link_pipewire) {
|
||||||
|
# When libpipewire is not directly linked, use stubs to allow for dlopening of
|
||||||
|
# the binary.
|
||||||
|
generate_stubs("pipewire_stubs") {
|
||||||
|
configs = [
|
||||||
|
"../../:common_config",
|
||||||
|
":pipewire",
|
||||||
|
]
|
||||||
|
deps = [ "../../rtc_base" ]
|
||||||
|
extra_header = "pipewire_stub_header.fragment"
|
||||||
|
logging_function = "RTC_LOG(LS_VERBOSE)"
|
||||||
|
logging_include = "rtc_base/logging.h"
|
||||||
|
output_name = "pipewire_stubs"
|
||||||
|
path_from_source = "modules/portal"
|
||||||
|
sigs = [ "pipewire.sigs" ]
|
||||||
|
if (!build_with_chromium) {
|
||||||
|
macro_include = "rtc_base/system/no_cfi_icall.h"
|
||||||
|
macro_deps = [ "../../rtc_base/system:no_cfi_icall" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config("pipewire_base") {
|
||||||
|
configs = [
|
||||||
|
":gio",
|
||||||
|
":pipewire",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
config("pipewire_all") {
|
||||||
|
configs = [
|
||||||
|
":pipewire_base",
|
||||||
|
":gbm",
|
||||||
|
":egl",
|
||||||
|
":epoxy",
|
||||||
|
":libdrm",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
config("pipewire_config") {
|
||||||
|
defines = [ "WEBRTC_USE_PIPEWIRE" ]
|
||||||
|
|
||||||
|
# Chromecast build config overrides `WEBRTC_USE_PIPEWIRE` even when
|
||||||
|
# `rtc_use_pipewire` is not set, which causes pipewire_config to not be
|
||||||
|
# included in targets. More details in: webrtc:13898
|
||||||
|
if (is_linux && !is_castos) {
|
||||||
|
defines += [ "WEBRTC_USE_GIO" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rtc_library("portal") {
|
||||||
|
sources = [
|
||||||
|
"pipewire_utils.cc",
|
||||||
|
"pipewire_utils.h",
|
||||||
|
"portal_request_response.h",
|
||||||
|
"scoped_glib.cc",
|
||||||
|
"scoped_glib.h",
|
||||||
|
"xdg_desktop_portal_utils.cc",
|
||||||
|
"xdg_desktop_portal_utils.h",
|
||||||
|
"xdg_session_details.h",
|
||||||
|
]
|
||||||
|
|
||||||
|
configs += [
|
||||||
|
":gio",
|
||||||
|
":pipewire",
|
||||||
|
":pipewire_config",
|
||||||
|
]
|
||||||
|
|
||||||
|
deps = [
|
||||||
|
"../../rtc_base:checks",
|
||||||
|
"../../rtc_base:logging",
|
||||||
|
"../../rtc_base:sanitizer",
|
||||||
|
]
|
||||||
|
absl_deps = [ "//third_party/abseil-cpp/absl/strings" ]
|
||||||
|
|
||||||
|
if (!rtc_link_pipewire) {
|
||||||
|
defines = [ "WEBRTC_DLOPEN_PIPEWIRE" ]
|
||||||
|
|
||||||
|
deps += [ ":pipewire_stubs" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
2
modules/portal/OWNERS
Normal file
2
modules/portal/OWNERS
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
alcooper@chromium.org
|
||||||
|
mfoltz@chromium.org
|
|
@ -8,12 +8,14 @@
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "modules/desktop_capture/linux/wayland/pipewire_utils.h"
|
#include "modules/portal/pipewire_utils.h"
|
||||||
|
|
||||||
|
#include <pipewire/pipewire.h>
|
||||||
|
|
||||||
#include "rtc_base/sanitizer.h"
|
#include "rtc_base/sanitizer.h"
|
||||||
|
|
||||||
#if defined(WEBRTC_DLOPEN_PIPEWIRE)
|
#if defined(WEBRTC_DLOPEN_PIPEWIRE)
|
||||||
#include "modules/desktop_capture/linux/wayland/pipewire_stubs.h"
|
#include "modules/portal/pipewire_stubs.h"
|
||||||
#endif // defined(WEBRTC_DLOPEN_PIPEWIRE)
|
#endif // defined(WEBRTC_DLOPEN_PIPEWIRE)
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
@ -23,10 +25,10 @@ bool InitializePipeWire() {
|
||||||
#if defined(WEBRTC_DLOPEN_PIPEWIRE)
|
#if defined(WEBRTC_DLOPEN_PIPEWIRE)
|
||||||
static constexpr char kPipeWireLib[] = "libpipewire-0.3.so.0";
|
static constexpr char kPipeWireLib[] = "libpipewire-0.3.so.0";
|
||||||
|
|
||||||
using modules_desktop_capture_linux_wayland::InitializeStubs;
|
using modules_portal::InitializeStubs;
|
||||||
using modules_desktop_capture_linux_wayland::kModulePipewire;
|
using modules_portal::kModulePipewire;
|
||||||
|
|
||||||
modules_desktop_capture_linux_wayland::StubPathMap paths;
|
modules_portal::StubPathMap paths;
|
||||||
|
|
||||||
// Check if the PipeWire library is available.
|
// Check if the PipeWire library is available.
|
||||||
paths[kModulePipewire].push_back(kPipeWireLib);
|
paths[kModulePipewire].push_back(kPipeWireLib);
|
||||||
|
@ -39,4 +41,13 @@ bool InitializePipeWire() {
|
||||||
#endif // defined(WEBRTC_DLOPEN_PIPEWIRE)
|
#endif // defined(WEBRTC_DLOPEN_PIPEWIRE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PipeWireThreadLoopLock::PipeWireThreadLoopLock(pw_thread_loop* loop)
|
||||||
|
: loop_(loop) {
|
||||||
|
pw_thread_loop_lock(loop_);
|
||||||
|
}
|
||||||
|
|
||||||
|
PipeWireThreadLoopLock::~PipeWireThreadLoopLock() {
|
||||||
|
pw_thread_loop_unlock(loop_);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
|
@ -8,8 +8,10 @@
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_PIPEWIRE_UTILS_H_
|
#ifndef MODULES_PORTAL_PIPEWIRE_UTILS_H_
|
||||||
#define MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_PIPEWIRE_UTILS_H_
|
#define MODULES_PORTAL_PIPEWIRE_UTILS_H_
|
||||||
|
|
||||||
|
struct pw_thread_loop;
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
|
@ -18,6 +20,16 @@ namespace webrtc {
|
||||||
// running nor does it establish a connection to one.
|
// running nor does it establish a connection to one.
|
||||||
bool InitializePipeWire();
|
bool InitializePipeWire();
|
||||||
|
|
||||||
|
// Locks pw_thread_loop in the current scope
|
||||||
|
class PipeWireThreadLoopLock {
|
||||||
|
public:
|
||||||
|
explicit PipeWireThreadLoopLock(pw_thread_loop* loop);
|
||||||
|
~PipeWireThreadLoopLock();
|
||||||
|
|
||||||
|
private:
|
||||||
|
pw_thread_loop* const loop_;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_PIPEWIRE_UTILS_H_
|
#endif // MODULES_PORTAL_PIPEWIRE_UTILS_H_
|
34
modules/portal/portal_request_response.h
Normal file
34
modules/portal/portal_request_response.h
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 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_PORTAL_PORTAL_REQUEST_RESPONSE_H_
|
||||||
|
#define MODULES_PORTAL_PORTAL_REQUEST_RESPONSE_H_
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
namespace xdg_portal {
|
||||||
|
|
||||||
|
// Contains type of responses that can be observed when making a request to
|
||||||
|
// a desktop portal interface.
|
||||||
|
enum class RequestResponse {
|
||||||
|
// Unknown, the initialized status.
|
||||||
|
kUnknown,
|
||||||
|
// Success, the request is carried out.
|
||||||
|
kSuccess,
|
||||||
|
// The user cancelled the interaction.
|
||||||
|
kUserCancelled,
|
||||||
|
// The user interaction was ended in some other way.
|
||||||
|
kError,
|
||||||
|
|
||||||
|
kMaxValue = kError,
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace xdg_portal
|
||||||
|
} // namespace webrtc
|
||||||
|
#endif // MODULES_PORTAL_PORTAL_REQUEST_RESPONSE_H_
|
|
@ -8,7 +8,7 @@
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "modules/desktop_capture/linux/wayland/scoped_glib.h"
|
#include "modules/portal/scoped_glib.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
65
modules/portal/scoped_glib.h
Normal file
65
modules/portal/scoped_glib.h
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2022 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_PORTAL_SCOPED_GLIB_H_
|
||||||
|
#define MODULES_PORTAL_SCOPED_GLIB_H_
|
||||||
|
|
||||||
|
#include <gio/gio.h>
|
||||||
|
|
||||||
|
#include "rtc_base/checks.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
class Scoped {
|
||||||
|
public:
|
||||||
|
Scoped() {}
|
||||||
|
explicit Scoped(T* val) { ptr_ = val; }
|
||||||
|
~Scoped() { RTC_DCHECK_NOTREACHED(); }
|
||||||
|
|
||||||
|
T* operator->() const { return ptr_; }
|
||||||
|
|
||||||
|
explicit operator bool() const { return ptr_ != nullptr; }
|
||||||
|
|
||||||
|
bool operator!() const { return ptr_ == nullptr; }
|
||||||
|
|
||||||
|
T* get() const { return ptr_; }
|
||||||
|
|
||||||
|
T** receive() {
|
||||||
|
RTC_CHECK(!ptr_);
|
||||||
|
return &ptr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
Scoped& operator=(T* val) {
|
||||||
|
RTC_DCHECK(val);
|
||||||
|
ptr_ = val;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
T* ptr_ = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
Scoped<GError>::~Scoped();
|
||||||
|
template <>
|
||||||
|
Scoped<char>::~Scoped();
|
||||||
|
template <>
|
||||||
|
Scoped<GVariant>::~Scoped();
|
||||||
|
template <>
|
||||||
|
Scoped<GVariantIter>::~Scoped();
|
||||||
|
template <>
|
||||||
|
Scoped<GDBusMessage>::~Scoped();
|
||||||
|
template <>
|
||||||
|
Scoped<GUnixFDList>::~Scoped();
|
||||||
|
|
||||||
|
} // namespace webrtc
|
||||||
|
|
||||||
|
#endif // MODULES_PORTAL_SCOPED_GLIB_H_
|
|
@ -7,12 +7,12 @@
|
||||||
* in the file PATENTS. All contributing project authors may
|
* in the file PATENTS. All contributing project authors may
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
#include "modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h"
|
#include "modules/portal/xdg_desktop_portal_utils.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
#include "modules/desktop_capture/linux/wayland/scoped_glib.h"
|
#include "modules/portal/scoped_glib.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
111
modules/portal/xdg_desktop_portal_utils.h
Normal file
111
modules/portal/xdg_desktop_portal_utils.h
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2022 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_PORTAL_XDG_DESKTOP_PORTAL_UTILS_H_
|
||||||
|
#define MODULES_PORTAL_XDG_DESKTOP_PORTAL_UTILS_H_
|
||||||
|
|
||||||
|
#include <gio/gio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
|
#include "modules/portal/portal_request_response.h"
|
||||||
|
#include "modules/portal/scoped_glib.h"
|
||||||
|
#include "modules/portal/xdg_session_details.h"
|
||||||
|
#include "rtc_base/checks.h"
|
||||||
|
#include "rtc_base/logging.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
namespace xdg_portal {
|
||||||
|
|
||||||
|
constexpr char kDesktopBusName[] = "org.freedesktop.portal.Desktop";
|
||||||
|
constexpr char kDesktopObjectPath[] = "/org/freedesktop/portal/desktop";
|
||||||
|
constexpr char kDesktopRequestObjectPath[] =
|
||||||
|
"/org/freedesktop/portal/desktop/request";
|
||||||
|
constexpr char kSessionInterfaceName[] = "org.freedesktop.portal.Session";
|
||||||
|
constexpr char kRequestInterfaceName[] = "org.freedesktop.portal.Request";
|
||||||
|
constexpr char kScreenCastInterfaceName[] = "org.freedesktop.portal.ScreenCast";
|
||||||
|
|
||||||
|
using ProxyRequestCallback = void (*)(GObject*, GAsyncResult*, gpointer);
|
||||||
|
using SessionRequestCallback = void (*)(GDBusProxy*, GAsyncResult*, gpointer);
|
||||||
|
using SessionRequestResponseSignalHandler = void (*)(GDBusConnection*,
|
||||||
|
const char*,
|
||||||
|
const char*,
|
||||||
|
const char*,
|
||||||
|
const char*,
|
||||||
|
GVariant*,
|
||||||
|
gpointer);
|
||||||
|
using StartRequestResponseSignalHandler = void (*)(GDBusConnection*,
|
||||||
|
const char*,
|
||||||
|
const char*,
|
||||||
|
const char*,
|
||||||
|
const char*,
|
||||||
|
GVariant*,
|
||||||
|
gpointer);
|
||||||
|
using SessionStartRequestedHandler = void (*)(GDBusProxy*,
|
||||||
|
GAsyncResult*,
|
||||||
|
gpointer);
|
||||||
|
|
||||||
|
std::string RequestResponseToString(RequestResponse request);
|
||||||
|
|
||||||
|
RequestResponse RequestResponseFromPortalResponse(uint32_t portal_response);
|
||||||
|
|
||||||
|
// Returns a string path for signal handle based on the provided connection and
|
||||||
|
// token.
|
||||||
|
std::string PrepareSignalHandle(absl::string_view token,
|
||||||
|
GDBusConnection* connection);
|
||||||
|
|
||||||
|
// Sets up the callback to execute when a response signal is received for the
|
||||||
|
// given object.
|
||||||
|
uint32_t SetupRequestResponseSignal(absl::string_view object_path,
|
||||||
|
const GDBusSignalCallback callback,
|
||||||
|
gpointer user_data,
|
||||||
|
GDBusConnection* connection);
|
||||||
|
|
||||||
|
void RequestSessionProxy(absl::string_view interface_name,
|
||||||
|
const ProxyRequestCallback proxy_request_callback,
|
||||||
|
GCancellable* cancellable,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void SetupSessionRequestHandlers(
|
||||||
|
absl::string_view portal_prefix,
|
||||||
|
const SessionRequestCallback session_request_callback,
|
||||||
|
const SessionRequestResponseSignalHandler request_response_signale_handler,
|
||||||
|
GDBusConnection* connection,
|
||||||
|
GDBusProxy* proxy,
|
||||||
|
GCancellable* cancellable,
|
||||||
|
std::string& portal_handle,
|
||||||
|
guint& session_request_signal_id,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void StartSessionRequest(
|
||||||
|
absl::string_view prefix,
|
||||||
|
absl::string_view session_handle,
|
||||||
|
const StartRequestResponseSignalHandler signal_handler,
|
||||||
|
const SessionStartRequestedHandler session_started_handler,
|
||||||
|
GDBusProxy* proxy,
|
||||||
|
GDBusConnection* connection,
|
||||||
|
GCancellable* cancellable,
|
||||||
|
guint& start_request_signal_id,
|
||||||
|
std::string& start_handle,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
// Tears down the portal session and cleans up related objects.
|
||||||
|
void TearDownSession(absl::string_view session_handle,
|
||||||
|
GDBusProxy* proxy,
|
||||||
|
GCancellable* cancellable,
|
||||||
|
GDBusConnection* connection);
|
||||||
|
|
||||||
|
} // namespace xdg_portal
|
||||||
|
} // namespace webrtc
|
||||||
|
|
||||||
|
#endif // MODULES_PORTAL_XDG_DESKTOP_PORTAL_UTILS_H_
|
33
modules/portal/xdg_session_details.h
Normal file
33
modules/portal/xdg_session_details.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2022 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_PORTAL_XDG_SESSION_DETAILS_H_
|
||||||
|
#define MODULES_PORTAL_XDG_SESSION_DETAILS_H_
|
||||||
|
|
||||||
|
#include <gio/gio.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
namespace xdg_portal {
|
||||||
|
|
||||||
|
// Details of the session associated with XDG desktop portal session. Portal API
|
||||||
|
// calls can be invoked by utilizing the information here.
|
||||||
|
struct SessionDetails {
|
||||||
|
GDBusProxy* proxy = nullptr;
|
||||||
|
GCancellable* cancellable = nullptr;
|
||||||
|
std::string session_handle;
|
||||||
|
uint32_t pipewire_stream_node_id = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace xdg_portal
|
||||||
|
} // namespace webrtc
|
||||||
|
|
||||||
|
#endif // MODULES_PORTAL_XDG_SESSION_DETAILS_H_
|
Loading…
Reference in a new issue