X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/6be1d64932f7007baa7974f72724a97dd6c7304e..3f66fa4d17ba703871da304d005a1945ba7ed97d:/lib/dvb/scan.cpp diff --git a/lib/dvb/scan.cpp b/lib/dvb/scan.cpp index f49607c2..109d2395 100644 --- a/lib/dvb/scan.cpp +++ b/lib/dvb/scan.cpp @@ -84,7 +84,7 @@ RESULT eDVBScan::nextChannel() { ePtr fe; - m_SDT = 0; m_BAT = 0; m_NIT = 0; + m_SDT = 0; m_PAT = 0; m_BAT = 0; m_NIT = 0; m_ready = 0; @@ -120,25 +120,13 @@ RESULT eDVBScan::nextChannel() return -ENOTSUP; } - int fetype; - fe->getFrontendType(fetype); - if ( fetype == iDVBFrontend::feSatellite) - { - eDVBFrontendParametersSatellite p; - m_ch_current->getDVBS(p); - m_chid_current = eDVBChannelID(p.orbital_position << 16, -1, -1); - } - else - m_chid_current = eDVBChannelID(); + m_chid_current = eDVBChannelID(); m_channel_state = iDVBChannel::state_idle; + if (fe->tune(*m_ch_current)) - { return nextChannel(); - m_event(evtFail); - return -EINVAL; - } - + m_event(evtUpdate); return 0; } @@ -157,16 +145,31 @@ RESULT eDVBScan::startFilter() if (startSDT && (m_ready_all & readySDT)) { m_SDT = new eTable(); + int tsid=-1; 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; + tsid = (*i)->getTableIdExtension(); // in PAT this is the transport stream id + + // KabelBW HACK ... on 618Mhz and 626Mhz the transport stream id in PAT and SDT is different + { + int type; + m_ch_current->getSystem(type); + if (type == iDVBFrontend::feCable) + { + eDVBFrontendParametersCable parm; + m_ch_current->getDVBC(parm); + if ((tsid == 0x00d7 && abs(parm.frequency-618000) < 2000) || + (tsid == 0x00d8 && abs(parm.frequency-626000) < 2000)) + tsid = -1; + } + } } - else if (m_SDT->start(m_demux, eDVBSDTSpec())) + if (tsid == -1 && m_SDT->start(m_demux, eDVBSDTSpec())) + return -1; + else if (m_SDT->start(m_demux, eDVBSDTSpec(tsid, true))) return -1; CONNECT(m_SDT->tableReady, eDVBScan::SDTready); } @@ -283,14 +286,33 @@ void eDVBScan::addChannelToScan(const eDVBChannelID &chid, iDVBFrontendParameter } } + int found_count=0; /* ... in the list of channels to scan */ - for (std::list >::iterator i(m_ch_toScan.begin()); i != m_ch_toScan.end(); ++i) + for (std::list >::iterator i(m_ch_toScan.begin()); i != m_ch_toScan.end();) + { if (sameChannel(*i, feparm)) { - *i = feparm; // update - eDebug("update"); - return; + if (!found_count) + { + *i = feparm; // update + eDebug("update"); + } + else + { + eDebug("remove dupe"); + m_ch_toScan.erase(i++); + continue; + } + ++found_count; } + ++i; + } + + if (found_count > 0) + { + eDebug("already in todo list"); + return; + } /* ... in the list of successfully scanned channels */ for (std::list >::const_iterator i(m_ch_scanned.begin()); i != m_ch_scanned.end(); ++i) @@ -357,12 +379,13 @@ void eDVBScan::channelDone() if (m_ready & validNIT) { int system; + std::list > m_ch_toScan_backup; m_ch_current->getSystem(system); SCAN_eDebug("dumping NIT"); if (m_flags & clearToScanOnFirstNIT) { + m_ch_toScan_backup = m_ch_toScan; m_ch_toScan.clear(); - m_flags &= ~clearToScanOnFirstNIT; } std::vector::const_iterator i; for (i = m_NIT->getSections().begin(); i != m_NIT->getSections().end(); ++i) @@ -433,19 +456,29 @@ void eDVBScan::channelDone() ePtr feparm = new eDVBFrontendParameters; eDVBFrontendParametersSatellite sat; sat.set(d); + + eDVBFrontendParametersSatellite p; + m_ch_current->getDVBS(p); + + if ( abs(p.orbital_position - sat.orbital_position) < 5 ) + sat.orbital_position = p.orbital_position; + + if ( abs(abs(3600 - p.orbital_position) - sat.orbital_position) < 5 ) + { + eDebug("found transponder with incorrect west/east flag ... correct this"); + sat.orbital_position = p.orbital_position; + } + feparm->setDVBS(sat); - unsigned long hash=0; - feparm->getHash(hash); - - eDVBNamespace ns = buildNamespace(onid, tsid, hash); - - if ( m_chid_current.dvbnamespace.get() != -1 && - ((ns.get() ^ m_chid_current.dvbnamespace.get()) & 0xFFFF0000)) + + if ( p.orbital_position != sat.orbital_position) SCAN_eDebug("dropping this transponder, it's on another satellite."); else { + unsigned long hash=0; + feparm->getHash(hash); addChannelToScan( - eDVBChannelID(ns, tsid, onid), + eDVBChannelID(buildNamespace(onid, tsid, hash), tsid, onid), feparm); } break; @@ -455,9 +488,25 @@ void eDVBScan::channelDone() break; } } - } + } + + /* a pitfall is to have the clearToScanOnFirstNIT-flag set, and having channels which have + no or invalid NIT. this code will not erase the toScan list unless at least one valid entry + has been found. + + This is not a perfect solution, as the channel could contain a partial NIT. Life's bad. + */ + if (m_flags & clearToScanOnFirstNIT) + { + if (m_ch_toScan.empty()) + { + eWarning("clearToScanOnFirstNIT was set, but NIT is invalid. Refusing to stop scan."); + m_ch_toScan = m_ch_toScan_backup; + } else + m_flags &= ~clearToScanOnFirstNIT; + } m_ready &= ~validNIT; } @@ -485,13 +534,25 @@ 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 addKnownGoodChannel(m_chid_current, m_ch_current); m_ch_scanned.push_back(m_ch_current); + + for (std::list >::iterator i(m_ch_toScan.begin()); i != m_ch_toScan.end();) + { + if (sameChannel(*i, m_ch_current)) + { + eDebug("remove dupe 2"); + m_ch_toScan.erase(i++); + continue; + } + ++i; + } + nextChannel(); } @@ -510,7 +571,7 @@ void eDVBScan::start(const eSmartPtrList &known_transpon bool exist=false; for (std::list >::const_iterator ii(m_ch_toScan.begin()); ii != m_ch_toScan.end(); ++ii) { - if (sameChannel(*i, *ii)) + if (sameChannel(*i, *ii, true)) { exist=true; break; @@ -631,7 +692,8 @@ void eDVBScan::insertInto(iDVBChannelList *db, bool dontRemoveOldFlags) else { db->addService(service->first, service->second); - service->second->m_flags |= eDVBService::dxNewFound; + if (!(m_flags & scanRemoveServices)) + service->second->m_flags |= eDVBService::dxNewFound; } } } @@ -725,3 +787,22 @@ void eDVBScan::getLastServiceName(std::string &last_service_name) else last_service_name = m_last_service->second->m_service_name; } + +RESULT eDVBScan::getFrontend(ePtr &fe) +{ + if (m_channel) + return m_channel->getFrontend(fe); + fe = 0; + return -1; +} + +RESULT eDVBScan::getCurrentTransponder(ePtr &tp) +{ + if (m_ch_current) + { + tp = m_ch_current; + return 0; + } + tp = 0; + return -1; +}