Commit 1374daaa authored by Laurent Aimar's avatar Laurent Aimar

Allow to select fast seeking with --input-fast-seeking.

No functionnality changes yet as the demuxers need to honor it.

 I have add an extra bool to  DEMUX_SET_POSITION/TIME to ask for precise
seeking to the demuxer.
(You cannot have precision and speed when seeking with non intra only codec).
parent 69a0bd83
......@@ -88,12 +88,12 @@ enum demux_query_e
/* I. Common queries to access_demux and demux */
/* POSITION double between 0.0 and 1.0 */
DEMUX_GET_POSITION, /* arg1= double * res= */
DEMUX_SET_POSITION, /* arg1= double res=can fail */
DEMUX_SET_POSITION, /* arg1= double arg2= bool b_precise res=can fail */
/* LENGTH/TIME in microsecond, 0 if unknown */
DEMUX_GET_LENGTH, /* arg1= int64_t * res= */
DEMUX_GET_TIME, /* arg1= int64_t * res= */
DEMUX_SET_TIME, /* arg1= int64_t res=can fail */
DEMUX_SET_TIME, /* arg1= int64_t arg2= bool b_precise res=can fail */
/* TITLE_INFO only if more than 1 title or 1 chapter */
DEMUX_GET_TITLE_INFO, /* arg1=input_title_t*** arg2=int*
......
......@@ -948,6 +948,7 @@ static void StartTitle( input_thread_t * p_input )
msg_Warn( p_input, "invalid stop-time ignored" );
p_input->p->i_stop = 0;
}
p_input->p->b_fast_seek = var_GetBool( p_input, "input-fast-seek" );
}
static void LoadSubtitles( input_thread_t *p_input )
......@@ -1585,7 +1586,7 @@ static bool Control( input_thread_t *p_input, int i_type,
/* Reset the decoders states and clock sync (before calling the demuxer */
es_out_SetTime( p_input->p->p_es_out, -1 );
if( demux_Control( p_input->p->input.p_demux, DEMUX_SET_POSITION,
f_pos ) )
f_pos, !p_input->p->b_fast_seek ) )
{
msg_Err( p_input, "INPUT_CONTROL_SET_POSITION(_OFFSET) "
"%2.1f%% failed", f_pos * 100 );
......@@ -1624,7 +1625,8 @@ static bool Control( input_thread_t *p_input, int i_type,
es_out_SetTime( p_input->p->p_es_out, -1 );
i_ret = demux_Control( p_input->p->input.p_demux,
DEMUX_SET_TIME, i_time );
DEMUX_SET_TIME, i_time,
!p_input->p->b_fast_seek );
if( i_ret )
{
int64_t i_length;
......@@ -1636,7 +1638,8 @@ static bool Control( input_thread_t *p_input, int i_type,
{
double f_pos = (double)i_time / (double)i_length;
i_ret = demux_Control( p_input->p->input.p_demux,
DEMUX_SET_POSITION, f_pos );
DEMUX_SET_POSITION, f_pos,
!p_input->p->b_fast_seek );
}
}
if( i_ret )
......@@ -2014,7 +2017,7 @@ static bool Control( input_thread_t *p_input, int i_type,
break;
}
if( demux_Control( slave->p_demux,
DEMUX_SET_TIME, i_time ) )
DEMUX_SET_TIME, i_time, true ) )
{
msg_Err( p_input, "seek failed for new slave" );
InputSourceClean( slave );
......@@ -2760,7 +2763,7 @@ static void SlaveSeek( input_thread_t *p_input )
{
input_source_t *in = p_input->p->slave[i];
if( demux_Control( in->p_demux, DEMUX_SET_TIME, i_time ) )
if( demux_Control( in->p_demux, DEMUX_SET_TIME, i_time, true ) )
{
if( !in->b_eof )
msg_Err( p_input, "seek failed for slave %d -> EOF", i );
......
......@@ -94,6 +94,7 @@ struct input_thread_private_t
int64_t i_stop; /* :stop-time, 0 if none */
int64_t i_run; /* :run-time, 0 if none */
int64_t i_time; /* Current time */
bool b_fast_seek;/* :input-fast-seek */
/* Title infos FIXME multi-input (not easy) ? */
int i_title;
......
......@@ -446,6 +446,7 @@ void input_ConfigVarInit ( input_thread_t *p_input )
var_Create( p_input, "start-time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
var_Create( p_input, "stop-time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
var_Create( p_input, "run-time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
var_Create( p_input, "input-fast-seek", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
var_Create( p_input, "input-slave",
VLC_VAR_STRING | VLC_VAR_DOINHERIT );
......
......@@ -678,6 +678,10 @@ static const char *const ppsz_clock_descriptions[] =
#define RUN_TIME_LONGTEXT N_( \
"The stream will run this duration (in seconds)." )
#define INPUT_FAST_SEEK_TEXT N_("Fast seek")
#define INPUT_FAST_SEEK_LONGTEXT N_( \
"Favor speed over precision while seeking" )
#define INPUT_LIST_TEXT N_("Input list")
#define INPUT_LIST_LONGTEXT N_( \
"You can give a comma-separated list " \
......@@ -1702,6 +1706,10 @@ vlc_module_begin ()
add_integer( "run-time", 0, NULL,
RUN_TIME_TEXT, RUN_TIME_LONGTEXT, true );
change_safe ()
add_bool( "input-fast-seek", false, NULL,
INPUT_FAST_SEEK_TEXT, INPUT_FAST_SEEK_LONGTEXT, false );
change_safe ()
add_string( "input-list", NULL, NULL,
INPUT_LIST_TEXT, INPUT_LIST_LONGTEXT, true );
add_string( "input-slave", NULL, NULL,
......
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