mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -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
|
|
@ -104,7 +104,102 @@ pinos_context_get_daemon_info (PinosContext *context,
|
|||
}
|
||||
|
||||
static void
|
||||
client_fill_info (PinosSourceInfo *info, GDBusProxy *proxy)
|
||||
client_fill_info (PinosClientInfo *info, GDBusProxy *proxy)
|
||||
{
|
||||
GVariant *variant;
|
||||
|
||||
info->id = proxy;
|
||||
|
||||
if ((variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "Name"))) {
|
||||
info->name = g_variant_get_string (variant, NULL);
|
||||
g_variant_unref (variant);
|
||||
} else {
|
||||
info->name = "Unknown";
|
||||
}
|
||||
|
||||
info->properties = pinos_properties_from_variant (
|
||||
g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "Properties"));
|
||||
}
|
||||
|
||||
static void
|
||||
client_clear_info (PinosClientInfo *info)
|
||||
{
|
||||
if (info->properties)
|
||||
pinos_properties_free (info->properties);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* pinos_context_list_client_info:
|
||||
* @context: a connected #PinosContext
|
||||
* @flags: extra #PinosClientInfoFlags
|
||||
* @cb: a #PinosClientInfoCallback
|
||||
* @cancelable: a #GCancellable
|
||||
* @user_data: user data passed to @cb
|
||||
*
|
||||
* Call @cb for each client. @cb will be called with NULL when there
|
||||
* are no more clients to list.
|
||||
*/
|
||||
void
|
||||
pinos_context_list_client_info (PinosContext *context,
|
||||
PinosClientInfoFlags flags,
|
||||
PinosClientInfoCallback cb,
|
||||
GCancellable *cancellable,
|
||||
gpointer user_data)
|
||||
{
|
||||
GList *walk;
|
||||
PinosContextPrivate *priv = context->priv;
|
||||
|
||||
g_return_if_fail (PINOS_IS_CONTEXT (context));
|
||||
g_return_if_fail (cb != NULL);
|
||||
|
||||
for (walk = priv->clients; walk; walk = g_list_next (walk)) {
|
||||
GDBusProxy *proxy = walk->data;
|
||||
PinosClientInfo info;
|
||||
|
||||
client_fill_info (&info, proxy);
|
||||
cb (context, &info, user_data);
|
||||
client_clear_info (&info);
|
||||
}
|
||||
cb (context, NULL, user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* pinos_context_get_client_info_by_id:
|
||||
* @context: a connected #PinosContext
|
||||
* @id: a client id
|
||||
* @flags: extra #PinosClientInfoFlags
|
||||
* @cb: a #PinosClientInfoCallback
|
||||
* @cancelable: a #GCancellable
|
||||
* @user_data: user data passed to @cb
|
||||
*
|
||||
* Call @cb for the client with @id. Then @cb will be called with NULL.
|
||||
*/
|
||||
void
|
||||
pinos_context_get_client_info_by_id (PinosContext *context,
|
||||
gpointer id,
|
||||
PinosClientInfoFlags flags,
|
||||
PinosClientInfoCallback cb,
|
||||
GCancellable *cancellable,
|
||||
gpointer user_data)
|
||||
{
|
||||
PinosClientInfo info;
|
||||
GDBusProxy *proxy;
|
||||
|
||||
g_return_if_fail (PINOS_IS_CONTEXT (context));
|
||||
g_return_if_fail (id != NULL);
|
||||
g_return_if_fail (cb != NULL);
|
||||
|
||||
proxy = G_DBUS_PROXY (id);
|
||||
|
||||
client_fill_info (&info, proxy);
|
||||
cb (context, &info, user_data);
|
||||
client_clear_info (&info);
|
||||
cb (context, NULL, user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
source_fill_info (PinosSourceInfo *info, GDBusProxy *proxy)
|
||||
{
|
||||
GVariant *variant;
|
||||
|
||||
|
|
@ -140,7 +235,7 @@ client_fill_info (PinosSourceInfo *info, GDBusProxy *proxy)
|
|||
}
|
||||
|
||||
static void
|
||||
client_clear_info (PinosSourceInfo *info)
|
||||
source_clear_info (PinosSourceInfo *info)
|
||||
{
|
||||
if (info->properties)
|
||||
pinos_properties_free (info->properties);
|
||||
|
|
@ -176,15 +271,15 @@ pinos_context_list_source_info (PinosContext *context,
|
|||
GDBusProxy *proxy = walk->data;
|
||||
PinosSourceInfo info;
|
||||
|
||||
client_fill_info (&info, proxy);
|
||||
source_fill_info (&info, proxy);
|
||||
cb (context, &info, user_data);
|
||||
client_clear_info (&info);
|
||||
source_clear_info (&info);
|
||||
}
|
||||
cb (context, NULL, user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* pinos_context_get_source_info:
|
||||
* pinos_context_get_source_info_by_id:
|
||||
* @context: a connected #PinosContext
|
||||
* @id: a source id
|
||||
* @flags: extra #PinosSourceInfoFlags
|
||||
|
|
@ -192,8 +287,7 @@ pinos_context_list_source_info (PinosContext *context,
|
|||
* @cancelable: a #GCancellable
|
||||
* @user_data: user data passed to @cb
|
||||
*
|
||||
* Call @cb for each source. @cb will be called with NULL when there
|
||||
* are no more sources to list.
|
||||
* Call @cb for the source with @id. Then @cb will be called with NULL.
|
||||
*/
|
||||
void
|
||||
pinos_context_get_source_info_by_id (PinosContext *context,
|
||||
|
|
@ -212,8 +306,119 @@ pinos_context_get_source_info_by_id (PinosContext *context,
|
|||
|
||||
proxy = G_DBUS_PROXY (id);
|
||||
|
||||
client_fill_info (&info, proxy);
|
||||
source_fill_info (&info, proxy);
|
||||
cb (context, &info, user_data);
|
||||
client_clear_info (&info);
|
||||
source_clear_info (&info);
|
||||
cb (context, NULL, user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
source_output_fill_info (PinosSourceOutputInfo *info, GDBusProxy *proxy)
|
||||
{
|
||||
GVariant *variant;
|
||||
|
||||
info->id = proxy;
|
||||
|
||||
if ((variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "Client"))) {
|
||||
info->client_path = g_variant_get_string (variant, NULL);
|
||||
g_variant_unref (variant);
|
||||
} else {
|
||||
info->client_path = "Unknown";
|
||||
}
|
||||
if ((variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "Source"))) {
|
||||
info->source_path = g_variant_get_string (variant, NULL);
|
||||
g_variant_unref (variant);
|
||||
} else {
|
||||
info->source_path = "Unknown";
|
||||
}
|
||||
if ((variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "PossibleFormats"))) {
|
||||
gsize len;
|
||||
gchar *formats = g_variant_dup_string (variant, &len);
|
||||
info->possible_formats = g_bytes_new_take (formats, len + 1);
|
||||
g_variant_unref (variant);
|
||||
} else {
|
||||
info->possible_formats = NULL;
|
||||
}
|
||||
info->properties = pinos_properties_from_variant (
|
||||
g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "Properties"));
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
source_output_clear_info (PinosSourceOutputInfo *info)
|
||||
{
|
||||
if (info->possible_formats)
|
||||
g_bytes_unref (info->possible_formats);
|
||||
if (info->properties)
|
||||
pinos_properties_free (info->properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* pinos_context_list_source_output_info:
|
||||
* @context: a connected #PinosContext
|
||||
* @flags: extra #PinosSourceOutputInfoFlags
|
||||
* @cb: a #PinosSourceOutputInfoCallback
|
||||
* @cancelable: a #GCancellable
|
||||
* @user_data: user data passed to @cb
|
||||
*
|
||||
* Call @cb for each source-output. @cb will be called with NULL when there
|
||||
* are no more outputs to list.
|
||||
*/
|
||||
void
|
||||
pinos_context_list_source_output_info (PinosContext *context,
|
||||
PinosSourceOutputInfoFlags flags,
|
||||
PinosSourceOutputInfoCallback cb,
|
||||
GCancellable *cancellable,
|
||||
gpointer user_data)
|
||||
{
|
||||
GList *walk;
|
||||
PinosContextPrivate *priv = context->priv;
|
||||
|
||||
g_return_if_fail (PINOS_IS_CONTEXT (context));
|
||||
g_return_if_fail (cb != NULL);
|
||||
|
||||
for (walk = priv->source_outputs; walk; walk = g_list_next (walk)) {
|
||||
GDBusProxy *proxy = walk->data;
|
||||
PinosSourceOutputInfo info;
|
||||
|
||||
source_output_fill_info (&info, proxy);
|
||||
cb (context, &info, user_data);
|
||||
source_output_clear_info (&info);
|
||||
}
|
||||
cb (context, NULL, user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* pinos_context_get_source_output_info_by_id:
|
||||
* @context: a connected #PinosContext
|
||||
* @id: a source output id
|
||||
* @flags: extra #PinosSourceOutputInfoFlags
|
||||
* @cb: a #PinosSourceOutputInfoCallback
|
||||
* @cancelable: a #GCancellable
|
||||
* @user_data: user data passed to @cb
|
||||
*
|
||||
* Call @cb for the source output with @id. Then @cb will be called with NULL.
|
||||
*/
|
||||
void
|
||||
pinos_context_get_source_output_info_by_id (PinosContext *context,
|
||||
gpointer id,
|
||||
PinosSourceOutputInfoFlags flags,
|
||||
PinosSourceOutputInfoCallback cb,
|
||||
GCancellable *cancellable,
|
||||
gpointer user_data)
|
||||
{
|
||||
PinosSourceOutputInfo info;
|
||||
GDBusProxy *proxy;
|
||||
|
||||
g_return_if_fail (PINOS_IS_CONTEXT (context));
|
||||
g_return_if_fail (id != NULL);
|
||||
g_return_if_fail (cb != NULL);
|
||||
|
||||
proxy = G_DBUS_PROXY (id);
|
||||
|
||||
source_output_fill_info (&info, proxy);
|
||||
cb (context, &info, user_data);
|
||||
source_output_clear_info (&info);
|
||||
cb (context, NULL, user_data);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue