* input_programs.c: es_descriptor_t, pgrm_descriptor_t management
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
- * $Id: input_programs.c,v 1.67 2001/12/05 03:31:04 jobi Exp $
+ * $Id: input_programs.c,v 1.77 2002/03/28 03:53:15 jobi 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
/* 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,
p_input->stream.pp_areas[i_area_index]->i_seek = NO_SEEK;
p_input->stream.pp_areas[i_area_index]->i_part_nb = 1;
p_input->stream.pp_areas[i_area_index]->i_part= 0;
- p_input->stream.pp_areas[i_area_index]->i_angle_nb = 1;
- p_input->stream.pp_areas[i_area_index]->i_angle = 0;
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;
+
+ if ( p_input->stream.p_selected_program )
+ {
+ 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] );
+ }
+ }
+
+ for (i_es_index = 0 ; i_es_index < p_new_prg->i_es_number ; 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;
+
+ 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 )
{
p_es->p_decoder_fifo = NULL;
p_es->b_audio = 0;
p_es->i_cat = UNKNOWN_ES;
+#ifdef HAVE_SATELLITE
+ p_es->i_dmx_fd = 0;
+#endif
if( i_data_len )
{
{
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 );
}
+ p_es->thread_id = 0;
+
switch( p_es->i_type )
{
case AC3_AUDIO_ES:
case LPCM_AUDIO_ES:
if( p_main->b_audio )
{
- /* This kludge should be removed */
- p_main->b_ac3 = ( p_es->i_type == AC3_AUDIO_ES );
-
/* Release the lock, not to block the input thread during
* the creation of the thread. */
vlc_mutex_unlock( &p_input->stream.stream_lock );
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 )
{
}
input_EndDecoder( p_input, p_es );
+ free( p_es->p_pes );
if( ( p_es->p_decoder_fifo == NULL ) &&
( p_input->stream.i_selected_es_number > 0 ) )
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 );
}
}