Commit fafd0af1 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: mp4: re-enable non fastseekable mp4

parent f8959894
......@@ -446,12 +446,6 @@ static int Open( vlc_object_t * p_this )
stream_Seek( p_demux->s, 0 ); /* rewind, for other demux */
goto error;
}
else if( !p_sys->b_fastseekable )
{
msg_Warn( p_demux, "MP4 plugin discarded (not fast-seekable)" );
stream_Seek( p_demux->s, 0 ); /* rewind, for other demux */
goto error;
}
MP4_BoxDumpStructure( p_demux->s, p_sys->p_root );
......@@ -775,42 +769,53 @@ static int Demux( demux_t *p_demux )
/* first wait for the good time to read a packet */
p_sys->i_pcr = MP4_GetMoviePTS( p_sys );
/* we will read 100ms for each stream so ...*/
mtime_t i_targettime = p_sys->i_pcr + CLOCK_FREQ/10;
bool b_data_sent = false;
/* Find next track matching contiguous data */
mp4_track_t *tk = NULL;
uint64_t i_candidate_pos = UINT64_MAX;
for( i_track = 0; i_track < p_sys->i_tracks; i_track++ )
{
mp4_track_t *tk = &p_sys->track[i_track];
if( !tk->b_ok || tk->b_chapter || !tk->b_selected || tk->i_sample >= tk->i_sample_count )
mp4_track_t *tk_tmp = &p_sys->track[i_track];
if( !tk_tmp->b_ok || tk_tmp->b_chapter || !tk_tmp->b_selected || tk_tmp->i_sample >= tk_tmp->i_sample_count )
continue;
while( MP4_TrackGetDTS( p_demux, tk ) < i_targettime
|| ( p_sys->i_pcr == VLC_TS_INVALID && !b_data_sent ) )
uint64_t i_pos = MP4_TrackGetPos( tk_tmp );
if ( i_pos <= i_candidate_pos )
{
i_candidate_pos = i_pos;
tk = tk_tmp;
}
}
if ( !tk )
{
msg_Dbg( p_demux, "Could not select track by data position" );
goto end;
}
#if 0
msg_Dbg( p_demux, "tk(%i)=%lld mv=%lld", i_track,
msg_Dbg( p_demux, "tk(%i)=%"PRId64" mv=%"PRId64" pos=%"PRIu64, i_track,
MP4_TrackGetDTS( p_demux, tk ),
MP4_GetMoviePTS( p_sys ) );
MP4_GetMoviePTS( p_sys ), i_candidate_pos );
#endif
uint32_t i_nb_samples = 0;
uint32_t i_samplessize = MP4_TrackSampleSize( tk, &i_nb_samples );
if( i_samplessize > 0 )
{
block_t *p_block;
int64_t i_delta, i_newpos;
int64_t i_delta;
/* go,go go ! */
i_newpos = MP4_TrackGetPos( tk );
if( stream_Tell( p_demux->s ) != i_newpos )
if( stream_Tell( p_demux->s ) != i_candidate_pos )
{
if( stream_Seek( p_demux->s, i_newpos ) )
if( stream_Seek( p_demux->s, i_candidate_pos ) )
{
msg_Warn( p_demux, "track[0x%x] will be disabled (eof?)",
tk->i_track_ID );
MP4_TrackUnselect( p_demux, tk );
break;
goto end;
}
}
......@@ -820,7 +825,7 @@ static int Demux( demux_t *p_demux )
msg_Warn( p_demux, "track[0x%x] will be disabled (eof?)",
tk->i_track_ID );
MP4_TrackUnselect( p_demux, tk );
break;
goto end;
}
else if( tk->fmt.i_cat == SPU_ES )
{
......@@ -846,14 +851,12 @@ static int Demux( demux_t *p_demux )
b_data_sent = true;
}
es_out_Send( p_demux->out, tk->p_es, p_block );
}
/* Next sample */
if( MP4_TrackNextSample( p_demux, tk, i_nb_samples ) )
break;
}
MP4_TrackNextSample( p_demux, tk, i_nb_samples );
}
end:
if ( b_data_sent )
{
p_sys->i_pcr = INT64_MAX;
......
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