add transfer bps to service interface (requires touching enigma_python.i)
[enigma2.git] / lib / python / Components / Converter / ServiceInfo.py
index d4054f0ce051733aa46a492fc6c9b4ab4324029c..fa3518cedb1aa8542edf3495e519cef0fc74de9e 100644 (file)
@@ -10,6 +10,17 @@ class ServiceInfo(Converter, object):
        SUBSERVICES_AVAILABLE = 4
        XRES = 5
        YRES = 6
+       APID = 7
+       VPID = 8
+       PCRPID = 9
+       PMTPID = 10
+       TXTPID = 11
+       TSID = 12
+       ONID = 13
+       SID = 14
+       FRAMERATE = 15
+       TRANSFERBPS = 16
+       
 
        def __init__(self, type):
                Converter.__init__(self, type)
@@ -21,15 +32,25 @@ class ServiceInfo(Converter, object):
                                "SubservicesAvailable": (self.SUBSERVICES_AVAILABLE, (iPlayableService.evUpdatedEventInfo,)),
                                "VideoWidth": (self.XRES, (iPlayableService.evVideoSizeChanged,)),
                                "VideoHeight": (self.YRES, (iPlayableService.evVideoSizeChanged,)),
+                               "AudioPid": (self.APID, (iPlayableService.evUpdatedInfo,)),
+                               "VideoPid": (self.VPID, (iPlayableService.evUpdatedInfo,)),
+                               "PcrPid": (self.PCRPID, (iPlayableService.evUpdatedInfo,)),
+                               "PmtPid": (self.PMTPID, (iPlayableService.evUpdatedInfo,)),
+                               "TxtPid": (self.TXTPID, (iPlayableService.evUpdatedInfo,)),
+                               "TsId": (self.TSID, (iPlayableService.evUpdatedInfo,)),
+                               "OnId": (self.ONID, (iPlayableService.evUpdatedInfo,)),
+                               "Sid": (self.SID, (iPlayableService.evUpdatedInfo,)),
+                               "Framerate": (self.FRAMERATE, (iPlayableService.evVideoSizeChanged,iPlayableService.evUpdatedInfo,)),
+                               "TransferBPS": (self.TRANSFERBPS, (iPlayableService.evUpdatedInfo,)),
                        }[type]
 
-       def getServiceInfoString(self, info, what):
+       def getServiceInfoString(self, info, what, convert = lambda x: "%d" % x):
                v = info.getInfo(what)
                if v == -1:
                        return "N/A"
                if v == -2:
                        return info.getInfoString(what)
-               return "%d" % v
+               return convert(v)
 
        @cached
        def getBoolean(self):
@@ -73,8 +94,28 @@ class ServiceInfo(Converter, object):
 
                if self.type == self.XRES:
                        return self.getServiceInfoString(info, iServiceInformation.sVideoWidth)
-               if self.type == self.YRES:
+               elif self.type == self.YRES:
                        return self.getServiceInfoString(info, iServiceInformation.sVideoHeight)
+               elif self.type == self.APID:
+                       return self.getServiceInfoString(info, iServiceInformation.sAudioPID)
+               elif self.type == self.VPID:
+                       return self.getServiceInfoString(info, iServiceInformation.sVideoPID)
+               elif self.type == self.PCRPID:
+                       return self.getServiceInfoString(info, iServiceInformation.sPCRPID)
+               elif self.type == self.PMTPID:
+                       return self.getServiceInfoString(info, iServiceInformation.sPMTPID)
+               elif self.type == self.TXTPID:
+                       return self.getServiceInfoString(info, iServiceInformation.sTXTPID)
+               elif self.type == self.TSID:
+                       return self.getServiceInfoString(info, iServiceInformation.sTSID)
+               elif self.type == self.ONID:
+                       return self.getServiceInfoString(info, iServiceInformation.sONID)
+               elif self.type == self.SID:
+                       return self.getServiceInfoString(info, iServiceInformation.sSID)
+               elif self.type == self.FRAMERATE:
+                       return self.getServiceInfoString(info, iServiceInformation.sFrameRate, lambda x: "%d fps" % ((x+500)/1000))
+               elif self.type == self.TRANSFERBPS:
+                       return self.getServiceInfoString(info, iServiceInformation.sTransferBPS, lambda x: "%d kB/s" % (x/1024))
                return ""
 
        text = property(getText)
@@ -90,6 +131,8 @@ class ServiceInfo(Converter, object):
                        return info.getInfo(iServiceInformation.sVideoWidth)
                if self.type == self.YRES:
                        return info.getInfo(iServiceInformation.sVideoHeight)
+               if self.type == self.FRAMERATE:
+                       return info.getInfo(iServiceInformation.sFrameRate)
 
                return -1