add support for show used tuner for running service in the infobar
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 26 Jun 2006 15:28:24 +0000 (15:28 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 26 Jun 2006 15:28:24 +0000 (15:28 +0000)
add support for show all tuners in use in the infobar
add support for show the currently date in the infobar
now all skins have to define some new widgets in skin.. look in skin.xml and
search for "not used in this skin yet"

data/skin.xml
lib/dvb/dvb.cpp
lib/dvb/dvb.h
lib/python/Screens/InfoBar.py
lib/python/Screens/InfoBarGenerics.py
lib/python/enigma_python.i
lib/service/servicedvb.cpp
skin.py

index 97f361b..b5c9968 100644 (file)
@@ -12,6 +12,7 @@
 
                <color name="transpBlack" value="#80000000" />
        </colors>
+       
        <windowstyle type="skinned">
                <title offset="20,5" font="Regular;20" />
                <color name="Background" color="#33294a6b" />
 
                <screen name="InfoBar" flags="wfNoBorder" position="0,380" size="720,148" title="InfoBar">
                        <ePixmap position="0,0" zPosition="-1" size="720,148" pixmap="info-bg.png" />
-
+<!-- not used in this skin yet -->                     
+                       <widget name="CurrentProvider" position="0,0" size="0,0" />
+                       <widget name="CurrentDate" position="0,0" size="0,0" />
+                       <widget name="NimA" position="0,0" size="0,0" />
+                       <widget name="NimB" position="0,0" size="0,0" />
+                       <widget name="NimA_Active" position="0,0" size="0,0" />
+                       <widget name="NimB_Active" position="0,0" size="0,0" />
+                       <widget name="TextActive" position="0,0" size="0,0" /> 
+<!-- ............................................................................. -->
                        <widget name="snr" text="SNR:" position="195,0" size="40,22" font="Regular;15" transparent="1" />
                        <widget name="agc" text="AGC:" position="275,0" size="40,22" font="Regular;15" transparent="1" />
                        <widget name="ber" text="BER:" position="355,0" size="40,22" font="Regular;15" transparent="1" />
index 09c9f5f..bad0ce1 100644 (file)
@@ -78,6 +78,14 @@ eDVBResourceManager::eDVBResourceManager()
        CONNECT(m_releaseCachedChannelTimer.timeout, eDVBResourceManager::releaseCachedChannel);
 }
 
+void eDVBResourceManager::feStateChanged()
+{
+       int mask=0;
+       for (eSmartPtrList<eDVBRegisteredFrontend>::iterator i(m_frontend.begin()); i != m_frontend.end(); ++i)
+               if (i->m_inuse)
+                       mask |= ( 1 << i->m_frontend->getID() );
+       /* emit */ frontendUseMaskChanged(mask);
+}
 
 DEFINE_REF(eDVBAdapterLinux);
 eDVBAdapterLinux::eDVBAdapterLinux(int nr): m_nr(nr)
@@ -215,6 +223,7 @@ void eDVBResourceManager::addAdapter(iDVBAdapter *adapter)
                {
                        frontend->setSEC(m_sec);
                        m_frontend.push_back(new eDVBRegisteredFrontend(frontend, adapter));
+                       CONNECT(m_frontend.back()->stateChanged, eDVBResourceManager::feStateChanged);
                }
        }
 }
index bc51ccd..4ca986b 100644 (file)
@@ -23,6 +23,7 @@ class eDVBRegisteredFrontend: public iObject, public Object
 {
        DECLARE_REF(eDVBRegisteredFrontend);
        eTimer *disable;
+       Signal0<void> stateChanged;
        void closeFrontend()
        {
                if (!m_inuse && m_frontend->closeFrontend()) // frontend busy
@@ -38,12 +39,18 @@ public:
        void dec_use()
        {
                if (!--m_inuse)
+               {
+                       /* emit */ stateChanged();
                        disable->start(3000, true);
+               }
        }
        void inc_use()
        {
                if (++m_inuse == 1)
+               {
                        m_frontend->openFrontend();
+                       /* emit */ stateChanged();
+               }
        }
        iDVBAdapter *m_adapter;
        ePtr<eDVBFrontend> m_frontend;
@@ -175,6 +182,7 @@ class eDVBResourceManager: public iObject, public Object
        eTimer m_releaseCachedChannelTimer;
        void DVBChannelStateChanged(iDVBChannel*);
        void releaseCachedChannel();
+       void feStateChanged();
 #ifndef SWIG
 public:
 #endif
@@ -199,6 +207,7 @@ public:
 #ifdef SWIG
 public:
 #endif
+       PSignal1<void,int> frontendUseMaskChanged;
        RESULT allocateRawChannel(eUsePtr<iDVBChannel> &, int frontend_index);
        static RESULT getInstance(ePtr<eDVBResourceManager> &);
 };
index 5672117..98a0f7c 100644 (file)
@@ -7,6 +7,8 @@ from Screens.Ci import CiHandler
 from ServiceReference import ServiceReference
 
 from Components.Clock import Clock
+from Components.Date import DateLabel
+from Components.ProviderName import ProviderName
 from Components.ActionMap import ActionMap, HelpableActionMap
 from Components.ServicePosition import ServicePosition, ServicePositionGauge
 from Components.config import currentConfigSelectionElement, config
@@ -62,6 +64,8 @@ class InfoBar(InfoBarShowHide,
 
                self["CurrentTime"] = Clock()
                # ServicePosition(self.session.nav, ServicePosition.TYPE_REMAINING)
+               self["CurrentDate"] = DateLabel()
+               self["CurrentProvider"] = ProviderName(self.session.nav)
 
        def showTv(self):
                self.showTvChannelList(True)
index be092c6..fcce082 100644 (file)
@@ -1105,7 +1105,7 @@ class InfoBarInstantRecord:
                if entry is not None and entry != -1:
                        self.session.nav.RecordTimer.removeEntry(self.recording[entry])
                        self.recording.remove(self.recording[entry])
-                       
+
        def startInstantRecording(self, limitEvent = False):
                serviceref = self.session.nav.getCurrentlyPlayingServiceReference()
                
@@ -1359,10 +1359,15 @@ class InfoBarSubserviceSelection:
 
 class InfoBarAdditionalInfo:
        def __init__(self):
+               self["NimA"] = Pixmap()
+               self["NimB"] = Pixmap()
+               self["TextActive"] = Pixmap()
                self["DolbyActive"] = Pixmap()
                self["CryptActive"] = Pixmap()
                self["FormatActive"] = Pixmap()
-               
+               self["NimA_Active"] = Pixmap()
+               self["NimB_Active"] = Pixmap()
+
                self["ButtonRed"] = PixmapConditional(withTimer = False)
                self["ButtonRed"].setConnect(lambda: harddiskmanager.HDDCount() > 0)
                self.onLayoutFinish.append(self["ButtonRed"].update)
@@ -1388,6 +1393,19 @@ class InfoBarAdditionalInfo:
                self.onLayoutFinish.append(self["ButtonBlueText"].update)
 
                self.session.nav.event.append(self.gotServiceEvent) # we like to get service events
+               res_mgr = eDVBResourceManagerPtr()
+               if eDVBResourceManager.getInstance(res_mgr) == 0:
+                       res_mgr.frontendUseMaskChanged.get().append(self.tunerUseMaskChanged)
+
+       def tunerUseMaskChanged(self, mask):
+               if mask&1:
+                       self["NimA_Active"].show()
+               else:
+                       self["NimA_Active"].hide()
+               if mask&2:
+                       self["NimB_Active"].show()
+               else:
+                       self["NimB_Active"].hide()
 
        def hideSubServiceIndication(self):
                self["ButtonGreen"].hide()
@@ -1399,15 +1417,25 @@ class InfoBarAdditionalInfo:
 
        def checkFormat(self, service):
                info = service.info()
-               if info is not None:
+               if info:
                        aspect = info.getInfo(iServiceInformation.sAspect)
                        if aspect in [ 3, 4, 7, 8, 0xB, 0xC, 0xF, 0x10 ]:
                                self["FormatActive"].show()
-                       else:
-                               self["FormatActive"].hide()
+                               return
+               self["FormatActive"].hide()
+
+       def checkText(self, service):
+               info = service.info()
+               if info:
+                       tpid = info.getInfo(iServiceInformation.sTXTPID)
+                       if tpid != -1:
+                               self["TextActive"].show()
+                               return
+               self["TextActive"].hide()
 
        def checkSubservices(self, service):
-               if service.subServices().getNumberOfSubservices() > 0:
+               subservices = service.subServices()
+               if subservices and subservices.getNumberOfSubservices() > 0:
                        self.showSubServiceIndication()
                else:
                        self.hideSubServiceIndication()
@@ -1416,7 +1444,7 @@ class InfoBarAdditionalInfo:
                # FIXME
                dolby = False
                audio = service.audioTracks()
-               if audio is not None:
+               if audio:
                        n = audio.getNumberOfTracks()
                        for x in range(n):
                                i = audio.getTrackInfo(x)
@@ -1431,25 +1459,41 @@ class InfoBarAdditionalInfo:
 
        def checkCrypted(self, service):
                info = service.info()
-               if info is not None:
-                       if info.getInfo(iServiceInformation.sIsCrypted) > 0:
-                               self["CryptActive"].show()
-                       else:
-                               self["CryptActive"].hide()
+               if info and info.getInfo(iServiceInformation.sIsCrypted) > 0:
+                       self["CryptActive"].show()
+               else:
+                       self["CryptActive"].hide()
+
+       def checkTunerState(self, service):
+               info = service.frontendInfo()
+               feNumber = info and info.getFrontendInfo(iFrontendInformation.frontendNumber)
+               if feNumber is None:
+                       self["NimA"].hide()
+                       self["NimB"].hide()
+               elif feNumber == 0:
+                       self["NimB"].hide()
+                       self["NimA"].show()
+               elif feNumber == 1:
+                       self["NimA"].hide()
+                       self["NimB"].show()
 
        def gotServiceEvent(self, ev):
                service = self.session.nav.getCurrentService()
-               if ev == iPlayableService.evUpdatedEventInfo:
+               if ev == iPlayableService.evStart:
+                       self.checkTunerState(service)
+               elif ev == iPlayableService.evUpdatedEventInfo:
                        self.checkSubservices(service)
                        self.checkFormat(service)
                elif ev == iPlayableService.evUpdatedInfo:
                        self.checkCrypted(service)
                        self.checkDolby(service)
+                       self.checkText(service)
                elif ev == iPlayableService.evEnd:
                        self.hideSubServiceIndication()
                        self["CryptActive"].hide()
                        self["DolbyActive"].hide()
                        self["FormatActive"].hide()
+                       self["TextActive"].hide()
 
 class InfoBarNotifications:
        def __init__(self):
index b80959c..89aef41 100644 (file)
@@ -155,6 +155,7 @@ typedef long time_t;
 %immutable pNavigation::m_event;
 %immutable eListbox::selectionChanged;
 %immutable eDVBCI_UI::ciStateChanged;
+%immutable eDVBResourceManager::frontendUseMaskChanged;
 
 %include <lib/base/console.h>
 %include <lib/base/nconfig.h>
index b7acd1f..581f64c 100644 (file)
@@ -1290,7 +1290,7 @@ int eDVBServicePlay::getCurrentChannel()
 
 RESULT eDVBServicePlay::selectChannel(int i)
 {
-       if (i < LEFT || i > RIGHT)
+       if (i < LEFT || i > RIGHT || i == STEREO)
                i = -1;  // Stereo
        if (m_dvb_service)
                m_dvb_service->setCacheEntry(eDVBService::cACHANNEL, i);
@@ -2013,7 +2013,7 @@ int eDVBServicePlay::getPCMDelay()
 void eDVBServicePlay::setAC3Delay(int delay)
 {
        if (m_dvb_service)
-               m_dvb_service->setCacheEntry(eDVBService::cAC3DELAY, delay);
+               m_dvb_service->setCacheEntry(eDVBService::cAC3DELAY, delay ? delay : -1);
        if (m_decoder)
                m_decoder->setAC3Delay(delay);
 }
@@ -2021,7 +2021,7 @@ void eDVBServicePlay::setAC3Delay(int delay)
 void eDVBServicePlay::setPCMDelay(int delay)
 {
        if (m_dvb_service)
-               m_dvb_service->setCacheEntry(eDVBService::cPCMDELAY, delay);
+               m_dvb_service->setCacheEntry(eDVBService::cPCMDELAY, delay ? delay : -1);
        if (m_decoder)
                m_decoder->setPCMDelay(delay);
 }
diff --git a/skin.py b/skin.py
index 30e8c72..08bc6c5 100644 (file)
--- a/skin.py
+++ b/skin.py
@@ -176,7 +176,7 @@ def applySingleAttribute(guiObject, desktop, attrib, value):
                        guiObject.setPointer(ptr.__deref__(), pos)
                elif attrib == 'shadowOffset':
                        guiObject.setShadowOffset(parsePosition(value))
-               else:
+               elif attrib != 'name':
                        print "unsupported attribute " + attrib + "=" + value
        except int:
 # AttributeError: