+ def setupConfig(self, configElement, configName):
+# print "[TranscodingSetup] set %s to %s" % ( configName, configElement.value )
+ configValue = configElement.value
+ procPath = g_procPath[configName]
+ if self.setConfig(procPath, configValue):
+ # set config failed, reset to current proc value
+ self.getConfigFromProc(procPath, configElement)
+ self.showMessage("Set %s failed." % (configName), MessageBox.TYPE_ERROR)
+
+ def getConfigFromProc(self, procPath, configElement):
+ curValue = getProcValue(procPath)
+ if isinstance(configElement.value, int): # is int ?
+ curValue = int(curValue)
+ configElement.value = curValue
+ configElement.save()
+
+ def setAutomode(self, configElement):
+ configName = "AutoMode"
+# print "[TranscodingSetup] setAutomode, configName %s, value %s" % ( configName, configElement.value )
+ if configElement.value == "On":
+ autoValue = str(-1)
+ if ((hasattr(config.plugins.transcodingsetup, "bitrate") and
+ self.setConfig(g_procPath["bitrate"], autoValue) ) or
+ (hasattr(config.plugins.transcodingsetup, "framerate") and
+ self.setConfig(g_procPath["framerate"], autoValue) ) ):
+ configElement.value = "Off" # set config failed, reset to previous value
+ configElement.save()
+ self.showMessage("Set %s failed." % (configName), MessageBox.TYPE_ERROR)
+ else: # Off
+ if hasattr(config.plugins.transcodingsetup, "bitrate"):
+ self.setBitrate(config.plugins.transcodingsetup.bitrate)
+ if hasattr(config.plugins.transcodingsetup, "framerate"):
+ self.setFramerate(config.plugins.transcodingsetup.framerate)
+
+ def setBitrate(self, configElement):
+ self.setupConfig(configElement, "bitrate")
+
+ def setFramerate(self, configElement):
+ self.setupConfig(configElement, "framerate")
+
+ def setResolution(self, configElement):
+ resolution = configElement.value
+ if resolution in [ "320x240", "160x120" ]:
+ (width, height) = tuple(resolution.split('x'))
+ self.setConfig(g_procPath["resolution"], "custom")
+ self.setConfig(g_procPath["width"], width)
+ self.setConfig(g_procPath["height"], height)
+ else:
+ self.setupConfig(configElement, "resolution")
+
+ def setAspectRatio(self, configElement):
+ self.setupConfig(configElement, "aspectratio")
+
+ def setAudioCodec(self, configElement):
+ self.setupConfig(configElement, "audiocodec")
+
+ def setVideoCodec(self, configElement):
+ self.setupConfig(configElement, "videocodec")
+
+ def setGopFrameB(self, configElement):
+ self.setupConfig(configElement, "gopframeb")
+
+ def setGopFrameP(self, configElement):
+ self.setupConfig(configElement, "gopframep")
+
+ def setLevel(self, configElement):
+ self.setupConfig(configElement, "level")
+
+ def setProfile(self, configElement):
+ self.setupConfig(configElement, "profile")
+