From 1426a55a83f054d8e2da687f3bb30cde009f9221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 8 Feb 2017 17:24:26 +0200 Subject: [PATCH] qtmux: Clear edit lists every time we recalculate them We recalculate them, so any old information has to be forgotten. Otherwise we write invalid edit lists when writing headers multiple times. https://bugzilla.gnome.org/show_bug.cgi?id=778330 --- gst/isomp4/atoms.c | 9 +++++++++ gst/isomp4/atoms.h | 1 + gst/isomp4/gstqtmux.c | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gst/isomp4/atoms.c b/gst/isomp4/atoms.c index 64c121fda2..4c0453fa21 100644 --- a/gst/isomp4/atoms.c +++ b/gst/isomp4/atoms.c @@ -3716,6 +3716,15 @@ atom_edts_add_entry (AtomEDTS * edts, gint index, EditListEntry * entry) *e = *entry; } +void +atom_trak_edts_clear (AtomTRAK * trak) +{ + if (trak->edts) { + atom_edts_clear (trak->edts); + trak->edts = NULL; + } +} + /* * Update an entry in this trak edits list, creating it if needed. * index is the index of the entry to update, or create if it's past the end. diff --git a/gst/isomp4/atoms.h b/gst/isomp4/atoms.h index d38980bd23..fad8b0bdf0 100644 --- a/gst/isomp4/atoms.h +++ b/gst/isomp4/atoms.h @@ -918,6 +918,7 @@ void atom_trak_add_samples (AtomTRAK * trak, guint32 nsamples, guint gint64 pts_offset); void atom_trak_set_elst_entry (AtomTRAK * trak, gint index, guint32 duration, guint32 media_time, guint32 rate); +void atom_trak_edts_clear (AtomTRAK * trak); guint32 atom_trak_get_timescale (AtomTRAK *trak); guint32 atom_trak_get_id (AtomTRAK * trak); void atom_stbl_add_samples (AtomSTBL * stbl, guint32 nsamples, diff --git a/gst/isomp4/gstqtmux.c b/gst/isomp4/gstqtmux.c index 39640e72d7..8be98ba68f 100644 --- a/gst/isomp4/gstqtmux.c +++ b/gst/isomp4/gstqtmux.c @@ -2511,6 +2511,8 @@ gst_qt_mux_update_edit_lists (GstQTMux * qtmux) GstCollectData *cdata = (GstCollectData *) walk->data; GstQTPad *qtpad = (GstQTPad *) cdata; + atom_trak_edts_clear (qtpad->trak); + if (GST_CLOCK_TIME_IS_VALID (qtpad->first_ts)) { guint32 lateness = 0; guint32 duration = qtpad->trak->tkhd.duration; @@ -2556,7 +2558,6 @@ gst_qt_mux_update_edit_lists (GstQTMux * qtmux) /* need to add the empty time to the trak duration */ duration += lateness; - qtpad->trak->tkhd.duration = duration; if (qtpad->tc_trak) { qtpad->tc_trak->tkhd.duration = duration;