debugutils: nicer printing of caps features
authorTim-Philipp Müller <tim@centricular.com>
Wed, 1 Apr 2015 11:13:17 +0000 (12:13 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Wed, 1 Apr 2015 11:15:30 +0000 (12:15 +0100)
Only print interesting caps features, don't
append (memory:SystemMemory) to all caps,
which makes them much more unwieldy and
harder to read. Also use internal function
to get caps features so that our printing
has no side effects on the caps.

https://bugzilla.gnome.org/show_bug.cgi?id=746809

gst/gst_private.h
gst/gstcaps.c
gst/gstdebugutils.c

index d0aefb4..4f4194a 100644 (file)
@@ -186,6 +186,10 @@ _priv_gst_do_linear_regression (GstClockTime *times, guint n,
     GstClockTime * m_num, GstClockTime * m_denom, GstClockTime * b,
     GstClockTime * xbase, gdouble * r_squared);
 
+/* For use in gstdebugutils */
+G_GNUC_INTERNAL
+GstCapsFeatures * __gst_caps_get_features_unchecked (const GstCaps * caps, guint idx);
+
 #ifndef GST_DISABLE_REGISTRY
 /* Secret variable to initialise gst without registry cache */
 GST_EXPORT gboolean _gst_disable_registry_cache;
index 147b32c..6acc564 100644 (file)
@@ -145,6 +145,12 @@ _priv_gst_caps_initialize (void)
       G_TYPE_STRING, gst_caps_transform_to_string);
 }
 
+GstCapsFeatures *
+__gst_caps_get_features_unchecked (const GstCaps * caps, guint idx)
+{
+  return gst_caps_get_features_unchecked (caps, idx);
+}
+
 static GstCaps *
 _gst_caps_copy (const GstCaps * caps)
 {
index 06d3469..b76c948 100644 (file)
@@ -357,17 +357,19 @@ debug_dump_describe_caps (GstCaps * caps, GstDebugGraphDetails details)
 
       str = g_string_sized_new (slen);
       for (i = 0; i < gst_caps_get_size (caps); i++) {
+        GstCapsFeatures *features = __gst_caps_get_features_unchecked (caps, i);
         GstStructure *structure = gst_caps_get_structure (caps, i);
 
-        const GstCapsFeatures *features = gst_caps_get_features (caps, i);
-        gchar *features_name = gst_caps_features_to_string (features);
-
         g_string_append (str, gst_structure_get_name (structure));
-        g_string_append (str, "(");
-        g_string_append (str, features_name);
-        g_string_append (str, ")\\l");
 
-        g_free (features_name);
+        if (features && (gst_caps_features_is_any (features)
+                || !gst_caps_features_is_equal (features,
+                    GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY))) {
+          g_string_append_c (str, '(');
+          priv_gst_caps_features_append_to_gstring (features, str);
+          g_string_append_c (str, ')');
+        }
+        g_string_append (str, "\\l");
 
         gst_structure_foreach (structure, string_append_field, (gpointer) str);
       }