bool parse::take_pat(dvbpsi_pat_t* p_pat, bool decoded) { dprintf("(%s): v%d, ts_id: %d", (decoded) ? "post" : "pre", p_pat->i_version, p_pat->i_ts_id); if (!decoded) { set_ts_id(p_pat->i_ts_id); #if USING_DVBPSI_VERSION_0 h_demux[PID_ATSC] = dvbpsi_AttachDemux(attach_table, this); #else if (h_demux.count(PID_ATSC)) { h_demux[PID_ATSC].detach_demux(); h_demux.erase(PID_ATSC); } if (!dvbpsi_decoder_present(h_demux[PID_ATSC].get_handle())) dvbpsi_AttachDemux(h_demux[PID_ATSC].get_handle(), attach_table, this); #endif return true; } process_pat(decoders[p_pat->i_ts_id].get_decoded_pat()); rewrite_pat(); has_pat = true; return true; }
/***************************************************************************** * main *****************************************************************************/ int main(int i_argc, char* pa_argv[]) { int i_fd; uint8_t data[188]; dvbpsi_handle h_dvbpsi; int b_ok; if(i_argc != 2) return 1; i_fd = open(pa_argv[1], 0); h_dvbpsi = dvbpsi_AttachDemux(NewSubtableBAT, NULL); b_ok = ReadPacket(i_fd, data); while(b_ok) { uint16_t i_pid = ((uint16_t)(data[1] & 0x1f) << 8) + data[2]; if(i_pid == 0x11) dvbpsi_PushPacket(h_dvbpsi, data); b_ok = ReadPacket(i_fd, data); } dvbpsi_DetachDemux(h_dvbpsi); return 0; }
bool scan_session_Push( scan_session_t *p_scan, block_t *p_block ) { if( p_block->i_buffer < 188 || p_block->p_buffer[0] != 0x47 ) { block_Release( p_block ); return false; } /* */ const int i_pid = ( (p_block->p_buffer[1]&0x1f)<<8) | p_block->p_buffer[2]; if( i_pid == 0x00 ) { if( !p_scan->pat ) p_scan->pat = dvbpsi_AttachPAT( (dvbpsi_pat_callback)PATCallBack, p_scan ); if( p_scan->pat ) dvbpsi_PushPacket( p_scan->pat, p_block->p_buffer ); } else if( i_pid == 0x11 ) { if( !p_scan->sdt ) p_scan->sdt = dvbpsi_AttachDemux( (dvbpsi_demux_new_cb_t)PSINewTableCallBack, p_scan ); if( p_scan->sdt ) dvbpsi_PushPacket( p_scan->sdt, p_block->p_buffer ); } else if( i_pid == p_scan->i_nit_pid ) { #ifdef DVBPSI_USE_NIT if( !p_scan->nit ) p_scan->nit = dvbpsi_AttachDemux( (dvbpsi_demux_new_cb_t)PSINewTableCallBack, p_scan ); if( p_scan->nit ) dvbpsi_PushPacket( p_scan->nit, p_block->p_buffer ); #endif } block_Release( p_block ); return p_scan->p_pat && p_scan->p_sdt && #ifdef DVBPSI_USE_NIT p_scan->p_nit; #else true; #endif }
/***************************************************************************** * main *****************************************************************************/ int main(int argc, char *argv[]) { AStdData *fp = Stdin; AStdFile _fp; uint8_t data[188]; dvbpsi_t *p_dvbpsi; bool b_ok; (void)DumpDescriptors; if (argc > 1) { if (_fp.open(argv[1], "rb")) fp = &_fp; else { fprintf(stderr, "Failed to open file '%s' for reading\n", argv[1]); exit(1); } } p_dvbpsi = dvbpsi_new(&message, DVBPSI_MSG_WARN); if (p_dvbpsi) { if (dvbpsi_AttachDemux(p_dvbpsi, newsubtable, NULL)) { b_ok = ReadPacket(*fp, data, sizeof(data)); while (b_ok) { uint16_t pid = ((uint16_t)(data[1] & 0x1f) << 8) + data[2]; if (pid == 0x12) dvbpsi_packet_push(p_dvbpsi, data); b_ok = ReadPacket(*fp, data, sizeof(data)); } dvbpsi_DetachDemux(p_dvbpsi); } else fprintf(stderr, "Failed to attach demux to dvbpsi handler\n"); dvbpsi_delete(p_dvbpsi); } else fprintf(stderr, "Failed to create new dvbpsi handler\n"); _fp.close(); return 0; }
/***************************************************************************** * main *****************************************************************************/ int main(int i_argc, char* pa_argv[]) { int i_fd; uint8_t data[188]; dvbpsi_t *p_dvbpsi; bool b_ok; if(i_argc != 2) return 1; i_fd = open(pa_argv[1], 0); if (i_fd < 0) return 1; p_dvbpsi = dvbpsi_NewHandle(&message, DVBPSI_MSG_DEBUG); if (p_dvbpsi == NULL) goto out; if (!dvbpsi_AttachDemux(p_dvbpsi, NewSubtable, NULL)) goto out; b_ok = ReadPacket(i_fd, data); while(b_ok) { uint16_t i_pid = ((uint16_t)(data[1] & 0x1f) << 8) + data[2]; if(i_pid == 0x11) dvbpsi_PushPacket(p_dvbpsi, data); b_ok = ReadPacket(i_fd, data); } out: if (p_dvbpsi) { dvbpsi_DetachDemux(p_dvbpsi); dvbpsi_DeleteHandle(p_dvbpsi); } close(i_fd); return 0; }
void parse::process_mgt(bool attach) { const decoded_mgt_t* decoded_mgt = decoders[ts_id].get_decoded_mgt(); bool b_expecting_vct = false; eit_pids.clear(); if (!decoded_mgt) fprintf(stderr, "%s: decoded_mgt is NULL!!!\n", __func__); else for (map_decoded_mgt_tables::const_iterator iter = decoded_mgt->tables.begin(); iter != decoded_mgt->tables.end(); ++iter) { bool b_attach_demux = false; switch (iter->first) { case 0x0000 ... 0x0003: /* TVCT / CVCT */ b_expecting_vct = true; b_attach_demux = true; break; case 0x0100 ... 0x017f: /* EIT-0 to EIT-127 */ if ((scan_mode) && (!epg_mode)) break; if ((eit_collection_limit == -1) || (eit_collection_limit >= iter->first - 0x0100)) { eit_pids[iter->second.pid] = iter->first - 0x0100; b_attach_demux = true; } break; case 0x0200 ... 0x027f: /* ETT-0 to ETT-127 */ if (dont_collect_ett) break; if (scan_mode) break; /* FALL THRU */ case 0x0004: /* Channel ETT */ b_attach_demux = true; break; case 0x0301 ... 0x03ff: /* RRT w/ rating region 1-255 */ #if RRT b_attach_demux = true; #endif break; case 0x0005: /* DCCSCT */ case 0x0006 ... 0x00ff: /* Reserved for future ATSC use */ case 0x0180 ... 0x01ff: /* Reserved for future ATSC use */ case 0x0280 ... 0x0300: /* Reserved for future ATSC use */ case 0x0400 ... 0x0fff: /* private */ case 0x1000 ... 0x13ff: /* Reserved for future ATSC use */ case 0x1400 ... 0x14ff: /* DCCT dcc id 0x00 - 0xff */ case 0x1500 ... 0xffff: /* Reserved for future ATSC use */ break; default: if (scan_mode) break; b_attach_demux = true; break; } if ((b_attach_demux) && (iter->second.pid != PID_ATSC)) { #if USING_DVBPSI_VERSION_0 if (h_demux.count(iter->second.pid)) #if 0 dvbpsi_DetachDemux(h_demux[iter->second.pid]); #else {} else #endif #else if (h_demux.count(iter->second.pid)) { h_demux[iter->second.pid].detach_demux(); h_demux.erase(iter->second.pid); } if ((attach) && (!dvbpsi_decoder_present(h_demux[iter->second.pid].get_handle()))) dvbpsi_AttachDemux(h_demux[iter->second.pid].get_handle(), attach_table, this); #endif add_filter(iter->second.pid); #if USING_DVBPSI_VERSION_0 h_demux[iter->second.pid] = dvbpsi_AttachDemux(attach_table, this); #endif } }