* input_programs.c: es_descriptor_t, pgrm_descriptor_t management
*****************************************************************************
* Copyright (C) 1999-2002 VideoLAN
- * $Id: input_programs.c,v 1.118 2003/08/17 20:39:08 fenrir Exp $
+ * $Id: input_programs.c,v 1.125 2003/11/29 11:12:46 fenrir Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
static int ESCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
+static es_format_t null_es_format = {0};
+
/*****************************************************************************
* input_InitStream: init the stream descriptor of the given input
*****************************************************************************/
p_input->stream.i_pgrm_number,
i_pgrm_index );
+ if( p_pgrm == p_input->stream.p_selected_program )
+ p_input->stream.p_selected_program = NULL;
+
/* Free the description of this program */
free( p_pgrm );
}
}
if( text2.psz_string ) free( text2.psz_string );
+ free( val.psz_string );
}
if( p_input->stream.i_area_nb == 2 )
i_es_index ++ )
{
#define p_es p_input->stream.p_selected_program->pp_es[i_es_index]
- if ( p_es->p_decoder_fifo ) /* if the ES was selected */
+ if ( p_es->p_dec ) /* if the ES was selected */
{
input_UnselectES( p_input , p_es );
}
switch( p_new_prg->pp_es[i_es_index]->i_cat )
{
case VIDEO_ES:
- msg_Dbg( p_input, "selecting ES %x",
+ msg_Dbg( p_input, "selecting video 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;
i_audio_es += 1;
if( i_audio_es <= i_required_audio_es )
{
- msg_Dbg( p_input, "selecting ES %x",
+ msg_Dbg( p_input, "selecting audio ES %x",
p_new_prg->pp_es[i_es_index]->i_id );
input_SelectES( p_input, p_new_prg->pp_es[i_es_index]);
}
i_spu_es += 1;
if( i_spu_es <= i_required_spu_es )
{
- msg_Dbg( p_input, "selecting ES %x",
+ msg_Dbg( p_input, "selecting spu ES %x",
p_new_prg->pp_es[i_es_index]->i_id );
input_SelectES( p_input, p_new_prg->pp_es[i_es_index] );
}
}
-
p_input->stream.p_selected_program = p_new_prg;
/* Update the navigation variables without triggering a callback */
sprintf( val.psz_string, "title %i", p_area->i_id );
var_Change( p_input, "navigation", VLC_VAR_DELCHOICE, &val, NULL );
var_Destroy( p_input, val.psz_string );
+
+ free( val.psz_string );
}
/* Remove this area from the stream's list of areas */
/* Init its values */
p_es->i_id = i_es_id;
p_es->p_pes = NULL;
- p_es->p_decoder_fifo = NULL;
+ p_es->p_dec = NULL;
p_es->i_cat = i_category;
p_es->i_demux_fd = 0;
p_es->c_packets = 0;
p_es->c_invalid_packets = 0;
p_es->b_force_decoder = VLC_FALSE;
+ p_es->fmt = null_es_format;
if( i_data_len )
{
}
p_es->p_waveformatex = NULL;
p_es->p_bitmapinfoheader = NULL;
+ p_es->p_spuinfo = NULL;
/* Add this ES to the program definition if one is given */
if( p_pgrm )
}
/* Kill associated decoder, if any. */
- if( p_es->p_decoder_fifo != NULL )
+ if( p_es->p_dec != NULL )
{
input_UnselectES( p_input, p_es );
}
{
free( p_es->p_bitmapinfoheader );
}
+ if( p_es->p_spuinfo )
+ {
+ free( p_es->p_spuinfo );
+ }
/* Free the description string */
if( p_es->psz_desc != NULL )
msg_Dbg( p_input, "selecting ES 0x%x", p_es->i_id );
- if( p_es->p_decoder_fifo != NULL )
+ if( p_es->p_dec != NULL )
{
msg_Err( p_input, "ES 0x%x is already selected", p_es->i_id );
return -1;
/* 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->p_decoder_fifo = input_RunDecoder( p_input, p_es );
+ p_es->p_dec = input_RunDecoder( p_input, p_es );
vlc_mutex_lock( &p_input->stream.stream_lock );
- if( p_es->p_decoder_fifo == NULL )
+ if( p_es->p_dec == NULL )
{
return -1;
}
msg_Dbg( p_input, "unselecting ES 0x%x", p_es->i_id );
- if( p_es->p_decoder_fifo == NULL )
+ if( p_es->p_dec == NULL )
{
msg_Err( p_input, "ES 0x%x is not selected", p_es->i_id );
return( -1 );
input_EndDecoder( p_input, p_es );
p_es->p_pes = NULL;
- if( ( p_es->p_decoder_fifo == NULL ) &&
+ if( ( p_es->p_dec == NULL ) &&
( p_input->stream.i_selected_es_number > 0 ) )
{
while( ( i_index < p_input->stream.i_selected_es_number - 1 ) &&
input_thread_t *p_input = (input_thread_t *)p_this;
unsigned int i;
vlc_value_t val;
+ unsigned int i_cat = UNKNOWN_ES;
+ es_descriptor_t *p_es = NULL;
vlc_mutex_lock( &p_input->stream.stream_lock );
- /* Unselect old ES */
+ /* First search old es type */
+ for( i = 0 ; i < p_input->stream.i_es_number ; i++ )
+ {
+ if( p_input->stream.pp_es[i]->i_id == oldval.i_int )
+ {
+ i_cat = p_input->stream.pp_es[i]->i_cat;
+ }
+ }
+
+ /* Unselect all old ES */
for( i = 0 ; i < p_input->stream.i_es_number ; i++ )
{
- if( p_input->stream.pp_es[i]->i_id == oldval.i_int &&
- p_input->stream.pp_es[i]->p_decoder_fifo != NULL )
+ if( p_input->stream.pp_es[i]->i_cat == i_cat &&
+ p_input->stream.pp_es[i]->i_id != newval.i_int &&
+ p_input->stream.pp_es[i]->p_dec != NULL )
{
input_UnselectES( p_input, p_input->stream.pp_es[i] );
}
/* Select new ES */
for( i = 0 ; i < p_input->stream.i_es_number ; i++ )
{
- if( p_input->stream.pp_es[i]->i_id == newval.i_int &&
- p_input->stream.pp_es[i]->p_decoder_fifo == NULL )
+ if( p_input->stream.pp_es[i]->i_id == newval.i_int )
{
- input_SelectES( p_input, p_input->stream.pp_es[i] );
+ p_es = p_input->stream.pp_es[i];
+ if( p_es->p_dec == NULL )
+ {
+ input_SelectES( p_input, p_es );
+ }
+ }
+ }
+
+ if( p_es )
+ {
+ /* Fix value (mainly for multiple selected ES */
+ val.i_int = p_es->i_id;
+ switch( p_es->i_cat )
+ {
+ case AUDIO_ES:
+ var_Change( p_input, "audio-es", VLC_VAR_SETVALUE, &val, NULL );
+ break;
+ case SPU_ES:
+ var_Change( p_input, "spu-es", VLC_VAR_SETVALUE, &val, NULL );
+ break;
+ case VIDEO_ES:
+ var_Change( p_input, "video-es", VLC_VAR_SETVALUE, &val, NULL );
+ break;
}
}