diff --git a/docs/plugins/validateflow.md b/docs/plugins/validateflow.md index 0b6aad3bdc..c35f9b2106 100644 --- a/docs/plugins/validateflow.md +++ b/docs/plugins/validateflow.md @@ -84,7 +84,7 @@ In order to use the plugin a validate configuration file must be provided, conta * `pad`: Required. Name of the pad that will be monitored. * `record-buffers`: Default: false. Whether buffers will be logged. By default only events are logged. - * `record-stream-id`: Default: false. `stream-id`'s are often non reproducible (this is the case for basesrc, for instance). For this reason, they are omitted by default when recording a `stream-start` event. This setting allows to override that behavior. + * `ignored-event-fields`: Default: `stream-start=stream-id` (as they are often non reproducible). Key with a list of coma (`,`) separated list of fields to not record. * `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/`. * `actual-results-dir`: Path to the directory where the events will be recorded. The expectation file will be compared to this. By default the current working directory is used, but this setting is usually set automatically as part of the `%(validateflow)s` expansion to the test log directory, i.e. `~/gst-validate/logs/validate/launch_pipeline/`. diff --git a/validate/plugins/flow/formatting.c b/validate/plugins/flow/formatting.c index 0e65f9d6f2..a7795233d3 100644 --- a/validate/plugins/flow/formatting.c +++ b/validate/plugins/flow/formatting.c @@ -239,12 +239,13 @@ validate_flow_format_buffer (GstBuffer * buffer) } gchar * -validate_flow_format_event (GstEvent * event, gboolean allow_stream_id, - const gchar * const *caps_properties) +validate_flow_format_event (GstEvent * event, + const gchar * const *caps_properties, GstStructure * ignored_event_fields) { const gchar *event_type; gchar *structure_string; gchar *event_string; + const gchar *ignored_fields; event_type = gst_event_type_get_name (GST_EVENT_TYPE (event)); @@ -262,8 +263,16 @@ validate_flow_format_event (GstEvent * event, gboolean allow_stream_id, GstStructure *printable = gst_structure_copy (gst_event_get_structure (event)); - if (GST_EVENT_TYPE (event) == GST_EVENT_STREAM_START && !allow_stream_id) - gst_structure_remove_fields (printable, "stream-id", NULL); + ignored_fields = + gst_structure_get_string (ignored_event_fields, event_type); + if (ignored_fields) { + gint i = 0; + gchar *field, **fields = g_strsplit (ignored_fields, ",", -1); + + for (field = fields[i]; field; field = fields[++i]) + gst_structure_remove_field (printable, field); + g_strfreev (fields); + } structure_string = gst_structure_to_string (printable); gst_structure_free (printable); diff --git a/validate/plugins/flow/formatting.h b/validate/plugins/flow/formatting.h index ea644c7ba7..2fce70be77 100644 --- a/validate/plugins/flow/formatting.h +++ b/validate/plugins/flow/formatting.h @@ -33,6 +33,6 @@ gchar* validate_flow_format_caps (const GstCaps* caps, const gchar * const *keys gchar* validate_flow_format_buffer (GstBuffer *buffer); -gchar* validate_flow_format_event (GstEvent *event, gboolean allow_stream_id, const gchar * const *caps_properties); +gchar* validate_flow_format_event (GstEvent *event, const gchar * const *caps_properties, GstStructure *ignored_event_fields); #endif // __GST_VALIDATE_FLOW_FORMATTING_H__ diff --git a/validate/plugins/flow/gstvalidateflow.c b/validate/plugins/flow/gstvalidateflow.c index 656462b611..ed7413b806 100644 --- a/validate/plugins/flow/gstvalidateflow.c +++ b/validate/plugins/flow/gstvalidateflow.c @@ -55,7 +55,7 @@ typedef struct _ValidateFlowOverride gchar *actual_results_dir; gboolean error_writing_file; gchar **caps_properties; - gboolean record_stream_id; + GstStructure *ignored_event_fields; gchar *expectations_file_path; gchar *actual_results_file_path; @@ -136,8 +136,9 @@ validate_flow_override_event_handler (GstValidateOverride * override, if (flow->error_writing_file) return; - event_string = validate_flow_format_event (event, flow->record_stream_id, - (const gchar * const *) flow->caps_properties); + event_string = validate_flow_format_event (event, + (const gchar * const *) flow->caps_properties, + flow->ignored_event_fields); validate_flow_override_printf (flow, "event %s\n", event_string); g_free (event_string); } @@ -188,6 +189,7 @@ validate_flow_override_new (GstStructure * config) { ValidateFlowOverride *flow; GstValidateOverride *override; + gchar *ignored_event_fields; flow = g_object_new (VALIDATE_TYPE_FLOW_OVERRIDE, NULL); override = GST_VALIDATE_OVERRIDE (flow); @@ -208,13 +210,26 @@ validate_flow_override_new (GstStructure * config) * only the listed properties will be written to the expectation log. */ flow->caps_properties = parse_caps_properties_setting (flow, config); - /* record-stream-id: stream-id's are often non reproducible (this is the case - * for basesrc, for instance). For this reason, they are omitted by default - * when recording a stream-start event. This setting allows to override that - * behavior. */ - flow->record_stream_id = FALSE; - gst_structure_get_boolean (config, "record-stream-id", - &flow->record_stream_id); + ignored_event_fields = + (gchar *) gst_structure_get_string (config, "ignored-event-fields"); + if (ignored_event_fields) { + ignored_event_fields = g_strdup_printf ("ignored,%s", ignored_event_fields); + flow->ignored_event_fields = + gst_structure_new_from_string (ignored_event_fields); + if (!flow->ignored_event_fields) + g_error ("Could not parse 'ignored-event-fields' %s in %s", + ignored_event_fields, gst_structure_to_string (config)); + g_free (ignored_event_fields); + } else { + flow->ignored_event_fields = + gst_structure_new_from_string ("ignored,stream-start=stream-id"); + } + + if (!gst_structure_has_field (flow->ignored_event_fields, "stream-start")) + gst_structure_set (flow->ignored_event_fields, "stream-start", + G_TYPE_STRING, "stream-id", NULL); + + /* expectations-dir: Path to the directory where the expectations will be * written if they don't exist, relative to the current working directory. @@ -421,6 +436,8 @@ validate_flow_override_finalize (GObject * object) g_free (*str_pointer); g_free (flow->caps_properties); } + if (flow->ignored_event_fields) + gst_structure_free (flow->ignored_event_fields); G_OBJECT_CLASS (validate_flow_override_parent_class)->finalize (object); }