fix for old api
[enigma2.git] / lib / dvb / scan.cpp
index 1c98dce0a613471744eebf3523da9af30601afcc..ba63ed9f3667e7b90f8cc679014eb31f4a9722f1 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);
 }
@@ -105,7 +104,6 @@ RESULT eDVBScan::nextChannel()
        }
        
        m_ch_current = m_ch_toScan.front();
-       m_chid_current = eDVBChannelID();
        
        m_ch_toScan.pop_front();
        
@@ -114,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))
        {
@@ -222,7 +231,7 @@ void eDVBScan::addChannelToScan(const eDVBChannelID &chid, iDVBFrontendParameter
                return;
 
                /* otherwise, add it to the todo list. */
-       m_ch_toScan.push_back(feparm);
+       m_ch_toScan.push_front(feparm); // better.. then the rotor not turning wild from east to west :)
 }
 
 int eDVBScan::sameChannel(iDVBFrontendParameters *ch1, iDVBFrontendParameters *ch2) const
@@ -302,7 +311,8 @@ void eDVBScan::channelDone()
                                                
                                                eDVBNamespace ns = buildNamespace(onid, tsid, hash);
                                                
-                                               if (m_chid_current && ((ns.get() ^ m_chid_current.dvbnamespace.get()) & 0xFFFF0000))
+                                               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
                                                {
@@ -365,7 +375,22 @@ void eDVBScan::start(const eSmartPtrList<iDVBFrontendParameters> &known_transpon
        m_ch_unavailable.clear();
        m_new_channels.clear();
        m_new_services.clear();
-       m_ch_toScan.insert(m_ch_toScan.end(), known_transponders.begin(), known_transponders.end());
+
+       for (eSmartPtrList<iDVBFrontendParameters>::const_iterator i(known_transponders.begin()); i != known_transponders.end(); ++i)
+       {
+               bool exist=false;
+               for (std::list<ePtr<iDVBFrontendParameters> >::const_iterator ii(m_ch_toScan.begin()); ii != m_ch_toScan.end(); ++ii)
+               {
+                       if (sameChannel(*i, *ii))
+                       {
+                               exist=true;
+                               break;
+                       }
+               }
+               if (!exist)
+                       m_ch_toScan.push_back(*i);
+       }
+
        nextChannel();
 }