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,110 +2117,106 @@ 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 );
bits_write( &bits, 8, 0x03 ); /* ES_DescrTag */
bits_fix_ESDescr = bits;
bits_write( &bits, 24,
GetDescriptorLength24b( 0 ) ); /* variable size */
bits_write( &bits, 16, p_stream->i_es_id );
bits_write( &bits, 1, 0x00 ); /* streamDependency */
bits_write( &bits, 1, 0x00 ); /* URL Flag */
bits_write( &bits, 1, 0x00 ); /* OCRStreamFlag */
bits_write( &bits, 5, 0x1f ); /* streamPriority */
/* DecoderConfigDesciptor */
bits_align( &bits );
bits_write( &bits, 8, 0x04 ); /* DecoderConfigDescrTag */
bits_fix_Decoder = bits;
bits_write( &bits, 24, GetDescriptorLength24b( 0 ) );
if( p_stream->i_stream_type == 0x10 )
{
bits_buffer_t bits_fix_ESDescr, bits_fix_Decoder;
/* ES descriptor */
bits_align( &bits );
bits_write( &bits, 8, 0x03 ); /* ES_DescrTag */
bits_fix_ESDescr = bits;
bits_write( &bits, 24,
GetDescriptorLength24b( 0 ) ); /* variable size */
bits_write( &bits, 16, p_stream->i_es_id );
bits_write( &bits, 1, 0x00 ); /* streamDependency */
bits_write( &bits, 1, 0x00 ); /* URL Flag */
bits_write( &bits, 1, 0x00 ); /* OCRStreamFlag */
bits_write( &bits, 5, 0x1f ); /* streamPriority */
/* DecoderConfigDesciptor */
bits_align( &bits );
bits_write( &bits, 8, 0x04 ); /* DecoderConfigDescrTag */
bits_fix_Decoder = bits;
bits_write( &bits, 24, GetDescriptorLength24b( 0 ) );
if( p_stream->i_stream_type == 0x10 )
{
bits_write( &bits, 8, 0x20 ); /* Visual 14496-2 */
bits_write( &bits, 6, 0x04 ); /* VisualStream */
}
else if( p_stream->i_stream_type == 0x1b )
{
bits_write( &bits, 8, 0x21 ); /* Visual 14496-2 */
bits_write( &bits, 6, 0x04 ); /* VisualStream */
}
else if( p_stream->i_stream_type == 0x11 ||
p_stream->i_stream_type == 0x0f )
{
bits_write( &bits, 8, 0x40 ); /* Audio 14496-3 */
bits_write( &bits, 6, 0x05 ); /* AudioStream */
}
else if( p_stream->i_stream_type == 0x12 &&
p_stream->i_codec == VLC_CODEC_SUBT )
{
bits_write( &bits, 8, 0x0B ); /* Text Stream */
bits_write( &bits, 6, 0x04 ); /* VisualStream */
}
else
{
bits_write( &bits, 8, 0x00 );
bits_write( &bits, 6, 0x00 );
bits_write( &bits, 8, 0x20 ); /* Visual 14496-2 */
bits_write( &bits, 6, 0x04 ); /* VisualStream */
}
else if( p_stream->i_stream_type == 0x1b )
{
bits_write( &bits, 8, 0x21 ); /* Visual 14496-2 */
bits_write( &bits, 6, 0x04 ); /* VisualStream */
}
else if( p_stream->i_stream_type == 0x11 ||
p_stream->i_stream_type == 0x0f )
{
bits_write( &bits, 8, 0x40 ); /* Audio 14496-3 */
bits_write( &bits, 6, 0x05 ); /* AudioStream */
}
else if( p_stream->i_stream_type == 0x12 &&
p_stream->i_codec == VLC_CODEC_SUBT )
{
bits_write( &bits, 8, 0x0B ); /* Text Stream */
bits_write( &bits, 6, 0x04 ); /* VisualStream */
}
else
{
bits_write( &bits, 8, 0x00 );
bits_write( &bits, 6, 0x00 );
msg_Err( p_mux->p_sout,"Unsupported stream_type => "
"broken IOD" );
}
bits_write( &bits, 1, 0x00 ); /* UpStream */
bits_write( &bits, 1, 0x01 ); /* reserved */
bits_write( &bits, 24, 1024 * 1024 ); /* bufferSizeDB */
bits_write( &bits, 32, 0x7fffffff ); /* maxBitrate */
bits_write( &bits, 32, 0 ); /* avgBitrate */
msg_Err( p_mux->p_sout,"Unsupported stream_type => "
"broken IOD" );
}
bits_write( &bits, 1, 0x00 ); /* UpStream */
bits_write( &bits, 1, 0x01 ); /* reserved */
bits_write( &bits, 24, 1024 * 1024 ); /* bufferSizeDB */
bits_write( &bits, 32, 0x7fffffff ); /* maxBitrate */
bits_write( &bits, 32, 0 ); /* avgBitrate */
if( p_stream->i_extra > 0 )
if( p_stream->i_extra > 0 )
{
/* DecoderSpecificInfo */
bits_align( &bits );
bits_write( &bits, 8, 0x05 ); /* tag */
bits_write( &bits, 24, GetDescriptorLength24b(
p_stream->i_extra ) );
for (int i = 0; i < p_stream->i_extra; i++ )
{
/* DecoderSpecificInfo */
bits_align( &bits );
bits_write( &bits, 8, 0x05 ); /* tag */
bits_write( &bits, 24, GetDescriptorLength24b(
p_stream->i_extra ) );
for (int i = 0; i < p_stream->i_extra; i++ )
{
bits_write( &bits, 8,
((uint8_t*)p_stream->p_extra)[i] );
}
bits_write( &bits, 8,
((uint8_t*)p_stream->p_extra)[i] );
}
/* fix Decoder length */
bits_write( &bits_fix_Decoder, 24,
GetDescriptorLength24b( bits.i_data -
bits_fix_Decoder.i_data - 3 ) );
/* SLConfigDescriptor : predefined (0x01) */
bits_align( &bits );
bits_write( &bits, 8, 0x06 ); /* tag */
bits_write( &bits, 24, GetDescriptorLength24b( 8 ) );
bits_write( &bits, 8, 0x01 );/* predefined */
bits_write( &bits, 1, 0 ); /* durationFlag */
bits_write( &bits, 32, 0 ); /* OCRResolution */
bits_write( &bits, 8, 0 ); /* OCRLength */
bits_write( &bits, 8, 0 ); /* InstantBitrateLength */
bits_align( &bits );
/* fix ESDescr length */
bits_write( &bits_fix_ESDescr, 24,
GetDescriptorLength24b( bits.i_data -
bits_fix_ESDescr.i_data - 3 ) );
}
/* fix Decoder length */
bits_write( &bits_fix_Decoder, 24,
GetDescriptorLength24b( bits.i_data -
bits_fix_Decoder.i_data - 3 ) );
/* SLConfigDescriptor : predefined (0x01) */
bits_align( &bits );
bits_write( &bits, 8, 0x06 ); /* tag */
bits_write( &bits, 24, GetDescriptorLength24b( 8 ) );
bits_write( &bits, 8, 0x01 );/* predefined */
bits_write( &bits, 1, 0 ); /* durationFlag */
bits_write( &bits, 32, 0 ); /* OCRResolution */
bits_write( &bits, 8, 0 ); /* OCRLength */
bits_write( &bits, 8, 0 ); /* InstantBitrateLength */
bits_align( &bits );
/* fix ESDescr length */
bits_write( &bits_fix_ESDescr, 24,
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,47 +2242,38 @@ 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 )
{
dvbpsi_sdt_service_t *p_service = dvbpsi_SDTAddService( &sdt,
p_sys->i_pmt_program_number[i], /* service id */
0, /* eit schedule */
0, /* eit present */
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
/* 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) );
/* 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) );
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
}
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 */
0, /* eit present */
4, /* running status ("4=RUNNING") */
0 ); /* free ca */
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];
psz_sdt_desc[0] = 0x01; /* digital television service */
/* service provider name length */
psz_sdt_desc[1] = (char)provlen;
memcpy( &psz_sdt_desc[2], psz_sdtprov, provlen );
/* service name length */
psz_sdt_desc[ 2 + provlen ] = (char)servlen;
memcpy( &psz_sdt_desc[3+provlen], psz_sdtserv, servlen );
dvbpsi_SDTServiceAddDescriptor( p_service, 0x48,
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