[vlc-commits] demux: mp4: handle DASH passive seek for now

Francois Cartegnie git at videolan.org
Fri Jan 2 19:27:51 CET 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Jan  2 19:00:50 2015 +0100| [aa9ccaaffff9ab043f50f305f8e6f2c84e0edabd] | committer: Francois Cartegnie

demux: mp4: handle DASH passive seek for now

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

 modules/demux/mp4/mp4.c |   29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index debb56f..171876c 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -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 )
                 {



More information about the vlc-commits mailing list