From 079dde49ed3fb67c833c1baa77e144958b7f889d Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Fri, 29 Nov 2013 11:26:05 -0300 Subject: [PATCH] qtdemux: Use the timestamp of the moof as the base fragment start In SmoothStreaming fragmented scenario, the timestamps are calculated starting from the fragment buffer timestamp. When there is a not-linked return from downstream, qtdemux will return upstream and will keep the non-pushed data into its adapter. On a new fragment buffer pushed to qtdemux, the new buffer timestamp would overwrite the previous one that should be used on the still to be pushed buffers. Because of this, this patch will also update the fragment_start timestamp from the adapter last pts to make sure the moof and timestamps are in sync and will result in correct timestamps for all fragments. --- gst/isomp4/qtdemux.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c index 78d4f45109..d2ca3f4f65 100644 --- a/gst/isomp4/qtdemux.c +++ b/gst/isomp4/qtdemux.c @@ -4787,6 +4787,10 @@ gst_qtdemux_chain (GstPad * sinkpad, GstObject * parent, GstBuffer * inbuf) } else if (fourcc == FOURCC_moof) { if ((demux->got_moov || demux->media_caps) && demux->fragmented) { GST_DEBUG_OBJECT (demux, "Parsing [moof]"); + + /* the timestamp of the moof buffer is relevant as some scenarios + * won't have the initial timestamp in the atoms */ + demux->fragment_start = gst_adapter_prev_pts (demux->adapter, NULL); if (!qtdemux_parse_moof (demux, data, demux->neededbytes, demux->offset, NULL)) { gst_adapter_unmap (demux->adapter);