mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-05 14:48:02 +02:00
policy: take into account the role of the client when linking it
This allows linking the client to the stream that has the same name as the role that it requests.
This commit is contained in:
parent
10f8eff99c
commit
a2bf7e3999
2 changed files with 25 additions and 0 deletions
|
|
@ -27,6 +27,8 @@ struct _WpPipewireSimpleEndpoint
|
|||
/* The global-id this endpoint refers to */
|
||||
guint global_id;
|
||||
|
||||
gchar *role;
|
||||
|
||||
/* The task to signal the endpoint is initialized */
|
||||
GTask *init_task;
|
||||
|
||||
|
|
@ -52,6 +54,7 @@ struct _WpPipewireSimpleEndpoint
|
|||
enum {
|
||||
PROP_0,
|
||||
PROP_GLOBAL_ID,
|
||||
PROP_ROLE,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
|
@ -222,6 +225,9 @@ on_proxy_node_created(GObject *initable, GAsyncResult *res, gpointer data)
|
|||
self->proxy_node = wp_proxy_node_new_finish(initable, res, NULL);
|
||||
g_return_if_fail (self->proxy_node);
|
||||
|
||||
self->role = g_strdup (spa_dict_lookup (
|
||||
wp_proxy_node_get_info (self->proxy_node)->props, "media.role"));
|
||||
|
||||
/* Emit the ports */
|
||||
emit_endpoint_ports(self);
|
||||
|
||||
|
|
@ -332,6 +338,8 @@ simple_endpoint_finalize (GObject * object)
|
|||
/* Destroy the done task */
|
||||
g_clear_object(&self->init_task);
|
||||
|
||||
g_free (self->role);
|
||||
|
||||
G_OBJECT_CLASS (simple_endpoint_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
|
@ -345,6 +353,10 @@ simple_endpoint_set_property (GObject * object, guint property_id,
|
|||
case PROP_GLOBAL_ID:
|
||||
self->global_id = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_ROLE:
|
||||
g_free (self->role);
|
||||
self->role = g_value_dup_string (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
|
|
@ -361,6 +373,9 @@ simple_endpoint_get_property (GObject * object, guint property_id,
|
|||
case PROP_GLOBAL_ID:
|
||||
g_value_set_uint (value, self->global_id);
|
||||
break;
|
||||
case PROP_ROLE:
|
||||
g_value_set_string (value, self->role);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
|
|
@ -482,6 +497,10 @@ simple_endpoint_class_init (WpPipewireSimpleEndpointClass * klass)
|
|||
g_param_spec_uint ("global-id", "global-id",
|
||||
"The global Id this endpoint refers to", 0, G_MAXUINT, 0,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_ROLE,
|
||||
g_param_spec_string ("role", "role", "The role of the wrapped node", NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -257,6 +257,7 @@ simple_policy_handle_endpoint (WpPolicy *policy, WpEndpoint *ep)
|
|||
g_autoptr (WpEndpoint) target = NULL;
|
||||
guint32 stream_id;
|
||||
gboolean is_sink = FALSE;
|
||||
g_autofree gchar *role = NULL;
|
||||
|
||||
/* TODO: For now we only accept audio stream clients */
|
||||
media_class = wp_endpoint_get_media_class(ep);
|
||||
|
|
@ -272,6 +273,11 @@ simple_policy_handle_endpoint (WpPolicy *policy, WpEndpoint *ep)
|
|||
g_variant_dict_insert (&d, "action", "s", "link");
|
||||
g_variant_dict_insert (&d, "media.class", "s",
|
||||
is_sink ? "Audio/Source" : "Audio/Sink");
|
||||
|
||||
g_object_get (ep, "role", &role, NULL);
|
||||
if (role)
|
||||
g_variant_dict_insert (&d, "media.role", "s", role);
|
||||
|
||||
/* TODO: more properties are needed here */
|
||||
|
||||
core = wp_policy_get_core (policy);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue