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
14 def __init__(self, type):
15 Converter.__init__(self, type)
17 "HasTelext": self.HAS_TELETEXT,
18 "IsMultichannel": self.IS_MULTICHANNEL,
19 "IsCrypted": self.IS_CRYPTED,
20 "IsWidescreen": self.IS_WIDESCREEN,
21 "SubservicesAvailable": self.SUBSERVICES_AVAILABLE,
22 "VideoWidth": self.XRES,
23 "VideoHeight": self.YRES,
26 self.interesting_events = {
27 self.HAS_TELETEXT: [iPlayableService.evUpdatedInfo],
28 self.IS_MULTICHANNEL: [iPlayableService.evUpdatedInfo],
29 self.IS_CRYPTED: [iPlayableService.evUpdatedInfo],
30 self.IS_WIDESCREEN: [iPlayableService.evVideoSizeChanged],
31 self.SUBSERVICES_AVAILABLE: [iPlayableService.evUpdatedEventInfo],
32 self.XRES: [iPlayableService.evVideoSizeChanged],
33 self.YRES: [iPlayableService.evVideoSizeChanged],
36 def getServiceInfoString(self, info, what):
37 v = info.getInfo(what)
41 return info.getInfoString(what)
46 service = self.source.service
47 info = service and service.info()
51 if self.type == self.HAS_TELETEXT:
52 tpid = info.getInfo(iServiceInformation.sTXTPID)
54 elif self.type == self.IS_MULTICHANNEL:
55 # FIXME. but currently iAudioTrackInfo doesn't provide more information.
56 audio = service.audioTracks()
58 n = audio.getNumberOfTracks()
60 i = audio.getTrackInfo(x)
61 description = i.getDescription();
62 if description.find("AC3") != -1 or description.find("DTS") != -1:
65 elif self.type == self.IS_CRYPTED:
66 return info.getInfo(iServiceInformation.sIsCrypted) == 1
67 elif self.type == self.IS_WIDESCREEN:
68 return info.getInfo(iServiceInformation.sAspect) in [3, 4, 7, 8, 0xB, 0xC, 0xF, 0x10]
69 elif self.type == self.SUBSERVICES_AVAILABLE:
70 subservices = service.subServices()
71 return subservices and subservices.getNumberOfSubservices() > 0
73 boolean = property(getBoolean)
77 service = self.source.service
78 info = service and service.info()
82 if self.type == self.XRES:
83 return self.getServiceInfoString(info, iServiceInformation.sVideoWidth)
84 if self.type == self.YRES:
85 return self.getServiceInfoString(info, iServiceInformation.sVideoHeight)
88 text = property(getText)
92 service = self.source.service
93 info = service and service.info()
97 if self.type == self.XRES:
98 return info.getInfo(iServiceInformation.sVideoWidth)
99 if self.type == self.YRES:
100 return info.getInfo(iServiceInformation.sVideoHeight)
104 value = property(getValue)
106 def changed(self, what):
107 if what[0] != self.CHANGED_SPECIFIC or what[1] in self.interesting_events:
108 Converter.changed(self, what)