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
12 def __init__(self, type):
13 Converter.__init__(self, type)
15 "HasTelext": self.HAS_TELETEXT,
16 "IsMultichannel": self.IS_MULTICHANNEL,
17 "IsCrypted": self.IS_CRYPTED,
18 "IsWidescreen": self.IS_WIDESCREEN,
19 "SubservicesAvailable": self.SUBSERVICES_AVAILABLE,
22 self.interesting_events = {
23 self.HAS_TELETEXT: [iPlayableService.evUpdatedInfo],
24 self.IS_MULTICHANNEL: [iPlayableService.evUpdatedInfo],
25 self.IS_CRYPTED: [iPlayableService.evUpdatedInfo],
26 self.IS_WIDESCREEN: [iPlayableService.evUpdatedEventInfo],
27 self.SUBSERVICES_AVAILABLE: [iPlayableService.evUpdatedEventInfo]
31 def getServiceInfoValue(self, info, what):
32 v = info.getInfo(what)
35 return info.getInfoString(what)
39 service = self.source.service
40 info = service and service.info()
44 if self.type == self.HAS_TELETEXT:
45 tpid = info.getInfo(iServiceInformation.sTXTPID)
47 elif self.type == self.IS_MULTICHANNEL:
48 # FIXME. but currently iAudioTrackInfo doesn't provide more information.
49 audio = service.audioTracks()
51 n = audio.getNumberOfTracks()
53 i = audio.getTrackInfo(x)
54 description = i.getDescription();
55 if description.find("AC3") != -1 or description.find("DTS") != -1:
58 elif self.type == self.IS_CRYPTED:
59 return info.getInfo(iServiceInformation.sIsCrypted) == 1
60 elif self.type == self.IS_WIDESCREEN:
61 return info.getInfo(iServiceInformation.sAspect) in [3, 4, 7, 8, 0xB, 0xC, 0xF, 0x10]
62 elif self.type == self.SUBSERVICES_AVAILABLE:
63 subservices = service.subServices()
64 return subservices and subservices.getNumberOfSubservices() > 0
66 boolean = property(getBoolean)
68 def changed(self, what):
69 if what[0] != self.CHANGED_SPECIFIC or what[1] in self.interesting_events:
70 Converter.changed(self, what)