]> git.sesse.net Git - vlc/commitdiff
* src/input: Added a --programs configuration option, allowing to select
authorChristophe Massiot <massiot@videolan.org>
Fri, 22 Oct 2004 13:49:14 +0000 (13:49 +0000)
committerChristophe Massiot <massiot@videolan.org>
Fri, 22 Oct 2004 13:49:14 +0000 (13:49 +0000)
   several coma-separated programs.

include/vlc_es_out.h
src/input/es_out.c
src/input/input.c
src/input/var.c
src/libvlc.h

index 01bc37f3d84565ec83e9679b56c7d2eea0e7fce3..5b6c4f6994657496959ad1c0bc584dea94102c8b 100644 (file)
@@ -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
index 8d7e76ff5991bb344aa3b29ee7cf8dcc0277d0a7..7273dd72f1a6c0a4b1e9954395fdf0a6dd0032b3 100644 (file)
@@ -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;
 
index fd6fe7a065c7a98ed018aec417a312e99a9798b0..f3722188ced90edd842e6616b8a32a7804708a2d 100644 (file)
@@ -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:
index cc5f5b928f63f0117c4715c7f8a7575bd74e8eb2..d6c217f83db61073544b08cd6d45b8909bd780cd 100644 (file)
@@ -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");
index 73215caafdd2c12a1194fd0eeff65f7cc21bed8d..8b0cfefd15142a23cda1112a852f83b6a782b3da 100644 (file)
@@ -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,