📄 ts.c
字号:
(*pp_data)++; (*pi_data)--; i_len = ( i_len << 7 ) + ( i_b&0x7f ); } while( i_b&0x80 ); return( i_len );}static int IODGetByte( int *pi_data, uint8_t **pp_data ){ if( *pi_data > 0 ) { const int i_b = **pp_data; (*pp_data)++; (*pi_data)--; return( i_b ); } return( 0 );}static int IODGetWord( int *pi_data, uint8_t **pp_data ){ const int i1 = IODGetByte( pi_data, pp_data ); const int i2 = IODGetByte( pi_data, pp_data ); return( ( i1 << 8 ) | i2 );}static int IODGet3Bytes( int *pi_data, uint8_t **pp_data ){ const int i1 = IODGetByte( pi_data, pp_data ); const int i2 = IODGetByte( pi_data, pp_data ); const int i3 = IODGetByte( pi_data, pp_data ); return( ( i1 << 16 ) | ( i2 << 8) | i3 );}static uint32_t IODGetDWord( int *pi_data, uint8_t **pp_data ){ const uint32_t i1 = IODGetWord( pi_data, pp_data ); const uint32_t i2 = IODGetWord( pi_data, pp_data ); return( ( i1 << 16 ) | i2 );}static char* IODGetURL( int *pi_data, uint8_t **pp_data ){ char *url; int i_url_len, i; i_url_len = IODGetByte( pi_data, pp_data ); url = malloc( i_url_len + 1 ); for( i = 0; i < i_url_len; i++ ) { url[i] = IODGetByte( pi_data, pp_data ); } url[i_url_len] = '\0'; return( url );}static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data ){ iod_descriptor_t *p_iod; int i; int i_es_index; uint8_t i_flags, i_iod_tag, byte1, byte2, byte3; vlc_bool_t b_url; int i_iod_length; p_iod = malloc( sizeof( iod_descriptor_t ) ); memset( p_iod, 0, sizeof( iod_descriptor_t ) ); fprintf( stderr, "\n************ IOD ************" ); for( i = 0; i < 255; i++ ) { p_iod->es_descr[i].b_ok = 0; } i_es_index = 0; if( i_data < 3 ) { return p_iod; } byte1 = IODGetByte( &i_data, &p_data ); byte2 = IODGetByte( &i_data, &p_data ); byte3 = IODGetByte( &i_data, &p_data ); if( byte2 == 0x02 ) //old vlc's buggy implementation of the IOD_descriptor { p_iod->i_iod_label_scope = 0x11; p_iod->i_iod_label = byte1; i_iod_tag = byte2; } else //correct implementation of the IOD_descriptor { p_iod->i_iod_label_scope = byte1; p_iod->i_iod_label = byte2; i_iod_tag = byte3; } fprintf( stderr, "\n* iod_label:%d", p_iod->i_iod_label ); fprintf( stderr, "\n* ===========" ); fprintf( stderr, "\n* tag:0x%x", i_iod_tag ); if( i_iod_tag != 0x02 ) { fprintf( stderr, "\n ERR: tag %02x != 0x02", i_iod_tag ); return p_iod; } i_iod_length = IODDescriptorLength( &i_data, &p_data ); fprintf( stderr, "\n* length:%d", i_iod_length ); if( i_iod_length > i_data ) { i_iod_length = i_data; } p_iod->i_od_id = ( IODGetByte( &i_data, &p_data ) << 2 ); i_flags = IODGetByte( &i_data, &p_data ); p_iod->i_od_id |= i_flags >> 6; b_url = ( i_flags >> 5 )&0x01; fprintf( stderr, "\n* od_id:%d", p_iod->i_od_id ); fprintf( stderr, "\n* url flag:%d", b_url ); fprintf( stderr, "\n* includeInlineProfileLevel flag:%d", ( i_flags >> 4 )&0x01 ); if( b_url ) { p_iod->psz_url = IODGetURL( &i_data, &p_data ); fprintf( stderr, "\n* url string:%s", p_iod->psz_url ); fprintf( stderr, "\n*****************************\n" ); return p_iod; } else { p_iod->psz_url = NULL; } p_iod->i_ODProfileLevelIndication = IODGetByte( &i_data, &p_data ); p_iod->i_sceneProfileLevelIndication = 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_graphicsProfileLevelIndication = IODGetByte( &i_data, &p_data ); fprintf( stderr, "\n* ODProfileLevelIndication:%d", p_iod->i_ODProfileLevelIndication ); fprintf( stderr, "\n* sceneProfileLevelIndication:%d", p_iod->i_sceneProfileLevelIndication ); fprintf( stderr, "\n* audioProfileLevelIndication:%d", p_iod->i_audioProfileLevelIndication ); fprintf( stderr, "\n* visualProfileLevelIndication:%d", p_iod->i_visualProfileLevelIndication ); fprintf( stderr, "\n* graphicsProfileLevelIndication:%d", p_iod->i_graphicsProfileLevelIndication ); while( i_data > 0 && i_es_index < 255) { int i_tag, i_length; int i_data_sav; uint8_t *p_data_sav; i_tag = IODGetByte( &i_data, &p_data ); i_length = IODDescriptorLength( &i_data, &p_data ); i_data_sav = i_data; p_data_sav = p_data; i_data = i_length; switch( i_tag ) { case 0x03: {#define es_descr p_iod->es_descr[i_es_index] int i_decoderConfigDescr_length; fprintf( stderr, "\n* - ES_Descriptor length:%d", i_length ); es_descr.b_ok = 1; es_descr.i_es_id = IODGetWord( &i_data, &p_data ); i_flags = IODGetByte( &i_data, &p_data ); es_descr.b_streamDependenceFlag = ( i_flags >> 7 )&0x01; b_url = ( i_flags >> 6 )&0x01; es_descr.b_OCRStreamFlag = ( i_flags >> 5 )&0x01; es_descr.i_streamPriority = i_flags & 0x1f; fprintf( stderr, "\n* * streamDependenceFlag:%d", es_descr.b_streamDependenceFlag ); fprintf( stderr, "\n* * OCRStreamFlag:%d", es_descr.b_OCRStreamFlag ); fprintf( stderr, "\n* * streamPriority:%d", es_descr.i_streamPriority ); if( es_descr.b_streamDependenceFlag ) { es_descr.i_dependOn_es_id = IODGetWord( &i_data, &p_data ); fprintf( stderr, "\n* * dependOn_es_id:%d", es_descr.i_dependOn_es_id ); } if( b_url ) { es_descr.psz_url = IODGetURL( &i_data, &p_data ); fprintf( stderr, "\n* url string:%s", es_descr.psz_url ); } else { es_descr.psz_url = NULL; } if( es_descr.b_OCRStreamFlag ) { es_descr.i_OCR_es_id = IODGetWord( &i_data, &p_data ); fprintf( stderr, "\n* * OCR_es_id:%d", es_descr.i_OCR_es_id ); } if( IODGetByte( &i_data, &p_data ) != 0x04 ) { fprintf( stderr, "\n* ERR missing DecoderConfigDescr" ); es_descr.b_ok = 0; break; } i_decoderConfigDescr_length = IODDescriptorLength( &i_data, &p_data ); fprintf( stderr, "\n* - DecoderConfigDesc length:%d", i_decoderConfigDescr_length );#define dec_descr es_descr.dec_descr dec_descr.i_objectTypeIndication = IODGetByte( &i_data, &p_data ); i_flags = IODGetByte( &i_data, &p_data ); dec_descr.i_streamType = i_flags >> 2; dec_descr.b_upStream = ( i_flags >> 1 )&0x01; dec_descr.i_bufferSizeDB = IODGet3Bytes( &i_data, &p_data ); dec_descr.i_maxBitrate = IODGetDWord( &i_data, &p_data ); dec_descr.i_avgBitrate = IODGetDWord( &i_data, &p_data ); fprintf( stderr, "\n* * objectTypeIndication:0x%x", dec_descr.i_objectTypeIndication ); fprintf( stderr, "\n* * streamType:0x%x", dec_descr.i_streamType ); fprintf( stderr, "\n* * upStream:%d", dec_descr.b_upStream ); fprintf( stderr, "\n* * bufferSizeDB:%d", dec_descr.i_bufferSizeDB ); fprintf( stderr, "\n* * maxBitrate:%d", dec_descr.i_maxBitrate ); fprintf( stderr, "\n* * avgBitrate:%d", dec_descr.i_avgBitrate ); if( i_decoderConfigDescr_length > 13 && IODGetByte( &i_data, &p_data ) == 0x05 ) { int i; dec_descr.i_decoder_specific_info_len = IODDescriptorLength( &i_data, &p_data ); if( dec_descr.i_decoder_specific_info_len > 0 ) { dec_descr.p_decoder_specific_info = malloc( dec_descr.i_decoder_specific_info_len ); } for( i = 0; i < dec_descr.i_decoder_specific_info_len; i++ ) { dec_descr.p_decoder_specific_info[i] = IODGetByte( &i_data, &p_data ); } } else { dec_descr.i_decoder_specific_info_len = 0; dec_descr.p_decoder_specific_info = NULL; } }#undef dec_descr#define sl_descr es_descr.sl_descr { int i_SLConfigDescr_length; int i_predefined; if( IODGetByte( &i_data, &p_data ) != 0x06 ) { fprintf( stderr, "\n* ERR missing SLConfigDescr" ); es_descr.b_ok = 0; break; } i_SLConfigDescr_length = IODDescriptorLength( &i_data, &p_data ); fprintf( stderr, "\n* - SLConfigDescr length:%d", i_SLConfigDescr_length ); i_predefined = IODGetByte( &i_data, &p_data ); fprintf( stderr, "\n* * i_predefined:0x%x", i_predefined ); switch( i_predefined ) { case 0x01: { sl_descr.b_useAccessUnitStartFlag = 0; sl_descr.b_useAccessUnitEndFlag = 0; sl_descr.b_useRandomAccessPointFlag = 0; //sl_descr.b_useRandomAccessUnitsOnlyFlag = 0; sl_descr.b_usePaddingFlag = 0; sl_descr.b_useTimeStampsFlags = 0; sl_descr.b_useIdleFlag = 0; sl_descr.b_durationFlag = 0; // FIXME FIXME sl_descr.i_timeStampResolution = 1000; sl_descr.i_OCRResolution = 0; // FIXME FIXME sl_descr.i_timeStampLength = 32; sl_descr.i_OCRLength = 0; // FIXME FIXME sl_descr.i_AU_Length = 0; sl_descr.i_instantBitrateLength= 0; // FIXME FIXME sl_descr.i_degradationPriorityLength= 0; sl_descr.i_AU_seqNumLength = 0; sl_descr.i_packetSeqNumLength = 0; if( sl_descr.b_durationFlag ) { sl_descr.i_timeScale = 0; // FIXME FIXME sl_descr.i_accessUnitDuration = 0; // FIXME FIXME sl_descr.i_compositionUnitDuration= 0; // FIXME FIXME } if( !sl_descr.b_useTimeStampsFlags ) { sl_descr.i_startDecodingTimeStamp = 0; // FIXME FIXME sl_descr.i_startCompositionTimeStamp= 0; // FIXME FIXME } } break; default: fprintf( stderr, "\n* ERR unsupported SLConfigDescr predefined" ); es_descr.b_ok = 0; break; } } break;#undef sl_descr#undef es_descr default: fprintf( stderr, "\n* - OD tag:0x%x length:%d (Unsupported)", i_tag, i_length ); break; } p_data = p_data_sav + i_length; i_data = i_data_sav - i_length; i_es_index++; } fprintf( stderr, "\n*****************************\n" ); return p_iod;}static void IODFree( iod_descriptor_t *p_iod ){ int i; if( p_iod->psz_url ) { free( p_iod->psz_url ); p_iod->psz_url = NULL; free( p_iod ); return; } for( i = 0; i < 255; i++ ) {#define es_descr p_iod->es_descr[i] if( es_descr.b_ok ) { if( es_descr.psz_url ) { free( es_descr.psz_url ); es_descr.psz_url = NULL; } else { if( es_descr.dec_descr.p_decoder_specific_info != NULL ) { free( es_descr.dec_descr.p_decoder_specific_info ); es_descr.dec_descr.p_decoder_specific_info = NULL; es_descr.dec_descr.i_decoder_specific_info_len = 0; } } } es_descr.b_ok = 0;#undef es_descr } free( p_iod );}/**************************************************************************** **************************************************************************** ** libdvbpsi callbacks **************************************************************************** ****************************************************************************/static vlc_bool_t DVBProgramIsSelected( demux_t *p_demux, uint16_t i_pgrm ){ demux_sys_t *p_sys = p_demux->p_sys; if ( !p_sys->b_dvb_control ) return VLC_FALSE; if ( p_sys->i_dvb_program == -1 && p_sys->p_programs_list == NULL ) return VLC_TRUE; if ( p_sys->i_dvb_program == i_pgrm ) return VLC_TRUE; if ( p_sys->p_programs_list != NULL ) { int i; for ( i = 0; i < p_sys->p_programs_list->i_count; i++ ) { if ( i_pgrm == p_sys->p_programs_list->p_values[i].i_int ) return VLC_TRUE; } } return VLC_FALSE;}#ifdef TS_USE_DVB_SIstatic void SDTCallBack( demux_t *p_demux, dvbpsi_sdt_t *p_sdt ){ demux_sys_t *p_sys = p_demux->p_sys; ts_pid_t *sdt = &p_sys->pid[0x11]; dvbpsi_sdt_service_t *p_srv; msg_Dbg( p_demux, "SDTCallBack called" ); if( sdt->psi->i_sdt_version != -1 && ( !p_sdt->b_current_next || p_sdt->i_version == sdt->psi->i_sdt_version ) ) { dvbpsi_DeleteSDT( p_sdt ); return; } msg_Dbg( p_demux, "new SDT ts_id=%d version=%d current_next=%d " "network_id
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -