| 1 |
|
| /*
|
| 2 |
|
| * parse_si.c
|
| 3 |
|
| *
|
| 4 |
|
| * Created on: 2 Apr 2011
|
| 5 |
|
| * Author: sdprice1
|
| 6 |
|
| */
|
| 7 |
|
|
|
| 8 |
|
|
|
| 9 |
|
| // VERSION = 1.01
|
| 10 |
|
|
|
| 11 |
|
| /*=============================================================================================*/
|
| 12 |
|
| // USES
|
| 13 |
|
| /*=============================================================================================*/
|
| 14 |
|
|
|
| 15 |
|
| #include <stdio.h>
|
| 16 |
|
| #include <stdlib.h>
|
| 17 |
|
| #include <unistd.h>
|
| 18 |
|
| #include <string.h>
|
| 19 |
|
| #include <errno.h>
|
| 20 |
|
| #include <ctype.h>
|
| 21 |
|
| #include <fcntl.h>
|
| 22 |
|
| #include <inttypes.h>
|
| 23 |
|
|
|
| 24 |
|
| #include "parse_si.h"
|
| 25 |
|
|
|
| 26 |
|
| #include "tables/parse_si_pat.h" /* 0x00 */
|
| 27 |
|
| #include "tables/parse_si_cat.h" /* 0x01 */
|
| 28 |
|
| #include "tables/parse_si_pmt.h" /* 0x02 */
|
| 29 |
|
| #include "tables/parse_si_nit.h" /* 0x40 */
|
| 30 |
|
| #include "tables/parse_si_sdt.h" /* 0x42 */
|
| 31 |
|
| #include "tables/parse_si_bat.h" /* 0x4a */
|
| 32 |
|
| #include "tables/parse_si_eit.h" /* 0x4e */
|
| 33 |
|
| #include "tables/parse_si_tdt.h" /* 0x70 */
|
| 34 |
|
| #include "tables/parse_si_rst.h" /* 0x71 */
|
| 35 |
|
| #include "tables/parse_si_st.h" /* 0x72 */
|
| 36 |
|
| #include "tables/parse_si_tot.h" /* 0x73 */
|
| 37 |
|
| #include "tables/parse_si_cit.h" /* 0x77 */
|
| 38 |
|
| #include "tables/parse_si_dit.h" /* 0x7e */
|
| 39 |
|
| #include "tables/parse_si_sit.h" /* 0x7f */
|
| 40 |
|
|
|
| 41 |
|
| /*=============================================================================================*/
|
| 42 |
|
| // CONSTANTS
|
| 43 |
|
| /*=============================================================================================*/
|
| 44 |
|
|
|
| 45 |
|
| // Maximum section lengths
|
| 46 |
|
| unsigned SECTION_MAX_LENGTHS[SECTION_MAX+1] = {
|
| 47 |
|
| // default max length is 1024 bytes (-1 header -2 crc)
|
| 48 |
|
| [0 ... SECTION_MAX] = 1021,
|
| 49 |
|
|
|
| 50 |
|
| // These default to 4043
|
| 51 |
|
| [SECTION_ST] = 4093,
|
| 52 |
|
| [SECTION_EIT_START ... SECTION_EIT_END] = 4093,
|
| 53 |
|
| [SECTION_SIT] = 4093,
|
| 54 |
|
| [SECTION_CIT] = 4093,
|
| 55 |
|
|
|
| 56 |
|
| // This is a funny!
|
| 57 |
|
| [SECTION_DIT] = 1
|
| 58 |
|
| } ;
|
| 59 |
|
|
|
| 60 |
|
| // Section syntax values
|
| 61 |
|
| #define SYNTAX_0 0x00
|
| 62 |
|
| #define SYNTAX_1 0x80
|
| 63 |
|
| #define SYNTAX_EITHER 0xFF
|
| 64 |
|
| unsigned SECTION_SYNTAX[SECTION_MAX+1] = {
|
| 65 |
|
| // Most have the bit set
|
| 66 |
|
| [0 ... SECTION_MAX] = SYNTAX_1,
|
| 67 |
|
|
|
| 68 |
|
| // These have bit 0
|
| 69 |
|
| [SECTION_TDT] = SYNTAX_0,
|
| 70 |
|
| [SECTION_TOT] = SYNTAX_0,
|
| 71 |
|
| [SECTION_RST] = SYNTAX_0,
|
| 72 |
|
| [SECTION_DIT] = SYNTAX_0,
|
| 73 |
|
|
|
| 74 |
|
| // Special
|
| 75 |
|
| [SECTION_ST] = SYNTAX_EITHER,
|
| 76 |
|
|
|
| 77 |
|
| } ;
|
| 78 |
|
|
|
| 79 |
|
|
|
| 80 |
|
| /*=============================================================================================*/
|
| 81 |
|
| // MACROS
|
| 82 |
|
| /*=============================================================================================*/
|
| 83 |
|
|
|
| 84 |
|
|
|
| 85 |
|
| /*=============================================================================================*/
|
| 86 |
|
| // FUNCTIONS
|
| 87 |
|
| /*=============================================================================================*/
|
| 88 |
|
|
|
| 89 |
0 |
| static void dummy_handler(struct TS_reader *tsreader, struct TS_state *tsstate, struct Section *section, void *user_data)
|
| 90 |
|
| {
|
| 91 |
|
|
|
| 92 |
0 |
| }
|
| 93 |
|
|
|
| 94 |
|
|
|
| 95 |
|
| /* ----------------------------------------------------------------------- */
|
| 96 |
0 |
| void print_si(struct Section *section)
|
| 97 |
|
| {
|
| 98 |
0 |
| switch(section->table_id)
|
| 99 |
|
| {
|
| 100 |
|
|
|
| 101 |
|
| // PAT
|
| 102 |
0 |
| case SECTION_PAT:
|
| 103 |
0 |
| print_pat((struct Section_program_association *)section) ;
|
| 104 |
0 |
| break;
|
| 105 |
|
|
|
| 106 |
|
| // CAT
|
| 107 |
0 |
| case SECTION_CAT:
|
| 108 |
0 |
| print_cat((struct Section_conditional_access *)section) ;
|
| 109 |
0 |
| break;
|
| 110 |
|
|
|
| 111 |
|
| // PMT
|
| 112 |
0 |
| case SECTION_PMT:
|
| 113 |
0 |
| print_pmt((struct Section_program_map *)section) ;
|
| 114 |
0 |
| break;
|
| 115 |
|
|
|
| 116 |
|
| // NIT this
|
| 117 |
0 |
| case SECTION_NIT_ACTUAL:
|
| 118 |
|
| // NIT other
|
| 119 |
|
| case SECTION_NIT_OTHER:
|
| 120 |
0 |
| print_nit((struct Section_network_information *)section) ;
|
| 121 |
0 |
| break;
|
| 122 |
|
|
|
| 123 |
|
| // SDT this
|
| 124 |
0 |
| case SECTION_SDT_ACTUAL:
|
| 125 |
|
| // SDT other
|
| 126 |
|
| case SECTION_SDT_OTHER:
|
| 127 |
0 |
| print_sdt((struct Section_service_description *)section) ;
|
| 128 |
0 |
| break;
|
| 129 |
|
|
|
| 130 |
|
| // BAT
|
| 131 |
0 |
| case SECTION_BAT:
|
| 132 |
0 |
| print_bat((struct Section_bouquet_association *)section) ;
|
| 133 |
0 |
| break;
|
| 134 |
|
|
|
| 135 |
|
| // Now/Next this
|
| 136 |
0 |
| case SECTION_EIT_NOW_ACTUAL:
|
| 137 |
|
| // Now/Next other
|
| 138 |
|
| case SECTION_EIT_NOW_OTHER:
|
| 139 |
|
| // EIT this
|
| 140 |
|
| case SECTION_EIT_ACTUAL_START ... SECTION_EIT_ACTUAL_END:
|
| 141 |
|
| // EIT other
|
| 142 |
|
| case SECTION_EIT_OTHER_START ... SECTION_EIT_OTHER_END:
|
| 143 |
0 |
| print_eit((struct Section_event_information *)section) ;
|
| 144 |
0 |
| break;
|
| 145 |
|
|
|
| 146 |
|
| // TDT
|
| 147 |
0 |
| case SECTION_TDT:
|
| 148 |
0 |
| print_tdt((struct Section_time_date *)section) ;
|
| 149 |
0 |
| break;
|
| 150 |
|
|
|
| 151 |
|
| // RST
|
| 152 |
0 |
| case SECTION_RST:
|
| 153 |
0 |
| print_rst((struct Section_running_status *)section) ;
|
| 154 |
0 |
| break;
|
| 155 |
|
|
|
| 156 |
|
| // ST
|
| 157 |
0 |
| case SECTION_ST:
|
| 158 |
0 |
| print_st((struct Section_stuffing *)section) ;
|
| 159 |
0 |
| break;
|
| 160 |
|
|
|
| 161 |
|
| // TOT
|
| 162 |
0 |
| case SECTION_TOT:
|
| 163 |
0 |
| print_tot((struct Section_time_offset *)section) ;
|
| 164 |
0 |
| break;
|
| 165 |
|
|
|
| 166 |
|
| // CIT
|
| 167 |
0 |
| case SECTION_CIT:
|
| 168 |
0 |
| print_cit((struct Section_content_identifier *)section) ;
|
| 169 |
0 |
| break;
|
| 170 |
|
|
|
| 171 |
|
| // DIT
|
| 172 |
0 |
| case SECTION_DIT:
|
| 173 |
0 |
| print_dit((struct Section_discontinuity_information *)section) ;
|
| 174 |
0 |
| break;
|
| 175 |
|
|
|
| 176 |
|
| // SIT
|
| 177 |
0 |
| case SECTION_SIT:
|
| 178 |
0 |
| print_sit((struct Section_selection_information *)section) ;
|
| 179 |
0 |
| break;
|
| 180 |
|
|
|
| 181 |
|
|
|
| 182 |
0 |
| default:
|
| 183 |
0 |
| break;
|
| 184 |
|
| }
|
| 185 |
|
|
|
| 186 |
0 |
| }
|
| 187 |
|
|
|
| 188 |
|
| /* ----------------------------------------------------------------------- */
|
| 189 |
0 |
| int parse_si(struct TS_reader *tsreader, struct TS_state *tsstate, uint8_t *payload, unsigned payload_len)
|
| 190 |
|
| {
|
| 191 |
|
| unsigned table_id ;
|
| 192 |
|
| unsigned section_len ;
|
| 193 |
|
| unsigned section_syntax ;
|
| 194 |
|
| unsigned max_section_len ;
|
| 195 |
|
| unsigned expected_syntax ;
|
| 196 |
|
| int ptr ;
|
| 197 |
0 |
| int payload_left = payload_len ;
|
| 198 |
0 |
| Section_handler handler = NULL ;
|
| 199 |
|
| struct Section_decode_flags flags ;
|
| 200 |
|
|
|
| 201 |
0 |
▶ | tsparse_dbg_prt(10, ("\n== parse_si() : PID 0x%02x : payload len %d [0x%02x] ==\n", tsstate->pid_item->pidinfo.pid, payload_left, payload[0]));
|
Branch: 1 branch
| Branch | True | False | Total |
| tsparse_dbg_prt(10, ("\n== parse_si() : PID 0x%02x : payload len %d [0x%02x] ==\n", tsstate->pid_item->pidinfo.pid, payload_left, payload[0]));
|
0 |
0 |
0 |
|
| 202 |
|
|
|
| 203 |
0 |
▶ | CHECK_TS_READER(tsreader) ;
|
Branch: 2 branches
| Branch | True | False | Total |
| CHECK_TS_READER(tsreader) ;
|
0 |
0 |
0 |
| CHECK_TS_READER(tsreader) ;
|
0 |
0 |
0 |
|
| 204 |
0 |
▶ | CHECK_TS_STATE(tsstate) ;
|
Branch: 2 branches
| Branch | True | False | Total |
| CHECK_TS_STATE(tsstate) ;
|
0 |
0 |
0 |
| CHECK_TS_STATE(tsstate) ;
|
0 |
0 |
0 |
|
| 205 |
0 |
▶ | CHECK_TS_PID(tsstate->pid_item) ;
|
Branch: 2 branches
| Branch | True | False | Total |
| CHECK_TS_PID(tsstate->pid_item) ;
|
0 |
0 |
0 |
| CHECK_TS_PID(tsstate->pid_item) ;
|
0 |
0 |
0 |
|
| 206 |
|
|
|
| 207 |
|
| //fprintf(stderr, "\n== parse_si() : payload len %d [0x%02x] ==\n", payload_left, payload[0]);
|
| 208 |
|
| //fprintf(stderr, " + payload len %d\n", payload_left);
|
| 209 |
|
| //fprintf(stderr, " + payload [0x%02x]\n", payload[0]);
|
| 210 |
|
|
|
| 211 |
|
|
|
| 212 |
|
| // keep processing while we've got some buffer left AND we're not at the stuffing bytes
|
| 213 |
0 |
▶ | while ( (payload_left > (SI_HEADER_LEN+SI_CRC_LEN)) && (payload[0] != 0xff) )
|
Branch: 2 branches
| Branch | True | False | Total |
| while ( (payload_left > (SI_HEADER_LEN+SI_CRC_LEN)) && (payload[0] != 0xff) )
|
0 |
0 |
0 |
| while ( (payload_left > (SI_HEADER_LEN+SI_CRC_LEN)) && (payload[0] != 0xff) )
|
0 |
0 |
0 |
|
| 214 |
|
| {
|
| 215 |
0 |
▶ | tsparse_dbg_prt(10, ("\nparse_si() loop start: payload now:\n"));
|
Branch: 1 branch
| Branch | True | False | Total |
| tsparse_dbg_prt(10, ("\nparse_si() loop start: payload now:\n"));
|
0 |
0 |
0 |
|
| 216 |
|
|
|
| 217 |
|
| //fprintf(stderr, " + loop start: payload left now = %d [payload buff @ %p]\n", payload_left, payload);
|
| 218 |
|
|
|
| 219 |
0 |
▶ | if (tsreader->debug >= 104)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (tsreader->debug >= 104)
|
0 |
0 |
0 |
|
| 220 |
0 |
| dump_buff(&payload[0], payload_left, payload_left) ;
|
| 221 |
|
|
|
| 222 |
|
|
|
| 223 |
|
| // pointer_field 8 uimsbf
|
| 224 |
0 |
| ptr = payload[0] ;
|
| 225 |
|
|
|
| 226 |
|
| // check to see if we've skipped off the end of the buffer!
|
| 227 |
0 |
▶ | if ( (payload_left-ptr) < (SI_HEADER_LEN+SI_CRC_LEN) )
|
Branch: 1 branch
| Branch | True | False | Total |
| if ( (payload_left-ptr) < (SI_HEADER_LEN+SI_CRC_LEN) )
|
0 |
0 |
0 |
|
| 228 |
|
| {
|
| 229 |
|
| //fprintf(stderr, " ** ptr=%d - Invalid PTR?\n", ptr);
|
| 230 |
|
|
|
| 231 |
0 |
▶ | if (tsreader->error_hook)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (tsreader->error_hook)
|
0 |
0 |
0 |
|
| 232 |
|
| {
|
| 233 |
0 |
| SET_DVB_ERROR(ERR_SECTIONLEN) ;
|
| 234 |
0 |
▶ | if (tsreader->error_hook)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (tsreader->error_hook)
|
0 |
0 |
0 |
|
| 235 |
0 |
| tsreader->error_hook(dvb_error_code, &tsstate->pidinfo, tsreader->user_data) ;
|
| 236 |
|
| }
|
| 237 |
|
|
|
| 238 |
0 |
| return 0 ;
|
| 239 |
|
| }
|
| 240 |
|
| //fprintf(stderr, " + + ptr=%d payload left now = %d [payload buff @ %p]\n", ptr, payload_left-ptr, &payload[ptr]);
|
| 241 |
|
|
|
| 242 |
|
| // table_id 8 uimsbf
|
| 243 |
|
| // section_syntax_indicator 1 bslbf
|
| 244 |
|
| // indicator 1 bslbf
|
| 245 |
|
| // reserved 2 bslbf
|
| 246 |
|
| // section_length 12 uimsbf
|
| 247 |
0 |
| table_id = payload[ptr+1] & SECTION_MAX ;
|
| 248 |
0 |
| section_syntax = payload[ptr+2] & 0x80 ;
|
| 249 |
|
|
|
| 250 |
0 |
| max_section_len = SECTION_MAX_LENGTHS[table_id] ;
|
| 251 |
0 |
| expected_syntax = SECTION_SYNTAX[table_id] ;
|
| 252 |
|
|
|
| 253 |
|
| // number of bytes AFTER this field INCLUDING 4 byte CRC
|
| 254 |
0 |
| section_len = ((payload[ptr+2] & 0x0f)<<8) | payload[ptr+3] ;
|
| 255 |
|
|
|
| 256 |
0 |
▶ | tsparse_dbg_prt(102, ("PSI pid %d Table %d Len %d : 0x%02x 0x%02x 0x%02x 0x%02x \n",
|
Branch: 1 branch
| Branch | True | False | Total |
| tsparse_dbg_prt(102, ("PSI pid %d Table %d Len %d : 0x%02x 0x%02x 0x%02x 0x%02x \n",
|
0 |
0 |
0 |
|
| 257 |
|
| tsstate->pidinfo.pid, table_id, section_len, payload[ptr+0], payload[ptr+1], payload[ptr+2], payload[ptr+3])) ;
|
| 258 |
|
|
|
| 259 |
0 |
▶ | tsparse_dbg_prt(2, ("PSI pid 0x%x Table 0x%x [ptr 0x%02x] Sect Len %d : Payload left %d (syntax 0x%02x)\n",
|
Branch: 1 branch
| Branch | True | False | Total |
| tsparse_dbg_prt(2, ("PSI pid 0x%x Table 0x%x [ptr 0x%02x] Sect Len %d : Payload left %d (syntax 0x%02x)\n",
|
0 |
0 |
0 |
|
| 260 |
|
| tsstate->pidinfo.pid, table_id,
|
| 261 |
|
| ptr,
|
| 262 |
|
| section_len, payload_left,
|
| 263 |
|
| section_syntax)) ;
|
| 264 |
|
|
|
| 265 |
|
|
|
| 266 |
|
| // error check
|
| 267 |
0 |
▶ | if (section_len > max_section_len)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (section_len > max_section_len)
|
0 |
0 |
0 |
|
| 268 |
|
| {
|
| 269 |
0 |
▶ | tsparse_dbg_prt(2, ("PSI pid 0x%x Table 0x%x : section length error : %d (max %d)\n",
|
Branch: 1 branch
| Branch | True | False | Total |
| tsparse_dbg_prt(2, ("PSI pid 0x%x Table 0x%x : section length error : %d (max %d)\n",
|
0 |
0 |
0 |
|
| 270 |
|
| tsstate->pidinfo.pid, table_id,
|
| 271 |
|
| section_len,
|
| 272 |
|
| max_section_len)) ;
|
| 273 |
|
|
|
| 274 |
0 |
| tsstate->pid_item->pesinfo.psi_error++ ;
|
| 275 |
0 |
| tsstate->pidinfo.pid_error++ ;
|
| 276 |
0 |
▶ | if (tsreader->error_hook)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (tsreader->error_hook)
|
0 |
0 |
0 |
|
| 277 |
|
| {
|
| 278 |
0 |
| SET_DVB_ERROR(ERR_SECTIONLEN) ;
|
| 279 |
0 |
▶ | if (tsreader->error_hook)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (tsreader->error_hook)
|
0 |
0 |
0 |
|
| 280 |
0 |
| tsreader->error_hook(dvb_error_code, &tsstate->pidinfo, tsreader->user_data) ;
|
| 281 |
|
| }
|
| 282 |
|
|
|
| 283 |
0 |
| return 0 ;
|
| 284 |
|
| }
|
| 285 |
|
| else
|
| 286 |
|
| {
|
| 287 |
|
| // skip PTR & header
|
| 288 |
0 |
| payload_left -= SI_HEADER_LEN ;
|
| 289 |
|
|
|
| 290 |
|
| // get handler for this SI table - skip if none specified
|
| 291 |
0 |
| handler = tsreader->section_decode_table[table_id].handler ;
|
| 292 |
0 |
| flags = tsreader->section_decode_table[table_id].flags ;
|
| 293 |
|
|
|
| 294 |
|
| // check section fits into remaining buffer
|
| 295 |
0 |
▶ | if ((section_len <= payload_left) && handler)
|
Branch: 2 branches
| Branch | True | False | Total |
| if ((section_len <= payload_left) && handler)
|
0 |
0 |
0 |
| if ((section_len <= payload_left) && handler)
|
0 |
0 |
0 |
|
| 296 |
|
| {
|
| 297 |
|
| // check syntax
|
| 298 |
0 |
▶ | if ((expected_syntax != SYNTAX_EITHER) && (section_syntax != expected_syntax))
|
Branch: 2 branches
| Branch | True | False | Total |
| if ((expected_syntax != SYNTAX_EITHER) && (section_syntax != expected_syntax))
|
0 |
0 |
0 |
| if ((expected_syntax != SYNTAX_EITHER) && (section_syntax != expected_syntax))
|
0 |
0 |
0 |
|
| 299 |
|
| {
|
| 300 |
0 |
▶ | tsparse_dbg_prt(2, ("Invalid section syntax 0x%02x (expected 0x%02x)\n", section_syntax, expected_syntax)) ;
|
Branch: 1 branch
| Branch | True | False | Total |
| tsparse_dbg_prt(2, ("Invalid section syntax 0x%02x (expected 0x%02x)\n", section_syntax, expected_syntax)) ;
|
0 |
0 |
0 |
|
| 301 |
|
|
|
| 302 |
0 |
| SET_DVB_ERROR(ERR_TSCORRUPT) ;
|
| 303 |
0 |
▶ | if (tsreader->error_hook)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (tsreader->error_hook)
|
0 |
0 |
0 |
|
| 304 |
0 |
| tsreader->error_hook(dvb_error_code, &tsstate->pidinfo, tsreader->user_data) ;
|
| 305 |
|
|
|
| 306 |
|
| //TODO: Return here!
|
| 307 |
|
| //return 0 ;
|
| 308 |
|
| }
|
| 309 |
|
|
|
| 310 |
|
| // CRC covers whole packet from table_id to crc, need to extend length by section head
|
| 311 |
0 |
| uint32_t crc = crc32 (&payload[ptr+1], section_len+SECTION_HEADER_LEN);
|
| 312 |
0 |
▶ | if (!crc)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (!crc)
|
0 |
0 |
0 |
|
| 313 |
|
| {
|
| 314 |
0 |
▶ | tsparse_dbg_prt(100, ("**SI CRC PASS**\n")) ;
|
Branch: 1 branch
| Branch | True | False | Total |
| tsparse_dbg_prt(100, ("**SI CRC PASS**\n")) ;
|
0 |
0 |
0 |
|
| 315 |
|
| }
|
| 316 |
|
| else
|
| 317 |
|
| {
|
| 318 |
0 |
▶ | tsparse_dbg_prt(2, ("!!SI CRC FAIL!! - SI skipped\n")) ;
|
Branch: 1 branch
| Branch | True | False | Total |
| tsparse_dbg_prt(2, ("!!SI CRC FAIL!! - SI skipped\n")) ;
|
0 |
0 |
0 |
|
| 319 |
0 |
| return 0 ;
|
| 320 |
|
| }
|
| 321 |
|
|
|
| 322 |
|
| // ignore CRC in lower level decoding
|
| 323 |
0 |
| struct TS_bits *bits = bits_new(&payload[ptr+1], section_len+SECTION_HEADER_LEN-SI_CRC_LEN) ;
|
| 324 |
|
|
|
| 325 |
|
|
|
| 326 |
0 |
| switch(table_id)
|
| 327 |
|
| {
|
| 328 |
|
|
|
| 329 |
|
| // PAT
|
| 330 |
0 |
| case SECTION_PAT:
|
| 331 |
0 |
▶ | if (tsreader->debug >= 103)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (tsreader->debug >= 103)
|
0 |
0 |
0 |
|
| 332 |
0 |
| dump_buff(&payload[ptr+1], payload_left, section_len) ;
|
| 333 |
0 |
| parse_pat(tsreader, tsstate, bits, handler, &flags) ;
|
| 334 |
0 |
| break;
|
| 335 |
|
|
|
| 336 |
|
| // CAT
|
| 337 |
0 |
| case SECTION_CAT:
|
| 338 |
0 |
▶ | if (tsreader->debug >= 103)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (tsreader->debug >= 103)
|
0 |
0 |
0 |
|
| 339 |
0 |
| dump_buff(&payload[ptr+1], payload_left, section_len) ;
|
| 340 |
0 |
| parse_cat(tsreader, tsstate, bits, handler, &flags) ;
|
| 341 |
0 |
| break;
|
| 342 |
|
|
|
| 343 |
|
| // PMT
|
| 344 |
0 |
| case SECTION_PMT:
|
| 345 |
0 |
▶ | if (tsreader->debug >= 103)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (tsreader->debug >= 103)
|
0 |
0 |
0 |
|
| 346 |
0 |
| dump_buff(&payload[ptr+1], payload_left, section_len) ;
|
| 347 |
0 |
| parse_pmt(tsreader, tsstate, bits, handler, &flags) ;
|
| 348 |
0 |
| break;
|
| 349 |
|
|
|
| 350 |
|
| // NIT this
|
| 351 |
0 |
| case SECTION_NIT_ACTUAL:
|
| 352 |
|
| // NIT other
|
| 353 |
|
| case SECTION_NIT_OTHER:
|
| 354 |
0 |
▶ | if (tsreader->debug >= 103)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (tsreader->debug >= 103)
|
0 |
0 |
0 |
|
| 355 |
0 |
| dump_buff(&payload[ptr+1], payload_left, section_len) ;
|
| 356 |
0 |
| parse_nit(tsreader, tsstate, bits, handler, &flags) ;
|
| 357 |
0 |
| break;
|
| 358 |
|
|
|
| 359 |
|
| // SDT this
|
| 360 |
0 |
| case SECTION_SDT_ACTUAL:
|
| 361 |
|
| // SDT other
|
| 362 |
|
| case SECTION_SDT_OTHER:
|
| 363 |
0 |
▶ | if (tsreader->debug >= 103)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (tsreader->debug >= 103)
|
0 |
0 |
0 |
|
| 364 |
0 |
| dump_buff(&payload[ptr+1], payload_left, section_len) ;
|
| 365 |
0 |
| parse_sdt(tsreader, tsstate, bits, handler, &flags) ;
|
| 366 |
0 |
| break;
|
| 367 |
|
|
|
| 368 |
|
| // BAT
|
| 369 |
0 |
| case SECTION_BAT:
|
| 370 |
0 |
▶ | if (tsreader->debug >= 103)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (tsreader->debug >= 103)
|
0 |
0 |
0 |
|
| 371 |
0 |
| dump_buff(&payload[ptr+1], payload_left, section_len) ;
|
| 372 |
0 |
| parse_bat(tsreader, tsstate, bits, handler, &flags) ;
|
| 373 |
0 |
| break;
|
| 374 |
|
|
|
| 375 |
|
| // Now/Next this
|
| 376 |
0 |
| case SECTION_EIT_NOW_ACTUAL:
|
| 377 |
|
| // Now/Next other
|
| 378 |
|
| case SECTION_EIT_NOW_OTHER:
|
| 379 |
|
| // EIT this
|
| 380 |
|
| case SECTION_EIT_ACTUAL_START ... SECTION_EIT_ACTUAL_END:
|
| 381 |
|
| // EIT other
|
| 382 |
|
| case SECTION_EIT_OTHER_START ... SECTION_EIT_OTHER_END:
|
| 383 |
0 |
▶ | if (tsreader->debug >= 103)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (tsreader->debug >= 103)
|
0 |
0 |
0 |
|
| 384 |
0 |
| dump_buff(&payload[ptr+1], payload_left, section_len) ;
|
| 385 |
0 |
| parse_eit(tsreader, tsstate, bits, handler, &flags) ;
|
| 386 |
0 |
| break;
|
| 387 |
|
|
|
| 388 |
|
| // TDT
|
| 389 |
0 |
| case SECTION_TDT:
|
| 390 |
0 |
▶ | if (tsreader->debug >= 103)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (tsreader->debug >= 103)
|
0 |
0 |
0 |
|
| 391 |
0 |
| dump_buff(&payload[ptr+1], payload_left, section_len) ;
|
| 392 |
0 |
| parse_tdt(tsreader, tsstate, bits, handler, &flags) ;
|
| 393 |
0 |
| break;
|
| 394 |
|
|
|
| 395 |
|
| // RST
|
| 396 |
0 |
| case SECTION_RST:
|
| 397 |
0 |
▶ | if (tsreader->debug >= 103)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (tsreader->debug >= 103)
|
0 |
0 |
0 |
|
| 398 |
0 |
| dump_buff(&payload[ptr+1], payload_left, section_len) ;
|
| 399 |
0 |
| parse_rst(tsreader, tsstate, bits, handler, &flags) ;
|
| 400 |
0 |
| break;
|
| 401 |
|
|
|
| 402 |
|
| // ST
|
| 403 |
0 |
| case SECTION_ST:
|
| 404 |
0 |
▶ | if (tsreader->debug >= 103)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (tsreader->debug >= 103)
|
0 |
0 |
0 |
|
| 405 |
0 |
| dump_buff(&payload[ptr+1], payload_left, section_len) ;
|
| 406 |
0 |
| parse_st(tsreader, tsstate, bits, handler, &flags) ;
|
| 407 |
0 |
| break;
|
| 408 |
|
|
|
| 409 |
|
| // TOT
|
| 410 |
0 |
| case SECTION_TOT:
|
| 411 |
0 |
▶ | if (tsreader->debug >= 103)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (tsreader->debug >= 103)
|
0 |
0 |
0 |
|
| 412 |
0 |
| dump_buff(&payload[ptr+1], payload_left, section_len) ;
|
| 413 |
0 |
| parse_tot(tsreader, tsstate, bits, handler, &flags) ;
|
| 414 |
0 |
| break;
|
| 415 |
|
|
|
| 416 |
|
| // CIT
|
| 417 |
0 |
| case SECTION_CIT:
|
| 418 |
0 |
▶ | if (tsreader->debug >= 103)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (tsreader->debug >= 103)
|
0 |
0 |
0 |
|
| 419 |
0 |
| dump_buff(&payload[ptr+1], payload_left, section_len) ;
|
| 420 |
0 |
| parse_cit(tsreader, tsstate, bits, handler, &flags) ;
|
| 421 |
0 |
| break;
|
| 422 |
|
|
|
| 423 |
|
| // DIT
|
| 424 |
0 |
| case SECTION_DIT:
|
| 425 |
0 |
▶ | if (tsreader->debug >= 103)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (tsreader->debug >= 103)
|
0 |
0 |
0 |
|
| 426 |
0 |
| dump_buff(&payload[ptr+1], payload_left, section_len) ;
|
| 427 |
0 |
| parse_dit(tsreader, tsstate, bits, handler, &flags) ;
|
| 428 |
0 |
| break;
|
| 429 |
|
|
|
| 430 |
|
| // SIT
|
| 431 |
0 |
| case SECTION_SIT:
|
| 432 |
0 |
▶ | if (tsreader->debug >= 103)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (tsreader->debug >= 103)
|
0 |
0 |
0 |
|
| 433 |
0 |
| dump_buff(&payload[ptr+1], payload_left, section_len) ;
|
| 434 |
0 |
| parse_sit(tsreader, tsstate, bits, handler, &flags) ;
|
| 435 |
0 |
| break;
|
| 436 |
|
|
|
| 437 |
|
|
|
| 438 |
0 |
| default:
|
| 439 |
0 |
| fprintf(stderr, "!! Unexpected Table 0x%02x !!\n", table_id) ;
|
| 440 |
0 |
| break;
|
| 441 |
|
| }
|
| 442 |
|
|
|
| 443 |
0 |
| bits_free(&bits) ;
|
| 444 |
|
| }
|
| 445 |
|
| }
|
| 446 |
|
|
|
| 447 |
|
| // skip to end of this section (ready for any subsequent section)
|
| 448 |
0 |
| unsigned section_total = (ptr+1) + SECTION_HEADER_LEN + section_len ;
|
| 449 |
0 |
| payload_left -= section_total ;
|
| 450 |
0 |
| payload += section_total ;
|
| 451 |
|
|
|
| 452 |
0 |
▶ | tsparse_dbg_prt(10, (" + parse_si() end of loop : payload left %d\n", payload_left)) ;
|
Branch: 1 branch
| Branch | True | False | Total |
| tsparse_dbg_prt(10, (" + parse_si() end of loop : payload left %d\n", payload_left)) ;
|
0 |
0 |
0 |
|
| 453 |
|
|
|
| 454 |
|
| } // while
|
| 455 |
|
|
|
| 456 |
0 |
| return 0 ;
|
| 457 |
|
| }
|