Skip to content

Instantly share code, notes, and snippets.

@josebraga
Created January 20, 2022 10:00
Show Gist options
  • Save josebraga/cfb8799883b5ae8bc27c92c3b5849f9a to your computer and use it in GitHub Desktop.
Save josebraga/cfb8799883b5ae8bc27c92c3b5849f9a to your computer and use it in GitHub Desktop.
gstreamer utility to print GstCaps
// Taken from tutorials
static gboolean print_field (GQuark field, const GValue * value, gpointer pfx) {
gchar *str = gst_value_serialize (value);
g_print ("%s %15s: %s\n", (gchar *) pfx, g_quark_to_string (field), str);
g_free (str);
return TRUE;
}
static void print_caps (const GstCaps * caps, const gchar * pfx) {
guint i;
g_return_if_fail (caps != NULL);
if (gst_caps_is_any (caps)) {
g_print ("%sANY\n", pfx);
return;
}
if (gst_caps_is_empty (caps)) {
g_print ("%sEMPTY\n", pfx);
return;
}
for (i = 0; i < gst_caps_get_size (caps); i++) {
GstStructure *structure = gst_caps_get_structure (caps, i);
g_print ("%s%s\n", pfx, gst_structure_get_name (structure));
gst_structure_foreach (structure, print_field, (gpointer) pfx);
}
}
if (!gst_caps_is_equal (caps, full_caps)) {
print_caps (caps, " --> ");
print_caps (full_caps, " --> ");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment