* mpeg_ts.c : Transport Stream input module for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
- * $Id: ts.c,v 1.29 2003/07/13 12:35:13 massiot Exp $
+ * $Id: ts.c,v 1.30 2003/08/01 18:02:06 fenrir Exp $
*
* Authors: Henri Fallon <henri@via.ecp.fr>
* Johan Bilien <jobi@via.ecp.fr>
{
/* unit_start set to 1 -> presence of a pointer field
* (see ISO/IEC 13818 (2.4.4.2) which should be set to 0x00 */
- if( (u8)p[0] != 0x00 )
+ if( (uint8_t)p[0] != 0x00 )
{
msg_Warn( p_input,
"non-zero pointer field found, trying to continue" );
- p+=(u8)p[0];
+ p+=(uint8_t)p[0];
}
else
{
/* This is the begining of a new section */
- if( ((u8)(p[1]) & 0xc0) != 0x80 )
+ if( ((uint8_t)(p[1]) & 0xc0) != 0x80 )
{
msg_Warn( p_input, "invalid PSI packet" );
p_psi->b_trash = 1;
p_psi->i_section_length = ((p[1] & 0xF) << 8) | p[2];
p_psi->b_section_complete = 0;
p_psi->i_read_in_section = 0;
- p_psi->i_section_number = (u8)p[6];
+ p_psi->i_section_number = (uint8_t)p[6];
if( p_psi->b_is_complete || p_psi->i_section_number == 0 )
{
p_psi->b_is_complete = 0;
p_psi->b_trash = 0;
p_psi->i_version_number = ( p[5] >> 1 ) & 0x1f;
- p_psi->i_last_section_number = (u8)p[7];
+ p_psi->i_last_section_number = (uint8_t)p[7];
/* We'll write at the begining of the buffer */
p_psi->p_current = p_psi->buffer;
"PSI version differs inside same PAT" );
p_psi->b_trash = 1;
}
- if( p_psi->i_section_number + 1 != (u8)p[6] )
+ if( p_psi->i_section_number + 1 != (uint8_t)p[6] )
{
msg_Warn( p_input,
"PSI Section discontinuity, packet lost?" );
do
{
- i_section_length = ((u32)(p_current_data[1] & 0xF) << 8) |
+ i_section_length = ((uint32_t)(p_current_data[1] & 0xF) << 8) |
p_current_data[2];
- i_current_section = (u8)p_current_data[6];
+ i_current_section = (uint8_t)p_current_data[6];
for( i_loop = 0;
( i_loop < (i_section_length - 9) / 4 ) && !b_changed;
i_loop++ )
{
- i_program_id = ( (u32)*(p_current_data + i_loop * 4 + 8) << 8 )
+ i_program_id = ( (uint32_t)*(p_current_data + i_loop * 4 + 8) << 8 )
| *(p_current_data + i_loop * 4 + 9);
- i_pmt_pid = ( ((u32)*(p_current_data + i_loop * 4 + 10) & 0x1F)
+ i_pmt_pid = ( ((uint32_t)*(p_current_data + i_loop * 4 + 10) & 0x1F)
<< 8 )
| *(p_current_data + i_loop * 4 + 11);
do
{
- i_section_length = ((u32)(p_current_data[1] & 0xF) << 8) |
+ i_section_length = ((uint32_t)(p_current_data[1] & 0xF) << 8) |
p_current_data[2];
- i_current_section = (u8)p_current_data[6];
+ i_current_section = (uint8_t)p_current_data[6];
for( i_loop = 0; i_loop < (i_section_length - 9) / 4 ; i_loop++ )
{
- i_program_id = ( (u32)*(p_current_data + i_loop * 4 + 8) << 8 )
+ i_program_id = ( (uint32_t)*(p_current_data + i_loop * 4 + 8) << 8 )
| *(p_current_data + i_loop * 4 + 9);
- i_pmt_pid = ( ((u32)*(p_current_data + i_loop * 4 + 10) & 0x1F)
+ i_pmt_pid = ( ((uint32_t)*(p_current_data + i_loop * 4 + 10) & 0x1F)
<< 8 )
| *(p_current_data + i_loop * 4 + 11);
p_pgrm_demux->i_pmt_version = PMT_UNINITIALIZED;
/* Add the PMT ES to this program */
- p_current_es = input_AddES( p_input, p_pgrm,(u16)i_pmt_pid,
+ p_current_es = input_AddES( p_input, p_pgrm,(uint16_t)i_pmt_pid,
UNKNOWN_ES, NULL, sizeof( es_ts_data_t) );
p_current_es->i_fourcc = VLC_FOURCC( 'p', 'm', 't', ' ' );
p_es_demux = (es_ts_data_t *)p_current_es->p_demux_data;
p_current_section = p_psi->buffer;
p_current_data = p_psi->buffer;
- p_pgrm_data->i_pcr_pid = ( ((u32)*(p_current_section + 8) & 0x1F) << 8 ) |
+ p_pgrm_data->i_pcr_pid = ( ((uint32_t)*(p_current_section + 8) & 0x1F) << 8 ) |
*(p_current_section + 9);
/* Then add what we received in this PMT */
do
{
- i_section_length = ( ((u32)*(p_current_data + 1) & 0xF) << 8 ) |
+ i_section_length = ( ((uint32_t)*(p_current_data + 1) & 0xF) << 8 ) |
*(p_current_data + 2);
- i_current_section = (u8)p_current_data[6];
- i_prog_info_length = ( ((u32)*(p_current_data + 10) & 0xF) << 8 ) |
+ i_current_section = (uint8_t)p_current_data[6];
+ i_prog_info_length = ( ((uint32_t)*(p_current_data + 10) & 0xF) << 8 ) |
*(p_current_data + 11);
/* For the moment we ignore program descriptors */
while( p_current_data < p_current_section + i_section_length -1 )
{
i_stream_type = (int)p_current_data[0];
- i_pid = ( ((u32)*(p_current_data + 1) & 0x1F) << 8 ) |
+ i_pid = ( ((uint32_t)*(p_current_data + 1) & 0x1F) << 8 ) |
*(p_current_data + 2);
- i_es_info_length = ( ((u32)*(p_current_data + 3) & 0xF) << 8 ) |
+ i_es_info_length = ( ((uint32_t)*(p_current_data + 3) & 0xF) << 8 ) |
*(p_current_data + 4);
/* Tell the interface what kind of stream it is and select
}
/* Add this ES to the program */
- p_new_es = input_AddES( p_input, p_es->p_pgrm, (u16)i_pid,
+ p_new_es = input_AddES( p_input, p_es->p_pgrm, (uint16_t)i_pid,
i_cat, NULL, sizeof( es_ts_data_t ) );
((es_ts_data_t *)p_new_es->p_demux_data)->i_continuity_counter = 0xFF;
if( !p_input->stream.p_selected_program )
{
pgrm_descriptor_t * p_pgrm_to_select;
- u16 i_id = (u16)config_GetInt( p_input, "program" );
+ uint16_t i_id = (uint16_t)config_GetInt( p_input, "program" );
if( i_id != 0 ) /* if user specified a program */
{
/* Add the PMT ES to this program */
p_current_es = input_AddES( p_input, p_new_pgrm,
- (u16)p_pgrm->i_pid, UNKNOWN_ES,
+ (uint16_t)p_pgrm->i_pid, UNKNOWN_ES,
NULL, sizeof(es_ts_data_t) );
p_current_es->i_fourcc = VLC_FOURCC( 'p', 'm', 't', ' ' );
p_es_demux = (es_ts_data_t *)p_current_es->p_demux_data;
p_es_demux->b_psi = 1;
p_es_demux->i_psi_type = PSI_IS_PMT;
-
- p_es_demux->p_psi_section = malloc( sizeof( psi_section_t ) );
- if ( p_es_demux->p_psi_section == NULL )
- {
- msg_Err( p_input, "out of memory" );
- p_input->b_error = 1;
- return;
- }
-
- p_es_demux->p_psi_section->b_is_complete = 0;
+ p_es_demux->p_psi_section = NULL;
p_es_demux->i_continuity_counter = 0xFF;
/* Create a PMT decoder */
p_pgrm_demux->i_pmt_version == PMT_UNINITIALIZED )
{
dvbpsi_descriptor_t *p_dr = p_new_pmt->p_first_descriptor;
+ int i_loop;
+
+ msg_Dbg( p_input, "Processing PMT for program %d version %d",
+ p_new_pmt->i_program_number, p_new_pmt->i_version );
+
+ /* Delete all ES in this program except the PSI. We start from the
+ * end because i_es_number gets decremented after each deletion. */
+ for( i_loop = p_es->p_pgrm->i_es_number ; i_loop > 0 ; )
+ {
+ es_ts_data_t * p_es_demux;
+
+ i_loop--;
+ p_es_demux = (es_ts_data_t *)
+ p_es->p_pgrm->pp_es[i_loop]->p_demux_data;
+ if ( !p_es_demux->b_psi )
+ {
+ input_DelES( p_input, p_es->p_pgrm->pp_es[i_loop] );
+ }
+ }
+
/* IOD */
while( p_dr && ( p_dr->i_tag != 0x1d ) )
p_dr = p_dr->p_next;
}
/* Add this ES */
- p_new_es = input_AddES( p_input, p_pgrm, (u16)p_es->i_pid,
+ p_new_es = input_AddES( p_input, p_pgrm, (uint16_t)p_es->i_pid,
i_cat, psz_desc, sizeof( es_ts_data_t ) );
if( p_new_es == NULL )
{
if( !p_input->stream.p_selected_program )
{
pgrm_descriptor_t * p_pgrm_to_select;
- u16 i_id = (u16)config_GetInt( p_input, "program" );
+ uint16_t i_id = (uint16_t)config_GetInt( p_input, "program" );
if( i_id != 0 ) /* if user specified a program */
{