[vlc-commits] demux: mp4: handle fragment start with missing traf

Francois Cartegnie git at videolan.org
Mon Apr 30 17:32:18 CEST 2018


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Apr 30 16:45:28 2018 +0200| [1a7915a5fabb25b0d7f582ec06a6a2f77ab82717] | committer: Francois Cartegnie

demux: mp4: handle fragment start with missing traf

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1a7915a5fabb25b0d7f582ec06a6a2f77ab82717
---

 modules/demux/mp4/mp4.c | 16 ++++++++++++----
 modules/demux/mp4/mp4.h |  2 ++
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index b03d48354b..186d5f0864 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -188,7 +188,7 @@ static stime_t GetMoovTrackDuration( demux_sys_t *p_sys, unsigned i_track_ID );
 static int  ProbeFragments( demux_t *p_demux, bool b_force, bool *pb_fragmented );
 static int  ProbeIndex( demux_t *p_demux );
 
-static int FragCreateTrunIndex( demux_t *, MP4_Box_t *, MP4_Box_t *, stime_t, bool );
+static int FragCreateTrunIndex( demux_t *, MP4_Box_t *, MP4_Box_t *, stime_t );
 
 static int FragGetMoofBySidxIndex( demux_t *p_demux, mtime_t i_target_time,
                                    uint64_t *pi_moof_pos, mtime_t *pi_sampletime );
@@ -1553,7 +1553,13 @@ static int FragPrepareChunk( demux_t *p_demux, MP4_Box_t *p_moof,
 {
     demux_sys_t *p_sys = p_demux->p_sys;
 
-    if( FragCreateTrunIndex( p_demux, p_moof, p_sidx, i_moof_time, b_discontinuity ) == VLC_SUCCESS )
+    if( b_discontinuity )
+    {
+        for( unsigned i=0; i<p_sys->i_tracks; i++ )
+            p_sys->track[i].context.b_resync_time_offset = true;
+    }
+
+    if( FragCreateTrunIndex( p_demux, p_moof, p_sidx, i_moof_time ) == VLC_SUCCESS )
     {
         for( unsigned i=0; i<p_sys->i_tracks; i++ )
         {
@@ -4548,7 +4554,7 @@ static int DemuxMoof( demux_t *p_demux )
 }
 
 static int FragCreateTrunIndex( demux_t *p_demux, MP4_Box_t *p_moof,
-                                MP4_Box_t *p_chunksidx, stime_t i_moof_time, bool b_discontinuity )
+                                MP4_Box_t *p_chunksidx, stime_t i_moof_time )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
 
@@ -4597,8 +4603,10 @@ static int FragCreateTrunIndex( demux_t *p_demux, MP4_Box_t *p_moof,
         stime_t  i_traf_start_time = p_track->i_time;
         bool     b_has_base_media_decode_time = false;
 
-        if( b_discontinuity ) /* We NEED start time offset for each track */
+        if( p_track->context.b_resync_time_offset ) /* We NEED start time offset for each track */
         {
+            p_track->context.b_resync_time_offset = false;
+
             /* Find start time */
             const MP4_Box_t *p_tfdt = MP4_BoxGet( p_traf, "tfdt" );
             if( p_tfdt )
diff --git a/modules/demux/mp4/mp4.h b/modules/demux/mp4/mp4.h
index 99cb9bbb5e..0f4c51b74b 100644
--- a/modules/demux/mp4/mp4.h
+++ b/modules/demux/mp4/mp4.h
@@ -150,6 +150,8 @@ typedef struct
     struct
     {
         /* for moof parsing */
+        bool b_resync_time_offset;
+
         /* tfhd defaults */
         uint32_t i_default_sample_size;
         uint32_t i_default_sample_duration;



More information about the vlc-commits mailing list