mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-05 07:48:01 +02:00
modules: remove endpoint impl on si-node, si-audio-convert and si-audio-adapter
This commit is contained in:
parent
59cb837075
commit
b7e347d92c
7 changed files with 29 additions and 728 deletions
|
|
@ -25,7 +25,6 @@ struct _WpSiAudioAdapter
|
|||
|
||||
/* configuration */
|
||||
WpNode *node;
|
||||
WpSession *session;
|
||||
gchar name[96];
|
||||
gchar media_class[32];
|
||||
gchar role[32];
|
||||
|
|
@ -37,19 +36,14 @@ struct _WpSiAudioAdapter
|
|||
|
||||
/* activate */
|
||||
struct spa_audio_info_raw format;
|
||||
|
||||
/* export */
|
||||
WpImplEndpoint *impl_endpoint;
|
||||
};
|
||||
|
||||
static void si_audio_adapter_endpoint_init (WpSiEndpointInterface * iface);
|
||||
static void si_audio_adapter_port_info_init (WpSiPortInfoInterface * iface);
|
||||
|
||||
G_DECLARE_FINAL_TYPE(WpSiAudioAdapter, si_audio_adapter, WP, SI_AUDIO_ADAPTER,
|
||||
WpSessionItem)
|
||||
G_DEFINE_TYPE_WITH_CODE (WpSiAudioAdapter, si_audio_adapter,
|
||||
WP_TYPE_SESSION_ITEM,
|
||||
G_IMPLEMENT_INTERFACE (WP_TYPE_SI_ENDPOINT, si_audio_adapter_endpoint_init)
|
||||
G_IMPLEMENT_INTERFACE (WP_TYPE_SI_PORT_INFO, si_audio_adapter_port_info_init))
|
||||
|
||||
static void
|
||||
|
|
@ -63,12 +57,10 @@ si_audio_adapter_reset (WpSessionItem * item)
|
|||
WpSiAudioAdapter *self = WP_SI_AUDIO_ADAPTER (item);
|
||||
|
||||
/* deactivate first */
|
||||
wp_object_deactivate (WP_OBJECT (self),
|
||||
WP_SESSION_ITEM_FEATURE_ACTIVE | WP_SESSION_ITEM_FEATURE_EXPORTED);
|
||||
wp_object_deactivate (WP_OBJECT (self), WP_SESSION_ITEM_FEATURE_ACTIVE);
|
||||
|
||||
/* reset */
|
||||
g_clear_object (&self->node);
|
||||
g_clear_object (&self->session);
|
||||
self->name[0] = '\0';
|
||||
self->media_class[0] = '\0';
|
||||
self->role[0] = '\0';
|
||||
|
|
@ -88,7 +80,6 @@ si_audio_adapter_configure (WpSessionItem * item, WpProperties *p)
|
|||
g_autoptr (WpProperties) si_props = wp_properties_ensure_unique_owner (p);
|
||||
WpNode *node = NULL;
|
||||
WpProperties *node_props = NULL;
|
||||
WpSession *session = NULL;
|
||||
const gchar *str;
|
||||
|
||||
/* reset previous config */
|
||||
|
|
@ -167,16 +158,7 @@ si_audio_adapter_configure (WpSessionItem * item, WpProperties *p)
|
|||
if (!str)
|
||||
wp_properties_setf (si_props, "enable-monitor", "%u", self->monitor);
|
||||
|
||||
/* session is optional (only needed if we want to export) */
|
||||
str = wp_properties_get (si_props, "session");
|
||||
if (str && (sscanf(str, "%p", &session) != 1 || !WP_IS_SESSION (session)))
|
||||
return FALSE;
|
||||
if (!str)
|
||||
wp_properties_setf (si_props, "session", "%p", session);
|
||||
|
||||
self->node = g_object_ref (node);
|
||||
if (session)
|
||||
self->session = g_object_ref (session);
|
||||
|
||||
wp_properties_set (si_props, "si-factory-name", SI_FACTORY_NAME);
|
||||
wp_session_item_set_properties (WP_SESSION_ITEM (self),
|
||||
|
|
@ -191,10 +173,6 @@ si_audio_adapter_get_associated_proxy (WpSessionItem * item, GType proxy_type)
|
|||
|
||||
if (proxy_type == WP_TYPE_NODE)
|
||||
return self->node ? g_object_ref (self->node) : NULL;
|
||||
else if (proxy_type == WP_TYPE_SESSION)
|
||||
return self->session ? g_object_ref (self->session) : NULL;
|
||||
else if (proxy_type == WP_TYPE_ENDPOINT)
|
||||
return self->impl_endpoint ? g_object_ref (self->impl_endpoint) : NULL;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -209,16 +187,6 @@ si_audio_adapter_disable_active (WpSessionItem *si)
|
|||
WP_SESSION_ITEM_FEATURE_ACTIVE);
|
||||
}
|
||||
|
||||
static void
|
||||
si_audio_adapter_disable_exported (WpSessionItem *si)
|
||||
{
|
||||
WpSiAudioAdapter *self = WP_SI_AUDIO_ADAPTER (si);
|
||||
|
||||
g_clear_object (&self->impl_endpoint);
|
||||
wp_object_update_features (WP_OBJECT (self), 0,
|
||||
WP_SESSION_ITEM_FEATURE_EXPORTED);
|
||||
}
|
||||
|
||||
static void
|
||||
on_sync_done (WpCore * core, GAsyncResult * res, WpTransition * transition)
|
||||
{
|
||||
|
|
@ -367,22 +335,6 @@ on_node_enum_format_done (WpPipewireObject * proxy, GAsyncResult * res,
|
|||
si_audio_adapter_configure_ports (self, transition);
|
||||
}
|
||||
|
||||
static void
|
||||
on_impl_endpoint_activated (WpObject * object, GAsyncResult * res,
|
||||
WpTransition * transition)
|
||||
{
|
||||
WpSiAudioAdapter *self = wp_transition_get_source_object (transition);
|
||||
g_autoptr (GError) error = NULL;
|
||||
|
||||
if (!wp_object_activate_finish (object, res, &error)) {
|
||||
wp_transition_return_error (transition, g_steal_pointer (&error));
|
||||
return;
|
||||
}
|
||||
|
||||
wp_object_update_features (WP_OBJECT (self),
|
||||
WP_SESSION_ITEM_FEATURE_EXPORTED, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
si_audio_adapter_enable_active (WpSessionItem *si, WpTransition *transition)
|
||||
{
|
||||
|
|
@ -400,99 +352,26 @@ si_audio_adapter_enable_active (WpSessionItem *si, WpTransition *transition)
|
|||
(GAsyncReadyCallback) on_node_enum_format_done, transition);
|
||||
}
|
||||
|
||||
static void
|
||||
si_audio_adapter_enable_exported (WpSessionItem *si, WpTransition *transition)
|
||||
static WpObjectFeatures
|
||||
si_audio_adapter_get_supported_features (WpObject * self)
|
||||
{
|
||||
WpSiAudioAdapter *self = WP_SI_AUDIO_ADAPTER (si);
|
||||
g_autoptr (WpCore) core = wp_object_get_core (WP_OBJECT (self));
|
||||
|
||||
self->impl_endpoint = wp_impl_endpoint_new (core, WP_SI_ENDPOINT (self));
|
||||
|
||||
g_signal_connect_object (self->impl_endpoint, "pw-proxy-destroyed",
|
||||
G_CALLBACK (wp_session_item_handle_proxy_destroyed), self, 0);
|
||||
|
||||
wp_object_activate (WP_OBJECT (self->impl_endpoint),
|
||||
WP_OBJECT_FEATURES_ALL, NULL,
|
||||
(GAsyncReadyCallback) on_impl_endpoint_activated, transition);
|
||||
return WP_SESSION_ITEM_FEATURE_ACTIVE;
|
||||
}
|
||||
|
||||
static void
|
||||
si_audio_adapter_class_init (WpSiAudioAdapterClass * klass)
|
||||
{
|
||||
WpObjectClass * wpobject_class = (WpObjectClass *) klass;
|
||||
WpSessionItemClass *si_class = (WpSessionItemClass *) klass;
|
||||
|
||||
wpobject_class->get_supported_features =
|
||||
si_audio_adapter_get_supported_features;
|
||||
|
||||
si_class->reset = si_audio_adapter_reset;
|
||||
si_class->configure = si_audio_adapter_configure;
|
||||
si_class->get_associated_proxy = si_audio_adapter_get_associated_proxy;
|
||||
si_class->disable_active = si_audio_adapter_disable_active;
|
||||
si_class->disable_exported = si_audio_adapter_disable_exported;
|
||||
si_class->enable_active = si_audio_adapter_enable_active;
|
||||
si_class->enable_exported = si_audio_adapter_enable_exported;
|
||||
}
|
||||
|
||||
static GVariant *
|
||||
si_audio_adapter_get_registration_info (WpSiEndpoint * item)
|
||||
{
|
||||
WpSiAudioAdapter *self = WP_SI_AUDIO_ADAPTER (item);
|
||||
GVariantBuilder b;
|
||||
|
||||
g_variant_builder_init (&b, G_VARIANT_TYPE ("(ssya{ss})"));
|
||||
g_variant_builder_add (&b, "s", self->name);
|
||||
g_variant_builder_add (&b, "s", self->media_class);
|
||||
g_variant_builder_add (&b, "y", (guchar) self->direction);
|
||||
g_variant_builder_add (&b, "a{ss}", NULL);
|
||||
|
||||
return g_variant_builder_end (&b);
|
||||
}
|
||||
|
||||
static WpProperties *
|
||||
si_audio_adapter_get_properties (WpSiEndpoint * item)
|
||||
{
|
||||
WpSiAudioAdapter *self = WP_SI_AUDIO_ADAPTER (item);
|
||||
g_autoptr (WpProperties) node_props = NULL;
|
||||
WpProperties *result;
|
||||
|
||||
result = wp_properties_new (
|
||||
PW_KEY_MEDIA_ROLE, self->role,
|
||||
NULL);
|
||||
wp_properties_setf (result, "endpoint.priority", "%u", self->priority);
|
||||
|
||||
/* copy useful properties from the node */
|
||||
node_props =
|
||||
wp_pipewire_object_get_properties (WP_PIPEWIRE_OBJECT (self->node));
|
||||
wp_properties_update_keys (result, node_props,
|
||||
PW_KEY_DEVICE_ID,
|
||||
PW_KEY_NODE_TARGET,
|
||||
NULL);
|
||||
|
||||
/* associate with the node */
|
||||
wp_properties_setf (result, PW_KEY_NODE_ID, "%d",
|
||||
wp_proxy_get_bound_id (WP_PROXY (self->node)));
|
||||
|
||||
wp_properties_set (result, "endpoint.description",
|
||||
wp_properties_get (node_props, PW_KEY_NODE_DESCRIPTION));
|
||||
wp_properties_set (result, PW_KEY_ENDPOINT_AUTOCONNECT,
|
||||
wp_properties_get (node_props, PW_KEY_NODE_AUTOCONNECT));
|
||||
|
||||
/* propagate the device icon, if this is a device */
|
||||
const gchar *icon = wp_properties_get (node_props, PW_KEY_DEVICE_ICON_NAME);
|
||||
if (icon)
|
||||
wp_properties_set (result, PW_KEY_ENDPOINT_ICON_NAME, icon);
|
||||
|
||||
/* endpoint.client.id: the id of the client that created the node
|
||||
* Not to be confused with client.id, which will also be set on the endpoint
|
||||
* to the id of the client object that creates the endpoint (wireplumber) */
|
||||
wp_properties_set (result, PW_KEY_ENDPOINT_CLIENT_ID,
|
||||
wp_properties_get (node_props, PW_KEY_CLIENT_ID));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
si_audio_adapter_endpoint_init (WpSiEndpointInterface * iface)
|
||||
{
|
||||
iface->get_registration_info = si_audio_adapter_get_registration_info;
|
||||
iface->get_properties = si_audio_adapter_get_properties;
|
||||
}
|
||||
|
||||
static GVariant *
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ struct _WpSiAudioConvert
|
|||
|
||||
/* configuration */
|
||||
WpSessionItem *target;
|
||||
WpSession *session;
|
||||
gchar name[96];
|
||||
WpDirection direction;
|
||||
gboolean control_port;
|
||||
|
|
@ -32,19 +31,14 @@ struct _WpSiAudioConvert
|
|||
WpNode *node;
|
||||
WpObjectManager *links_watch;
|
||||
WpSessionItem *link_to_target;
|
||||
|
||||
/* export */
|
||||
WpImplEndpoint *impl_endpoint;
|
||||
};
|
||||
|
||||
static void si_audio_convert_endpoint_init (WpSiEndpointInterface * iface);
|
||||
static void si_audio_convert_port_info_init (WpSiPortInfoInterface * iface);
|
||||
|
||||
G_DECLARE_FINAL_TYPE(WpSiAudioConvert, si_audio_convert, WP, SI_AUDIO_CONVERT,
|
||||
WpSessionItem)
|
||||
G_DEFINE_TYPE_WITH_CODE (WpSiAudioConvert, si_audio_convert,
|
||||
WP_TYPE_SESSION_ITEM,
|
||||
G_IMPLEMENT_INTERFACE (WP_TYPE_SI_ENDPOINT, si_audio_convert_endpoint_init)
|
||||
G_IMPLEMENT_INTERFACE (WP_TYPE_SI_PORT_INFO, si_audio_convert_port_info_init))
|
||||
|
||||
static void
|
||||
|
|
@ -63,7 +57,6 @@ si_audio_convert_reset (WpSessionItem * item)
|
|||
|
||||
/* reset */
|
||||
g_clear_object (&self->target);
|
||||
g_clear_object (&self->session);
|
||||
self->name[0] = '\0';
|
||||
self->direction = WP_DIRECTION_INPUT;
|
||||
self->control_port = FALSE;
|
||||
|
|
@ -78,7 +71,6 @@ si_audio_convert_configure (WpSessionItem * item, WpProperties *p)
|
|||
g_autoptr (WpProperties) si_props = wp_properties_ensure_unique_owner (p);
|
||||
WpSessionItem *target;
|
||||
WpProperties *target_props = NULL;
|
||||
WpSession *session = NULL;
|
||||
const gchar *str;
|
||||
|
||||
/* reset previous config */
|
||||
|
|
@ -110,16 +102,7 @@ si_audio_convert_configure (WpSessionItem * item, WpProperties *p)
|
|||
wp_properties_setf (si_props, "enable-control-port", "%u",
|
||||
self->control_port);
|
||||
|
||||
/* session is optional (only needed if we want to export) */
|
||||
str = wp_properties_get (si_props, "session");
|
||||
if (str && (sscanf(str, "%p", &session) != 1 || !WP_IS_SESSION (session)))
|
||||
return FALSE;
|
||||
if (!str)
|
||||
wp_properties_setf (si_props, "session", "%p", session);
|
||||
|
||||
self->target = g_object_ref (target);
|
||||
if (session)
|
||||
self->session = g_object_ref (session);
|
||||
|
||||
wp_properties_set (si_props, "si-factory-name", SI_FACTORY_NAME);
|
||||
wp_session_item_set_properties (WP_SESSION_ITEM (self),
|
||||
|
|
@ -134,10 +117,6 @@ si_audio_convert_get_associated_proxy (WpSessionItem * item, GType proxy_type)
|
|||
|
||||
if (proxy_type == WP_TYPE_NODE)
|
||||
return self->node ? g_object_ref (self->node) : NULL;
|
||||
if (proxy_type == WP_TYPE_SESSION)
|
||||
return self->session ? g_object_ref (self->session) : NULL;
|
||||
else if (proxy_type == WP_TYPE_ENDPOINT)
|
||||
return self->impl_endpoint ? g_object_ref (self->impl_endpoint) : NULL;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -154,16 +133,6 @@ si_audio_convert_disable_active (WpSessionItem *si)
|
|||
WP_SESSION_ITEM_FEATURE_ACTIVE);
|
||||
}
|
||||
|
||||
static void
|
||||
si_audio_convert_disable_exported (WpSessionItem *si)
|
||||
{
|
||||
WpSiAudioConvert *self = WP_SI_AUDIO_CONVERT (si);
|
||||
|
||||
g_clear_object (&self->impl_endpoint);
|
||||
wp_object_update_features (WP_OBJECT (self), 0,
|
||||
WP_SESSION_ITEM_FEATURE_EXPORTED);
|
||||
}
|
||||
|
||||
static void
|
||||
on_link_activated (WpSessionItem * item, GAsyncResult * res,
|
||||
WpSiAudioConvert * self)
|
||||
|
|
@ -280,22 +249,6 @@ on_node_activate_done (WpObject * node, GAsyncResult * res,
|
|||
si_audio_convert_do_links_watch (self, transition);
|
||||
}
|
||||
|
||||
static void
|
||||
on_impl_endpoint_activated (WpObject * object, GAsyncResult * res,
|
||||
WpTransition * transition)
|
||||
{
|
||||
WpSiAudioConvert *self = wp_transition_get_source_object (transition);
|
||||
g_autoptr (GError) error = NULL;
|
||||
|
||||
if (!wp_object_activate_finish (object, res, &error)) {
|
||||
wp_transition_return_error (transition, g_steal_pointer (&error));
|
||||
return;
|
||||
}
|
||||
|
||||
wp_object_update_features (WP_OBJECT (self),
|
||||
WP_SESSION_ITEM_FEATURE_EXPORTED, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
si_audio_convert_enable_active (WpSessionItem *si, WpTransition *transition)
|
||||
{
|
||||
|
|
@ -392,62 +345,6 @@ si_audio_convert_enable_active (WpSessionItem *si, WpTransition *transition)
|
|||
(GAsyncReadyCallback) on_node_activate_done, transition);
|
||||
}
|
||||
|
||||
static void
|
||||
si_audio_convert_enable_exported (WpSessionItem *si, WpTransition *transition)
|
||||
{
|
||||
WpSiAudioConvert *self = WP_SI_AUDIO_CONVERT (si);
|
||||
g_autoptr (WpCore) core = wp_object_get_core (WP_OBJECT (self));
|
||||
|
||||
self->impl_endpoint = wp_impl_endpoint_new (core, WP_SI_ENDPOINT (self));
|
||||
|
||||
g_signal_connect_object (self->impl_endpoint, "pw-proxy-destroyed",
|
||||
G_CALLBACK (wp_session_item_handle_proxy_destroyed), self, 0);
|
||||
|
||||
wp_object_activate (WP_OBJECT (self->impl_endpoint),
|
||||
WP_OBJECT_FEATURES_ALL, NULL,
|
||||
(GAsyncReadyCallback) on_impl_endpoint_activated, transition);
|
||||
}
|
||||
|
||||
static GVariant *
|
||||
si_audio_convert_get_registration_info (WpSiEndpoint * item)
|
||||
{
|
||||
WpSiAudioConvert *self = WP_SI_AUDIO_CONVERT (item);
|
||||
GVariantBuilder b;
|
||||
|
||||
g_variant_builder_init (&b, G_VARIANT_TYPE ("(ssya{ss})"));
|
||||
g_variant_builder_add (&b, "s", self->name);
|
||||
g_variant_builder_add (&b, "s", "Audio/Convert");
|
||||
g_variant_builder_add (&b, "y", (guchar) self->direction);
|
||||
g_variant_builder_add (&b, "a{ss}", NULL);
|
||||
|
||||
return g_variant_builder_end (&b);
|
||||
}
|
||||
|
||||
static WpProperties *
|
||||
si_audio_convert_get_properties (WpSiEndpoint * item)
|
||||
{
|
||||
WpSiAudioConvert *self = WP_SI_AUDIO_CONVERT (item);
|
||||
WpProperties *result = wp_properties_new_empty ();
|
||||
|
||||
wp_properties_set (result, "endpoint.priority", NULL);
|
||||
wp_properties_setf (result, "endpoint.description", "%s", "Audio Converter");
|
||||
wp_properties_setf (result, PW_KEY_ENDPOINT_AUTOCONNECT, "%d", FALSE);
|
||||
wp_properties_set (result, PW_KEY_ENDPOINT_CLIENT_ID, NULL);
|
||||
|
||||
/* associate with the node */
|
||||
wp_properties_setf (result, PW_KEY_NODE_ID, "%d",
|
||||
wp_proxy_get_bound_id (WP_PROXY (self->node)));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
si_audio_convert_endpoint_init (WpSiEndpointInterface * iface)
|
||||
{
|
||||
iface->get_registration_info = si_audio_convert_get_registration_info;
|
||||
iface->get_properties = si_audio_convert_get_properties;
|
||||
}
|
||||
|
||||
static GVariant *
|
||||
si_audio_convert_get_ports (WpSiPortInfo * item, const gchar * context)
|
||||
{
|
||||
|
|
@ -508,18 +405,26 @@ si_audio_convert_port_info_init (WpSiPortInfoInterface * iface)
|
|||
iface->get_ports = si_audio_convert_get_ports;
|
||||
}
|
||||
|
||||
static WpObjectFeatures
|
||||
si_audio_convert_get_supported_features (WpObject * self)
|
||||
{
|
||||
return WP_SESSION_ITEM_FEATURE_ACTIVE;
|
||||
}
|
||||
|
||||
static void
|
||||
si_audio_convert_class_init (WpSiAudioConvertClass * klass)
|
||||
{
|
||||
WpObjectClass * wpobject_class = (WpObjectClass *) klass;
|
||||
WpSessionItemClass *si_class = (WpSessionItemClass *) klass;
|
||||
|
||||
wpobject_class->get_supported_features =
|
||||
si_audio_convert_get_supported_features;
|
||||
|
||||
si_class->reset = si_audio_convert_reset;
|
||||
si_class->configure = si_audio_convert_configure;
|
||||
si_class->get_associated_proxy = si_audio_convert_get_associated_proxy;
|
||||
si_class->disable_active = si_audio_convert_disable_active;
|
||||
si_class->disable_exported = si_audio_convert_disable_exported;
|
||||
si_class->enable_active = si_audio_convert_enable_active;
|
||||
si_class->enable_exported = si_audio_convert_enable_exported;
|
||||
}
|
||||
|
||||
WP_PLUGIN_EXPORT gboolean
|
||||
|
|
|
|||
|
|
@ -19,23 +19,17 @@ struct _WpSiNode
|
|||
|
||||
/* configuration */
|
||||
WpNode *node;
|
||||
WpSession *session;
|
||||
gchar name[96];
|
||||
gchar media_class[32];
|
||||
gchar role[32];
|
||||
guint priority;
|
||||
WpDirection direction;
|
||||
|
||||
/* export */
|
||||
WpImplEndpoint *impl_endpoint;
|
||||
};
|
||||
|
||||
static void si_node_endpoint_init (WpSiEndpointInterface * iface);
|
||||
static void si_node_port_info_init (WpSiPortInfoInterface * iface);
|
||||
|
||||
G_DECLARE_FINAL_TYPE(WpSiNode, si_node, WP, SI_NODE, WpSessionItem)
|
||||
G_DEFINE_TYPE_WITH_CODE (WpSiNode, si_node, WP_TYPE_SESSION_ITEM,
|
||||
G_IMPLEMENT_INTERFACE (WP_TYPE_SI_ENDPOINT, si_node_endpoint_init)
|
||||
G_IMPLEMENT_INTERFACE (WP_TYPE_SI_PORT_INFO, si_node_port_info_init))
|
||||
|
||||
static void
|
||||
|
|
@ -49,12 +43,10 @@ si_node_reset (WpSessionItem * item)
|
|||
WpSiNode *self = WP_SI_NODE (item);
|
||||
|
||||
/* deactivate first */
|
||||
wp_object_deactivate (WP_OBJECT (self),
|
||||
WP_SESSION_ITEM_FEATURE_ACTIVE | WP_SESSION_ITEM_FEATURE_EXPORTED);
|
||||
wp_object_deactivate (WP_OBJECT (self), WP_SESSION_ITEM_FEATURE_ACTIVE);
|
||||
|
||||
/* reset */
|
||||
g_clear_object (&self->node);
|
||||
g_clear_object (&self->session);
|
||||
self->name[0] = '\0';
|
||||
self->media_class[0] = '\0';
|
||||
self->role[0] = '\0';
|
||||
|
|
@ -71,7 +63,6 @@ si_node_configure (WpSessionItem * item, WpProperties *p)
|
|||
g_autoptr (WpProperties) si_props = wp_properties_ensure_unique_owner (p);
|
||||
WpNode *node = NULL;
|
||||
WpProperties *node_props = NULL;
|
||||
WpSession *session = NULL;
|
||||
const gchar *str;
|
||||
|
||||
/* reset previous config */
|
||||
|
|
@ -130,16 +121,7 @@ si_node_configure (WpSessionItem * item, WpProperties *p)
|
|||
if (!str)
|
||||
wp_properties_setf (si_props, "priority", "%u", self->priority);
|
||||
|
||||
/* session is optional (only needed if we want to export) */
|
||||
str = wp_properties_get (si_props, "session");
|
||||
if (str && (sscanf(str, "%p", &session) != 1 || !WP_IS_SESSION (session)))
|
||||
return FALSE;
|
||||
if (!str)
|
||||
wp_properties_setf (si_props, "session", "%p", session);
|
||||
|
||||
self->node = g_object_ref (node);
|
||||
if (session)
|
||||
self->session = g_object_ref (session);
|
||||
|
||||
wp_properties_set (si_props, "si-factory-name", SI_FACTORY_NAME);
|
||||
wp_session_item_set_properties (WP_SESSION_ITEM (self),
|
||||
|
|
@ -154,10 +136,6 @@ si_node_get_associated_proxy (WpSessionItem * item, GType proxy_type)
|
|||
|
||||
if (proxy_type == WP_TYPE_NODE)
|
||||
return self->node ? g_object_ref (self->node) : NULL;
|
||||
if (proxy_type == WP_TYPE_SESSION)
|
||||
return self->session ? g_object_ref (self->session) : NULL;
|
||||
else if (proxy_type == WP_TYPE_ENDPOINT)
|
||||
return self->impl_endpoint ? g_object_ref (self->impl_endpoint) : NULL;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -171,16 +149,6 @@ si_node_disable_active (WpSessionItem *si)
|
|||
WP_SESSION_ITEM_FEATURE_ACTIVE);
|
||||
}
|
||||
|
||||
static void
|
||||
si_node_disable_exported (WpSessionItem *si)
|
||||
{
|
||||
WpSiNode *self = WP_SI_NODE (si);
|
||||
|
||||
g_clear_object (&self->impl_endpoint);
|
||||
wp_object_update_features (WP_OBJECT (self), 0,
|
||||
WP_SESSION_ITEM_FEATURE_EXPORTED);
|
||||
}
|
||||
|
||||
static void
|
||||
on_node_activated (WpObject * node, GAsyncResult * res,
|
||||
WpTransition * transition)
|
||||
|
|
@ -214,116 +182,25 @@ si_node_enable_active (WpSessionItem *si, WpTransition *transition)
|
|||
NULL, (GAsyncReadyCallback) on_node_activated, transition);
|
||||
}
|
||||
|
||||
static void
|
||||
on_impl_endpoint_activated (WpObject * object, GAsyncResult * res,
|
||||
WpTransition * transition)
|
||||
static WpObjectFeatures
|
||||
si_node_get_supported_features (WpObject * self)
|
||||
{
|
||||
WpSiNode *self = wp_transition_get_source_object (transition);
|
||||
g_autoptr (GError) error = NULL;
|
||||
|
||||
if (!wp_object_activate_finish (object, res, &error)) {
|
||||
wp_transition_return_error (transition, g_steal_pointer (&error));
|
||||
return;
|
||||
}
|
||||
|
||||
wp_object_update_features (WP_OBJECT (self),
|
||||
WP_SESSION_ITEM_FEATURE_EXPORTED, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
si_node_enable_exported (WpSessionItem *si, WpTransition *transition)
|
||||
{
|
||||
WpSiNode *self = WP_SI_NODE (si);
|
||||
|
||||
g_autoptr (WpCore) core = wp_object_get_core (WP_OBJECT (self));
|
||||
|
||||
self->impl_endpoint = wp_impl_endpoint_new (core, WP_SI_ENDPOINT (self));
|
||||
|
||||
g_signal_connect_object (self->impl_endpoint, "pw-proxy-destroyed",
|
||||
G_CALLBACK (wp_session_item_handle_proxy_destroyed), self, 0);
|
||||
|
||||
wp_object_activate (WP_OBJECT (self->impl_endpoint),
|
||||
WP_OBJECT_FEATURES_ALL, NULL,
|
||||
(GAsyncReadyCallback) on_impl_endpoint_activated, transition);
|
||||
return WP_SESSION_ITEM_FEATURE_ACTIVE;
|
||||
}
|
||||
|
||||
static void
|
||||
si_node_class_init (WpSiNodeClass * klass)
|
||||
{
|
||||
WpObjectClass * wpobject_class = (WpObjectClass *) klass;
|
||||
WpSessionItemClass *si_class = (WpSessionItemClass *) klass;
|
||||
|
||||
wpobject_class->get_supported_features = si_node_get_supported_features;
|
||||
|
||||
si_class->reset = si_node_reset;
|
||||
si_class->configure = si_node_configure;
|
||||
si_class->get_associated_proxy = si_node_get_associated_proxy;
|
||||
si_class->disable_active = si_node_disable_active;
|
||||
si_class->disable_exported = si_node_disable_exported;
|
||||
si_class->enable_active = si_node_enable_active;
|
||||
si_class->enable_exported = si_node_enable_exported;
|
||||
}
|
||||
|
||||
static GVariant *
|
||||
si_node_get_registration_info (WpSiEndpoint * item)
|
||||
{
|
||||
WpSiNode *self = WP_SI_NODE (item);
|
||||
GVariantBuilder b;
|
||||
|
||||
g_variant_builder_init (&b, G_VARIANT_TYPE ("(ssya{ss})"));
|
||||
g_variant_builder_add (&b, "s", self->name);
|
||||
g_variant_builder_add (&b, "s", self->media_class);
|
||||
g_variant_builder_add (&b, "y", (guchar) self->direction);
|
||||
g_variant_builder_add (&b, "a{ss}", NULL);
|
||||
|
||||
return g_variant_builder_end (&b);
|
||||
}
|
||||
|
||||
static WpProperties *
|
||||
si_node_get_properties (WpSiEndpoint * item)
|
||||
{
|
||||
WpSiNode *self = WP_SI_NODE (item);
|
||||
g_autoptr (WpProperties) node_props = NULL;
|
||||
WpProperties *result;
|
||||
|
||||
result = wp_properties_new (
|
||||
PW_KEY_MEDIA_ROLE, self->role,
|
||||
NULL);
|
||||
wp_properties_setf (result, "endpoint.priority", "%u", self->priority);
|
||||
|
||||
/* copy useful properties from the node */
|
||||
node_props = wp_pipewire_object_get_properties (WP_PIPEWIRE_OBJECT (self->node));
|
||||
wp_properties_update_keys (result, node_props,
|
||||
PW_KEY_DEVICE_ID,
|
||||
PW_KEY_NODE_TARGET,
|
||||
NULL);
|
||||
|
||||
/* associate with the node */
|
||||
wp_properties_setf (result, PW_KEY_NODE_ID, "%d",
|
||||
wp_proxy_get_bound_id (WP_PROXY (self->node)));
|
||||
|
||||
wp_properties_set (result, "endpoint.description",
|
||||
wp_properties_get (node_props, PW_KEY_NODE_DESCRIPTION));
|
||||
wp_properties_set (result, PW_KEY_ENDPOINT_AUTOCONNECT,
|
||||
wp_properties_get (node_props, PW_KEY_NODE_AUTOCONNECT));
|
||||
|
||||
/* propagate the device icon, if this is a device */
|
||||
const gchar *icon = wp_properties_get (node_props, PW_KEY_DEVICE_ICON_NAME);
|
||||
if (icon)
|
||||
wp_properties_set (result, PW_KEY_ENDPOINT_ICON_NAME, icon);
|
||||
|
||||
/* endpoint.client.id: the id of the client that created the node
|
||||
* Not to be confused with client.id, which will also be set on the endpoint
|
||||
* to the id of the client object that creates the endpoint (wireplumber) */
|
||||
const gchar *client_id = wp_properties_get (node_props, PW_KEY_CLIENT_ID);
|
||||
if (client_id)
|
||||
wp_properties_set (result, PW_KEY_ENDPOINT_CLIENT_ID, client_id);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
si_node_endpoint_init (WpSiEndpointInterface * iface)
|
||||
{
|
||||
iface->get_registration_info = si_node_get_registration_info;
|
||||
iface->get_properties = si_node_get_properties;
|
||||
}
|
||||
|
||||
static GVariant *
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ function addItem (node, item_type)
|
|||
end
|
||||
|
||||
-- activate item
|
||||
items[id]:activate (Feature.SessionItem.ACTIVE, function (item)
|
||||
items[id]:activate (Feature.Object.ALL, function (item)
|
||||
Log.info(item, "activated item for node " .. tostring(id))
|
||||
item:register ()
|
||||
end)
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ test_si_audio_adapter_configure_activate (TestFixture * f,
|
|||
/* create adapter */
|
||||
adapter = wp_session_item_make (f->base.core, "si-audio-adapter");
|
||||
g_assert_nonnull (adapter);
|
||||
g_assert_true (WP_IS_SI_ENDPOINT (adapter));
|
||||
g_assert_true (WP_IS_SI_PORT_INFO (adapter));
|
||||
|
||||
/* configure */
|
||||
{
|
||||
|
|
@ -131,104 +131,6 @@ test_si_audio_adapter_configure_activate (TestFixture * f,
|
|||
g_assert_false (wp_session_item_is_configured (adapter));
|
||||
}
|
||||
|
||||
static void
|
||||
test_si_audio_adapter_export (TestFixture * f, gconstpointer user_data)
|
||||
{
|
||||
g_autoptr (WpNode) node = NULL;
|
||||
g_autoptr (WpSession) session = NULL;
|
||||
g_autoptr (WpSessionItem) adapter = NULL;
|
||||
g_autoptr (WpObjectManager) clients_om = NULL;
|
||||
g_autoptr (WpClient) self_client = NULL;
|
||||
|
||||
/* find self_client, to be used for verifying endpoint.client.id */
|
||||
clients_om = wp_object_manager_new ();
|
||||
wp_object_manager_add_interest (clients_om, WP_TYPE_CLIENT, NULL);
|
||||
wp_object_manager_request_object_features (clients_om,
|
||||
WP_TYPE_CLIENT, WP_PROXY_FEATURE_BOUND);
|
||||
g_signal_connect_swapped (clients_om, "objects-changed",
|
||||
G_CALLBACK (g_main_loop_quit), f->base.loop);
|
||||
wp_core_install_object_manager (f->base.core, clients_om);
|
||||
g_main_loop_run (f->base.loop);
|
||||
g_assert_nonnull (self_client =
|
||||
wp_object_manager_lookup (clients_om, WP_TYPE_CLIENT, NULL));
|
||||
|
||||
/* create session */
|
||||
session = WP_SESSION (wp_impl_session_new (f->base.core));
|
||||
g_assert_nonnull (session);
|
||||
wp_object_activate (WP_OBJECT (session), WP_OBJECT_FEATURES_ALL, NULL,
|
||||
(GAsyncReadyCallback) test_object_activate_finish_cb, f);
|
||||
g_main_loop_run (f->base.loop);
|
||||
|
||||
/* create adapter */
|
||||
node = wp_node_new_from_factory (f->base.core,
|
||||
"adapter",
|
||||
wp_properties_new (
|
||||
"factory.name", "audiotestsrc",
|
||||
"node.name", "audiotestsrc.adapter",
|
||||
NULL));
|
||||
g_assert_nonnull (node);
|
||||
wp_object_activate (WP_OBJECT (node), WP_PIPEWIRE_OBJECT_FEATURES_MINIMAL,
|
||||
NULL, (GAsyncReadyCallback) test_object_activate_finish_cb, f);
|
||||
g_main_loop_run (f->base.loop);
|
||||
adapter = wp_session_item_make (f->base.core, "si-audio-adapter");
|
||||
g_assert_nonnull (adapter);
|
||||
g_assert_true (WP_IS_SI_ENDPOINT (adapter));
|
||||
|
||||
/* configure */
|
||||
{
|
||||
WpProperties *props = wp_properties_new_empty ();
|
||||
wp_properties_setf (props, "node", "%p", node);
|
||||
wp_properties_setf (props, "session", "%p", session);
|
||||
g_assert_true (wp_session_item_configure (adapter, props));
|
||||
g_assert_true (wp_session_item_is_configured (adapter));
|
||||
}
|
||||
|
||||
/* activate and export */
|
||||
wp_object_activate (WP_OBJECT (adapter),
|
||||
WP_SESSION_ITEM_FEATURE_ACTIVE | WP_SESSION_ITEM_FEATURE_EXPORTED,
|
||||
NULL, (GAsyncReadyCallback) test_object_activate_finish_cb, f);
|
||||
g_main_loop_run (f->base.loop);
|
||||
g_assert_cmphex (wp_object_get_active_features (WP_OBJECT (adapter)), ==,
|
||||
WP_SESSION_ITEM_FEATURE_ACTIVE | WP_SESSION_ITEM_FEATURE_EXPORTED);
|
||||
|
||||
/* validate */
|
||||
{
|
||||
g_autoptr (WpEndpoint) ep = NULL;
|
||||
g_autoptr (WpProperties) props = NULL;
|
||||
gchar *tmp;
|
||||
|
||||
g_assert_nonnull (
|
||||
ep = wp_session_item_get_associated_proxy (adapter, WP_TYPE_ENDPOINT));
|
||||
g_assert_nonnull (
|
||||
props = wp_pipewire_object_get_properties (WP_PIPEWIRE_OBJECT (ep)));
|
||||
|
||||
g_assert_cmpstr (wp_endpoint_get_name (ep), ==, "audiotestsrc.adapter");
|
||||
g_assert_cmpstr (wp_endpoint_get_media_class (ep), ==,
|
||||
"Audio/Source");
|
||||
g_assert_cmpint (wp_endpoint_get_direction (ep), ==, WP_DIRECTION_OUTPUT);
|
||||
g_assert_cmpstr (wp_properties_get (props, "endpoint.name"), ==,
|
||||
"audiotestsrc.adapter");
|
||||
g_assert_cmpstr (wp_properties_get (props, "media.class"), ==,
|
||||
"Audio/Source");
|
||||
|
||||
tmp = g_strdup_printf ("%d", wp_proxy_get_bound_id (WP_PROXY (session)));
|
||||
g_assert_cmpstr (wp_properties_get (props, "session.id"), ==, tmp);
|
||||
g_free (tmp);
|
||||
|
||||
tmp = g_strdup_printf ("%d", wp_proxy_get_bound_id (WP_PROXY (node)));
|
||||
g_assert_cmpstr (wp_properties_get (props, "node.id"), ==, tmp);
|
||||
g_free (tmp);
|
||||
|
||||
tmp = g_strdup_printf ("%d", wp_proxy_get_bound_id (WP_PROXY (self_client)));
|
||||
g_assert_cmpstr (wp_properties_get (props, "endpoint.client.id"), ==, tmp);
|
||||
g_free (tmp);
|
||||
}
|
||||
|
||||
/* reset */
|
||||
wp_session_item_reset (adapter);
|
||||
g_assert_false (wp_session_item_is_configured (adapter));
|
||||
}
|
||||
|
||||
gint
|
||||
main (gint argc, gchar *argv[])
|
||||
{
|
||||
|
|
@ -243,13 +145,5 @@ main (gint argc, gchar *argv[])
|
|||
test_si_audio_adapter_configure_activate,
|
||||
test_si_audio_adapter_teardown);
|
||||
|
||||
/* export */
|
||||
|
||||
g_test_add ("/modules/si-audio-adapter/export",
|
||||
TestFixture, NULL,
|
||||
test_si_audio_adapter_setup,
|
||||
test_si_audio_adapter_export,
|
||||
test_si_audio_adapter_teardown);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ test_si_audio_convert_configure_activate (TestFixture * f,
|
|||
|
||||
target = wp_session_item_make (f->base.core, "si-audio-adapter");
|
||||
g_assert_nonnull (target);
|
||||
g_assert_true (WP_IS_SI_ENDPOINT (target));
|
||||
g_assert_true (WP_IS_SI_PORT_INFO (target));
|
||||
|
||||
/* configure target */
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ test_si_audio_convert_configure_activate (TestFixture * f,
|
|||
|
||||
convert = wp_session_item_make (f->base.core, "si-audio-convert");
|
||||
g_assert_nonnull (convert);
|
||||
g_assert_true (WP_IS_SI_ENDPOINT (convert));
|
||||
g_assert_true (WP_IS_SI_PORT_INFO (convert));
|
||||
|
||||
/* configure convert */
|
||||
|
||||
|
|
@ -137,122 +137,6 @@ test_si_audio_convert_configure_activate (TestFixture * f,
|
|||
g_assert_false (wp_session_item_is_configured (convert));
|
||||
}
|
||||
|
||||
static void
|
||||
test_si_audio_convert_export (TestFixture * f, gconstpointer user_data)
|
||||
{
|
||||
g_autoptr (WpNode) target_node = NULL;
|
||||
g_autoptr (WpSessionItem) target = NULL;
|
||||
g_autoptr (WpSessionItem) convert = NULL;
|
||||
g_autoptr (WpSession) session = NULL;
|
||||
g_autoptr (WpObjectManager) clients_om = NULL;
|
||||
g_autoptr (WpClient) self_client = NULL;
|
||||
|
||||
/* find self_client, to be used for verifying endpoint.client.id */
|
||||
|
||||
clients_om = wp_object_manager_new ();
|
||||
wp_object_manager_add_interest (clients_om, WP_TYPE_CLIENT, NULL);
|
||||
wp_object_manager_request_object_features (clients_om,
|
||||
WP_TYPE_CLIENT, WP_PROXY_FEATURE_BOUND);
|
||||
g_signal_connect_swapped (clients_om, "objects-changed",
|
||||
G_CALLBACK (g_main_loop_quit), f->base.loop);
|
||||
wp_core_install_object_manager (f->base.core, clients_om);
|
||||
g_main_loop_run (f->base.loop);
|
||||
g_assert_nonnull (self_client =
|
||||
wp_object_manager_lookup (clients_om, WP_TYPE_CLIENT, NULL));
|
||||
|
||||
/* create session */
|
||||
|
||||
session = WP_SESSION (wp_impl_session_new (f->base.core));
|
||||
g_assert_nonnull (session);
|
||||
|
||||
wp_object_activate (WP_OBJECT (session), WP_OBJECT_FEATURES_ALL, NULL,
|
||||
(GAsyncReadyCallback) test_object_activate_finish_cb, f);
|
||||
g_main_loop_run (f->base.loop);
|
||||
|
||||
/* create target node */
|
||||
|
||||
target_node = wp_node_new_from_factory (f->base.core,
|
||||
"adapter",
|
||||
wp_properties_new (
|
||||
"factory.name", "audiotestsrc",
|
||||
"node.name", "audiotestsrc.adapter",
|
||||
NULL));
|
||||
g_assert_nonnull (target_node);
|
||||
wp_object_activate (WP_OBJECT (target_node),
|
||||
WP_PIPEWIRE_OBJECT_FEATURES_MINIMAL, NULL,
|
||||
(GAsyncReadyCallback) test_object_activate_finish_cb, f);
|
||||
g_main_loop_run (f->base.loop);
|
||||
|
||||
/* create target */
|
||||
|
||||
target = wp_session_item_make (f->base.core, "si-audio-adapter");
|
||||
g_assert_nonnull (target);
|
||||
g_assert_true (WP_IS_SI_ENDPOINT (target));
|
||||
|
||||
/* configure target */
|
||||
|
||||
{
|
||||
WpProperties *props = wp_properties_new_empty ();
|
||||
wp_properties_setf (props, "node", "%p", target_node);
|
||||
g_assert_true (wp_session_item_configure (target, props));
|
||||
g_assert_true (wp_session_item_is_configured (target));
|
||||
}
|
||||
|
||||
/* create convert */
|
||||
|
||||
convert = wp_session_item_make (f->base.core, "si-audio-convert");
|
||||
g_assert_nonnull (convert);
|
||||
|
||||
/* configure convert */
|
||||
{
|
||||
WpProperties *props = wp_properties_new_empty ();
|
||||
wp_properties_setf (props, "target", "%p", target);
|
||||
wp_properties_set (props, "name", "convert");
|
||||
wp_properties_setf (props, "session", "%p", session);
|
||||
g_assert_true (wp_session_item_configure (convert, props));
|
||||
g_assert_true (wp_session_item_is_configured (convert));
|
||||
}
|
||||
|
||||
/* activate convert */
|
||||
|
||||
{
|
||||
wp_object_activate (WP_OBJECT (convert),
|
||||
WP_SESSION_ITEM_FEATURE_ACTIVE | WP_SESSION_ITEM_FEATURE_EXPORTED,
|
||||
NULL, (GAsyncReadyCallback) test_object_activate_finish_cb, f);
|
||||
g_main_loop_run (f->base.loop);
|
||||
g_assert_cmphex (wp_object_get_active_features (WP_OBJECT (convert)), ==,
|
||||
WP_SESSION_ITEM_FEATURE_ACTIVE | WP_SESSION_ITEM_FEATURE_EXPORTED);
|
||||
}
|
||||
|
||||
{
|
||||
g_autoptr (WpEndpoint) ep = NULL;
|
||||
g_autoptr (WpProperties) props = NULL;
|
||||
gchar *tmp;
|
||||
|
||||
g_assert_nonnull (
|
||||
ep = wp_session_item_get_associated_proxy (convert, WP_TYPE_ENDPOINT));
|
||||
g_assert_nonnull (
|
||||
props = wp_pipewire_object_get_properties (WP_PIPEWIRE_OBJECT (ep)));
|
||||
|
||||
g_assert_cmpstr (wp_endpoint_get_name (ep), ==, "convert");
|
||||
g_assert_cmpstr (wp_endpoint_get_media_class (ep), ==,
|
||||
"Audio/Convert");
|
||||
g_assert_cmpint (wp_endpoint_get_direction (ep), ==, WP_DIRECTION_OUTPUT);
|
||||
g_assert_cmpstr (wp_properties_get (props, "endpoint.name"), ==,
|
||||
"convert");
|
||||
g_assert_cmpstr (wp_properties_get (props, "media.class"), ==,
|
||||
"Audio/Convert");
|
||||
|
||||
tmp = g_strdup_printf ("%d", wp_proxy_get_bound_id (WP_PROXY (session)));
|
||||
g_assert_cmpstr (wp_properties_get (props, "session.id"), ==, tmp);
|
||||
g_free (tmp);
|
||||
}
|
||||
|
||||
/* reset */
|
||||
wp_session_item_reset (convert);
|
||||
g_assert_false (wp_session_item_is_configured (convert));
|
||||
}
|
||||
|
||||
gint
|
||||
main (gint argc, gchar *argv[])
|
||||
{
|
||||
|
|
@ -265,13 +149,6 @@ main (gint argc, gchar *argv[])
|
|||
test_si_audio_convert_setup,
|
||||
test_si_audio_convert_configure_activate,
|
||||
test_si_audio_convert_teardown);
|
||||
/* export */
|
||||
|
||||
g_test_add ("/modules/si-audio-convert/export",
|
||||
TestFixture, NULL,
|
||||
test_si_audio_convert_setup,
|
||||
test_si_audio_convert_export,
|
||||
test_si_audio_convert_teardown);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ test_si_node_configure_activate (TestFixture * f, gconstpointer user_data)
|
|||
|
||||
item = wp_session_item_make (f->base.core, "si-node");
|
||||
g_assert_nonnull (item);
|
||||
g_assert_true (WP_IS_SI_ENDPOINT (item));
|
||||
g_assert_true (WP_IS_SI_PORT_INFO (item));
|
||||
|
||||
node = wp_node_new_from_factory (f->base.core,
|
||||
|
|
@ -182,116 +181,6 @@ test_si_node_configure_activate (TestFixture * f, gconstpointer user_data)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_si_node_export (TestFixture * f, gconstpointer user_data)
|
||||
{
|
||||
const TestData *data = user_data;
|
||||
g_autoptr (WpNode) node = NULL;
|
||||
g_autoptr (WpSession) session = NULL;
|
||||
g_autoptr (WpSessionItem) item = NULL;
|
||||
g_autoptr (WpObjectManager) clients_om = NULL;
|
||||
g_autoptr (WpClient) self_client = NULL;
|
||||
|
||||
/* find self_client, to be used for verifying endpoint.client.id */
|
||||
|
||||
clients_om = wp_object_manager_new ();
|
||||
wp_object_manager_add_interest (clients_om, WP_TYPE_CLIENT, NULL);
|
||||
wp_object_manager_request_object_features (clients_om,
|
||||
WP_TYPE_CLIENT, WP_PROXY_FEATURE_BOUND);
|
||||
g_signal_connect_swapped (clients_om, "objects-changed",
|
||||
G_CALLBACK (g_main_loop_quit), f->base.loop);
|
||||
wp_core_install_object_manager (f->base.core, clients_om);
|
||||
g_main_loop_run (f->base.loop);
|
||||
g_assert_nonnull (self_client = wp_object_manager_lookup (clients_om,
|
||||
WP_TYPE_CLIENT, NULL));
|
||||
|
||||
/* create session */
|
||||
|
||||
session = WP_SESSION (wp_impl_session_new (f->base.core));
|
||||
g_assert_nonnull (session);
|
||||
|
||||
wp_object_activate (WP_OBJECT (session), WP_OBJECT_FEATURES_ALL,
|
||||
NULL, (GAsyncReadyCallback) test_object_activate_finish_cb, f);
|
||||
g_main_loop_run (f->base.loop);
|
||||
|
||||
/* create item */
|
||||
|
||||
item = wp_session_item_make (f->base.core, "si-node");
|
||||
g_assert_nonnull (item);
|
||||
|
||||
node = wp_node_new_from_factory (f->base.core,
|
||||
"spa-node-factory",
|
||||
wp_properties_new (
|
||||
"factory.name", data->factory,
|
||||
"node.name", data->name,
|
||||
NULL));
|
||||
g_assert_nonnull (node);
|
||||
|
||||
wp_object_activate (WP_OBJECT (node), WP_PIPEWIRE_OBJECT_FEATURES_MINIMAL,
|
||||
NULL, (GAsyncReadyCallback) test_object_activate_finish_cb, f);
|
||||
g_main_loop_run (f->base.loop);
|
||||
|
||||
/* configure */
|
||||
|
||||
{
|
||||
WpProperties *props = wp_properties_new_empty ();
|
||||
wp_properties_setf (props, "node", "%p", node);
|
||||
wp_properties_set (props, "media-class", data->media_class);
|
||||
wp_properties_set (props, "role", "test");
|
||||
wp_properties_setf (props, "priority", "%u", 10);
|
||||
wp_properties_setf (props, "session", "%p", session);
|
||||
g_assert_true (wp_session_item_configure (item, props));
|
||||
g_assert_true (wp_session_item_is_configured (item));
|
||||
}
|
||||
|
||||
/* export */
|
||||
|
||||
wp_object_activate (WP_OBJECT (item),
|
||||
WP_SESSION_ITEM_FEATURE_ACTIVE | WP_SESSION_ITEM_FEATURE_EXPORTED,
|
||||
NULL, (GAsyncReadyCallback) test_object_activate_finish_cb, f);
|
||||
g_main_loop_run (f->base.loop);
|
||||
g_assert_cmphex (wp_object_get_active_features (WP_OBJECT (item)), ==,
|
||||
WP_SESSION_ITEM_FEATURE_ACTIVE | WP_SESSION_ITEM_FEATURE_EXPORTED);
|
||||
|
||||
{
|
||||
g_autoptr (WpEndpoint) ep = NULL;
|
||||
g_autoptr (WpProperties) props = NULL;
|
||||
gchar *tmp;
|
||||
|
||||
g_assert_nonnull (
|
||||
ep = wp_session_item_get_associated_proxy (item, WP_TYPE_ENDPOINT));
|
||||
g_assert_nonnull (
|
||||
props = wp_pipewire_object_get_properties (WP_PIPEWIRE_OBJECT (ep)));
|
||||
|
||||
g_assert_cmpstr (wp_endpoint_get_name (ep), ==, data->name);
|
||||
g_assert_cmpstr (wp_endpoint_get_media_class (ep), ==,
|
||||
data->expected_media_class);
|
||||
g_assert_cmpint (wp_endpoint_get_direction (ep), ==,
|
||||
data->expected_direction);
|
||||
g_assert_cmpstr (wp_properties_get (props, "endpoint.name"), ==,
|
||||
data->name);
|
||||
g_assert_cmpstr (wp_properties_get (props, "media.class"), ==,
|
||||
data->expected_media_class);
|
||||
g_assert_cmpstr (wp_properties_get (props, "media.role"), ==, "test");
|
||||
g_assert_cmpstr (wp_properties_get (props, "endpoint.priority"), ==, "10");
|
||||
|
||||
tmp = g_strdup_printf ("%d", wp_proxy_get_bound_id (WP_PROXY (session)));
|
||||
g_assert_cmpstr (wp_properties_get (props, "session.id"), ==, tmp);
|
||||
g_free (tmp);
|
||||
|
||||
tmp = g_strdup_printf ("%d", wp_proxy_get_bound_id (WP_PROXY (node)));
|
||||
g_assert_cmpstr (wp_properties_get (props, "node.id"), ==, tmp);
|
||||
g_free (tmp);
|
||||
|
||||
tmp = g_strdup_printf ("%d", wp_proxy_get_bound_id (WP_PROXY (self_client)));
|
||||
g_assert_cmpstr (wp_properties_get (props, "endpoint.client.id"), ==, tmp);
|
||||
g_free (tmp);
|
||||
}
|
||||
|
||||
wp_session_item_reset (item);
|
||||
g_assert_cmphex (wp_object_get_active_features (WP_OBJECT (item)), ==, 0);
|
||||
}
|
||||
|
||||
gint
|
||||
main (gint argc, gchar *argv[])
|
||||
{
|
||||
|
|
@ -330,25 +219,5 @@ main (gint argc, gchar *argv[])
|
|||
test_si_node_configure_activate,
|
||||
test_si_node_teardown);
|
||||
|
||||
/* export */
|
||||
|
||||
g_test_add ("/modules/si-node/export/fakesink",
|
||||
TestFixture, &fakesink_data,
|
||||
test_si_node_setup,
|
||||
test_si_node_export,
|
||||
test_si_node_teardown);
|
||||
|
||||
g_test_add ("/modules/si-node/export/fakesrc",
|
||||
TestFixture, &fakesrc_data,
|
||||
test_si_node_setup,
|
||||
test_si_node_export,
|
||||
test_si_node_teardown);
|
||||
|
||||
g_test_add ("/modules/si-node/export/audiotestsrc",
|
||||
TestFixture, &audiotestsrc_data,
|
||||
test_si_node_setup,
|
||||
test_si_node_export,
|
||||
test_si_node_teardown);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue