tsdemux: do not send a new-segment on stream removal

When a program is changed, stream_added is called which sets the
need_newsegment to TRUE, then stream_removed is called, which calls
the flush_pending_data, which checks for the newsegment and causes
it to send a new-segment.

We must not send the newsegment when flushing the pending data on the
removed stream. We should only push it when flushing data on the newly
added streams (after they finish parsing their PTS header)
This commit is contained in:
Youness Alaoui 2011-08-18 23:52:37 +00:00 committed by Sebastian Dröge
parent 382710e200
commit 818762e8fc

View file

@ -1217,13 +1217,24 @@ gst_ts_demux_stream_added (MpegTSBase * base, MpegTSBaseStream * bstream,
static void
gst_ts_demux_stream_removed (MpegTSBase * base, MpegTSBaseStream * bstream)
{
GstTSDemux *demux = GST_TS_DEMUX (base);
TSDemuxStream *stream = (TSDemuxStream *) bstream;
if (stream->pad) {
if (gst_pad_is_active (stream->pad)) {
GST_DEBUG_OBJECT (stream->pad, "Flushing out pending data");
gboolean need_newsegment = demux->need_newsegment;
/* We must not send the newsegment when flushing the pending data
on the removed stream. We should only push it when the newly added
stream finishes parsing its PTS */
demux->need_newsegment = FALSE;
/* Flush out all data */
GST_DEBUG_OBJECT (stream->pad, "Flushing out pending data");
gst_ts_demux_push_pending_data ((GstTSDemux *) base, stream);
demux->need_newsegment = need_newsegment;
GST_DEBUG_OBJECT (stream->pad, "Pushing out EOS");
gst_pad_push_event (stream->pad, gst_event_new_eos ());
GST_DEBUG_OBJECT (stream->pad, "Deactivating and removing pad");