[frontend] use dvb type with delsys instead of m_type.
[vuplus_dvbapp] / lib / dvb / dvb.cpp
index e32e5f8..62b01d2 100755 (executable)
@@ -270,14 +270,12 @@ void eDVBResourceManager::addAdapter(iDVBAdapter *adapter)
                ePtr<eDVBFrontend> frontend;
                if (!adapter->getFrontend(frontend, i))
                {
-                       int frontendType=0;
-                       frontend->getFrontendType(frontendType);
                        eDVBRegisteredFrontend *new_fe = new eDVBRegisteredFrontend(frontend, adapter);
                        CONNECT(new_fe->stateChanged, eDVBResourceManager::feStateChanged);
                        m_frontend.push_back(new_fe);
                        frontend->setSEC(m_sec);
                        // we must link all dvb-t frontends ( for active antenna voltage )
-                       if (frontendType == iDVBFrontend::feTerrestrial)
+                       if (frontend->supportsDeliverySystem(SYS_DVBT, false) || frontend->supportsDeliverySystem(SYS_DVBT2, false))
                        {
                                if (prev_dvbt_frontend)
                                {
@@ -295,14 +293,12 @@ void eDVBResourceManager::addAdapter(iDVBAdapter *adapter)
                ePtr<eDVBFrontend> frontend;
                if (!adapter->getFrontend(frontend, i, true))
                {
-                       int frontendType=0;
-                       frontend->getFrontendType(frontendType);
                        eDVBRegisteredFrontend *new_fe = new eDVBRegisteredFrontend(frontend, adapter);
 //                     CONNECT(new_fe->stateChanged, eDVBResourceManager::feStateChanged);
                        m_simulate_frontend.push_back(new_fe);
                        frontend->setSEC(m_sec);
                        // we must link all dvb-t frontends ( for active antenna voltage )
-                       if (frontendType == iDVBFrontend::feTerrestrial)
+                       if (frontend->supportsDeliverySystem(SYS_DVBT, false) || frontend->supportsDeliverySystem(SYS_DVBT2, false))
                        {
                                if (prev_dvbt_frontend)
                                {
@@ -355,6 +351,74 @@ PyObject *eDVBResourceManager::setFrontendSlotInformations(ePyObject list)
        Py_RETURN_NONE;
 }
 
+bool eDVBResourceManager::frontendIsCompatible(int index, const char *type)
+{
+       for (eSmartPtrList<eDVBRegisteredFrontend>::iterator i(m_frontend.begin()); i != m_frontend.end(); ++i)
+       {
+               if (i->m_frontend->getSlotID() == index)
+               {
+                       if (!strcmp(type, "DVB-S2"))
+                       {
+                               return i->m_frontend->supportsDeliverySystem(SYS_DVBS2, false);
+                       }
+                       else if (!strcmp(type, "DVB-S"))
+                       {
+                               return i->m_frontend->supportsDeliverySystem(SYS_DVBS, false);
+                       }
+                       else if (!strcmp(type, "DVB-T2"))
+                       {
+                               return i->m_frontend->supportsDeliverySystem(SYS_DVBT2, false);
+                       }
+                       else if (!strcmp(type, "DVB-T"))
+                       {
+                               return i->m_frontend->supportsDeliverySystem(SYS_DVBT, false);
+                       }
+                       else if (!strcmp(type, "DVB-C"))
+                       {
+#if DVB_API_VERSION > 5 || DVB_API_VERSION == 5 && DVB_API_VERSION_MINOR >= 6
+                               return i->m_frontend->supportsDeliverySystem(SYS_DVBC_ANNEX_A, false);
+#else
+                               return i->m_frontend->supportsDeliverySystem(SYS_DVBC_ANNEX_AC, false);
+#endif
+                       }
+               }
+       }
+       return false;
+}
+
+void eDVBResourceManager::setFrontendType(int index, const char *type)
+{
+       eDebug("[eDVBResourceManager::setFrontendType] index : %d, type : %s", index, type);
+
+       for (eSmartPtrList<eDVBRegisteredFrontend>::iterator i(m_frontend.begin()); i != m_frontend.end(); ++i)
+       {
+               if (i->m_frontend->getSlotID() == index)
+               {
+                       std::vector<fe_delivery_system_t> whitelist;
+                       if (!strcmp(type, "DVB-S2") || !strcmp(type, "DVB-S"))
+                       {
+                               whitelist.push_back(SYS_DVBS);
+                               whitelist.push_back(SYS_DVBS2);
+                       }
+                       else if (!strcmp(type, "DVB-T2") || !strcmp(type, "DVB-T"))
+                       {
+                               whitelist.push_back(SYS_DVBT);
+                               whitelist.push_back(SYS_DVBT2);
+                       }
+                       else if (!strcmp(type, "DVB-C"))
+                       {
+#if DVB_API_VERSION > 5 || DVB_API_VERSION == 5 && DVB_API_VERSION_MINOR >= 6
+                               whitelist.push_back(SYS_DVBC_ANNEX_A);
+#else
+                               whitelist.push_back(SYS_DVBC_ANNEX_AC);
+#endif
+                       }
+                       i->m_frontend->setDeliverySystemWhitelist(whitelist);
+                       break;
+               }
+       }
+}
+
 RESULT eDVBResourceManager::allocateFrontend(ePtr<eDVBAllocatedFrontend> &fe, ePtr<iDVBFrontendParameters> &feparm, bool simulate)
 {
        eSmartPtrList<eDVBRegisteredFrontend> &frontends = simulate ? m_simulate_frontend : m_frontend;