Commit ca66eeb3 authored by Rafaël Carré's avatar Rafaël Carré

TS Mux: deindent, cosmetics, use stack rather than heap

parent 73f01617
......@@ -2088,8 +2088,7 @@ static void GetPMTmpeg4(sout_mux_t *p_mux)
{
sout_mux_sys_t *p_sys = p_mux->p_sys;
uint8_t iod[4096];
bits_buffer_t bits;
bits_buffer_t bits_fix_IOD;
bits_buffer_t bits, bits_fix_IOD;
/* Make valgrind happy : it works at byte level not bit one so
* bit_write confuse it (but DON'T CHANGE the way that bit_write is
......@@ -2118,13 +2117,12 @@ static void GetPMTmpeg4(sout_mux_t *p_mux)
bits_write( &bits, 8, 0xff ); /* graphicProfile (no ) */
for (int i_stream = 0; i_stream < p_mux->i_nb_inputs; i_stream++ )
{
ts_stream_t *p_stream;
p_stream = (ts_stream_t*)p_mux->pp_inputs[i_stream]->p_sys;
ts_stream_t *p_stream = (ts_stream_t*)p_mux->pp_inputs[i_stream]->p_sys;
if( p_stream->i_stream_id != 0xfa && p_stream->i_stream_id != 0xfb &&
p_stream->i_stream_id != 0xfe )
continue;
if( p_stream->i_stream_id == 0xfa ||
p_stream->i_stream_id == 0xfb ||
p_stream->i_stream_id == 0xfe )
{
bits_buffer_t bits_fix_ESDescr, bits_fix_Decoder;
/* ES descriptor */
bits_align( &bits );
......@@ -2213,15 +2211,12 @@ static void GetPMTmpeg4(sout_mux_t *p_mux)
GetDescriptorLength24b( bits.i_data -
bits_fix_ESDescr.i_data - 3 ) );
}
}
bits_align( &bits );
/* fix IOD length */
bits_write( &bits_fix_IOD, 24,
GetDescriptorLength24b( bits.i_data -
bits_fix_IOD.i_data - 3 ) );
GetDescriptorLength24b(bits.i_data - bits_fix_IOD.i_data - 3 ));
dvbpsi_PMTAddDescriptor( &p_sys->dvbpmt[0], 0x1d, bits.i_data,
bits.p_data );
dvbpsi_PMTAddDescriptor(&p_sys->dvbpmt[0], 0x1d, bits.i_data, bits.p_data);
}
static void GetPMT( sout_mux_t *p_mux, sout_buffer_chain_t *c )
......@@ -2247,8 +2242,9 @@ static void GetPMT( sout_mux_t *p_mux, sout_buffer_chain_t *c )
1, /* b_current_next */
p_sys->i_pcr_pid );
if( p_sys->b_sdt )
{
if( !p_sys->b_sdt )
continue;
dvbpsi_sdt_service_t *p_service = dvbpsi_SDTAddService( &sdt,
p_sys->i_pmt_program_number[i], /* service id */
0, /* eit schedule */
......@@ -2256,38 +2252,28 @@ static void GetPMT( sout_mux_t *p_mux, sout_buffer_chain_t *c )
4, /* running status ("4=RUNNING") */
0 ); /* free ca */
#define psz_sdtprov p_sys->sdt_descriptors[i].psz_provider
#define psz_sdtserv p_sys->sdt_descriptors[i].psz_service_name
const char *psz_sdtprov = p_sys->sdt_descriptors[i].psz_provider;
const char *psz_sdtserv = p_sys->sdt_descriptors[i].psz_service_name;
if( !psz_sdtprov || !psz_sdtserv )
continue;
size_t provlen = VLC_CLIP(strlen(psz_sdtprov), 0, 255);
size_t servlen = VLC_CLIP(strlen(psz_sdtserv), 0, 255);
uint8_t psz_sdt_desc[3 + provlen + servlen];
/* FIXME: Ineffecient malloc's & ugly code...... */
if( ( psz_sdtprov != NULL ) && ( psz_sdtserv != NULL ) )
{
uint8_t *psz_sdt_desc = malloc( 3 + strlen(psz_sdtprov)
+ strlen(psz_sdtserv) );
if( psz_sdt_desc )
{
psz_sdt_desc[0] = 0x01; /* digital television service */
/* service provider name length */
psz_sdt_desc[1] = (char)strlen(psz_sdtprov);
memcpy( &psz_sdt_desc[2], psz_sdtprov, strlen(psz_sdtprov) );
psz_sdt_desc[1] = (char)provlen;
memcpy( &psz_sdt_desc[2], psz_sdtprov, provlen );
/* service name length */
psz_sdt_desc[ 2 + strlen(psz_sdtprov) ]
= (char)strlen(psz_sdtserv);
memcpy( &psz_sdt_desc[3+strlen(psz_sdtprov)], psz_sdtserv,
strlen(psz_sdtserv) );
psz_sdt_desc[ 2 + provlen ] = (char)servlen;
memcpy( &psz_sdt_desc[3+provlen], psz_sdtserv, servlen );
dvbpsi_SDTServiceAddDescriptor( p_service, 0x48,
3 + strlen(psz_sdtprov) + strlen(psz_sdtserv),
(uint8_t *)psz_sdt_desc );
free( psz_sdt_desc );
psz_sdt_desc = NULL;
}
}
#undef psz_sdtprov
#undef psz_sdtserv
}
3 + provlen + servlen, psz_sdt_desc );
}
if( p_sys->i_mpeg4_streams > 0 )
......
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