77511d1a640fb49820b6d476c3553a152cb5f9d1
[vuplus_dvbapp] / lib / python / Plugins / SystemPlugins / TransCodingSetup / plugin.py
1 from Screens.Screen import Screen
2 from Components.ConfigList import ConfigListScreen
3 from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSelection, ConfigInteger
4 from Components.ActionMap import ActionMap
5 from Screens.MessageBox import MessageBox
6 from Components.Sources.StaticText import StaticText
7 from Plugins.Plugin import PluginDescriptor
8 from Tools.Directories import fileExists
9 from enigma import eTimer
10 from os import system as os_system
11 from __init__ import _
12
13 def getModel():
14         filename = "/proc/stb/info/vumodel"
15         if fileExists(filename):
16                 return file(filename).read().strip()
17         return ""
18
19 def getProcValue(procPath):
20         fd = open(procPath,'r')
21         curValue = fd.read().strip(' ').strip('\n')
22         fd.close()
23 #       print "[TranscodingSetup] get %s from %s" % (curValue, procPath)
24         return curValue
25
26 def setProcValue(procPath, value):
27         print "[TranscodingSetup] set %s to %s" % (procPath, value)
28         fd = open(procPath,'w')
29         fd.write(value)
30         fd.close()
31
32 def checkSupportAdvanced():
33         if fileExists( g_procPath["aspectratio"] ):
34                 return True
35         return False
36
37 transcodingsetupinit = None
38
39 g_procPath = {
40         "bitrate"               :       "/proc/stb/encoder/0/bitrate",
41         "framerate"             :       "/proc/stb/encoder/0/framerate",
42         "resolution"    :       "/proc/stb/encoder/0/display_format",
43         "aspectratio"   :       "/proc/stb/encoder/0/aspectratio",
44         "audiocodec"    :       "/proc/stb/encoder/0/audio_codec",
45         "videocodec"    :       "/proc/stb/encoder/0/video_codec",
46         "gopframeb"     :       "/proc/stb/encoder/0/gop_frameb",
47         "gopframep"     :       "/proc/stb/encoder/0/gop_framep",
48         "level"                 :       "/proc/stb/encoder/0/level",
49         "profile"               :       "/proc/stb/encoder/0/profile",
50         "width"                 :       "/proc/stb/encoder/0/width",
51         "height"                :       "/proc/stb/encoder/0/height",
52 }
53
54 config.plugins.transcodingsetup = ConfigSubsection()
55 config.plugins.transcodingsetup.transcoding = ConfigSelection(default = "enable", choices = [ ("enable", _("enable")), ("disable", _("disable"))] )
56 config.plugins.transcodingsetup.port = ConfigSelection(default = "8002", choices = [ ("8001", "8001"), ("8002", "8002")] )
57
58 if fileExists( g_procPath["bitrate"] ):
59         if getModel() == "solo2":
60                 config.plugins.transcodingsetup.bitrate = ConfigInteger(default = 400000, limits = (50000, 1000000))
61         else:
62                 config.plugins.transcodingsetup.bitrate = ConfigInteger(default = 2000000, limits = (100000, 5000000))
63
64 if fileExists( g_procPath["framerate"] ):
65         config.plugins.transcodingsetup.framerate = ConfigSelection(default = "30000", choices = [ ("23976", _("23976")), ("24000", _("24000")), ("25000", _("25000")), ("29970", _("29970")), ("30000", _("30000")), ("50000", _("50000")), ("59940", _("59940")), ("60000", _("60000"))] )
66
67 if checkSupportAdvanced() and (hasattr(config.plugins.transcodingsetup, "bitrate") or hasattr(config.plugins.transcodingsetup, "framerate")):
68         config.plugins.transcodingsetup.automode = ConfigSelection(default = "Off", choices = [ ("On", _("On")), ("Off", _("Off")) ] )
69
70 if fileExists( g_procPath["resolution"] ):
71         config.plugins.transcodingsetup.resolution = ConfigSelection(default = "480p", choices = [ ("480p", _("480p")), ("576p", _("576p")), ("720p", _("720p")), ("320x240", _("320x240")), ("160x120", _("160x120")) ] )
72
73 if fileExists( g_procPath["aspectratio"] ):
74         config.plugins.transcodingsetup.aspectratio = ConfigSelection(default = "1", choices = [ ("0", _("auto")), ("1", _("4x3")), ("2", _("16x9")) ] )
75
76 if fileExists( g_procPath["audiocodec"] ):
77         config.plugins.transcodingsetup.audiocodec = ConfigSelection(default = "aac", choices = [("mpg", _("mpg")), ("mp3", _("mp3")), ("aac", _("aac")), ("aac+", _("aac+")), ("aac+loas", _("aac+loas")), ("aac+adts", _("aac+adts")), ("ac3", _("ac3"))] )
78
79 if fileExists( g_procPath["videocodec"] ):
80         config.plugins.transcodingsetup.videocodec = ConfigSelection(default = "h264", choices = [ ("h264", _("h264")), ("mpeg2", _("mpeg2")), ("mpeg4p2", _("mpeg4p2"))] )
81
82 if fileExists( g_procPath["gopframeb"] ):
83         config.plugins.transcodingsetup.gopframeb = ConfigInteger(default = 0, limits = (0, 60))
84
85 if fileExists( g_procPath["gopframep"] ):
86         config.plugins.transcodingsetup.gopframep = ConfigInteger(default = 29, limits = (0, 60))
87
88 if fileExists( g_procPath["level"] ):
89         config.plugins.transcodingsetup.level = ConfigSelection(default = "3.1", choices = [("1.0", _("1.0")), ("2.0", _("2.0")),
90                 ("2.1", _("2.1")), ("2.2", _("2.2")), ("3.0", _("3.0")), ("3.1", _("3.1")),
91                 ("3.2", _("3.2")), ("4.0", _("4.0")), ("4.1", _("4.1")), ("4.2", _("4.2")),
92                 ("5.0", _("5.0")), ("low", _("low")), ("main", _("main")), ("high", _("high"))] )
93
94 if fileExists( g_procPath["profile"] ):
95         config.plugins.transcodingsetup.profile = ConfigSelection(default = "baseline", choices = [("baseline", _("baseline")), ("simple", _("simple")), ("main", _("main")), ("high", _("high")), ("advanced simple", _("advanced simple"))] )
96
97 class TranscodingSetupInit:
98         def __init__(self):
99                 self.pluginsetup = None
100                 config.plugins.transcodingsetup.port.addNotifier(self.setPort)
101
102                 if hasattr(config.plugins.transcodingsetup, "automode"):
103                         if config.plugins.transcodingsetup.automode.value == "On":
104                                 config.plugins.transcodingsetup.automode.addNotifier(self.setAutomode)
105
106                                 if hasattr(config.plugins.transcodingsetup, "bitrate"):
107                                         config.plugins.transcodingsetup.bitrate.addNotifier(self.setBitrate, False)
108
109                                 if hasattr(config.plugins.transcodingsetup, "framerate"):
110                                         config.plugins.transcodingsetup.framerate.addNotifier(self.setFramerate, False)
111
112                         else: # autoMode Off
113                                 config.plugins.transcodingsetup.automode.addNotifier(self.setAutomode, False)
114                                 if hasattr(config.plugins.transcodingsetup, "bitrate"):
115                                         config.plugins.transcodingsetup.bitrate.addNotifier(self.setBitrate)
116
117                                 if hasattr(config.plugins.transcodingsetup, "framerate"):
118                                         config.plugins.transcodingsetup.framerate.addNotifier(self.setFramerate)
119
120                 if hasattr(config.plugins.transcodingsetup, "resolution"):
121                         config.plugins.transcodingsetup.resolution.addNotifier(self.setResolution)
122
123                 if hasattr(config.plugins.transcodingsetup, "aspectratio"):
124                         config.plugins.transcodingsetup.aspectratio.addNotifier(self.setAspectRatio)
125
126                 if hasattr(config.plugins.transcodingsetup, "audiocodec"):
127                         config.plugins.transcodingsetup.audiocodec.addNotifier(self.setAudioCodec)
128
129                 if hasattr(config.plugins.transcodingsetup, "videocodec"):
130                         config.plugins.transcodingsetup.videocodec.addNotifier(self.setVideoCodec)
131
132                 if hasattr(config.plugins.transcodingsetup, "gopframeb"):
133                         config.plugins.transcodingsetup.gopframeb.addNotifier(self.setGopFrameB)
134
135                 if hasattr(config.plugins.transcodingsetup, "gopframep"):
136                         config.plugins.transcodingsetup.gopframep.addNotifier(self.setGopFrameP)
137
138                 if hasattr(config.plugins.transcodingsetup, "level"):
139                         config.plugins.transcodingsetup.level.addNotifier(self.setLevel)
140
141                 if hasattr(config.plugins.transcodingsetup, "profile"):
142                         config.plugins.transcodingsetup.profile.addNotifier(self.setProfile)
143
144         def setConfig(self, procPath, value, configName = ""):
145                 if not fileExists(procPath):
146                         return -1
147                 if isinstance(value, str):
148                         value = value.strip(' ').strip('\n')
149                 else:
150                         value = str(value)
151                 try:
152                         oldValue = getProcValue(procPath)
153                         if oldValue != value:
154 #                               print "[TranscodingSetup] set %s "%procPath, value
155                                 setProcValue(procPath, value)
156                                 setValue = getProcValue(procPath)
157                                 if value != setValue:
158                                         print "[TranscodingSetup] set failed. (%s > %s)" % ( value, procPath )
159                                         return -1
160                                 return 0
161                 except:
162                         print "setConfig exception error (%s > %s)" % ( value, procPath )
163                         return -1
164                 return 0
165
166         def setPort(self, configElement):
167                 port = configElement.value
168                 port2 = (port == "8001") and "8002" or "8001"
169
170                 print "[TranscodingSetup] set port ",port
171                 try:
172                         newConfigData = ""
173                         oldConfigData = file('/etc/inetd.conf').read()
174                         for L in oldConfigData.splitlines():
175                                 try:
176                                         if L[0] == '#':
177                                                 newConfigData += L + '\n'
178                                                 continue
179                                 except: continue
180                                 LL = L.split()
181                                 if LL[5] == '/usr/bin/streamproxy':
182                                         LL[0] = port2
183                                 elif LL[5] == '/usr/bin/transtreamproxy':
184                                         LL[0] = port
185                                 newConfigData += ''.join(str(X) + " " for X in LL) + '\n'
186
187                         if newConfigData.find("transtreamproxy") == -1:
188                                 newConfigData += port + " stream tcp nowait root /usr/bin/transtreamproxy transtreamproxy\n"
189                         file('/etc/inetd.conf', 'w').write(newConfigData)
190                 except:
191                         self.showMessage("Set port failed.", MessageBox.TYPE_ERROR)
192                         return
193
194                 self.inetdRestart()
195                 if port == "8001":
196                         msg = "Set port OK.\nPC Streaming is replaced with mobile streaming."
197                         self.showMessage(msg, MessageBox.TYPE_INFO)
198
199         def setupConfig(self, configElement, configName):
200 #               print "[TranscodingSetup] set %s to %s" % ( configName, configElement.value )
201                 configValue = configElement.value
202                 procPath = g_procPath[configName]
203                 if self.setConfig(procPath, configValue):
204                         # set config failed, reset to current proc value
205                         self.getConfigFromProc(procPath, configElement)
206                         self.showMessage("Set %s failed." % (configName), MessageBox.TYPE_ERROR)
207
208         def getConfigFromProc(self, procPath, configElement):
209                 curValue = getProcValue(procPath)
210                 if isinstance(configElement.value, int): # is int ?
211                         curValue = int(curValue)
212                 configElement.value = curValue
213                 configElement.save()
214
215         def setAutomode(self, configElement):
216                 configName = "AutoMode"
217 #               print "[TranscodingSetup]  setAutomode, configName %s, value %s" % ( configName, configElement.value )
218                 if configElement.value == "On":
219                         autoValue = str(-1)
220                         if ((hasattr(config.plugins.transcodingsetup, "bitrate") and
221                                         self.setConfig(g_procPath["bitrate"], autoValue) ) or
222                                         (hasattr(config.plugins.transcodingsetup, "framerate") and
223                                         self.setConfig(g_procPath["framerate"], autoValue) ) ):
224                                 configElement.value = "Off" # set config failed, reset to previous value
225                                 configElement.save()
226                                 self.showMessage("Set %s failed." % (configName), MessageBox.TYPE_ERROR)
227                 else: # Off
228                         if hasattr(config.plugins.transcodingsetup, "bitrate"):
229                                 self.setBitrate(config.plugins.transcodingsetup.bitrate)
230                         if hasattr(config.plugins.transcodingsetup, "framerate"):
231                                 self.setFramerate(config.plugins.transcodingsetup.framerate)
232
233         def setBitrate(self, configElement):
234                 self.setupConfig(configElement, "bitrate")
235
236         def setFramerate(self, configElement):
237                 self.setupConfig(configElement, "framerate")
238
239         def setResolution(self, configElement):
240                 resolution = configElement.value
241                 if resolution in [ "320x240", "160x120" ]:
242                         (width, height) = tuple(resolution.split('x'))
243                         self.setConfig(g_procPath["resolution"], "custom")
244                         self.setConfig(g_procPath["width"], width)
245                         self.setConfig(g_procPath["height"], height)
246                 else:
247                         self.setupConfig(configElement, "resolution")
248
249         def setAspectRatio(self, configElement):
250                 self.setupConfig(configElement, "aspectratio")
251
252         def setAudioCodec(self, configElement):
253                 self.setupConfig(configElement, "audiocodec")
254
255         def setVideoCodec(self, configElement):
256                 self.setupConfig(configElement, "videocodec")
257
258         def setGopFrameB(self, configElement):
259                 self.setupConfig(configElement, "gopframeb")
260
261         def setGopFrameP(self, configElement):
262                 self.setupConfig(configElement, "gopframep")
263
264         def setLevel(self, configElement):
265                 self.setupConfig(configElement, "level")
266
267         def setProfile(self, configElement):
268                 self.setupConfig(configElement, "profile")
269
270         def inetdRestart(self):
271                 if fileExists("/etc/init.d/inetd"):
272                         os_system("/etc/init.d/inetd restart")
273                 elif fileExists("/etc/init.d/inetd.busybox"):
274                         os_system("/etc/init.d/inetd.busybox restart")
275
276         def showMessage(self, msg, msgType):
277                 if self.pluginsetup:
278                         self.pluginsetup.showMessage(msg, msgType)
279
280 class TranscodingSetup(Screen, ConfigListScreen):
281         skin_expert =  """
282                 <screen position="center,center" size="600,450">
283                         <ePixmap pixmap="skin_default/buttons/red.png" position="5,0" size="140,40" alphatest="on" />
284                         <ePixmap pixmap="skin_default/buttons/green.png" position="155,0" size="140,40" alphatest="on" />
285                         <ePixmap pixmap="skin_default/buttons/yellow.png" position="305,0" size="140,40" alphatest="on" />
286                         <ePixmap pixmap="skin_default/buttons/blue.png" position="455,0" size="140,40" alphatest="on" />
287                         <widget source="key_red" render="Label" position="5,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" foregroundColor="#ffffff" transparent="1" />
288                         <widget source="key_green" render="Label" position="155,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" foregroundColor="#ffffff" transparent="1" />
289                         <widget source="key_yellow" render="Label" position="305,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" foregroundColor="#ffffff" transparent="1" />
290                         <widget source="key_blue" render="Label" position="455,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" foregroundColor="#ffffff" transparent="1" />
291                         <widget name="config" zPosition="2" position="25,70" size="560,300" scrollbarMode="showOnDemand" transparent="1" />
292                         <widget source="description" render="Label" position="20,370" size="540,60" font="Regular;20" halign="center" valign="center" />
293                         <widget source="text" render="Label" position="20,430" size="540,20" font="Regular;22" halign="center" valign="center" />
294                 </screen>
295                 """
296
297         skin_normal =  """
298                 <screen position="center,center" size="540,290">
299                         <ePixmap pixmap="skin_default/buttons/red.png" position="30,10" size="140,40" alphatest="on" />
300                         <ePixmap pixmap="skin_default/buttons/green.png" position="200,10" size="140,40" alphatest="on" />
301                         <ePixmap pixmap="skin_default/buttons/yellow.png" position="370,10" size="140,40" alphatest="on" />
302                         <widget source="key_red" render="Label" position="30,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" foregroundColor="#ffffff" transparent="1" />
303                         <widget source="key_green" render="Label" position="200,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" foregroundColor="#ffffff" transparent="1" />
304                         <widget source="key_yellow" render="Label" position="370,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" foregroundColor="#ffffff" transparent="1" />
305                         <widget name="config" zPosition="2" position="20,70" size="500,120" scrollbarMode="showOnDemand" transparent="1" />
306                         <widget source="description" render="Label" position="30,190" size="480,60" font="Regular;20" halign="center" valign="center" />
307                         <widget source="text" render="Label" position="30,250" size="480,30" font="Regular;22" halign="center" valign="center" />
308                 </screen>
309                 """
310
311         def __init__(self,session):
312                 Screen.__init__(self,session)
313                 self.session = session
314                 self.setTitle(_("Transcoding Setup"))
315
316                 if checkSupportAdvanced():
317                         self.skin = TranscodingSetup.skin_expert
318                 else:
319                         self.skin = TranscodingSetup.skin_normal
320                 if getModel() == "solo2":
321                         TEXT = _("Transcoding and PIP are mutually exclusive.")
322                 else:
323                         TEXT = _("2nd transcoding and PIP are mutually exclusive.")
324                 self["text"] = StaticText(_("%s")%TEXT)
325
326                 self["key_red"] = StaticText(_("Cancel"))
327                 self["key_green"] = StaticText(_("Save"))
328                 self["key_yellow"] = StaticText(_("Default"))
329                 self["key_blue"] = StaticText(_("Advanced"))
330                 self["description"] = StaticText(_("Transcoding Setup"))
331
332                 self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
333                 {
334                         "cancel"        : self.keyCancel,
335                         "red"           : self.keyCancel,
336                         "green"         : self.keySave,
337                         "yellow"        : self.KeyDefault,
338                         "blue"          : self.keyBlue,
339                 }, -2)
340
341                 self.list = []
342                 ConfigListScreen.__init__(self, self.list,session = self.session)
343                 self.setupMode = "Normal" # Normal / Advanced
344                 self.automode = None
345                 self.createSetup()
346                 self.onLayoutFinish.append(self.checkEncoder)
347                 self.invaliedModelTimer = eTimer()
348                 self.invaliedModelTimer.callback.append(self.invalidmodel)
349                 global transcodingsetupinit
350                 transcodingsetupinit.pluginsetup = self
351                 self.onClose.append(self.onClosed)
352
353         def onClosed(self):
354                 transcodingsetupinit.pluginsetup = None
355
356         def checkEncoder(self):
357                 if not fileExists("/proc/stb/encoder/enable"):
358                         self.invaliedModelTimer.start(100,True)
359
360         def invalidmodel(self):
361                 self.session.openWithCallback(self.close, MessageBox, _("This model is not support transcoding."), MessageBox.TYPE_ERROR)
362
363         def createSetup(self):
364                 self.list = []
365                 self.list.append(getConfigListEntry(_("Port"), config.plugins.transcodingsetup.port))
366
367                 if self.automode is None and checkSupportAdvanced() and hasattr(config.plugins.transcodingsetup, "automode"):
368                         self.automode = getConfigListEntry(_("Auto set Framerate / Bitrate"), config.plugins.transcodingsetup.automode)
369
370                 if self.automode is not None:
371                         self.list.append( self.automode )
372
373                 if not ( hasattr(config.plugins.transcodingsetup, "automode") and config.plugins.transcodingsetup.automode.value == "On" ):
374                         if hasattr(config.plugins.transcodingsetup, "bitrate"):
375                                 self.list.append(getConfigListEntry(_("Bitrate"), config.plugins.transcodingsetup.bitrate))
376                         if hasattr(config.plugins.transcodingsetup, "framerate"):
377                                 self.list.append(getConfigListEntry(_("Framerate"), config.plugins.transcodingsetup.framerate))
378
379                 if hasattr(config.plugins.transcodingsetup, "resolution"):
380                                 self.list.append(getConfigListEntry(_("Resolution"), config.plugins.transcodingsetup.resolution))
381
382                 if checkSupportAdvanced() and self.setupMode != "Normal":
383                         if hasattr(config.plugins.transcodingsetup, "aspectratio"):
384                                 self.list.append(getConfigListEntry(_("Aspect Ratio"), config.plugins.transcodingsetup.aspectratio))
385
386                         if hasattr(config.plugins.transcodingsetup, "audiocodec"):
387                                 self.list.append(getConfigListEntry(_("Audio codec"), config.plugins.transcodingsetup.audiocodec))
388
389                         if hasattr(config.plugins.transcodingsetup, "videocodec"):
390                                 self.list.append(getConfigListEntry(_("Video codec"), config.plugins.transcodingsetup.videocodec))
391
392                         if hasattr(config.plugins.transcodingsetup, "gopframeb"):
393                                 self.list.append(getConfigListEntry(_("GOP Frame B"), config.plugins.transcodingsetup.gopframeb))
394
395                         if hasattr(config.plugins.transcodingsetup, "gopframep"):
396                                 self.list.append(getConfigListEntry(_("GOP Frame P"), config.plugins.transcodingsetup.gopframep))
397
398                         if hasattr(config.plugins.transcodingsetup, "level"):
399                                 self.list.append(getConfigListEntry(_("Level"), config.plugins.transcodingsetup.level))
400
401                         if hasattr(config.plugins.transcodingsetup, "profile"):
402                                 self.list.append(getConfigListEntry(_("Profile"), config.plugins.transcodingsetup.profile))
403
404                 self["config"].list = self.list
405                 self["config"].l.setList(self.list)
406                 if not self.showDescription in self["config"].onSelectionChanged:
407                         self["config"].onSelectionChanged.append(self.showDescription)
408
409         def showDescription(self):
410                 configName = "<%s>\n"%self["config"].getCurrent()[0]
411                 current = self["config"].getCurrent()[1]
412                 className = self["config"].getCurrent()[1].__class__.__name__
413                 text = ""
414                 if className == "ConfigSelection":
415                         text = configName
416                         for choice in current.choices.choices:
417                                 if text == configName:  
418                                         text += choice[1]
419                                 else:
420                                         text += ', ' + choice[1]
421                 elif className == "ConfigInteger":
422                         limits = current.limits[0]
423                         text = configName
424                         text += "Max : %d, Min : %d" % (limits[0], limits[1])
425                 self["description"].setText( _(text) )
426
427         def showMessage(self, msg, msgType = MessageBox.TYPE_ERROR):
428                 self.session.open(MessageBox, _(msg), msgType)
429
430         def keySave(self):
431                 self.saveAll()
432                 self.close()
433
434         def KeyDefault(self):
435                 configs = config.plugins.transcodingsetup.dict()
436                 for (configName, configElement) in configs.items():
437                         if configName == "automode":
438                                 continue
439                         configElement.value = configElement.default
440
441                 if "automode" in configs.keys():
442                         configElement = configs["automode"]
443                         configElement.value = configElement.default
444
445                 self.createSetup()
446
447         def keyBlue(self):
448                 if not checkSupportAdvanced():
449                         return
450                 if self.setupMode == "Normal":
451                         self.setupMode = "Advanced"
452                         self["key_blue"].setText( _("Normal") )
453                 else:
454                         self.setupMode = "Normal"
455                         self["key_blue"].setText( _("Advanced") )
456                 self.createSetup()
457
458         def resetConfig(self):
459                 for x in self["config"].list:
460                         x[1].cancel()
461
462         def keyLeft(self):
463                 ConfigListScreen.keyLeft(self)
464                 if self.automode is not None and (self["config"].getCurrent() == self.automode) :
465                         self.createSetup()
466
467         def keyRight(self):
468                 ConfigListScreen.keyRight(self)
469                 if self.automode is not None and (self["config"].getCurrent() == self.automode) :
470                         self.createSetup()
471
472         def cancelConfirm(self, result):
473                 if not result:
474                         return
475
476                 configs = config.plugins.transcodingsetup.dict()
477                 for (key, configElement) in configs.items():
478                         if key == "automode":
479                                 continue
480                         configElement.cancel()
481
482                 if "automode" in configs.keys():
483                         configElement = configs["automode"]
484                         configElement.cancel()
485
486                 self.close()
487
488         def keyCancel(self):
489                 transcodingsetupinit.pluginsetup = None
490                 if self["config"].isChanged():
491                         self.session.openWithCallback(self.cancelConfirm, MessageBox, _("Really close without saving settings?"))
492                 else:
493                         self.close()
494
495 def main(session, **kwargs):
496         session.open(TranscodingSetup)
497
498 def Plugins(**kwargs):
499         return [PluginDescriptor(name=_("TranscodingSetup"), description=_("Transcoding Setup"), where = PluginDescriptor.WHERE_PLUGINMENU, needsRestart = False, fnc=main)]
500
501 transcodingsetupinit = TranscodingSetupInit()
502