]> git.sesse.net Git - vlc/blobdiff - src/input/input_programs.c
* ./include/threads.h: support for the State Threads Library, a userland
[vlc] / src / input / input_programs.c
index 78e2378ee723788a20430d20c8254085689b25b5..9d4c23593e338d98bc232af3fc1906b4805baed4 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.66 2001/11/28 15:08:06 massiot Exp $
+ * $Id: input_programs.c,v 1.71 2002/02/19 00:50:19 sam Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include "defs.h"
-
 #include <stdlib.h>
 #include <string.h>                                    /* memcpy(), memset() */
 #include <sys/types.h>                                              /* off_t */
 
-#include "config.h"
-#include "common.h"
-#include "intf_msg.h"
-#include "threads.h"
-#include "mtime.h"
-#include "debug.h"
+#include <videolan/vlc.h>
 
 #include "stream_control.h"
 #include "input_ext-intf.h"
 #include "input_ext-dec.h"
 #include "input_ext-plugins.h"
 
-#include "main.h"                                     /* --noaudio --novideo */
+#include "debug.h"
 
 /*
  * NOTICE : all of these functions expect you to have taken the lock on
@@ -65,7 +58,9 @@ int input_InitStream( input_thread_t * p_input, size_t i_data_len )
     p_input->stream.p_removed_es = NULL;
     p_input->stream.p_newly_selected_es = NULL;
     p_input->stream.pp_programs = NULL;
-
+    p_input->stream.p_selected_program = NULL;
+    p_input->stream.p_new_program = NULL;
+    
     if( i_data_len )
     {
         if ( (p_input->stream.p_demux_data = malloc( i_data_len )) == NULL )
@@ -147,8 +142,6 @@ pgrm_descriptor_t * input_AddProgram( input_thread_t * p_input,
     /* Where to add the pgrm */
     int i_pgrm_index = p_input->stream.i_pgrm_number;
 
-    intf_DbgMsg("Adding description for pgrm %d", i_pgrm_id);
-
     /* Add an entry to the list of program associated with the stream */
     p_input->stream.i_pgrm_number++;
     p_input->stream.pp_programs = realloc( p_input->stream.pp_programs,
@@ -213,8 +206,6 @@ void input_DelProgram( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm )
 
     ASSERT( p_pgrm );
 
-    intf_DbgMsg("Deleting description for pgrm %d", p_pgrm->i_number);
-
     /* Free the structures that describe the es that belongs to that program */
     while( p_pgrm->i_es_number )
     {
@@ -264,8 +255,6 @@ input_area_t * input_AddArea( input_thread_t * p_input )
     /* Where to add the pgrm */
     int i_area_index = p_input->stream.i_area_nb;
 
-    intf_DbgMsg("Adding description for area %d", i_area_index );
-
     /* Add an entry to the list of program associated with the stream */
     p_input->stream.i_area_nb++;
     p_input->stream.pp_areas = realloc( p_input->stream.pp_areas,
@@ -300,6 +289,29 @@ input_area_t * input_AddArea( input_thread_t * p_input )
     return p_input->stream.pp_areas[i_area_index];
 }
 
+/*****************************************************************************
+ * input_SetProgram: changes the current program
+ *****************************************************************************/
+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 ++ )
+    {
+        input_UnselectES( p_input , old_prg->pp_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] );
+    }
+
+    p_input->stream.p_selected_program = p_new_prg;
+
+    return( 0 );
+}
+
+
 /*****************************************************************************
  * input_DelArea: destroy a area descriptor
  *****************************************************************************
@@ -311,8 +323,6 @@ void input_DelArea( input_thread_t * p_input, input_area_t * p_area )
 
     ASSERT( p_area );
 
-    intf_DbgMsg("Deleting description for area %d", p_area->i_id );
-
     /* Find the area in the areas table */
     for( i_area_index = 0; i_area_index < p_input->stream.i_area_nb;
          i_area_index++ )
@@ -372,8 +382,6 @@ es_descriptor_t * input_AddES( input_thread_t * p_input,
 {
     es_descriptor_t * p_es;
 
-    intf_DbgMsg("Adding description for ES 0x%x", i_es_id);
-
     p_es = (es_descriptor_t *)malloc( sizeof(es_descriptor_t) );
     if( p_es == NULL )
     {
@@ -515,13 +523,11 @@ int input_SelectES( input_thread_t * p_input, es_descriptor_t * p_es )
 {
     if( p_es == NULL )
     {
-        intf_ErrMsg( "Nothing to do in input_SelectES" );
+        intf_ErrMsg( "input error: nothing to do in input_SelectES" );
         return -1;
     }
 
-#ifdef TRACE_INPUT
-    intf_DbgMsg( "Selecting ES 0x%x", p_es->i_id );
-#endif
+    intf_WarnMsg( 4, "input: selecting ES 0x%x", p_es->i_id );
 
     if( p_es->p_decoder_fifo != NULL )
     {
@@ -589,9 +595,7 @@ int input_UnselectES( input_thread_t * p_input, es_descriptor_t * p_es )
         return -1;
     }
 
-#ifdef TRACE_INPUT
-    intf_DbgMsg( "Unselecting ES 0x%x", p_es->i_id );
-#endif
+    intf_WarnMsg( 4, "input: unselecting ES 0x%x", p_es->i_id );
 
     if( p_es->p_decoder_fifo == NULL )
     {
@@ -622,9 +626,7 @@ int input_UnselectES( input_thread_t * p_input, es_descriptor_t * p_es )
 
         if( p_input->stream.pp_selected_es == NULL )
         {
-#ifdef TRACE_INPUT
-            intf_DbgMsg( "No more selected ES in input_UnselectES" );
-#endif
+            intf_WarnMsg( 4, "input: no more selected ES in input_UnselectES" );
             return( 1 );
         }
     }