tsdemux: Add support for group-id in the stream-start event

This commit is contained in:
Sebastian Dröge 2013-07-23 10:24:22 +02:00
parent 2a1877909f
commit 44e404fe41
2 changed files with 25 additions and 1 deletions

View file

@ -329,6 +329,9 @@ gst_ts_demux_reset (MpegTSBase * base)
gst_event_unref (demux->update_segment); gst_event_unref (demux->update_segment);
demux->update_segment = NULL; demux->update_segment = NULL;
} }
demux->have_group_id = FALSE;
demux->group_id = G_MAXUINT;
} }
static void static void
@ -684,6 +687,7 @@ static GstPad *
create_pad_for_stream (MpegTSBase * base, MpegTSBaseStream * bstream, create_pad_for_stream (MpegTSBase * base, MpegTSBaseStream * bstream,
MpegTSBaseProgram * program) MpegTSBaseProgram * program)
{ {
GstTSDemux *demux = GST_TS_DEMUX (base);
TSDemuxStream *stream = (TSDemuxStream *) bstream; TSDemuxStream *stream = (TSDemuxStream *) bstream;
gchar *name = NULL; gchar *name = NULL;
GstCaps *caps = NULL; GstCaps *caps = NULL;
@ -964,6 +968,7 @@ create_pad_for_stream (MpegTSBase * base, MpegTSBaseStream * bstream,
done: done:
if (template && name && caps) { if (template && name && caps) {
GstEvent *event;
gchar *stream_id; gchar *stream_id;
GST_LOG ("stream:%p creating pad with name %s and caps %" GST_PTR_FORMAT, GST_LOG ("stream:%p creating pad with name %s and caps %" GST_PTR_FORMAT,
@ -974,7 +979,23 @@ done:
stream_id = stream_id =
gst_pad_create_stream_id_printf (pad, GST_ELEMENT_CAST (base), "%08x", gst_pad_create_stream_id_printf (pad, GST_ELEMENT_CAST (base), "%08x",
bstream->pid); bstream->pid);
gst_pad_push_event (pad, gst_event_new_stream_start (stream_id));
event = gst_pad_get_sticky_event (base->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 (pad, event);
g_free (stream_id); g_free (stream_id);
gst_pad_set_caps (pad, caps); gst_pad_set_caps (pad, caps);
gst_pad_set_query_function (pad, gst_ts_demux_srcpad_query); gst_pad_set_query_function (pad, gst_ts_demux_srcpad_query);

View file

@ -53,6 +53,9 @@ struct _GstTSDemux
{ {
MpegTSBase parent; MpegTSBase parent;
gboolean have_group_id;
guint group_id;
/* the following vars must be protected with the OBJECT_LOCK as they can be /* the following vars must be protected with the OBJECT_LOCK as they can be
* accessed from the application thread and the streaming thread */ * accessed from the application thread and the streaming thread */
gint requested_program_number; /* Required program number (ignore:-1) */ gint requested_program_number; /* Required program number (ignore:-1) */