add a blinking point to the infobar
[enigma2.git] / lib / dvb / scan.cpp
index 4188b64..8865f30 100644 (file)
@@ -30,29 +30,28 @@ eDVBScan::~eDVBScan()
 {
 }
 
-int eDVBScan::isValidONIDTSID(eOriginalNetworkID onid, eTransportStreamID tsid)
+int eDVBScan::isValidONIDTSID(int orbital_position, eOriginalNetworkID onid, eTransportStreamID tsid)
 {
        switch (onid.get())
        {
        case 0:
-       case 0xFFFF:
        case 0x1111:
                return 0;
        case 1:
-               return tsid>1;
+               return orbital_position == 192;
        case 0x00B1:
                return tsid != 0x00B0;
        case 0x0002:
-               return tsid != 0x07E8;
+               return abs(orbital_position-282) < 6;
        default:
-               return 1;
+               return onid.get() < 0xFF00;
        }
 }
 
 eDVBNamespace eDVBScan::buildNamespace(eOriginalNetworkID onid, eTransportStreamID tsid, unsigned long hash)
 {
                // on valid ONIDs, ignore frequency ("sub network") part
-       if (isValidONIDTSID(onid, tsid))
+       if (isValidONIDTSID((hash >> 16) & 0xFFFF, onid, tsid))
                hash &= ~0xFFFF;
        return eDVBNamespace(hash);
 }
@@ -69,11 +68,12 @@ void eDVBScan::stateChange(iDVBChannel *ch)
        {
                startFilter();
                m_channel_state = state;
-       } else if (state == iDVBChannel::state_unavailable)
+       } else if (state == iDVBChannel::state_failed)
        {
                m_ch_unavailable.push_back(m_ch_current);
                nextChannel();
        }
+                       /* unavailable will timeout, anyway. */
 }
 
 RESULT eDVBScan::nextChannel()
@@ -82,7 +82,17 @@ RESULT eDVBScan::nextChannel()
 
        m_SDT = 0; m_BAT = 0; m_NIT = 0;
 
-       m_ready = readyBAT;
+       m_ready = 0;
+       
+               /* check what we need */
+       m_ready_all = readySDT;
+       
+       if (m_flags & scanNetworkSearch)
+               m_ready_all |= readyNIT;
+       
+       if (m_flags & scanSearchBAT)
+               m_ready_all |= readyBAT;
+       
        if (m_ch_toScan.empty())
        {
                eDebug("no channels left to scan.");
@@ -94,7 +104,6 @@ RESULT eDVBScan::nextChannel()
        }
        
        m_ch_current = m_ch_toScan.front();
-       m_chid_current = eDVBChannelID();
        
        m_ch_toScan.pop_front();
        
@@ -103,7 +112,18 @@ RESULT eDVBScan::nextChannel()
                m_event(evtFail);
                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_channel_state = iDVBChannel::state_idle;
        if (fe->tune(*m_ch_current))
        {
@@ -120,21 +140,35 @@ RESULT eDVBScan::startFilter()
 {
        assert(m_demux);
        
-       m_SDT = new eTable<ServiceDescriptionSection>();
-       if (m_SDT->start(m_demux, eDVBSDTSpec()))
-               return -1;
-       CONNECT(m_SDT->tableReady, eDVBScan::SDTready);
+                       /* only start required filters filter */
+       
+       m_SDT = 0;
+
+       if (m_ready_all & readySDT)
+       {
+               m_SDT = new eTable<ServiceDescriptionSection>();
+               if (m_SDT->start(m_demux, eDVBSDTSpec()))
+                       return -1;
+               CONNECT(m_SDT->tableReady, eDVBScan::SDTready);
+       }
 
        m_NIT = 0;
-       m_NIT = new eTable<NetworkInformationSection>();
-       if (m_NIT->start(m_demux, eDVBNITSpec()))
-               return -1;
-       CONNECT(m_NIT->tableReady, eDVBScan::NITready);
-       
-       m_BAT = new eTable<BouquetAssociationSection>();
-       if (m_BAT->start(m_demux, eDVBBATSpec()))
-               return -1;
-       CONNECT(m_BAT->tableReady, eDVBScan::BATready);
+       if (m_ready_all & readyNIT)
+       {
+               m_NIT = new eTable<NetworkInformationSection>();
+               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<BouquetAssociationSection>();
+               if (m_BAT->start(m_demux, eDVBBATSpec()))
+                       return -1;
+               CONNECT(m_BAT->tableReady, eDVBScan::BATready);
+       }
        
        return 0;
 }
@@ -276,10 +310,16 @@ void eDVBScan::channelDone()
                                                feparm->getHash(hash);
                                                
                                                eDVBNamespace ns = buildNamespace(onid, tsid, hash);
-
-                                               addChannelToScan(
-                                                               eDVBChannelID(ns, tsid, onid),
-                                                               feparm);
+                                               
+                                               if ( m_chid_current.dvbnamespace.get() != -1 &&
+                                                       ((ns.get() ^ m_chid_current.dvbnamespace.get()) & 0xFFFF0000))
+                                                       eDebug("dropping this transponder, it's on another satellite.");
+                                               else
+                                               {
+                                                       addChannelToScan(
+                                                                       eDVBChannelID(ns, tsid, onid),
+                                                                       feparm);
+                                               }
                                                break;
                                        }
                                        default:
@@ -293,7 +333,7 @@ void eDVBScan::channelDone()
                m_ready &= ~validNIT;
        }
        
-       if ((m_ready  & readyAll) != readyAll)
+       if ((m_ready  & m_ready_all) != m_ready_all)
                return;
        SCAN_eDebug("channel done!");
        
@@ -327,8 +367,9 @@ void eDVBScan::channelDone()
        nextChannel();
 }
 
-void eDVBScan::start(const std::list<ePtr<iDVBFrontendParameters> > &known_transponders)
+void eDVBScan::start(const eSmartPtrList<iDVBFrontendParameters> &known_transponders, int flags)
 {
+       m_flags = flags;
        m_ch_toScan.clear();
        m_ch_scanned.clear();
        m_ch_unavailable.clear();
@@ -388,6 +429,8 @@ RESULT eDVBScan::processSDT(eDVBNamespace dvbnamespace, const ServiceDescription
                        {
                                ServiceDescriptor &d = (ServiceDescriptor&)**desc;
                                service->m_service_name = convertDVBUTF8(d.getServiceName());
+                               service->genSortName();
+
                                service->m_provider_name = convertDVBUTF8(d.getServiceProviderName());
                                SCAN_eDebug("name '%s', provider_name '%s'", service->m_service_name.c_str(), service->m_provider_name.c_str());
                                break;