From 89a85732d4d91ea6b41e3ea85fdf96152bc58e8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Zanelli?= Date: Mon, 16 Mar 2015 16:20:44 +0100 Subject: [PATCH] tsdemux: ignore sparse stream when checking for initial timestamp Unless we only have sparse streams. In this case we will consider them. It fixes a bug happening when first observed timestamp comes from a sparse stream and other streams don't have a valid timestamp, yet. Thus leading the timestamp from sparse stream to be the start of the following segment. In this case, if the timestamp is really bigger than non-sparse stream (audio/video), it will lead the pipeline to clip samples from the non-parse stream. https://bugzilla.gnome.org/show_bug.cgi?id=744469 --- gst/mpegtsdemux/tsdemux.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/gst/mpegtsdemux/tsdemux.c b/gst/mpegtsdemux/tsdemux.c index b0ff238ea3..40f06e3670 100644 --- a/gst/mpegtsdemux/tsdemux.c +++ b/gst/mpegtsdemux/tsdemux.c @@ -2119,15 +2119,28 @@ check_pending_buffers (GstTSDemux * demux) /* The biggest offset */ guint64 offset = 0; GList *tmp; + gboolean have_only_sparse = TRUE; + + /* 0. Do we only have sparse stream */ + for (tmp = demux->program->stream_list; tmp; tmp = tmp->next) { + TSDemuxStream *tmpstream = (TSDemuxStream *) tmp->data; + + if (!tmpstream->sparse) { + have_only_sparse = FALSE; + break; + } + } /* 1. Go over all streams */ for (tmp = demux->program->stream_list; tmp; tmp = tmp->next) { TSDemuxStream *tmpstream = (TSDemuxStream *) tmp->data; /* 1.1 check if at least one stream got a valid DTS */ - if ((tmpstream->raw_dts != -1 && tmpstream->dts != GST_CLOCK_TIME_NONE) || - (tmpstream->raw_pts != -1 && tmpstream->pts != GST_CLOCK_TIME_NONE)) { - have_observation = TRUE; - break; + if (have_only_sparse || !tmpstream->sparse) { + if ((tmpstream->raw_dts != -1 && tmpstream->dts != GST_CLOCK_TIME_NONE) || + (tmpstream->raw_pts != -1 && tmpstream->pts != GST_CLOCK_TIME_NONE)) { + have_observation = TRUE; + break; + } } }