Commit b2147ab9 authored by Christophe Massiot's avatar Christophe Massiot

* src/input: Added a --programs configuration option, allowing to select

   several coma-separated programs.
parent 289b82b0
......@@ -33,7 +33,8 @@ enum es_out_mode_e
{
ES_OUT_MODE_NONE, /* don't select anything */
ES_OUT_MODE_ALL, /* eg for stream output */
ES_OUT_MODE_AUTO /* best audio/video or for input follow audio-channel, spu-channel */
ES_OUT_MODE_AUTO, /* best audio/video or for input follow audio-channel, spu-channel */
ES_OUT_MODE_PARTIAL /* select programs given after --programs */
};
enum es_out_query_e
......
......@@ -73,6 +73,7 @@ struct es_out_sys_t
/* all programs */
int i_pgrm;
es_out_pgrm_t **pgrm;
es_out_pgrm_t **pp_selected_pgrm; /* --programs */
es_out_pgrm_t *p_pgrm; /* Master program */
/* all es */
......@@ -423,7 +424,7 @@ static es_out_id_t *EsOutAdd( es_out_t *out, es_format_t *fmt )
if( fmt->i_group < 0 )
{
msg_Err( p_input, "invakud group number" );
msg_Err( p_input, "invalid group number" );
return NULL;
}
......@@ -619,6 +620,22 @@ static void EsOutSelect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_force )
if( !es->p_dec )
EsSelect( out, es );
}
else if( p_sys->i_mode == ES_OUT_MODE_PARTIAL )
{
vlc_value_t val;
int i;
var_Get( p_sys->p_input, "programs", &val );
for ( i = 0; i < val.p_list->i_count; i++ )
{
if ( val.p_list->p_values[i].i_int == es->p_pgrm->i_id || b_force )
{
if( !es->p_dec )
EsSelect( out, es );
break;
}
}
var_Change( p_sys->p_input, "programs", VLC_VAR_FREELIST, &val, NULL );
}
else if( p_sys->i_mode == ES_OUT_MODE_AUTO )
{
int i_wanted = -1;
......@@ -843,7 +860,7 @@ static int EsOutControl( es_out_t *out, int i_query, va_list args )
case ES_OUT_SET_MODE:
i = (int) va_arg( args, int );
if( i == ES_OUT_MODE_NONE || i == ES_OUT_MODE_ALL ||
i == ES_OUT_MODE_AUTO )
i == ES_OUT_MODE_AUTO || i == ES_OUT_MODE_PARTIAL )
{
p_sys->i_mode = i;
......
......@@ -514,6 +514,7 @@ static int Init( input_thread_t * p_input )
vlc_value_t val;
double f_fps;
vlc_meta_t *p_meta, *p_meta_user;
int i_es_out_mode;
int i, i_delay;
/* Initialize optional stream output. (before access/demuxer) */
......@@ -745,20 +746,45 @@ static int Init( input_thread_t * p_input )
/* Set up es_out */
es_out_Control( p_input->p_es_out, ES_OUT_SET_ACTIVE, VLC_TRUE );
val.b_bool = VLC_FALSE;
i_es_out_mode = ES_OUT_MODE_AUTO;
val.p_list = NULL;
if( p_input->p_sout )
{
var_Get( p_input, "sout-all", &val );
if ( val.b_bool )
{
i_es_out_mode = ES_OUT_MODE_ALL;
val.p_list = NULL;
}
else
{
var_Get( p_input, "programs", &val );
if ( val.p_list && val.p_list->i_count )
{
i_es_out_mode = ES_OUT_MODE_PARTIAL;
/* Note : we should remove the "program" callback. */
}
else
var_Change( p_input, "programs", VLC_VAR_FREELIST, &val, NULL );
}
}
es_out_Control( p_input->p_es_out, ES_OUT_SET_MODE,
val.b_bool ? ES_OUT_MODE_ALL : ES_OUT_MODE_AUTO );
es_out_Control( p_input->p_es_out, ES_OUT_SET_MODE, i_es_out_mode );
/* Inform the demuxer about waited group (needed only for DVB) */
if( val.b_bool )
demux2_Control( p_input->input.p_demux, DEMUX_SET_GROUP, -1 );
if( i_es_out_mode == ES_OUT_MODE_ALL )
{
demux2_Control( p_input->input.p_demux, DEMUX_SET_GROUP, -1, NULL );
}
else if( i_es_out_mode == ES_OUT_MODE_PARTIAL )
{
demux2_Control( p_input->input.p_demux, DEMUX_SET_GROUP, -1,
val.p_list );
}
else
{
demux2_Control( p_input->input.p_demux, DEMUX_SET_GROUP,
(int) var_GetInteger( p_input, "program" ) );
(int) var_GetInteger( p_input, "program" ), NULL );
}
if( p_input->p_sout )
{
......@@ -1265,7 +1291,8 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type,
es_out_Control( p_input->p_es_out,
ES_OUT_SET_GROUP, val.i_int );
demux2_Control( p_input->input.p_demux, DEMUX_SET_GROUP, val.i_int );
demux2_Control( p_input->input.p_demux, DEMUX_SET_GROUP, val.i_int,
NULL );
break;
case INPUT_CONTROL_SET_ES:
......
......@@ -130,6 +130,11 @@ void input_ControlVarInit ( input_thread_t *p_input )
var_Change( p_input, "program", VLC_VAR_SETTEXT, &text, NULL );
var_AddCallback( p_input, "program", ProgramCallback, NULL );
/* Programs */
var_Create( p_input, "programs", VLC_VAR_LIST | VLC_VAR_DOINHERIT );
text.psz_string = _("Programs");
var_Change( p_input, "programs", VLC_VAR_SETTEXT, &text, NULL );
/* Title */
var_Create( p_input, "title", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
text.psz_string = _("Title");
......
......@@ -281,6 +281,11 @@ static char *ppsz_align_descriptions[] =
#define INPUT_PROGRAM_LONGTEXT N_( \
"Choose the program to select by giving its Service ID.")
#define INPUT_PROGRAMS_TEXT N_("Choose programs")
#define INPUT_PROGRAMS_LONGTEXT N_( \
"Choose the programs to select by giving a comma-separated list of" \
"SIDs.")
#define INPUT_AUDIO_TEXT N_("Choose audio")
#define INPUT_AUDIO_LONGTEXT N_( \
"Give the default type of audio you want to use in a DVD. " \
......@@ -890,6 +895,8 @@ vlc_module_begin();
add_integer( "program", 0, NULL,
INPUT_PROGRAM_TEXT, INPUT_PROGRAM_LONGTEXT, VLC_TRUE );
add_string( "programs", "", NULL,
INPUT_PROGRAMS_TEXT, INPUT_PROGRAMS_LONGTEXT, VLC_FALSE );
add_integer( "audio-type", -1, NULL,
INPUT_AUDIO_TEXT, INPUT_AUDIO_LONGTEXT, VLC_TRUE );
add_integer( "audio-channel", -1, 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