finally implement proper clipping for texts
[enigma2.git] / lib / dvb / db.cpp
index 65b378627dae0b9a914fa0fe933cc685877e58d9..eb0721b65b2349cc9769fb20f785e85157379937 100644 (file)
@@ -114,12 +114,13 @@ RESULT eBouquet::setListName(const std::string &name)
 }
 
 eDVBService::eDVBService()
-       :m_flags(0)
+       :m_cache(0), m_flags(0)
 {
 }
 
 eDVBService::~eDVBService()
 {
+       delete [] m_cache;
 }
 
 eDVBService &eDVBService::operator=(const eDVBService &s)
@@ -129,7 +130,7 @@ eDVBService &eDVBService::operator=(const eDVBService &s)
        m_provider_name = s.m_provider_name;
        m_flags = s.m_flags;
        m_ca = s.m_ca;
-       m_cache = s.m_cache;
+       copyCache(s.m_cache);
        return *this;
 }
 
@@ -223,19 +224,48 @@ int eDVBService::checkFilter(const eServiceReferenceDVB &ref, const eDVBChannelQ
                return res;
 }
 
-int eDVBService::getCachePID(cacheID id)
+bool eDVBService::cacheEmpty()
 {
-       std::map<int, int>::iterator it = m_cache.find(id);
-       if ( it != m_cache.end() )
-               return it->second;
-       return -1;
+       if (m_cache)
+               for (int i=0; i < cacheMax; ++i)
+                       if (m_cache[i] != -1)
+                               return false;
+       return true;
+}
+
+void eDVBService::initCache()
+{
+       m_cache = new int[cacheMax];
+       memset(m_cache, -1, sizeof(int) * cacheMax);
 }
 
-void eDVBService::setCachePID(cacheID id, int pid)
+void eDVBService::copyCache(int *source)
 {
-       if (pid == -1)
-               m_cache.erase(id);
+       if (source)
+       {
+               if (!m_cache)
+                       m_cache = new int[cacheMax];
+               memcpy(m_cache, source, cacheMax * sizeof(int));
+       }
        else
+       {
+               delete [] m_cache;
+               m_cache = 0;
+       }
+}
+
+int eDVBService::getCacheEntry(cacheID id)
+{
+       if (id >= cacheMax || !m_cache)
+               return -1;
+       return m_cache[id];
+}
+
+void eDVBService::setCacheEntry(cacheID id, int pid)
+{
+       if (!m_cache)
+               initCache();
+       if (id < cacheMax)
                m_cache[id] = pid;
 }
 
@@ -300,8 +330,11 @@ void eDVBDB::reloadServicelist()
                        if (line[1]=='s')
                        {
                                eDVBFrontendParametersSatellite sat;
-                               int frequency, symbol_rate, polarisation, fec, orbital_position, inversion;
-                               sscanf(line+2, "%d:%d:%d:%d:%d:%d", &frequency, &symbol_rate, &polarisation, &fec, &orbital_position, &inversion);
+                               int frequency, symbol_rate, polarisation, fec, orbital_position, inversion,
+                                       system=eDVBFrontendParametersSatellite::System::DVB_S,
+                                       modulation=eDVBFrontendParametersSatellite::Modulation::QPSK,
+                                       rolloff=eDVBFrontendParametersSatellite::RollOff::alpha_auto;
+                               sscanf(line+2, "%d:%d:%d:%d:%d:%d:%d:%d:%d", &frequency, &symbol_rate, &polarisation, &fec, &orbital_position, &inversion, &system, &modulation, &rolloff);
                                sat.frequency = frequency;
                                sat.symbol_rate = symbol_rate;
                                sat.polarisation = polarisation;
@@ -309,6 +342,9 @@ void eDVBDB::reloadServicelist()
                                sat.orbital_position =
                                        orbital_position < 0 ? orbital_position + 3600 : orbital_position;
                                sat.inversion = inversion;
+                               sat.system = system;
+                               sat.modulation = modulation;
+                               sat.roll_off = rolloff;
                                feparm->setDVBS(sat);
                        } else if (line[1]=='t')
                        {
@@ -414,12 +450,12 @@ void eDVBDB::reloadServicelist()
                                {
                                        int cid, val;
                                        sscanf(v.c_str(), "%02d%04x", &cid, &val);
-                                       s->m_cache[cid]=val;
+                                       s->setCacheEntry((eDVBService::cacheID)cid,val);
                                } else if (p == 'C')
                                {
                                        int val;
                                        sscanf(v.c_str(), "%04x", &val);
-                                       s->m_ca.insert(val);
+                                       s->m_ca.push_front((uint16_t)val);
                                }
                        }
                addService(ref, s);
@@ -452,11 +488,25 @@ void eDVBDB::saveServicelist()
                eDVBFrontendParametersCable cab;
                if (!ch.m_frontendParameters->getDVBS(sat))
                {
-                       fprintf(f, "\ts %d:%d:%d:%d:%d:%d\n",
-                               sat.frequency, sat.symbol_rate,
-                               sat.polarisation, sat.fec,
-                               sat.orbital_position > 1800 ? sat.orbital_position - 3600 : sat.orbital_position,
-                               sat.inversion);
+                       if (sat.system == eDVBFrontendParametersSatellite::System::DVB_S2)
+                       {
+                               fprintf(f, "\ts %d:%d:%d:%d:%d:%d:%d:%d:%d\n",
+                                       sat.frequency, sat.symbol_rate,
+                                       sat.polarisation, sat.fec,
+                                       sat.orbital_position > 1800 ? sat.orbital_position - 3600 : sat.orbital_position,
+                                       sat.inversion,
+                                       sat.system,
+                                       sat.modulation,
+                                       sat.roll_off);
+                       }
+                       else
+                       {
+                               fprintf(f, "\ts %d:%d:%d:%d:%d:%d\n",
+                                       sat.frequency, sat.symbol_rate,
+                                       sat.polarisation, sat.fec,
+                                       sat.orbital_position > 1800 ? sat.orbital_position - 3600 : sat.orbital_position,
+                                       sat.inversion);
+                       }
                }
                if (!ch.m_frontendParameters->getDVBT(ter))
                {
@@ -490,12 +540,15 @@ void eDVBDB::saveServicelist()
                fprintf(f, "p:%s", i->second->m_provider_name.c_str());
 
                // write cached pids
-               for (std::map<int,int>::const_iterator ca(i->second->m_cache.begin());
-                       ca != i->second->m_cache.end(); ++ca)
-                       fprintf(f, ",c:%02d%04x", ca->first, ca->second);
+               for (int x=0; x < eDVBService::cacheMax; ++x)
+               {
+                       int entry = i->second->getCacheEntry((eDVBService::cacheID)x);
+                       if (entry != -1)
+                               fprintf(f, ",c:%02d%04x", x, entry);
+               }
 
                // write cached ca pids
-               for (std::set<int>::const_iterator ca(i->second->m_ca.begin());
+               for (CAID_LIST::const_iterator ca(i->second->m_ca.begin());
                        ca != i->second->m_ca.end(); ++ca)
                        fprintf(f, ",C:%04x", *ca);