add (tune)simulate support to some functions
authorghost <andreas.monzner@multimedia-labs.de>
Fri, 7 Nov 2008 23:16:49 +0000 (00:16 +0100)
committerghost <andreas.monzner@multimedia-labs.de>
Fri, 7 Nov 2008 23:16:49 +0000 (00:16 +0100)
lib/dvb/db.cpp
lib/dvb/dvb.cpp
lib/dvb/dvb.h
lib/dvb/idvb.h
lib/python/enigma_python.i
lib/service/iservice.h
lib/service/service.cpp
lib/service/servicedvb.cpp
lib/service/servicedvb.h

index 02ecc1d2d7234f4e21332ce8c5c97e4af5b5ccd7..c6c2e855cd692eeaf5a4619990a6d737845cf610 100644 (file)
@@ -151,7 +151,7 @@ RESULT eDVBService::getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &
        return eEPGCache::getInstance()->lookupEventTime(ref, start_time, ptr);
 }
 
-int eDVBService::isPlayable(const eServiceReference &ref, const eServiceReference &ignore)
+int eDVBService::isPlayable(const eServiceReference &ref, const eServiceReference &ignore, bool simulate)
 {
        ePtr<eDVBResourceManager> res_mgr;
        if ( eDVBResourceManager::getInstance( res_mgr ) )
@@ -161,7 +161,7 @@ int eDVBService::isPlayable(const eServiceReference &ref, const eServiceReferenc
                eDVBChannelID chid, chid_ignore;
                ((const eServiceReferenceDVB&)ref).getChannelID(chid);
                ((const eServiceReferenceDVB&)ignore).getChannelID(chid_ignore);
-               return res_mgr->canAllocateChannel(chid, chid_ignore);
+               return res_mgr->canAllocateChannel(chid, chid_ignore, simulate);
        }
        return 0;
 }
index 68d9a0dd958eca788b58826f508ce716eeb23a2a..e04caa00efd8ac3e79aec326b515abaa2c2eca75 100644 (file)
@@ -713,12 +713,13 @@ RESULT eDVBResourceManager::connectChannelAdded(const Slot1<void,eDVBChannel*> &
        return 0;
 }
 
-int eDVBResourceManager::canAllocateFrontend(ePtr<iDVBFrontendParameters> &feparm)
+int eDVBResourceManager::canAllocateFrontend(ePtr<iDVBFrontendParameters> &feparm, bool simulate)
 {
+       eSmartPtrList<eDVBRegisteredFrontend> &frontends = simulate ? m_simulate_frontend : m_frontend;
        ePtr<eDVBRegisteredFrontend> best;
        int bestval = 0;
 
-       for (eSmartPtrList<eDVBRegisteredFrontend>::iterator i(m_frontend.begin()); i != m_frontend.end(); ++i)
+       for (eSmartPtrList<eDVBRegisteredFrontend>::iterator i(frontends.begin()); i != frontends.end(); ++i)
                if (!i->m_inuse)
                {
                        int c = i->m_frontend->isCompatibleWith(feparm);
@@ -755,10 +756,11 @@ int tuner_type_channel_default(ePtr<iDVBChannelList> &channellist, const eDVBCha
        return 0;
 }
 
-int eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid, const eDVBChannelID& ignore)
+int eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid, const eDVBChannelID& ignore, bool simulate)
 {
+       std::list<active_channel> &active_channels = simulate ? m_active_simulate_channels : m_active_channels;
        int ret=0;
-       if (m_cached_channel)
+       if (!simulate && m_cached_channel)
        {
                eDVBChannel *cache_chan = (eDVBChannel*)&(*m_cached_channel);
                if(channelid==cache_chan->getChannelID())
@@ -767,7 +769,7 @@ int eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid, cons
 
                /* first, check if a channel is already existing. */
 //     eDebug("allocate channel.. %04x:%04x", channelid.transport_stream_id.get(), channelid.original_network_id.get());
-       for (std::list<active_channel>::iterator i(m_active_channels.begin()); i != m_active_channels.end(); ++i)
+       for (std::list<active_channel>::iterator i(active_channels.begin()); i != active_channels.end(); ++i)
        {
 //             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)
@@ -780,8 +782,9 @@ int eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid, cons
        int *decremented_cached_channel_fe_usecount=NULL,
                *decremented_fe_usecount=NULL;
 
-       for (std::list<active_channel>::iterator i(m_active_channels.begin()); i != m_active_channels.end(); ++i)
+       for (std::list<active_channel>::iterator i(active_channels.begin()); i != active_channels.end(); ++i)
        {
+               eSmartPtrList<eDVBRegisteredFrontend> &frontends = simulate ? m_simulate_frontend : m_frontend;
 //             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 == ignore)
                {
@@ -795,7 +798,7 @@ int eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid, cons
                                ePtr<iDVBFrontend> fe;
                                if (!i->m_channel->getFrontend(fe))
                                {
-                                       for (eSmartPtrList<eDVBRegisteredFrontend>::iterator ii(m_frontend.begin()); ii != m_frontend.end(); ++ii)
+                                       for (eSmartPtrList<eDVBRegisteredFrontend>::iterator ii(frontends.begin()); ii != frontends.end(); ++ii)
                                        {
                                                if ( &(*fe) == &(*ii->m_frontend) )
                                                {
@@ -822,7 +825,8 @@ int eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid, cons
                                ePtr<iDVBFrontend> fe;
                                if (!channel->getFrontend(fe))
                                {
-                                       for (eSmartPtrList<eDVBRegisteredFrontend>::iterator ii(m_frontend.begin()); ii != m_frontend.end(); ++ii)
+                                       eSmartPtrList<eDVBRegisteredFrontend> &frontends = simulate ? m_simulate_frontend : m_frontend;
+                                       for (eSmartPtrList<eDVBRegisteredFrontend>::iterator ii(frontends.begin()); ii != frontends.end(); ++ii)
                                        {
                                                if ( &(*fe) == &(*ii->m_frontend) )
                                                {
@@ -852,7 +856,7 @@ int eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid, cons
                goto error;
        }
 
-       ret = canAllocateFrontend(feparm);
+       ret = canAllocateFrontend(feparm, simulate);
 
 error:
        if (decremented_fe_usecount)
index 1a773efadb4d8a1f6b00a473061f58acb1c2412b..13556c261eb047c76a69f189687b16a16fd90567 100644 (file)
@@ -184,7 +184,7 @@ public:
        };
        
        RESULT connectChannelAdded(const Slot1<void,eDVBChannel*> &channelAdded, ePtr<eConnection> &connection);
-       int canAllocateChannel(const eDVBChannelID &channelid, const eDVBChannelID &ignore);
+       int canAllocateChannel(const eDVBChannelID &channelid, const eDVBChannelID &ignore, bool simulate=false);
 
                /* allocate channel... */
        RESULT allocateChannel(const eDVBChannelID &channelid, eUsePtr<iDVBChannel> &channel, bool simulate=false);
@@ -206,7 +206,7 @@ public:
 #ifdef SWIG
 public:
 #endif
-       int canAllocateFrontend(ePtr<iDVBFrontendParameters> &feparm);
+       int canAllocateFrontend(ePtr<iDVBFrontendParameters> &feparm, bool simulate=false);
        bool canMeasureFrontendInputPower();
        PSignal1<void,int> frontendUseMaskChanged;
        SWIG_VOID(RESULT) allocateRawChannel(eUsePtr<iDVBChannel> &SWIG_OUTPUT, int slot_index);
index a2cce94d36343cc79e49584501100eda84719b0e..cda058946f4114d779d60ff5f48043d8769107b9 100644 (file)
@@ -315,7 +315,7 @@ public:
        // iStaticServiceInformation
        RESULT getName(const eServiceReference &ref, std::string &name);
        RESULT getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &ptr, time_t start_time);
-       int isPlayable(const eServiceReference &ref, const eServiceReference &ignore);
+       int isPlayable(const eServiceReference &ref, const eServiceReference &ignore, bool simulate=false);
        PyObject *getInfoObject(const eServiceReference &ref, int);  // implemented in lib/service/servicedvb.h
 
                /* for filtering: */
index 8f05d53de3c0592a6d9ad408c2803fb64b13b4ca..7de05d2b848b8a3e7622bf9ec24790870197d64c 100644 (file)
@@ -282,9 +282,9 @@ PyObject *New_iRecordableServicePtr(const ePtr<iRecordableService> &ptr)
 
 /* needed for service groups */
 
-PyObject *getBestPlayableServiceReference(const eServiceReference &bouquet_ref, const eServiceReference &ignore);
+PyObject *getBestPlayableServiceReference(const eServiceReference &bouquet_ref, const eServiceReference &ignore, bool simulate=false);
 %{
-PyObject *getBestPlayableServiceReference(const eServiceReference &bouquet_ref, const eServiceReference &ignore)
+PyObject *getBestPlayableServiceReference(const eServiceReference &bouquet_ref, const eServiceReference &ignore, bool simulate=false)
 {
        eStaticServiceDVBBouquetInformation info;
        if (info.isPlayable(bouquet_ref, ignore))
index 0385b9c2af7d25281cfa0991b074e29130eab18b..02fc4508527dd91c243ecae40ffed1372b1dac8b 100644 (file)
@@ -240,7 +240,7 @@ public:
        virtual int getLength(const eServiceReference &ref);
        virtual SWIG_VOID(RESULT) getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &SWIG_OUTPUT, time_t start_time=-1);
                // returns true when not implemented
-       virtual int isPlayable(const eServiceReference &ref, const eServiceReference &ignore);
+       virtual int isPlayable(const eServiceReference &ref, const eServiceReference &ignore, bool simulate=false);
 
        virtual int getInfo(const eServiceReference &ref, int w);
        virtual std::string getInfoString(const eServiceReference &ref,int w);
index f34237d2307e623a2212161a714b81199bd54f7c..eb2757abae058edea84c404cde47d1742f72a7c6 100644 (file)
@@ -239,7 +239,7 @@ int iStaticServiceInformation::getLength(const eServiceReference &ref)
        return -1;
 }
 
-int iStaticServiceInformation::isPlayable(const eServiceReference &ref, const eServiceReference &ignore)
+int iStaticServiceInformation::isPlayable(const eServiceReference &ref, const eServiceReference &ignore, bool simulate)
 {
        return 0;
 }
index 954a3964dff1390176e31427fcdd575d7e155529..2f98ed6b1e9d15b0f7a4ce114d088daf6d8820ed 100644 (file)
@@ -412,7 +412,7 @@ RESULT eStaticServiceDVBBouquetInformation::getName(const eServiceReference &ref
                return -1;
 }
 
-int eStaticServiceDVBBouquetInformation::isPlayable(const eServiceReference &ref, const eServiceReference &ignore)
+int eStaticServiceDVBBouquetInformation::isPlayable(const eServiceReference &ref, const eServiceReference &ignore, bool simulate)
 {
        if (ref.flags & eServiceReference::isGroup)
        {
@@ -453,7 +453,7 @@ int eStaticServiceDVBBouquetInformation::isPlayable(const eServiceReference &ref
                                { 2, 1, 3 }  // -T -S -C
                        };
                        ((const eServiceReferenceDVB&)*it).getChannelID(chid);
-                       int tmp=res->canAllocateChannel(chid, chid_ignore);
+                       int tmp=res->canAllocateChannel(chid, chid_ignore, simulate);
                        switch(tmp)
                        {
                                case 0:
index 85e97ea127a884370787b4be9bcb7a94f16269c7..d19b92d694203fd0d81ebd2567521a848395761e 100644 (file)
@@ -293,7 +293,7 @@ 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);
+       int isPlayable(const eServiceReference &ref, const eServiceReference &ignore, bool simulate=false);
        RESULT getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &ptr, time_t start_time);
 };