Commit 1adfba81 authored by Johan Bilien's avatar Johan Bilien

* in TS demux, a program is selected only if a PMT for it was found.

  This should fix the problem that occured when reading a file directly
  extracted from a satellite card.
* UDP access plugin uses input_SetProgram.
parent db10e796
...@@ -45,6 +45,7 @@ N: Johan Bilien ...@@ -45,6 +45,7 @@ N: Johan Bilien
E: jobi@via.ecp.fr E: jobi@via.ecp.fr
C: jobi C: jobi
D: VCD input D: VCD input
D: Satellite input
S: France S: France
N: Julien Blache N: Julien Blache
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* udp.c: raw UDP access plug-in * udp.c: raw UDP access plug-in
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * Copyright (C) 2001, 2002 VideoLAN
* $Id: udp.c,v 1.7 2002/03/29 00:14:19 massiot Exp $ * $Id: udp.c,v 1.8 2002/04/17 17:00:58 jobi Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -51,7 +51,6 @@ ...@@ -51,7 +51,6 @@
*****************************************************************************/ *****************************************************************************/
static void input_getfunctions( function_list_t * ); static void input_getfunctions( function_list_t * );
static int UDPOpen ( struct input_thread_s * ); static int UDPOpen ( struct input_thread_s * );
static int UDPSetProgram ( struct input_thread_s * , pgrm_descriptor_t * );
/***************************************************************************** /*****************************************************************************
* Build configuration tree. * Build configuration tree.
...@@ -85,7 +84,7 @@ static void input_getfunctions( function_list_t * p_function_list ) ...@@ -85,7 +84,7 @@ static void input_getfunctions( function_list_t * p_function_list )
input.pf_open = UDPOpen; input.pf_open = UDPOpen;
input.pf_read = input_FDNetworkRead; input.pf_read = input_FDNetworkRead;
input.pf_close = input_FDClose; input.pf_close = input_FDClose;
input.pf_set_program = UDPSetProgram; input.pf_set_program = input_SetProgram;
input.pf_set_area = NULL; input.pf_set_area = NULL;
input.pf_seek = NULL; input.pf_seek = NULL;
#undef input #undef input
...@@ -277,59 +276,3 @@ static int UDPOpen( input_thread_t * p_input ) ...@@ -277,59 +276,3 @@ static int UDPOpen( input_thread_t * p_input )
return( 0 ); return( 0 );
} }
/*****************************************************************************
* UDPSetProgram: Selects another program
*****************************************************************************/
int UDPSetProgram( 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 = 1 ; /* 0 should be the PMT */
i_es_index < p_input->stream.p_selected_program->
i_es_number ;
i_es_index ++ )
{
#define p_es p_input->stream.p_selected_program->pp_es[i_es_index]
if ( p_es->p_decoder_fifo )
{
input_UnselectES( p_input , p_es );
p_es->p_pes = NULL; /* FIXME */
}
#undef p_es
}
}
for (i_es_index = 1 ; i_es_index < p_new_prg->i_es_number ; i_es_index ++ )
{
#define p_es p_new_prg->pp_es[i_es_index]
switch( p_es->i_cat )
{
case MPEG1_VIDEO_ES:
case MPEG2_VIDEO_ES:
if ( p_main->b_video )
{
input_SelectES( p_input , p_es );
}
break;
case MPEG1_AUDIO_ES:
case MPEG2_AUDIO_ES:
if ( p_main->b_audio )
{
input_SelectES( p_input , p_es );
}
break;
default:
input_SelectES( p_input , p_es );
break;
#undef p_es
}
}
p_input->stream.p_selected_program = p_new_prg;
return( 0 );
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_programs.c: es_descriptor_t, pgrm_descriptor_t management * input_programs.c: es_descriptor_t, pgrm_descriptor_t management
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: input_programs.c,v 1.79 2002/04/10 16:26:21 jobi Exp $ * $Id: input_programs.c,v 1.80 2002/04/17 17:00:58 jobi Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -306,7 +306,7 @@ int input_SetProgram( input_thread_t * p_input, pgrm_descriptor_t * p_new_prg ) ...@@ -306,7 +306,7 @@ int input_SetProgram( input_thread_t * p_input, pgrm_descriptor_t * p_new_prg )
i_es_index ++ ) i_es_index ++ )
{ {
#define p_es p_input->stream.p_selected_program->pp_es[i_es_index] #define p_es p_input->stream.p_selected_program->pp_es[i_es_index]
if ( p_es->p_decoder_fifo ) if ( p_es->p_decoder_fifo ) /* if the ES was selected */
{ {
input_UnselectES( p_input , p_es ); input_UnselectES( p_input , p_es );
} }
...@@ -350,8 +350,7 @@ int input_SetProgram( input_thread_t * p_input, pgrm_descriptor_t * p_new_prg ) ...@@ -350,8 +350,7 @@ int input_SetProgram( input_thread_t * p_input, pgrm_descriptor_t * p_new_prg )
case VIDEO_ES: case VIDEO_ES:
intf_WarnMsg( 4, "Selecting ES %x", intf_WarnMsg( 4, "Selecting ES %x",
p_new_prg->pp_es[i_es_index]->i_id ); p_new_prg->pp_es[i_es_index]->i_id );
input_SelectES( p_input, input_SelectES( p_input, p_new_prg->pp_es[i_es_index] );
p_new_prg->pp_es[i_es_index] );
break; break;
case AUDIO_ES: case AUDIO_ES:
i_audio_es += 1; i_audio_es += 1;
...@@ -359,8 +358,7 @@ int input_SetProgram( input_thread_t * p_input, pgrm_descriptor_t * p_new_prg ) ...@@ -359,8 +358,7 @@ int input_SetProgram( input_thread_t * p_input, pgrm_descriptor_t * p_new_prg )
{ {
intf_WarnMsg( 4, "Selecting ES %x", intf_WarnMsg( 4, "Selecting ES %x",
p_new_prg->pp_es[i_es_index]->i_id ); p_new_prg->pp_es[i_es_index]->i_id );
input_SelectES( p_input, input_SelectES( p_input, p_new_prg->pp_es[i_es_index]);
p_new_prg->pp_es[i_es_index]);
} }
break; break;
/* Not sure this one is fully specification-compliant */ /* Not sure this one is fully specification-compliant */
...@@ -370,11 +368,12 @@ int input_SetProgram( input_thread_t * p_input, pgrm_descriptor_t * p_new_prg ) ...@@ -370,11 +368,12 @@ int input_SetProgram( input_thread_t * p_input, pgrm_descriptor_t * p_new_prg )
{ {
intf_WarnMsg( 4, "Selecting ES %x", intf_WarnMsg( 4, "Selecting ES %x",
p_new_prg->pp_es[i_es_index]->i_id ); p_new_prg->pp_es[i_es_index]->i_id );
input_SelectES( p_input, input_SelectES( p_input, p_new_prg->pp_es[i_es_index] );
p_new_prg->pp_es[i_es_index] );
} }
break; break;
default : default :
intf_WarnMsg( 2, "ES %x has unknown type",
p_new_prg->pp_es[i_es_index]->i_id );
break; break;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* mpeg_system.c: TS, PS and PES management * mpeg_system.c: TS, PS and PES management
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: mpeg_system.c,v 1.89 2002/04/08 14:53:05 jobi Exp $ * $Id: mpeg_system.c,v 1.90 2002/04/17 17:00:58 jobi Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Michel Lespinasse <walken@via.ecp.fr> * Michel Lespinasse <walken@via.ecp.fr>
...@@ -1588,18 +1588,6 @@ static void input_DecodePAT( input_thread_t * p_input, es_descriptor_t * p_es ) ...@@ -1588,18 +1588,6 @@ static void input_DecodePAT( input_thread_t * p_input, es_descriptor_t * p_es )
} }
#undef p_psi #undef p_psi
if( !p_input->stream.p_selected_program )
{
pgrm_descriptor_t * p_pgrm_to_select;
u16 i_id = config_GetIntVariable( "input_program" );
p_pgrm_to_select = input_FindProgram( p_input, i_id );
if ( p_pgrm_to_select )
input_SetProgram( p_input, p_pgrm_to_select );
else /* take the first one */
input_SetProgram( p_input, p_input->stream.pp_programs[0] );
}
} }
/***************************************************************************** /*****************************************************************************
...@@ -1628,8 +1616,6 @@ static void input_DecodePMT( input_thread_t * p_input, es_descriptor_t * p_es ) ...@@ -1628,8 +1616,6 @@ static void input_DecodePMT( input_thread_t * p_input, es_descriptor_t * p_es )
int i_section_length,i_current_section; int i_section_length,i_current_section;
int i_prog_info_length, i_loop; int i_prog_info_length, i_loop;
int i_es_info_length, i_pid, i_stream_type; int i_es_info_length, i_pid, i_stream_type;
int i_audio_es, i_spu_es;
int i_required_audio_es, i_required_spu_es;
p_current_section = p_psi->buffer; p_current_section = p_psi->buffer;
p_current_data = p_psi->buffer; p_current_data = p_psi->buffer;
...@@ -1637,42 +1623,10 @@ static void input_DecodePMT( input_thread_t * p_input, es_descriptor_t * p_es ) ...@@ -1637,42 +1623,10 @@ static void input_DecodePMT( input_thread_t * p_input, es_descriptor_t * p_es )
p_pgrm_data->i_pcr_pid = ( ((u32)*(p_current_section + 8) & 0x1F) << 8 ) | p_pgrm_data->i_pcr_pid = ( ((u32)*(p_current_section + 8) & 0x1F) << 8 ) |
*(p_current_section + 9); *(p_current_section + 9);
i_audio_es = 0;
i_spu_es = 0;
/* Lock stream information */ /* Lock stream information */
vlc_mutex_lock( &p_input->stream.stream_lock ); vlc_mutex_lock( &p_input->stream.stream_lock );
/* 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;
}
/* Delete all ES in this program except the PSI. We start from the /* Delete all ES in this program except the PSI. We start from the
* end because i_es_number gets decremented after each deletion. */ * end because i_es_number gets decremented after each deletion. */
for( i_loop = p_es->p_pgrm->i_es_number ; i_loop ; ) for( i_loop = p_es->p_pgrm->i_es_number ; i_loop ; )
...@@ -1717,37 +1671,26 @@ static void input_DecodePMT( input_thread_t * p_input, es_descriptor_t * p_es ) ...@@ -1717,37 +1671,26 @@ static void input_DecodePMT( input_thread_t * p_input, es_descriptor_t * p_es )
/* Tell the interface what kind of stream it is and select /* Tell the interface what kind of stream it is and select
* the required ones */ * the required ones */
if ( p_input->stream.p_selected_program == p_new_es->p_pgrm )
{ {
switch( i_stream_type ) switch( i_stream_type )
{ {
case MPEG1_VIDEO_ES: case MPEG1_VIDEO_ES:
case MPEG2_VIDEO_ES: case MPEG2_VIDEO_ES:
p_new_es->i_cat = VIDEO_ES; p_new_es->i_cat = VIDEO_ES;
input_SelectES( p_input, p_new_es );
break; break;
case MPEG1_AUDIO_ES: case MPEG1_AUDIO_ES:
case MPEG2_AUDIO_ES: case MPEG2_AUDIO_ES:
p_new_es->i_cat = AUDIO_ES; p_new_es->i_cat = AUDIO_ES;
i_audio_es += 1;
if( i_audio_es == i_required_audio_es )
input_SelectES( p_input, p_new_es );
break; break;
case LPCM_AUDIO_ES : case LPCM_AUDIO_ES :
case AC3_AUDIO_ES : case AC3_AUDIO_ES :
p_new_es->i_stream_id = 0xBD; p_new_es->i_stream_id = 0xBD;
p_new_es->i_cat = AUDIO_ES; p_new_es->i_cat = AUDIO_ES;
i_audio_es += 1;
if( i_audio_es == i_required_audio_es )
input_SelectES( p_input, p_new_es );
break; break;
/* Not sure this one is fully specification-compliant */ /* Not sure this one is fully specification-compliant */
case DVD_SPU_ES : case DVD_SPU_ES :
p_new_es->i_stream_id = 0xBD; p_new_es->i_stream_id = 0xBD;
p_new_es->i_cat = SPU_ES; p_new_es->i_cat = SPU_ES;
i_spu_es += 1;
if( i_spu_es == i_required_spu_es )
input_SelectES( p_input, p_new_es );
break; break;
default : default :
p_new_es->i_cat = UNKNOWN_ES; p_new_es->i_cat = UNKNOWN_ES;
...@@ -1765,17 +1708,24 @@ static void input_DecodePMT( input_thread_t * p_input, es_descriptor_t * p_es ) ...@@ -1765,17 +1708,24 @@ static void input_DecodePMT( input_thread_t * p_input, es_descriptor_t * p_es )
} while( i_current_section < p_psi->i_last_section_number ); } while( i_current_section < p_psi->i_last_section_number );
if( i_required_audio_es > i_audio_es ) p_pgrm_data->i_pmt_version = p_psi->i_version_number;
/* if no program is selected :*/
if( !p_input->stream.p_selected_program )
{ {
intf_WarnMsg( 2, "input: non-existing audio ES required" ); pgrm_descriptor_t * p_pgrm_to_select;
} u16 i_id = (u16)config_GetIntVariable( "input_program" );
if( i_required_spu_es > i_spu_es ) if( i_id != 0 ) /* if user specified a program */
{ {
intf_WarnMsg( 2, "input: non-existing subtitles ES required" ); p_pgrm_to_select = input_FindProgram( p_input, i_id );
}
p_pgrm_data->i_pmt_version = p_psi->i_version_number; if( p_pgrm_to_select || p_pgrm_to_select == p_es->p_pgrm )
p_input->pf_set_program( p_input, p_pgrm_to_select );
}
else
p_input->pf_set_program( p_input, p_es->p_pgrm );
}
/* inform interface that stream has changed */ /* inform interface that stream has changed */
p_input->stream.b_changed = 1; p_input->stream.b_changed = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment