From 4e3c13c87c258c9c95e2217d32ab314d12b5fffc Mon Sep 17 00:00:00 2001 From: Matej Knopp Date: Sat, 14 Sep 2013 15:54:29 +0200 Subject: [PATCH] qtmux: use segment.start or last buffer end time in case of missing DTS https://bugzilla.gnome.org/show_bug.cgi?id=707340 --- gst/isomp4/gstqtmux.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/gst/isomp4/gstqtmux.c b/gst/isomp4/gstqtmux.c index 7207a00..c35a9f3 100644 --- a/gst/isomp4/gstqtmux.c +++ b/gst/isomp4/gstqtmux.c @@ -2130,6 +2130,27 @@ gst_qt_mux_add_buffer (GstQTMux * qtmux, GstQTPad * pad, GstBuffer * buf) last_buf = pad->last_buf; + /* if buffer has missing DTS, we take either segment start or previous buffer end time, + which ever is later */ + if (buf && pad->have_dts && !GST_BUFFER_DTS_IS_VALID (buf)) { + GstClockTime last_buf_duration = last_buf + && GST_BUFFER_DURATION_IS_VALID (last_buf) ? + GST_BUFFER_DURATION (last_buf) : 0; + + buf = gst_buffer_make_writable (buf); + GST_BUFFER_DTS (buf) = + gst_segment_to_running_time (&pad->collect.segment, GST_FORMAT_TIME, + pad->collect.segment.start); + if (GST_CLOCK_TIME_IS_VALID (pad->first_ts)) + check_and_subtract_ts (qtmux, &GST_BUFFER_DTS (buf), pad->first_ts); + + if (last_buf + && (GST_BUFFER_DTS (last_buf) + last_buf_duration) > + GST_BUFFER_DTS (buf)) { + GST_BUFFER_DTS (buf) = GST_BUFFER_DTS (last_buf) + last_buf_duration; + } + } + if (last_buf == NULL) { #ifndef GST_DISABLE_GST_DEBUG if (buf == NULL) { -- 2.7.4