]> git.sesse.net Git - vlc/blobdiff - src/input/input_programs.c
All decoders (audio, video, subtitles) are now modules.
[vlc] / src / input / input_programs.c
index 12c6efcbdf96911d3e70a30ad11714406c827e0d..e903a3efeb32e94764a50a88bf7fb53af7b365a8 100644 (file)
@@ -2,7 +2,7 @@
  * input_programs.c: es_descriptor_t, pgrm_descriptor_t management
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: input_programs.c,v 1.54 2001/05/01 04:18:18 sam Exp $
+ * $Id: input_programs.c,v 1.64 2001/11/13 12:09:18 henri Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -41,7 +41,7 @@
 #include "stream_control.h"
 #include "input_ext-intf.h"
 #include "input_ext-dec.h"
-#include "input.h"
+#include "input_ext-plugins.h"
 
 #include "main.h"                                     /* --noaudio --novideo */
 
@@ -56,7 +56,6 @@
 int input_InitStream( input_thread_t * p_input, size_t i_data_len )
 {
 
-    p_input->stream.i_method = INPUT_METHOD_NONE;
     p_input->stream.i_stream_id = 0;
 
     /* initialized to 0 since we don't give the signal to the interface
@@ -64,6 +63,8 @@ int input_InitStream( input_thread_t * p_input, size_t i_data_len )
     p_input->stream.b_changed = 0;
     p_input->stream.pp_es = NULL;
     p_input->stream.pp_selected_es = NULL;
+    p_input->stream.p_removed_es = NULL;
+    p_input->stream.p_newly_selected_es = NULL;
     p_input->stream.pp_programs = NULL;
 
     if( i_data_len )
@@ -75,6 +76,10 @@ int input_InitStream( input_thread_t * p_input, size_t i_data_len )
         }
         memset( p_input->stream.p_demux_data, 0, i_data_len );
     }
+    else
+    {
+        p_input->stream.p_demux_data = NULL;
+    }
 
     return 0;
 }
@@ -102,6 +107,12 @@ void input_EndStream( input_thread_t * p_input )
         input_DelArea( p_input, p_input->stream.pp_areas[0] );
     }
 
+    /* Free selected ES */
+    if( p_input->stream.pp_selected_es != NULL )
+    {
+        free( p_input->stream.pp_selected_es );
+    }
+    
     if( p_input->stream.p_demux_data != NULL )
     {
         free( p_input->stream.p_demux_data );
@@ -172,9 +183,6 @@ pgrm_descriptor_t * input_AddProgram( input_thread_t * p_input,
     p_input->stream.pp_programs[i_pgrm_index]->i_synchro_state
                                                 = SYNCHRO_START;
 
-    p_input->stream.pp_programs[i_pgrm_index]->p_vout
-                                            = p_input->p_default_vout;
-
     if( i_data_len )
     {
         p_input->stream.pp_programs[i_pgrm_index]->p_demux_data =
@@ -187,6 +195,10 @@ pgrm_descriptor_t * input_AddProgram( input_thread_t * p_input,
         memset( p_input->stream.pp_programs[i_pgrm_index]->p_demux_data, 0,
                 i_data_len );
     }
+    else
+    {
+        p_input->stream.pp_programs[i_pgrm_index]->p_demux_data = NULL;
+    }
 
     return p_input->stream.pp_programs[i_pgrm_index];
 }
@@ -521,7 +533,7 @@ static int InitDecConfig( input_thread_t * p_input, es_descriptor_t * p_es,
     p_config->p_decoder_fifo->pf_delete_pes = p_input->pf_delete_pes;
     p_es->p_decoder_fifo = p_config->p_decoder_fifo;
 
-    p_config->pf_init_bit_stream = InitBitstream;
+    p_config->pf_init_bit_stream = p_input->pf_init_bit_stream;
 
     p_input->stream.i_selected_es_number++;
 
@@ -541,45 +553,20 @@ static int InitDecConfig( input_thread_t * p_input, es_descriptor_t * p_es,
 }
 
 /*****************************************************************************
- * GetVdecConfig: returns a valid vdec_config_t
+ * GetDecConfig: returns a valid decoder_config_t
  *****************************************************************************/
-static vdec_config_t * GetVdecConfig( input_thread_t * p_input,
+static decoder_config_t * GetDecConfig( input_thread_t * p_input,
                                       es_descriptor_t * p_es )
 {
-    vdec_config_t *     p_config;
+    decoder_config_t *     p_config;
 
-    p_config = (vdec_config_t *)malloc( sizeof(vdec_config_t) );
+    p_config = (decoder_config_t *)malloc( sizeof(decoder_config_t) );
     if( p_config == NULL )
     {
-        intf_ErrMsg( "Unable to allocate memory in GetVdecConfig" );
+        intf_ErrMsg( "Unable to allocate memory in GetDecConfig" );
         return( NULL );
     }
-    p_config->p_vout = p_input->p_default_vout;
-    if( InitDecConfig( p_input, p_es, &p_config->decoder_config ) == -1 )
-    {
-        free( p_config );
-        return( NULL );
-    }
-
-    return( p_config );
-}
-
-/*****************************************************************************
- * GetAdecConfig: returns a valid adec_config_t
- *****************************************************************************/
-static adec_config_t * GetAdecConfig( input_thread_t * p_input,
-                                      es_descriptor_t * p_es )
-{
-    adec_config_t *     p_config;
-
-    p_config = (adec_config_t *)malloc( sizeof(adec_config_t));
-    if( p_config == NULL )
-    {
-        intf_ErrMsg( "Unable to allocate memory in GetAdecConfig" );
-        return( NULL );
-    }
-
-    if( InitDecConfig( p_input, p_es, &p_config->decoder_config ) == -1 )
+    if( InitDecConfig( p_input, p_es, p_config ) == -1 )
     {
         free( p_config );
         return( NULL );
@@ -601,11 +588,11 @@ vlc_thread_t ac3spdif_CreateThread( void * );
 vlc_thread_t spdif_CreateThread( void * );
 vlc_thread_t vpar_CreateThread( void * );
 vlc_thread_t spudec_CreateThread( void * );
+vlc_thread_t lpcmdec_CreateThread( void * );
 
 int input_SelectES( input_thread_t * p_input, es_descriptor_t * p_es )
 {
     /* FIXME ! */
-    decoder_capabilities_t  decoder;
     void *                  p_config;
 
     if( p_es == NULL )
@@ -626,91 +613,47 @@ int input_SelectES( input_thread_t * p_input, es_descriptor_t * p_es )
 
     switch( p_es->i_type )
     {
+    case AC3_AUDIO_ES:
     case MPEG1_AUDIO_ES:
     case MPEG2_AUDIO_ES:
+    case LPCM_AUDIO_ES:
         if( p_main->b_audio )
         {
-            decoder.pf_create_thread = adec_CreateThread;
-            p_config = (void *)GetAdecConfig( p_input, p_es );
+            decoder_config_t * p_dec_config;
+            
+            p_dec_config = GetDecConfig( p_input, p_es );            
+            p_config =(void *)p_dec_config;
+            p_dec_config->i_type = p_es->i_type;
+            
+            p_main->b_ac3 = ( p_es->i_type == AC3_AUDIO_ES );
+            /* Useful to Unned decoder module */
+            p_es->p_dec_config = p_dec_config;
 
             /* Release the lock, not to block the input thread during
              * the creation of the thread. */
             vlc_mutex_unlock( &p_input->stream.stream_lock );
-            p_es->thread_id = input_RunDecoder( &decoder, p_config );
+            p_es->thread_id = input_RunDecoder( p_config );
             vlc_mutex_lock( &p_input->stream.stream_lock );
         }
         break;
 
     case MPEG1_VIDEO_ES:
     case MPEG2_VIDEO_ES:
-        if( p_main->b_video )
-        {
-            decoder.pf_create_thread = vpar_CreateThread;
-            p_config = (void *)GetVdecConfig( p_input, p_es );
-
-            /* Release the lock, not to block the input thread during
-             * the creation of the thread. */
-            vlc_mutex_unlock( &p_input->stream.stream_lock );
-            p_es->thread_id = input_RunDecoder( &decoder, p_config );
-            vlc_mutex_lock( &p_input->stream.stream_lock );
-        }
-        break;
-
-    case AC3_AUDIO_ES:
-        if( p_main->b_audio )
-        {
-            if( main_GetIntVariable( AOUT_SPDIF_VAR, 0 ) )
-            {
-                decoder.pf_create_thread = spdif_CreateThread;
-            }
-            else
-            {
-                decoder.pf_create_thread = ac3dec_CreateThread;
-            }
-
-            p_config = (void *)GetAdecConfig( p_input, p_es );
-
-            /* Release the lock, not to block the input thread during
-             * the creation of the thread. */
-            vlc_mutex_unlock( &p_input->stream.stream_lock );
-            p_es->thread_id = input_RunDecoder( &decoder, p_config );
-            vlc_mutex_lock( &p_input->stream.stream_lock );
-        }
-        break;
-#if 0
-    case LPCM_AUDIO_ES:
-        if( p_main->b_audio )
-        {
-            if( p_main->b_spdif )
-            {
-                decoder.pf_create_thread = spdif_CreateThread;
-            }
-            else
-            {
-                intf_ErrMsg( "input error: LPCM audio not handled yet" );
-                break;
-            }
-
-            p_config = (void *)GetAdecConfig( p_input, p_es );
-
-            /* Release the lock, not to block the input thread during
-             * the creation of the thread. */
-            vlc_mutex_unlock( &p_input->stream.stream_lock );
-            p_es->thread_id = input_RunDecoder( &decoder, p_config );
-            vlc_mutex_lock( &p_input->stream.stream_lock );
-        }
-        break;
-#endif
     case DVD_SPU_ES:
         if( p_main->b_video )
         {
-            decoder.pf_create_thread = spudec_CreateThread;
-            p_config = (void *)GetVdecConfig( p_input, p_es );
+            decoder_config_t * p_dec_config;
+
+            p_dec_config = GetDecConfig( p_input, p_es );
+            p_config = (void *)p_dec_config;
+            p_dec_config->i_type = p_es->i_type;
+            /* Useful to Unned decoder module */
+            p_es->p_dec_config = p_dec_config;
 
             /* Release the lock, not to block the input thread during
              * the creation of the thread. */
             vlc_mutex_unlock( &p_input->stream.stream_lock );
-            p_es->thread_id = input_RunDecoder( &decoder, p_config );
+            p_es->thread_id = input_RunDecoder( p_config );
             vlc_mutex_lock( &p_input->stream.stream_lock );
         }
         break;