Commit 5d66046d authored by Francois Cartegnie's avatar Francois Cartegnie

demux: mp4: always use sidx on discontinuity

Should fix out-of-sync tracks with DASH
parent 08722cb5
...@@ -96,6 +96,7 @@ struct demux_sys_t ...@@ -96,6 +96,7 @@ struct demux_sys_t
mp4_fragment_t *p_fragment; mp4_fragment_t *p_fragment;
uint32_t i_current_box_type; uint32_t i_current_box_type;
uint32_t i_mdatbytesleft; uint32_t i_mdatbytesleft;
uint32_t i_lastseqnumber;
} context; } context;
/* */ /* */
...@@ -592,6 +593,8 @@ static int Open( vlc_object_t * p_this ) ...@@ -592,6 +593,8 @@ static int Open( vlc_object_t * p_this )
p_demux->pf_demux = Demux; p_demux->pf_demux = Demux;
p_demux->pf_control = Control; p_demux->pf_control = Control;
p_sys->context.i_lastseqnumber = 1;
p_demux->p_sys = p_sys; p_demux->p_sys = p_sys;
if( stream_Peek( p_demux->s, &p_peek, 24 ) < 24 ) return VLC_EGENERIC; if( stream_Peek( p_demux->s, &p_peek, 24 ) < 24 ) return VLC_EGENERIC;
...@@ -5034,19 +5037,14 @@ static int DemuxAsLeaf( demux_t *p_demux ) ...@@ -5034,19 +5037,14 @@ static int DemuxAsLeaf( demux_t *p_demux )
return 1; return 1;
} }
if( p_sys->b_dash && p_sys->moovfragment.p_moox && p_sys->moovfragment.p_next ) MP4_Box_t *p_mfhd = MP4_BoxGet( p_fragbox, "mfhd" );
if( p_mfhd && BOXDATA(p_mfhd) )
{ {
/* Detect and Handle Passive Seek */ /* Detect and Handle Passive Seek */
mp4_fragment_t *lastfrag = p_sys->moovfragment.p_next; if( p_sys->context.i_lastseqnumber + 1 != BOXDATA(p_mfhd)->i_sequence_number )
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 %"PRIu32" %"PRIu32, msg_Info( p_demux, "Fragment sequence discontinuity detected %"PRIu32" != %"PRIu32,
BOXDATA(p_mfhd)->i_sequence_number, p_prevmfhd->data.p_mfhd->i_sequence_number + 1 ); BOXDATA(p_mfhd)->i_sequence_number, p_sys->context.i_lastseqnumber + 1 );
MP4_Box_t *p_sidx = MP4_BoxGet( p_vroot, "sidx" ); MP4_Box_t *p_sidx = MP4_BoxGet( p_vroot, "sidx" );
if( p_sidx && BOXDATA(p_sidx) && BOXDATA(p_sidx)->i_timescale ) if( p_sidx && BOXDATA(p_sidx) && BOXDATA(p_sidx)->i_timescale )
{ {
...@@ -5062,6 +5060,7 @@ static int DemuxAsLeaf( demux_t *p_demux ) ...@@ -5062,6 +5060,7 @@ static int DemuxAsLeaf( demux_t *p_demux )
p_sys->i_pcr = VLC_TS_INVALID; p_sys->i_pcr = VLC_TS_INVALID;
} }
} }
p_sys->context.i_lastseqnumber = BOXDATA(p_mfhd)->i_sequence_number;
} }
/* detach */ /* detach */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment