1 from Components.HTMLComponent import HTMLComponent
2 from Components.GUIComponent import GUIComponent
3 from Screen import Screen
4 from Components.ActionMap import ActionMap
5 from Components.Label import Label
6 from ServiceReference import ServiceReference
7 from enigma import eListboxPythonMultiContent, eListbox, gFont, iServiceInformation, eServiceCenter
14 TYPE_VALUE_HEX_DEC = 3
17 def ServiceInfoListEntry(a, b, valueType=TYPE_TEXT, param=4):
20 #PyObject *type, *px, *py, *pwidth, *pheight, *pfnt, *pstring, *pflags;
21 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 200, 30, 0, RT_HALIGN_LEFT, ""))
22 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 200, 25, 0, RT_HALIGN_LEFT, a))
24 if type(b) is not str:
25 if valueType == TYPE_VALUE_HEX:
26 b = ("0x%0" + str(param) + "x") % b
27 elif valueType == TYPE_VALUE_DEC:
29 elif valueType == TYPE_VALUE_HEX_DEC:
30 b = ("0x%0" + str(param) + "x (%dd)") % (b, b)
34 res.append((eListboxPythonMultiContent.TYPE_TEXT, 220, 0, 350, 25, 0, RT_HALIGN_LEFT, b))
38 class ServiceInfoList(HTMLComponent, GUIComponent):
39 def __init__(self, source):
40 GUIComponent.__init__(self)
41 self.l = eListboxPythonMultiContent()
43 self.l.setList(self.list)
44 self.l.setFont(0, gFont("Regular", 23))
45 self.l.setItemHeight(25)
49 def postWidgetCreate(self, instance):
50 self.instance.setContent(self.l)
53 TYPE_TRANSPONDER_INFO = 2
55 class ServiceInfo(Screen):
56 def __init__(self, session, serviceref=None):
57 Screen.__init__(self, session)
59 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
63 "red": self.information,
65 "yellow": self.transponder,
70 self.type = TYPE_TRANSPONDER_INFO
72 self["green"] = Label()
73 self["yellow"] = Label()
74 self["blue"] = Label()
75 info = eServiceCenter.getInstance().info(serviceref)
76 self.transponder_info = info.getInfoObject(serviceref, iServiceInformation.sTransponderData)
77 # info is a iStaticServiceInformation, not a iServiceInformation
81 self.type = TYPE_SERVICE_INFO
82 self["red"] = Label(_("Serviceinfo"))
83 self["green"] = Label(_("PIDs"))
84 self["yellow"] = Label(_("Transponder"))
85 self["blue"] = Label(_("Tuner status"))
86 service = session.nav.getCurrentService()
87 if service is not None:
88 self.info = service.info()
89 self.feinfo = service.frontendInfo()
90 print self.info.getInfoObject(iServiceInformation.sCAIDs);
97 self["infolist"] = ServiceInfoList(tlist)
98 self.onShown.append(self.information)
100 def information(self):
101 if self.type == TYPE_SERVICE_INFO:
102 if self.session.nav.getCurrentlyPlayingServiceReference():
103 name = ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference()).getServiceName()
106 aspect = self.getServiceInfoValue(iServiceInformation.sAspect)
107 if aspect in ( 1, 2, 5, 6, 9, 0xA, 0xD, 0xE ):
111 width = self.info and self.info.getInfo(iServiceInformation.sVideoWidth) or -1
112 height = self.info and self.info.getInfo(iServiceInformation.sVideoHeight) or -1
113 if width != -1 and height != -1:
114 Labels = ( ("Name", name, TYPE_TEXT),
115 ("Provider", self.getServiceInfoValue(iServiceInformation.sProvider), TYPE_TEXT),
116 ("Videoformat", aspect, TYPE_TEXT),
117 ("Videosize", "%dx%d" %(width, height), TYPE_TEXT),
118 ("Namespace", self.getServiceInfoValue(iServiceInformation.sNamespace), TYPE_VALUE_HEX, 8))
120 Labels = ( ("Name", name, TYPE_TEXT),
121 ("Provider", self.getServiceInfoValue(iServiceInformation.sProvider), TYPE_TEXT),
122 ("Videoformat", aspect, TYPE_TEXT),
123 ("Namespace", self.getServiceInfoValue(iServiceInformation.sNamespace), TYPE_VALUE_HEX, 8))
124 self.fillList(Labels)
126 if self.transponder_info:
127 conv = { "type" : _("Transponder Type"),
128 "frequency" : _("Frequency"),
129 "symbolrate" : _("Symbolrate"),
130 "orbital position" : _("Orbital Position"),
131 "inversion" : _("Inversion"),
132 "fec inner" : _("FEC"),
133 "modulation" : _("Modulation"),
134 "polarization" : _("Polarization"),
135 "roll off" : _("Rolloff"),
136 "system" : _("System"),
137 "bandwidth" : _("Bandwidth"),
138 "code rate lp" : _("Coderate LP"),
139 "code rate hp" : _("Coderate HP"),
140 "constellation" : _("Constellation"),
141 "transmission mode": _("Transmission Mode"),
142 "guard interval" : _("Guard Interval"),
143 "hierarchy" : _("Hierarchy Information") }
145 for i in self.transponder_info.keys():
146 Labels.append( (conv[i], self.transponder_info[i], TYPE_TEXT) )
147 self.fillList(Labels)
150 if self.type == TYPE_SERVICE_INFO:
151 Labels = ( ("VideoPID", self.getServiceInfoValue(iServiceInformation.sVideoPID), TYPE_VALUE_HEX_DEC, 4),
152 ("AudioPID", self.getServiceInfoValue(iServiceInformation.sAudioPID), TYPE_VALUE_HEX_DEC, 4),
153 ("PCRPID", self.getServiceInfoValue(iServiceInformation.sPCRPID), TYPE_VALUE_HEX_DEC, 4),
154 ("PMTPID", self.getServiceInfoValue(iServiceInformation.sPMTPID), TYPE_VALUE_HEX_DEC, 4),
155 ("TXTPID", self.getServiceInfoValue(iServiceInformation.sTXTPID), TYPE_VALUE_HEX_DEC, 4),
156 ("TSID", self.getServiceInfoValue(iServiceInformation.sTSID), TYPE_VALUE_HEX_DEC, 4),
157 ("ONID", self.getServiceInfoValue(iServiceInformation.sONID), TYPE_VALUE_HEX_DEC, 4),
158 ("SID", self.getServiceInfoValue(iServiceInformation.sSID), TYPE_VALUE_HEX_DEC, 4))
159 self.fillList(Labels)
161 def showFrontendData(self, real):
162 if self.type == TYPE_SERVICE_INFO:
163 frontendData = self.feinfo and self.feinfo.getAll(real)
164 Labels = self.getFEData(frontendData)
165 self.fillList(Labels)
167 def transponder(self):
168 if self.type == TYPE_SERVICE_INFO:
169 self.showFrontendData(True)
172 if self.type == TYPE_SERVICE_INFO:
173 self.showFrontendData(False)
175 def getFEData(self, frontendData):
176 if frontendData and len(frontendData):
177 if frontendData["tuner_type"] == "DVB-S":
178 return (("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
179 ("Type", frontendData["system"], TYPE_TEXT),
180 ("Modulation", frontendData["modulation"], TYPE_TEXT),
181 ("Orbital position", frontendData["orbital_position"], TYPE_VALUE_DEC),
182 ("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
183 ("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
184 ("Polarization", frontendData["polarization"], TYPE_TEXT),
185 ("Inversion", frontendData["inversion"], TYPE_TEXT),
186 ("FEC inner", frontendData["fec_inner"], TYPE_TEXT))
187 elif frontendData["tuner_type"] == "DVB-C":
188 return (("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
189 ("Type", frontendData["tuner_type"], TYPE_TEXT),
190 ("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
191 ("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
192 ("Modulation", frontendData["modulation"], TYPE_TEXT),
193 ("Inversion", frontendData["inversion"], TYPE_TEXT),
194 ("FEC inner", frontendData["fec_inner"], TYPE_TEXT))
195 elif frontendData["tuner_type"] == "DVB-T":
196 return (("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
197 ("Type", frontendData["tuner_type"], TYPE_TEXT),
198 ("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
199 ("Inversion", frontendData["inversion"], TYPE_TEXT),
200 ("Bandwidth", frontendData["bandwidth"], TYPE_VALUE_DEC),
201 ("CodeRateLP", frontendData["code_rate_lp"], TYPE_TEXT),
202 ("CodeRateHP", frontendData["code_rate_hp"], TYPE_TEXT),
203 ("Constellation", frontendData["constellation"], TYPE_TEXT),
204 ("Transmission Mode", frontendData["transmission_mode"], TYPE_TEXT),
205 ("Guard Interval", frontendData["guard_interval"], TYPE_TEXT),
206 ("Hierarchy Inform.", frontendData["hierarchy_information"], TYPE_TEXT))
209 def fillList(self, Labels):
215 tlist.append(ServiceInfoListEntry(item[0]+":", value, item[2]))
217 tlist.append(ServiceInfoListEntry(item[0]+":", value, item[2], item[3]))
219 self["infolist"].l.setList(tlist)
221 def getServiceInfoValue(self, what):
222 if self.info is None:
225 v = self.info.getInfo(what)
227 v = self.info.getInfoString(what)