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
8 from Tools.Transponder import ConvertToHumanReadable
15 TYPE_VALUE_HEX_DEC = 3
21 def ServiceInfoListEntry(a, b, valueType=TYPE_TEXT, param=4):
23 if not isinstance(b, str):
24 if valueType == TYPE_VALUE_HEX:
25 b = ("0x%0" + str(param) + "x") % to_unsigned(b)
26 elif valueType == TYPE_VALUE_DEC:
28 elif valueType == TYPE_VALUE_HEX_DEC:
29 b = ("0x%0" + str(param) + "x (%dd)") % (to_unsigned(b), b)
34 #PyObject *type, *px, *py, *pwidth, *pheight, *pfnt, *pstring, *pflags;
35 (eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 200, 30, 0, RT_HALIGN_LEFT, ""),
36 (eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 200, 25, 0, RT_HALIGN_LEFT, a),
37 (eListboxPythonMultiContent.TYPE_TEXT, 220, 0, 350, 25, 0, RT_HALIGN_LEFT, b)
40 class ServiceInfoList(HTMLComponent, GUIComponent):
41 def __init__(self, source):
42 GUIComponent.__init__(self)
43 self.l = eListboxPythonMultiContent()
45 self.l.setList(self.list)
46 self.l.setFont(0, gFont("Regular", 23))
47 self.l.setItemHeight(25)
51 def postWidgetCreate(self, instance):
52 self.instance.setContent(self.l)
55 TYPE_TRANSPONDER_INFO = 2
57 class ServiceInfo(Screen):
58 def __init__(self, session, serviceref=None):
59 Screen.__init__(self, session)
61 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
65 "red": self.information,
67 "yellow": self.transponder,
72 self.type = TYPE_TRANSPONDER_INFO
74 self["green"] = Label()
75 self["yellow"] = Label()
76 self["blue"] = Label()
77 info = eServiceCenter.getInstance().info(serviceref)
78 self.transponder_info = info.getInfoObject(serviceref, iServiceInformation.sTransponderData)
79 # info is a iStaticServiceInformation, not a iServiceInformation
83 self.type = TYPE_SERVICE_INFO
84 self["red"] = Label(_("Serviceinfo"))
85 self["green"] = Label(_("PIDs"))
86 self["yellow"] = Label(_("Transponder"))
87 self["blue"] = Label(_("Tuner status"))
88 service = session.nav.getCurrentService()
89 if service is not None:
90 self.info = service.info()
91 self.feinfo = service.frontendInfo()
92 print self.info.getInfoObject(iServiceInformation.sCAIDs);
99 self["infolist"] = ServiceInfoList(tlist)
100 self.onShown.append(self.information)
102 def information(self):
103 if self.type == TYPE_SERVICE_INFO:
104 if self.session.nav.getCurrentlyPlayingServiceReference():
105 name = ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference()).getServiceName()
106 refstr = self.session.nav.getCurrentlyPlayingServiceReference().toString()
110 aspect = self.getServiceInfoValue(iServiceInformation.sAspect)
111 if aspect in ( 1, 2, 5, 6, 9, 0xA, 0xD, 0xE ):
115 width = self.info and self.info.getInfo(iServiceInformation.sVideoWidth) or -1
116 height = self.info and self.info.getInfo(iServiceInformation.sVideoHeight) or -1
117 if width != -1 and height != -1:
118 Labels = ( ("Name", name, TYPE_TEXT),
119 ("Provider", self.getServiceInfoValue(iServiceInformation.sProvider), TYPE_TEXT),
120 ("Videoformat", aspect, TYPE_TEXT),
121 ("Videosize", "%dx%d" %(width, height), TYPE_TEXT),
122 ("Namespace", self.getServiceInfoValue(iServiceInformation.sNamespace), TYPE_VALUE_HEX, 8),
123 ("Service Reference", refstr, TYPE_TEXT))
125 Labels = ( ("Name", name, TYPE_TEXT),
126 ("Provider", self.getServiceInfoValue(iServiceInformation.sProvider), TYPE_TEXT),
127 ("Videoformat", aspect, TYPE_TEXT),
128 ("Namespace", self.getServiceInfoValue(iServiceInformation.sNamespace), TYPE_VALUE_HEX, 8),
129 ("Service Reference", refstr, TYPE_TEXT))
130 self.fillList(Labels)
132 if self.transponder_info:
133 tp_info = ConvertToHumanReadable(self.transponder_info)
134 conv = { "tuner_type" : _("Transponder Type"),
135 "system" : _("System"),
136 "modulation" : _("Modulation"),
137 "orbital_position" : _("Orbital Position"),
138 "frequency" : _("Frequency"),
139 "symbol_rate" : _("Symbolrate"),
140 "bandwidth" : _("Bandwidth"),
141 "polarization" : _("Polarization"),
142 "inversion" : _("Inversion"),
143 "pilot" : _("Pilot"),
144 "rolloff" : _("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_information": _("Hierarchy Information") }
152 Labels = [(conv[i], tp_info[i], TYPE_VALUE_DEC) for i in tp_info.keys()]
153 self.fillList(Labels)
156 if self.type == TYPE_SERVICE_INFO:
157 Labels = ( ("VideoPID", self.getServiceInfoValue(iServiceInformation.sVideoPID), TYPE_VALUE_HEX_DEC, 4),
158 ("AudioPID", self.getServiceInfoValue(iServiceInformation.sAudioPID), TYPE_VALUE_HEX_DEC, 4),
159 ("PCRPID", self.getServiceInfoValue(iServiceInformation.sPCRPID), TYPE_VALUE_HEX_DEC, 4),
160 ("PMTPID", self.getServiceInfoValue(iServiceInformation.sPMTPID), TYPE_VALUE_HEX_DEC, 4),
161 ("TXTPID", self.getServiceInfoValue(iServiceInformation.sTXTPID), TYPE_VALUE_HEX_DEC, 4),
162 ("TSID", self.getServiceInfoValue(iServiceInformation.sTSID), TYPE_VALUE_HEX_DEC, 4),
163 ("ONID", self.getServiceInfoValue(iServiceInformation.sONID), TYPE_VALUE_HEX_DEC, 4),
164 ("SID", self.getServiceInfoValue(iServiceInformation.sSID), TYPE_VALUE_HEX_DEC, 4))
165 self.fillList(Labels)
167 def showFrontendData(self, real):
168 if self.type == TYPE_SERVICE_INFO:
169 frontendData = self.feinfo and self.feinfo.getAll(real)
170 Labels = self.getFEData(frontendData)
171 self.fillList(Labels)
173 def transponder(self):
174 if self.type == TYPE_SERVICE_INFO:
175 self.showFrontendData(True)
178 if self.type == TYPE_SERVICE_INFO:
179 self.showFrontendData(False)
181 def getFEData(self, frontendDataOrg):
182 if frontendDataOrg and len(frontendDataOrg):
183 frontendData = ConvertToHumanReadable(frontendDataOrg)
184 if frontendDataOrg["tuner_type"] == "DVB-S":
185 return (("NIM", ('A', 'B', 'C', 'D')[frontendData["tuner_number"]], TYPE_TEXT),
186 ("Type", frontendData["system"], TYPE_TEXT),
187 ("Modulation", frontendData["modulation"], TYPE_TEXT),
188 ("Orbital position", frontendData["orbital_position"], TYPE_VALUE_DEC),
189 ("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
190 ("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
191 ("Polarization", frontendData["polarization"], TYPE_TEXT),
192 ("Inversion", frontendData["inversion"], TYPE_TEXT),
193 ("FEC inner", frontendData["fec_inner"], TYPE_TEXT),
194 ("Pilot", frontendData.get("pilot", None), TYPE_TEXT),
195 ("Rolloff", frontendData.get("rolloff", None), TYPE_TEXT))
196 elif frontendDataOrg["tuner_type"] == "DVB-C":
197 return (("NIM", ('A', 'B', 'C', 'D')[frontendData["tuner_number"]], TYPE_TEXT),
198 ("Type", frontendData["tuner_type"], TYPE_TEXT),
199 ("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
200 ("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
201 ("Modulation", frontendData["modulation"], TYPE_TEXT),
202 ("Inversion", frontendData["inversion"], TYPE_TEXT),
203 ("FEC inner", frontendData["fec_inner"], TYPE_TEXT))
204 elif frontendDataOrg["tuner_type"] == "DVB-T":
205 return (("NIM", ('A', 'B', 'C', 'D')[frontendData["tuner_number"]], TYPE_TEXT),
206 ("Type", frontendData["tuner_type"], TYPE_TEXT),
207 ("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
208 ("Inversion", frontendData["inversion"], TYPE_TEXT),
209 ("Bandwidth", frontendData["bandwidth"], TYPE_VALUE_DEC),
210 ("CodeRateLP", frontendData["code_rate_lp"], TYPE_TEXT),
211 ("CodeRateHP", frontendData["code_rate_hp"], TYPE_TEXT),
212 ("Constellation", frontendData["constellation"], TYPE_TEXT),
213 ("Transmission Mode", frontendData["transmission_mode"], TYPE_TEXT),
214 ("Guard Interval", frontendData["guard_interval"], TYPE_TEXT),
215 ("Hierarchy Inform.", frontendData["hierarchy_information"], TYPE_TEXT))
218 def fillList(self, Labels):
226 tlist.append(ServiceInfoListEntry(item[0]+":", value, item[2]))
228 tlist.append(ServiceInfoListEntry(item[0]+":", value, item[2], item[3]))
230 self["infolist"].l.setList(tlist)
232 def getServiceInfoValue(self, what):
233 if self.info is None:
236 v = self.info.getInfo(what)
238 v = self.info.getInfoString(what)