Commit 448a2181 authored by Rafaël Carré's avatar Rafaël Carré

TS demux: use a static function for debugging

parent e607f604
...@@ -62,6 +62,17 @@ ...@@ -62,6 +62,17 @@
# include <dvbpsi/tot.h> # include <dvbpsi/tot.h>
#undef TS_DEBUG #undef TS_DEBUG
static void ts_debug(const char *format, ...)
{
#ifdef TS_DEBUG
va_list ap;
va_start(ap, format);
vfprintf(stderr, format, ap);
va_end(ap);
#else
(void)format;
#endif
}
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
...@@ -2355,9 +2366,8 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data ) ...@@ -2355,9 +2366,8 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data )
if( !p_iod ) return NULL; if( !p_iod ) return NULL;
memset( p_iod, 0, sizeof( iod_descriptor_t ) ); memset( p_iod, 0, sizeof( iod_descriptor_t ) );
#ifdef TS_DEBUG ts_debug( "\n************ IOD ************" );
fprintf( stderr, "\n************ IOD ************" );
#endif
for( i = 0; i < 255; i++ ) for( i = 0; i < 255; i++ )
{ {
p_iod->es_descr[i].b_ok = 0; p_iod->es_descr[i].b_ok = 0;
...@@ -2384,23 +2394,19 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data ) ...@@ -2384,23 +2394,19 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data )
p_iod->i_iod_label = byte2; p_iod->i_iod_label = byte2;
i_iod_tag = byte3; i_iod_tag = byte3;
} }
#ifdef TS_DEBUG
fprintf( stderr, "\n* iod_label:%d", p_iod->i_iod_label ); ts_debug( "\n* iod_label:%d", p_iod->i_iod_label );
fprintf( stderr, "\n* ===========" ); ts_debug( "\n* ===========" );
fprintf( stderr, "\n* tag:0x%x", i_iod_tag ); ts_debug( "\n* tag:0x%x", i_iod_tag );
#endif
if( i_iod_tag != 0x02 ) if( i_iod_tag != 0x02 )
{ {
#ifdef TS_DEBUG ts_debug( "\n ERR: tag %02x != 0x02", i_iod_tag );
fprintf( stderr, "\n ERR: tag %02x != 0x02", i_iod_tag );
#endif
return p_iod; return p_iod;
} }
i_iod_length = IODDescriptorLength( &i_data, &p_data ); i_iod_length = IODDescriptorLength( &i_data, &p_data );
#ifdef TS_DEBUG ts_debug( "\n* length:%d", i_iod_length );
fprintf( stderr, "\n* length:%d", i_iod_length );
#endif
if( i_iod_length > i_data ) if( i_iod_length > i_data )
{ {
i_iod_length = i_data; i_iod_length = i_data;
...@@ -2410,18 +2416,14 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data ) ...@@ -2410,18 +2416,14 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data )
i_flags = IODGetByte( &i_data, &p_data ); i_flags = IODGetByte( &i_data, &p_data );
p_iod->i_od_id |= i_flags >> 6; p_iod->i_od_id |= i_flags >> 6;
b_url = ( i_flags >> 5 )&0x01; b_url = ( i_flags >> 5 )&0x01;
#ifdef TS_DEBUG ts_debug( "\n* od_id:%d", p_iod->i_od_id );
fprintf( stderr, "\n* od_id:%d", p_iod->i_od_id ); ts_debug( "\n* url flag:%d", b_url );
fprintf( stderr, "\n* url flag:%d", b_url ); ts_debug( "\n* includeInlineProfileLevel flag:%d", ( i_flags >> 4 )&0x01 );
fprintf( stderr, "\n* includeInlineProfileLevel flag:%d", ( i_flags >> 4 )&0x01 );
#endif
if( b_url ) if( b_url )
{ {
p_iod->psz_url = IODGetURL( &i_data, &p_data ); p_iod->psz_url = IODGetURL( &i_data, &p_data );
#ifdef TS_DEBUG ts_debug( "\n* url string:%s", p_iod->psz_url );
fprintf( stderr, "\n* url string:%s", p_iod->psz_url ); ts_debug( "\n*****************************\n" );
fprintf( stderr, "\n*****************************\n" );
#endif
return p_iod; return p_iod;
} }
else else
...@@ -2434,13 +2436,11 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data ) ...@@ -2434,13 +2436,11 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data )
p_iod->i_audioProfileLevelIndication = IODGetByte( &i_data, &p_data ); p_iod->i_audioProfileLevelIndication = IODGetByte( &i_data, &p_data );
p_iod->i_visualProfileLevelIndication = IODGetByte( &i_data, &p_data ); p_iod->i_visualProfileLevelIndication = IODGetByte( &i_data, &p_data );
p_iod->i_graphicsProfileLevelIndication = IODGetByte( &i_data, &p_data ); p_iod->i_graphicsProfileLevelIndication = IODGetByte( &i_data, &p_data );
#ifdef TS_DEBUG ts_debug( "\n* ODProfileLevelIndication:%d", p_iod->i_ODProfileLevelIndication );
fprintf( stderr, "\n* ODProfileLevelIndication:%d", p_iod->i_ODProfileLevelIndication ); ts_debug( "\n* sceneProfileLevelIndication:%d", p_iod->i_sceneProfileLevelIndication );
fprintf( stderr, "\n* sceneProfileLevelIndication:%d", p_iod->i_sceneProfileLevelIndication ); ts_debug( "\n* audioProfileLevelIndication:%d", p_iod->i_audioProfileLevelIndication );
fprintf( stderr, "\n* audioProfileLevelIndication:%d", p_iod->i_audioProfileLevelIndication ); ts_debug( "\n* visualProfileLevelIndication:%d", p_iod->i_visualProfileLevelIndication );
fprintf( stderr, "\n* visualProfileLevelIndication:%d", p_iod->i_visualProfileLevelIndication ); ts_debug( "\n* graphicsProfileLevelIndication:%d", p_iod->i_graphicsProfileLevelIndication );
fprintf( stderr, "\n* graphicsProfileLevelIndication:%d", p_iod->i_graphicsProfileLevelIndication );
#endif
while( i_data > 0 && i_es_index < 255) while( i_data > 0 && i_es_index < 255)
{ {
...@@ -2462,9 +2462,7 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data ) ...@@ -2462,9 +2462,7 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data )
{ {
#define es_descr p_iod->es_descr[i_es_index] #define es_descr p_iod->es_descr[i_es_index]
int i_decoderConfigDescr_length; int i_decoderConfigDescr_length;
#ifdef TS_DEBUG ts_debug( "\n* - ES_Descriptor length:%d", i_length );
fprintf( stderr, "\n* - ES_Descriptor length:%d", i_length );
#endif
es_descr.b_ok = 1; es_descr.b_ok = 1;
es_descr.i_es_id = IODGetWord( &i_data, &p_data ); es_descr.i_es_id = IODGetWord( &i_data, &p_data );
...@@ -2473,25 +2471,19 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data ) ...@@ -2473,25 +2471,19 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data )
b_url = ( i_flags >> 6 )&0x01; b_url = ( i_flags >> 6 )&0x01;
es_descr.b_OCRStreamFlag = ( i_flags >> 5 )&0x01; es_descr.b_OCRStreamFlag = ( i_flags >> 5 )&0x01;
es_descr.i_streamPriority = i_flags & 0x1f; es_descr.i_streamPriority = i_flags & 0x1f;
#ifdef TS_DEBUG ts_debug( "\n* * streamDependenceFlag:%d", es_descr.b_streamDependenceFlag );
fprintf( stderr, "\n* * streamDependenceFlag:%d", es_descr.b_streamDependenceFlag ); ts_debug( "\n* * OCRStreamFlag:%d", es_descr.b_OCRStreamFlag );
fprintf( stderr, "\n* * OCRStreamFlag:%d", es_descr.b_OCRStreamFlag ); ts_debug( "\n* * streamPriority:%d", es_descr.i_streamPriority );
fprintf( stderr, "\n* * streamPriority:%d", es_descr.i_streamPriority );
#endif
if( es_descr.b_streamDependenceFlag ) if( es_descr.b_streamDependenceFlag )
{ {
es_descr.i_dependOn_es_id = IODGetWord( &i_data, &p_data ); es_descr.i_dependOn_es_id = IODGetWord( &i_data, &p_data );
#ifdef TS_DEBUG ts_debug( "\n* * dependOn_es_id:%d", es_descr.i_dependOn_es_id );
fprintf( stderr, "\n* * dependOn_es_id:%d", es_descr.i_dependOn_es_id );
#endif
} }
if( b_url ) if( b_url )
{ {
es_descr.psz_url = IODGetURL( &i_data, &p_data ); es_descr.psz_url = IODGetURL( &i_data, &p_data );
#ifdef TS_DEBUG ts_debug( "\n* url string:%s", es_descr.psz_url );
fprintf( stderr, "\n* url string:%s", es_descr.psz_url );
#endif
} }
else else
{ {
...@@ -2501,23 +2493,17 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data ) ...@@ -2501,23 +2493,17 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data )
if( es_descr.b_OCRStreamFlag ) if( es_descr.b_OCRStreamFlag )
{ {
es_descr.i_OCR_es_id = IODGetWord( &i_data, &p_data ); es_descr.i_OCR_es_id = IODGetWord( &i_data, &p_data );
#ifdef TS_DEBUG ts_debug( "\n* * OCR_es_id:%d", es_descr.i_OCR_es_id );
fprintf( stderr, "\n* * OCR_es_id:%d", es_descr.i_OCR_es_id );
#endif
} }
if( IODGetByte( &i_data, &p_data ) != 0x04 ) if( IODGetByte( &i_data, &p_data ) != 0x04 )
{ {
#ifdef TS_DEBUG ts_debug( "\n* ERR missing DecoderConfigDescr" );
fprintf( stderr, "\n* ERR missing DecoderConfigDescr" );
#endif
es_descr.b_ok = 0; es_descr.b_ok = 0;
break; break;
} }
i_decoderConfigDescr_length = IODDescriptorLength( &i_data, &p_data ); i_decoderConfigDescr_length = IODDescriptorLength( &i_data, &p_data );
#ifdef TS_DEBUG ts_debug( "\n* - DecoderConfigDesc length:%d", i_decoderConfigDescr_length );
fprintf( stderr, "\n* - DecoderConfigDesc length:%d", i_decoderConfigDescr_length );
#endif
#define dec_descr es_descr.dec_descr #define dec_descr es_descr.dec_descr
dec_descr.i_objectTypeIndication = IODGetByte( &i_data, &p_data ); dec_descr.i_objectTypeIndication = IODGetByte( &i_data, &p_data );
i_flags = IODGetByte( &i_data, &p_data ); i_flags = IODGetByte( &i_data, &p_data );
...@@ -2526,14 +2512,12 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data ) ...@@ -2526,14 +2512,12 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data )
dec_descr.i_bufferSizeDB = IODGet3Bytes( &i_data, &p_data ); dec_descr.i_bufferSizeDB = IODGet3Bytes( &i_data, &p_data );
dec_descr.i_maxBitrate = IODGetDWord( &i_data, &p_data ); dec_descr.i_maxBitrate = IODGetDWord( &i_data, &p_data );
dec_descr.i_avgBitrate = IODGetDWord( &i_data, &p_data ); dec_descr.i_avgBitrate = IODGetDWord( &i_data, &p_data );
#ifdef TS_DEBUG ts_debug( "\n* * objectTypeIndication:0x%x", dec_descr.i_objectTypeIndication );
fprintf( stderr, "\n* * objectTypeIndication:0x%x", dec_descr.i_objectTypeIndication ); ts_debug( "\n* * streamType:0x%x", dec_descr.i_streamType );
fprintf( stderr, "\n* * streamType:0x%x", dec_descr.i_streamType ); ts_debug( "\n* * upStream:%d", dec_descr.b_upStream );
fprintf( stderr, "\n* * upStream:%d", dec_descr.b_upStream ); ts_debug( "\n* * bufferSizeDB:%d", dec_descr.i_bufferSizeDB );
fprintf( stderr, "\n* * bufferSizeDB:%d", dec_descr.i_bufferSizeDB ); ts_debug( "\n* * maxBitrate:%d", dec_descr.i_maxBitrate );
fprintf( stderr, "\n* * maxBitrate:%d", dec_descr.i_maxBitrate ); ts_debug( "\n* * avgBitrate:%d", dec_descr.i_avgBitrate );
fprintf( stderr, "\n* * avgBitrate:%d", dec_descr.i_avgBitrate );
#endif
if( i_decoderConfigDescr_length > 13 && IODGetByte( &i_data, &p_data ) == 0x05 ) if( i_decoderConfigDescr_length > 13 && IODGetByte( &i_data, &p_data ) == 0x05 )
{ {
int i; int i;
...@@ -2563,20 +2547,14 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data ) ...@@ -2563,20 +2547,14 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data )
if( IODGetByte( &i_data, &p_data ) != 0x06 ) if( IODGetByte( &i_data, &p_data ) != 0x06 )
{ {
#ifdef TS_DEBUG ts_debug( "\n* ERR missing SLConfigDescr" );
fprintf( stderr, "\n* ERR missing SLConfigDescr" );
#endif
es_descr.b_ok = 0; es_descr.b_ok = 0;
break; break;
} }
i_SLConfigDescr_length = IODDescriptorLength( &i_data, &p_data ); i_SLConfigDescr_length = IODDescriptorLength( &i_data, &p_data );
#ifdef TS_DEBUG ts_debug( "\n* - SLConfigDescr length:%d", i_SLConfigDescr_length );
fprintf( stderr, "\n* - SLConfigDescr length:%d", i_SLConfigDescr_length );
#endif
i_predefined = IODGetByte( &i_data, &p_data ); i_predefined = IODGetByte( &i_data, &p_data );
#ifdef TS_DEBUG ts_debug( "\n* * i_predefined:0x%x", i_predefined );
fprintf( stderr, "\n* * i_predefined:0x%x", i_predefined );
#endif
switch( i_predefined ) switch( i_predefined )
{ {
case 0x01: case 0x01:
...@@ -2612,9 +2590,7 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data ) ...@@ -2612,9 +2590,7 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data )
} }
break; break;
default: default:
#ifdef TS_DEBUG ts_debug( "\n* ERR unsupported SLConfigDescr predefined" );
fprintf( stderr, "\n* ERR unsupported SLConfigDescr predefined" );
#endif
es_descr.b_ok = 0; es_descr.b_ok = 0;
break; break;
} }
...@@ -2623,9 +2599,7 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data ) ...@@ -2623,9 +2599,7 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data )
#undef sl_descr #undef sl_descr
#undef es_descr #undef es_descr
default: default:
#ifdef TS_DEBUG ts_debug( "\n* - OD tag:0x%x length:%d (Unsupported)", i_tag, i_length );
fprintf( stderr, "\n* - OD tag:0x%x length:%d (Unsupported)", i_tag, i_length );
#endif
break; break;
} }
...@@ -2633,9 +2607,7 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data ) ...@@ -2633,9 +2607,7 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data )
i_data = i_data_sav - i_length; i_data = i_data_sav - i_length;
i_es_index++; i_es_index++;
} }
#ifdef TS_DEBUG ts_debug( "\n*****************************\n" );
fprintf( stderr, "\n*****************************\n" );
#endif
return p_iod; return p_iod;
} }
......
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