validateflow: Add a logged-event-fields configuration

This commit is contained in:
Thibault Saunier 2020-02-04 16:59:39 -03:00 committed by Thibault Saunier
parent 27fc0d45a2
commit 39d6c7760e
4 changed files with 43 additions and 15 deletions

View file

@ -86,6 +86,7 @@ In order to use the plugin a validate configuration file must be provided, conta
* `record-buffers`: Default: false. Whether buffers will be logged. By default only events are logged.
* `buffers-checksum`: Default: false. Whether a checkum of the buffer data is logged. Implies `record-buffers`.
* `ignored-event-fields`: Default: `"stream-start={ stream-id }"` (as they are often non reproducible). Key with a serialized GstValueList(str) of fields to not record.
* `logged-event-fields`: Default: `NULL` Key with a serialized GstValueList(str) of fields to record, eg. `logged-event-fields="stream-start={flags}, caps={width, height, framerate}"`. Overrides `ignored-event-fields` for specified event types.
* `ignored-event-types`: Default: `{ }`. List of event type names to not record
* `logged-event-types`: Default: `NULL`. List of event type names to not record, if noone provided, all events are logged, except the ones defined in the `ignored-event-types`.
* `expectations-dir`: Path to the directory where the expectations will be written if they don't exist, relative to the current working directory. By default the current working directory is used, but this setting is usually set automatically as part of the `%(validateflow)s` expansion to a correct path like `~/gst-validate/gst-integration-testsuites/flow-expectations/<test name>`.

View file

@ -118,8 +118,7 @@ gpointer_free (gpointer pointer_location)
}
gchar *
validate_flow_format_caps (const GstCaps * caps,
const gchar * const *keys_to_print)
validate_flow_format_caps (const GstCaps * caps, gchar ** keys_to_print)
{
guint i;
GArray *structures_strv = g_array_new (TRUE, FALSE, sizeof (gchar *));
@ -257,7 +256,9 @@ validate_flow_format_buffer (GstBuffer * buffer, gboolean add_checksum)
gchar *
validate_flow_format_event (GstEvent * event,
const gchar * const *caps_properties, GstStructure * ignored_event_fields,
const gchar * const *caps_properties,
GstStructure * logged_event_fields,
GstStructure * ignored_event_fields,
const gchar * const *ignored_event_types,
const gchar * const *logged_event_types)
{
@ -265,6 +266,7 @@ validate_flow_format_event (GstEvent * event,
gchar *structure_string;
gchar *event_string;
gchar **ignored_fields;
gchar **logged_fields;
event_type = gst_event_type_get_name (GST_EVENT_TYPE (event));
@ -274,6 +276,7 @@ validate_flow_format_event (GstEvent * event,
if (ignored_event_types && g_strv_contains (ignored_event_types, event_type))
return NULL;
logged_fields = gst_validate_utils_get_strv (logged_event_fields, event_type);
if (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT) {
const GstSegment *segment;
gst_event_parse_segment (event, &segment);
@ -281,22 +284,30 @@ validate_flow_format_event (GstEvent * event,
} else if (GST_EVENT_TYPE (event) == GST_EVENT_CAPS) {
GstCaps *caps;
gst_event_parse_caps (event, &caps);
structure_string = validate_flow_format_caps (caps, caps_properties);
structure_string =
validate_flow_format_caps (caps,
logged_fields ? logged_fields : (gchar **) caps_properties);
} else if (!gst_event_get_structure (event)) {
structure_string = g_strdup ("(no structure)");
} else {
GstStructure *printable =
gst_structure_copy (gst_event_get_structure (event));
ignored_fields =
gst_validate_utils_get_strv (ignored_event_fields, event_type);
if (ignored_fields) {
gint i = 0;
gchar *field;
if (logged_fields) {
gst_structure_filter_and_map_in_place (printable,
(GstStructureFilterMapFunc) structure_only_given_keys, logged_fields);
} else {
ignored_fields =
gst_validate_utils_get_strv (ignored_event_fields, event_type);
if (ignored_fields) {
gint i = 0;
gchar *field;
for (field = ignored_fields[i]; field; field = ignored_fields[++i])
gst_structure_remove_field (printable, field);
g_strfreev (ignored_fields);
for (field = ignored_fields[i]; field; field = ignored_fields[++i])
gst_structure_remove_field (printable, field);
g_strfreev (ignored_fields);
}
}
structure_string = gst_structure_to_string (printable);
@ -304,6 +315,7 @@ validate_flow_format_event (GstEvent * event,
}
event_string = g_strdup_printf ("%s: %s", event_type, structure_string);
g_strfreev (logged_fields);
g_free (structure_string);
return event_string;
}

View file

@ -29,10 +29,10 @@ void format_time(gchar* dest_str, guint64 time);
gchar* validate_flow_format_segment (const GstSegment *segment);
gchar* validate_flow_format_caps (const GstCaps* caps, const gchar * const *keys_to_print);
gchar* validate_flow_format_caps (const GstCaps* caps, gchar **keys_to_print);
gchar* validate_flow_format_buffer (GstBuffer *buffer, gboolean add_checksum);
gchar* validate_flow_format_event(GstEvent* event, const gchar* const* caps_properties, GstStructure* ignored_event_fields, const gchar* const* ignored_event_types, const gchar* const* logged_event_types);
gchar* validate_flow_format_event(GstEvent* event, const gchar* const* caps_properties, GstStructure* logged_event_fields, GstStructure* ignored_event_fields, const gchar* const* ignored_event_types, const gchar* const* logged_event_types);
#endif // __GST_VALIDATE_FLOW_FORMATTING_H__

View file

@ -60,6 +60,7 @@ struct _ValidateFlowOverride
gboolean error_writing_file;
gchar **caps_properties;
GstStructure *ignored_event_fields;
GstStructure *logged_event_fields;
gchar **logged_event_types;
gchar **ignored_event_types;
@ -163,6 +164,7 @@ validate_flow_override_event_handler (GstValidateOverride * override,
event_string = validate_flow_format_event (event,
(const gchar * const *) flow->caps_properties,
flow->logged_event_fields,
flow->ignored_event_fields,
(const gchar * const *) flow->ignored_event_types,
(const gchar * const *) flow->logged_event_types);
@ -216,7 +218,7 @@ validate_flow_override_new (GstStructure * config)
{
ValidateFlowOverride *flow;
GstValidateOverride *override;
gchar *ignored_event_fields;
gchar *ignored_event_fields, *logged_event_fields;
flow = g_object_new (VALIDATE_TYPE_FLOW_OVERRIDE, NULL);
override = GST_VALIDATE_OVERRIDE (flow);
@ -269,6 +271,19 @@ validate_flow_override_new (GstStructure * config)
gst_structure_set (flow->ignored_event_fields, "stream-start",
G_TYPE_STRING, "{stream-id}", NULL);
logged_event_fields =
(gchar *) gst_structure_get_string (config, "logged-event-fields");
if (logged_event_fields) {
logged_event_fields = g_strdup_printf ("logged,%s", logged_event_fields);
flow->logged_event_fields =
gst_structure_new_from_string (logged_event_fields);
if (!flow->logged_event_fields)
g_error ("Could not parse 'logged-event-fields' %s in %s",
logged_event_fields, gst_structure_to_string (config));
g_free (logged_event_fields);
} else {
flow->logged_event_fields = NULL;
}
/* expectations-dir: Path to the directory where the expectations will be