X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/259b27b6f2d5457569b6639d625f5da255a73413..9d8d1436be9d8c9c5b79089a288b9716e4a098b9:/lib/dvb/scan.cpp diff --git a/lib/dvb/scan.cpp b/lib/dvb/scan.cpp index e722b3c5..89c4735a 100644 --- a/lib/dvb/scan.cpp +++ b/lib/dvb/scan.cpp @@ -16,13 +16,17 @@ #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 debug) + :m_channel(channel), m_channel_state(iDVBChannel::state_idle) + ,m_ready(0), m_ready_all(readySDT), m_flags(0) { + 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); @@ -97,10 +101,10 @@ RESULT eDVBScan::nextChannel() if (m_ch_toScan.empty()) { - eDebug("no channels left to scan."); - eDebug("%d channels scanned, %d were unavailable.", + SCAN_eDebug("no channels left to scan."); + SCAN_eDebug("%d channels scanned, %d were unavailable.", m_ch_scanned.size(), m_ch_unavailable.size()); - eDebug("%d channels in database.", m_new_channels.size()); + SCAN_eDebug("%d channels in database.", m_new_channels.size()); m_event(evtFinish); return -ENOENT; } @@ -251,6 +255,11 @@ void eDVBScan::channelDone() if (m_ready & validSDT) { unsigned long hash = 0; + + // 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( @@ -338,7 +347,7 @@ void eDVBScan::channelDone() if ( m_chid_current.dvbnamespace.get() != -1 && ((ns.get() ^ m_chid_current.dvbnamespace.get()) & 0xFFFF0000)) - eDebug("dropping this transponder, it's on another satellite."); + SCAN_eDebug("dropping this transponder, it's on another satellite."); else { addChannelToScan( @@ -382,7 +391,7 @@ void eDVBScan::channelDone() These are the reasons for adding the transponder here, and not before. */ - + if (!m_chid_current) eWarning("SCAN: the current channel's ID was not corrected - not adding channel."); else @@ -420,8 +429,89 @@ void eDVBScan::start(const eSmartPtrList &known_transpon nextChannel(); } -void eDVBScan::insertInto(iDVBChannelList *db) +void eDVBScan::insertInto(iDVBChannelList *db, bool dontRemoveOldFlags) { + if (m_flags & scanRemoveServices) + { + bool clearTerrestrial=false; + bool clearCable=false; + std::set scanned_sat_positions; + + std::list >::iterator it(m_ch_scanned.begin()); + for (;it != m_ch_scanned.end(); ++it) + { + int system; + (*it)->getSystem(system); + switch(system) + { + case iDVBFrontend::feSatellite: + { + eDVBFrontendParametersSatellite sat_parm; + (*it)->getDVBS(sat_parm); + scanned_sat_positions.insert(sat_parm.orbital_position); + break; + } + case iDVBFrontend::feTerrestrial: + { + clearTerrestrial=true; + break; + } + case iDVBFrontend::feCable: + { + clearCable=true; + break; + } + } + } + + for (it=m_ch_unavailable.begin();it != m_ch_unavailable.end(); ++it) + { + int system; + (*it)->getSystem(system); + switch(system) + { + case iDVBFrontend::feSatellite: + { + eDVBFrontendParametersSatellite sat_parm; + (*it)->getDVBS(sat_parm); + scanned_sat_positions.insert(sat_parm.orbital_position); + break; + } + case iDVBFrontend::feTerrestrial: + { + clearTerrestrial=true; + break; + } + case iDVBFrontend::feCable: + { + clearCable=true; + break; + } + } + } + + if (clearTerrestrial) + { + eDVBChannelID chid; + chid.dvbnamespace=0xEEEE0000; + db->removeServices(chid); + } + if (clearCable) + { + eDVBChannelID chid; + chid.dvbnamespace=0xFFFF0000; + db->removeServices(chid); + } + for (std::set::iterator x(scanned_sat_positions.begin()); x != scanned_sat_positions.end(); ++x) + { + eDVBChannelID chid; + if (m_flags & scanDontRemoveFeeds) + chid.dvbnamespace = eDVBNamespace((*x)<<16); +// eDebug("remove %d %08x", *x, chid.dvbnamespace.get()); + db->removeServices(chid, *x); + } + } + for (std::map >::const_iterator ch(m_new_channels.begin()); ch != m_new_channels.end(); ++ch) db->addChannelToList(ch->first, ch->second); @@ -430,9 +520,25 @@ void eDVBScan::insertInto(iDVBChannelList *db) { ePtr dvb_service; if (!db->getService(service->first, dvb_service)) - *dvb_service = *service->second; + { + if (dvb_service->m_flags & eDVBService::dxNoSDT) + continue; + if (!(dvb_service->m_flags & eDVBService::dxHoldName)) + { + dvb_service->m_service_name = service->second->m_service_name; + 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; + } else + { db->addService(service->first, service->second); + service->second->m_flags |= eDVBService::dxNewFound; + } } } @@ -484,7 +590,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;