From 8fdd59f9d5f4dc0e5b889fc7d0ce3df77ccea016 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Thu, 15 Aug 2024 17:58:14 -0400 Subject: [PATCH] validate: flow: Allow logging upstream events Part-of: --- subprojects/gst-devtools/docs/gst-validate-flow.md | 5 ++++- .../validate/gst/validate/flow/formatting.c | 13 ++++++++++++- .../validate/gst/validate/flow/formatting.h | 2 +- .../validate/gst/validate/flow/gstvalidateflow.c | 7 ++++++- .../gst/validate/gst-validate-pad-monitor.c | 3 +++ 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/subprojects/gst-devtools/docs/gst-validate-flow.md b/subprojects/gst-devtools/docs/gst-validate-flow.md index 6e67f0ecc7..d2afb76def 100644 --- a/subprojects/gst-devtools/docs/gst-validate-flow.md +++ b/subprojects/gst-devtools/docs/gst-validate-flow.md @@ -150,9 +150,12 @@ several overrides and listening to different pads with different settings. caps={width, height, framerate}, buffer={pts}"`. 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, +* `logged-event-types`: Default: `NULL`. List of (downstream) event type names to not record, if noone provided, all events are logged, except the ones defined in the `ignored-event-types`. +* `logged-upstream-event-types`: Default: `NULL`. List of upstream event type names to record, + for backward compatibility reasons, upstream events are not logged by default, + and you must specify the ones you want to be logged. * `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 diff --git a/subprojects/gst-devtools/validate/gst/validate/flow/formatting.c b/subprojects/gst-devtools/validate/gst/validate/flow/formatting.c index e1f5d3a97b..8149ac291e 100644 --- a/subprojects/gst-devtools/validate/gst/validate/flow/formatting.c +++ b/subprojects/gst-devtools/validate/gst/validate/flow/formatting.c @@ -450,7 +450,8 @@ validate_flow_format_event (GstEvent * event, GstStructure * logged_fields_struct, GstStructure * ignored_fields_struct, const gchar * const *ignored_event_types, - const gchar * const *logged_event_types) + const gchar * const *logged_event_types, + const gchar * const *logged_upstream_event_types) { const gchar *event_type; gchar *structure_string; @@ -460,6 +461,16 @@ validate_flow_format_event (GstEvent * event, event_type = gst_event_type_get_name (GST_EVENT_TYPE (event)); + if (GST_EVENT_IS_UPSTREAM (event) && !GST_EVENT_IS_DOWNSTREAM (event)) { + /* For backward compatibility reason, only logged requested upstream event + * types */ + if (!logged_upstream_event_types) + return NULL; + + if (!g_strv_contains (logged_upstream_event_types, event_type)) + return NULL; + } + if (logged_event_types && !g_strv_contains (logged_event_types, event_type)) return NULL; diff --git a/subprojects/gst-devtools/validate/gst/validate/flow/formatting.h b/subprojects/gst-devtools/validate/gst/validate/flow/formatting.h index 8fb1183b03..b3c4437822 100644 --- a/subprojects/gst-devtools/validate/gst/validate/flow/formatting.h +++ b/subprojects/gst-devtools/validate/gst/validate/flow/formatting.h @@ -37,6 +37,6 @@ gchar* validate_flow_format_caps (const GstCaps* caps, gchar **wanted_fields, gc gchar* validate_flow_format_buffer(GstBuffer* buffer, gboolean add_checksum, GstStructure* logged_fields_struct, GstStructure* ignored_fields_struct); -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); +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, const gchar* const* logged_upstream_event_types); #endif // __GST_VALIDATE_FLOW_FORMATTING_H__ diff --git a/subprojects/gst-devtools/validate/gst/validate/flow/gstvalidateflow.c b/subprojects/gst-devtools/validate/gst/validate/flow/gstvalidateflow.c index 873480a77b..5188d11e9d 100644 --- a/subprojects/gst-devtools/validate/gst/validate/flow/gstvalidateflow.c +++ b/subprojects/gst-devtools/validate/gst/validate/flow/gstvalidateflow.c @@ -87,6 +87,7 @@ struct _ValidateFlowOverride GstStructure *logged_fields; gchar **logged_event_types; + gchar **logged_upstream_event_types; gchar **ignored_event_types; gchar *expectations_file_path; @@ -192,7 +193,8 @@ validate_flow_override_event_handler (GstValidateOverride * override, flow->logged_fields, flow->ignored_fields, (const gchar * const *) flow->ignored_event_types, - (const gchar * const *) flow->logged_event_types); + (const gchar * const *) flow->logged_event_types, + (const gchar * const *) flow->logged_upstream_event_types); if (event_string) { validate_flow_override_printf (flow, "event %s\n", event_string); @@ -294,6 +296,8 @@ validate_flow_override_new (GstStructure * config) flow->logged_event_types = gst_validate_utils_get_strv (config, "logged-event-types"); + flow->logged_upstream_event_types = + gst_validate_utils_get_strv (config, "logged-upstream-event-types"); flow->ignored_event_types = gst_validate_utils_get_strv (config, "ignored-event-types"); @@ -619,6 +623,7 @@ validate_flow_override_finalize (GObject * object) fclose (flow->output_file); g_strfreev (flow->caps_properties); g_strfreev (flow->logged_event_types); + g_strfreev (flow->logged_upstream_event_types); g_strfreev (flow->ignored_event_types); if (flow->ignored_fields) gst_structure_free (flow->ignored_fields); diff --git a/subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c b/subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c index 0494c36b65..f35cc52514 100644 --- a/subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c +++ b/subprojects/gst-devtools/validate/gst/validate/gst-validate-pad-monitor.c @@ -2428,10 +2428,13 @@ gst_validate_pad_monitor_src_event_func (GstPad * pad, GstObject * parent, GstValidatePadMonitor *pad_monitor = _GET_PAD_MONITOR (pad); gboolean ret; + gst_validate_pad_monitor_event_overrides (pad_monitor, event); + GST_VALIDATE_MONITOR_LOCK (pad_monitor); ret = gst_validate_pad_monitor_src_event_check (pad_monitor, parent, event, pad_monitor->event_func); GST_VALIDATE_MONITOR_UNLOCK (pad_monitor); + return ret; }