validate: flow: Allow logging upstream events

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7382>
This commit is contained in:
Thibault Saunier 2024-08-15 17:58:14 -04:00 committed by GStreamer Marge Bot
parent 0fc5210c48
commit 8fdd59f9d5
5 changed files with 26 additions and 4 deletions

View file

@ -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

View file

@ -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;

View file

@ -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__

View file

@ -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);

View file

@ -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;
}