Commit b271b9ff authored by Laurent Aimar's avatar Laurent Aimar

Added --run-time option to specify how many second VLC will play an item

(Usefull to save live programs like DVB/UDP)
parent a14c0186
...@@ -147,6 +147,7 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item, ...@@ -147,6 +147,7 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
p_input->p->i_start = 0; p_input->p->i_start = 0;
p_input->i_time = 0; p_input->i_time = 0;
p_input->p->i_stop = 0; p_input->p->i_stop = 0;
p_input->p->i_run = 0;
p_input->p->i_title = 0; p_input->p->i_title = 0;
p_input->p->title = NULL; p_input->p->title = NULL;
p_input->p->i_title_offset = p_input->p->i_seekpoint_offset = 0; p_input->p->i_title_offset = p_input->p->i_seekpoint_offset = 0;
...@@ -573,6 +574,7 @@ exit: ...@@ -573,6 +574,7 @@ exit:
*****************************************************************************/ *****************************************************************************/
static void MainLoop( input_thread_t *p_input ) static void MainLoop( input_thread_t *p_input )
{ {
int64_t i_start_mdate = mdate();
int64_t i_intf_update = 0; int64_t i_intf_update = 0;
int i_updates = 0; int i_updates = 0;
...@@ -586,10 +588,11 @@ static void MainLoop( input_thread_t *p_input ) ...@@ -586,10 +588,11 @@ static void MainLoop( input_thread_t *p_input )
/* Do the read */ /* Do the read */
if( p_input->i_state != PAUSE_S ) if( p_input->i_state != PAUSE_S )
{ {
if( p_input->p->i_stop <= 0 || p_input->i_time < p_input->p->i_stop ) if( ( p_input->p->i_stop > 0 && p_input->i_time >= p_input->p->i_stop ) ||
i_ret=p_input->p->input.p_demux->pf_demux(p_input->p->input.p_demux); ( p_input->p->i_run > 0 && i_start_mdate+p_input->p->i_run < mdate() ) )
i_ret = 0; /* EOF */
else else
i_ret = 0; /* EOF */ i_ret = p_input->p->input.p_demux->pf_demux(p_input->p->input.p_demux);
if( i_ret > 0 ) if( i_ret > 0 )
{ {
...@@ -659,6 +662,9 @@ static void MainLoop( input_thread_t *p_input ) ...@@ -659,6 +662,9 @@ static void MainLoop( input_thread_t *p_input )
input_ControlPush( p_input, INPUT_CONTROL_SET_POSITION, input_ControlPush( p_input, INPUT_CONTROL_SET_POSITION,
&val ); &val );
} }
/* */
i_start_mdate = mdate();
} }
} }
else if( i_ret < 0 ) else if( i_ret < 0 )
...@@ -915,10 +921,14 @@ static int Init( input_thread_t * p_input ) ...@@ -915,10 +921,14 @@ static int Init( input_thread_t * p_input )
/* Start time*/ /* Start time*/
/* Set start time */ /* Set start time */
p_input->p->i_start = (int64_t)var_GetInteger( p_input, "start-time" ) * p_input->p->i_start = I64C(1000000) * var_GetInteger( p_input, "start-time" );
I64C(1000000); p_input->p->i_stop = I64C(1000000) * var_GetInteger( p_input, "stop-time" );
p_input->p->i_stop = (int64_t)var_GetInteger( p_input, "stop-time" ) * p_input->p->i_run = I64C(1000000) * var_GetInteger( p_input, "run-time" );
I64C(1000000); if( p_input->p->i_run < 0 )
{
msg_Warn( p_input, "invalid run-time ignored" );
p_input->p->i_run = 0;
}
if( p_input->p->i_start > 0 ) if( p_input->p->i_start > 0 )
{ {
......
...@@ -75,6 +75,7 @@ struct input_thread_private_t ...@@ -75,6 +75,7 @@ struct input_thread_private_t
/* */ /* */
int64_t i_start; /* :start-time,0 by default */ int64_t i_start; /* :start-time,0 by default */
int64_t i_stop; /* :stop-time, 0 if none */ int64_t i_stop; /* :stop-time, 0 if none */
int64_t i_run; /* :run-time, 0 if none */
/* Title infos FIXME multi-input (not easy) ? */ /* Title infos FIXME multi-input (not easy) ? */
int i_title; int i_title;
......
...@@ -432,6 +432,7 @@ void input_ConfigVarInit ( input_thread_t *p_input ) ...@@ -432,6 +432,7 @@ void input_ConfigVarInit ( input_thread_t *p_input )
VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
var_Create( p_input, "start-time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); 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, "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-slave", var_Create( p_input, "input-slave",
VLC_VAR_STRING | VLC_VAR_DOINHERIT ); VLC_VAR_STRING | VLC_VAR_DOINHERIT );
......
...@@ -531,6 +531,10 @@ static const char *ppsz_clock_descriptions[] = ...@@ -531,6 +531,10 @@ static const char *ppsz_clock_descriptions[] =
#define STOP_TIME_LONGTEXT N_( \ #define STOP_TIME_LONGTEXT N_( \
"The stream will stop at this position (in seconds)." ) "The stream will stop at this position (in seconds)." )
#define RUN_TIME_TEXT N_("Run time")
#define RUN_TIME_LONGTEXT N_( \
"The stream will run this duration (in seconds)." )
#define INPUT_LIST_TEXT N_("Input list") #define INPUT_LIST_TEXT N_("Input list")
#define INPUT_LIST_LONGTEXT N_( \ #define INPUT_LIST_LONGTEXT N_( \
"You can give a comma-separated list " \ "You can give a comma-separated list " \
...@@ -1454,6 +1458,8 @@ vlc_module_begin(); ...@@ -1454,6 +1458,8 @@ vlc_module_begin();
START_TIME_TEXT, START_TIME_LONGTEXT, VLC_TRUE ); START_TIME_TEXT, START_TIME_LONGTEXT, VLC_TRUE );
add_integer( "stop-time", 0, NULL, add_integer( "stop-time", 0, NULL,
STOP_TIME_TEXT, STOP_TIME_LONGTEXT, VLC_TRUE ); STOP_TIME_TEXT, STOP_TIME_LONGTEXT, VLC_TRUE );
add_integer( "run-time", 0, NULL,
RUN_TIME_TEXT, RUN_TIME_LONGTEXT, VLC_TRUE );
add_string( "input-list", NULL, NULL, add_string( "input-list", NULL, NULL,
INPUT_LIST_TEXT, INPUT_LIST_LONGTEXT, VLC_TRUE ); INPUT_LIST_TEXT, INPUT_LIST_LONGTEXT, VLC_TRUE );
add_string( "input-slave", NULL, NULL, 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