From: longinus Date: Mon, 31 Jan 2011 02:58:13 +0000 (+0000) Subject: fix logo parse func X-Git-Url: http://git.osdn.net/view?p=rec10%2Frec10-git.git;a=commitdiff_plain;h=4500bdc373a7e8920d8aebb8095a7d5d549e2094;ds=sidebyside fix logo parse func git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@822 4e526526-5e11-4fc0-8910-f8fd03428081 --- diff --git a/epgdump/Makefile b/epgdump/Makefile index 8f2d778..79264f4 100644 --- a/epgdump/Makefile +++ b/epgdump/Makefile @@ -7,14 +7,19 @@ LANG = C CC = gcc #CFLAGS = -std=c99 -O2 -Wall -g -CFLAGS = -std=c99 -O0 -Wall -ggdb -#CFLAGS = -std=c99 -O2 -Wall -ggdb +#CFLAGS = -std=c99 -O0 -Wall -ggdb +CFLAGS = -std=c99 -O2 -Wall -ggdb #CFLAGS = -std=c99 -O2 -Wall -ggdb -lefence +CXX = g++ +CXXFLAGS = -O2 -Wall -ggdb -lstdc++ + LIBS = .c.o: ${CC} ${CFLAGS} -c $< +.cpp.o: $(CXX) $(CXXFLAGS) -o $@ -c $^ + all: ${TARGETS} ${TARGETS}: ${OBJ_TARGETS} diff --git a/epgdump/dsmcc.c b/epgdump/dsmcc.c index c521769..0a21085 100644 --- a/epgdump/dsmcc.c +++ b/epgdump/dsmcc.c @@ -9,6 +9,7 @@ #include "clt2png.h" // STD-B21 p130 (144) +// a_90-with-att.pdf p24 (29/99) int parseDSMCChead(unsigned char *data, DSMCChead *dsmh) { int boff = 0; @@ -29,6 +30,8 @@ int parseDSMCChead(unsigned char *data, DSMCChead *dsmh) { return 8; } +// a_90-with-att.pdf p29 (34/99) +// 2-STD-B24v5_4-3p3.pdf p16 (30/125) int parseDSMCCbodyDII(unsigned char *data, DSMCCbodyDII *dsmbdii) { int boff = 0, i; DSMCCbodyDIIModule *module; @@ -81,7 +84,7 @@ int parseDSMCCbodyDII(unsigned char *data, DSMCCbodyDII *dsmbdii) { dsmbdii->numberOfModules = getBit(data, &boff, 16); if ( dsmbdii->numberOfModules > 0 ) { - dsmbdii->modules = calloc(1, sizeof(DSMCCbodyDIIModule) * dsmbdii->numberOfModules); + dsmbdii->modules = calloc(1, sizeof(DSMCCbodyDIIModule) * dsmbdii->numberOfModules + 1000); for (i=0; inumberOfModules; i++) { module = dsmbdii->modules + sizeof(DSMCCbodyDIIModule) * i; @@ -89,7 +92,33 @@ int parseDSMCCbodyDII(unsigned char *data, DSMCCbodyDII *dsmbdii) { module->moduleSize = getBit(data, &boff, 32); module->moduleVersion = getBit(data, &boff, 8); module->moduleInfoLength = getBit(data, &boff, 8); - module->moduleInfo = allocCopy(data, &boff, module->moduleInfoLength); + + if ( *(data + boff / 8) == 0x01 ) { + /* Type 記述子 モジュールの型(MIME 形式等) */ + module->descriptor_tag = getBit(data, &boff, 8); + module->descriptor_length = getBit(data, &boff, 8); + module->Type = allocCopy(data, &boff, module->descriptor_length + 1); + module->Type[module->descriptor_length] = '\0'; + // +1 byte for null-terminated + } + else if ( *(data + boff / 8) == 0x02 ) { + /* Name 記述子 モジュール名(ファイル名) */ + module->descriptor_tag = getBit(data, &boff, 8); + module->descriptor_length = getBit(data, &boff, 8); + module->Name = allocCopy(data, &boff, module->descriptor_length + 1); + module->Name[module->descriptor_length] = '\0'; + } + else if ( *(data + boff / 8) == 0x03 ) { + /* Info 記述子 モジュール情報(文字型) */ + module->descriptor_tag = getBit(data, &boff, 8); + module->descriptor_length = getBit(data, &boff, 8); + boff += 24; // ISO_639_language_code + module->Info = allocCopy(data, &boff, module->descriptor_length - 3 + 1); + module->Info[module->descriptor_length] = '\0'; + } + else { + module->moduleInfo = allocCopy(data, &boff, module->moduleInfoLength); + } } } @@ -99,6 +128,7 @@ int parseDSMCCbodyDII(unsigned char *data, DSMCCbodyDII *dsmbdii) { return boff / 8; } +// a_90-with-att.pdf p35 (40/99) int parseDSMCCbodyDDB(unsigned char *data, DSMCCbodyDDB *dsmbddb) { int boff = 0; @@ -121,12 +151,12 @@ int parseDSMCCbodyDDB(unsigned char *data, DSMCCbodyDDB *dsmbddb) { dsmbddb->moduleVersion = getBit(data, &boff, 8); dsmbddb->reserved2 = getBit(data, &boff, 8); dsmbddb->blockNumber = getBit(data, &boff, 16); - dsmbddb->blockData = allocCopy(data, &boff, dsmbddb->adaptationLength); + dsmbddb->blockData = allocCopy(data, &boff, dsmbddb->messageLength); return boff / 8; } -void dumpDSMCC(unsigned char *ptr, STATION *station, int station_count) +void dumpDSMCC(unsigned char *ptr, int * downloadDataId, DSM_CONTROL *dsmctl) { DSMCChead dsmh; DSMCCbodyDII dsmbdii; @@ -148,8 +178,8 @@ void dumpDSMCC(unsigned char *ptr, STATION *station, int station_count) */ if ( dsmh.table_id == 0x3B ) { len = parseDSMCCbodyDII(ptr, &dsmbdii); -#if 1 - printf("DSMCCbDDI=(%d:%d:%d:%d:%d:%d) (%d:%d:%d:%d)\n", +#if 0 + printf("DSMCCbDII=(%d:%d:%d:%d:%d:%d) (%d:%d:%d:%d)\n", dsmbdii.protocolDiscriminator, dsmbdii.dsmccType, dsmbdii.messageId, dsmbdii.transaction_id, dsmbdii.adaptationLength, dsmbdii.messageLength, @@ -159,24 +189,37 @@ void dumpDSMCC(unsigned char *ptr, STATION *station, int station_count) #endif for (i=0; imoduleInfo == 0x01 ) { - printf("1 %d %s\n",module, module->moduleInfo + 2); + // 0x01 Type 記述子 + // 0x02 Name 記述子 + // 0x03 Info 記述子 + if ( module->descriptor_tag == 0x01 ) { + //printf("1 %s\n", module->Type); } - else if ( *module->moduleInfo == 0x02 ) { - printf("2 %s\n",module->moduleInfo + 2); + else if ( module->descriptor_tag == 0x02 ) { + //printf("2 %s\n", module->Name); + // is_bs_cs == 1 && + if ( !strncmp( module->Name, "LOGO", 4 ) ) { + //printf("%s(%d) : id = %d\n", module->Name, is_bs_cs, dsmbdii.downloadId); + *downloadDataId = dsmbdii.downloadId; + } + // なぜかBSにCSのロゴも載ってるため + // is_bs_cs == 2 && + else if ( !strncmp( module->Name, "CS_LOGO", 7 ) ) { + //printf("%s(%d) : id = %d\n", module->Name, is_bs_cs, dsmbdii.downloadId); + *downloadDataId = dsmbdii.downloadId; + } } - else if ( *module->moduleInfo == 0x03 ) { - printf("3 %s\n",module->moduleInfo); + else if ( module->descriptor_tag == 0x03 ) { + //printf("3 %s\n", module->Info); } - */ } } else if ( dsmh.table_id == 0x3C ) { len = parseDSMCCbodyDDB(ptr, &dsmbddb); -// if ( station[0].logo_download_data_id == dsmbddb.downloadId ) { -// if ( 151585024 == dsmbddb.downloadId ) { -#if 1 + if ( *downloadDataId == dsmbddb.downloadId ) { +// if ( 33882368 == dsmbddb.downloadId ) { +// { +#if 0 printf("DSMCCbDDB=(%d:%d:%d:%d:%d:%d) (%d:%d:%d)\n", dsmbddb.protocolDiscriminator, dsmbddb.dsmccType, dsmbddb.messageId, dsmbddb.downloadId, @@ -184,7 +227,31 @@ void dumpDSMCC(unsigned char *ptr, STATION *station, int station_count) dsmbddb.moduleId , dsmbddb.moduleVersion , dsmbddb.blockNumber); #endif -// } + + for (i = 0; i < 1024; i++) { + if ( dsmctl[i].isUsed == 0 ) { + // リストの終端まで来たので + //printf("moduleId=%d as dsmctl[%d]\n", dsmbddb.moduleId, i); + dsmctl[i].moduleId = dsmbddb.moduleId; + dsmctl[i].lastBlockNumber = -1; + dsmctl[i].isUsed = 1; + } + if ( dsmctl[i].moduleId == dsmbddb.moduleId ) { + if ( dsmctl[i].lastBlockNumber + 1 == dsmbddb.blockNumber ) { + dsmbddb.messageLength -= 6; // length of moduleId, moduleVersion, reserved, blockNumber + //printf("moduleId=%d as dsmctl[%d] size %d += %d\n", dsmbddb.moduleId, i, dsmctl[i].blockSize, dsmbddb.messageLength); + dsmctl[i].blockData = realloc( dsmctl[i].blockData, dsmctl[i].blockSize + dsmbddb.messageLength ); + memcpy( dsmctl[i].blockData + dsmctl[i].blockSize, dsmbddb.blockData, dsmbddb.messageLength ); + dsmctl[i].blockSize += dsmbddb.messageLength; + dsmctl[i].lastBlockNumber++; + } + else { + //printf("ignoring %d(max %d)\n", dsmbddb.blockNumber, dsmctl[i].lastBlockNumber); + } + break; + } + } + } } return; diff --git a/epgdump/dsmcc.h b/epgdump/dsmcc.h index 4ff5a06..edd174d 100644 --- a/epgdump/dsmcc.h +++ b/epgdump/dsmcc.h @@ -39,6 +39,12 @@ typedef struct _DSMCCbodyDIIModule { int moduleVersion; int moduleInfoLength; unsigned char *moduleInfo; + + int descriptor_tag; + int descriptor_length; + char *Type; + char *Name; + char *Info; } DSMCCbodyDIIModule; typedef struct _DSMCCbodyDII { @@ -87,7 +93,7 @@ extern "C"{ int parseDSMCChead(unsigned char *data, DSMCChead *h); int parseDSMCCbodyDDB(unsigned char *data, DSMCCbodyDDB *dsmbddb); - void dumpDSMCC(unsigned char *ptr, STATION *station, int station_count); + void dumpDSMCC(unsigned char *ptr, int *downloadDataId, DSM_CONTROL *dsmctl); #ifdef __cplusplus } diff --git a/epgdump/epgdump.c b/epgdump/epgdump.c index 305b838..e4dd11e 100755 --- a/epgdump/epgdump.c +++ b/epgdump/epgdump.c @@ -11,8 +11,10 @@ #include "sdt.h" #include "sdtt.h" #include "eit.h" +#include "tot.h" #include "dsmcc.h" #include "ts_ctl.h" +#include "util.h" typedef struct _ContentTYPE{ char *japanese ; @@ -41,6 +43,7 @@ static CONTENT_TYPE ContentCatList[CAT_COUNT] = { SVT_CONTROL *svttop = NULL; +DSM_CONTROL dsmctl[1024]; #define SECCOUNT 64 char title[1024]; char subtitle[1024]; @@ -111,22 +114,18 @@ void xmlspecialchars(char *str) void GetSDT(FILE *infile, SVT_CONTROL *svttop, SECcache *secs, - int count, STATION **station, int * station_count, char *header, int is_bs_cs) + int count, STATION **station, int * station_count, char *header, int is_bs_cs_logo) { SECcache *bsecs; int pmtpids[SECCOUNT]; memset(pmtpids, 0, sizeof(pmtpids)); int dsmccpids[SECCOUNT]; memset(dsmccpids, 0, sizeof(dsmccpids)); - int i = 0; + int i = 0 , downloadDataId = 0; while((bsecs = readTS(infile, secs, count)) != NULL) { - /* PAT */ - if(is_bs_cs && (bsecs->pid & 0xFF) == 0x00) { - dumpPAT(bsecs->buf, secs, count, pmtpids); - } /* SDT */ - else if((bsecs->pid & 0xFF) == 0x11) { + if((bsecs->pid & 0xFF) == 0x11) { dumpSDT(bsecs->buf, svttop, station, station_count, header); } /* TOT */ @@ -134,14 +133,19 @@ void GetSDT(FILE *infile, SVT_CONTROL *svttop, SECcache *secs, dumpTOT(bsecs->buf); } /* SDTT */ - else if((bsecs->pid & 0xFF) == 0x23) { - dumpSDTT(bsecs->buf, *station, *station_count); - } + //else if((bsecs->pid & 0xFF) == 0x23) { + // dumpSDTT(bsecs->buf, *station, *station_count); + //} /* CDT */ else if((bsecs->pid & 0xFF) == 0x29) { dumpCDT(bsecs->buf, *station, *station_count); } - else if ( is_bs_cs ) { + else if ( is_bs_cs_logo ) { + /* PAT */ + if((bsecs->pid & 0xFF) == 0x00) { + dumpPAT(bsecs->buf, secs, count, pmtpids); + } + /* PMT */ for ( i = 1; i < SECCOUNT; i++ ) { if ( pmtpids[i] == 0 ) { break; @@ -151,14 +155,14 @@ void GetSDT(FILE *infile, SVT_CONTROL *svttop, SECcache *secs, dumpPMT(bsecs->buf, secs, count, dsmccpids); } } - + /* DSM-CC */ for ( i = 0; i < SECCOUNT; i++ ) { if ( dsmccpids[i] == 0 ) { break; } /* DSM-CC specified by PMT */ if ( bsecs->pid == dsmccpids[i] ) { - dumpDSMCC(bsecs->buf, *station, *station_count); + dumpDSMCC(bsecs->buf, &downloadDataId, &dsmctl); } } } @@ -279,66 +283,36 @@ void GetEIT(FILE *infile, FILE *outfile, STATION *psta, SECcache *secs) free(eittop); eittop = NULL; } -void checkSta_BS(STATION **station,int *stalength){ - STATION *statmp; - int chl[30]; - int chlt=0; - int stal=0; - STATION * statin= *station; - statmp=malloc(sizeof(STATION)*2); - for (int i=0;i<*stalength;i++){ - int noidinchl=1; - for (int j=0;j= 290){ - noidinchl=0; - } - } - if (noidinchl==1){ - statmp=realloc(statmp,(stal+1)*sizeof(STATION)); - statmp[stal]=statin[i]; - //memcpy(statmp[stal-1],station[i],sizeof(STATION)); - chl[chlt]=statin[i].svId; - chlt++; - stal++; - } - } - //*station=realloc(station,(stal+1)*sizeof(STATION)); - //memcpy(*station,statmp,(stal+1)*sizeof(STATION)); - *station=statmp; - *stalength=stal; - //memcpy(statin,statmp,chlt*sizeof(STATION)); - //free(statmp); -} void checkSta(STATION **station,int *stalength){ STATION *statmp; int chl[90]; - int chlt=0; - int stal=0; - STATION * statin= *station; - statmp=malloc(sizeof(STATION)*2); - for (int i=0;i<*stalength;i++){ - int noidinchl=1; - for (int j=0;j \n", argv[0]); - fprintf(stdout, "Usage : %s \n", argv[0]); + fprintf(stdout, "Usage : %s {/BS|/CS} \n", argv[0]); + fprintf(stdout, "Usage : %s \n", argv[0]); fprintf(stdout, "\n"); fprintf(stdout, "id チャンネル識別子。地上波の物理チャンネルを与えます。\n"); fprintf(stdout, "/BS BSモード。一つのTSからBS全局のデータを読み込みます。\n"); @@ -412,54 +389,37 @@ int main(int argc, char *argv[]) return 0; } - if(strcmp(arg_onTV, "/BS") == 0){ - STATION *sta = NULL; - int sta_count = 0; - svttop = calloc(1, sizeof(SVT_CONTROL)); - char *head="BS"; - GetSDT(infile, svttop, secs, SECCOUNT,&sta, &sta_count, head, 1); - checkSta_BS(&sta,&sta_count); - pStas = sta; - staCount = sta_count; - //staCount = sizeof(pStas) / sizeof (STATION); - act = 0 ; - }else if(strcmp(arg_onTV, "/CS") == 0){ - STATION *sta=NULL; - int sta_count = 0; - svttop = calloc(1, sizeof(SVT_CONTROL)); - char *head="CS"; - GetSDT(infile, svttop, secs, SECCOUNT,&sta, &sta_count, head, 1); - checkSta(&sta,&sta_count); - pStas = sta; - staCount = sta_count; - //staCount=sizeof(pStas) / sizeof (STATION); - act = 0 ; - }else if(strcmp(arg_onTV, "/TEST") == 0){ - STATION *sta=NULL; - int sta_count = 0; - svttop = calloc(1, sizeof(SVT_CONTROL)); - char *head="TEST"; - GetSDT(infile, svttop, secs, SECCOUNT,&sta, &sta_count, head, 0); - checkSta(&sta,&sta_count); - //if (sta_count) - printf("Station count: %d\n1st ontv=%s,name=%s\n",sta_count, sta[0].ontv, sta[0].name); - pStas = sta; - staCount = sta_count;// sizeof(pStas) / sizeof (STATION); - act = 0 ; - }else if(strcmp(arg_onTV, "/TIME") == 0){ + pStas = NULL; + staCount = 0; + svttop = calloc(1, sizeof(SVT_CONTROL)); + act = 0 ; + + if(strcmp(arg_onTV, "/TIME") == 0){ printf("TSに載っている時刻データは2秒ほど早めてあるのかもしれません。\n"); memset(secs, 0, sizeof(SECcache) * SECCOUNT); secs[0].pid = 0x14; /* TOT */ GetSDT(infile, NULL, secs, SECCOUNT,NULL, NULL,NULL, 0); - act = 0 ; goto cleanup; + }else if(strcmp(arg_onTV, "/BS") == 0){ + char *head = "BS"; + GetSDT(infile, svttop, secs, SECCOUNT, &pStas, &staCount, head, 0); + }else if(strcmp(arg_onTV, "/CS") == 0){ + char *head = "CS"; + GetSDT(infile, svttop, secs, SECCOUNT, &pStas, &staCount, head, 0); + }else if(strcmp(arg_onTV, "/BSCSLOGO") == 0){ + is_bs_cs_logo = 1; + GetSDT(infile, svttop, secs, SECCOUNT, &pStas, &staCount, "", 1); + }else if(strcmp(arg_onTV, "/TEST") == 0){ + char *head = "TEST"; + GetSDT(infile, svttop, secs, SECCOUNT, &pStas, &staCount, head, 0); + //if (sta_count) + // printf("Station count: %d\n1st ontv=%s,name=%s\n",staCount, pStas[0].ontv, pStas[0].name); }else{ - if(infile == NULL){ - fprintf(stderr, "Can't open file: %s\n", argv[2]); - return 1; - } + GetSDT(infile, svttop, secs, SECCOUNT, &pStas, &staCount, arg_onTV, 0); + + // 地上波のマルチチャンネル対応のためコメントアウト /* act = 1 ; svttop = calloc(1, sizeof(SVT_CONTROL)); @@ -478,24 +438,73 @@ int main(int argc, char *argv[]) pStas->name = svtcur->servicename ; staCount = 1; */ - - // 地上波のマルチチャンネル対応のため - STATION *sta = NULL; - int sta_count = 0; - svttop = calloc(1, sizeof(SVT_CONTROL)); - //char *head=arg_onTV; - GetSDT(infile, svttop, secs, SECCOUNT, &sta, &sta_count, arg_onTV, 0); - checkSta(&sta, &sta_count); - //if (sta_count) printf("Station count: %d\n1st ontv=%s,name=%s\n",sta_count, sta[0].ontv, sta[0].name); - pStas = sta; - staCount = sta_count;// sizeof(pStas) / sizeof (STATION); - act = 0 ; } + checkSta(&pStas, &staCount); fprintf(outfile, "\n"); fprintf(outfile, "\n\n"); fprintf(outfile, "\n"); + for ( i = 0; i < 1024; i++) { + if ( dsmctl[i].isUsed == 0 ) break; + parseSDTTdata(dsmctl[i].blockData, &sdtd); + + for (j = 0; j < sdtd.number_of_loop; j++) { + loop = sdtd.loop + sizeof(SDTTdataLoop) * j; + + for ( k = 0; k < loop->number_of_services; k++) { + service = loop->services + sizeof(SDTTdataService) * k; + + /* + for(lp = 0 ; lp < staCount ; lp++){ + if ( + pStas[lp].tsId == service->transport_stream_id && + pStas[lp].onId == service->original_network_id && + pStas[lp].svId == service->service_id + ) { + clt2png(loop->data, + &pStas[lp].logo_array[sdtd.logo_type].logo, + &pStas[lp].logo_array[sdtd.logo_type].logo_size); + } + } + */ + + #if 0 + printf( "SDTTdataLoop (%d:%d) %d:%d[%d:%d:%d]%d\n", + i, j, + sdtd.logo_type, + loop->logo_id, + service->transport_stream_id, + service->original_network_id, + service->service_id, + loop->data_size + ); + #endif + + if ( is_bs_cs_logo ) { + fprintf(outfile, " %d\n", + service->transport_stream_id, + service->original_network_id, + service->service_id, + sdtd.logo_type, + loop->logo_id); + } + } + + if ( is_bs_cs_logo ) { + void* logo = NULL; + int logo_size = 0; + + clt2png(loop->data, &logo, &logo_size); + memset(Logo, '\0', sizeof(Logo)); + base64_encode(Logo, logo, logo_size); + xmlspecialchars(Logo); + fprintf(outfile, " %s\n", + loop->logo_id, + Logo); + } + } + } for(lp = 0 ; lp < staCount ; lp++){ memset(ServiceName, '\0', sizeof(ServiceName)); strcpy(ServiceName, pStas[lp].name); @@ -503,18 +512,23 @@ int main(int argc, char *argv[]) fprintf(outfile, " \n", pStas[lp].ontv); fprintf(outfile, " %s\n", ServiceName); + fprintf(outfile, " \n", pStas[lp].tsId, pStas[lp].onId, pStas[lp].svId); memset(Logo, '\0', sizeof(Logo)); for ( i = 0 ; i < 6 ; i++) { if (pStas[lp].logo_array[i].logo) { base64_encode(Logo, pStas[lp].logo_array[i].logo, pStas[lp].logo_array[i].logo_size); xmlspecialchars(Logo); - fprintf(outfile, " %s\n", i, Logo); + fprintf(outfile, " %s\n", i, Logo); } } fprintf(outfile, " \n"); } + if ( is_bs_cs_logo ) { + fprintf(outfile, "\n"); + goto cleanup; + } for(lp = 0 ; lp < staCount ; lp++){ GetEIT(infile, outfile, &pStas[lp], secs); } @@ -538,3 +552,4 @@ cleanup: return 0; } + diff --git a/epgdump/psi.c b/epgdump/psi.c index bfeaeda..c6a43ee 100644 --- a/epgdump/psi.c +++ b/epgdump/psi.c @@ -6,6 +6,7 @@ #include "psi.h" +// 2-STD-B10v4_6.pdf p178 (190/399) int parsePAThead(unsigned char *data, PAThead *path) { int boff = 0; @@ -91,6 +92,7 @@ void dumpPAT(unsigned char *ptr, SECcache *secs, int count, int *pmtpids) return; } +// 2-STD-B10v4_6.pdf p180 (192/399( int parsePMThead(unsigned char *data, PMThead *pmth) { int boff = 0; @@ -165,13 +167,14 @@ void dumpPMT(unsigned char *ptr, SECcache *secs, int count, int *dsmccpids) printf("PMTb=(0x%x:%d:%d)\n", pmtb.stream_type , pmtb.elementary_PID , pmtb.ES_info_length); */ + // 2-STD-B24v5_4-3p3.pdf p11 (25/125) if ( pmtb.stream_type == 0x0B || pmtb.stream_type == 0x0D ) { for ( i = 1; i < count; i++ ) { if ( secs[i].pid == pmtb.elementary_PID ) { break; } if ( secs[i].pid == 0 ) { - printf("PMT: Adding PID(0x%04x) to secs[%d]\n", pmtb.elementary_PID, i); + //printf("PMT: Adding PID(0x%04x) to secs[%d]\n", pmtb.elementary_PID, i); secs[i].pid = pmtb.elementary_PID; break; } @@ -181,7 +184,7 @@ void dumpPMT(unsigned char *ptr, SECcache *secs, int count, int *dsmccpids) break; } if ( dsmccpids[i] == 0 ) { - printf("PMT: Adding PID(0x%04x) to dsmccpids[%d]\n", pmtb.elementary_PID, i); + //printf("PMT: Adding PID(0x%04x) to dsmccpids[%d]\n", pmtb.elementary_PID, i); dsmccpids[i] = pmtb.elementary_PID; break; } diff --git a/epgdump/sdt.c b/epgdump/sdt.c index bfc3c28..0f8d12a 100755 --- a/epgdump/sdt.c +++ b/epgdump/sdt.c @@ -214,8 +214,7 @@ void dumpSDT(unsigned char *ptr, SVT_CONTROL *top,STATION **station, int * stati } } - pStation = realloc(pStation,(stationi+1)*sizeof(STATION)); - if (!pStation) printf( "Realloc returned NULL!!! stationi = %d\n", stationi); + pStation = realloc(pStation, (stationi + 1) * sizeof(STATION)); pStation[stationi].name = malloc( strlen(desc.service_name) + 1 ); pStation[stationi].ontv = malloc( strlen(sid) + 1 ); pStation[stationi].tsId = sdth.transport_stream_id; diff --git a/epgdump/sdtt.c b/epgdump/sdtt.c index cdb2fdd..eeeecbd 100644 --- a/epgdump/sdtt.c +++ b/epgdump/sdtt.c @@ -140,24 +140,24 @@ int parseSDTTdesc(unsigned char *data, SDTTdesc *sdts) { } // STD-B21 p193 (209) -int parseSDTTdata(unsigned char *data, SDTTdata *cdtd) { +int parseSDTTdata(unsigned char *data, SDTTdata *sdtd) { int boff = 0, i, j; SDTTdataLoop *loop; SDTTdataService *service; - memset(cdtd, 0, sizeof(SDTTdata)); + memset(sdtd, 0, sizeof(SDTTdata)); - cdtd->logo_type = getBit(data, &boff, 8); - cdtd->number_of_loop = getBit(data, &boff, 16); - cdtd->loop = calloc(1, sizeof(SDTTdataLoop) * cdtd->number_of_loop); + sdtd->logo_type = getBit(data, &boff, 8); + sdtd->number_of_loop = getBit(data, &boff, 16); + sdtd->loop = calloc(1, ( sizeof(SDTTdataLoop) + 5000 ) * sdtd->number_of_loop); - for (i=0; inumber_of_loop; i++) { - loop = cdtd->loop + sizeof(SDTTdataLoop) * i; + for (i=0; inumber_of_loop; i++) { + loop = sdtd->loop + sizeof(SDTTdataLoop) * i; loop->reserved_future_use1 = getBit(data, &boff, 7); loop->logo_id = getBit(data, &boff, 9); loop->number_of_services = getBit(data, &boff, 8); - loop->services = calloc(1, sizeof(SDTTdataService) * loop->number_of_services); + loop->services = calloc(1, ( sizeof(SDTTdataService) + 5000 )* loop->number_of_services); for (j=0; jnumber_of_services; j++) { service = loop->services + sizeof(SDTTdataService) * j; @@ -237,7 +237,7 @@ void dumpSDTT(unsigned char *ptr, STATION *station, int station_count) len = parseSDTTdesc(ptr, &sdts); ptr += len; desc_len -= len; -#if 1 +#if 0 printf("SDTTdesc %d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%s\n", sdts.descriptor_tag, sdts.descriptor_length, sdts.reboot, sdts.add_on, @@ -255,7 +255,7 @@ void dumpSDTT(unsigned char *ptr, STATION *station, int station_count) printf("sdts.Name %s id:%d\n", module->Name, sdts.download_id); if ( strstr( module->Name, "CS_LOGO" ) ) { - station[0].logo_download_data_id = sdts.download_id; + //station[0].logo_download_data_id = sdts.download_id; } else if ( strstr( module->Name, "LOGO" ) ) { station[0].logo_download_data_id = sdts.download_id; @@ -279,8 +279,8 @@ void dumpSDTT(unsigned char *ptr, STATION *station, int station_count) cdth.original_network_id, cdth.data_type, cdth.section_length, cdth.descriptors_loop_length, - cdtdte.logo_type, cdtdte.logo_id, cdtdte.logo_version, - cdtdte.data_size); + sdtdte.logo_type, sdtdte.logo_id, sdtdte.logo_version, + sdtdte.data_size); #endif } } diff --git a/epgdump/tot.c b/epgdump/tot.c index 15c7641..a0d5948 100644 --- a/epgdump/tot.c +++ b/epgdump/tot.c @@ -45,7 +45,6 @@ void dumpTOT(unsigned char *ptr) int len = 0; int loop_len = 0; int desc_len = 0; - int i = 0; time_t tot; /* TOT */ diff --git a/epgdump/ts_ctl.h b/epgdump/ts_ctl.h index 098ac73..3d3ccad 100755 --- a/epgdump/ts_ctl.h +++ b/epgdump/ts_ctl.h @@ -38,5 +38,15 @@ struct _EIT_CONTROL{ char *desc ; // Description int desc_length ; // Description Length }; + +typedef struct _DSM_CONTROL DSM_CONTROL; +struct _DSM_CONTROL{ + int isUsed ; + int moduleId ; + int lastBlockNumber ; + int blockSize ; + void *blockData ; +}; + #endif diff --git a/epgdump/util.h b/epgdump/util.h index 2cc701c..a2cff51 100755 --- a/epgdump/util.h +++ b/epgdump/util.h @@ -9,6 +9,7 @@ extern "C"{ #endif /* __cplusplus */ + int strrep(char *buf, char *mae, char *ato); int getBit(unsigned char *byte, int *pbit, int gbit); void getStr(char *tostr, unsigned char *byte, int *pbit, int len); int parseOTHERdesc(unsigned char *data);