Skip to content

Instantly share code, notes, and snippets.

@bharadwaj-raju
Created March 8, 2026 10:57
Show Gist options
  • Select an option

  • Save bharadwaj-raju/bd46428cb66a50ffcc6f175f04b4f03b to your computer and use it in GitHub Desktop.

Select an option

Save bharadwaj-raju/bd46428cb66a50ffcc6f175f04b4f03b to your computer and use it in GitHub Desktop.
wp-profile-list.c
#include <glib.h>
#include <stdio.h>
#include <wireplumber-0.5/wp/wp.h>
void print_profiles(WpPipewireObject *device) {
g_autoptr(WpIterator) iter =
wp_pipewire_object_enum_params_sync(device, "EnumProfile", NULL);
g_auto(GValue) val = G_VALUE_INIT;
for (; wp_iterator_next(iter, &val); g_value_unset(&val)) {
WpSpaPod *pod = g_value_get_boxed(&val);
g_autoptr(WpSpaPodParser) parser = wp_spa_pod_parser_new_object(pod, NULL);
gint index = 0;
const gchar *name = NULL;
if (wp_spa_pod_parser_get(parser, "index", "i", &index, "name", "s", &name,
NULL)) {
g_print(" Profile [%s] (index %d)\n", name, index);
}
}
}
void on_objman_installed(WpObjectManager *objman, gpointer user_data) {
GMainLoop *loop = (GMainLoop *)user_data;
WpIterator *objiter = wp_object_manager_new_iterator(objman);
g_auto(GValue) val = G_VALUE_INIT;
for (; wp_iterator_next(objiter, &val); g_value_unset(&val)) {
WpPipewireObject *device = g_value_get_object(&val);
g_autoptr(WpProperties) props = wp_pipewire_object_get_properties(device);
const gchar *name = wp_properties_get(props, "device.name");
const gchar *desc = wp_properties_get(props, "device.description");
if (g_strstr_len(desc, -1, "Camera") != NULL) {
continue;
}
g_print("- %s [%s]\n", desc ? desc : "No description",
name ? name : "Unknown");
print_profiles(device);
}
g_main_loop_quit(loop);
}
int main() {
wp_init(WP_INIT_ALL);
WpCore *core = wp_core_new(NULL, NULL, NULL);
wp_core_connect(core);
WpObjectManager *objman = wp_object_manager_new();
WpObjectInterest *interest =
wp_object_interest_new_type(wp_device_get_type());
wp_object_manager_add_interest_full(objman, interest);
GMainLoop *loop = g_main_loop_new(NULL, FALSE);
g_signal_connect(objman, "installed", G_CALLBACK(on_objman_installed), loop);
wp_object_manager_request_object_features(objman, wp_device_get_type(),
WP_OBJECT_FEATURES_ALL);
wp_core_install_object_manager(core, objman);
g_main_loop_run(loop);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment