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
20 def ServiceInfoListEntry(a, b, valueType=TYPE_TEXT, param=4):
23 #PyObject *type, *px, *py, *pwidth, *pheight, *pfnt, *pstring, *pflags;
24 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 200, 30, 0, RT_HALIGN_LEFT, ""))
25 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 200, 25, 0, RT_HALIGN_LEFT, a))
27 if type(b) is not str:
28 if valueType == TYPE_VALUE_HEX:
29 b = ("0x%0" + str(param) + "x") % to_unsigned(b)
30 elif valueType == TYPE_VALUE_DEC:
32 elif valueType == TYPE_VALUE_HEX_DEC:
33 b = ("0x%0" + str(param) + "x (%dd)") % (to_unsigned(b), b)
37 res.append((eListboxPythonMultiContent.TYPE_TEXT, 220, 0, 350, 25, 0, RT_HALIGN_LEFT, b))
41 class ServiceInfoList(HTMLComponent, GUIComponent):
42 def __init__(self, source):
43 GUIComponent.__init__(self)
44 self.l = eListboxPythonMultiContent()
46 self.l.setList(self.list)
47 self.l.setFont(0, gFont("Regular", 23))
48 self.l.setItemHeight(25)
52 def postWidgetCreate(self, instance):
53 self.instance.setContent(self.l)
56 TYPE_TRANSPONDER_INFO = 2
58 class ServiceInfo(Screen):
59 def __init__(self, session, serviceref=None):
60 Screen.__init__(self, session)
62 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
66 "red": self.information,
68 "yellow": self.transponder,
73 self.type = TYPE_TRANSPONDER_INFO
75 self["green"] = Label()
76 self["yellow"] = Label()
77 self["blue"] = Label()
78 info = eServiceCenter.getInstance().info(serviceref)
79 self.transponder_info = info.getInfoObject(serviceref, iServiceInformation.sTransponderData)
80 # info is a iStaticServiceInformation, not a iServiceInformation
84 self.type = TYPE_SERVICE_INFO
85 self["red"] = Label(_("Serviceinfo"))
86 self["green"] = Label(_("PIDs"))
87 self["yellow"] = Label(_("Transponder"))
88 self["blue"] = Label(_("Tuner status"))
89 service = session.nav.getCurrentService()
90 if service is not None:
91 self.info = service.info()
92 self.feinfo = service.frontendInfo()
93 print self.info.getInfoObject(iServiceInformation.sCAIDs);
100 self["infolist"] = ServiceInfoList(tlist)
101 self.onShown.append(self.information)
103 def information(self):
104 if self.type == TYPE_SERVICE_INFO:
105 if self.session.nav.getCurrentlyPlayingServiceReference():
106 name = ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference()).getServiceName()
107 refstr = self.session.nav.getCurrentlyPlayingServiceReference().toString()
111 aspect = self.getServiceInfoValue(iServiceInformation.sAspect)
112 if aspect in ( 1, 2, 5, 6, 9, 0xA, 0xD, 0xE ):
116 width = self.info and self.info.getInfo(iServiceInformation.sVideoWidth) or -1
117 height = self.info and self.info.getInfo(iServiceInformation.sVideoHeight) or -1
118 if width != -1 and height != -1:
119 Labels = ( ("Name", name, TYPE_TEXT),
120 ("Provider", self.getServiceInfoValue(iServiceInformation.sProvider), TYPE_TEXT),
121 ("Videoformat", aspect, TYPE_TEXT),
122 ("Videosize", "%dx%d" %(width, height), TYPE_TEXT),
123 ("Namespace", self.getServiceInfoValue(iServiceInformation.sNamespace), TYPE_VALUE_HEX, 8),
124 ("Service Reference", refstr, TYPE_TEXT))
126 Labels = ( ("Name", name, TYPE_TEXT),
127 ("Provider", self.getServiceInfoValue(iServiceInformation.sProvider), TYPE_TEXT),
128 ("Videoformat", aspect, TYPE_TEXT),
129 ("Namespace", self.getServiceInfoValue(iServiceInformation.sNamespace), TYPE_VALUE_HEX, 8),
130 ("Service Reference", refstr, TYPE_TEXT))
131 self.fillList(Labels)
133 if self.transponder_info:
134 conv = { "type" : _("Transponder Type"),
135 "system" : _("System"),
136 "modulation" : _("Modulation"),
137 "orbital position" : _("Orbital Position"),
138 "frequency" : _("Frequency"),
139 "symbolrate" : _("Symbolrate"),
140 "bandwidth" : _("Bandwidth"),
141 "polarization" : _("Polarization"),
142 "inversion" : _("Inversion"),
143 "pilot" : _("Pilot"),
144 "roll off" : _("Rolloff"),
145 "fec inner" : _("FEC"),
146 "code rate lp" : _("Coderate LP"),
147 "code rate hp" : _("Coderate HP"),
148 "constellation" : _("Constellation"),
149 "transmission mode": _("Transmission Mode"),
150 "guard interval" : _("Guard Interval"),
151 "hierarchy" : _("Hierarchy Information") }
153 for i in self.transponder_info.keys():
154 Labels.append( (conv[i], self.transponder_info[i], TYPE_TEXT) )
155 self.fillList(Labels)
158 if self.type == TYPE_SERVICE_INFO:
159 Labels = ( ("VideoPID", self.getServiceInfoValue(iServiceInformation.sVideoPID), TYPE_VALUE_HEX_DEC, 4),
160 ("AudioPID", self.getServiceInfoValue(iServiceInformation.sAudioPID), TYPE_VALUE_HEX_DEC, 4),
161 ("PCRPID", self.getServiceInfoValue(iServiceInformation.sPCRPID), TYPE_VALUE_HEX_DEC, 4),
162 ("PMTPID", self.getServiceInfoValue(iServiceInformation.sPMTPID), TYPE_VALUE_HEX_DEC, 4),
163 ("TXTPID", self.getServiceInfoValue(iServiceInformation.sTXTPID), TYPE_VALUE_HEX_DEC, 4),
164 ("TSID", self.getServiceInfoValue(iServiceInformation.sTSID), TYPE_VALUE_HEX_DEC, 4),
165 ("ONID", self.getServiceInfoValue(iServiceInformation.sONID), TYPE_VALUE_HEX_DEC, 4),
166 ("SID", self.getServiceInfoValue(iServiceInformation.sSID), TYPE_VALUE_HEX_DEC, 4))
167 self.fillList(Labels)
169 def showFrontendData(self, real):
170 if self.type == TYPE_SERVICE_INFO:
171 frontendData = self.feinfo and self.feinfo.getAll(real)
172 Labels = self.getFEData(frontendData)
173 self.fillList(Labels)
175 def transponder(self):
176 if self.type == TYPE_SERVICE_INFO:
177 self.showFrontendData(True)
180 if self.type == TYPE_SERVICE_INFO:
181 self.showFrontendData(False)
183 def getFEData(self, frontendData):
184 if frontendData and len(frontendData):
185 if frontendData["tuner_type"] == "DVB-S":
186 return (("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
187 ("Type", frontendData["system"], TYPE_TEXT),
188 ("Modulation", frontendData["modulation"], TYPE_TEXT),
189 ("Orbital position", frontendData["orbital_position"], TYPE_VALUE_DEC),
190 ("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
191 ("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
192 ("Polarization", frontendData["polarization"], TYPE_TEXT),
193 ("Inversion", frontendData["inversion"], TYPE_TEXT),
194 ("FEC inner", frontendData["fec_inner"], TYPE_TEXT),
195 ("Pilot", frontendData.get("pilot", None), TYPE_TEXT),
196 ("Rolloff", frontendData.get("rolloff", None), TYPE_TEXT))
197 elif frontendData["tuner_type"] == "DVB-C":
198 return (("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
199 ("Type", frontendData["tuner_type"], TYPE_TEXT),
200 ("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
201 ("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
202 ("Modulation", frontendData["modulation"], TYPE_TEXT),
203 ("Inversion", frontendData["inversion"], TYPE_TEXT),
204 ("FEC inner", frontendData["fec_inner"], TYPE_TEXT))
205 elif frontendData["tuner_type"] == "DVB-T":
206 return (("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
207 ("Type", frontendData["tuner_type"], TYPE_TEXT),
208 ("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
209 ("Inversion", frontendData["inversion"], TYPE_TEXT),
210 ("Bandwidth", frontendData["bandwidth"], TYPE_VALUE_DEC),
211 ("CodeRateLP", frontendData["code_rate_lp"], TYPE_TEXT),
212 ("CodeRateHP", frontendData["code_rate_hp"], TYPE_TEXT),
213 ("Constellation", frontendData["constellation"], TYPE_TEXT),
214 ("Transmission Mode", frontendData["transmission_mode"], TYPE_TEXT),
215 ("Guard Interval", frontendData["guard_interval"], TYPE_TEXT),
216 ("Hierarchy Inform.", frontendData["hierarchy_information"], TYPE_TEXT))
219 def fillList(self, Labels):
227 tlist.append(ServiceInfoListEntry(item[0]+":", value, item[2]))
229 tlist.append(ServiceInfoListEntry(item[0]+":", value, item[2], item[3]))
231 self["infolist"].l.setList(tlist)
233 def getServiceInfoValue(self, what):
234 if self.info is None:
237 v = self.info.getInfo(what)
239 v = self.info.getInfoString(what)