IS_CRYPTED = 2
IS_WIDESCREEN = 3
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)
- self.type = {
- "HasTelext": self.HAS_TELETEXT,
- "IsMultichannel": self.IS_MULTICHANNEL,
- "IsCrypted": self.IS_CRYPTED,
- "IsWidescreen": self.IS_WIDESCREEN,
- "SubservicesAvailable": self.SUBSERVICES_AVAILABLE,
+ self.type, self.interesting_events = {
+ "HasTelext": (self.HAS_TELETEXT, (iPlayableService.evUpdatedInfo,)),
+ "IsMultichannel": (self.IS_MULTICHANNEL, (iPlayableService.evUpdatedInfo,)),
+ "IsCrypted": (self.IS_CRYPTED, (iPlayableService.evUpdatedInfo,)),
+ "IsWidescreen": (self.IS_WIDESCREEN, (iPlayableService.evVideoSizeChanged,)),
+ "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]
- self.interesting_events = {
- self.HAS_TELETEXT: [iPlayableService.evUpdatedInfo],
- self.IS_MULTICHANNEL: [iPlayableService.evUpdatedInfo],
- self.IS_CRYPTED: [iPlayableService.evUpdatedInfo],
- self.IS_WIDESCREEN: [iPlayableService.evUpdatedEventInfo],
- self.SUBSERVICES_AVAILABLE: [iPlayableService.evUpdatedEventInfo]
- }[self.type]
-
- @cached
- def getServiceInfoValue(self, info, what):
+ def getServiceInfoString(self, info, what, convert = lambda x: "%d" % x):
v = info.getInfo(what)
- if v != -2:
+ if v == -1:
return "N/A"
- return info.getInfoString(what)
+ if v == -2:
+ return info.getInfoString(what)
+ return convert(v)
@cached
def getBoolean(self):
audio = service.audioTracks()
if audio:
n = audio.getNumberOfTracks()
- for x in range(n):
- i = audio.getTrackInfo(x)
+ idx = 0
+ while idx < n:
+ i = audio.getTrackInfo(idx)
description = i.getDescription();
- if description.find("AC3") != -1 or description.find("DTS") != -1:
+ if "AC3" in description or "DTS" in description:
return True
+ idx += 1
return False
elif self.type == self.IS_CRYPTED:
return info.getInfo(iServiceInformation.sIsCrypted) == 1
elif self.type == self.IS_WIDESCREEN:
- return info.getInfo(iServiceInformation.sAspect) in [3, 4, 7, 8, 0xB, 0xC, 0xF, 0x10]
+ return info.getInfo(iServiceInformation.sAspect) in (3, 4, 7, 8, 0xB, 0xC, 0xF, 0x10)
elif self.type == self.SUBSERVICES_AVAILABLE:
subservices = service.subServices()
return subservices and subservices.getNumberOfSubservices() > 0
boolean = property(getBoolean)
+
+ @cached
+ def getText(self):
+ service = self.source.service
+ info = service and service.info()
+ if not info:
+ return ""
+
+ if self.type == self.XRES:
+ return self.getServiceInfoString(info, iServiceInformation.sVideoWidth)
+ 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)
+
+ @cached
+ def getValue(self):
+ service = self.source.service
+ info = service and service.info()
+ if not info:
+ return -1
+
+ if self.type == self.XRES:
+ 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
+
+ value = property(getValue)
def changed(self, what):
if what[0] != self.CHANGED_SPECIFIC or what[1] in self.interesting_events: