tsdemux: Drain remaining data on disconts

This commit is contained in:
Sebastian Dröge 2014-03-28 17:32:56 +01:00
parent d986d24d41
commit 264d7dbd89
3 changed files with 44 additions and 1 deletions

View file

@ -997,6 +997,18 @@ gst_mpegts_base_handle_eos (MpegTSBase * base)
return TRUE;
}
static inline GstFlowReturn
mpegts_base_drain (MpegTSBase * base)
{
MpegTSBaseClass *klass = GST_MPEGTS_BASE_GET_CLASS (base);
/* Call implementation */
if (klass->drain)
return klass->drain (base);
return GST_FLOW_OK;
}
static inline void
mpegts_base_flush (MpegTSBase * base, gboolean hard)
{
@ -1096,8 +1108,12 @@ mpegts_base_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
if (klass->input_done)
gst_buffer_ref (buf);
if (FALSE && GST_BUFFER_IS_DISCONT (buf)) {
if (GST_BUFFER_IS_DISCONT (buf)) {
GST_DEBUG_OBJECT (base, "Got DISCONT buffer, flushing");
res = mpegts_base_drain (base);
if (G_UNLIKELY (res != GST_FLOW_OK))
return res;
mpegts_base_flush (base, FALSE);
mpegts_packetizer_flush (base->packetizer, TRUE);
}

View file

@ -185,6 +185,9 @@ struct _MpegTSBaseClass {
/* seek is called to wait for seeking */
GstFlowReturn (*seek) (MpegTSBase * base, GstEvent * event);
/* Drain all currently pending data */
GstFlowReturn (*drain) (MpegTSBase * base);
/* flush all streams
* The hard inicator is used to flush completelly on FLUSH_STOP events
* or partially in pull mode seeks of tsdemux */

View file

@ -245,6 +245,7 @@ static GstFlowReturn
gst_ts_demux_push (MpegTSBase * base, MpegTSPacketizerPacket * packet,
GstMpegTsSection * section);
static void gst_ts_demux_flush (MpegTSBase * base, gboolean hard);
static GstFlowReturn gst_ts_demux_drain (MpegTSBase * base);
static void
gst_ts_demux_stream_added (MpegTSBase * base, MpegTSBaseStream * stream,
MpegTSBaseProgram * program);
@ -326,6 +327,7 @@ gst_ts_demux_class_init (GstTSDemuxClass * klass)
ts_class->stream_removed = gst_ts_demux_stream_removed;
ts_class->seek = GST_DEBUG_FUNCPTR (gst_ts_demux_do_seek);
ts_class->flush = GST_DEBUG_FUNCPTR (gst_ts_demux_flush);
ts_class->drain = GST_DEBUG_FUNCPTR (gst_ts_demux_drain);
}
static void
@ -1893,6 +1895,28 @@ gst_ts_demux_flush (MpegTSBase * base, gboolean hard)
}
}
static GstFlowReturn
gst_ts_demux_drain (MpegTSBase * base)
{
GstTSDemux *demux = GST_TS_DEMUX_CAST (base);
GList *tmp;
GstFlowReturn res = GST_FLOW_OK;
if (!demux->program)
return res;
for (tmp = demux->program->stream_list; tmp; tmp = tmp->next) {
TSDemuxStream *stream = (TSDemuxStream *) tmp->data;
if (stream->pad) {
res = gst_ts_demux_push_pending_data (demux, stream);
if (G_UNLIKELY (res != GST_FLOW_OK))
break;
}
}
return res;
}
static GstFlowReturn
gst_ts_demux_push (MpegTSBase * base, MpegTSPacketizerPacket * packet,
GstMpegTsSection * section)