validate:flow: Log caps features

No reason not to use directy the GstCaps serialization function here
This commits avoids needing regenerated all expectations to remove
the `;` which is not generated anymore as it is simple and makes
merging simpler.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-devtools/-/merge_requests/248>
This commit is contained in:
Thibault Saunier 2021-05-23 22:43:04 -04:00
parent ac88851587
commit b3065bb9ec

View file

@ -164,11 +164,10 @@ structure_set_fields (GQuark field_id, GValue * value, StructureValues * data)
return TRUE; return TRUE;
} }
static gchar * static GstStructure *
validate_flow_structure_to_string (const GstStructure * structure, validate_flow_structure_cleanup (const GstStructure * structure,
gchar ** wanted_fields, gchar ** ignored_fields) gchar ** wanted_fields, gchar ** ignored_fields)
{ {
gchar *res;
GstStructure *nstructure; GstStructure *nstructure;
StructureValues d = { StructureValues d = {
.fields = NULL, .fields = NULL,
@ -188,39 +187,31 @@ validate_flow_structure_to_string (const GstStructure * structure,
} }
g_list_free (d.fields); g_list_free (d.fields);
res = gst_structure_to_string (nstructure);
gst_structure_free (nstructure);
return res; return nstructure;
}
static void
gpointer_free (gpointer pointer_location)
{
g_free (*(void **) pointer_location);
} }
gchar * gchar *
validate_flow_format_caps (const GstCaps * caps, gchar ** wanted_fields) validate_flow_format_caps (const GstCaps * caps, gchar ** wanted_fields)
{ {
guint i; guint i;
GArray *structures_strv = g_array_new (TRUE, FALSE, sizeof (gchar *)); GstCaps *new_caps = gst_caps_new_empty ();
gchar *caps_str; gchar *caps_str;
g_array_set_clear_func (structures_strv, gpointer_free);
/* A single GstCaps can contain several caps structures (although only one is /* A single GstCaps can contain several caps structures (although only one is
* used in most cases). We will print them separated with spaces. */ * used in most cases). We will print them separated with spaces. */
for (i = 0; i < gst_caps_get_size (caps); i++) { for (i = 0; i < gst_caps_get_size (caps); i++) {
gchar *structure_str = GstStructure *structure =
validate_flow_structure_to_string (gst_caps_get_structure (caps, i), validate_flow_structure_cleanup (gst_caps_get_structure (caps, i),
wanted_fields, NULL); wanted_fields, NULL);
g_array_append_val (structures_strv, structure_str); gst_caps_append_structure_full (new_caps, structure,
gst_caps_features_copy (gst_caps_get_features (caps, i)));
} }
caps_str = g_strjoinv (" ", (gchar **) structures_strv->data); caps_str = gst_caps_to_string (new_caps);
g_array_free (structures_strv, TRUE); gst_caps_unref (new_caps);
return caps_str; return caps_str;
} }
@ -423,17 +414,22 @@ validate_flow_format_event (GstEvent * event,
structure_string = structure_string =
validate_flow_format_caps (caps, validate_flow_format_caps (caps,
logged_fields ? logged_fields : (gchar **) caps_properties); logged_fields ? logged_fields : (gchar **) caps_properties);
/* FIXME: Remove spurious `;` and regenerate all the expectation files */
event_string = g_strdup_printf ("%s: %s;", event_type, structure_string);
goto done;
} else if (!gst_event_get_structure (event)) { } else if (!gst_event_get_structure (event)) {
structure_string = g_strdup ("(no structure)"); structure_string = g_strdup ("(no structure)");
} else { } else {
structure_string = GstStructure *structure =
validate_flow_structure_to_string (gst_event_get_structure (event), validate_flow_structure_cleanup (gst_event_get_structure (event),
logged_fields, ignored_fields); logged_fields, ignored_fields);
structure_string = gst_structure_to_string (structure);
gst_structure_free (structure);
} }
event_string = g_strdup_printf ("%s: %s", event_type, structure_string); event_string = g_strdup_printf ("%s: %s", event_type, structure_string);
done:
g_strfreev (logged_fields); g_strfreev (logged_fields);
g_strfreev (ignored_fields); g_strfreev (ignored_fields);
g_free (structure_string); g_free (structure_string);
return event_string; return event_string;