]> git.sesse.net Git - vlc/commitdiff
* fixed some bugs in program management : selected ESs must be attached
authorJohan Bilien <jobi@videolan.org>
Tue, 19 Mar 2002 23:02:29 +0000 (23:02 +0000)
committerJohan Bilien <jobi@videolan.org>
Tue, 19 Mar 2002 23:02:29 +0000 (23:02 +0000)
to the selected program.

src/input/input_programs.c
src/input/mpeg_system.c

index 81231ea2d79ae033a4a63e46c934abfb450c9836..5557674a9d699e9a559d9a490edbb0db383036ee 100644 (file)
@@ -2,7 +2,7 @@
  * input_programs.c: es_descriptor_t, pgrm_descriptor_t management
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: input_programs.c,v 1.74 2002/03/12 18:37:46 stef Exp $
+ * $Id: input_programs.c,v 1.75 2002/03/19 23:02:29 jobi Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -293,16 +293,104 @@ input_area_t * input_AddArea( input_thread_t * p_input )
 int input_SetProgram( input_thread_t * p_input, pgrm_descriptor_t * p_new_prg )
 {
     int i_es_index;
-#define old_prg p_input->stream.p_selected_program
-    for ( i_es_index = 0 ; i_es_index < old_prg->i_es_number ; i_es_index ++ )
+    
+    if ( p_input->stream.p_selected_program )
     {
-        input_UnselectES( p_input , old_prg->pp_es[i_es_index] );
+        for ( i_es_index = 0 ; 
+                i_es_index < p_input->stream.i_selected_es_number; 
+                i_es_index ++ )
+        {
+            intf_WarnMsg( 4, "Unselecting ES %d", 
+                    p_input->stream.pp_selected_es[i_es_index]->i_id );
+            input_UnselectES( p_input , 
+                    p_input->stream.pp_selected_es[i_es_index] );
+        }
     }
-#undef old_prg
+
     for (i_es_index = 0 ; i_es_index < p_new_prg->i_es_number ; i_es_index ++ )
     {
-        input_SelectES( p_input , p_new_prg->pp_es[i_es_index] );
+        int i_required_audio_es;
+        int i_required_spu_es;
+        int i_audio_es = 0;
+        int i_spu_es = 0;
+
+        /* Get the number of the required audio stream */
+        if( p_main->b_audio )
+        {
+            /* Default is the first one */
+            i_required_audio_es = config_GetIntVariable( "input_channel" );
+            if( i_required_audio_es < 0 )
+            {
+                i_required_audio_es = 1;
+            }
+        }
+        else
+        {
+            i_required_audio_es = 0;
+        }
+
+        /* Same thing for subtitles */
+        if( p_main->b_video )
+        {
+            /* for spu, default is none */
+            i_required_spu_es = config_GetIntVariable( "input_subtitle" );
+            if( i_required_spu_es < 0 )
+            {
+                i_required_spu_es = 0;
+            }
+        }
+        else
+        {
+            i_required_spu_es = 0;
+        }
+        switch( p_new_prg->pp_es[i_es_index]->i_cat )
+                    {
+                        case MPEG1_VIDEO_ES:
+                        case MPEG2_VIDEO_ES:
+                            intf_WarnMsg( 4, "Selecting ES %x", 
+                                    p_new_prg->pp_es[i_es_index]->i_id );
+                            input_SelectES( p_input, 
+                                   p_new_prg->pp_es[i_es_index] );
+                            break;
+                        case MPEG1_AUDIO_ES:
+                        case MPEG2_AUDIO_ES:
+                            i_audio_es += 1;
+                            if( i_audio_es == i_required_audio_es )
+                            {
+                                intf_WarnMsg( 4, "Selecting ES %x", 
+                                    p_new_prg->pp_es[i_es_index]->i_id );   
+                                input_SelectES( p_input, 
+                                    p_new_prg->pp_es[i_es_index]);
+                            }
+                            break;
+                        case LPCM_AUDIO_ES :
+                        case AC3_AUDIO_ES :
+                            i_audio_es += 1;
+                            if( i_audio_es == i_required_audio_es )
+                            {
+                                intf_WarnMsg( 4, "Selecting ES %x", 
+                                    p_new_prg->pp_es[i_es_index]->i_id );
+                                input_SelectES( p_input, 
+                                    p_new_prg->pp_es[i_es_index] );
+                            }
+                            break;
+                        /* Not sure this one is fully specification-compliant */
+                        case DVD_SPU_ES :
+                            i_spu_es += 1;
+                            if( i_spu_es == i_required_spu_es )
+                            {
+                                intf_WarnMsg( 4, "Selecting ES %x", 
+                                    p_new_prg->pp_es[i_es_index]->i_id );
+                                input_SelectES( p_input, 
+                                    p_new_prg->pp_es[i_es_index] );
+                            }
+                            break;
+                        default :
+                            break;
+                    }
+
     }
+    
 
     p_input->stream.p_selected_program = p_new_prg;
 
index 08fc6e9a2dacf045f9b276f0c93651ebd2d6cabe..0b3d9bbd1ff88469bd658b701d98d3d10e2c24fa 100644 (file)
@@ -2,7 +2,7 @@
  * mpeg_system.c: TS, PS and PES management
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: mpeg_system.c,v 1.85 2002/03/17 17:00:38 sam Exp $
+ * $Id: mpeg_system.c,v 1.86 2002/03/19 23:02:29 jobi Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Michel Lespinasse <walken@via.ecp.fr>
@@ -1590,7 +1590,10 @@ static void input_DecodePAT( input_thread_t * p_input, es_descriptor_t * p_es )
 #undef p_psi    
 
     /* FIXME This has nothing to do here */
-    p_input->stream.p_selected_program = p_input->stream.pp_programs[0] ;
+    if( !p_input->stream.p_selected_program )
+    {
+        input_SetProgram( p_input, p_input->stream.pp_programs[0] );
+    }
 }
 
 /*****************************************************************************
@@ -1708,39 +1711,42 @@ static void input_DecodePMT( input_thread_t * p_input, es_descriptor_t * p_es )
 
                 /* Tell the interface what kind of stream it is and select 
                  * the required ones */
-                switch( i_stream_type )
+                if ( p_input->stream.p_selected_program == p_new_es->p_pgrm )
                 {
-                    case MPEG1_VIDEO_ES:
-                    case MPEG2_VIDEO_ES:
-                        p_new_es->i_cat = VIDEO_ES;
-                        input_SelectES( p_input, p_new_es );
-                        break;
-                    case MPEG1_AUDIO_ES:
-                    case MPEG2_AUDIO_ES:
-                        p_new_es->i_cat = AUDIO_ES;
-                        i_audio_es += 1;
-                        if( i_audio_es == i_required_audio_es )
-                            input_SelectES( p_input, p_new_es );
-                        break;
-                    case LPCM_AUDIO_ES :
-                    case AC3_AUDIO_ES :
-                        p_new_es->i_stream_id = 0xBD;
-                        p_new_es->i_cat = AUDIO_ES;
-                        i_audio_es += 1;
-                        if( i_audio_es == i_required_audio_es )
-                            input_SelectES( p_input, p_new_es );
-                        break;
-                    /* Not sure this one is fully specification-compliant */
-                    case DVD_SPU_ES :
-                        p_new_es->i_stream_id = 0xBD;
-                        p_new_es->i_cat = SPU_ES;
-                        i_spu_es += 1;
-                        if( i_spu_es == i_required_spu_es )
+                    switch( i_stream_type )
+                    {
+                        case MPEG1_VIDEO_ES:
+                        case MPEG2_VIDEO_ES:
+                            p_new_es->i_cat = VIDEO_ES;
                             input_SelectES( p_input, p_new_es );
-                        break;
-                    default :
-                        p_new_es->i_cat = UNKNOWN_ES;
-                        break;
+                            break;
+                        case MPEG1_AUDIO_ES:
+                        case MPEG2_AUDIO_ES:
+                            p_new_es->i_cat = AUDIO_ES;
+                            i_audio_es += 1;
+                            if( i_audio_es == i_required_audio_es )
+                                input_SelectES( p_input, p_new_es );
+                            break;
+                        case LPCM_AUDIO_ES :
+                        case AC3_AUDIO_ES :
+                            p_new_es->i_stream_id = 0xBD;
+                            p_new_es->i_cat = AUDIO_ES;
+                            i_audio_es += 1;
+                            if( i_audio_es == i_required_audio_es )
+                                input_SelectES( p_input, p_new_es );
+                            break;
+                        /* Not sure this one is fully specification-compliant */
+                        case DVD_SPU_ES :
+                            p_new_es->i_stream_id = 0xBD;
+                            p_new_es->i_cat = SPU_ES;
+                            i_spu_es += 1;
+                            if( i_spu_es == i_required_spu_es )
+                                input_SelectES( p_input, p_new_es );
+                            break;
+                        default :
+                            p_new_es->i_cat = UNKNOWN_ES;
+                            break;
+                    }
                 }
                 
                 p_current_data += 5 + i_es_info_length;