mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	pinos-monitor: show peer ports
This commit is contained in:
		
							parent
							
								
									e8116fa68d
								
							
						
					
					
						commit
						6fcd0985a3
					
				
					 3 changed files with 51 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -103,6 +103,19 @@ G_STMT_START {
 | 
			
		|||
  }                                                                                     \
 | 
			
		||||
} G_STMT_END
 | 
			
		||||
 | 
			
		||||
#define SET_OBJV(name, field, idx)                                                      \
 | 
			
		||||
G_STMT_START {                                                                          \
 | 
			
		||||
  GVariant *variant;                                                                    \
 | 
			
		||||
  if (!changed || g_hash_table_contains (changed, name))                                \
 | 
			
		||||
    info->change_mask |= 1 << idx;                                                      \
 | 
			
		||||
  if ((variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), name))) {      \
 | 
			
		||||
    info->field = g_variant_dup_objv (variant, NULL);                                   \
 | 
			
		||||
    g_variant_unref (variant);                                                          \
 | 
			
		||||
  } else {                                                                              \
 | 
			
		||||
    info->field = NULL;                                                                 \
 | 
			
		||||
  }                                                                                     \
 | 
			
		||||
} G_STMT_END
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
daemon_fill_info (PinosDaemonInfo *info, GDBusProxy *proxy)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -324,9 +337,10 @@ port_fill_info (PinosPortInfo *info, GDBusProxy *proxy)
 | 
			
		|||
 | 
			
		||||
  info->change_mask = 0;
 | 
			
		||||
  SET_STRING ("Name", name, 0);
 | 
			
		||||
  SET_PROPERTIES ("Properties", properties, 1);
 | 
			
		||||
  SET_BYTES ("PossibleFormats", possible_formats, 2);
 | 
			
		||||
  SET_BYTES ("Format", format, 3);
 | 
			
		||||
  SET_OBJV ("Peers", peers, 1);
 | 
			
		||||
  SET_PROPERTIES ("Properties", properties, 2);
 | 
			
		||||
  SET_BYTES ("PossibleFormats", possible_formats, 3);
 | 
			
		||||
  SET_BYTES ("Format", format, 4);
 | 
			
		||||
 | 
			
		||||
  if (changed)
 | 
			
		||||
    g_hash_table_remove_all (changed);
 | 
			
		||||
| 
						 | 
				
			
			@ -335,6 +349,8 @@ port_fill_info (PinosPortInfo *info, GDBusProxy *proxy)
 | 
			
		|||
static void
 | 
			
		||||
port_clear_info (PinosPortInfo *info)
 | 
			
		||||
{
 | 
			
		||||
  if (info->peers)
 | 
			
		||||
    g_strfreev (info->peers);
 | 
			
		||||
  if (info->properties)
 | 
			
		||||
    pinos_properties_free (info->properties);
 | 
			
		||||
  if (info->possible_formats)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -212,6 +212,7 @@ void            pinos_context_get_node_info_by_id   (PinosContext *context,
 | 
			
		|||
 * @direction: the direction of the port
 | 
			
		||||
 * @change_mask: bitfield of changed fields since last call
 | 
			
		||||
 * @name: name the port, suitable for display
 | 
			
		||||
 * @peers: paths to peer ports
 | 
			
		||||
 * @properties: the properties of the port
 | 
			
		||||
 * @possible_formats: the possible formats this port can consume
 | 
			
		||||
 * @format: the current format on this port
 | 
			
		||||
| 
						 | 
				
			
			@ -227,6 +228,7 @@ typedef struct {
 | 
			
		|||
  guint64 change_mask;
 | 
			
		||||
  const char *name;
 | 
			
		||||
  PinosProperties *properties;
 | 
			
		||||
  gchar **peers;
 | 
			
		||||
  GBytes *possible_formats;
 | 
			
		||||
  GBytes *format;
 | 
			
		||||
} PinosPortInfo;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -92,6 +92,32 @@ print_properties (PinosProperties *props, gchar mark)
 | 
			
		|||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
print_peers (gchar **peers, gchar mark)
 | 
			
		||||
{
 | 
			
		||||
  GValue list = G_VALUE_INIT;
 | 
			
		||||
  gint idx = 0;
 | 
			
		||||
  gchar *str;
 | 
			
		||||
 | 
			
		||||
  g_value_init (&list, GST_TYPE_LIST);
 | 
			
		||||
 | 
			
		||||
  if (peers != NULL) {
 | 
			
		||||
    while (peers[idx]) {
 | 
			
		||||
      GValue peer = G_VALUE_INIT;
 | 
			
		||||
 | 
			
		||||
      g_value_init (&peer, G_TYPE_STRING);
 | 
			
		||||
      g_value_set_string (&peer, peers[idx]);
 | 
			
		||||
      gst_value_list_append_and_take_value (&list, &peer);
 | 
			
		||||
      idx++;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  str = gst_value_serialize (&list);
 | 
			
		||||
  g_print ("%c\tpeers: %s\n", mark, str);
 | 
			
		||||
  g_free (str);
 | 
			
		||||
  g_value_unset (&list);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
info_ready (GObject *o, GAsyncResult *res, gpointer user_data)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -153,9 +179,10 @@ dump_port_info (PinosContext *c, const PinosPortInfo *info, gpointer user_data)
 | 
			
		|||
    g_print ("\tnode-path: \"%s\"\n", info->node_path);
 | 
			
		||||
    g_print ("\tdirection: \"%s\"\n", pinos_direction_as_string (info->direction));
 | 
			
		||||
    g_print ("%c\tname: \"%s\"\n", MARK_CHANGE (0), info->name);
 | 
			
		||||
    print_properties (info->properties, MARK_CHANGE (1));
 | 
			
		||||
    print_formats ("possible formats", info->possible_formats, MARK_CHANGE (2));
 | 
			
		||||
    print_formats ("format", info->format, MARK_CHANGE (3));
 | 
			
		||||
    print_peers (info->peers, MARK_CHANGE (1));
 | 
			
		||||
    print_properties (info->properties, MARK_CHANGE (2));
 | 
			
		||||
    print_formats ("possible formats", info->possible_formats, MARK_CHANGE (3));
 | 
			
		||||
    print_formats ("format", info->format, MARK_CHANGE (4));
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue