X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/67dbb2973f32ccf52c0e5f3e2b5848320a215062..f769a73f621f88d4b4e64be8fae3f79ca3ef6c1b:/lib/dvb/scan.cpp diff --git a/lib/dvb/scan.cpp b/lib/dvb/scan.cpp index 3c4f407b..2a08bf79 100644 --- a/lib/dvb/scan.cpp +++ b/lib/dvb/scan.cpp @@ -13,18 +13,17 @@ #include #include -static bool scan_debug; -#define SCAN_eDebug(x...) do { if (scan_debug) eDebug(x); } while(0) -#define SCAN_eDebugNoNewLine(x...) do { if (scan_debug) eDebugNoNewLine(x); } while(0) +#define SCAN_eDebug(x...) do { if (m_scan_debug) eDebug(x); } while(0) +#define SCAN_eDebugNoNewLine(x...) do { if (m_scan_debug) eDebugNoNewLine(x); } while(0) DEFINE_REF(eDVBScan); eDVBScan::eDVBScan(iDVBChannel *channel, bool usePAT, bool debug) :m_channel(channel), m_channel_state(iDVBChannel::state_idle) ,m_ready(0), m_ready_all(usePAT ? (readySDT|readyPAT) : readySDT) - ,m_pmt_running(false), m_abort_current_pmt(false), m_flags(0), m_usePAT(usePAT) + ,m_pmt_running(false), m_abort_current_pmt(false), m_flags(0) + ,m_usePAT(usePAT), m_scan_debug(debug) { - scan_debug=debug; if (m_channel->getDemux(m_demux)) SCAN_eDebug("scan: failed to allocate demux!"); m_channel->connectStateChange(slot(*this, &eDVBScan::stateChange), m_stateChanged_connection); @@ -143,10 +142,20 @@ RESULT eDVBScan::startFilter() if (m_ready_all & readyPAT) startSDT = m_ready & readyPAT; + // m_ch_current is not set, when eDVBScan is just used for a SDT update + if (!m_ch_current) + { + unsigned int channelFlags; + m_channel->getCurrentFrontendParameters(m_ch_current); + m_ch_current->getFlags(channelFlags); + if (channelFlags & iDVBFrontendParameters::flagOnlyFree) + m_flags |= scanOnlyFree; + } + m_SDT = 0; if (startSDT && (m_ready_all & readySDT)) { - m_SDT = new eTable(); + m_SDT = new eTable(m_scan_debug); int tsid=-1; if (m_ready & readyPAT && m_ready & validPAT) { @@ -162,11 +171,11 @@ RESULT eDVBScan::startFilter() for (; program != pat.getPrograms()->end(); ++program) m_pmts_to_read.insert(std::pair((*program)->getProgramNumber(), service((*program)->getProgramMapPid()))); } - m_PMT = new eTable(); + m_PMT = new eTable(m_scan_debug); CONNECT(m_PMT->tableReady, eDVBScan::PMTready); - PMTready(-1); - + PMTready(-2); // KabelBW HACK ... on 618Mhz and 626Mhz the transport stream id in PAT and SDT is different + { int type; m_ch_current->getSystem(type); @@ -195,7 +204,7 @@ RESULT eDVBScan::startFilter() m_PAT = 0; if (m_ready_all & readyPAT) { - m_PAT = new eTable(); + m_PAT = new eTable(m_scan_debug); if (m_PAT->start(m_demux, eDVBPATSpec())) return -1; CONNECT(m_PAT->tableReady, eDVBScan::PATready); @@ -204,7 +213,7 @@ RESULT eDVBScan::startFilter() m_NIT = 0; if (m_ready_all & readyNIT) { - m_NIT = new eTable(); + m_NIT = new eTable(m_scan_debug); if (m_NIT->start(m_demux, eDVBNITSpec())) return -1; CONNECT(m_NIT->tableReady, eDVBScan::NITready); @@ -213,13 +222,12 @@ RESULT eDVBScan::startFilter() m_BAT = 0; if (m_ready_all & readyBAT) { - m_BAT = new eTable(); + m_BAT = new eTable(m_scan_debug); if (m_BAT->start(m_demux, eDVBBATSpec())) return -1; CONNECT(m_BAT->tableReady, eDVBScan::BATready); } } - return 0; } @@ -275,7 +283,7 @@ void eDVBScan::PMTready(int err) if (pcrpid == 0xFFFF) pcrpid = pmt.getPcrPid(); else - eDebug("already have a pcrpid %04x %04x", pcrpid, pmt.getPcrPid()); + SCAN_eDebug("already have a pcrpid %04x %04x", pcrpid, pmt.getPcrPid()); ElementaryStreamInfoConstIterator es; for (es = pmt.getEsInfo()->begin(); es != pmt.getEsInfo()->end(); ++es) { @@ -299,35 +307,37 @@ void eDVBScan::PMTready(int err) for (DescriptorConstIterator desc = (*es)->getDescriptors()->begin(); desc != (*es)->getDescriptors()->end(); ++desc) { - switch ((*desc)->getTag()) + uint8_t tag = (*desc)->getTag(); + if (!isaudio && !isvideo) { - case DTS_DESCRIPTOR: - case AAC_DESCRIPTOR: - isaudio = 1; - case AC3_DESCRIPTOR: - isaudio = 1; - break; - case CA_DESCRIPTOR: - is_scrambled = 1; - break; - case REGISTRATION_DESCRIPTOR: /* some services don't have a separate AC3 descriptor */ - { - /* libdvbsi++ doesn't yet support this descriptor type, so work around. */ - if ((*desc)->getLength() != 4) - break; - unsigned char descr[6]; - (*desc)->writeToBuffer(descr); - int format_identifier = (descr[2] << 24) | (descr[3] << 16) | (descr[4] << 8) | (descr[5]); - switch (format_identifier) + switch (tag) { - case 0x41432d33: + case DTS_DESCRIPTOR: + case AAC_DESCRIPTOR: + case AC3_DESCRIPTOR: isaudio = 1; - default: + break; + case REGISTRATION_DESCRIPTOR: /* some services don't have a separate AC3 descriptor */ + { + /* libdvbsi++ doesn't yet support this descriptor type, so work around. */ + if ((*desc)->getLength() != 4) + break; + unsigned char descr[6]; + (*desc)->writeToBuffer(descr); + int format_identifier = (descr[2] << 24) | (descr[3] << 16) | (descr[4] << 8) | (descr[5]); + switch (format_identifier) + { + case 0x41432d33: + isaudio = 1; + default: + break; + } break; } - break; - } + } } + if (tag == CA_DESCRIPTOR) + is_scrambled = 1; } break; } @@ -355,7 +365,7 @@ void eDVBScan::PMTready(int err) else m_pmt_in_progress->second.serviceType = 100; } - if (err == -2) // aborted in sdt progress + if (err == -1) // timeout or removed by sdt m_pmts_to_read.erase(m_pmt_in_progress++); else if (m_pmt_running) ++m_pmt_in_progress; @@ -369,6 +379,7 @@ void eDVBScan::PMTready(int err) m_PMT->start(m_demux, eDVBPMTSpec(m_pmt_in_progress->second.pmtPid, m_pmt_in_progress->first)); else { + m_PMT = 0; m_pmt_running = false; channelDone(); } @@ -395,7 +406,7 @@ void eDVBScan::addChannelToScan(const eDVBChannelID &chid, iDVBFrontendParameter { eDVBFrontendParametersSatellite parm; feparm->getDVBS(parm); - eDebug("try to add %d %d %d %d %d %d", + SCAN_eDebug("try to add %d %d %d %d %d %d", parm.orbital_position, parm.frequency, parm.symbol_rate, parm.polarisation, parm.fec, parm.modulation); break; } @@ -403,7 +414,7 @@ void eDVBScan::addChannelToScan(const eDVBChannelID &chid, iDVBFrontendParameter { eDVBFrontendParametersCable parm; feparm->getDVBC(parm); - eDebug("try to add %d %d %d %d", + SCAN_eDebug("try to add %d %d %d %d", parm.frequency, parm.symbol_rate, parm.modulation, parm.fec_inner); break; } @@ -411,7 +422,7 @@ void eDVBScan::addChannelToScan(const eDVBChannelID &chid, iDVBFrontendParameter { eDVBFrontendParametersTerrestrial parm; feparm->getDVBT(parm); - eDebug("try to add %d %d %d %d %d %d %d %d", + SCAN_eDebug("try to add %d %d %d %d %d %d %d %d", parm.frequency, parm.modulation, parm.transmission_mode, parm.hierarchy, parm.guard_interval, parm.code_rate_LP, parm.code_rate_HP, parm.bandwidth); break; @@ -427,11 +438,11 @@ void eDVBScan::addChannelToScan(const eDVBChannelID &chid, iDVBFrontendParameter if (!found_count) { *i = feparm; // update - eDebug("update"); + SCAN_eDebug("update"); } else { - eDebug("remove dupe"); + SCAN_eDebug("remove dupe"); m_ch_toScan.erase(i++); continue; } @@ -442,7 +453,7 @@ void eDVBScan::addChannelToScan(const eDVBChannelID &chid, iDVBFrontendParameter if (found_count > 0) { - eDebug("already in todo list"); + SCAN_eDebug("already in todo list"); return; } @@ -450,7 +461,7 @@ void eDVBScan::addChannelToScan(const eDVBChannelID &chid, iDVBFrontendParameter for (std::list >::const_iterator i(m_ch_scanned.begin()); i != m_ch_scanned.end(); ++i) if (sameChannel(*i, feparm)) { - eDebug("successfully scanned"); + SCAN_eDebug("successfully scanned"); return; } @@ -458,18 +469,18 @@ void eDVBScan::addChannelToScan(const eDVBChannelID &chid, iDVBFrontendParameter for (std::list >::const_iterator i(m_ch_unavailable.begin()); i != m_ch_unavailable.end(); ++i) if (sameChannel(*i, feparm, true)) { - eDebug("scanned but not available"); + SCAN_eDebug("scanned but not available"); return; } /* ... on the current channel */ if (sameChannel(m_ch_current, feparm)) { - eDebug("is current"); + SCAN_eDebug("is current"); return; } - eDebug("really add"); + SCAN_eDebug("really add"); /* otherwise, add it to the todo list. */ m_ch_toScan.push_front(feparm); // better.. then the rotor not turning wild from east to west :) } @@ -490,16 +501,6 @@ void eDVBScan::channelDone() { unsigned long hash = 0; - // m_ch_current is not set, when eDVBScan is just used for a SDT update - if (!m_ch_current) - { - unsigned int channelFlags; - m_channel->getCurrentFrontendParameters(m_ch_current); - m_ch_current->getFlags(channelFlags); - if (channelFlags & iDVBFrontendParameters::flagOnlyFree) - m_flags |= scanOnlyFree; - } - m_ch_current->getHash(hash); eDVBNamespace dvbnamespace = buildNamespace( @@ -516,7 +517,6 @@ void eDVBScan::channelDone() if (m_ready & validNIT) { - eDebug("validNIT"); int system; std::list > m_ch_toScan_backup; m_ch_current->getSystem(system); @@ -604,7 +604,7 @@ void eDVBScan::channelDone() if ( abs(abs(3600 - p.orbital_position) - sat.orbital_position) < 5 ) { - eDebug("found transponder with incorrect west/east flag ... correct this"); + SCAN_eDebug("found transponder with incorrect west/east flag ... correct this"); sat.orbital_position = p.orbital_position; } @@ -692,16 +692,6 @@ void eDVBScan::channelDone() { unsigned long hash = 0; - // m_ch_current is not set, when eDVBScan is just used for a SDT update - if (!m_ch_current) - { - unsigned int channelFlags; - m_channel->getCurrentFrontendParameters(m_ch_current); - m_ch_current->getFlags(channelFlags); - if (channelFlags & iDVBFrontendParameters::flagOnlyFree) - m_flags |= scanOnlyFree; - } - m_ch_current->getHash(hash); m_chid_current = eDVBChannelID( @@ -771,13 +761,17 @@ void eDVBScan::channelDone() service->m_provider_name = pname; } - std::pair >::iterator, bool> i = m_new_services.insert(std::pair >(ref, service)); - - if (i.second) - { - m_last_service = i.first; - m_event(evtNewService); + if (!(m_flags & scanOnlyFree) || !m_pmt_in_progress->second.scrambled) { + SCAN_eDebug("add not scrambled!"); + std::pair >::iterator, bool> i = m_new_services.insert(std::pair >(ref, service)); + if (i.second) + { + m_last_service = i.first; + m_event(evtNewService); + } } + else + SCAN_eDebug("dont add... is scrambled!"); m_pmts_to_read.erase(m_pmt_in_progress++); } @@ -792,7 +786,7 @@ void eDVBScan::channelDone() { if (sameChannel(*i, m_ch_current)) { - eDebug("remove dupe 2"); + SCAN_eDebug("remove dupe 2"); m_ch_toScan.erase(i++); continue; } @@ -841,10 +835,8 @@ void eDVBScan::insertInto(iDVBChannelList *db, bool dontRemoveOldFlags) std::list >::iterator it(m_ch_scanned.begin()); for (;it != m_ch_scanned.end(); ++it) { - if (m_flags & scanDontRemoveUnscanned) { - eDebug("scanDontRemoveUnscanned!"); + if (m_flags & scanDontRemoveUnscanned) db->removeServices(&(*(*it))); - } else { int system; @@ -990,9 +982,13 @@ RESULT eDVBScan::processSDT(eDVBNamespace dvbnamespace, const ServiceDescription SCAN_eDebug("is scrambled!"); add = false; } + else + SCAN_eDebug("is free"); } - else + else { SCAN_eDebug("not found in PAT.. so we assume it is scrambled!!"); + add = false; + } } if (add)