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
This commit is contained in:
Vincent Penquerc'h 2011-09-26 12:16:30 +01:00
parent 9715fc3189
commit f909c57546
2 changed files with 22 additions and 1 deletions

View file

@ -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 */

View file

@ -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 {