From 2d92a2ee54552c82bce5a55534ff110442e34a2f Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Thu, 12 Dec 2024 05:51:09 +0100 Subject: [PATCH] urisourcebin: Only rewrite stream-start event once If the custom field is already present, we don't want to rewrite the event again. Otherwise it would cause downstream into believing that a *new* stream-start event has arrived ... which isn't the case. Fixes #4097 Part-of: --- .../gst/playback/gsturisourcebin.c | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/subprojects/gst-plugins-base/gst/playback/gsturisourcebin.c b/subprojects/gst-plugins-base/gst/playback/gsturisourcebin.c index b1978c4068..a4ebe9a07c 100644 --- a/subprojects/gst-plugins-base/gst/playback/gsturisourcebin.c +++ b/subprojects/gst-plugins-base/gst/playback/gsturisourcebin.c @@ -724,6 +724,24 @@ gst_uri_source_bin_get_property (GObject * object, guint prop_id, } } +static GstEvent * +add_stream_start_custom_flag (GstEvent ** event) +{ + GstStructure *s; + /* This is a temporary hack to notify downstream decodebin3 to *not* + * plug in an extra parsebin */ + s = (GstStructure *) gst_event_get_structure (*event); + if (!gst_structure_has_field_typed (s, "urisourcebin-parsed-data", + G_TYPE_BOOLEAN)) { + *event = gst_event_make_writable (*event); + s = (GstStructure *) gst_event_get_structure (*event); + gst_structure_set (s, "urisourcebin-parsed-data", G_TYPE_BOOLEAN, TRUE, + NULL); + } + + return *event; +} + typedef struct { GstPad *target_pad; @@ -738,13 +756,7 @@ copy_sticky_events (GstPad * pad, GstEvent ** event, gpointer user_data) if (data->rewrite_stream_start && GST_EVENT_TYPE (*event) == GST_EVENT_STREAM_START) { - GstStructure *s; - /* This is a temporary hack to notify downstream decodebin3 to *not* - * plug in an extra parsebin */ - *event = gst_event_make_writable (*event); - s = (GstStructure *) gst_event_get_structure (*event); - gst_structure_set (s, "urisourcebin-parsed-data", G_TYPE_BOOLEAN, TRUE, - NULL); + add_stream_start_custom_flag (event); } GST_DEBUG_OBJECT (gpad, "store sticky event from %" GST_PTR_FORMAT " %" GST_PTR_FORMAT, pad, @@ -977,11 +989,7 @@ demux_pad_events (GstPad * pad, GstPadProbeInfo * info, OutputSlotInfo * slot) * plug in an extra parsebin */ if (urisrc->is_adaptive || (slot->linked_info && slot->linked_info->demuxer_is_parsebin)) { - GstStructure *s; - GST_PAD_PROBE_INFO_DATA (info) = ev = gst_event_make_writable (ev); - s = (GstStructure *) gst_event_get_structure (ev); - gst_structure_set (s, "urisourcebin-parsed-data", G_TYPE_BOOLEAN, TRUE, - NULL); + GST_PAD_PROBE_INFO_DATA (info) = add_stream_start_custom_flag (&ev); } } /* PASSTHROUGH */