diff --git a/src/client/context.c b/src/client/context.c index f97631254..060d63bea 100644 --- a/src/client/context.c +++ b/src/client/context.c @@ -75,7 +75,7 @@ pinos_context_get_property (GObject *_object, break; case PROP_PROPERTIES: - g_value_set_variant (value, priv->properties); + g_value_set_boxed (value, priv->properties); break; case PROP_STATE: @@ -117,8 +117,8 @@ pinos_context_set_property (GObject *_object, case PROP_PROPERTIES: if (priv->properties) - g_variant_unref (priv->properties); - priv->properties = g_value_dup_variant (value); + pinos_properties_free (priv->properties); + priv->properties = g_value_dup_boxed (value); break; case PROP_SUBSCRIPTION_MASK: @@ -140,7 +140,7 @@ pinos_context_finalize (GObject * object) g_clear_pointer (&priv->context, g_main_context_unref); g_free (priv->name); if (priv->properties) - g_variant_unref (priv->properties); + pinos_properties_free (priv->properties); g_clear_object (&priv->subscribe); g_clear_error (&priv->error); @@ -193,13 +193,12 @@ pinos_context_class_init (PinosContextClass * klass) */ g_object_class_install_property (gobject_class, PROP_PROPERTIES, - g_param_spec_variant ("properties", - "Properties", - "Extra properties", - G_VARIANT_TYPE_DICTIONARY, - NULL, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS)); + g_param_spec_boxed ("properties", + "Properties", + "Extra properties", + PINOS_TYPE_PROPERTIES, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); /** * PinosContext:state * @@ -287,20 +286,20 @@ pinos_context_init (PinosContext * context) * Returns: a new unconnected #PinosContext */ PinosContext * -pinos_context_new (GMainContext *context, - const gchar *name, - GVariant *properties) +pinos_context_new (GMainContext *context, + const gchar *name, + PinosProperties *properties) { g_return_val_if_fail (name != NULL, NULL); - if (properties == NULL) { - GVariantBuilder builder; + if (properties == NULL) + properties = pinos_properties_new ("media.name", name, NULL); - g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); - g_variant_builder_add (&builder, "{sv}", "name", g_variant_new_string (name)); - properties = g_variant_builder_end (&builder); - } - return g_object_new (PINOS_TYPE_CONTEXT, "main-context", context, "name", name, "properties", properties, NULL); + return g_object_new (PINOS_TYPE_CONTEXT, + "main-context", context, + "name", name, + "properties", properties, + NULL); } static gboolean @@ -388,12 +387,15 @@ on_daemon_connected (GObject *source_object, { PinosContext *context = user_data; PinosContextPrivate *priv = context->priv; + GVariant *variant; context_set_state (context, PINOS_CONTEXT_STATE_REGISTERING); + variant = pinos_properties_to_variant (priv->properties); + g_dbus_proxy_call (priv->daemon, "ConnectClient", - g_variant_new ("(@a{sv})", priv->properties), + g_variant_new ("(@a{sv})", variant), G_DBUS_CALL_FLAGS_NONE, -1, NULL, diff --git a/src/client/context.h b/src/client/context.h index d3b468c19..bf72e2711 100644 --- a/src/client/context.h +++ b/src/client/context.h @@ -24,6 +24,7 @@ #include #include +#include G_BEGIN_DECLS @@ -97,9 +98,9 @@ struct _PinosContextClass { /* normal GObject stuff */ GType pinos_context_get_type (void); -PinosContext * pinos_context_new (GMainContext *ctx, - const gchar *name, - GVariant *properties); +PinosContext * pinos_context_new (GMainContext *ctx, + const gchar *name, + PinosProperties *properties); gboolean pinos_context_connect (PinosContext *context, PinosContextFlags flags); gboolean pinos_context_disconnect (PinosContext *context); diff --git a/src/client/introspect.c b/src/client/introspect.c index c56b55a10..72070c131 100644 --- a/src/client/introspect.c +++ b/src/client/introspect.c @@ -43,7 +43,8 @@ fill_info (PinosSourceInfo *info, GDBusProxy *proxy) info->name = "Unknown"; } - info->properties = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "Properties"); + info->properties = pinos_properties_from_variant ( + g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "Properties")); if ((variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "State"))) { info->state = g_variant_get_uint32 (variant); @@ -63,10 +64,10 @@ fill_info (PinosSourceInfo *info, GDBusProxy *proxy) } static void -clear_info (PinosSourceInfo *info) +client_clear_info (PinosSourceInfo *info) { if (info->properties) - g_variant_unref (info->properties); + pinos_properties_free (info->properties); if (info->formats) g_bytes_unref (info->formats); } @@ -99,9 +100,9 @@ pinos_context_list_source_info (PinosContext *context, GDBusProxy *proxy = walk->data; PinosSourceInfo info; - fill_info (&info, proxy); + client_fill_info (&info, proxy); cb (context, &info, user_data); - clear_info (&info); + client_clear_info (&info); } cb (context, NULL, user_data); } @@ -135,9 +136,8 @@ pinos_context_get_source_info_by_id (PinosContext *context, proxy = G_DBUS_PROXY (id); - fill_info (&info, proxy); + client_fill_info (&info, proxy); cb (context, &info, user_data); - clear_info (&info); - + client_clear_info (&info); cb (context, NULL, user_data); } diff --git a/src/client/introspect.h b/src/client/introspect.h index bb1ccf4ff..ef5da0208 100644 --- a/src/client/introspect.h +++ b/src/client/introspect.h @@ -24,6 +24,7 @@ #include #include +#include G_BEGIN_DECLS @@ -57,13 +58,14 @@ typedef enum { * @state: the current state of the source * @formats: the supported formats * - * The source information + * The source information. Extra information can be added in later + * versions. */ typedef struct { gpointer id; const char *source_path; const char *name; - GVariant *properties; + PinosProperties *properties; PinosSourceState state; GBytes *formats; } PinosSourceInfo; diff --git a/src/client/private.h b/src/client/private.h index 9b681bfe4..a77486dc0 100644 --- a/src/client/private.h +++ b/src/client/private.h @@ -22,7 +22,7 @@ struct _PinosContextPrivate GMainContext *context; gchar *name; - GVariant *properties; + PinosProperties *properties; guint id; GDBusConnection *connection; diff --git a/src/client/stream.c b/src/client/stream.c index 8495571d2..deb4b825f 100644 --- a/src/client/stream.c +++ b/src/client/stream.c @@ -32,7 +32,7 @@ struct _PinosStreamPrivate { PinosContext *context; gchar *name; - GVariant *properties; + PinosProperties *properties; guint id; @@ -99,7 +99,7 @@ pinos_stream_get_property (GObject *_object, break; case PROP_PROPERTIES: - g_value_set_variant (value, priv->properties); + g_value_set_boxed (value, priv->properties); break; case PROP_STATE: @@ -144,8 +144,8 @@ pinos_stream_set_property (GObject *_object, case PROP_PROPERTIES: if (priv->properties) - g_variant_unref (priv->properties); - priv->properties = g_value_dup_variant (value); + pinos_properties_free (priv->properties); + priv->properties = g_value_dup_boxed (value); break; default: @@ -233,7 +233,7 @@ pinos_stream_finalize (GObject * object) g_clear_error (&priv->error); if (priv->properties) - g_variant_unref (priv->properties); + pinos_properties_free (priv->properties); g_signal_handler_disconnect (priv->context->priv->subscribe, priv->id); g_clear_object (&priv->context); g_free (priv->name); @@ -288,14 +288,13 @@ pinos_stream_class_init (PinosStreamClass * klass) */ g_object_class_install_property (gobject_class, PROP_PROPERTIES, - g_param_spec_variant ("properties", - "Properties", - "The properties of the stream", - G_VARIANT_TYPE_VARIANT, - NULL, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); + g_param_spec_boxed ("properties", + "Properties", + "The properties of the stream", + PINOS_TYPE_PROPERTIES, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); /** * PinosStream:state * @@ -393,14 +392,18 @@ pinos_stream_init (PinosStream * stream) * Returns: a new unconnected #PinosStream */ PinosStream * -pinos_stream_new (PinosContext *context, - const gchar *name, - GVariant *props) +pinos_stream_new (PinosContext *context, + const gchar *name, + PinosProperties *props) { g_return_val_if_fail (PINOS_IS_CONTEXT (context), NULL); g_return_val_if_fail (name != NULL, NULL); - return g_object_new (PINOS_TYPE_STREAM, "context", context, "name", name, "properties", props, NULL); + return g_object_new (PINOS_TYPE_STREAM, + "context", context, + "name", name, + "properties", props, + NULL); } /** @@ -546,7 +549,7 @@ do_connect_capture (PinosStream *stream) * @stream: a #PinosStream * @source_path: the source path to connect to * @flags: a #PinosStreamFlags - * @spec: a #GVariant + * @accepted_formats: a #GBytes with accepted formats * * Connect @stream for capturing from @source_path. * @@ -606,7 +609,7 @@ do_connect_provide (PinosStream *stream) * pinos_stream_connect_provide: * @stream: a #PinosStream * @flags: a #PinosStreamFlags - * @spec: a #GVariant + * @possible_formats: a #GBytes * * Connect @stream for providing data for a new source. * diff --git a/src/client/stream.h b/src/client/stream.h index 6be1ad873..f0d53a885 100644 --- a/src/client/stream.h +++ b/src/client/stream.h @@ -93,9 +93,9 @@ struct _PinosStreamClass { GType pinos_stream_get_type (void); -PinosStream * pinos_stream_new (PinosContext *context, - const gchar *name, - GVariant *props); +PinosStream * pinos_stream_new (PinosContext *context, + const gchar *name, + PinosProperties *props); PinosStreamState pinos_stream_get_state (PinosStream *stream); const GError * pinos_stream_get_error (PinosStream *stream); diff --git a/src/daemon/main.c b/src/daemon/main.c index 7bfca22ee..e10cb78d4 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -29,12 +29,14 @@ main (gint argc, gchar *argv[]) { PinosDaemon *daemon; GMainLoop *loop; + PinosProperties *props; pinos_init (&argc, &argv); loop = g_main_loop_new (NULL, FALSE); - daemon = pinos_daemon_new (); + props = pinos_properties_new ("test", "test", NULL); + daemon = pinos_daemon_new (props); pinos_gst_manager_new (daemon); pinos_daemon_start (daemon); diff --git a/src/dbus/org.pinos.xml b/src/dbus/org.pinos.xml index 8ad5be74d..26bc2ca25 100644 --- a/src/dbus/org.pinos.xml +++ b/src/dbus/org.pinos.xml @@ -18,6 +18,8 @@ + +