remove non working indication of playable services in servicelist
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Sat, 3 Dec 2005 12:37:40 +0000 (12:37 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Sat, 3 Dec 2005 12:37:40 +0000 (12:37 +0000)
get current event in listboxservicecontent via iStaticServiceInformation instead of use directly eEPGCache

lib/dvb/db.cpp
lib/dvb/dvb.cpp
lib/dvb/dvb.h
lib/dvb/idvb.h
lib/dvb/pmt.cpp
lib/dvb/pmt.h
lib/service/iservice.h
lib/service/listboxservice.cpp
lib/service/listboxservice.h
lib/service/service.cpp
lib/service/servicedvb.cpp

index 8892e4e186a5974108de543db7b727a931da5a83..38a062a2a5cd1dc562462996bc575e2c911c1193 100644 (file)
@@ -1,6 +1,7 @@
 #include <errno.h>
 #include <lib/dvb/db.h>
 #include <lib/dvb/frontend.h>
+#include <lib/dvb/epgcache.h>
 #include <lib/base/eerror.h>
 #include <lib/base/estring.h>
 #include <dvbsi++/service_description_section.h>
@@ -138,8 +139,8 @@ void eDVBService::genSortName()
 
 RESULT eDVBService::getName(const eServiceReference &ref, std::string &name)
 {
-       if (!ref.name.empty())
-               name = ref.name;
+       if (!ref.name.empty())  
+               name = ref.name; // use renamed service name..
        else if (!m_service_name.empty())
                name = m_service_name;
        else
@@ -147,9 +148,10 @@ RESULT eDVBService::getName(const eServiceReference &ref, std::string &name)
        return 0;
 }
 
-int eDVBService::getLength(const eServiceReference &ref)
+RESULT eDVBService::getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &ptr)
 {
-       return -1;
+       time_t t=-1;
+       return eEPGCache::getInstance()->lookupEventTime(ref, t, ptr);
 }
 
 int eDVBService::checkFilter(const eServiceReferenceDVB &ref, const eDVBChannelQuery &query)
index 676c063305a51a2b0b8c59cfa4b46b893d9e770c..4107c22dc89e65fcfd5f82e2850df56f1a4d16ec 100644 (file)
@@ -296,8 +296,7 @@ RESULT eDVBResourceManager::getChannelList(ePtr<iDVBChannelList> &list)
                return -ENOENT;
 }
 
-
-RESULT eDVBResourceManager::allocateChannel(const eDVBChannelID &channelid, eUsePtr<iDVBChannel> &channel, bool fake)
+RESULT eDVBResourceManager::allocateChannel(const eDVBChannelID &channelid, eUsePtr<iDVBChannel> &channel)
 {
                /* first, check if a channel is already existing. */
        
@@ -335,21 +334,18 @@ RESULT eDVBResourceManager::allocateChannel(const eDVBChannelID &channelid, eUse
        if (allocateFrontend(fe, feparm))
                return errNoFrontend;
 
-       if (!fake)
-       {
-               RESULT res;
-               ePtr<eDVBChannel> ch;
-               ch = new eDVBChannel(this, fe);
+       RESULT res;
+       ePtr<eDVBChannel> ch;
+       ch = new eDVBChannel(this, fe);
 
-               res = ch->setChannel(channelid, feparm);
-               if (res)
-               {
-                       channel = 0;
-                       return errChidNotFound;
-               }
-       
-               channel = ch;
+       res = ch->setChannel(channelid, feparm);
+       if (res)
+       {
+               channel = 0;
+               return errChidNotFound;
        }
+       channel = ch;
+
        return 0;
 }
 
@@ -410,6 +406,82 @@ RESULT eDVBResourceManager::connectChannelAdded(const Slot1<void,eDVBChannel*> &
        return 0;
 }
 
+bool eDVBResourceManager::canAllocateFrontend(ePtr<iDVBFrontendParameters> &feparm, int used_tuner_mask)
+{
+       eDebug("canAllocateFrontend mask %08x", used_tuner_mask);
+       ePtr<eDVBRegisteredFrontend> best;
+       int bestval = 0;
+
+       for (eSmartPtrList<eDVBRegisteredFrontend>::iterator i(m_frontend.begin()); i != m_frontend.end(); ++i)
+               if ( !(used_tuner_mask & (1<<i->m_frontend->getID())) )
+               {
+                       int c = i->m_frontend->isCompatibleWith(feparm);
+                       if (c > bestval)
+                               bestval = c;
+               }
+
+       return bestval>0;
+}
+
+bool eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid)
+{
+       return true;
+#if 0
+       int used_tuner_mask=0;
+
+               /* first, check if a channel is already existing. */
+//     eDebug("allocate channel.. %04x:%04x", channelid.transport_stream_id.get(), channelid.original_network_id.get());
+       int cnt=0;
+       for (std::list<active_channel>::iterator i(m_active_channels.begin()); i != m_active_channels.end(); ++i, ++cnt)
+       {
+//             eDebug("available channel.. %04x:%04x", i->m_channel_id.transport_stream_id.get(), i->m_channel_id.original_network_id.get());
+               if (i->m_channel_id == channelid)
+               {
+//                     eDebug("found shared channel..");
+                       return true;
+               }
+
+               eDebug("activeChannel %d, NonDecoderDemux %p, DecoderDemux %p",
+                       cnt, i->m_channel->getNonDecoderDemux(), i->m_channel->getDecoderDemux() );
+               if ( i->m_channel->getNonDecoderDemux() )
+               {
+                       ePtr<iDVBFrontend> fe;
+                       if (!i->m_channel->getFrontend(fe))
+                       {
+                               if (fe)
+                               {
+                                       for (eSmartPtrList<eDVBRegisteredFrontend>::iterator ii(m_frontend.begin()); ii != m_frontend.end(); ++ii)
+                                       {
+                                               if ( &(*fe) == &(*ii->m_frontend) )
+                                               {
+                                                       used_tuner_mask |= (1 << ii->m_frontend->getID());
+                                                       break;
+                                               }
+                                       }
+                               }
+                               else
+                                       eDebug("fe kaputt");
+                       }
+               }
+       }
+
+       if (!m_list)
+       {
+               eDebug("no channel list set!");
+               return false;
+       }
+
+       ePtr<iDVBFrontendParameters> feparm;
+       if (m_list->getChannelFrontendData(channelid, feparm))
+       {
+               eDebug("channel not found!");
+               return false;
+       }
+
+       return canAllocateFrontend(feparm, used_tuner_mask);
+#endif
+}
+
 DEFINE_REF(eDVBChannel);
 
 eDVBChannel::eDVBChannel(eDVBResourceManager *mgr, eDVBAllocatedFrontend *frontend): m_state(state_idle), m_mgr(mgr)
index 355e246998b7c660e25024810b15188f54370497..5c3c515035819d37a535b6bf158810ade742ba9d 100644 (file)
@@ -7,7 +7,6 @@
 #include <lib/dvb/tstools.h>
 #include <connection.h>
 
-class eDVBChannel;
 class eDVBChannel;
 
        /* we do NOT handle resource conflicts here. instead, the allocateChannel
@@ -142,6 +141,8 @@ class eDVBResourceManager: public iObject
        Signal1<void,eDVBChannel*> m_channelAdded;
        Signal1<void,eDVBChannel*> m_channelRemoved;
        Signal1<void,iDVBChannel*> m_channelRunning;
+
+       bool canAllocateFrontend(ePtr<iDVBFrontendParameters> &feparm, int used_tuner_mask);
 public:
        eDVBResourceManager();
        virtual ~eDVBResourceManager();
@@ -158,13 +159,15 @@ public:
        };
 
                /* allocate channel... */
-       RESULT allocateChannel(const eDVBChannelID &channelid, eUsePtr<iDVBChannel> &channel, bool fake=false);
+       RESULT allocateChannel(const eDVBChannelID &channelid, eUsePtr<iDVBChannel> &channel);
        RESULT allocateRawChannel(eUsePtr<iDVBChannel> &channel, int frontend_index);
        RESULT allocatePVRChannel(eUsePtr<iDVBPVRChannel> &channel);
 
        RESULT connectChannelAdded(const Slot1<void,eDVBChannel*> &channelAdded, ePtr<eConnection> &connection);
        RESULT connectChannelRemoved(const Slot1<void,eDVBChannel*> &channelRemoved, ePtr<eConnection> &connection);
        RESULT connectChannelRunning(const Slot1<void,iDVBChannel*> &channelRemoved, ePtr<eConnection> &connection);
+
+       bool canAllocateChannel(const eDVBChannelID &channelid);
 };
 
 class eFilePushThread;
index 119b6e3752d1c97e3b6ebac4a1d0325dd8e023b3..c7e223970b39532d956a7c9a4cf608d2f0a0facf 100644 (file)
@@ -218,7 +218,7 @@ public:
        
        // iStaticServiceInformation
        RESULT getName(const eServiceReference &ref, std::string &name);
-       int getLength(const eServiceReference &ref);
+       RESULT getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &ptr);
        
                /* for filtering: */
        int checkFilter(const eServiceReferenceDVB &ref, const eDVBChannelQuery &query);
index 0fc05240539226c96edf4cf58d564de1ffa6f1cd..5a1b7c5c4fc7a14f590e930cc004a7ae1584632c 100644 (file)
@@ -9,8 +9,6 @@
 #include <dvbsi++/iso639_language_descriptor.h>
 #include <dvbsi++/component_descriptor.h>
 
-int eDVBServicePMTHandler::m_count;
-
 eDVBServicePMTHandler::eDVBServicePMTHandler(int record)
        :m_ca_servicePtr(0)
 {
@@ -19,7 +17,6 @@ eDVBServicePMTHandler::eDVBServicePMTHandler(int record)
        CONNECT(m_PMT.tableReady, eDVBServicePMTHandler::PMTready);
        CONNECT(m_PAT.tableReady, eDVBServicePMTHandler::PATready);
        eDebug("new PMT handler record: %d", m_record);
-       ++m_count;
 }
 
 eDVBServicePMTHandler::~eDVBServicePMTHandler()
@@ -35,7 +32,6 @@ eDVBServicePMTHandler::~eDVBServicePMTHandler()
                eDVBCAService::unregister_service(m_reference, demux_num, ptr);
                eDVBCIInterfaces::getInstance()->removePMTHandler(this);
        }
-       --m_count;
 }
 
 void eDVBServicePMTHandler::channelStateChanged(iDVBChannel *channel)
index b8ed76f9488dec38892a8e85a652c6996ac1c1a2..5f3d4777d4b3f23ee304174e98f8971f7fa33bfd 100644 (file)
@@ -66,9 +66,7 @@ class eDVBServicePMTHandler: public Object
        void PATready(int error);
        
        int m_record;
-       static int m_count;
 public:
-       static int getCount() { return m_count; }
        eDVBServicePMTHandler(int record);
        ~eDVBServicePMTHandler();
        
index e4127fb9443cf20d795a1d50ddb7a89c345a0e74..ab95ef79abe49e58c719f453e4cf68ee82ce3d89 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <lib/python/swig.h>
 #include <lib/base/object.h>
+#include <lib/service/event.h>
 #include <string>
 #include <connection.h>
 #include <list>
@@ -172,7 +173,8 @@ public:
        virtual SWIG_VOID(RESULT) getName(const eServiceReference &ref, std::string &SWIG_OUTPUT)=0;
        
                // doesn't need to be implemented, should return -1 then.
-       virtual int getLength(const eServiceReference &ref)=0;
+       virtual int getLength(const eServiceReference &ref);
+       virtual SWIG_VOID(RESULT) getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &SWIG_OUTPUT);
 };
 
 TEMPLATE_TYPEDEF(ePtr<iStaticServiceInformation>, iStaticServiceInformationPtr);
index 9d68a5e835aecb42301d88b3cde352750bd143c9..4e20fcb7f53e70cd4125c036faaf92a59664d180 100644 (file)
@@ -166,12 +166,10 @@ void eListboxServiceContent::sort()
 DEFINE_REF(eListboxServiceContent);
 
 eListboxServiceContent::eListboxServiceContent()
-       :m_epgcache(eEPGCache::getInstance()), m_visual_mode(visModeSimple), m_size(0), m_current_marked(false), m_numberoffset(0)
+       :m_visual_mode(visModeSimple), m_size(0), m_current_marked(false), m_numberoffset(0)
 {
        cursorHome();
        eServiceCenter::getInstance(m_service_center);
-       if (eDVBResourceManager::getInstance(m_res_mgr))
-               eDebug("no resource manager");
 }
 
 void eListboxServiceContent::cursorHome()
@@ -339,17 +337,15 @@ void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const
 
        bool tuneable=true;
 
+#if 0
        if (m_res_mgr && cursorValid() && !((m_cursor->flags & eServiceReference::flagDirectory) == eServiceReference::flagDirectory))
        {
-               if ( eDVBServicePMTHandler::getCount() > 1 )
-               {
-                       eServiceReferenceDVB &ref = (eServiceReferenceDVB&) *m_cursor;
-                       eUsePtr<iDVBChannel> channel;
-                       eDVBChannelID chid;
-                       ref.getChannelID(chid);
-                       tuneable = !m_res_mgr->allocateChannel(chid, channel, true);  // no real allocate channel..just fake
-               }
+               eServiceReferenceDVB &ref = (eServiceReferenceDVB&) *m_cursor;
+               eDVBChannelID chid;
+               ref.getChannelID(chid);
+               tuneable = m_res_mgr->canAllocateChannel(chid);
        }
+#endif
 
        if (m_current_marked && selected)
                style.setStyle(painter, eWindowStyle::styleListboxMarked);
@@ -401,8 +397,7 @@ void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const
                        case celServiceInfo:
                        {
                                ePtr<eServiceEvent> evt;
-                               time_t t=-1;
-                               if ( !m_epgcache->lookupEventTime(*m_cursor, t, evt) )
+                               if ( !service_info->getEvent(*m_cursor, evt) )
                                        text = '(' + evt->getEventName() + ')';
                                else
                                        continue;
index 6e8d50173e7d282d26d106e34caf6445160898b4..b1cc249b940bc9d0cc0676ffc494ce3465395d57 100644 (file)
@@ -1,18 +1,13 @@
 #ifndef __lib_service_listboxservice_h
 #define __lib_service_listboxservice_h
 
-#include <lib/dvb/dvb.h>
 #include <lib/gui/elistbox.h>
 #include <lib/service/iservice.h>
 #include <set>
 
-class eEPGCache;
-
 class eListboxServiceContent: public virtual iListboxContent
 {
        DECLARE_REF(eListboxServiceContent);
-       eEPGCache *m_epgcache;
-       ePtr<eDVBResourceManager> m_res_mgr;
 public:
        eListboxServiceContent();
        void setRoot(const eServiceReference &ref);
index 62bbe12d8e3d5c1f260b5b454d8119cdfa12c0c9..a7f6e529823a68152189cfd85745257d84b86f36 100644 (file)
@@ -133,6 +133,17 @@ RESULT iServiceHandler::info(const eServiceReference &, ePtr<iStaticServiceInfor
 
 #include <lib/service/event.h>
 
+RESULT iStaticServiceInformation::getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &evt)
+{
+       evt = 0;
+       return -1;
+}
+
+int iStaticServiceInformation::getLength(const eServiceReference &ref)
+{
+       return -1;
+}
+
 RESULT iServiceInformation::getEvent(ePtr<eServiceEvent> &evt, int m_nownext)
 {      
        evt = 0;
index 143269149e1ff8eab75879ced08588ce88ea88cb..96f942abfd15a837c7214095a3d25318b3cc72b0 100644 (file)
@@ -25,7 +25,7 @@ DEFINE_REF(eStaticServiceDVBInformation);
 
 RESULT eStaticServiceDVBInformation::getName(const eServiceReference &ref, std::string &name)
 {
-       if ( ref.name.length() )
+       if ( !ref.name.empty() )
        {
                name = ref.name;
                return 0;
@@ -358,25 +358,25 @@ RESULT eServiceFactoryDVB::list(const eServiceReference &ref, ePtr<iListableServ
 
 RESULT eServiceFactoryDVB::info(const eServiceReference &ref, ePtr<iStaticServiceInformation> &ptr)
 {
-               /* do we have a PVR service? */
+       /* is a listable service? */
        if ((ref.flags & eServiceReference::flagDirectory) == eServiceReference::flagDirectory) // bouquet
        {
-               if ( !ref.name.empty() )
+               if ( !ref.name.empty() )  // satellites or providers list
                        ptr = new eStaticServiceDVBInformation;
-               else
+               else // a dvb bouquet
                        ptr = new eStaticServiceDVBBouquetInformation;
                return 0;
        }
-       else if (!ref.path.empty())
+       else if (!ref.path.empty()) /* do we have a PVR service? */
        {
                ptr = new eStaticServiceDVBPVRInformation(ref);
                return 0;
        }
-       else
+       else // normal dvb service
        {
                ePtr<eDVBService> service;
                int r = lookupService(service, ref);
-               if (r)
+               if (r) // no eDVBService avail for this reference ( Linkage Services... )
                        ptr = new eStaticServiceDVBInformation;
                else
                        /* eDVBService has the iStaticServiceInformation interface, so we pass it here. */