Blame 0001-PipeWire-update-to-0.3-API.patch

fbc0514
From a38901e5e7f835efe7b7a06c55790c8c20bc91a2 Mon Sep 17 00:00:00 2001
fbc0514
From: Wim Taymans <wtaymans@redhat.com>
fbc0514
Date: Tue, 14 Jan 2020 09:37:09 +0100
fbc0514
Subject: [PATCH] PipeWire: update to 0.3 API
fbc0514
fbc0514
---
fbc0514
 configure.ac      |   2 +-
fbc0514
 src/camera.c      |  24 ++++----
fbc0514
 src/pipewire.c    | 141 +++++++++++++---------------------------------
fbc0514
 src/pipewire.h    |  10 ++--
fbc0514
 src/screen-cast.c |  98 ++++++--------------------------
fbc0514
 5 files changed, 72 insertions(+), 203 deletions(-)
fbc0514
fbc0514
diff --git a/configure.ac b/configure.ac
fbc0514
index 89902fa..62d7960 100644
fbc0514
--- a/configure.ac
fbc0514
+++ b/configure.ac
fbc0514
@@ -97,7 +97,7 @@ AC_ARG_ENABLE(pipewire,
fbc0514
 	      [AS_HELP_STRING([--enable-pipewire],[Enable PipeWire support. Needed for screen cast portal])],
fbc0514
 	      enable_pipewire=$enableval, enable_pipewire=yes)
fbc0514
 if test x$enable_pipewire = xyes ; then
fbc0514
-	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.2 >= 0.2.6])
fbc0514
+	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.3 >= 0.2.90])
fbc0514
 	AC_DEFINE([HAVE_PIPEWIRE],[1], [Define to enable PipeWire support])
fbc0514
 fi
fbc0514
 AM_CONDITIONAL([HAVE_PIPEWIRE],[test "$enable_pipewire" = "yes"])
fbc0514
diff --git a/src/camera.c b/src/camera.c
fbc0514
index c2b392c..20fe3aa 100644
fbc0514
--- a/src/camera.c
fbc0514
+++ b/src/camera.c
fbc0514
@@ -141,7 +141,7 @@ open_pipewire_camera_remote (const char *app_id,
fbc0514
                              GError **error)
fbc0514
 {
fbc0514
   PipeWireRemote *remote;
fbc0514
-  struct spa_dict_item permission_items[1];
fbc0514
+  struct pw_permission permission_items[2];
fbc0514
   struct pw_properties *pipewire_properties;
fbc0514
 
fbc0514
   pipewire_properties =
fbc0514
@@ -158,12 +158,12 @@ open_pipewire_camera_remote (const char *app_id,
fbc0514
    * Hide all existing and future nodes by default. PipeWire will use the
fbc0514
    * permission store to set up permissions.
fbc0514
    */
fbc0514
-  permission_items[0].key = PW_CORE_PROXY_PERMISSIONS_DEFAULT;
fbc0514
-  permission_items[0].value = "---";
fbc0514
+  permission_items[0] = PW_PERMISSION_INIT (PW_ID_CORE, PW_PERM_RWX);
fbc0514
+  permission_items[1] = PW_PERMISSION_INIT (PW_ID_ANY, 0);
fbc0514
 
fbc0514
-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
fbc0514
-                             &SPA_DICT_INIT (permission_items,
fbc0514
-                                             G_N_ELEMENTS (permission_items)));
fbc0514
+  pw_client_update_permissions (pw_core_get_client(remote->core),
fbc0514
+                                G_N_ELEMENTS (permission_items),
fbc0514
+                                permission_items);
fbc0514
 
fbc0514
   pipewire_remote_roundtrip (remote);
fbc0514
 
fbc0514
@@ -219,7 +219,7 @@ handle_open_pipewire_remote (XdpCamera *object,
fbc0514
     }
fbc0514
 
fbc0514
   out_fd_list = g_unix_fd_list_new ();
fbc0514
-  fd = pw_remote_steal_fd (remote->remote);
fbc0514
+  fd = pw_core_steal_fd (remote->core);
fbc0514
   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
fbc0514
   close (fd);
fbc0514
   pipewire_remote_destroy (remote);
fbc0514
@@ -250,29 +250,28 @@ camera_iface_init (XdpCameraIface *iface)
fbc0514
 static void
fbc0514
 global_added_cb (PipeWireRemote *remote,
fbc0514
                  uint32_t id,
fbc0514
-                 uint32_t type,
fbc0514
+                 const char *type,
fbc0514
                  const struct spa_dict *props,
fbc0514
                  gpointer user_data)
fbc0514
 {
fbc0514
   Camera *camera = user_data;
fbc0514
-  struct pw_type *core_type = pw_core_get_type (remote->core);
fbc0514
   const struct spa_dict_item *media_class;
fbc0514
   const struct spa_dict_item *media_role;
fbc0514
 
fbc0514
-  if (type != core_type->node)
fbc0514
+  if (strcmp(type, PW_TYPE_INTERFACE_Node) != 0)
fbc0514
     return;
fbc0514
 
fbc0514
   if (!props)
fbc0514
     return;
fbc0514
 
fbc0514
-  media_class = spa_dict_lookup_item (props, "media.class");
fbc0514
+  media_class = spa_dict_lookup_item (props, PW_KEY_MEDIA_CLASS);
fbc0514
   if (!media_class)
fbc0514
     return;
fbc0514
 
fbc0514
   if (g_strcmp0 (media_class->value, "Video/Source") != 0)
fbc0514
     return;
fbc0514
 
fbc0514
-  media_role = spa_dict_lookup_item (props, "media.role");
fbc0514
+  media_role = spa_dict_lookup_item (props, PW_KEY_MEDIA_ROLE);
fbc0514
   if (!media_role)
fbc0514
     return;
fbc0514
 
fbc0514
@@ -342,6 +341,7 @@ create_pipewire_remote (Camera *camera,
fbc0514
     }
fbc0514
 
fbc0514
   pipewire_properties = pw_properties_new ("pipewire.access.portal.is_portal", "true",
fbc0514
+                                           "portal.monitor", "Camera",
fbc0514
                                            NULL);
fbc0514
   camera->pipewire_remote = pipewire_remote_new_sync (pipewire_properties,
fbc0514
                                                       global_added_cb,
fbc0514
diff --git a/src/pipewire.c b/src/pipewire.c
fbc0514
index 793a378..162cd55 100644
fbc0514
--- a/src/pipewire.c
fbc0514
+++ b/src/pipewire.c
fbc0514
@@ -21,6 +21,7 @@
fbc0514
 #include <errno.h>
fbc0514
 #include <glib.h>
fbc0514
 #include <pipewire/pipewire.h>
fbc0514
+#include <spa/utils/result.h>
fbc0514
 
fbc0514
 #include "pipewire.h"
fbc0514
 
fbc0514
@@ -36,27 +37,25 @@ static gboolean is_pipewire_initialized = FALSE;
fbc0514
 static void
fbc0514
 registry_event_global (void *user_data,
fbc0514
                        uint32_t id,
fbc0514
-                       uint32_t parent_id,
fbc0514
                        uint32_t permissions,
fbc0514
-                       uint32_t type,
fbc0514
+                       const char *type,
fbc0514
                        uint32_t version,
fbc0514
                        const struct spa_dict *props)
fbc0514
 {
fbc0514
   PipeWireRemote *remote = user_data;
fbc0514
-  struct pw_type *core_type = pw_core_get_type (remote->core);
fbc0514
   const struct spa_dict_item *factory_object_type;
fbc0514
   PipeWireGlobal *global;
fbc0514
 
fbc0514
   global = g_new0 (PipeWireGlobal, 1);
fbc0514
   *global = (PipeWireGlobal) {
fbc0514
-    .parent_id = parent_id,
fbc0514
+    .parent_id = id,
fbc0514
   };
fbc0514
 
fbc0514
   g_hash_table_insert (remote->globals, GINT_TO_POINTER (id), global);
fbc0514
   if (remote->global_added_cb)
fbc0514
     remote->global_added_cb (remote, id, type, props, remote->user_data);
fbc0514
 
fbc0514
-  if (type != core_type->factory)
fbc0514
+  if (strcmp(type, PW_TYPE_INTERFACE_Factory) != 0)
fbc0514
     return;
fbc0514
 
fbc0514
   factory_object_type = spa_dict_lookup_item (props, "factory.type.name");
fbc0514
@@ -81,8 +80,8 @@ registry_event_global_remove (void *user_data,
fbc0514
   g_hash_table_remove (remote->globals, GINT_TO_POINTER (id));
fbc0514
 }
fbc0514
 
fbc0514
-static const struct pw_registry_proxy_events registry_events = {
fbc0514
-  PW_VERSION_REGISTRY_PROXY_EVENTS,
fbc0514
+static const struct pw_registry_events registry_events = {
fbc0514
+  PW_VERSION_REGISTRY_EVENTS,
fbc0514
   .global = registry_event_global,
fbc0514
   .global_remove = registry_event_global_remove,
fbc0514
 };
fbc0514
@@ -90,7 +89,7 @@ static const struct pw_registry_proxy_events registry_events = {
fbc0514
 void
fbc0514
 pipewire_remote_roundtrip (PipeWireRemote *remote)
fbc0514
 {
fbc0514
-  pw_core_proxy_sync (remote->core_proxy, ++remote->sync_seq);
fbc0514
+  remote->sync_seq = pw_core_sync (remote->core, PW_ID_CORE, remote->sync_seq);
fbc0514
   pw_main_loop_run (remote->loop);
fbc0514
 }
fbc0514
 
fbc0514
@@ -98,16 +97,13 @@ static gboolean
fbc0514
 discover_node_factory_sync (PipeWireRemote *remote,
fbc0514
                             GError **error)
fbc0514
 {
fbc0514
-  struct pw_type *core_type = pw_core_get_type (remote->core);
fbc0514
-  struct pw_registry_proxy *registry_proxy;
fbc0514
+  struct pw_registry *registry;
fbc0514
 
fbc0514
-  registry_proxy = pw_core_proxy_get_registry (remote->core_proxy,
fbc0514
-                                               core_type->registry,
fbc0514
-                                               PW_VERSION_REGISTRY, 0);
fbc0514
-  pw_registry_proxy_add_listener (registry_proxy,
fbc0514
-                                  &remote->registry_listener,
fbc0514
-                                  &registry_events,
fbc0514
-                                  remote);
fbc0514
+  registry = pw_core_get_registry (remote->core, PW_VERSION_REGISTRY, 0);
fbc0514
+  pw_registry_add_listener (registry,
fbc0514
+                            &remote->registry_listener,
fbc0514
+                            &registry_events,
fbc0514
+                            remote);
fbc0514
 
fbc0514
   pipewire_remote_roundtrip (remote);
fbc0514
 
fbc0514
@@ -122,59 +118,35 @@ discover_node_factory_sync (PipeWireRemote *remote,
fbc0514
 }
fbc0514
 
fbc0514
 static void
fbc0514
-on_state_changed (void *user_data,
fbc0514
-                  enum pw_remote_state old,
fbc0514
-                  enum pw_remote_state state,
fbc0514
-                  const char *error)
fbc0514
+core_event_error (void       *user_data,
fbc0514
+                  uint32_t    id,
fbc0514
+		  int         seq,
fbc0514
+		  int         res,
fbc0514
+		  const char *message)
fbc0514
 {
fbc0514
   PipeWireRemote *remote = user_data;
fbc0514
 
fbc0514
-  switch (state)
fbc0514
+  if (id == PW_ID_CORE)
fbc0514
     {
fbc0514
-    case PW_REMOTE_STATE_ERROR:
fbc0514
-      if (!remote->error)
fbc0514
-        {
fbc0514
-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
fbc0514
-                       "%s", error);
fbc0514
-        }
fbc0514
+      g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
fbc0514
+                 "%s", message);
fbc0514
       pw_main_loop_quit (remote->loop);
fbc0514
-      break;
fbc0514
-    case PW_REMOTE_STATE_UNCONNECTED:
fbc0514
-      if (!remote->error)
fbc0514
-        {
fbc0514
-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
fbc0514
-                       "Disconnected");
fbc0514
-        }
fbc0514
-      pw_main_loop_quit (remote->loop);
fbc0514
-      break;
fbc0514
-    case PW_REMOTE_STATE_CONNECTING:
fbc0514
-      break;
fbc0514
-    case PW_REMOTE_STATE_CONNECTED:
fbc0514
-      pw_main_loop_quit (remote->loop);
fbc0514
-      break;
fbc0514
-    default:
fbc0514
-      g_warning ("Unknown PipeWire state");
fbc0514
-      break;
fbc0514
     }
fbc0514
 }
fbc0514
 
fbc0514
-static const struct pw_remote_events remote_events = {
fbc0514
-  PW_VERSION_REMOTE_EVENTS,
fbc0514
-  .state_changed = on_state_changed,
fbc0514
-};
fbc0514
-
fbc0514
 static void
fbc0514
 core_event_done (void *user_data,
fbc0514
-                 uint32_t seq)
fbc0514
+                 uint32_t id, int seq)
fbc0514
 {
fbc0514
   PipeWireRemote *remote = user_data;
fbc0514
 
fbc0514
-  if (remote->sync_seq == seq)
fbc0514
+  if (id == PW_ID_CORE && remote->sync_seq == seq)
fbc0514
     pw_main_loop_quit (remote->loop);
fbc0514
 }
fbc0514
 
fbc0514
-static const struct pw_core_proxy_events core_events = {
fbc0514
-  PW_VERSION_CORE_PROXY_EVENTS,
fbc0514
+static const struct pw_core_events core_events = {
fbc0514
+  PW_VERSION_CORE_EVENTS,
fbc0514
+  .error = core_event_error,
fbc0514
   .done = core_event_done,
fbc0514
 };
fbc0514
 
fbc0514
@@ -237,8 +209,8 @@ void
fbc0514
 pipewire_remote_destroy (PipeWireRemote *remote)
fbc0514
 {
fbc0514
   g_clear_pointer (&remote->globals, g_hash_table_destroy);
fbc0514
-  g_clear_pointer (&remote->remote, pw_remote_destroy);
fbc0514
-  g_clear_pointer (&remote->core, pw_core_destroy);
fbc0514
+  g_clear_pointer (&remote->core, pw_core_disconnect);
fbc0514
+  g_clear_pointer (&remote->context, pw_context_destroy);
fbc0514
   g_clear_pointer (&remote->loop, pw_main_loop_destroy);
fbc0514
   g_clear_error (&remote->error);
fbc0514
 
fbc0514
@@ -307,68 +279,31 @@ pipewire_remote_new_sync (struct pw_properties *pipewire_properties,
fbc0514
       return NULL;
fbc0514
     }
fbc0514
 
fbc0514
-  remote->core = pw_core_new (pw_main_loop_get_loop (remote->loop), NULL);
fbc0514
-  if (!remote->core)
fbc0514
+  remote->context = pw_context_new (pw_main_loop_get_loop (remote->loop), NULL, 0);
fbc0514
+  if (!remote->context)
fbc0514
     {
fbc0514
       pipewire_remote_destroy (remote);
fbc0514
       pw_properties_free (pipewire_properties);
fbc0514
       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
fbc0514
-                   "Couldn't create PipeWire core");
fbc0514
+                   "Couldn't create PipeWire context");
fbc0514
       return NULL;
fbc0514
     }
fbc0514
 
fbc0514
-  remote->remote = pw_remote_new (remote->core, pipewire_properties, 0);
fbc0514
-  if (!remote->remote)
fbc0514
+  remote->core = pw_context_connect (remote->context, pipewire_properties, 0);
fbc0514
+  if (!remote->core)
fbc0514
     {
fbc0514
       pipewire_remote_destroy (remote);
fbc0514
       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
fbc0514
-                   "Couldn't create PipeWire remote");
fbc0514
+                   "Couldn't connect to PipeWire");
fbc0514
       return NULL;
fbc0514
     }
fbc0514
 
fbc0514
   remote->globals = g_hash_table_new_full (NULL, NULL, NULL, g_free);
fbc0514
 
fbc0514
-  pw_remote_add_listener (remote->remote,
fbc0514
-                          &remote->remote_listener,
fbc0514
-                          &remote_events,
fbc0514
-                          remote);
fbc0514
-
fbc0514
-  if (pw_remote_connect (remote->remote) != 0)
fbc0514
-    {
fbc0514
-      pipewire_remote_destroy (remote);
fbc0514
-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
fbc0514
-                   "Couldn't connect PipeWire remote");
fbc0514
-      return NULL;
fbc0514
-    }
fbc0514
-
fbc0514
-  pw_main_loop_run (remote->loop);
fbc0514
-
fbc0514
-  switch (pw_remote_get_state (remote->remote, NULL))
fbc0514
-    {
fbc0514
-    case PW_REMOTE_STATE_ERROR:
fbc0514
-    case PW_REMOTE_STATE_UNCONNECTED:
fbc0514
-      *error = g_steal_pointer (&remote->error);
fbc0514
-      pipewire_remote_destroy (remote);
fbc0514
-      return NULL;
fbc0514
-    case PW_REMOTE_STATE_CONNECTING:
fbc0514
-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
fbc0514
-                   "PipeWire loop stopped unexpectedly");
fbc0514
-      pipewire_remote_destroy (remote);
fbc0514
-      return NULL;
fbc0514
-    case PW_REMOTE_STATE_CONNECTED:
fbc0514
-      break;
fbc0514
-    default:
fbc0514
-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
fbc0514
-                   "Unexpected PipeWire state");
fbc0514
-      pipewire_remote_destroy (remote);
fbc0514
-      return NULL;
fbc0514
-    }
fbc0514
-
fbc0514
-  remote->core_proxy = pw_remote_get_core_proxy (remote->remote);
fbc0514
-  pw_core_proxy_add_listener (remote->core_proxy,
fbc0514
-                              &remote->core_listener,
fbc0514
-                              &core_events,
fbc0514
-                              remote);
fbc0514
+  pw_core_add_listener (remote->core,
fbc0514
+                        &remote->core_listener,
fbc0514
+                        &core_events,
fbc0514
+                        remote);
fbc0514
 
fbc0514
   if (!discover_node_factory_sync (remote, error))
fbc0514
     {
fbc0514
diff --git a/src/pipewire.h b/src/pipewire.h
fbc0514
index 0f1bf54..bf48d5e 100644
fbc0514
--- a/src/pipewire.h
fbc0514
+++ b/src/pipewire.h
fbc0514
@@ -32,7 +32,7 @@ typedef struct _PipeWireGlobal
fbc0514
 
fbc0514
 typedef void (* PipeWireGlobalAddedCallback) (PipeWireRemote *remote,
fbc0514
                                               uint32_t id,
fbc0514
-                                              uint32_t type,
fbc0514
+                                              const char *type,
fbc0514
                                               const struct spa_dict *props,
fbc0514
                                               gpointer user_data);
fbc0514
 
fbc0514
@@ -43,13 +43,11 @@ typedef void (* PipeWireGlobalRemovedCallback) (PipeWireRemote *remote,
fbc0514
 struct _PipeWireRemote
fbc0514
 {
fbc0514
   struct pw_main_loop *loop;
fbc0514
+  struct pw_context *context;
fbc0514
   struct pw_core *core;
fbc0514
-  struct pw_remote *remote;
fbc0514
-  struct spa_hook remote_listener;
fbc0514
-
fbc0514
-  struct pw_core_proxy *core_proxy;
fbc0514
   struct spa_hook core_listener;
fbc0514
-  uint32_t sync_seq;
fbc0514
+
fbc0514
+  int sync_seq;
fbc0514
 
fbc0514
   struct spa_hook registry_listener;
fbc0514
 
fbc0514
diff --git a/src/screen-cast.c b/src/screen-cast.c
fbc0514
index 7881ddc..1677050 100644
fbc0514
--- a/src/screen-cast.c
fbc0514
+++ b/src/screen-cast.c
fbc0514
@@ -31,10 +31,10 @@
fbc0514
 #include "xdp-impl-dbus.h"
fbc0514
 #include "xdp-utils.h"
fbc0514
 
fbc0514
-#define PERMISSION_ITEM(item_key, item_value) \
fbc0514
-  ((struct spa_dict_item) { \
fbc0514
-    .key = item_key, \
fbc0514
-    .value = item_value \
fbc0514
+#define PERMISSION_ITEM(item_id, item_permissions) \
fbc0514
+  ((struct pw_permission) { \
fbc0514
+    .id = item_id, \
fbc0514
+    .permissions = item_permissions \
fbc0514
   })
fbc0514
 
fbc0514
 typedef struct _ScreenCast ScreenCast;
fbc0514
@@ -517,42 +517,9 @@ screen_cast_stream_get_pipewire_node_id (ScreenCastStream *stream)
fbc0514
   return stream->id;
fbc0514
 }
fbc0514
 
fbc0514
-static void
fbc0514
-append_parent_permissions (PipeWireRemote *remote,
fbc0514
-                           GArray *permission_items,
fbc0514
-                           GList **string_stash,
fbc0514
-                           PipeWireGlobal *global,
fbc0514
-                           const char *permission)
fbc0514
-{
fbc0514
-  PipeWireGlobal *parent;
fbc0514
-  char *parent_permission_value;
fbc0514
-
fbc0514
-  if (global->parent_id == 0)
fbc0514
-    return;
fbc0514
-
fbc0514
-  parent = g_hash_table_lookup (remote->globals, GINT_TO_POINTER (global->parent_id));
fbc0514
-
fbc0514
-  if (parent->permission_set)
fbc0514
-    return;
fbc0514
-  parent->permission_set = TRUE;
fbc0514
-
fbc0514
-  append_parent_permissions (remote, permission_items, string_stash,
fbc0514
-                             parent, permission);
fbc0514
-
fbc0514
-  parent_permission_value = g_strdup_printf ("%u:%s",
fbc0514
-                                             global->parent_id,
fbc0514
-                                             permission);
fbc0514
-  *string_stash = g_list_prepend (*string_stash, parent_permission_value);
fbc0514
-
fbc0514
-  g_array_append_val (permission_items,
fbc0514
-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
fbc0514
-                                       parent_permission_value));
fbc0514
-}
fbc0514
-
fbc0514
 static void
fbc0514
 append_stream_permissions (PipeWireRemote *remote,
fbc0514
                            GArray *permission_items,
fbc0514
-                           GList **string_stash,
fbc0514
                            GList *streams)
fbc0514
 {
fbc0514
   GList *l;
fbc0514
@@ -561,21 +528,10 @@ append_stream_permissions (PipeWireRemote *remote,
fbc0514
     {
fbc0514
       ScreenCastStream *stream = l->data;
fbc0514
       uint32_t stream_id;
fbc0514
-      PipeWireGlobal *stream_global;
fbc0514
-      char *stream_permission_value;
fbc0514
 
fbc0514
       stream_id = screen_cast_stream_get_pipewire_node_id (stream);
fbc0514
-      stream_global = g_hash_table_lookup (remote->globals,
fbc0514
-                                           GINT_TO_POINTER (stream_id));
fbc0514
-
fbc0514
-      append_parent_permissions (remote, permission_items, string_stash,
fbc0514
-                                 stream_global, "r--");
fbc0514
-
fbc0514
-      stream_permission_value = g_strdup_printf ("%u:rwx", stream_id);
fbc0514
-      *string_stash = g_list_prepend (*string_stash, stream_permission_value);
fbc0514
       g_array_append_val (permission_items,
fbc0514
-                          PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
fbc0514
-                                           stream_permission_value));
fbc0514
+                          PERMISSION_ITEM (stream_id, PW_PERM_RWX));
fbc0514
     }
fbc0514
 }
fbc0514
 
fbc0514
@@ -587,9 +543,6 @@ open_pipewire_screen_cast_remote (const char *app_id,
fbc0514
   struct pw_properties *pipewire_properties;
fbc0514
   PipeWireRemote *remote;
fbc0514
   g_autoptr(GArray) permission_items = NULL;
fbc0514
-  char *node_factory_permission_string;
fbc0514
-  GList *string_stash = NULL;
fbc0514
-  struct spa_dict *permission_dict;
fbc0514
   PipeWireGlobal *node_global;
fbc0514
 
fbc0514
   pipewire_properties = pw_properties_new ("pipewire.access.portal.app_id", app_id,
fbc0514
@@ -603,48 +556,31 @@ open_pipewire_screen_cast_remote (const char *app_id,
fbc0514
 
fbc0514
   permission_items = g_array_new (FALSE, TRUE, sizeof (struct spa_dict_item));
fbc0514
 
fbc0514
-  /*
fbc0514
-   * Hide all existing and future nodes (except the ones we explicitly list below.
fbc0514
-   */
fbc0514
-  g_array_append_val (permission_items,
fbc0514
-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_EXISTING,
fbc0514
-                                       "---"));
fbc0514
-  g_array_append_val (permission_items,
fbc0514
-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_DEFAULT,
fbc0514
-                                       "---"));
fbc0514
-
fbc0514
   /*
fbc0514
    * PipeWire:Interface:Core
fbc0514
    * Needs rwx to be able create the sink node using the create-object method
fbc0514
    */
fbc0514
   g_array_append_val (permission_items,
fbc0514
-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
fbc0514
-                                       "0:rwx"));
fbc0514
+                      PERMISSION_ITEM (PW_ID_CORE, PW_PERM_RWX));
fbc0514
 
fbc0514
   /*
fbc0514
    * PipeWire:Interface:NodeFactory
fbc0514
    * Needs r-- so it can be passed to create-object when creating the sink node.
fbc0514
    */
fbc0514
-  node_factory_permission_string = g_strdup_printf ("%d:r--",
fbc0514
-                                                    remote->node_factory_id);
fbc0514
-  string_stash = g_list_prepend (string_stash, node_factory_permission_string);
fbc0514
   g_array_append_val (permission_items,
fbc0514
-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
fbc0514
-                                       node_factory_permission_string));
fbc0514
-  node_global = g_hash_table_lookup (remote->globals,
fbc0514
-                                     GINT_TO_POINTER (remote->node_factory_id));
fbc0514
-  append_parent_permissions (remote, permission_items, &string_stash,
fbc0514
-                             node_global, "r--");
fbc0514
+                      PERMISSION_ITEM (remote->node_factory_id, PW_PERM_R));
fbc0514
 
fbc0514
-  append_stream_permissions (remote, permission_items, &string_stash, streams);
fbc0514
+  append_stream_permissions (remote, permission_items, streams);
fbc0514
 
fbc0514
-  permission_dict =
fbc0514
-    &SPA_DICT_INIT ((struct spa_dict_item *) permission_items->data,
fbc0514
-                    permission_items->len);
fbc0514
-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
fbc0514
-                             permission_dict);
fbc0514
+  /*
fbc0514
+   * Hide all existing and future nodes (except the ones we explicitly list above).
fbc0514
+   */
fbc0514
+  g_array_append_val (permission_items,
fbc0514
+                      PERMISSION_ITEM (PW_ID_ANY, 0));
fbc0514
 
fbc0514
-  g_list_free_full (string_stash, g_free);
fbc0514
+  pw_client_update_permissions (pw_core_get_client(remote->core),
fbc0514
+                                permission_items->len,
fbc0514
+                                (const struct pw_permission *)permission_items->data);
fbc0514
 
fbc0514
   pipewire_remote_roundtrip (remote);
fbc0514
 
fbc0514
@@ -943,7 +879,7 @@ handle_open_pipewire_remote (XdpScreenCast *object,
fbc0514
     }
fbc0514
 
fbc0514
   out_fd_list = g_unix_fd_list_new ();
fbc0514
-  fd = pw_remote_steal_fd (remote->remote);
fbc0514
+  fd = pw_core_steal_fd (remote->core);
fbc0514
   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
fbc0514
   close (fd);
fbc0514
   pipewire_remote_destroy (remote);
fbc0514
-- 
fbc0514
2.24.1
fbc0514