qtdemux: Use the timestamp of the moof as the base fragment start
authorThiago Santos <ts.santos@sisa.samsung.com>
Fri, 29 Nov 2013 14:26:05 +0000 (11:26 -0300)
committerThiago Santos <ts.santos@sisa.samsung.com>
Fri, 29 Nov 2013 20:28:48 +0000 (17:28 -0300)
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

index 78d4f45109fb75fdaa1c84cb456207baa59e20ad..d2ca3f4f65df8a4ecc79fb1162f74fd143b4639c 100644 (file)
@@ -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);