From 4ec7baa61aaf30cc8ec813eace0c84d820c1d427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 23 Jul 2013 10:15:58 +0200 Subject: [PATCH] mpegdemux: Add support for group-id in the stream-start event --- gst/mpegdemux/gstmpegdemux.c | 21 ++++++++++++++++++++- gst/mpegdemux/gstmpegdemux.h | 3 +++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/gst/mpegdemux/gstmpegdemux.c b/gst/mpegdemux/gstmpegdemux.c index 4e1a37dfd4..4a4c4e8a30 100644 --- a/gst/mpegdemux/gstmpegdemux.c +++ b/gst/mpegdemux/gstmpegdemux.c @@ -338,6 +338,8 @@ gst_flups_demux_reset (GstFluPSDemux * demux) gst_segment_init (&demux->sink_segment, GST_FORMAT_UNDEFINED); gst_segment_init (&demux->src_segment, GST_FORMAT_TIME); gst_flups_demux_flush (demux); + demux->have_group_id = FALSE; + demux->group_id = G_MAXUINT; } static GstFluPSStream * @@ -349,6 +351,7 @@ gst_flups_demux_create_stream (GstFluPSDemux * demux, gint id, gint stream_type) GstFluPSDemuxClass *klass = GST_FLUPS_DEMUX_GET_CLASS (demux); GstCaps *caps; GstClockTime threshold = SEGMENT_THRESHOLD; + GstEvent *event; gchar *stream_id; name = NULL; @@ -472,7 +475,23 @@ gst_flups_demux_create_stream (GstFluPSDemux * demux, gint id, gint stream_type) stream_id = gst_pad_create_stream_id_printf (stream->pad, GST_ELEMENT_CAST (demux), "%02x", id); - gst_pad_push_event (stream->pad, gst_event_new_stream_start (stream_id)); + + event = gst_pad_get_sticky_event (demux->sinkpad, GST_EVENT_STREAM_START, 0); + if (event) { + if (gst_event_parse_group_id (event, &demux->group_id)) + demux->have_group_id = TRUE; + else + demux->have_group_id = FALSE; + gst_event_unref (event); + } else if (!demux->have_group_id) { + demux->have_group_id = TRUE; + demux->group_id = gst_util_group_id_next (); + } + event = gst_event_new_stream_start (stream_id); + if (demux->have_group_id) + gst_event_set_group_id (event, demux->group_id); + + gst_pad_push_event (stream->pad, event); g_free (stream_id); gst_pad_set_caps (stream->pad, caps); diff --git a/gst/mpegdemux/gstmpegdemux.h b/gst/mpegdemux/gstmpegdemux.h index dee8388aca..acca25427c 100644 --- a/gst/mpegdemux/gstmpegdemux.h +++ b/gst/mpegdemux/gstmpegdemux.h @@ -107,6 +107,9 @@ struct _GstFluPSDemux gboolean random_access; /* If we operate in pull mode */ gboolean flushing; + gboolean have_group_id; + guint group_id; + GstAdapter *adapter; GstAdapter *rev_adapter; guint64 adapter_offset;