mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
Improve introspection
Add instrospection of client and source-output. Add properties to source-output and to CreateSourceOutput/Input Add helper to fill properties of context. Add client-name to pinossrc and pinossink Improve test-subscribe to show all new introspection details.
This commit is contained in:
parent
85e09e7a5b
commit
13d846ec38
21 changed files with 684 additions and 72 deletions
|
|
@ -23,10 +23,158 @@
|
|||
|
||||
static GMainLoop *loop;
|
||||
|
||||
static void
|
||||
dump_object (GDBusProxy *proxy)
|
||||
static gboolean
|
||||
print_field (GQuark field, const GValue * value, gpointer user_data)
|
||||
{
|
||||
gchar *str = gst_value_serialize (value);
|
||||
|
||||
g_print ("\t\t%15s: %s\n", g_quark_to_string (field), str);
|
||||
g_free (str);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
print_formats (GBytes *formats)
|
||||
{
|
||||
GstCaps *caps = gst_caps_from_string (g_bytes_get_data (formats, NULL));
|
||||
guint i;
|
||||
|
||||
g_print ("\tformats:\n");
|
||||
|
||||
if (gst_caps_is_any (caps)) {
|
||||
g_print ("\t\tANY\n");
|
||||
return;
|
||||
}
|
||||
if (gst_caps_is_empty (caps)) {
|
||||
g_print ("\t\tEMPTY\n");
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < gst_caps_get_size (caps); i++) {
|
||||
GstStructure *structure = gst_caps_get_structure (caps, i);
|
||||
GstCapsFeatures *features = gst_caps_get_features (caps, i);
|
||||
|
||||
if (features && (gst_caps_features_is_any (features) ||
|
||||
!gst_caps_features_is_equal (features,
|
||||
GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY))) {
|
||||
gchar *features_string = gst_caps_features_to_string (features);
|
||||
|
||||
g_print ("\t\t%s(%s)\n", gst_structure_get_name (structure),
|
||||
features_string);
|
||||
g_free (features_string);
|
||||
} else {
|
||||
g_print ("\t\t%s\n", gst_structure_get_name (structure));
|
||||
}
|
||||
gst_structure_foreach (structure, print_field, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_properties (PinosProperties *props)
|
||||
{
|
||||
gpointer state = NULL;
|
||||
const gchar *key;
|
||||
|
||||
g_print ("\tproperties:\n");
|
||||
while ((key = pinos_properties_iterate (props, &state))) {
|
||||
g_print ("\t\t%s = \"%s\"\n", key, pinos_properties_get (props, key));
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
dump_daemon_info (PinosContext *c, const PinosDaemonInfo *info, gpointer userdata)
|
||||
{
|
||||
if (info == NULL)
|
||||
return FALSE;
|
||||
|
||||
g_print ("\tid: %p\n", info->id);
|
||||
g_print ("\tuser-name: \"%s\"\n", info->user_name);
|
||||
g_print ("\thost-name: \"%s\"\n", info->host_name);
|
||||
g_print ("\tversion: \"%s\"\n", info->version);
|
||||
g_print ("\tname: \"%s\"\n", info->name);
|
||||
g_print ("\tcookie: %d\n", info->cookie);
|
||||
print_properties (info->properties);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
dump_client_info (PinosContext *c, const PinosClientInfo *info, gpointer userdata)
|
||||
{
|
||||
if (info == NULL)
|
||||
return FALSE;
|
||||
|
||||
g_print ("\tid: %p\n", info->id);
|
||||
g_print ("\tname: \"%s\"\n", info->name);
|
||||
print_properties (info->properties);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
dump_source_info (PinosContext *c, const PinosSourceInfo *info, gpointer userdata)
|
||||
{
|
||||
if (info == NULL)
|
||||
return FALSE;
|
||||
|
||||
g_print ("\tid: %p\n", info->id);
|
||||
g_print ("\tsource-path: \"%s\"\n", info->source_path);
|
||||
g_print ("\tname: \"%s\"\n", info->name);
|
||||
g_print ("\tstate: %d\n", info->state);
|
||||
print_formats (info->formats);
|
||||
print_properties (info->properties);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
dump_source_output_info (PinosContext *c, const PinosSourceOutputInfo *info, gpointer userdata)
|
||||
{
|
||||
if (info == NULL)
|
||||
return FALSE;
|
||||
|
||||
g_print ("\tid: %p\n", info->id);
|
||||
g_print ("\tclient-path: \"%s\"\n", info->client_path);
|
||||
g_print ("\tsource-path: \"%s\"\n", info->source_path);
|
||||
print_formats (info->possible_formats);
|
||||
print_properties (info->properties);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
dump_object (PinosContext *context, GDBusProxy *proxy, PinosSubscriptionFlags flags)
|
||||
{
|
||||
if (flags & PINOS_SUBSCRIPTION_FLAGS_DAEMON) {
|
||||
pinos_context_get_daemon_info (context,
|
||||
PINOS_DAEMON_INFO_FLAGS_NONE,
|
||||
dump_daemon_info,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
else if (flags & PINOS_SUBSCRIPTION_FLAGS_CLIENT) {
|
||||
pinos_context_get_client_info_by_id (context,
|
||||
proxy,
|
||||
PINOS_CLIENT_INFO_FLAGS_NONE,
|
||||
dump_client_info,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
else if (flags & PINOS_SUBSCRIPTION_FLAGS_SOURCE) {
|
||||
pinos_context_get_source_info_by_id (context,
|
||||
proxy,
|
||||
PINOS_SOURCE_INFO_FLAGS_FORMATS,
|
||||
dump_source_info,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
else if (flags & PINOS_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT) {
|
||||
pinos_context_get_source_output_info_by_id (context,
|
||||
proxy,
|
||||
PINOS_SOURCE_OUTPUT_INFO_FLAGS_NONE,
|
||||
dump_source_output_info,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -38,18 +186,16 @@ subscription_cb (PinosContext *context,
|
|||
{
|
||||
switch (type) {
|
||||
case PINOS_SUBSCRIPTION_EVENT_NEW:
|
||||
g_print ("object added %s\n", g_dbus_proxy_get_object_path (id));
|
||||
dump_object (G_DBUS_PROXY (id));
|
||||
g_print ("added: %s\n", g_dbus_proxy_get_object_path (id));
|
||||
dump_object (context, G_DBUS_PROXY (id), flags);
|
||||
break;
|
||||
|
||||
case PINOS_SUBSCRIPTION_EVENT_CHANGE:
|
||||
g_print ("object changed %s\n", g_dbus_proxy_get_object_path (id));
|
||||
dump_object (G_DBUS_PROXY (id));
|
||||
g_print ("changed: %s\n", g_dbus_proxy_get_object_path (id));
|
||||
break;
|
||||
|
||||
case PINOS_SUBSCRIPTION_EVENT_REMOVE:
|
||||
g_print ("object removed %s\n", g_dbus_proxy_get_object_path (id));
|
||||
dump_object (G_DBUS_PROXY (id));
|
||||
g_print ("removed: %s\n", g_dbus_proxy_get_object_path (id));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue