pad: Only remove TAG events on STREAM_START if the stream-id actually changes

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4097

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8135>
This commit is contained in:
Sebastian Dröge 2024-12-12 10:50:30 +02:00 committed by GStreamer Marge Bot
parent f28a7b6ef3
commit 88a36b53c5

View file

@ -5374,6 +5374,7 @@ store_sticky_event (GstPad * pad, GstEvent * event)
gboolean res = FALSE; gboolean res = FALSE;
const gchar *name = NULL; const gchar *name = NULL;
gboolean insert = TRUE; gboolean insert = TRUE;
gboolean changed_stream_id = FALSE;
type = GST_EVENT_TYPE (event); type = GST_EVENT_TYPE (event);
guint sticky_order = _to_sticky_order (type); guint sticky_order = _to_sticky_order (type);
@ -5390,10 +5391,9 @@ store_sticky_event (GstPad * pad, GstEvent * event)
/* Unset the EOS flag when received STREAM_START event, so pad can /* Unset the EOS flag when received STREAM_START event, so pad can
* store sticky event and then push it later */ * store sticky event and then push it later */
if (type == GST_EVENT_STREAM_START) { if (type == GST_EVENT_STREAM_START) {
GST_LOG_OBJECT (pad, "Removing pending EOS, StreamGroupDone, TAG events"); GST_LOG_OBJECT (pad, "Removing pending EOS, StreamGroupDone events");
remove_event_by_type (pad, GST_EVENT_EOS); remove_event_by_type (pad, GST_EVENT_EOS);
remove_event_by_type (pad, GST_EVENT_STREAM_GROUP_DONE); remove_event_by_type (pad, GST_EVENT_STREAM_GROUP_DONE);
remove_event_by_type (pad, GST_EVENT_TAG);
GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_EOS); GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_EOS);
} }
@ -5417,6 +5417,15 @@ store_sticky_event (GstPad * pad, GstEvent * event)
if (name && !gst_event_has_name (ev->event, name)) if (name && !gst_event_has_name (ev->event, name))
continue; continue;
if (type == GST_EVENT_STREAM_START && event != ev->event) {
const gchar *old_stream_id, *new_stream_id;
gst_event_parse_stream_start (ev->event, &old_stream_id);
gst_event_parse_stream_start (event, &new_stream_id);
changed_stream_id = !g_str_equal (old_stream_id, new_stream_id);
}
/* overwrite */ /* overwrite */
if ((res = gst_event_replace (&ev->event, event))) if ((res = gst_event_replace (&ev->event, event)))
ev->received = FALSE; ev->received = FALSE;
@ -5446,6 +5455,12 @@ store_sticky_event (GstPad * pad, GstEvent * event)
ev.received = FALSE; ev.received = FALSE;
g_array_insert_val (events, i, ev); g_array_insert_val (events, i, ev);
res = TRUE; res = TRUE;
changed_stream_id = type == GST_EVENT_STREAM_START;
}
if (changed_stream_id) {
GST_LOG_OBJECT (pad, "Removing pending TAG events");
remove_event_by_type (pad, GST_EVENT_TAG);
} }
if (res) { if (res) {