X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/056f4ed60ae323f41601b8acdc42794902eac0d1..60c8087aa78a5fa24617b0f2ef86fa54f6083101:/lib/dvb/scan.cpp diff --git a/lib/dvb/scan.cpp b/lib/dvb/scan.cpp index 17c6b5c2..c4d4c6f4 100644 --- a/lib/dvb/scan.cpp +++ b/lib/dvb/scan.cpp @@ -1,7 +1,4 @@ #include -#include -#include -#include #include #include #include @@ -15,19 +12,19 @@ #include #include #include -#include -#define SCAN_eDebug(x...) eDebug(x) -#define SCAN_eDebugNoNewLine(x...) eDebugNoNewLine(x) +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_REF(eDVBScan); -eDVBScan::eDVBScan(iDVBChannel *channel): m_channel(channel) +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_flags(0), m_usePAT(usePAT) { - m_ready = m_flags = 0; - m_ready_all = readySDT; - m_channel_state = iDVBChannel::state_idle; - + 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); @@ -90,7 +87,7 @@ RESULT eDVBScan::nextChannel() m_SDT = 0; m_BAT = 0; m_NIT = 0; m_ready = 0; - + /* check what we need */ m_ready_all = readySDT; @@ -99,7 +96,10 @@ RESULT eDVBScan::nextChannel() if (m_flags & scanSearchBAT) m_ready_all |= readyBAT; - + + if (m_usePAT) + m_ready_all |= readyPAT; + if (m_ch_toScan.empty()) { SCAN_eDebug("no channels left to scan."); @@ -145,38 +145,62 @@ RESULT eDVBScan::nextChannel() RESULT eDVBScan::startFilter() { + bool startSDT=true; assert(m_demux); - + /* only start required filters filter */ - - m_SDT = 0; - if (m_ready_all & readySDT) + if (m_ready_all & readyPAT) + startSDT = m_ready & readyPAT; + + m_SDT = 0; + if (startSDT && (m_ready_all & readySDT)) { m_SDT = new eTable(); - if (m_SDT->start(m_demux, eDVBSDTSpec())) + if (m_ready & readyPAT && m_ready & validPAT) + { + std::vector::const_iterator i = + m_PAT->getSections().begin(); + assert(i != m_PAT->getSections().end()); + int tsid = (*i)->getTableIdExtension(); // in PAT this is the transport stream id + if (m_SDT->start(m_demux, eDVBSDTSpec(tsid, true))) + return -1; + } + else if (m_SDT->start(m_demux, eDVBSDTSpec())) return -1; CONNECT(m_SDT->tableReady, eDVBScan::SDTready); } - m_NIT = 0; - if (m_ready_all & readyNIT) + if (!(m_ready & readyPAT)) { - m_NIT = new eTable(); - if (m_NIT->start(m_demux, eDVBNITSpec())) - return -1; - CONNECT(m_NIT->tableReady, eDVBScan::NITready); - } + m_PAT = 0; + if (m_ready_all & readyPAT) + { + m_PAT = new eTable(); + if (m_PAT->start(m_demux, eDVBPATSpec())) + return -1; + CONNECT(m_PAT->tableReady, eDVBScan::PATready); + } - m_BAT = 0; - if (m_ready_all & readyBAT) - { - m_BAT = new eTable(); - if (m_BAT->start(m_demux, eDVBBATSpec())) - return -1; - CONNECT(m_BAT->tableReady, eDVBScan::BATready); + m_NIT = 0; + if (m_ready_all & readyNIT) + { + m_NIT = new eTable(); + if (m_NIT->start(m_demux, eDVBNITSpec())) + return -1; + CONNECT(m_NIT->tableReady, eDVBScan::NITready); + } + + m_BAT = 0; + if (m_ready_all & readyBAT) + { + m_BAT = new eTable(); + if (m_BAT->start(m_demux, eDVBBATSpec())) + return -1; + CONNECT(m_BAT->tableReady, eDVBScan::BATready); + } } - + return 0; } @@ -207,6 +231,15 @@ void eDVBScan::BATready(int err) channelDone(); } +void eDVBScan::PATready(int err) +{ + SCAN_eDebug("got pat"); + m_ready |= readyPAT; + if (!err) + m_ready |= validPAT; + startFilter(); // for starting the SDT filter +} + void eDVBScan::addKnownGoodChannel(const eDVBChannelID &chid, iDVBFrontendParameters *feparm) { /* add it to the list of known channels. */ @@ -257,13 +290,12 @@ void eDVBScan::channelDone() { unsigned long hash = 0; - ePtr p = m_ch_current; - - if (!p) // used in sdt scan - m_channel->getCurrentFrontendParameters(p); - - p->getHash(hash); + // m_ch_current is not set, when eDVBScan is just used for a SDT update + if (!m_ch_current) + m_channel->getCurrentFrontendParameters(m_ch_current); + m_ch_current->getHash(hash); + eDVBNamespace dvbnamespace = buildNamespace( (**m_SDT->getSections().begin()).getOriginalNetworkId(), (**m_SDT->getSections().begin()).getTransportStreamId(), @@ -394,16 +426,12 @@ void eDVBScan::channelDone() here, and not before. */ - ePtr p = m_ch_current; - if (!p) - m_channel->getCurrentFrontendParameters(p); - if (!m_chid_current) eWarning("SCAN: the current channel's ID was not corrected - not adding channel."); else - addKnownGoodChannel(m_chid_current, p); - - m_ch_scanned.push_back(p); + addKnownGoodChannel(m_chid_current, m_ch_current); + + m_ch_scanned.push_back(m_ch_current); nextChannel(); } @@ -535,7 +563,8 @@ void eDVBScan::insertInto(iDVBChannelList *db, bool dontRemoveOldFlags) dvb_service->m_service_name_sort = service->second->m_service_name_sort; } dvb_service->m_provider_name = service->second->m_provider_name; - + if (service->second->m_ca.size()) + dvb_service->m_ca = service->second->m_ca; if (!dontRemoveOldFlags) // do not remove new found flags when not wished dvb_service->m_flags &= ~eDVBService::dxNewFound; } @@ -553,10 +582,9 @@ RESULT eDVBScan::processSDT(eDVBNamespace dvbnamespace, const ServiceDescription SCAN_eDebug("ONID: %04x", sdt.getOriginalNetworkId()); eDVBChannelID chid(dvbnamespace, sdt.getTransportStreamId(), sdt.getOriginalNetworkId()); - /* save correct CHID for this channel if this is an ACTUAL_SDT */ - if (sdt.getTableId() == TID_SDT_ACTUAL) - m_chid_current = chid; - + /* save correct CHID for this channel */ + m_chid_current = chid; + for (ServiceDescriptionConstIterator s(services.begin()); s != services.end(); ++s) { SCAN_eDebugNoNewLine("SID %04x: ", (*s)->getServiceId()); @@ -595,7 +623,7 @@ RESULT eDVBScan::processSDT(eDVBNamespace dvbnamespace, const ServiceDescription for (CaSystemIdList::const_iterator i(caids.begin()); i != caids.end(); ++i) { SCAN_eDebugNoNewLine("%04x ", *i); - service->m_ca.insert(*i); + service->m_ca.push_front(*i); } SCAN_eDebug(""); break;