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

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