lib/python/Plugins/SystemPlugins/DeviceManager/Makefile
lib/python/Plugins/SystemPlugins/DeviceManager/meta/Makefile
lib/python/Plugins/SystemPlugins/DeviceManager/locale/Makefile
-lib/python/Plugins/SystemPlugins/TransCordingSetup/Makefile
-lib/python/Plugins/SystemPlugins/TransCordingSetup/meta/Makefile
-lib/python/Plugins/SystemPlugins/TransCordingSetup/locale/Makefile
+lib/python/Plugins/SystemPlugins/TransCodingSetup/Makefile
+lib/python/Plugins/SystemPlugins/TransCodingSetup/meta/Makefile
+lib/python/Plugins/SystemPlugins/TransCodingSetup/locale/Makefile
lib/python/Tools/Makefile
lib/service/Makefile
lib/components/Makefile
TempFanControl FactoryTest Fancontrol FPGAUpgrade WirelessLanSetup ManualFancontrol \
Blindscan RemoteControlCode UI3DSetup UIPositionSetup HDMICEC LEDBrightnessSetup \
FirmwareUpgrade CrashReport 3GModemManager WirelessAccessPoint ZappingModeSelection \
- DeviceManager TransCordingSetup
+ DeviceManager TransCodingSetup
install_PYTHON = \
__init__.py
--- /dev/null
+installdir = $(pkglibdir)/python/Plugins/SystemPlugins/TransCodingSetup
+
+SUBDIRS = meta locale
+
+install_PYTHON = \
+ __init__.py \
+ plugin.py
--- /dev/null
+from Components.Language import language
+from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE
+import os,gettext
+
+PluginLanguageDomain = "TransCodingSetup"
+PluginLanguagePath = "SystemPlugins/TransCodingSetup/locale"
+
+def localeInit():
+ lang = language.getLanguage()[:2]
+ os.environ["LANGUAGE"] = lang
+ gettext.bindtextdomain("enigma2", resolveFilename(SCOPE_LANGUAGE))
+ gettext.textdomain("enigma2")
+ gettext.bindtextdomain(PluginLanguageDomain, resolveFilename(SCOPE_PLUGINS, PluginLanguagePath))
+
+def _(txt):
+ t = gettext.dgettext(PluginLanguageDomain, txt)
+ if t == txt:
+ t = gettext.gettext(txt)
+ return t
+
+localeInit()
+language.addCallback(localeInit)
--- /dev/null
+PLUGIN = TransCodingSetup
+LANGS = de
+
+CATEGORY ?= "SystemPlugins"
+
+plugindir = $(libdir)/enigma2/python/Plugins/$(CATEGORY)/$(PLUGIN)
+
+LANGMO = $(LANGS:=.mo)
+LANGPO = $(LANGS:=.po)
+
+.po.mo:
+ $(MSGFMT) -o $@ $<
+
+BUILT_SOURCES = $(LANGMO)
+CLEANFILES = $(LANGMO) $(PLUGIN)-py.pot $(PLUGIN)-xml.pot $(PLUGIN).pot
+
+dist-hook: $(LANGPO)
+
+install-data-local: $(LANGMO)
+ for lang in $(LANGS); do \
+ $(mkinstalldirs) $(DESTDIR)$(plugindir)/locale/$$lang/LC_MESSAGES; \
+ $(INSTALL_DATA) $$lang.mo $(DESTDIR)$(plugindir)/locale/$$lang/LC_MESSAGES/$(PLUGIN).mo; \
+ done
+
+uninstall-local:
+ for lang in $(LANGS); do \
+ $(RM) $(DESTDIR)$(plugindir)/locale/$$lang/LC_MESSAGES/$(PLUGIN).mo; \
+ done
--- /dev/null
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR ORGANIZATION
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: 2012-12-18 09:59+KST\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: ENCODING\n"
+"Generated-By: pygettext.py 1.5\n"
+
+
+#: ../plugin.py:14
+msgid "disabled"
+msgstr ""
+
+#: ../plugin.py:14
+msgid "enabled"
+msgstr ""
+
+#: ../plugin.py:157
+msgid "Cancel"
+msgstr ""
+
+#: ../plugin.py:158
+msgid "Ok"
+msgstr ""
+
+#: ../plugin.py:159
+msgid "%s"
+msgstr ""
+
+#: ../plugin.py:170
+msgid "This Plugin is available on SOLO2/DUO2"
+msgstr ""
+
+#: ../plugin.py:174
+msgid "Transcoding"
+msgstr ""
+
+#: ../plugin.py:175
+msgid "Port"
+msgstr ""
+
+#: ../plugin.py:190
+msgid ""
+"Failed, Encoder %s\n"
+"(%s)."
+msgstr ""
+
+#: ../plugin.py:195
+msgid ""
+"OK. Encoder %s.\n"
+"%s"
+msgstr ""
+
+#: ../plugin.py:197
+msgid "OK. Encoder %s."
+msgstr ""
+
+#: ../plugin.py:224
+msgid "TranscodingSetup"
+msgstr ""
+
--- /dev/null
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR ORGANIZATION
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"POT-Creation-Date: 2012-12-18 09:59+KST\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: ENCODING\n"
+"Generated-By: pygettext.py 1.5\n"
+
+
+#: ../plugin.py:14
+msgid "disabled"
+msgstr ""
+
+#: ../plugin.py:14
+msgid "enabled"
+msgstr ""
+
+#: ../plugin.py:157
+msgid "Cancel"
+msgstr ""
+
+#: ../plugin.py:158
+msgid "Ok"
+msgstr ""
+
+#: ../plugin.py:159
+msgid "%s"
+msgstr ""
+
+#: ../plugin.py:170
+msgid "This Plugin is available on SOLO2/DUO2"
+msgstr ""
+
+#: ../plugin.py:174
+msgid "Transcoding"
+msgstr ""
+
+#: ../plugin.py:175
+msgid "Port"
+msgstr ""
+
+#: ../plugin.py:190
+msgid ""
+"Failed, Encoder %s\n"
+"(%s)."
+msgstr ""
+
+#: ../plugin.py:195
+msgid ""
+"OK. Encoder %s.\n"
+"%s"
+msgstr ""
+
+#: ../plugin.py:197
+msgid "OK. Encoder %s."
+msgstr ""
+
+#: ../plugin.py:224
+msgid "TranscodingSetup"
+msgstr ""
+
--- /dev/null
+installdir = $(datadir)/meta
+
+dist_install_DATA = plugin_transcodingsetup.xml
--- /dev/null
+<default>
+ <prerequisites>
+ <tag type="System" />
+ </prerequisites>
+ <info>
+ <author>hschang</author>
+ <name>TranscodingSetup</name>
+ <packagename>enigma2-plugin-systemplugins-transcodingsetup</packagename>
+ <shortdescription>Setup transcoding of your VU+</shortdescription>
+ <description>Setup transcoding of your VU+</description>
+ </info>
+
+ <files type="package"> <!-- without version, without .ipk -->
+ <file type="package" name="enigma2-plugin-systemplugins-transcodingsetup" />
+ </files>
+</default>
--- /dev/null
+from Screens.Screen import Screen
+from Components.ConfigList import ConfigListScreen
+from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSelection
+from Components.ActionMap import ActionMap
+from Screens.MessageBox import MessageBox
+from Components.Sources.StaticText import StaticText
+from Plugins.Plugin import PluginDescriptor
+from Tools.Directories import fileExists
+from enigma import eTimer
+from os import system as os_system
+from __init__ import _
+
+config.plugins.transcodingsetup = ConfigSubsection()
+config.plugins.transcodingsetup.transcoding = ConfigSelection(default = "disabled", choices = [ ("enabled", _("enabled")), ("disabled", _("disabled"))] )
+config.plugins.transcodingsetup.port = ConfigSelection(default = "8002", choices = [ ("8001", "8001"), ("8002", "8002")] )
+
+error_msg ={
+ -1 : "File not exist - /proc/stb/encoder/enable.",
+ -2 : "File not exist - /etc/inetd.conf.",
+ -3 : "File open error - /proc/stb/encoder/enable.",
+ -4 : "File open error - /etc/inetd.conf.",
+ -5 : "Set encoder error.",
+ -6 : "Set port error.",
+ -7 : "Setting value is incorrect."
+}
+class TranscodingSetupInit:
+ def __init__(self):
+ self.transcoding_value = config.plugins.transcodingsetup.transcoding.value
+ if self.transcoding_value == "disabled":
+ self.port_value = "8002"
+ else:
+ self.port_value = config.plugins.transcodingsetup.port.value
+ self.transcoding_old = config.plugins.transcodingsetup.transcoding.value
+ ret = self.setTranscoding(self.transcoding_value, self.port_value)
+ if ret is not None and ret < 0:
+ print "[TranscodingSetup] set failed!(%s, %s)"%(self.transcoding_value, self.port_value)
+
+ def setTranscoding(self, transcoding, port):
+ if not self.getModel():
+ print "This plugin is only supported for solo2/duo2."
+ return -8
+ if transcoding not in ["enabled","disabled"] or port not in ["8001","8002"]:
+ print "Input error."
+ return -7
+ if not fileExists("/proc/stb/encoder/enable"):
+ return -1
+ elif not fileExists("/etc/inetd.conf"):
+ return -2
+ if self.setEncoder(transcoding) < 0:
+ return -5
+ res = self.setPort(port)
+ if res < 0:
+ self.setEncoder(self.transcoding_old)
+ return res
+ else:
+ self.inetdRestart()
+ return res
+
+ def setEncoder(self,mode = "disabled"):
+ print "<TranscodingSetup> set encoder : %s" % mode
+ mode = mode.strip(' ').strip('\n')
+ try:
+ fd = open("/proc/stb/encoder/enable",'r')
+ self.transcoding_old = fd.read()
+ fd.close()
+ fd = open("/proc/stb/encoder/enable",'w')
+ fd.write(mode)
+ fd.close()
+ fd = open("/proc/stb/encoder/enable",'r')
+ encoder_enable = fd.read().strip(' ').strip('\n')
+ fd.close()
+ if encoder_enable == mode:
+ return 0
+ else:
+# print "<TranscodingSetup> can not setting."
+ return -1
+ except:
+# print "setEncoder exception error"
+ return -1
+
+ def setPort(self, port = "8001"):
+ print "<TranscodingSetup> set port : %s" % port
+ try:
+ fp = file('/etc/inetd.conf', 'r')
+ datas = fp.readlines()
+ fp.close()
+ except:
+# print "file open error, inetd.conf!"
+ return -4
+ try:
+ newdatas=""
+ s_port = ""
+ if port == "8001":
+ s_port = "8002"
+ else:
+ s_port = "8001"
+ for line in datas:
+ if line.find("transtreamproxy") != -1:
+ p=line.replace('\t',' ').find(' ')
+ line = port+line[p:]
+ elif line.find("streamproxy") != -1:
+ p=line.replace('\t',' ').find(' ')
+ line = s_port+line[p:]
+ newdatas+=line
+
+ if newdatas.find("transtreamproxy") == -1:
+ newdatas+=port+'\t'+'stream'+'\t'+'tcp'+'\t'+'nowait'+'\t'+'root'+'\t'+'/usr/bin/transtreamproxy'+'\t'+'transtreamproxy\n'
+ fd = file("/etc/inetd.conf",'w')
+ fd.write(newdatas)
+ fd.close()
+ except:
+ return -6
+ return 0
+
+ def inetdRestart(self):
+ if fileExists("/etc/init.d/inetd"):
+ os_system("/etc/init.d/inetd restart")
+
+ def getModel(self):
+ if fileExists("/proc/stb/info/vumodel"):
+ vumodel = open("/proc/stb/info/vumodel")
+ info=vumodel.read().strip()
+ vumodel.close()
+ if info in ["solo2", "duo2"]:
+ return True
+ else:
+ return False
+ else:
+ return False
+
+class TranscodingSetup(Screen,ConfigListScreen, TranscodingSetupInit):
+ skin = """
+ <screen position="center,center" size="560,270" title="Transcoding Setup" >
+ <ePixmap pixmap="skin_default/buttons/red.png" position="110,10" size="140,40" alphatest="on" />
+ <ePixmap pixmap="skin_default/buttons/green.png" position="310,10" size="140,40" alphatest="on" />
+ <widget source="key_red" render="Label" position="110,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" foregroundColor="#ffffff" transparent="1" />
+ <widget source="key_green" render="Label" position="310,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" foregroundColor="#ffffff" transparent="1" />
+ <widget name="config" zPosition="2" position="5,70" size="550,70" scrollbarMode="showOnDemand" transparent="1" />
+ <widget source="text" render="Label" position="20,140" size="520,130" font="Regular;18" halign="center" valign="center" />
+ </screen>
+ """
+
+ def __init__(self,session):
+ Screen.__init__(self,session)
+ self.session = session
+ self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
+ {
+ "ok": self.keySave,
+ "cancel": self.keyCancel,
+ "red": self.keyCancel,
+ "green": self.keySave,
+ }, -2)
+ self.list = []
+ ConfigListScreen.__init__(self, self.list,session = self.session)
+ TEXT = "Transcoding can be started when there is no corresponding channel recordings."
+ TEXT += "\nWhen transcoding, both PIP and analog video outputs are disabled."
+ self["key_red"] = StaticText(_("Cancel"))
+ self["key_green"] = StaticText(_("Ok"))
+ self["text"] = StaticText(_("%s")%TEXT)
+ self.createSetup()
+ self.onLayoutFinish.append(self.checkModel)
+ self.checkModelTimer = eTimer()
+ self.checkModelTimer.callback.append(self.invalidmodel)
+
+ def checkModel(self):
+ if not self.getModel():
+ self.checkModelTimer.start(1000,True)
+
+ def invalidmodel(self):
+ self.session.openWithCallback(self.close, MessageBox, _("This plugin is available on SOLO2/DUO2"), MessageBox.TYPE_ERROR)
+
+ def createSetup(self):
+ self.list = []
+ self.transcoding = getConfigListEntry(_("Transcoding"), config.plugins.transcodingsetup.transcoding)
+ self.port = getConfigListEntry(_("Port"), config.plugins.transcodingsetup.port)
+ self.list.append( self.transcoding )
+ if config.plugins.transcodingsetup.transcoding.value == "enabled":
+ self.list.append( self.port )
+ self["config"].list = self.list
+ self["config"].l.setList(self.list)
+
+ def keySave(self):
+ transcoding = config.plugins.transcodingsetup.transcoding.value
+ port = config.plugins.transcodingsetup.port.value
+ print "<TranscodingSetup> Transcoding %s(port : %s)"%(transcoding, port)
+ ret = self.setupTranscoding(transcoding, port)
+ if ret is not None and ret <0 :
+ self.resetConfig()
+ global error_msg
+ self.session.openWithCallback(self.close, MessageBox, _("Failed, Encoder %s\n(%s).")%(transcoding, error_msg[ret]), MessageBox.TYPE_ERROR)
+ else:
+ self.saveAll()
+ if transcoding == "enabled" and port == "8001" :
+ text = "PC Streaming is replaced with mobile streaming."
+ self.session.openWithCallback(self.close, MessageBox, _("OK. Encoder %s.\n%s")%(transcoding,text), MessageBox.TYPE_INFO)
+ else:
+ self.session.openWithCallback(self.close, MessageBox, _("OK. Encoder %s.")%transcoding, MessageBox.TYPE_INFO)
+ self.close()
+
+ def resetConfig(self):
+ for x in self["config"].list:
+ x[1].cancel()
+
+ def setupTranscoding(self, transcoding = None, port = None):
+ if transcoding == "disabled":
+ config.plugins.transcodingsetup.port.value = "8002"
+ port = "8002"
+ return self.setTranscoding(transcoding, port)
+
+ def keyLeft(self):
+ ConfigListScreen.keyLeft(self)
+ if self["config"].getCurrent() == self.transcoding:
+ self.createSetup()
+
+ def keyRight(self):
+ ConfigListScreen.keyRight(self)
+ if self["config"].getCurrent() == self.transcoding:
+ self.createSetup()
+
+def main(session, **kwargs):
+ session.open(TranscodingSetup)
+
+def Plugins(**kwargs):
+ return [PluginDescriptor(name=_("TranscodingSetup"), description="Transcoding Setup", where = PluginDescriptor.WHERE_PLUGINMENU, needsRestart = False, fnc=main)]
+
+transcodingsetupinit = TranscodingSetupInit()
+
+++ /dev/null
-installdir = $(pkglibdir)/python/Plugins/SystemPlugins/TransCordingSetup
-
-SUBDIRS = meta locale
-
-install_PYTHON = \
- __init__.py \
- plugin.py
+++ /dev/null
-from Components.Language import language
-from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE
-import os,gettext
-
-PluginLanguageDomain = "TransCordingSetup"
-PluginLanguagePath = "SystemPlugins/TransCordingSetup/locale"
-
-def localeInit():
- lang = language.getLanguage()[:2]
- os.environ["LANGUAGE"] = lang
- gettext.bindtextdomain("enigma2", resolveFilename(SCOPE_LANGUAGE))
- gettext.textdomain("enigma2")
- gettext.bindtextdomain(PluginLanguageDomain, resolveFilename(SCOPE_PLUGINS, PluginLanguagePath))
-
-def _(txt):
- t = gettext.dgettext(PluginLanguageDomain, txt)
- if t == txt:
- t = gettext.gettext(txt)
- return t
-
-localeInit()
-language.addCallback(localeInit)
+++ /dev/null
-PLUGIN = TransCordingSetup
-LANGS = de
-
-CATEGORY ?= "SystemPlugins"
-
-plugindir = $(libdir)/enigma2/python/Plugins/$(CATEGORY)/$(PLUGIN)
-
-LANGMO = $(LANGS:=.mo)
-LANGPO = $(LANGS:=.po)
-
-.po.mo:
- $(MSGFMT) -o $@ $<
-
-BUILT_SOURCES = $(LANGMO)
-CLEANFILES = $(LANGMO) $(PLUGIN)-py.pot $(PLUGIN)-xml.pot $(PLUGIN).pot
-
-dist-hook: $(LANGPO)
-
-install-data-local: $(LANGMO)
- for lang in $(LANGS); do \
- $(mkinstalldirs) $(DESTDIR)$(plugindir)/locale/$$lang/LC_MESSAGES; \
- $(INSTALL_DATA) $$lang.mo $(DESTDIR)$(plugindir)/locale/$$lang/LC_MESSAGES/$(PLUGIN).mo; \
- done
-
-uninstall-local:
- for lang in $(LANGS); do \
- $(RM) $(DESTDIR)$(plugindir)/locale/$$lang/LC_MESSAGES/$(PLUGIN).mo; \
- done
+++ /dev/null
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR ORGANIZATION
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2012-12-17 18:07+KST\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: pygettext.py 1.5\n"
-
-
-#: ../plugin.py:11
-msgid "disabled"
-msgstr ""
-
-#: ../plugin.py:11
-msgid "enabled"
-msgstr ""
-
-#: ../plugin.py:129
-msgid "Cancel"
-msgstr ""
-
-#: ../plugin.py:130
-msgid "Ok"
-msgstr ""
-
-#: ../plugin.py:131
-msgid "%s"
-msgstr ""
-
-#: ../plugin.py:136
-msgid "Transcording"
-msgstr ""
-
-#: ../plugin.py:137
-msgid "Port"
-msgstr ""
-
-#: ../plugin.py:149
-msgid ""
-"SET FAILED.\n"
-"(%s)."
-msgstr ""
-
-#: ../plugin.py:152
-msgid "SET SUCCESSED."
-msgstr ""
-
-#: ../plugin.py:166
-msgid "TranscordingSetup"
-msgstr ""
-
+++ /dev/null
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR ORGANIZATION
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2012-12-17 18:07+KST\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: pygettext.py 1.5\n"
-
-
-#: ../plugin.py:11
-msgid "disabled"
-msgstr ""
-
-#: ../plugin.py:11
-msgid "enabled"
-msgstr ""
-
-#: ../plugin.py:129
-msgid "Cancel"
-msgstr ""
-
-#: ../plugin.py:130
-msgid "Ok"
-msgstr ""
-
-#: ../plugin.py:131
-msgid "%s"
-msgstr ""
-
-#: ../plugin.py:136
-msgid "Transcording"
-msgstr ""
-
-#: ../plugin.py:137
-msgid "Port"
-msgstr ""
-
-#: ../plugin.py:149
-msgid ""
-"SET FAILED.\n"
-"(%s)."
-msgstr ""
-
-#: ../plugin.py:152
-msgid "SET SUCCESSED."
-msgstr ""
-
-#: ../plugin.py:166
-msgid "TranscordingSetup"
-msgstr ""
-
+++ /dev/null
-installdir = $(datadir)/meta
-
-dist_install_DATA = plugin_transcordingsetup.xml
+++ /dev/null
-<default>
- <prerequisites>
- <tag type="System" />
- </prerequisites>
- <info>
- <author>hschang</author>
- <name>TranscordingSetup</name>
- <packagename>enigma2-plugin-systemplugins-transcordingsetup</packagename>
- <shortdescription>Setup transcording of your VU+</shortdescription>
- <description>Setup transcording of your VU+</description>
- </info>
-
- <files type="package"> <!-- without version, without .ipk -->
- <file type="package" name="enigma2-plugin-systemplugins-transcordingsetup" />
- </files>
-</default>
+++ /dev/null
-from Screens.Screen import Screen
-from Components.ConfigList import ConfigListScreen
-from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSelection
-from Components.ActionMap import ActionMap
-from Screens.MessageBox import MessageBox
-from Components.Sources.StaticText import StaticText
-from Plugins.Plugin import PluginDescriptor
-from Tools.Directories import fileExists
-from enigma import eTimer
-from os import system as os_system
-from __init__ import _
-
-config.plugins.transcordingsetup = ConfigSubsection()
-config.plugins.transcordingsetup.transcording = ConfigSelection(default = "disabled", choices = [ ("enabled", _("enabled")), ("disabled", _("disabled"))] )
-config.plugins.transcordingsetup.port = ConfigSelection(default = "8002", choices = [ ("8001", "8001"), ("8002", "8002")] )
-
-error_msg ={
- -1 : "File not exist - /proc/stb/encoder/enable.",
- -2 : "File not exist - /etc/inetd.conf.",
- -3 : "File open error - /proc/stb/encoder/enable.",
- -4 : "File open error - /etc/inetd.conf.",
- -5 : "Set encoder error.",
- -6 : "Set port error.",
- -7 : "Setting value is incorrect."
-}
-class TranscordingSetupInit:
- def __init__(self):
- self.transcording_value = config.plugins.transcordingsetup.transcording.value
- if self.transcording_value == "disabled":
- self.port_value = "8002"
- else:
- self.port_value = config.plugins.transcordingsetup.port.value
- self.transcording_old = config.plugins.transcordingsetup.transcording.value
- ret = self.setTranscording(self.transcording_value, self.port_value)
- if ret is not None and ret < 0:
- print "[TranscordingSetup] setup failed!(%s, %s)"%(self.transcording_value, self.port_value)
-
- def setTranscording(self, transcording, port):
- if not self.getModel():
- print "This plugin is only supported for solo2/duo2."
- return -8
- if transcording not in ["enabled","disabled"] or port not in ["8001","8002"]:
- print "Input arg error.."
- return -7
- if not fileExists("/proc/stb/encoder/enable"):
- return -1
- elif not fileExists("/etc/inetd.conf"):
- return -2
- if self.setEncoder(transcording) < 0:
- return -5
- res = self.setPort(port)
- if res < 0:
- self.setEncoder(self.transcording_old)
- return res
- else:
- self.inetdRestart()
- return res
-
- def setEncoder(self,mode = "disabled"):
- print "<TranscordingSetup> set encoder : %s" % mode
- mode = mode.strip(' ').strip('\n')
- try:
- fd = open("/proc/stb/encoder/enable",'r')
- self.transcording_old = fd.read()
- fd.close()
- fd = open("/proc/stb/encoder/enable",'w')
- fd.write(mode)
- fd.close()
- print "-->",mode
- fd = open("/proc/stb/encoder/enable",'r')
- encoder_enable = fd.read().strip(' ').strip('\n')
- fd.close()
- print "<--",encoder_enable
- if encoder_enable == mode:
- return 0
- else:
- print "can not setting.."
- return -1
- except:
- print "setEncoder exception error"
- return -1
-
- def setPort(self, port = "8001"):
- print "<TranscordingSetup> set port : %s" % port
- try:
- fp = file('/etc/inetd.conf', 'r')
- datas = fp.readlines()
- fp.close()
- except:
- print "file open error, inetd.conf!"
- return -4
- try:
- newdatas=""
- s_port = ""
- if port == "8001":
- s_port = "8002"
- else:
- s_port = "8001"
- for line in datas:
- if line.find("transtreamproxy") != -1:
- p=line.replace('\t',' ').find(' ')
- line = port+line[p:]
- elif line.find("streamproxy") != -1:
- p=line.replace('\t',' ').find(' ')
- line = s_port+line[p:]
- newdatas+=line
-
- if newdatas.find("transtreamproxy") == -1:
- newdatas+=port+'\t'+'stream'+'\t'+'tcp'+'\t'+'nowait'+'\t'+'root'+'\t'+'/usr/bin/transtreamproxy'+'\t'+'transtreamproxy\n'
- fd = file("/etc/inetd.conf",'w')
- fd.write(newdatas)
- fd.close()
- except:
- return -6
- return 0
-
- def inetdRestart(self):
- if fileExists("/etc/init.d/inetd"):
- os_system("/etc/init.d/inetd restart")
-
- def getModel(self):
- if fileExists("/proc/stb/info/vumodel"):
- vumodel = open("/proc/stb/info/vumodel")
- info=vumodel.read().strip()
- vumodel.close()
- if info in ["solo2", "duo2"]:
- return True
- else:
- return False
- else:
- return False
-
-class TranscordingSetup(Screen,ConfigListScreen, TranscordingSetupInit):
- skin = """
- <screen position="center,center" size="560,270" title="Transcording Setup" >
- <ePixmap pixmap="skin_default/buttons/red.png" position="110,10" size="140,40" alphatest="on" />
- <ePixmap pixmap="skin_default/buttons/green.png" position="310,10" size="140,40" alphatest="on" />
- <widget source="key_red" render="Label" position="110,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" foregroundColor="#ffffff" transparent="1" />
- <widget source="key_green" render="Label" position="310,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" foregroundColor="#ffffff" transparent="1" />
- <widget name="config" zPosition="2" position="5,70" size="550,70" scrollbarMode="showOnDemand" transparent="1" />
- <widget source="text" render="Label" position="20,140" size="520,130" font="Regular;18" halign="center" valign="center" />
- </screen>
- """
-
- def __init__(self,session):
- Screen.__init__(self,session)
- self.session = session
- self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
- {
- "ok": self.keySave,
- "cancel": self.keyCancel,
- "red": self.keyCancel,
- "green": self.keySave,
- }, -2)
- self.list = []
- ConfigListScreen.__init__(self, self.list,session = self.session)
- TEXT = "Tanscoding can be started when there is no corresponding channel recordings."
- TEXT += "\nWhen transcoding, both PIP and analog video outputs are disabled."
- self["key_red"] = StaticText(_("Cancel"))
- self["key_green"] = StaticText(_("Ok"))
- self["text"] = StaticText(_("%s")%TEXT)
- self.createSetup()
- self.onLayoutFinish.append(self.checkModel)
- self.checkModelTimer = eTimer()
- self.checkModelTimer.callback.append(self.invalidmodel)
-
- def checkModel(self):
- if not self.getModel():
- self.checkModelTimer.start(1000,True)
-
- def invalidmodel(self):
- self.session.openWithCallback(self.close, MessageBox, _("This Plugin is available on SOLO2/DUO2"), MessageBox.TYPE_ERROR)
-
- def createSetup(self):
- self.list = []
- self.transcording = getConfigListEntry(_("Transcording"), config.plugins.transcordingsetup.transcording)
- self.port = getConfigListEntry(_("Port"), config.plugins.transcordingsetup.port)
- self.list.append( self.transcording )
- if config.plugins.transcordingsetup.transcording.value == "enabled":
- self.list.append( self.port )
- self["config"].list = self.list
- self["config"].l.setList(self.list)
-
- def keySave(self):
- transcording = config.plugins.transcordingsetup.transcording.value
- port = config.plugins.transcordingsetup.port.value
- print "<ZappingModeSelection> Transcording %s(port : %s)"%(transcording, port)
- ret = self.setupTranscording(transcording, port)
- if ret is not None and ret <0 :
- self.resetConfig()
- global error_msg
- self.session.openWithCallback(self.close, MessageBox, _("Failed, Encoder %s\n(%s).")%(transcording, error_msg[ret]), MessageBox.TYPE_ERROR)
- else:
- self.saveAll()
- if transcording == "enabled" and port == "8001" :
- text = "PC Streaming is replaced with mobile streaming."
- self.session.openWithCallback(self.close, MessageBox, _("OK. Encoder %s.\n%s")%(transcording,text), MessageBox.TYPE_INFO)
- else:
- self.session.openWithCallback(self.close, MessageBox, _("OK. Encoder %s.")%transcording, MessageBox.TYPE_INFO)
- self.close()
-
- def resetConfig(self):
- for x in self["config"].list:
- x[1].cancel()
-
- def setupTranscording(self, transcording = None, port = None):
- if transcording == "disabled":
- config.plugins.transcordingsetup.port.value = "8002"
- port = "8002"
- return self.setTranscording(transcording, port)
-
- def keyLeft(self):
- ConfigListScreen.keyLeft(self)
- if self["config"].getCurrent() == self.transcording:
- self.createSetup()
-
- def keyRight(self):
- ConfigListScreen.keyRight(self)
- if self["config"].getCurrent() == self.transcording:
- self.createSetup()
-
-def main(session, **kwargs):
- session.open(TranscordingSetup)
-
-def Plugins(**kwargs):
- return [PluginDescriptor(name=_("TranscordingSetup"), description="Transcording Setup", where = PluginDescriptor.WHERE_PLUGINMENU, needsRestart = False, fnc=main)]
-
-transcordingsetupinit = TranscordingSetupInit()
-