[Xineliboutput-cvslog] vdr-xineliboutput/tools ts.h, 1.16, 1.17 ts.c, 1.26, 1.27
Brought to you by:
phintuka
From: Petri H. <phi...@us...> - 2010-07-19 13:26:19
|
Update of /cvsroot/xineliboutput/vdr-xineliboutput/tools In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv11444 Modified Files: ts.h ts.c Log Message: Added pat_changed_flag. Fixed program nimber (int -> uint16_t) Index: ts.h =================================================================== RCS file: /cvsroot/xineliboutput/vdr-xineliboutput/tools/ts.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- ts.h 16 May 2010 11:28:18 -0000 1.16 +++ ts.h 19 Jul 2010 13:12:07 -0000 1.17 @@ -103,10 +103,21 @@ #define TS_MAX_SPU_TRACKS 32 typedef struct { - int program_number[TS_MAX_PROGRAMS]; + uint16_t program_number[TS_MAX_PROGRAMS]; uint16_t pmt_pid[TS_MAX_PROGRAMS]; + + uint8_t version; + uint32_t crc32; + uint8_t pat_changed_flag; } pat_data_t; +/* + * ts_parse_pat() + * + * returns n : number of programs in PAT + * 0 : error or unchanged PAT + */ + int ts_parse_pat(pat_data_t *pat_data, const uint8_t *ts_data); @@ -146,10 +157,10 @@ } pmt_data_t; /* - * parse_pmt() + * ts_parse_pmt() * * returns 1 : PMT parsed and changed - * 0 : error or unchanged pmt + * 0 : error or unchanged PMT */ int ts_parse_pmt(pmt_data_t *pmt, uint program_no, const uint8_t *ts_data); Index: ts.c =================================================================== RCS file: /cvsroot/xineliboutput/vdr-xineliboutput/tools/ts.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- ts.c 21 May 2010 13:02:24 -0000 1.26 +++ ts.c 19 Jul 2010 13:12:10 -0000 1.27 @@ -76,6 +76,7 @@ int ts_parse_pat(pat_data_t *pat, const uint8_t *pkt) { const uint8_t *original_pkt = pkt; + uint pat_changed = 0; if (! ts_PAYLOAD_START(pkt)) { LOGMSG ("parse_pat: PAT without payload unit start indicator"); @@ -92,7 +93,7 @@ uint section_syntax_indicator = ((pkt[6] >> 7) & 0x01) ; uint section_length = ((pkt[6] & 0x03) << 8) | pkt[7]; /*uint transport_stream_id = (pkt[8] << 8) | pkt[9];*/ -/*uint version_number = (pkt[10] >> 1) & 0x1f;*/ + uint version_number = (pkt[10] >> 1) & 0x1f; uint current_next_indicator = pkt[10] & 0x01; uint section_number = pkt[11]; uint last_section_number = pkt[12]; @@ -125,6 +126,15 @@ return 0; } + /* check if version or crc changed */ + if (pat->crc32 != crc32 || pat->version != version_number) { + LOGPMT("PAT changed: version %d->%d, crc32 0x%x->0x%x", + pat->version, version_number, pat->crc32, crc32); + pat->crc32 = crc32; + pat->version = version_number; + pat_changed++; + } + /* * Process all programs in the program loop */ @@ -143,8 +153,19 @@ if (program_number == 0x0000) continue; - pat->program_number[program_count] = program_number; - pat->pmt_pid[program_count] = pmt_pid; + if (pat->program_number[program_count] != program_number || + pat->pmt_pid[program_count] != pmt_pid) { + + LOGPMT("PAT: program %d changed: number %d->%d, pmt pid 0x%x->0x%x", + program_count, + pat->program_number[program_count], program_number, + pat->pmt_pid[program_count], pmt_pid); + + pat->program_number[program_count] = program_number; + pat->pmt_pid[program_count] = pmt_pid; + + pat_changed++; + } LOGPMT("PAT acquired count=%d programNumber=0x%04x pmtPid=0x%04x", program_count, @@ -156,6 +177,8 @@ pat->program_number[program_count] = 0; + pat->pat_changed_flag = !!pat_changed; + return program_count; } |