From a8a32d131740f8e5de0828d19143c6b586866562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 22 Jul 2013 16:01:13 +0200 Subject: [PATCH] realmedia: Add support for group-id in the stream-start event --- gst/realmedia/rademux.c | 23 ++++++++++++++++++++++- gst/realmedia/rademux.h | 3 +++ gst/realmedia/rmdemux.c | 26 +++++++++++++++++++++++++- gst/realmedia/rmdemux.h | 3 +++ 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/gst/realmedia/rademux.c b/gst/realmedia/rademux.c index c6ff3bcdce..4c2ddc46a9 100644 --- a/gst/realmedia/rademux.c +++ b/gst/realmedia/rademux.c @@ -153,6 +153,9 @@ gst_real_audio_demux_reset (GstRealAudioDemux * demux) demux->offset = 0; + demux->have_group_id = FALSE; + demux->group_id = G_MAXUINT; + gst_adapter_clear (demux->adapter); } @@ -320,6 +323,7 @@ gst_real_audio_demux_parse_header (GstRealAudioDemux * demux) const guint8 *data; gchar *codec_name = NULL; GstCaps *caps = NULL; + GstEvent *event; gchar *stream_id; guint avail; @@ -449,7 +453,24 @@ gst_real_audio_demux_parse_header (GstRealAudioDemux * demux) stream_id = gst_pad_create_stream_id (demux->srcpad, GST_ELEMENT_CAST (demux), NULL); - gst_pad_push_event (demux->srcpad, 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 (demux->srcpad, event); g_free (stream_id); gst_pad_set_caps (demux->srcpad, caps); diff --git a/gst/realmedia/rademux.h b/gst/realmedia/rademux.h index 3e4b07ec2d..8392d15431 100644 --- a/gst/realmedia/rademux.h +++ b/gst/realmedia/rademux.h @@ -51,6 +51,9 @@ struct _GstRealAudioDemux { GstPad *sinkpad; GstPad *srcpad; + + gboolean have_group_id; + guint group_id; GstAdapter *adapter; GstRealAudioDemuxState state; diff --git a/gst/realmedia/rmdemux.c b/gst/realmedia/rmdemux.c index 539d8d326b..e3729205c0 100644 --- a/gst/realmedia/rmdemux.c +++ b/gst/realmedia/rmdemux.c @@ -262,6 +262,8 @@ gst_rmdemux_init (GstRMDemux * rmdemux) rmdemux->first_ts = GST_CLOCK_TIME_NONE; rmdemux->base_ts = GST_CLOCK_TIME_NONE; rmdemux->need_newsegment = TRUE; + rmdemux->have_group_id = FALSE; + rmdemux->group_id = G_MAXUINT; gst_rm_utils_run_tests (); } @@ -693,6 +695,9 @@ gst_rmdemux_reset (GstRMDemux * rmdemux) rmdemux->first_ts = GST_CLOCK_TIME_NONE; rmdemux->base_ts = GST_CLOCK_TIME_NONE; rmdemux->need_newsegment = TRUE; + + rmdemux->have_group_id = FALSE; + rmdemux->group_id = G_MAXUINT; } static GstStateChangeReturn @@ -1467,6 +1472,7 @@ gst_rmdemux_add_stream (GstRMDemux * rmdemux, GstRMDemuxStream * stream) stream_caps); if (stream->pad && stream_caps) { + GstEvent *event; GST_LOG_OBJECT (rmdemux, "%d bytes of extra data for stream %s", stream->extra_data_size, GST_PAD_NAME (stream->pad)); @@ -1498,7 +1504,25 @@ gst_rmdemux_add_stream (GstRMDemux * rmdemux, GstRMDemuxStream * stream) stream_id = gst_pad_create_stream_id_printf (stream->pad, GST_ELEMENT_CAST (rmdemux), "%03u", stream->id); - gst_pad_push_event (stream->pad, gst_event_new_stream_start (stream_id)); + + event = + gst_pad_get_sticky_event (rmdemux->sinkpad, GST_EVENT_STREAM_START, 0); + if (event) { + if (gst_event_parse_group_id (event, &rmdemux->group_id)) + rmdemux->have_group_id = TRUE; + else + rmdemux->have_group_id = FALSE; + gst_event_unref (event); + } else if (!rmdemux->have_group_id) { + rmdemux->have_group_id = TRUE; + rmdemux->group_id = gst_util_group_id_next (); + } + + event = gst_event_new_stream_start (stream_id); + if (rmdemux->have_group_id) + gst_event_set_group_id (event, rmdemux->group_id); + + gst_pad_push_event (stream->pad, event); g_free (stream_id); gst_pad_set_caps (stream->pad, stream_caps); diff --git a/gst/realmedia/rmdemux.h b/gst/realmedia/rmdemux.h index 739434c0ae..25e40bb5b3 100644 --- a/gst/realmedia/rmdemux.h +++ b/gst/realmedia/rmdemux.h @@ -82,6 +82,9 @@ struct _GstRMDemux { /* pads */ GstPad *sinkpad; + gboolean have_group_id; + guint group_id; + GSList *streams; guint n_video_streams; guint n_audio_streams;