From: Edward Hervey Date: Fri, 1 Oct 2021 12:36:48 +0000 (+0200) Subject: tsdemux: Improve gap detection X-Git-Tag: 1.19.3~172 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d9b1e1e99f39a638e78078924161a99fd59efbbf;p=platform%2Fupstream%2Fgstreamer.git tsdemux: Improve gap detection We should also take into account whether data is currently pending when checking for gap on streams. It could very well be that some streams have very low bitrate (and spread out) data. For those we don't want to push out a gap event. Part-of: --- diff --git a/subprojects/gst-plugins-bad/gst/mpegtsdemux/tsdemux.c b/subprojects/gst-plugins-bad/gst/mpegtsdemux/tsdemux.c index bf6ad58..4faabcc 100644 --- a/subprojects/gst-plugins-bad/gst/mpegtsdemux/tsdemux.c +++ b/subprojects/gst-plugins-bad/gst/mpegtsdemux/tsdemux.c @@ -2887,9 +2887,10 @@ gst_ts_demux_check_and_sync_streams (GstTSDemux * demux, GstClockTime time) * This means we can detect buffers passing without PTSes fine and still generate * gaps. * - * If there haven't been any buffers pushed on this stream since the last - * gap check, push a gap event updating to the indicated input PCR time - * and update the pad's tracking. + * If there haven't been any buffers pushed on this stream since the last gap + * check *AND* there is no pending data (stream->current_size), push a gap + * event updating to the indicated input PCR time and update the pad's + * tracking. * * If there have been buffers pushed, update the reference buffer count * and but don't push a gap event @@ -2898,15 +2899,16 @@ gst_ts_demux_check_and_sync_streams (GstTSDemux * demux, GstClockTime time) TSDemuxStream *ps = (TSDemuxStream *) tmp->data; GST_DEBUG_OBJECT (ps->pad, "0x%04x, PTS:%" GST_TIME_FORMAT " REFPTS:%" GST_TIME_FORMAT " Gap:%" - GST_TIME_FORMAT " nb_buffers: %d (ref:%d)", + GST_TIME_FORMAT " nb_buffers: %d (ref:%d) pending_data size %u", ((MpegTSBaseStream *) ps)->pid, GST_TIME_ARGS (ps->pts), GST_TIME_ARGS (ps->gap_ref_pts), GST_TIME_ARGS (ps->pts - ps->gap_ref_pts), ps->nb_out_buffers, - ps->gap_ref_buffers); + ps->gap_ref_buffers, ps->current_size); if (ps->pad == NULL) continue; - if (ps->nb_out_buffers == ps->gap_ref_buffers && ps->gap_ref_pts != ps->pts) { + if (ps->nb_out_buffers == ps->gap_ref_buffers && ps->current_size == 0 + && ps->gap_ref_pts != ps->pts) { /* Do initial setup of pad if needed - segment etc */ GST_DEBUG_OBJECT (ps->pad, "Stream needs update. Pushing GAP event to TS %" GST_TIME_FORMAT,