some changes for new service groups
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Wed, 29 Nov 2006 22:11:03 +0000 (22:11 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Wed, 29 Nov 2006 22:11:03 +0000 (22:11 +0000)
lib/dvb/dvb.cpp
lib/python/enigma_python.i
lib/service/servicedvb.cpp
lib/service/servicedvb.h

index c3c0a02..135d054 100644 (file)
@@ -529,7 +529,7 @@ int eDVBResourceManager::canAllocateFrontend(ePtr<iDVBFrontendParameters> &fepar
 
 int eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid, const eDVBChannelID& ignore)
 {
-       bool ret=true;
+       bool ret=3000;
        if (m_cached_channel)
        {
                eDVBChannel *cache_chan = (eDVBChannel*)&(*m_cached_channel);
@@ -615,14 +615,14 @@ int eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid, cons
        if (!m_list)
        {
                eDebug("no channel list set!");
-               ret = false;
+               ret = 0;
                goto error;
        }
 
        if (m_list->getChannelFrontendData(channelid, feparm))
        {
                eDebug("channel not found!");
-               ret = false;
+               ret = 0;
                goto error;
        }
 
index 21c0664..ebe934a 100644 (file)
@@ -45,6 +45,7 @@ is usually caused by not marking PSignals as immutable.
 #include <lib/service/iservice.h>
 #include <lib/service/service.h>
 #include <lib/service/event.h>
+#include <lib/service/servicedvb.h>
 #include <lib/gdi/fb.h>
 #include <lib/gdi/font.h>
 #include <lib/gdi/gpixmap.h>
@@ -98,6 +99,14 @@ extern int getPrevAsciiCode();
 extern int isUTF8(const std::string &);
 extern std::string convertUTF8DVB(const std::string &, int);
 extern std::string convertDVBUTF8(const unsigned char *data, int len, int table, int tsidonid);
+PyObject *getBestPlayableServiceReference(const eServiceReference &bouquet_ref, const eServiceReference &ignore)
+{
+       eStaticServiceDVBBouquetInformation info;
+       if (info.isPlayable(bouquet_ref, ignore))
+               return New_eServiceReference(info.getPlayableService());
+       Py_INCREF(Py_None);
+       return Py_None;
+}
 %}
 
 %feature("ref")   iObject "$this->AddRef(); /* eDebug(\"AddRef (%s:%d)!\", __FILE__, __LINE__); */ "
@@ -273,6 +282,7 @@ int getPrevAsciiCode();
 void runMainloop();
 void quitMainloop(int exit_code);
 eApplication *getApplication();
+PyObject *getBestPlayableServiceReference(const eServiceReference &bouquet_ref, const eServiceReference &ignore);
 %{
 RESULT SwigFromPython(ePtr<gPixmap> &result, PyObject *obj)
 {      
index 4b7d63a..56a18e4 100644 (file)
@@ -106,17 +106,6 @@ int eStaticServiceDVBInformation::isPlayable(const eServiceReference &ref, const
        return false;
 }
 
-
-class eStaticServiceDVBBouquetInformation: public iStaticServiceInformation
-{
-       DECLARE_REF(eStaticServiceDVBBouquetInformation);
-public:
-       eServiceReference m_playable_service;
-       RESULT getName(const eServiceReference &ref, std::string &name);
-       int getLength(const eServiceReference &ref);
-       int isPlayable(const eServiceReference &ref, const eServiceReference &ignore);
-};
-
 DEFINE_REF(eStaticServiceDVBBouquetInformation);
 
 RESULT eStaticServiceDVBBouquetInformation::getName(const eServiceReference &ref, std::string &name)
@@ -162,34 +151,40 @@ int eStaticServiceDVBBouquetInformation::isPlayable(const eServiceReference &ref
                if (eDVBResourceManager::getInstance(res))
                {
                        eDebug("eStaticServiceDVBBouquetInformation::isPlayable failed.. no resource manager!");
-                       return false;
+                       return 0;
                }
 
                if (res->getChannelList(db))
                {
                        eDebug("eStaticServiceDVBBouquetInformation::isPlayable failed.. no channel list!");
-                       return false;
+                       return 0;
                }
 
                eBouquet *bouquet=0;
                if (db->getBouquet(ref, bouquet))
                {
                        eDebug("eStaticServiceDVBBouquetInformation::isPlayable failed.. getBouquet failed!");
-                       return false;
+                       return 0;
                }
 
+               int cur=0;
                eDVBChannelID chid, chid_ignore;
                ((const eServiceReferenceDVB&)ignore).getChannelID(chid_ignore);
                for (std::list<eServiceReference>::iterator it(bouquet->m_services.begin()); it != bouquet->m_services.end(); ++it)
                {
-                       m_playable_service = *it;
+                       int tmp=res->canAllocateChannel(chid, chid_ignore);
                        ((const eServiceReferenceDVB&)*it).getChannelID(chid);
-                       if (res->canAllocateChannel(chid, chid_ignore))
-                               return true;
+                       if (tmp > cur)
+                       {
+                               m_playable_service = *it;
+                               cur = tmp;
+                       }
                }
+               if (cur)
+                       return cur;
        }
        m_playable_service = eServiceReference();
-       return false;
+       return 0;
 }
 
 int eStaticServiceDVBBouquetInformation::getLength(const eServiceReference &ref)
index 979a9ca..e12e3e1 100644 (file)
@@ -268,4 +268,15 @@ private:
        void radioTextUpdated();
 };
 
+class eStaticServiceDVBBouquetInformation: public iStaticServiceInformation
+{
+       DECLARE_REF(eStaticServiceDVBBouquetInformation);
+       eServiceReference m_playable_service;
+public:
+       eServiceReference &getPlayableService() { return m_playable_service; }
+       RESULT getName(const eServiceReference &ref, std::string &name);
+       int getLength(const eServiceReference &ref);
+       int isPlayable(const eServiceReference &ref, const eServiceReference &ignore);
+};
+
 #endif