From e3225bc62835c6accc18787c6038fc1dce2484fc Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 10 May 2025 17:10:59 +0200 Subject: Move dbus code to a separate process to allow gpu-screen-recorder to use cap_sys_nice for better recording performance on amd --- dbus/client/dbus_client.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 dbus/client/dbus_client.h (limited to 'dbus/client/dbus_client.h') diff --git a/dbus/client/dbus_client.h b/dbus/client/dbus_client.h new file mode 100644 index 0000000..c9e8182 --- /dev/null +++ b/dbus/client/dbus_client.h @@ -0,0 +1,36 @@ +#ifndef GSR_DBUS_CLIENT_H +#define GSR_DBUS_CLIENT_H + +/* + Using a client-server architecture is needed for dbus because cap_sys_nice doesn't work with desktop portal. + The main binary has cap_sys_nice and we launch a new child-process without it which uses uses desktop portal. +*/ + +#include "../portal.h" +#include +#include +#include + +typedef struct { + int socket_pair[2]; + char *screencast_restore_token; + pid_t pid; +} gsr_dbus_client; + +/* Blocking. TODO: Make non-blocking */ +bool gsr_dbus_client_init(gsr_dbus_client *self, const char *screencast_restore_token); +void gsr_dbus_client_deinit(gsr_dbus_client *self); + +/* The follow functions should be called in order to setup ScreenCast properly */ +/* These functions that return an int return the response status code */ +int gsr_dbus_client_screencast_create_session(gsr_dbus_client *self, char *session_handle, size_t session_handle_size); +/* + |capture_type| is a bitmask of gsr_portal_capture_type values. gsr_portal_capture_type values that are not supported by the desktop portal will be ignored. + |gsr_portal_cursor_mode| is a bitmask of gsr_portal_cursor_mode values. gsr_portal_cursor_mode values that are not supported will be ignored. +*/ +int gsr_dbus_client_screencast_select_sources(gsr_dbus_client *self, const char *session_handle, uint32_t capture_type, uint32_t cursor_mode); +int gsr_dbus_client_screencast_start(gsr_dbus_client *self, const char *session_handle, uint32_t *pipewire_node); +bool gsr_dbus_client_screencast_open_pipewire_remote(gsr_dbus_client *self, const char *session_handle, int *pipewire_fd); +const char* gsr_dbus_client_screencast_get_restore_token(gsr_dbus_client *self); + +#endif /* GSR_DBUS_CLIENT_H */ -- cgit v1.2.3-70-g09d2