From f909c5754693d9c62fe779b8216712894b9ca494 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Mon, 26 Sep 2011 12:16:30 +0100 Subject: [PATCH] mpegtsdemux: signal no-more-pads when appropriate We track streams for which a data callback is set (and for which pads will be added only when data is received), and signal no-more-pads when the last pad is added. https://bugzilla.gnome.org/show_bug.cgi?id=659924 --- gst/mpegdemux/gstmpegtsdemux.c | 20 +++++++++++++++++++- gst/mpegdemux/gstmpegtsdemux.h | 3 +++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/gst/mpegdemux/gstmpegtsdemux.c b/gst/mpegdemux/gstmpegtsdemux.c index 648bc2128f..1fab2b0bd6 100644 --- a/gst/mpegdemux/gstmpegtsdemux.c +++ b/gst/mpegdemux/gstmpegtsdemux.c @@ -1245,7 +1245,12 @@ gst_mpegts_demux_data_cb (GstPESFilter * filter, gboolean first, /* activate and add */ gst_pad_set_active (srcpad, TRUE); gst_element_add_pad (GST_ELEMENT_CAST (demux), srcpad); - demux->need_no_more_pads = TRUE; + demux->pending_pads--; + GST_DEBUG_OBJECT (demux, + "Adding pad due to received data, decreasing pending pads to %d", + demux->pending_pads); + if (demux->pending_pads == 0) + gst_element_no_more_pads (GST_ELEMENT (demux)); stream->discont = TRUE; @@ -1471,6 +1476,8 @@ gst_mpegts_stream_parse_pmt (GstMpegTSStream * stream, g_array_free (PMT->entries, TRUE); PMT->entries = g_array_new (FALSE, TRUE, sizeof (GstMpegTSPMTEntry)); + GST_DEBUG_OBJECT (demux, "Resetting pending pads due to parsing the PMT"); + demux->pending_pads = 0; while (entries > 0) { GstMpegTSPMTEntry entry; GstMpegTSStream *ES_stream; @@ -1554,6 +1561,12 @@ gst_mpegts_stream_parse_pmt (GstMpegTSStream * stream, ES_stream->filter.gather_pes = TRUE; } } + + ++demux->pending_pads; + GST_DEBUG_OBJECT (demux, + "Setting data callback, increasing pending pads to %d", + demux->pending_pads); + gst_pes_filter_set_callbacks (&ES_stream->filter, (GstPESFilterData) gst_mpegts_demux_data_cb, (GstPESFilterResync) gst_mpegts_demux_resync_cb, ES_stream); @@ -1585,6 +1598,11 @@ gst_mpegts_stream_parse_pmt (GstMpegTSStream * stream, gst_mpegts_activate_pmt (demux, stream); } + GST_DEBUG_OBJECT (demux, "Done parsing PMT, pending pads now %d", + demux->pending_pads); + if (demux->pending_pads == 0) + gst_element_no_more_pads (GST_ELEMENT (demux)); + return TRUE; /* ERRORS */ diff --git a/gst/mpegdemux/gstmpegtsdemux.h b/gst/mpegdemux/gstmpegtsdemux.h index d25e7fde8a..9a5db0e1aa 100644 --- a/gst/mpegdemux/gstmpegtsdemux.h +++ b/gst/mpegdemux/gstmpegtsdemux.h @@ -231,6 +231,9 @@ struct _GstMpegTSDemux { /* Detect when the source stops for a while, we will resync the interpolation gap */ GstClockTime last_buf_ts; + + /* Number of expected pads which have not been added yet */ + gint pending_pads; }; struct _GstMpegTSDemuxClass {