1 from Components.Converter.Converter import Converter
2 from enigma import iServiceInformation, iPlayableService
3 from Components.Element import cached
5 class ServiceInfo(Converter, object):
10 SUBSERVICES_AVAILABLE = 4
25 def __init__(self, type):
26 Converter.__init__(self, type)
27 self.type, self.interesting_events = {
28 "HasTelext": (self.HAS_TELETEXT, (iPlayableService.evUpdatedInfo,)),
29 "IsMultichannel": (self.IS_MULTICHANNEL, (iPlayableService.evUpdatedInfo,)),
30 "IsCrypted": (self.IS_CRYPTED, (iPlayableService.evUpdatedInfo,)),
31 "IsWidescreen": (self.IS_WIDESCREEN, (iPlayableService.evVideoSizeChanged,)),
32 "SubservicesAvailable": (self.SUBSERVICES_AVAILABLE, (iPlayableService.evUpdatedEventInfo,)),
33 "VideoWidth": (self.XRES, (iPlayableService.evVideoSizeChanged,)),
34 "VideoHeight": (self.YRES, (iPlayableService.evVideoSizeChanged,)),
35 "AudioPid": (self.APID, (iPlayableService.evUpdatedInfo,)),
36 "VideoPid": (self.VPID, (iPlayableService.evUpdatedInfo,)),
37 "PcrPid": (self.PCRPID, (iPlayableService.evUpdatedInfo,)),
38 "PmtPid": (self.PMTPID, (iPlayableService.evUpdatedInfo,)),
39 "TxtPid": (self.TXTPID, (iPlayableService.evUpdatedInfo,)),
40 "TsId": (self.TSID, (iPlayableService.evUpdatedInfo,)),
41 "OnId": (self.ONID, (iPlayableService.evUpdatedInfo,)),
42 "Sid": (self.SID, (iPlayableService.evUpdatedInfo,)),
43 "Framerate": (self.FRAMERATE, (iPlayableService.evVideoSizeChanged,iPlayableService.evUpdatedInfo,)),
44 "TransferBPS": (self.TRANSFERBPS, (iPlayableService.evUpdatedInfo,)),
47 def getServiceInfoString(self, info, what, convert = lambda x: "%d" % x):
48 v = info.getInfo(what)
52 return info.getInfoString(what)
57 service = self.source.service
58 info = service and service.info()
62 if self.type == self.HAS_TELETEXT:
63 tpid = info.getInfo(iServiceInformation.sTXTPID)
65 elif self.type == self.IS_MULTICHANNEL:
66 # FIXME. but currently iAudioTrackInfo doesn't provide more information.
67 audio = service.audioTracks()
69 n = audio.getNumberOfTracks()
72 i = audio.getTrackInfo(idx)
73 description = i.getDescription();
74 if "AC3" in description or "DTS" in description:
78 elif self.type == self.IS_CRYPTED:
79 return info.getInfo(iServiceInformation.sIsCrypted) == 1
80 elif self.type == self.IS_WIDESCREEN:
81 return info.getInfo(iServiceInformation.sAspect) in (3, 4, 7, 8, 0xB, 0xC, 0xF, 0x10)
82 elif self.type == self.SUBSERVICES_AVAILABLE:
83 subservices = service.subServices()
84 return subservices and subservices.getNumberOfSubservices() > 0
86 boolean = property(getBoolean)
90 service = self.source.service
91 info = service and service.info()
95 if self.type == self.XRES:
96 return self.getServiceInfoString(info, iServiceInformation.sVideoWidth)
97 elif self.type == self.YRES:
98 return self.getServiceInfoString(info, iServiceInformation.sVideoHeight)
99 elif self.type == self.APID:
100 return self.getServiceInfoString(info, iServiceInformation.sAudioPID)
101 elif self.type == self.VPID:
102 return self.getServiceInfoString(info, iServiceInformation.sVideoPID)
103 elif self.type == self.PCRPID:
104 return self.getServiceInfoString(info, iServiceInformation.sPCRPID)
105 elif self.type == self.PMTPID:
106 return self.getServiceInfoString(info, iServiceInformation.sPMTPID)
107 elif self.type == self.TXTPID:
108 return self.getServiceInfoString(info, iServiceInformation.sTXTPID)
109 elif self.type == self.TSID:
110 return self.getServiceInfoString(info, iServiceInformation.sTSID)
111 elif self.type == self.ONID:
112 return self.getServiceInfoString(info, iServiceInformation.sONID)
113 elif self.type == self.SID:
114 return self.getServiceInfoString(info, iServiceInformation.sSID)
115 elif self.type == self.FRAMERATE:
116 return self.getServiceInfoString(info, iServiceInformation.sFrameRate, lambda x: "%d fps" % ((x+500)/1000))
117 elif self.type == self.TRANSFERBPS:
118 return self.getServiceInfoString(info, iServiceInformation.sTransferBPS, lambda x: "%d kB/s" % (x/1024))
121 text = property(getText)
125 service = self.source.service
126 info = service and service.info()
130 if self.type == self.XRES:
131 return info.getInfo(iServiceInformation.sVideoWidth)
132 if self.type == self.YRES:
133 return info.getInfo(iServiceInformation.sVideoHeight)
134 if self.type == self.FRAMERATE:
135 return info.getInfo(iServiceInformation.sFrameRate)
139 value = property(getValue)
141 def changed(self, what):
142 if what[0] != self.CHANGED_SPECIFIC or what[1] in self.interesting_events:
143 Converter.changed(self, what)