]> git.sesse.net Git - vlc/commitdiff
demux: mp4: handle DASH passive seek for now
authorFrancois Cartegnie <fcvlcdev@free.fr>
Fri, 2 Jan 2015 18:00:50 +0000 (19:00 +0100)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Fri, 2 Jan 2015 18:27:37 +0000 (19:27 +0100)
modules/demux/mp4/mp4.c

index debb56fb42ced56c258be8eb3defda1885631528..171876c6cc758ee3c88a6ff91280513e6e1dab02 100644 (file)
@@ -5035,6 +5035,35 @@ static int DemuxAsLeaf( demux_t *p_demux )
                     return 1;
                 }
 
+                if( p_sys->b_dash && p_sys->moovfragment.p_moox && p_sys->moovfragment.p_next )
+                {
+                    /* Detect and Handle Passive Seek */
+                    mp4_fragment_t *lastfrag = p_sys->moovfragment.p_next;
+                    while(lastfrag->p_next)
+                        lastfrag = lastfrag->p_next;
+                    MP4_Box_t *p_mfhd = MP4_BoxGet( p_fragbox, "mfhd" );
+                    MP4_Box_t *p_prevmfhd = MP4_BoxGet( lastfrag->p_moox, "mfhd" );
+                    if( p_mfhd && p_prevmfhd &&
+                        BOXDATA(p_mfhd)->i_sequence_number != p_prevmfhd->data.p_mfhd->i_sequence_number + 1 )
+                    {
+                        msg_Info( p_demux, "Passive DASH Seek detected" );
+                        MP4_Box_t *p_sidx = MP4_BoxGet( p_vroot, "sidx" );
+                        if( p_sidx && BOXDATA(p_sidx) && BOXDATA(p_sidx)->i_timescale )
+                        {
+                            mtime_t i_time_base = BOXDATA(p_sidx)->i_earliest_presentation_time;
+
+                            for( unsigned int i_track = 0; i_track < p_sys->i_tracks; i_track++ )
+                            {
+                                p_sys->track[i_track].i_time = i_time_base * p_sys->track[i_track].i_timescale
+                                                                           / BOXDATA(p_sidx)->i_timescale;
+                            }
+
+                            p_sys->i_time = i_time_base * p_sys->i_timescale / BOXDATA(p_sidx)->i_timescale;
+                            p_sys->i_pcr  = VLC_TS_INVALID;
+                        }
+                    }
+                }
+
                 /* detach */
                 while( p_vroot->p_first )
                 {