static void sdt_pid_parse(uint8_t *psi, void *arg) { uint8_t *section; int section_len; struct epgdump_s *epgd = arg; if (!sdt_validate(psi)) return; if (!psi_get_current(psi)) return; if (psi_get_tableid(psi) != SDT_TABLE_ID_ACTUAL) return; section_len = psi_get_length(psi) + PSI_HEADER_SIZE; section = malloc(section_len); if (!section) critical_error("Memory allocation failed\n"); memcpy(section, psi, section_len); if (!psi_table_section(epgd->sdt.sdt_current, section)) return; epgd->sdt.complete = 1; epgd->sdt.original_network_id = sdt_get_onid(epgd->sdt.sdt_current[0]); epgd->sdt.current_ts_id = sdt_get_tsid(epgd->sdt.sdt_current[0]); demux_del_psi_pid(&epgd->demux, SDT_PID); }
/***************************************************************************** * handle_section *****************************************************************************/ static void handle_section(uint16_t i_pid, uint8_t *p_section) { uint8_t i_table_id = psi_get_tableid(p_section); if (!psi_validate(p_section)) { printf("<ERROR type=\"invalid_section\" pid=\"%hu\"/>\n", i_pid); free(p_section); return; } switch (i_table_id) { case PAT_TABLE_ID: handle_pat_section(i_pid, p_section); break; case TSDT_TABLE_ID: handle_tsdt_section(i_pid, p_section); break; case PMT_TABLE_ID: handle_pmt(i_pid, p_section); break; case NIT_TABLE_ID_ACTUAL: handle_nit_section(i_pid, p_section); break; case SDT_TABLE_ID_ACTUAL: handle_sdt_section(i_pid, p_section); break; default: free( p_section ); break; } }