base-endpoint: add _get_priority API

This commit is contained in:
Julian Bouzas
2019-12-11 16:13:42 -05:00
parent 0552e7da87
commit 0ad0c9fb9d
6 changed files with 39 additions and 2 deletions

View File

@@ -96,6 +96,7 @@ struct _WpBaseEndpointPrivate
gchar media_class[40]; gchar media_class[40];
guint direction; guint direction;
guint64 creation_time; guint64 creation_time;
guint priority;
GPtrArray *streams; GPtrArray *streams;
GPtrArray *controls; GPtrArray *controls;
GPtrArray *links; GPtrArray *links;
@@ -109,6 +110,7 @@ enum {
PROP_MEDIA_CLASS, PROP_MEDIA_CLASS,
PROP_DIRECTION, PROP_DIRECTION,
PROP_CREATION_TIME, PROP_CREATION_TIME,
PROP_PRIORITY,
}; };
enum { enum {
@@ -223,6 +225,9 @@ wp_base_endpoint_set_property (GObject * object, guint property_id,
case PROP_CREATION_TIME: case PROP_CREATION_TIME:
priv->creation_time = g_value_get_uint64(value); priv->creation_time = g_value_get_uint64(value);
break; break;
case PROP_PRIORITY:
priv->priority = g_value_get_uint(value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break; break;
@@ -252,6 +257,9 @@ wp_base_endpoint_get_property (GObject * object, guint property_id, GValue * val
case PROP_CREATION_TIME: case PROP_CREATION_TIME:
g_value_set_uint64 (value, priv->creation_time); g_value_set_uint64 (value, priv->creation_time);
break; break;
case PROP_PRIORITY:
g_value_set_uint (value, priv->priority);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break; break;
@@ -318,6 +326,14 @@ wp_base_endpoint_class_init (WpBaseEndpointClass * klass)
"The time that this endpoint was created, in monotonic time", "The time that this endpoint was created, in monotonic time",
0, G_MAXUINT64, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); 0, G_MAXUINT64, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
* WpBaseEndpoint::direction:
* The priority of the endpoint:
*/
g_object_class_install_property (object_class, PROP_PRIORITY,
g_param_spec_uint ("priority", "priority",
"The priority of the endpoint", 0, G_MAXUINT, 0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
} }
/** /**
@@ -451,6 +467,17 @@ wp_base_endpoint_get_creation_time (WpBaseEndpoint * self)
return priv->creation_time; return priv->creation_time;
} }
guint32
wp_base_endpoint_get_priority (WpBaseEndpoint * self)
{
WpBaseEndpointPrivate *priv;
g_return_val_if_fail (WP_IS_BASE_ENDPOINT (self), -1);
priv = wp_base_endpoint_get_instance_private (self);
return priv->priority;
}
WpProperties * WpProperties *
wp_base_endpoint_get_properties (WpBaseEndpoint * self) wp_base_endpoint_get_properties (WpBaseEndpoint * self)
{ {

View File

@@ -54,6 +54,7 @@ const gchar * wp_base_endpoint_get_name (WpBaseEndpoint * self);
const gchar * wp_base_endpoint_get_media_class (WpBaseEndpoint * self); const gchar * wp_base_endpoint_get_media_class (WpBaseEndpoint * self);
guint wp_base_endpoint_get_direction (WpBaseEndpoint * self); guint wp_base_endpoint_get_direction (WpBaseEndpoint * self);
guint64 wp_base_endpoint_get_creation_time (WpBaseEndpoint * self); guint64 wp_base_endpoint_get_creation_time (WpBaseEndpoint * self);
guint32 wp_base_endpoint_get_priority (WpBaseEndpoint * self);
WpProperties * wp_base_endpoint_get_properties (WpBaseEndpoint * self); WpProperties * wp_base_endpoint_get_properties (WpBaseEndpoint * self);
const char * wp_base_endpoint_get_role (WpBaseEndpoint * self); const char * wp_base_endpoint_get_role (WpBaseEndpoint * self);

View File

@@ -141,6 +141,8 @@ on_node_added (WpObjectManager *om, WpProxy *proxy, gpointer d)
"media-class", g_variant_new_string (media_class)); "media-class", g_variant_new_string (media_class));
g_variant_builder_add (&b, "{sv}", g_variant_builder_add (&b, "{sv}",
"direction", g_variant_new_uint32 (endpoint_data->e.direction)); "direction", g_variant_new_uint32 (endpoint_data->e.direction));
g_variant_builder_add (&b, "{sv}",
"priority", g_variant_new_uint32 (endpoint_data->e.priority));
g_variant_builder_add (&b, "{sv}", g_variant_builder_add (&b, "{sv}",
"proxy-node", g_variant_new_uint64 ((guint64) proxy)); "proxy-node", g_variant_new_uint64 ((guint64) proxy));
if (streams_variant) if (streams_variant)

View File

@@ -495,7 +495,7 @@ audio_softdsp_endpoint_factory (WpFactory * factory, GType type, GVariant * prop
{ {
g_autoptr (WpCore) core = NULL; g_autoptr (WpCore) core = NULL;
const gchar *name, *media_class; const gchar *name, *media_class;
guint direction; guint direction, priority;
guint64 node; guint64 node;
g_autoptr (GVariant) streams = NULL; g_autoptr (GVariant) streams = NULL;
@@ -513,6 +513,8 @@ audio_softdsp_endpoint_factory (WpFactory * factory, GType type, GVariant * prop
return; return;
if (!g_variant_lookup (properties, "direction", "u", &direction)) if (!g_variant_lookup (properties, "direction", "u", &direction))
return; return;
if (!g_variant_lookup (properties, "priority", "u", &priority))
return;
if (!g_variant_lookup (properties, "proxy-node", "t", &node)) if (!g_variant_lookup (properties, "proxy-node", "t", &node))
return; return;
streams = g_variant_lookup_value (properties, "streams", streams = g_variant_lookup_value (properties, "streams",
@@ -525,6 +527,7 @@ audio_softdsp_endpoint_factory (WpFactory * factory, GType type, GVariant * prop
"name", name, "name", name,
"media-class", media_class, "media-class", media_class,
"direction", direction, "direction", direction,
"priority", priority,
"proxy-node", (gpointer) node, "proxy-node", (gpointer) node,
"streams", streams, "streams", streams,
NULL); NULL);

View File

@@ -209,7 +209,7 @@ wp_endpoint_audiotestsrc_factory (WpFactory * factory, GType type,
{ {
g_autoptr (WpCore) core = NULL; g_autoptr (WpCore) core = NULL;
const gchar *name, *media_class; const gchar *name, *media_class;
guint direction; guint direction, priority;
guint64 node; guint64 node;
g_autoptr (GVariant) streams = NULL; g_autoptr (GVariant) streams = NULL;
@@ -222,6 +222,8 @@ wp_endpoint_audiotestsrc_factory (WpFactory * factory, GType type,
return; return;
if (!g_variant_lookup (properties, "direction", "u", &direction)) if (!g_variant_lookup (properties, "direction", "u", &direction))
return; return;
if (!g_variant_lookup (properties, "priority", "u", &priority))
return;
if (!g_variant_lookup (properties, "proxy-node", "t", &node)) if (!g_variant_lookup (properties, "proxy-node", "t", &node))
return; return;
streams = g_variant_lookup_value (properties, "streams", streams = g_variant_lookup_value (properties, "streams",
@@ -233,6 +235,7 @@ wp_endpoint_audiotestsrc_factory (WpFactory * factory, GType type,
"name", name, "name", name,
"media-class", media_class, "media-class", media_class,
"direction", direction, "direction", direction,
"priority", priority,
"proxy-node", (gpointer) node, "proxy-node", (gpointer) node,
"streams", streams, "streams", streams,
NULL); NULL);

View File

@@ -224,6 +224,7 @@ wp_fake_endpoint_new_async (WpCore *core, const char *name,
"name", name, "name", name,
"media-class", media_class, "media-class", media_class,
"direction", direction, "direction", direction,
"priority", 0,
"properties", props, "properties", props,
"role", role, "role", role,
"streams", streams, "streams", streams,