Commit e827c773 authored by Laurent Aimar's avatar Laurent Aimar

Improved current times in regard to es_out timeshift.

parent 1f8343b8
......@@ -2307,6 +2307,17 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args )
EsOutFrameNext( out );
return VLC_SUCCESS;
case ES_OUT_SET_TIMES:
{
double f_position = (double)va_arg( args, double );
mtime_t i_time = (mtime_t)va_arg( args, mtime_t );
mtime_t i_length = (mtime_t)va_arg( args, mtime_t );
/* TODO handle es_out buffering */
input_SendEventTimes( p_sys->p_input, f_position, i_time, i_length );
return VLC_SUCCESS;
}
default:
msg_Err( p_sys->p_input, "unknown query in es_out_Control" );
return VLC_EGENERIC;
......
......@@ -71,6 +71,9 @@ enum es_out_query_private_e
/* Set next frame */
ES_OUT_SET_FRAME_NEXT, /* res=can fail */
/* Set position/time/length */
ES_OUT_SET_TIMES, /* arg1=double f_position arg2=mtime_t i_time arg3=mtime_t i_length res=cannot fail */
};
static inline mtime_t es_out_GetWakeup( es_out_t *p_out )
......@@ -121,6 +124,11 @@ static inline int es_out_SetFrameNext( es_out_t *p_out )
{
return es_out_Control( p_out, ES_OUT_SET_FRAME_NEXT );
}
static inline void es_out_SetTimes( es_out_t *p_out, double f_position, mtime_t i_time, mtime_t i_length )
{
int i_ret = es_out_Control( p_out, ES_OUT_SET_TIMES, f_position, i_time, i_length );
assert( !i_ret );
}
es_out_t *input_EsOutNew( input_thread_t *, int i_rate );
......
......@@ -121,6 +121,13 @@ typedef struct attribute_packed
es_out_id_t *p_es;
es_format_t *p_fmt;
} es_fmt;
struct
{
/* FIXME Really too big (double make the whole thing too big) */
double f_position;
mtime_t i_time;
mtime_t i_length;
} times;
};
} ts_cmd_control_t;
......@@ -595,6 +602,7 @@ static int ControlLocked( es_out_t *p_out, int i_query, va_list args )
case ES_OUT_SET_ES_DEFAULT:
case ES_OUT_SET_ES_STATE:
case ES_OUT_SET_ES_FMT:
case ES_OUT_SET_TIMES:
{
ts_cmd_t cmd;
if( CmdInitControl( &cmd, i_query, args, p_sys->b_delayed ) )
......@@ -1377,6 +1385,17 @@ static int CmdInitControl( ts_cmd_t *p_cmd, int i_query, va_list args, bool b_co
}
break;
}
case ES_OUT_SET_TIMES:
{
double f_position = (double)va_arg( args, double );
mtime_t i_time = (mtime_t)va_arg( args, mtime_t );
mtime_t i_length = (mtime_t)va_arg( args, mtime_t );
p_cmd->control.times.f_position = f_position;
p_cmd->control.times.i_time = i_time;
p_cmd->control.times.i_length = i_length;
break;
}
default:
assert(0);
......@@ -1405,16 +1424,19 @@ static int CmdExecuteControl( es_out_t *p_out, ts_cmd_t *p_cmd )
return es_out_Control( p_out, i_query, p_cmd->control.i_i64 );
case ES_OUT_SET_GROUP_PCR: /* arg1= int i_group, arg2=int64_t i_pcr(microsecond!)*/
return es_out_Control( p_out, i_query, p_cmd->control.int_i64.i_int, p_cmd->control.int_i64.i_i64 );
return es_out_Control( p_out, i_query, p_cmd->control.int_i64.i_int,
p_cmd->control.int_i64.i_i64 );
case ES_OUT_RESET_PCR: /* no arg */
return es_out_Control( p_out, i_query );
case ES_OUT_SET_GROUP_META: /* arg1=int i_group arg2=vlc_meta_t* */
return es_out_Control( p_out, i_query, p_cmd->control.int_meta.i_int, p_cmd->control.int_meta.p_meta );
return es_out_Control( p_out, i_query, p_cmd->control.int_meta.i_int,
p_cmd->control.int_meta.p_meta );
case ES_OUT_SET_GROUP_EPG: /* arg1=int i_group arg2=vlc_epg_t* */
return es_out_Control( p_out, i_query, p_cmd->control.int_epg.i_int, p_cmd->control.int_epg.p_epg );
return es_out_Control( p_out, i_query, p_cmd->control.int_epg.i_int,
p_cmd->control.int_epg.p_epg );
/* Modified control */
case ES_OUT_SET_ES: /* arg1= es_out_id_t* */
......@@ -1423,10 +1445,17 @@ static int CmdExecuteControl( es_out_t *p_out, ts_cmd_t *p_cmd )
return es_out_Control( p_out, i_query, p_cmd->control.p_es->p_es );
case ES_OUT_SET_ES_STATE:/* arg1= es_out_id_t* arg2=bool */
return es_out_Control( p_out, i_query, p_cmd->control.es_bool.p_es->p_es, p_cmd->control.es_bool.b_bool );
return es_out_Control( p_out, i_query, p_cmd->control.es_bool.p_es->p_es,
p_cmd->control.es_bool.b_bool );
case ES_OUT_SET_ES_FMT: /* arg1= es_out_id_t* arg2=es_format_t* */
return es_out_Control( p_out, i_query, p_cmd->control.es_fmt.p_es->p_es, p_cmd->control.es_fmt.p_fmt );
return es_out_Control( p_out, i_query, p_cmd->control.es_fmt.p_es->p_es,
p_cmd->control.es_fmt.p_fmt );
case ES_OUT_SET_TIMES:
return es_out_Control( p_out, i_query, p_cmd->control.times.f_position,
p_cmd->control.times.i_time,
p_cmd->control.times.i_length );
default:
assert(0);
......
......@@ -38,22 +38,23 @@ static void Trigger( input_thread_t *p_input, int i_type );
/*****************************************************************************
* Event for input.c
*****************************************************************************/
void input_SendEventTimes( input_thread_t *p_input, const input_event_times_t *p_times )
void input_SendEventTimes( input_thread_t *p_input,
double f_position, mtime_t i_time, mtime_t i_length )
{
vlc_value_t val;
/* */
val.f_float = p_times->f_position;
val.f_float = f_position;
var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
/* */
val.i_time = p_times->i_time;
val.i_time = i_time;
var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
/* FIXME ugly + what about meta change event ? */
if( var_GetTime( p_input, "length" ) != p_times->i_length )
input_item_SetDuration( p_input->p->input.p_item, p_times->i_length );
val.i_time = p_times->i_length;
if( var_GetTime( p_input, "length" ) != i_length )
input_item_SetDuration( p_input->p->input.p_item, i_length );
val.i_time = i_length;
var_Change( p_input, "length", VLC_VAR_SETVALUE, &val, NULL );
Trigger( p_input, INPUT_EVENT_TIMES );
......
......@@ -33,14 +33,7 @@
/*****************************************************************************
* Event for input.c
*****************************************************************************/
typedef struct
{
double f_position;
mtime_t i_time;
mtime_t i_length;
} input_event_times_t;
void input_SendEventTimes( input_thread_t *p_input, const input_event_times_t *p_times );
void input_SendEventTimes( input_thread_t *p_input, double f_position, mtime_t i_time, mtime_t i_length );
void input_SendEventStatistics( input_thread_t *p_input );
void input_SendEventRate( input_thread_t *p_input, int i_rate );
void input_SendEventAudioDelay( input_thread_t *p_input, mtime_t i_delay );
......
......@@ -644,26 +644,24 @@ static void MainLoopDemux( input_thread_t *p_input, bool *pb_changed, mtime_t *p
*/
static void MainLoopInterface( input_thread_t *p_input )
{
input_event_times_t ev;
ev.f_position = 0.0;
ev.i_time = 0;
ev.i_length = 0;
double f_position = 0.0;
mtime_t i_time = 0;
mtime_t i_length = 0;
/* update input status variables */
if( demux_Control( p_input->p->input.p_demux,
DEMUX_GET_POSITION, &ev.f_position ) )
ev.f_position = 0.0;
DEMUX_GET_POSITION, &f_position ) )
f_position = 0.0;
if( demux_Control( p_input->p->input.p_demux,
DEMUX_GET_TIME, &ev.i_time ) )
ev.i_time = 0;
DEMUX_GET_TIME, &i_time ) )
i_time = 0;
if( demux_Control( p_input->p->input.p_demux,
DEMUX_GET_LENGTH, &ev.i_length ) )
ev.i_length = 0;
DEMUX_GET_LENGTH, &i_length ) )
i_length = 0;
input_SendEventTimes( p_input, &ev );
es_out_SetTimes( p_input->p->p_es_out, f_position, i_time, i_length );
}
/**
......@@ -1165,15 +1163,13 @@ static int Init( input_thread_t * p_input )
/* Load master infos */
/* Init length */
input_event_times_t ev_times;
ev_times.f_position = 0;
ev_times.i_time = 0;
mtime_t i_length;
if( demux_Control( p_input->p->input.p_demux, DEMUX_GET_LENGTH,
&ev_times.i_length ) )
ev_times.i_length = 0;
if( ev_times.i_length <= 0 )
ev_times.i_length = input_item_GetDuration( p_input->p->input.p_item );
input_SendEventTimes( p_input, &ev_times );
&i_length ) )
i_length = 0;
if( i_length <= 0 )
i_length = input_item_GetDuration( p_input->p->input.p_item );
input_SendEventTimes( p_input, 0.0, 0, i_length );
StartTitle( p_input );
......
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