Commit c570d9bc authored by Christophe Massiot's avatar Christophe Massiot

* Removed all arbitrary limits on the number of elementary streams.

parent cc50abf7
......@@ -168,12 +168,6 @@
* interface, and is in fact an interface limitation */
#define INPUT_MAX_THREADS 10
/* Maximum number of ES definitions in a TS stream */
#define INPUT_MAX_ES 42
/* Maximum number of selected ES in an input thread */
#define INPUT_MAX_SELECTED_ES 42
/* Maximum size of a data packet (128 kB) */
#define INPUT_MAX_PACKET_SIZE 131072
......
......@@ -4,7 +4,7 @@
* control the pace of reading.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: input_ext-intf.h,v 1.5 2000/12/20 17:49:40 massiot Exp $
* $Id: input_ext-intf.h,v 1.6 2000/12/21 13:54:15 massiot Exp $
*
* Authors:
*
......@@ -210,11 +210,12 @@ typedef struct input_thread_s
/* General stream description */
stream_descriptor_t stream; /* PAT tables */
es_descriptor_t p_es[INPUT_MAX_ES];
/* carried elementary streams */
es_descriptor_t ** pp_es; /* carried elementary streams */
int i_es_number;
/* List of streams to demux */
es_descriptor_t * pp_selected_es[INPUT_MAX_SELECTED_ES];
es_descriptor_t ** pp_selected_es;
int i_selected_es_number;
/* For auto-launch of decoders */
struct aout_thread_s * p_default_aout;
......
......@@ -4,7 +4,7 @@
* decoders.
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: input.c,v 1.60 2000/12/20 16:04:31 massiot Exp $
* $Id: input.c,v 1.61 2000/12/21 13:54:15 massiot Exp $
*
* Authors:
*
......@@ -75,7 +75,6 @@ input_thread_t *input_CreateThread ( input_config_t * p_config, int *pi_status )
{
input_thread_t * p_input; /* thread descriptor */
int i_status; /* thread status */
int i;
/* Allocate descriptor */
intf_DbgMsg("\n");
......@@ -96,14 +95,10 @@ input_thread_t *input_CreateThread ( input_config_t * p_config, int *pi_status )
p_input->p_config = p_config;
/* Initialize stream description */
for( i = 0; i < INPUT_MAX_SELECTED_ES; i++ )
{
p_input->pp_selected_es[i] = NULL;
}
for( i= 0; i < INPUT_MAX_ES; i++ )
{
p_input->p_es[i].i_id = EMPTY_ID;
}
p_input->pp_es = NULL;
p_input->pp_selected_es = NULL;
p_input->i_es_number = 0;
p_input->i_selected_es_number = 0;
p_input->stream.i_pgrm_number = 0;
/* Initialize stream control properties. */
......@@ -318,9 +313,7 @@ static void EndThread( input_thread_t * p_input )
#endif
/* Destroy all decoder threads */
for( i_es_loop = 0;
(i_es_loop < INPUT_MAX_ES)
&& (p_input->pp_selected_es[i_es_loop] != NULL) ;
for( i_es_loop = 0; i_es_loop < p_input->i_selected_es_number;
i_es_loop++ )
{
p_input->pp_selected_es[i_es_loop]->p_decoder_fifo->b_die = 1;
......
/*****************************************************************************
* input_programs.c: es_descriptor_t, pgrm_descriptor_t management
* FIXME : check the return value of realloc() and malloc() !
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: input_programs.c,v 1.10 2000/12/21 13:25:51 massiot Exp $
* $Id: input_programs.c,v 1.11 2000/12/21 13:54:15 massiot Exp $
*
* Authors:
*
......@@ -184,53 +185,41 @@ es_descriptor_t * input_AddES( input_thread_t * p_input,
pgrm_descriptor_t * p_pgrm, u16 i_es_id,
size_t i_data_len )
{
int i_index;
es_descriptor_t * p_es = NULL;
es_descriptor_t * p_es;
intf_DbgMsg("Adding description for ES %d", i_es_id);
/* Find an empty slot to store the description of that es */
for( i_index = 0; i_index < INPUT_MAX_ES &&
p_input->p_es[i_index].i_id != EMPTY_ID; i_index++ );
p_es = (es_descriptor_t *)malloc( sizeof(es_descriptor_t) );
p_input->i_es_number++;
p_input->pp_es = realloc( p_input->pp_es, p_input->i_es_number
* sizeof(es_descriptor_t *) );
p_input->pp_es[p_input->i_es_number - 1] = p_es;
p_es->i_id = i_es_id;
if( i_index >= INPUT_MAX_ES )
/* Init its values */
p_es->b_discontinuity = 0;
p_es->p_pes = NULL;
p_es->p_decoder_fifo = NULL;
if( i_data_len )
{
/* No slot is empty */
intf_ErrMsg("Stream carries too many ES for our decoder");
p_es->p_demux_data = malloc( i_data_len );
memset( p_es->p_demux_data, 0, i_data_len );
}
/* Add this ES to the program definition if one is given */
if( p_pgrm )
{
p_pgrm->i_es_number++;
p_pgrm->pp_es = realloc( p_pgrm->pp_es,
p_pgrm->i_es_number
* sizeof(es_descriptor_t *) );
p_pgrm->pp_es[p_pgrm->i_es_number - 1] = p_es;
p_es->p_pgrm = p_pgrm;
}
else
{
/* Reserve the slot for that ES */
p_es = &p_input->p_es[i_index];
p_es->i_id = i_es_id;
intf_DbgMsg("Slot %d in p_es table assigned to ES %d",
i_index, i_es_id);
/* Init its values */
p_es->b_discontinuity = 0;
p_es->p_pes = NULL;
p_es->p_decoder_fifo = NULL;
if( i_data_len )
{
p_es->p_demux_data = malloc( i_data_len );
memset( p_es->p_demux_data, 0, i_data_len );
}
/* Add this ES to the program definition if one is given */
if( p_pgrm )
{
p_pgrm->i_es_number++;
p_pgrm->pp_es = realloc( p_pgrm->pp_es,
p_pgrm->i_es_number
* sizeof(es_descriptor_t *) );
p_pgrm->pp_es[p_pgrm->i_es_number - 1] = p_es;
p_es->p_pgrm = p_pgrm;
}
else
{
p_es->p_pgrm = NULL;
}
p_es->p_pgrm = NULL;
}
return p_es;
......@@ -241,17 +230,17 @@ es_descriptor_t * input_AddES( input_thread_t * p_input,
*****************************************************************************/
void input_DelES( input_thread_t * p_input, u16 i_id )
{
int i_index;
int i_index, i_es;
pgrm_descriptor_t * p_pgrm = NULL;
es_descriptor_t * p_es = NULL;
/* Look for the description of the ES */
for( i_index = 0; i_index < INPUT_MAX_ES; i_index++ )
for( i_es = 0; i_es < p_input->i_es_number; i_es++ )
{
if( p_input->p_es[i_index].i_id == i_id )
if( p_input->pp_es[i_es]->i_id == i_id )
{
p_es = &p_input->p_es[i_index];
p_pgrm = p_input->p_es[i_index].p_pgrm;
p_es = p_input->pp_es[i_es];
p_pgrm = p_input->pp_es[i_es]->p_pgrm;
break;
}
}
......@@ -276,15 +265,18 @@ void input_DelES( input_thread_t * p_input, u16 i_id )
}
}
/* The table of stream descriptors is static, so don't free memory
* but just mark the slot as unused */
p_es->i_id = EMPTY_ID;
/* Free the demux data */
if( p_es->p_demux_data != NULL )
{
free( p_es->p_demux_data );
}
/* Free the ES */
free( p_es );
p_input->i_es_number--;
p_input->pp_es[i_es] = p_input->pp_es[p_input->i_es_number];
p_input->pp_es = realloc( p_input->pp_es, p_input->i_es_number
* sizeof(es_descriptor_t *));
}
#ifdef STATS
......@@ -402,7 +394,6 @@ static adec_config_t * GetAdecConfig( input_thread_t * p_input,
int input_SelectES( input_thread_t * p_input, es_descriptor_t * p_es )
{
int i;
es_descriptor_t ** p_spot = NULL;
#ifdef DEBUG_INPUT
intf_DbgMsg( "Selecting ES %d", p_es->i_id );
......@@ -414,22 +405,6 @@ int input_SelectES( input_thread_t * p_input, es_descriptor_t * p_es )
return( -1 );
}
/* Find a free spot in pp_selected_es. */
for( i = 0; i < INPUT_MAX_SELECTED_ES; i++ )
{
if( p_input->pp_selected_es[i] == NULL )
{
p_spot = &p_input->pp_selected_es[i];
break;
}
}
if( p_spot == NULL )
{
intf_ErrMsg( "Too many ES selected" );
return( -1 );
}
switch( p_es->i_type )
{
case MPEG1_AUDIO_ES:
......@@ -474,7 +449,11 @@ int input_SelectES( input_thread_t * p_input, es_descriptor_t * p_es )
if( p_es->p_decoder_fifo != NULL )
{
*p_spot = p_es;
p_input->i_selected_es_number++;
p_input->pp_selected_es = realloc( p_input->pp_selected_es,
p_input->i_selected_es_number
* sizeof(es_descriptor_t *) );
p_input->pp_selected_es[p_input->i_selected_es_number - 1] = p_es;
}
return( 0 );
}
......@@ -2,7 +2,7 @@
* mpeg_system.c: TS, PS and PES management
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: mpeg_system.c,v 1.12 2000/12/20 20:09:19 sam Exp $
* $Id: mpeg_system.c,v 1.13 2000/12/21 13:54:15 massiot Exp $
*
* Authors:
*
......@@ -667,6 +667,7 @@ static u16 GetID( data_packet_t * p_data )
/*****************************************************************************
* DecodePSM: Decode the Program Stream Map information
*****************************************************************************/
/* FIXME : deprecated code ! */
static void DecodePSM( input_thread_t * p_input, data_packet_t * p_data )
{
stream_ps_data_t * p_demux =
......@@ -709,6 +710,7 @@ static void DecodePSM( input_thread_t * p_input, data_packet_t * p_data )
/* 4 == minimum useful size of a section */
while( p_byte + 4 <= p_end )
{
#if 0
p_input->p_es[i_es].i_id
= p_input->p_es[i_es].i_stream_id
= p_byte[1];
......@@ -735,6 +737,7 @@ static void DecodePSM( input_thread_t * p_input, data_packet_t * p_data )
#endif
i_es++;
#endif
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
......@@ -771,7 +774,8 @@ es_descriptor_t * input_ParsePS( input_thread_t * p_input,
if( p_input->stream.pp_programs[0]->b_is_ok )
{
/* Look only at the selected ES. */
for( i_dummy = 0; i_dummy < INPUT_MAX_SELECTED_ES; i_dummy++ )
for( i_dummy = 0; i_dummy < p_input->i_selected_es_number;
i_dummy++ )
{
if( p_input->pp_selected_es[i_dummy] != NULL
&& p_input->pp_selected_es[i_dummy]->i_id == i_id )
......@@ -784,12 +788,12 @@ es_descriptor_t * input_ParsePS( input_thread_t * p_input,
else
{
/* Search all ES ; if not found -> AddES */
for( i_dummy = 0; i_dummy < INPUT_MAX_ES; i_dummy++ )
for( i_dummy = 0; i_dummy < p_input->i_es_number; i_dummy++ )
{
if( p_input->p_es[i_dummy].i_id != EMPTY_ID
&& p_input->p_es[i_dummy].i_id == i_id )
if( p_input->pp_es[i_dummy] != NULL
&& p_input->pp_es[i_dummy]->i_id == i_id )
{
p_es = &p_input->p_es[i_dummy];
p_es = p_input->pp_es[i_dummy];
break;
}
}
......@@ -995,13 +999,13 @@ void input_DemuxTS( input_thread_t * p_input, data_packet_t * p_data )
/* Find out the elementary stream. */
vlc_mutex_lock( &p_input->stream.stream_lock );
for( i_dummy = 0; i_dummy < INPUT_MAX_ES; i_dummy++ )
for( i_dummy = 0; i_dummy < p_input->i_es_number; i_dummy++ )
{
if( p_input->p_es[i_dummy].i_id != EMPTY_ID )
if( p_input->pp_es[i_dummy] != NULL )
{
if( p_input->p_es[i_dummy].i_id == i_pid )
if( p_input->pp_es[i_dummy]->i_id == i_pid )
{
p_es = &p_input->p_es[i_dummy];
p_es = p_input->pp_es[i_dummy];
p_es_demux = (es_ts_data_t *)p_es->p_demux_data;
p_pgrm_demux = (pgrm_ts_data_t *)p_es->p_pgrm->p_demux_data;
break;
......
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