mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	introspect: improve instrospection
Pass changed properties around so that we can print them
This commit is contained in:
		
							parent
							
								
									51f18b540a
								
							
						
					
					
						commit
						8361f74646
					
				
					 8 changed files with 110 additions and 59 deletions
				
			
		| 
						 | 
					@ -35,6 +35,7 @@ static void subscription_cb (PinosSubscribe         *subscribe,
 | 
				
			||||||
                             PinosSubscriptionEvent  event,
 | 
					                             PinosSubscriptionEvent  event,
 | 
				
			||||||
                             PinosSubscriptionFlags  flags,
 | 
					                             PinosSubscriptionFlags  flags,
 | 
				
			||||||
                             GDBusProxy             *object,
 | 
					                             GDBusProxy             *object,
 | 
				
			||||||
 | 
					                             GStrv                   properties,
 | 
				
			||||||
                             gpointer                user_data);
 | 
					                             gpointer                user_data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum
 | 
					enum
 | 
				
			||||||
| 
						 | 
					@ -246,6 +247,8 @@ pinos_context_class_init (PinosContextClass * klass)
 | 
				
			||||||
   * @event: A #PinosSubscriptionEvent
 | 
					   * @event: A #PinosSubscriptionEvent
 | 
				
			||||||
   * @flags: #PinosSubscriptionFlags indicating the object
 | 
					   * @flags: #PinosSubscriptionFlags indicating the object
 | 
				
			||||||
   * @object: the GDBusProxy object
 | 
					   * @object: the GDBusProxy object
 | 
				
			||||||
 | 
					   * @properties: extra properties that changed or %NULL when all properties
 | 
				
			||||||
 | 
					   *              are affected (new and remove)
 | 
				
			||||||
   *
 | 
					   *
 | 
				
			||||||
   * Notify about a new object that was added/removed/modified.
 | 
					   * Notify about a new object that was added/removed/modified.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
| 
						 | 
					@ -257,10 +260,11 @@ pinos_context_class_init (PinosContextClass * klass)
 | 
				
			||||||
                                                     NULL,
 | 
					                                                     NULL,
 | 
				
			||||||
                                                     g_cclosure_marshal_generic,
 | 
					                                                     g_cclosure_marshal_generic,
 | 
				
			||||||
                                                     G_TYPE_NONE,
 | 
					                                                     G_TYPE_NONE,
 | 
				
			||||||
                                                     3,
 | 
					                                                     4,
 | 
				
			||||||
                                                     PINOS_TYPE_SUBSCRIPTION_EVENT,
 | 
					                                                     PINOS_TYPE_SUBSCRIPTION_EVENT,
 | 
				
			||||||
                                                     PINOS_TYPE_SUBSCRIPTION_FLAGS,
 | 
					                                                     PINOS_TYPE_SUBSCRIPTION_FLAGS,
 | 
				
			||||||
                                                     G_TYPE_DBUS_PROXY);
 | 
					                                                     G_TYPE_DBUS_PROXY,
 | 
				
			||||||
 | 
					                                                     G_TYPE_STRV);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -411,17 +415,18 @@ subscription_cb (PinosSubscribe         *subscribe,
 | 
				
			||||||
                 PinosSubscriptionEvent  event,
 | 
					                 PinosSubscriptionEvent  event,
 | 
				
			||||||
                 PinosSubscriptionFlags  flags,
 | 
					                 PinosSubscriptionFlags  flags,
 | 
				
			||||||
                 GDBusProxy             *object,
 | 
					                 GDBusProxy             *object,
 | 
				
			||||||
 | 
					                 GStrv                   properties,
 | 
				
			||||||
                 gpointer                user_data)
 | 
					                 gpointer                user_data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosContext *context = user_data;
 | 
					  PinosContext *context = user_data;
 | 
				
			||||||
  PinosContextPrivate *priv = context->priv;
 | 
					  PinosContextPrivate *priv = context->priv;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  switch (flags) {
 | 
					  switch (flags) {
 | 
				
			||||||
    case PINOS_SUBSCRIPTION_FLAGS_DAEMON:
 | 
					    case PINOS_SUBSCRIPTION_FLAG_DAEMON:
 | 
				
			||||||
      priv->daemon = g_object_ref (object);
 | 
					      priv->daemon = g_object_ref (object);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case PINOS_SUBSCRIPTION_FLAGS_CLIENT:
 | 
					    case PINOS_SUBSCRIPTION_FLAG_CLIENT:
 | 
				
			||||||
      if (event == PINOS_SUBSCRIPTION_EVENT_NEW) {
 | 
					      if (event == PINOS_SUBSCRIPTION_EVENT_NEW) {
 | 
				
			||||||
        priv->clients = g_list_prepend (priv->clients, object);
 | 
					        priv->clients = g_list_prepend (priv->clients, object);
 | 
				
			||||||
      } else if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE) {
 | 
					      } else if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE) {
 | 
				
			||||||
| 
						 | 
					@ -434,14 +439,14 @@ subscription_cb (PinosSubscribe         *subscribe,
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case PINOS_SUBSCRIPTION_FLAGS_SOURCE:
 | 
					    case PINOS_SUBSCRIPTION_FLAG_SOURCE:
 | 
				
			||||||
      if (event == PINOS_SUBSCRIPTION_EVENT_NEW)
 | 
					      if (event == PINOS_SUBSCRIPTION_EVENT_NEW)
 | 
				
			||||||
        priv->sources = g_list_prepend (priv->sources, object);
 | 
					        priv->sources = g_list_prepend (priv->sources, object);
 | 
				
			||||||
      else if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE)
 | 
					      else if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE)
 | 
				
			||||||
        priv->sources = g_list_remove (priv->sources, object);
 | 
					        priv->sources = g_list_remove (priv->sources, object);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case PINOS_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT:
 | 
					    case PINOS_SUBSCRIPTION_FLAG_SOURCE_OUTPUT:
 | 
				
			||||||
      if (event == PINOS_SUBSCRIPTION_EVENT_NEW)
 | 
					      if (event == PINOS_SUBSCRIPTION_EVENT_NEW)
 | 
				
			||||||
        priv->source_outputs = g_list_prepend (priv->source_outputs, object);
 | 
					        priv->source_outputs = g_list_prepend (priv->source_outputs, object);
 | 
				
			||||||
      else if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE)
 | 
					      else if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE)
 | 
				
			||||||
| 
						 | 
					@ -455,7 +460,8 @@ subscription_cb (PinosSubscribe         *subscribe,
 | 
				
			||||||
                   0,
 | 
					                   0,
 | 
				
			||||||
                   event,
 | 
					                   event,
 | 
				
			||||||
                   flags,
 | 
					                   flags,
 | 
				
			||||||
                   object);
 | 
					                   object,
 | 
				
			||||||
 | 
					                   properties);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -227,10 +227,10 @@ source_fill_info (PinosSourceInfo *info, GDBusProxy *proxy)
 | 
				
			||||||
  if ((variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "PossibleFormats"))) {
 | 
					  if ((variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "PossibleFormats"))) {
 | 
				
			||||||
    gsize len;
 | 
					    gsize len;
 | 
				
			||||||
    gchar *formats = g_variant_dup_string (variant, &len);
 | 
					    gchar *formats = g_variant_dup_string (variant, &len);
 | 
				
			||||||
    info->formats = g_bytes_new_take (formats, len + 1);
 | 
					    info->possible_formats = g_bytes_new_take (formats, len + 1);
 | 
				
			||||||
    g_variant_unref (variant);
 | 
					    g_variant_unref (variant);
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    info->formats = NULL;
 | 
					    info->possible_formats = NULL;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -239,8 +239,8 @@ source_clear_info (PinosSourceInfo *info)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if (info->properties)
 | 
					  if (info->properties)
 | 
				
			||||||
    pinos_properties_free (info->properties);
 | 
					    pinos_properties_free (info->properties);
 | 
				
			||||||
  if (info->formats)
 | 
					  if (info->possible_formats)
 | 
				
			||||||
    g_bytes_unref (info->formats);
 | 
					    g_bytes_unref (info->possible_formats);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -124,7 +124,7 @@ typedef enum {
 | 
				
			||||||
 * @name: name the source, suitable for display
 | 
					 * @name: name the source, suitable for display
 | 
				
			||||||
 * @properties: the properties of the source
 | 
					 * @properties: the properties of the source
 | 
				
			||||||
 * @state: the current state of the source
 | 
					 * @state: the current state of the source
 | 
				
			||||||
 * @formats: the supported formats
 | 
					 * @possible formats: the possible formats this source can produce
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * The source information. Extra information can be added in later
 | 
					 * The source information. Extra information can be added in later
 | 
				
			||||||
 * versions.
 | 
					 * versions.
 | 
				
			||||||
| 
						 | 
					@ -135,7 +135,7 @@ typedef struct {
 | 
				
			||||||
  const char *name;
 | 
					  const char *name;
 | 
				
			||||||
  PinosProperties *properties;
 | 
					  PinosProperties *properties;
 | 
				
			||||||
  PinosSourceState state;
 | 
					  PinosSourceState state;
 | 
				
			||||||
  GBytes *formats;
 | 
					  GBytes *possible_formats;
 | 
				
			||||||
} PinosSourceInfo;
 | 
					} PinosSourceInfo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -179,13 +179,14 @@ subscription_cb (PinosSubscribe         *subscribe,
 | 
				
			||||||
                 PinosSubscriptionEvent  event,
 | 
					                 PinosSubscriptionEvent  event,
 | 
				
			||||||
                 PinosSubscriptionFlags  flags,
 | 
					                 PinosSubscriptionFlags  flags,
 | 
				
			||||||
                 GDBusProxy             *object,
 | 
					                 GDBusProxy             *object,
 | 
				
			||||||
 | 
					                 GStrv                   properties,
 | 
				
			||||||
                 gpointer                user_data)
 | 
					                 gpointer                user_data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosStream *stream = PINOS_STREAM (user_data);
 | 
					  PinosStream *stream = PINOS_STREAM (user_data);
 | 
				
			||||||
  PinosStreamPrivate *priv = stream->priv;
 | 
					  PinosStreamPrivate *priv = stream->priv;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  switch (flags) {
 | 
					  switch (flags) {
 | 
				
			||||||
    case PINOS_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT:
 | 
					    case PINOS_SUBSCRIPTION_FLAG_SOURCE_OUTPUT:
 | 
				
			||||||
      if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE) {
 | 
					      if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE) {
 | 
				
			||||||
        if (object == priv->source_output) {
 | 
					        if (object == priv->source_output) {
 | 
				
			||||||
          priv->error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_CLOSED, "output disappeared");
 | 
					          priv->error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_CLOSED, "output disappeared");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -92,26 +92,27 @@ subscription_set_state (PinosSubscribe         *subscribe,
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
notify_event (PinosSubscribe         *subscribe,
 | 
					notify_event (PinosSubscribe         *subscribe,
 | 
				
			||||||
              PinosObjectData        *data,
 | 
					              PinosObjectData        *data,
 | 
				
			||||||
              PinosSubscriptionEvent  event)
 | 
					              PinosSubscriptionEvent  event,
 | 
				
			||||||
 | 
					              GStrv                   properties)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  const gchar *interface_name;
 | 
					  const gchar *interface_name;
 | 
				
			||||||
  PinosSubscriptionFlags flags = 0;
 | 
					  PinosSubscriptionFlags flags = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  interface_name = g_dbus_proxy_get_interface_name (data->proxy);
 | 
					  interface_name = g_dbus_proxy_get_interface_name (data->proxy);
 | 
				
			||||||
  if (g_strcmp0 (interface_name, "org.pinos.Daemon1") == 0) {
 | 
					  if (g_strcmp0 (interface_name, "org.pinos.Daemon1") == 0) {
 | 
				
			||||||
    flags = PINOS_SUBSCRIPTION_FLAGS_DAEMON;
 | 
					    flags = PINOS_SUBSCRIPTION_FLAG_DAEMON;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else if (g_strcmp0 (interface_name, "org.pinos.Client1") == 0) {
 | 
					  else if (g_strcmp0 (interface_name, "org.pinos.Client1") == 0) {
 | 
				
			||||||
    flags = PINOS_SUBSCRIPTION_FLAGS_CLIENT;
 | 
					    flags = PINOS_SUBSCRIPTION_FLAG_CLIENT;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else if (g_strcmp0 (interface_name, "org.pinos.Source1") == 0) {
 | 
					  else if (g_strcmp0 (interface_name, "org.pinos.Source1") == 0) {
 | 
				
			||||||
    flags = PINOS_SUBSCRIPTION_FLAGS_SOURCE;
 | 
					    flags = PINOS_SUBSCRIPTION_FLAG_SOURCE;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else if (g_strcmp0 (interface_name, "org.pinos.SourceOutput1") == 0) {
 | 
					  else if (g_strcmp0 (interface_name, "org.pinos.SourceOutput1") == 0) {
 | 
				
			||||||
    flags = PINOS_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT;
 | 
					    flags = PINOS_SUBSCRIPTION_FLAG_SOURCE_OUTPUT;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  g_signal_emit (subscribe, signals[SIGNAL_SUBSCRIPTION_EVENT], 0,
 | 
					  g_signal_emit (subscribe, signals[SIGNAL_SUBSCRIPTION_EVENT], 0,
 | 
				
			||||||
          event, flags, data->proxy);
 | 
					          event, flags, data->proxy, properties);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
| 
						 | 
					@ -121,8 +122,22 @@ on_proxy_properties_changed (GDBusProxy *proxy,
 | 
				
			||||||
                             gpointer    user_data)
 | 
					                             gpointer    user_data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosObjectData *data = user_data;
 | 
					  PinosObjectData *data = user_data;
 | 
				
			||||||
 | 
					  GPtrArray *ptr;
 | 
				
			||||||
 | 
					  GVariantIter iter;
 | 
				
			||||||
 | 
					  GVariant *value;
 | 
				
			||||||
 | 
					  gchar *key;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  notify_event (data->subscribe, data, PINOS_SUBSCRIPTION_EVENT_CHANGE);
 | 
					  ptr = g_ptr_array_new_with_free_func (g_free);
 | 
				
			||||||
 | 
					  g_variant_iter_init (&iter, changed_properties);
 | 
				
			||||||
 | 
					  while (g_variant_iter_loop (&iter, "{sv}", &key, &value)) {
 | 
				
			||||||
 | 
					    g_ptr_array_add (ptr, g_strdup (key));
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  g_ptr_array_add (ptr, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  notify_event (data->subscribe, data, PINOS_SUBSCRIPTION_EVENT_CHANGE,
 | 
				
			||||||
 | 
					      (gchar **) ptr->pdata);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  g_ptr_array_free (ptr, TRUE);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
| 
						 | 
					@ -143,7 +158,7 @@ remove_data (PinosSubscribe  *subscribe,
 | 
				
			||||||
  if (data->pending) {
 | 
					  if (data->pending) {
 | 
				
			||||||
    data->removed = TRUE;
 | 
					    data->removed = TRUE;
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    notify_event (subscribe, data, PINOS_SUBSCRIPTION_EVENT_REMOVE);
 | 
					    notify_event (subscribe, data, PINOS_SUBSCRIPTION_EVENT_REMOVE, NULL);
 | 
				
			||||||
    object_data_free (data);
 | 
					    object_data_free (data);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -189,7 +204,7 @@ on_proxy_created (GObject      *source_object,
 | 
				
			||||||
                    (GCallback) on_proxy_properties_changed,
 | 
					                    (GCallback) on_proxy_properties_changed,
 | 
				
			||||||
                    data);
 | 
					                    data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  notify_event (subscribe, data, PINOS_SUBSCRIPTION_EVENT_NEW);
 | 
					  notify_event (subscribe, data, PINOS_SUBSCRIPTION_EVENT_NEW, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (walk = data->tasks; walk; walk = g_list_next (walk)) {
 | 
					  for (walk = data->tasks; walk; walk = g_list_next (walk)) {
 | 
				
			||||||
    GTask *task = walk->data;
 | 
					    GTask *task = walk->data;
 | 
				
			||||||
| 
						 | 
					@ -636,6 +651,8 @@ pinos_subscribe_class_init (PinosSubscribeClass * klass)
 | 
				
			||||||
   * @event: A #PinosSubscriptionEvent
 | 
					   * @event: A #PinosSubscriptionEvent
 | 
				
			||||||
   * @flags: #PinosSubscriptionFlags indicating the object
 | 
					   * @flags: #PinosSubscriptionFlags indicating the object
 | 
				
			||||||
   * @id: the unique and opaque object id
 | 
					   * @id: the unique and opaque object id
 | 
				
			||||||
 | 
					   * @properties: extra properties that changed or %NULL when all properties
 | 
				
			||||||
 | 
					   *              are affected (new or remove)
 | 
				
			||||||
   *
 | 
					   *
 | 
				
			||||||
   * Notify about a new object that was added/removed/modified.
 | 
					   * Notify about a new object that was added/removed/modified.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
| 
						 | 
					@ -647,10 +664,11 @@ pinos_subscribe_class_init (PinosSubscribeClass * klass)
 | 
				
			||||||
                                                     NULL,
 | 
					                                                     NULL,
 | 
				
			||||||
                                                     g_cclosure_marshal_generic,
 | 
					                                                     g_cclosure_marshal_generic,
 | 
				
			||||||
                                                     G_TYPE_NONE,
 | 
					                                                     G_TYPE_NONE,
 | 
				
			||||||
                                                     3,
 | 
					                                                     4,
 | 
				
			||||||
                                                     PINOS_TYPE_SUBSCRIPTION_EVENT,
 | 
					                                                     PINOS_TYPE_SUBSCRIPTION_EVENT,
 | 
				
			||||||
                                                     PINOS_TYPE_SUBSCRIPTION_FLAGS,
 | 
					                                                     PINOS_TYPE_SUBSCRIPTION_FLAGS,
 | 
				
			||||||
                                                     G_TYPE_POINTER);
 | 
					                                                     G_TYPE_POINTER,
 | 
				
			||||||
 | 
					                                                     G_TYPE_STRV);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,10 +45,10 @@ typedef enum {
 | 
				
			||||||
} PinosSubscriptionState;
 | 
					} PinosSubscriptionState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef enum {
 | 
					typedef enum {
 | 
				
			||||||
    PINOS_SUBSCRIPTION_FLAGS_DAEMON          = (1 << 0),
 | 
					    PINOS_SUBSCRIPTION_FLAG_DAEMON          = (1 << 0),
 | 
				
			||||||
    PINOS_SUBSCRIPTION_FLAGS_CLIENT          = (1 << 1),
 | 
					    PINOS_SUBSCRIPTION_FLAG_CLIENT          = (1 << 1),
 | 
				
			||||||
    PINOS_SUBSCRIPTION_FLAGS_SOURCE          = (1 << 2),
 | 
					    PINOS_SUBSCRIPTION_FLAG_SOURCE          = (1 << 2),
 | 
				
			||||||
    PINOS_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT   = (1 << 3),
 | 
					    PINOS_SUBSCRIPTION_FLAG_SOURCE_OUTPUT   = (1 << 3),
 | 
				
			||||||
} PinosSubscriptionFlags;
 | 
					} PinosSubscriptionFlags;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define PINOS_SUBSCRIPTION_FLAGS_ALL 0xf
 | 
					#define PINOS_SUBSCRIPTION_FLAGS_ALL 0xf
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -198,8 +198,8 @@ new_source (const PinosSourceInfo *info)
 | 
				
			||||||
  gpointer state = NULL;
 | 
					  gpointer state = NULL;
 | 
				
			||||||
  const gchar *klass;
 | 
					  const gchar *klass;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (info->formats)
 | 
					  if (info->possible_formats)
 | 
				
			||||||
    caps = gst_caps_from_string (g_bytes_get_data (info->formats, NULL));
 | 
					    caps = gst_caps_from_string (g_bytes_get_data (info->possible_formats, NULL));
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    caps = gst_caps_new_any();
 | 
					    caps = gst_caps_new_any();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -273,19 +273,20 @@ context_subscribe_cb (PinosContext           *context,
 | 
				
			||||||
                      PinosSubscriptionEvent  type,
 | 
					                      PinosSubscriptionEvent  type,
 | 
				
			||||||
                      PinosSubscriptionFlags  flags,
 | 
					                      PinosSubscriptionFlags  flags,
 | 
				
			||||||
                      gpointer                id,
 | 
					                      gpointer                id,
 | 
				
			||||||
                      gpointer                user_data)
 | 
					                      gpointer                user_data,
 | 
				
			||||||
 | 
					                      GStrv                   properties)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  GstPinosDeviceProvider *self = user_data;
 | 
					  GstPinosDeviceProvider *self = user_data;
 | 
				
			||||||
  GstDeviceProvider *provider = user_data;
 | 
					  GstDeviceProvider *provider = user_data;
 | 
				
			||||||
  GstPinosDevice *dev;
 | 
					  GstPinosDevice *dev;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (flags != PINOS_SUBSCRIPTION_FLAGS_SOURCE)
 | 
					  if (flags != PINOS_SUBSCRIPTION_FLAG_SOURCE)
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  dev = find_device (provider, id);
 | 
					  dev = find_device (provider, id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (type == PINOS_SUBSCRIPTION_EVENT_NEW) {
 | 
					  if (type == PINOS_SUBSCRIPTION_EVENT_NEW) {
 | 
				
			||||||
    if (flags == PINOS_SUBSCRIPTION_FLAGS_SOURCE && dev == NULL)
 | 
					    if (flags == PINOS_SUBSCRIPTION_FLAG_SOURCE && dev == NULL)
 | 
				
			||||||
      pinos_context_get_source_info_by_id (context,
 | 
					      pinos_context_get_source_info_by_id (context,
 | 
				
			||||||
                                           id,
 | 
					                                           id,
 | 
				
			||||||
                                           PINOS_SOURCE_INFO_FLAGS_FORMATS,
 | 
					                                           PINOS_SOURCE_INFO_FLAGS_FORMATS,
 | 
				
			||||||
| 
						 | 
					@ -293,7 +294,7 @@ context_subscribe_cb (PinosContext           *context,
 | 
				
			||||||
                                           NULL,
 | 
					                                           NULL,
 | 
				
			||||||
                                           self);
 | 
					                                           self);
 | 
				
			||||||
  } else if (type == PINOS_SUBSCRIPTION_EVENT_REMOVE) {
 | 
					  } else if (type == PINOS_SUBSCRIPTION_EVENT_REMOVE) {
 | 
				
			||||||
    if (flags == PINOS_SUBSCRIPTION_FLAGS_SOURCE && dev != NULL) {
 | 
					    if (flags == PINOS_SUBSCRIPTION_FLAG_SOURCE && dev != NULL) {
 | 
				
			||||||
      gst_device_provider_device_remove (GST_DEVICE_PROVIDER (self),
 | 
					      gst_device_provider_device_remove (GST_DEVICE_PROVIDER (self),
 | 
				
			||||||
                                         GST_DEVICE (dev));
 | 
					                                         GST_DEVICE (dev));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -83,6 +83,8 @@ print_properties (PinosProperties *props)
 | 
				
			||||||
static gboolean
 | 
					static gboolean
 | 
				
			||||||
dump_daemon_info (PinosContext *c, const PinosDaemonInfo *info, gpointer userdata)
 | 
					dump_daemon_info (PinosContext *c, const PinosDaemonInfo *info, gpointer userdata)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					  const gchar * const *props = userdata;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (info == NULL)
 | 
					  if (info == NULL)
 | 
				
			||||||
    return FALSE;
 | 
					    return FALSE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -92,6 +94,7 @@ dump_daemon_info (PinosContext *c, const PinosDaemonInfo *info, gpointer userdat
 | 
				
			||||||
  g_print ("\tversion: \"%s\"\n", info->version);
 | 
					  g_print ("\tversion: \"%s\"\n", info->version);
 | 
				
			||||||
  g_print ("\tname: \"%s\"\n", info->name);
 | 
					  g_print ("\tname: \"%s\"\n", info->name);
 | 
				
			||||||
  g_print ("\tcookie: %d\n", info->cookie);
 | 
					  g_print ("\tcookie: %d\n", info->cookie);
 | 
				
			||||||
 | 
					  if (!props || g_strv_contains (props, "Properties"))
 | 
				
			||||||
    print_properties (info->properties);
 | 
					    print_properties (info->properties);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return TRUE;
 | 
					  return TRUE;
 | 
				
			||||||
| 
						 | 
					@ -100,11 +103,15 @@ dump_daemon_info (PinosContext *c, const PinosDaemonInfo *info, gpointer userdat
 | 
				
			||||||
static gboolean
 | 
					static gboolean
 | 
				
			||||||
dump_client_info (PinosContext *c, const PinosClientInfo *info, gpointer userdata)
 | 
					dump_client_info (PinosContext *c, const PinosClientInfo *info, gpointer userdata)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					  const gchar * const *props = userdata;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (info == NULL)
 | 
					  if (info == NULL)
 | 
				
			||||||
    return FALSE;
 | 
					    return FALSE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  g_print ("\tid: %p\n", info->id);
 | 
					  g_print ("\tid: %p\n", info->id);
 | 
				
			||||||
 | 
					  if (!props || g_strv_contains (props, "Name"))
 | 
				
			||||||
    g_print ("\tname: \"%s\"\n", info->name);
 | 
					    g_print ("\tname: \"%s\"\n", info->name);
 | 
				
			||||||
 | 
					  if (!props || g_strv_contains (props, "Properties"))
 | 
				
			||||||
    print_properties (info->properties);
 | 
					    print_properties (info->properties);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return TRUE;
 | 
					  return TRUE;
 | 
				
			||||||
| 
						 | 
					@ -113,14 +120,21 @@ dump_client_info (PinosContext *c, const PinosClientInfo *info, gpointer userdat
 | 
				
			||||||
static gboolean
 | 
					static gboolean
 | 
				
			||||||
dump_source_info (PinosContext *c, const PinosSourceInfo *info, gpointer userdata)
 | 
					dump_source_info (PinosContext *c, const PinosSourceInfo *info, gpointer userdata)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					  const gchar * const *props = userdata;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (info == NULL)
 | 
					  if (info == NULL)
 | 
				
			||||||
    return FALSE;
 | 
					    return FALSE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  g_print ("\tid: %p\n", info->id);
 | 
					  g_print ("\tid: %p\n", info->id);
 | 
				
			||||||
 | 
					  if (!props || g_strv_contains (props, "Source"))
 | 
				
			||||||
    g_print ("\tsource-path: \"%s\"\n", info->source_path);
 | 
					    g_print ("\tsource-path: \"%s\"\n", info->source_path);
 | 
				
			||||||
 | 
					  if (!props || g_strv_contains (props, "Name"))
 | 
				
			||||||
    g_print ("\tname: \"%s\"\n", info->name);
 | 
					    g_print ("\tname: \"%s\"\n", info->name);
 | 
				
			||||||
 | 
					  if (!props || g_strv_contains (props, "State"))
 | 
				
			||||||
    g_print ("\tstate: %d\n", info->state);
 | 
					    g_print ("\tstate: %d\n", info->state);
 | 
				
			||||||
  print_formats ("formats", info->formats);
 | 
					  if (!props || g_strv_contains (props, "PossibleFormats"))
 | 
				
			||||||
 | 
					    print_formats ("possible formats", info->possible_formats);
 | 
				
			||||||
 | 
					  if (!props || g_strv_contains (props, "Properties"))
 | 
				
			||||||
    print_properties (info->properties);
 | 
					    print_properties (info->properties);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return TRUE;
 | 
					  return TRUE;
 | 
				
			||||||
| 
						 | 
					@ -129,53 +143,62 @@ dump_source_info (PinosContext *c, const PinosSourceInfo *info, gpointer userdat
 | 
				
			||||||
static gboolean
 | 
					static gboolean
 | 
				
			||||||
dump_source_output_info (PinosContext *c, const PinosSourceOutputInfo *info, gpointer userdata)
 | 
					dump_source_output_info (PinosContext *c, const PinosSourceOutputInfo *info, gpointer userdata)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					  const gchar * const *props = userdata;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (info == NULL)
 | 
					  if (info == NULL)
 | 
				
			||||||
    return FALSE;
 | 
					    return FALSE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  g_print ("\tid: %p\n", info->id);
 | 
					  g_print ("\tid: %p\n", info->id);
 | 
				
			||||||
 | 
					  if (!props || g_strv_contains (props, "Client"))
 | 
				
			||||||
    g_print ("\tclient-path: \"%s\"\n", info->client_path);
 | 
					    g_print ("\tclient-path: \"%s\"\n", info->client_path);
 | 
				
			||||||
 | 
					  if (!props || g_strv_contains (props, "Source"))
 | 
				
			||||||
    g_print ("\tsource-path: \"%s\"\n", info->source_path);
 | 
					    g_print ("\tsource-path: \"%s\"\n", info->source_path);
 | 
				
			||||||
 | 
					  if (!props || g_strv_contains (props, "PossibleFormats"))
 | 
				
			||||||
    print_formats ("possible-formats", info->possible_formats);
 | 
					    print_formats ("possible-formats", info->possible_formats);
 | 
				
			||||||
 | 
					  if (!props || g_strv_contains (props, "State"))
 | 
				
			||||||
    g_print ("\tstate: \"%d\"\n", info->state);
 | 
					    g_print ("\tstate: \"%d\"\n", info->state);
 | 
				
			||||||
 | 
					  if (!props || g_strv_contains (props, "Format"))
 | 
				
			||||||
    print_formats ("format", info->format);
 | 
					    print_formats ("format", info->format);
 | 
				
			||||||
 | 
					  if (!props || g_strv_contains (props, "Properties"))
 | 
				
			||||||
    print_properties (info->properties);
 | 
					    print_properties (info->properties);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return TRUE;
 | 
					  return TRUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
dump_object (PinosContext *context, GDBusProxy *proxy, PinosSubscriptionFlags flags)
 | 
					dump_object (PinosContext *context, GDBusProxy *proxy, PinosSubscriptionFlags flags,
 | 
				
			||||||
 | 
					    GStrv properties)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if (flags & PINOS_SUBSCRIPTION_FLAGS_DAEMON) {
 | 
					  if (flags & PINOS_SUBSCRIPTION_FLAG_DAEMON) {
 | 
				
			||||||
    pinos_context_get_daemon_info (context,
 | 
					    pinos_context_get_daemon_info (context,
 | 
				
			||||||
                                   PINOS_DAEMON_INFO_FLAGS_NONE,
 | 
					                                   PINOS_DAEMON_INFO_FLAGS_NONE,
 | 
				
			||||||
                                   dump_daemon_info,
 | 
					                                   dump_daemon_info,
 | 
				
			||||||
                                   NULL,
 | 
					                                   NULL,
 | 
				
			||||||
                                   NULL);
 | 
					                                   properties);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else if (flags & PINOS_SUBSCRIPTION_FLAGS_CLIENT) {
 | 
					  else if (flags & PINOS_SUBSCRIPTION_FLAG_CLIENT) {
 | 
				
			||||||
    pinos_context_get_client_info_by_id (context,
 | 
					    pinos_context_get_client_info_by_id (context,
 | 
				
			||||||
                                         proxy,
 | 
					                                         proxy,
 | 
				
			||||||
                                         PINOS_CLIENT_INFO_FLAGS_NONE,
 | 
					                                         PINOS_CLIENT_INFO_FLAGS_NONE,
 | 
				
			||||||
                                         dump_client_info,
 | 
					                                         dump_client_info,
 | 
				
			||||||
                                         NULL,
 | 
					                                         NULL,
 | 
				
			||||||
                                         NULL);
 | 
					                                         properties);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else if (flags & PINOS_SUBSCRIPTION_FLAGS_SOURCE) {
 | 
					  else if (flags & PINOS_SUBSCRIPTION_FLAG_SOURCE) {
 | 
				
			||||||
    pinos_context_get_source_info_by_id (context,
 | 
					    pinos_context_get_source_info_by_id (context,
 | 
				
			||||||
                                         proxy,
 | 
					                                         proxy,
 | 
				
			||||||
                                         PINOS_SOURCE_INFO_FLAGS_FORMATS,
 | 
					                                         PINOS_SOURCE_INFO_FLAGS_FORMATS,
 | 
				
			||||||
                                         dump_source_info,
 | 
					                                         dump_source_info,
 | 
				
			||||||
                                         NULL,
 | 
					                                         NULL,
 | 
				
			||||||
                                         NULL);
 | 
					                                         properties);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else if (flags & PINOS_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT) {
 | 
					  else if (flags & PINOS_SUBSCRIPTION_FLAG_SOURCE_OUTPUT) {
 | 
				
			||||||
    pinos_context_get_source_output_info_by_id (context,
 | 
					    pinos_context_get_source_output_info_by_id (context,
 | 
				
			||||||
                                                proxy,
 | 
					                                                proxy,
 | 
				
			||||||
                                                PINOS_SOURCE_OUTPUT_INFO_FLAGS_NONE,
 | 
					                                                PINOS_SOURCE_OUTPUT_INFO_FLAGS_NONE,
 | 
				
			||||||
                                                dump_source_output_info,
 | 
					                                                dump_source_output_info,
 | 
				
			||||||
                                                NULL,
 | 
					                                                NULL,
 | 
				
			||||||
                                                NULL);
 | 
					                                                properties);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -184,16 +207,18 @@ subscription_cb (PinosContext           *context,
 | 
				
			||||||
                 PinosSubscriptionEvent  type,
 | 
					                 PinosSubscriptionEvent  type,
 | 
				
			||||||
                 PinosSubscriptionFlags  flags,
 | 
					                 PinosSubscriptionFlags  flags,
 | 
				
			||||||
                 gpointer                id,
 | 
					                 gpointer                id,
 | 
				
			||||||
 | 
					                 GStrv                   properties,
 | 
				
			||||||
                 gpointer                user_data)
 | 
					                 gpointer                user_data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  switch (type) {
 | 
					  switch (type) {
 | 
				
			||||||
    case PINOS_SUBSCRIPTION_EVENT_NEW:
 | 
					    case PINOS_SUBSCRIPTION_EVENT_NEW:
 | 
				
			||||||
      g_print ("added: %s\n", g_dbus_proxy_get_object_path (id));
 | 
					      g_print ("added: %s\n", g_dbus_proxy_get_object_path (id));
 | 
				
			||||||
      dump_object (context, G_DBUS_PROXY (id), flags);
 | 
					      dump_object (context, G_DBUS_PROXY (id), flags, properties);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case PINOS_SUBSCRIPTION_EVENT_CHANGE:
 | 
					    case PINOS_SUBSCRIPTION_EVENT_CHANGE:
 | 
				
			||||||
      g_print ("changed: %s\n", g_dbus_proxy_get_object_path (id));
 | 
					      g_print ("changed: %s\n", g_dbus_proxy_get_object_path (id));
 | 
				
			||||||
 | 
					      dump_object (context, G_DBUS_PROXY (id), flags, properties);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case PINOS_SUBSCRIPTION_EVENT_REMOVE:
 | 
					    case PINOS_SUBSCRIPTION_EVENT_REMOVE:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue