/***************************************************************************** * 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; }
void ts_psi_Del( demux_t *p_demux, ts_psi_t *psi ) { VLC_UNUSED(p_demux); if( dvbpsi_decoder_present( psi->handle ) ) dvbpsi_DetachDemux( psi->handle ); dvbpsi_delete( psi->handle ); free( psi ); }
void ts_si_Del( demux_t *p_demux, ts_si_t *si ) { if( dvbpsi_decoder_present( si->handle ) ) dvbpsi_DetachDemux( si->handle ); dvbpsi_delete( si->handle ); if( si->eitpid ) PIDRelease( p_demux, si->eitpid ); if( si->tdtpid ) PIDRelease( p_demux, si->tdtpid ); free( si ); }
/***************************************************************************** * 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 scan_session_Clean( scan_t *p_scan, scan_session_t *p_session ) { const int i_service_start = p_scan->i_service; dvbpsi_pat_t *p_pat = p_session->p_pat; dvbpsi_sdt_t *p_sdt = p_session->p_sdt; #ifdef DVBPSI_USE_NIT dvbpsi_nit_t *p_nit = p_session->p_nit; #endif if( p_pat ) { /* Parse PAT */ dvbpsi_pat_program_t *p_program; for( p_program = p_pat->p_first_program; p_program != NULL; p_program = p_program->p_next ) { if( p_program->i_number == 0 ) /* NIT */ continue; scan_service_t *s = scan_service_New( p_program->i_number, &p_session->cfg ); TAB_APPEND( p_scan->i_service, p_scan->pp_service, s ); } } /* Parse SDT */ if( p_pat && p_sdt ) { dvbpsi_sdt_service_t *p_srv; for( p_srv = p_sdt->p_first_service; p_srv; p_srv = p_srv->p_next ) { scan_service_t *s = ScanFindService( p_scan, i_service_start, p_srv->i_service_id ); dvbpsi_descriptor_t *p_dr; if( s ) s->b_crypted = p_srv->b_free_ca; for( p_dr = p_srv->p_first_descriptor; p_dr; p_dr = p_dr->p_next ) { if( p_dr->i_tag == 0x48 ) { dvbpsi_service_dr_t *pD = dvbpsi_DecodeServiceDr( p_dr ); if( s ) { if( !s->psz_name ) s->psz_name = dvbsi_to_utf8( pD->i_service_name, pD->i_service_name_length ); if( s->type == SERVICE_UNKNOWN ) { switch( pD->i_service_type ) { case 0x01: s->type = SERVICE_DIGITAL_TELEVISION; break; case 0x02: s->type = SERVICE_DIGITAL_RADIO; break; case 0x16: s->type = SERVICE_DIGITAL_TELEVISION_AC_SD; break; case 0x19: s->type = SERVICE_DIGITAL_TELEVISION_AC_HD; break; } } } } } } } #ifdef DVBPSI_USE_NIT /* Parse NIT */ if( p_pat && p_nit ) { dvbpsi_nit_ts_t *p_ts; for( p_ts = p_nit->p_first_ts; p_ts != NULL; p_ts = p_ts->p_next ) { uint32_t i_private_data_id = 0; dvbpsi_descriptor_t *p_dsc; if( p_ts->i_orig_network_id != p_nit->i_network_id || p_ts->i_ts_id != p_pat->i_ts_id ) continue; for( p_dsc = p_ts->p_first_descriptor; p_dsc != NULL; p_dsc = p_dsc->p_next ) { if( p_dsc->i_tag == 0x5f ) { i_private_data_id = GetDWBE( &p_dsc->p_data[0] ); } else if( i_private_data_id == 0x28 && p_dsc->i_tag == 0x83 ) { for( int i = 0; i < p_dsc->i_length/4; i++ ) { uint16_t i_service_id = GetWBE( &p_dsc->p_data[4*i+0] ); int i_channel_number = GetWBE( &p_dsc->p_data[4*i+2] ) & 0x3ff; scan_service_t *s = ScanFindService( p_scan, i_service_start, i_service_id ); if( s && s->i_channel < 0 ) s->i_channel = i_channel_number; } } } } } #endif /* */ for( int i = i_service_start; i < p_scan->i_service; i++ ) { scan_service_t *p_srv = p_scan->pp_service[i]; p_srv->i_snr = p_session->i_snr; if( p_sdt ) p_srv->i_sdt_version = p_sdt->i_version; #ifdef DVBPSI_USE_NIT if( p_nit ) { p_srv->i_network_id = p_nit->i_network_id; p_srv->i_nit_version = p_nit->i_version; } #endif } /* */ if( p_session->pat ) dvbpsi_DetachPAT( p_session->pat ); if( p_session->p_pat ) dvbpsi_DeletePAT( p_session->p_pat ); if( p_session->sdt ) dvbpsi_DetachDemux( p_session->sdt ); if( p_session->p_sdt ) dvbpsi_DeleteSDT( p_session->p_sdt ); #ifdef DVBPSI_USE_NIT if( p_session->nit ) dvbpsi_DetachDemux( p_session->nit ); if( p_session->p_nit ) dvbpsi_DeleteNIT( p_session->p_nit ); #endif }
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 } }