* 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
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 )
/* 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,
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 )
{
/* 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,
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
*****************************************************************************
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++ )
{
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 )
{
{
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 )
{
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 )
{
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 );
}
}