From e25a861ed6ad3cea89eac055f7f976fed21f2799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 4 Aug 2012 12:16:44 +0200 Subject: [PATCH] oggdemux: Add stream-id to the stream-start event --- ext/ogg/gstoggdemux.c | 50 ++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/ext/ogg/gstoggdemux.c b/ext/ogg/gstoggdemux.c index ba0dc6dedf..8a794d8ca9 100644 --- a/ext/ogg/gstoggdemux.c +++ b/ext/ogg/gstoggdemux.c @@ -823,10 +823,7 @@ gst_ogg_pad_submit_packet (GstOggPad * pad, ogg_packet * packet) ogg->total_time = MAX (ogg->total_time, pad->map.total_time); } } - if (pad->map.caps) { - gst_pad_push_event (GST_PAD (pad), gst_event_new_stream_start ()); - gst_pad_set_caps (GST_PAD (pad), pad->map.caps); - } else { + if (!pad->map.caps) { GST_WARNING_OBJECT (ogg, "stream parser didn't create src pad caps"); } } @@ -2587,6 +2584,7 @@ gst_ogg_demux_activate_chain (GstOggDemux * ogg, GstOggChain * chain, /* first add the pads */ for (i = 0; i < chain->streams->len; i++) { GstOggPad *pad; + gchar *stream_id; pad = g_array_index (chain->streams, GstOggPad *, i); @@ -2600,7 +2598,7 @@ gst_ogg_demux_activate_chain (GstOggDemux * ogg, GstOggChain * chain, pad->last_ret = GST_FLOW_OK; if (pad->map.is_skeleton || pad->map.is_cmml || pad->added - || !gst_pad_has_current_caps (GST_PAD_CAST (pad))) + || !pad->map.caps) continue; GST_DEBUG_OBJECT (ogg, "adding pad %" GST_PTR_FORMAT, pad); @@ -2608,6 +2606,17 @@ gst_ogg_demux_activate_chain (GstOggDemux * ogg, GstOggChain * chain, /* activate first */ gst_pad_set_active (GST_PAD_CAST (pad), TRUE); + stream_id = + gst_pad_create_stream_id_printf (GST_PAD (pad), GST_ELEMENT_CAST (ogg), + "%08x", pad->map.serialno); + gst_pad_push_event (GST_PAD (pad), gst_event_new_stream_start (stream_id)); + g_free (stream_id); + + /* Set headers on caps */ + pad->map.caps = + gst_ogg_demux_set_header_on_caps (ogg, pad->map.caps, pad->map.headers); + gst_pad_set_caps (GST_PAD_CAST (pad), pad->map.caps); + gst_element_add_pad (GST_ELEMENT (ogg), GST_PAD_CAST (pad)); pad->added = TRUE; } @@ -2623,26 +2632,24 @@ gst_ogg_demux_activate_chain (GstOggDemux * ogg, GstOggChain * chain, /* we are finished now */ gst_element_no_more_pads (GST_ELEMENT (ogg)); - /* FIXME, must be sent from the streaming thread */ - if (event) { - GstTagList *tags; - - gst_ogg_demux_send_event (ogg, event); - - tags = gst_tag_list_new (GST_TAG_CONTAINER_FORMAT, "Ogg", NULL); - gst_tag_list_set_scope (tags, GST_TAG_SCOPE_GLOBAL); - gst_ogg_demux_send_event (ogg, gst_event_new_tag (tags)); - } - GST_DEBUG_OBJECT (ogg, "starting chain"); /* then send out any headers and queued packets */ for (i = 0; i < chain->streams->len; i++) { GList *walk; GstOggPad *pad; + GstTagList *tags; pad = g_array_index (chain->streams, GstOggPad *, i); + /* Skip pads that were not added, e.g. Skeleton streams */ + if (!pad->added) + continue; + + /* FIXME, must be sent from the streaming thread */ + if (event) + gst_pad_push_event (GST_PAD_CAST (pad), gst_event_ref (event)); + /* FIXME also streaming thread */ if (pad->map.taglist) { GST_DEBUG_OBJECT (ogg, "pushing tags"); @@ -2651,10 +2658,9 @@ gst_ogg_demux_activate_chain (GstOggDemux * ogg, GstOggChain * chain, pad->map.taglist = NULL; } - /* Set headers on caps */ - pad->map.caps = - gst_ogg_demux_set_header_on_caps (ogg, pad->map.caps, pad->map.headers); - gst_pad_set_caps (GST_PAD_CAST (pad), pad->map.caps); + tags = gst_tag_list_new (GST_TAG_CONTAINER_FORMAT, "Ogg", NULL); + gst_tag_list_set_scope (tags, GST_TAG_SCOPE_GLOBAL); + gst_pad_push_event (GST_PAD (pad), gst_event_new_tag (tags)); GST_DEBUG_OBJECT (ogg, "pushing headers"); /* push headers */ @@ -2667,6 +2673,10 @@ gst_ogg_demux_activate_chain (GstOggDemux * ogg, GstOggChain * chain, GST_DEBUG_OBJECT (ogg, "pushing queued buffers"); gst_ogg_demux_push_queued_buffers (ogg, pad); } + + if (event) + gst_event_unref (event); + return TRUE; }