Commit a63f2bb9 authored by George Kiagiadakis's avatar George Kiagiadakis

lib/wp: merge both WpRemote & WpRemotePipewire in WpCore

In practice we always create a remote and connect to pipewire.
Any other scenario is invalid, therefore, it is not justified
to be confused with so many classes for such small functionality.
This simplifies a lot the modules code.

Also, this commit exposes the pw_core and pw_remote objects
out of WpCore. This is in practice useful when dealing with low-level
pw and spa factories, which are used in the monitors. Let's not
add API wrappers for everything... Bindings will never use this
functionality anyway, since it depends on low level pipewire C API.
parent 84b752e3
This diff is collapsed.
...@@ -10,12 +10,57 @@ ...@@ -10,12 +10,57 @@
#define __WIREPLUMBER_CORE_H__ #define __WIREPLUMBER_CORE_H__
#include <glib-object.h> #include <glib-object.h>
#include "proxy.h"
G_BEGIN_DECLS G_BEGIN_DECLS
struct pw_core;
struct pw_remote;
/**
* WpRemoteState:
* @WP_REMOTE_STATE_ERROR: remote is in error
* @WP_REMOTE_STATE_UNCONNECTED: not connected
* @WP_REMOTE_STATE_CONNECTING: connecting to remote service
* @WP_REMOTE_STATE_CONNECTED: remote is connected and ready
*
* The different states the remote can be
*/
typedef enum {
WP_REMOTE_STATE_ERROR = -1,
WP_REMOTE_STATE_UNCONNECTED = 0,
WP_REMOTE_STATE_CONNECTING = 1,
WP_REMOTE_STATE_CONNECTED = 2,
} WpRemoteState;
#define WP_TYPE_CORE (wp_core_get_type ()) #define WP_TYPE_CORE (wp_core_get_type ())
G_DECLARE_FINAL_TYPE (WpCore, wp_core, WP, CORE, GObject) G_DECLARE_FINAL_TYPE (WpCore, wp_core, WP, CORE, GObject)
WpCore * wp_core_new (GMainContext *context);
GMainContext * wp_core_get_context (WpCore * self);
struct pw_core * wp_core_get_pw_core (WpCore * self);
struct pw_remote * wp_core_get_pw_remote (WpCore * self);
gboolean wp_core_connect (WpCore * self);
WpRemoteState wp_core_get_remote_state (WpCore * self, const gchar ** error);
void wp_core_set_default_proxy_features (
WpCore * self, GType proxy_type, WpProxyFeatures features);
WpProxy * wp_core_create_remote_object (WpCore * self,
const gchar * factory_name, guint32 interface_type,
guint32 interface_version, WpProperties * properties);
/* private */
struct pw_core_proxy;
struct pw_registry_proxy;
struct pw_core_proxy * wp_core_get_pw_core_proxy (WpCore * self);
struct pw_registry_proxy * wp_core_get_pw_registry_proxy (WpCore * self);
enum { enum {
WP_CORE_FOREACH_GLOBAL_DONE = FALSE, WP_CORE_FOREACH_GLOBAL_DONE = FALSE,
WP_CORE_FOREACH_GLOBAL_CONTINUE = TRUE, WP_CORE_FOREACH_GLOBAL_CONTINUE = TRUE,
...@@ -24,8 +69,6 @@ enum { ...@@ -24,8 +69,6 @@ enum {
typedef gboolean (*WpCoreForeachGlobalFunc) (GQuark key, gpointer global, typedef gboolean (*WpCoreForeachGlobalFunc) (GQuark key, gpointer global,
gpointer user_data); gpointer user_data);
WpCore * wp_core_new (void);
gpointer wp_core_get_global (WpCore * self, GQuark key); gpointer wp_core_get_global (WpCore * self, GQuark key);
void wp_core_foreach_global (WpCore * self, WpCoreForeachGlobalFunc callback, void wp_core_foreach_global (WpCore * self, WpCoreForeachGlobalFunc callback,
gpointer user_data); gpointer user_data);
...@@ -46,14 +89,6 @@ GQuark wp_global_module_quark (void); ...@@ -46,14 +89,6 @@ GQuark wp_global_module_quark (void);
#define WP_GLOBAL_POLICY_MANAGER (wp_global_policy_manager_quark ()) #define WP_GLOBAL_POLICY_MANAGER (wp_global_policy_manager_quark ())
GQuark wp_global_policy_manager_quark (void); GQuark wp_global_policy_manager_quark (void);
/**
* WP_GLOBAL_REMOTE_PIPEWIRE:
* The key to access the #WpRemote global object that maintains
* the connection to pipewire
*/
#define WP_GLOBAL_REMOTE_PIPEWIRE (wp_global_remote_pipewire_quark ())
GQuark wp_global_remote_pipewire_quark (void);
G_END_DECLS G_END_DECLS
#endif #endif
...@@ -11,8 +11,6 @@ wp_lib_sources = [ ...@@ -11,8 +11,6 @@ wp_lib_sources = [
'proxy-link.c', 'proxy-link.c',
'proxy-node.c', 'proxy-node.c',
'proxy-port.c', 'proxy-port.c',
'remote.c',
'remote-pipewire.c',
] ]
wp_lib_headers = [ wp_lib_headers = [
...@@ -28,8 +26,6 @@ wp_lib_headers = [ ...@@ -28,8 +26,6 @@ wp_lib_headers = [
'proxy-node.h', 'proxy-node.h',
'proxy-port.h', 'proxy-port.h',
'proxy-link.h', 'proxy-link.h',
'remote.h',
'remote-pipewire.h',
'wp.h', 'wp.h',
] ]
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
*/ */
#include "proxy.h" #include "proxy.h"
#include "core.h"
#include "error.h" #include "error.h"
#include "remote-pipewire.h"
#include "wpenums.h" #include "wpenums.h"
#include "proxy-client.h" #include "proxy-client.h"
...@@ -24,7 +24,7 @@ typedef struct _WpProxyPrivate WpProxyPrivate; ...@@ -24,7 +24,7 @@ typedef struct _WpProxyPrivate WpProxyPrivate;
struct _WpProxyPrivate struct _WpProxyPrivate
{ {
/* properties */ /* properties */
GWeakRef remote; GWeakRef core;
guint32 global_id; guint32 global_id;
guint32 global_perm; guint32 global_perm;
...@@ -48,7 +48,7 @@ struct _WpProxyPrivate ...@@ -48,7 +48,7 @@ struct _WpProxyPrivate
enum { enum {
PROP_0, PROP_0,
PROP_REMOTE, PROP_CORE,
PROP_GLOBAL_ID, PROP_GLOBAL_ID,
PROP_GLOBAL_PERMISSIONS, PROP_GLOBAL_PERMISSIONS,
PROP_GLOBAL_PROPERTIES, PROP_GLOBAL_PROPERTIES,
...@@ -194,7 +194,7 @@ wp_proxy_init (WpProxy * self) ...@@ -194,7 +194,7 @@ wp_proxy_init (WpProxy * self)
{ {
WpProxyPrivate *priv = wp_proxy_get_instance_private (self); WpProxyPrivate *priv = wp_proxy_get_instance_private (self);
g_weak_ref_init (&priv->remote, NULL); g_weak_ref_init (&priv->core, NULL);
priv->async_tasks = g_hash_table_new_full (g_direct_hash, g_direct_equal, priv->async_tasks = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL, g_object_unref); NULL, g_object_unref);
} }
...@@ -221,7 +221,7 @@ wp_proxy_finalize (GObject * object) ...@@ -221,7 +221,7 @@ wp_proxy_finalize (GObject * object)
g_clear_object (&priv->task); g_clear_object (&priv->task);
g_clear_pointer (&priv->global_props, wp_properties_unref); g_clear_pointer (&priv->global_props, wp_properties_unref);
g_clear_pointer (&priv->pw_proxy, pw_proxy_destroy); g_clear_pointer (&priv->pw_proxy, pw_proxy_destroy);
g_weak_ref_clear (&priv->remote); g_weak_ref_clear (&priv->core);
g_clear_pointer (&priv->async_tasks, g_hash_table_unref); g_clear_pointer (&priv->async_tasks, g_hash_table_unref);
G_OBJECT_CLASS (wp_proxy_parent_class)->finalize (object); G_OBJECT_CLASS (wp_proxy_parent_class)->finalize (object);
...@@ -234,8 +234,8 @@ wp_proxy_set_property (GObject * object, guint property_id, ...@@ -234,8 +234,8 @@ wp_proxy_set_property (GObject * object, guint property_id,
WpProxyPrivate *priv = wp_proxy_get_instance_private (WP_PROXY(object)); WpProxyPrivate *priv = wp_proxy_get_instance_private (WP_PROXY(object));
switch (property_id) { switch (property_id) {
case PROP_REMOTE: case PROP_CORE:
g_weak_ref_set (&priv->remote, g_value_get_object (value)); g_weak_ref_set (&priv->core, g_value_get_object (value));
break; break;
case PROP_GLOBAL_ID: case PROP_GLOBAL_ID:
priv->global_id = g_value_get_uint (value); priv->global_id = g_value_get_uint (value);
...@@ -268,8 +268,8 @@ wp_proxy_get_property (GObject * object, guint property_id, GValue * value, ...@@ -268,8 +268,8 @@ wp_proxy_get_property (GObject * object, guint property_id, GValue * value,
WpProxyPrivate *priv = wp_proxy_get_instance_private (WP_PROXY(object)); WpProxyPrivate *priv = wp_proxy_get_instance_private (WP_PROXY(object));
switch (property_id) { switch (property_id) {
case PROP_REMOTE: case PROP_CORE:
g_value_take_object (value, g_weak_ref_get (&priv->remote)); g_value_take_object (value, g_weak_ref_get (&priv->core));
break; break;
case PROP_GLOBAL_ID: case PROP_GLOBAL_ID:
g_value_set_uint (value, priv->global_id); g_value_set_uint (value, priv->global_id);
...@@ -309,7 +309,7 @@ static void ...@@ -309,7 +309,7 @@ static void
wp_proxy_default_augment (WpProxy * self, WpProxyFeatures features) wp_proxy_default_augment (WpProxy * self, WpProxyFeatures features)
{ {
WpProxyPrivate *priv = wp_proxy_get_instance_private (self); WpProxyPrivate *priv = wp_proxy_get_instance_private (self);
g_autoptr (WpRemote) remote = NULL; g_autoptr (WpCore) core = NULL;
/* ensure we have a pw_proxy, as we can't have /* ensure we have a pw_proxy, as we can't have
* any other feature without first having that */ * any other feature without first having that */
...@@ -327,13 +327,13 @@ wp_proxy_default_augment (WpProxy * self, WpProxyFeatures features) ...@@ -327,13 +327,13 @@ wp_proxy_default_augment (WpProxy * self, WpProxyFeatures features)
return; return;
} }
remote = g_weak_ref_get (&priv->remote); core = g_weak_ref_get (&priv->core);
g_return_if_fail (remote); g_return_if_fail (core);
/* bind */ /* bind */
priv->pw_proxy = wp_remote_pipewire_proxy_bind ( priv->pw_proxy = pw_registry_proxy_bind (
WP_REMOTE_PIPEWIRE (remote), wp_core_get_pw_registry_proxy (core), priv->global_id,
priv->global_id, priv->iface_type); priv->iface_type, priv->iface_version, 0);
wp_proxy_got_pw_proxy (self); wp_proxy_got_pw_proxy (self);
} }
} }
...@@ -352,9 +352,8 @@ wp_proxy_class_init (WpProxyClass * klass) ...@@ -352,9 +352,8 @@ wp_proxy_class_init (WpProxyClass * klass)
/* Install the properties */ /* Install the properties */
g_object_class_install_property (object_class, PROP_REMOTE, g_object_class_install_property (object_class, PROP_CORE,
g_param_spec_object ("remote", "remote", g_param_spec_object ("core", "core", "The WpCore", WP_TYPE_CORE,
"The pipewire connection WpRemote", WP_TYPE_REMOTE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_GLOBAL_ID, g_object_class_install_property (object_class, PROP_GLOBAL_ID,
...@@ -414,13 +413,13 @@ wp_proxy_class_init (WpProxyClass * klass) ...@@ -414,13 +413,13 @@ wp_proxy_class_init (WpProxyClass * klass)
} }
WpProxy * WpProxy *
wp_proxy_new_global (WpRemote * remote, wp_proxy_new_global (WpCore * core,
guint32 id, guint32 permissions, WpProperties * properties, guint32 id, guint32 permissions, WpProperties * properties,
guint32 type, guint32 version) guint32 type, guint32 version)
{ {
GType gtype = wp_proxy_find_instance_type (type, version); GType gtype = wp_proxy_find_instance_type (type, version);
return g_object_new (gtype, return g_object_new (gtype,
"remote", remote, "core", core,
"global-id", id, "global-id", id,
"global-permissions", permissions, "global-permissions", permissions,
"global-properties", properties, "global-properties", properties,
...@@ -430,12 +429,12 @@ wp_proxy_new_global (WpRemote * remote, ...@@ -430,12 +429,12 @@ wp_proxy_new_global (WpRemote * remote,
} }
WpProxy * WpProxy *
wp_proxy_new_wrap (WpRemote * remote, wp_proxy_new_wrap (WpCore * core,
struct pw_proxy * proxy, guint32 type, guint32 version) struct pw_proxy * proxy, guint32 type, guint32 version)
{ {
GType gtype = wp_proxy_find_instance_type (type, version); GType gtype = wp_proxy_find_instance_type (type, version);
return g_object_new (gtype, return g_object_new (gtype,
"remote", remote, "core", core,
"pw-proxy", proxy, "pw-proxy", proxy,
"interface-type", type, "interface-type", type,
"interface-version", version, "interface-version", version,
...@@ -544,20 +543,20 @@ wp_proxy_get_features (WpProxy * self) ...@@ -544,20 +543,20 @@ wp_proxy_get_features (WpProxy * self)
} }
/** /**
* wp_proxy_get_remote: * wp_proxy_get_core:
* @self: the proxy * @self: the proxy
* *
* Returns: (transfer full): the remote that created this proxy * Returns: (transfer full): the core that created this proxy
*/ */
WpRemote * WpCore *
wp_proxy_get_remote (WpProxy * self) wp_proxy_get_core (WpProxy * self)
{ {
WpProxyPrivate *priv; WpProxyPrivate *priv;
g_return_val_if_fail (WP_IS_PROXY (self), NULL); g_return_val_if_fail (WP_IS_PROXY (self), NULL);
priv = wp_proxy_get_instance_private (self); priv = wp_proxy_get_instance_private (self);
return g_weak_ref_get (&priv->remote); return g_weak_ref_get (&priv->core);
} }
gboolean gboolean
......
...@@ -12,12 +12,12 @@ ...@@ -12,12 +12,12 @@
#include <gio/gio.h> #include <gio/gio.h>
#include "remote.h"
#include "properties.h" #include "properties.h"
G_BEGIN_DECLS G_BEGIN_DECLS
struct pw_proxy; struct pw_proxy;
typedef struct _WpCore WpCore;
typedef enum { /*< flags >*/ typedef enum { /*< flags >*/
WP_PROXY_FEATURE_PW_PROXY = (1 << 0), WP_PROXY_FEATURE_PW_PROXY = (1 << 0),
...@@ -40,10 +40,10 @@ struct _WpProxyClass ...@@ -40,10 +40,10 @@ struct _WpProxyClass
void (*pw_proxy_destroyed) (WpProxy * self); void (*pw_proxy_destroyed) (WpProxy * self);
}; };
WpProxy * wp_proxy_new_global (WpRemote * remote, WpProxy * wp_proxy_new_global (WpCore * core,
guint32 id, guint32 permissions, WpProperties * properties, guint32 id, guint32 permissions, WpProperties * properties,
guint32 type, guint32 version); guint32 type, guint32 version);
WpProxy * wp_proxy_new_wrap (WpRemote * remote, WpProxy * wp_proxy_new_wrap (WpCore * core,
struct pw_proxy * proxy, guint32 type, guint32 version); struct pw_proxy * proxy, guint32 type, guint32 version);
void wp_proxy_augment (WpProxy *self, void wp_proxy_augment (WpProxy *self,
...@@ -54,7 +54,7 @@ gboolean wp_proxy_augment_finish (WpProxy * self, GAsyncResult * res, ...@@ -54,7 +54,7 @@ gboolean wp_proxy_augment_finish (WpProxy * self, GAsyncResult * res,
WpProxyFeatures wp_proxy_get_features (WpProxy * self); WpProxyFeatures wp_proxy_get_features (WpProxy * self);
WpRemote * wp_proxy_get_remote (WpProxy * self); WpCore * wp_proxy_get_core (WpProxy * self);
gboolean wp_proxy_is_global (WpProxy * self); gboolean wp_proxy_is_global (WpProxy * self);
guint32 wp_proxy_get_global_id (WpProxy * self); guint32 wp_proxy_get_global_id (WpProxy * self);
......
This diff is collapsed.
/* WirePlumber
*
* Copyright © 2019 Collabora Ltd.
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
*
* SPDX-License-Identifier: MIT
*/
#ifndef __WIREPLUMBER_REMOTE_PIPEWIRE_H__
#define __WIREPLUMBER_REMOTE_PIPEWIRE_H__
#include "remote.h"
#include "proxy.h"
G_BEGIN_DECLS
#define WP_TYPE_REMOTE_PIPEWIRE (wp_remote_pipewire_get_type ())
G_DECLARE_FINAL_TYPE (WpRemotePipewire, wp_remote_pipewire,
WP, REMOTE_PIPEWIRE, WpRemote)
WpRemote *wp_remote_pipewire_new (WpCore *core, GMainContext *context);
void wp_remote_pipewire_set_default_features (
WpRemotePipewire * self, GType proxy_type, WpProxyFeatures features);
WpProxy * wp_remote_pipewire_create_object (WpRemotePipewire *self,
const gchar *factory_name, guint32 interface_type,
guint32 interface_version, WpProperties * properties);
gpointer wp_remote_pipewire_proxy_bind (WpRemotePipewire *self, guint global_id,
guint global_type);
gpointer wp_remote_pipewire_find_factory (WpRemotePipewire *self,
const char *factory_name);
void wp_remote_pipewire_add_spa_lib (WpRemotePipewire *self,
const char *factory_regexp, const char *lib);
gpointer wp_remote_pipewire_load_spa_handle(WpRemotePipewire *self,
const char *factory_name, gconstpointer info);
gpointer wp_remote_pipewire_export (WpRemotePipewire *self, guint type,
gpointer props, gpointer object, size_t user_data_size);
gpointer wp_remote_pipewire_module_load (WpRemotePipewire *self,
const char *name, const char *args, gpointer properties);
G_END_DECLS
#endif
/* WirePlumber
*
* Copyright © 2019 Collabora Ltd.
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
*
* SPDX-License-Identifier: MIT
*/
#include "remote.h"
#include "wpenums.h"
enum {
PROP_0,
PROP_CORE,
PROP_STATE,
PROP_ERROR_MESSAGE,
};
enum {
SIGNAL_STATE_CHANGED,
N_SIGNALS
};
static guint signals[N_SIGNALS];
typedef struct _WpRemotePrivate WpRemotePrivate;
struct _WpRemotePrivate
{
GWeakRef core;
};
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (WpRemote, wp_remote, G_TYPE_OBJECT)
static void
wp_remote_init (WpRemote *self)
{
WpRemotePrivate *priv = wp_remote_get_instance_private (self);
g_weak_ref_init (&priv->core, NULL);
}
static void
wp_remote_finalize (GObject *object)
{
WpRemotePrivate *priv = wp_remote_get_instance_private (WP_REMOTE (object));
g_weak_ref_clear (&priv->core);
g_debug ("%s destroyed", G_OBJECT_TYPE_NAME (object));
G_OBJECT_CLASS (wp_remote_parent_class)->finalize (object);
}
static void
wp_remote_set_property (GObject * object, guint property_id,
const GValue * value, GParamSpec * pspec)
{
WpRemotePrivate *priv = wp_remote_get_instance_private (WP_REMOTE (object));
switch (property_id) {
case PROP_CORE:
g_weak_ref_set (&priv->core, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
wp_remote_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec)
{
WpRemotePrivate *priv = wp_remote_get_instance_private (WP_REMOTE (object));
switch (property_id) {
case PROP_CORE:
g_value_take_object (value, g_weak_ref_get (&priv->core));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
wp_remote_notify (GObject *object, GParamSpec *param)
{
if (!g_strcmp0 (param->name, "state")) {
WpRemoteState state;
GParamSpecEnum *param_enum = (GParamSpecEnum *) param;
GEnumValue *value;
GQuark detail;
g_object_get (object, "state", &state, NULL);
value = g_enum_get_value (param_enum->enum_class, state);
detail = g_quark_from_static_string (value->value_nick);
g_signal_emit (object, signals[SIGNAL_STATE_CHANGED], detail, state);
}
if (G_OBJECT_CLASS (wp_remote_parent_class)->notify)
G_OBJECT_CLASS (wp_remote_parent_class)->notify (object, param);
}
static void
wp_remote_class_init (WpRemoteClass *klass)
{
GObjectClass *object_class = (GObjectClass *) klass;
object_class->finalize = wp_remote_finalize;
object_class->set_property = wp_remote_set_property;
object_class->get_property = wp_remote_get_property;
object_class->notify = wp_remote_notify;
g_object_class_install_property (object_class, PROP_CORE,
g_param_spec_object ("core", "core", "The wireplumber core",
WP_TYPE_CORE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_STATE,
g_param_spec_enum ("state", "state", "The state of the remote",
WP_TYPE_REMOTE_STATE, WP_REMOTE_STATE_UNCONNECTED,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_ERROR_MESSAGE,
g_param_spec_string ("error-message", "error-message",
"The last error message of the remote", NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
signals[SIGNAL_STATE_CHANGED] = g_signal_new ("state-changed",
G_TYPE_FROM_CLASS (klass), G_SIGNAL_DETAILED | G_SIGNAL_RUN_LAST,
0, NULL, NULL, NULL, G_TYPE_NONE, 1, WP_TYPE_REMOTE_STATE);
}
/**
* wp_remote_get_core:
* @self: the remote
*
* Returns: (transfer full): the core of the remote
*/
WpCore *
wp_remote_get_core (WpRemote *self)
{
WpRemotePrivate *priv = wp_remote_get_instance_private (self);
return g_weak_ref_get (&priv->core);
}
gboolean
wp_remote_connect (WpRemote *self)
{
if (WP_REMOTE_GET_CLASS (self)->connect)
return WP_REMOTE_GET_CLASS (self)->connect (self);
return FALSE;
}
/* WirePlumber
*
* Copyright © 2019 Collabora Ltd.
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
*
* SPDX-License-Identifier: MIT
*/
#ifndef __WIREPLUMBER_REMOTE_H__
#define __WIREPLUMBER_REMOTE_H__
#include "core.h"
G_BEGIN_DECLS
/**
* WpRemoteState:
* @WP_REMOTE_STATE_ERROR: remote is in error
* @WP_REMOTE_STATE_UNCONNECTED: not connected
* @WP_REMOTE_STATE_CONNECTING: connecting to remote service
* @WP_REMOTE_STATE_CONNECTED: remote is connected and ready
*
* The different states the remote can be
*/
typedef enum {
WP_REMOTE_STATE_ERROR = -1,
WP_REMOTE_STATE_UNCONNECTED = 0,
WP_REMOTE_STATE_CONNECTING = 1,
WP_REMOTE_STATE_CONNECTED = 2,
} WpRemoteState;
#define WP_TYPE_REMOTE (wp_remote_get_type ())
G_DECLARE_DERIVABLE_TYPE (WpRemote, wp_remote, WP, REMOTE, GObject)
struct _WpRemoteClass
{
GObjectClass parent_class;
gboolean (*connect) (WpRemote *self);
};
WpCore *wp_remote_get_core (WpRemote *self);
gboolean wp_remote_connect (WpRemote *self);
G_END_DECLS
#endif
...@@ -18,5 +18,3 @@ ...@@ -18,5 +18,3 @@
#include "proxy-link.h" #include "proxy-link.h"
#include "proxy-node.h" #include "proxy-node.h"
#include "proxy-port.h" #include "proxy-port.h"
#include "remote.h"
#include "remote-pipewire.h"
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include <pipewire/pipewire.h> #include <pipewire/pipewire.h>
static void static void
client_added (WpRemote * remote, WpProxyClient *client, gpointer data) client_added (WpCore * core, WpProxyClient *client, gpointer data)
{ {
g_autoptr (WpProperties) properties = NULL; g_autoptr (WpProperties) properties = NULL;
const char *access; const char *access;
...@@ -30,12 +30,9 @@ client_added (WpRemote * remote, WpProxyClient *client, gpointer data) ...@@ -30,12 +30,9 @@ client_added (WpRemote * remote, WpProxyClient *client, gpointer data)
void void
wireplumber__module_init (WpModule * module, WpCore * core, GVariant * args) wireplumber__module_init (WpModule * module, WpCore * core, GVariant * args)
{ {
WpRemote *remote = wp_core_get_global (core, WP_GLOBAL_REMOTE_PIPEWIRE); wp_core_set_default_proxy_features (core, WP_TYPE_PROXY_CLIENT,
g_return_if_fail (remote != NULL); WP_PROXY_FEATURE_PW_PROXY | WP_PROXY_FEATURE_INFO);
wp_remote_pipewire_set_default_features (WP_REMOTE_PIPEWIRE (remote), g_signal_connect(core, "remote-global-added::client",
WP_TYPE_PROXY_CLIENT, WP_PROXY_FEATURE_PW_PROXY | WP_PROXY_FEATURE_INFO); (GCallback) client_added, NULL);
g_signal_connect(remote, "global-added::client", (GCallback) client_added,
NULL);
} }
...@@ -298,9 +298,8 @@ mixer_endpoint_class_init (WpMixerEndpointClass * klass) ...@@ -298,9 +298,8 @@ mixer_endpoint_class_init (WpMixerEndpointClass * klass)
} }
static void static void
remote_connected (WpRemote *remote, WpRemoteState state, GVariant *streams) remote_connected (WpCore *core, WpRemoteState state, GVariant *streams)
{ {
g_autoptr (WpCore) core = wp_remote_get_core (remote);
g_autoptr (WpEndpoint) ep = g_object_new (mixer_endpoint_get_type (), g_autoptr (WpEndpoint) ep = g_object_new (mixer_endpoint_get_type (),
"core", core, "core", core,
"name", "Mixer", "name", "Mixer",
...@@ -313,15 +312,11 @@ remote_connected (WpRemote *remote, WpRemoteState state, GVariant *streams) ...@@ -313,15 +312,11 @@ remote_connected (WpRemote *remote, WpRemoteState state, GVariant *streams)
void void
wireplumber__module_init (WpModule * module, WpCore * core, GVariant * args) wireplumber__module_init (WpModule * module, WpCore * core, GVariant * args)
{ {
WpRemote *remote;
GVariant *streams; GVariant *streams;
remote = wp_core_get_global (core, WP_GLOBAL_REMOTE_PIPEWIRE);
g_return_if_fail (remote != NULL);
streams = g_variant_lookup_value (args, "streams", G_VARIANT_TYPE ("as")); streams = g_variant_lookup_value (args, "streams", G_VARIANT_TYPE ("as"));
g_signal_connect_data (remote, "state-changed::connected", g_signal_connect_data (core, "remote-state-changed::connected",
(GCallback) remote_connected, streams, (GClosureNotify) g_variant_unref, (GCallback) remote_connected, streams, (GClosureNotify) g_variant_unref,
0); 0);
} }
...@@ -23,20 +23,10 @@ void simple_endpoint_link_factory (WpFactory * factory, GType type, ...@@ -23,20 +23,10 @@ void simple_endpoint_link_factory (WpFactory * factory, GType type,
void void