added autoresolution plugin to the repository
authorFrank Nehls <domino@users.schwerkraft.elitedvb.net>
Sun, 28 Sep 2008 08:33:45 +0000 (08:33 +0000)
committerFrank Nehls <domino@users.schwerkraft.elitedvb.net>
Sun, 28 Sep 2008 08:33:45 +0000 (08:33 +0000)
Makefile.am
autoresolution/CONTROL/control [new file with mode: 0644]
autoresolution/Makefile.am [new file with mode: 0644]
autoresolution/src/Makefile.am [new file with mode: 0644]
autoresolution/src/__init__.py [new file with mode: 0644]
autoresolution/src/plugin.py [new file with mode: 0644]
configure.ac

index 46b8dac..5626dc6 100644 (file)
@@ -1,2 +1,2 @@
 AUTOMAKE_OPTIONS = gnu
-SUBDIRS = antiscrollbar movietagger webinterface wirelesslan netcaster lastfm logomanager vlcplayer simplerss trafficinfo fritzcall webcamviewer emailclient autotimer epgrefresh werbezapper httpproxy startuptostandby imdb ofdb networkwizard movieretitle moviecut tageditor cdinfo unwetterzentrale youtubeplayer zaphistorybrowser passwordchanger
+SUBDIRS = antiscrollbar movietagger webinterface wirelesslan netcaster lastfm logomanager vlcplayer simplerss trafficinfo fritzcall webcamviewer emailclient autotimer epgrefresh werbezapper httpproxy startuptostandby imdb ofdb networkwizard movieretitle moviecut tageditor cdinfo unwetterzentrale youtubeplayer zaphistorybrowser passwordchanger autoresolution
diff --git a/autoresolution/CONTROL/control b/autoresolution/CONTROL/control
new file mode 100644 (file)
index 0000000..e72d5aa
--- /dev/null
@@ -0,0 +1,10 @@
+Package: enigma2-plugin-systemplugins-autoresolution
+Version: 0.8-20080928-r0
+Description: Automatically change resolution 
+Architecture: mipsel
+Section: extra
+Priority: optional
+Maintainer: domino <dom.nehls@web.de>
+Homepage: n/a
+Depends: enigma2(>=2.5cvs20080928)
+Source: http://schwerkraft.elitedvb.net/scm/?group_id=11
diff --git a/autoresolution/Makefile.am b/autoresolution/Makefile.am
new file mode 100644 (file)
index 0000000..af437a6
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS = src
diff --git a/autoresolution/src/Makefile.am b/autoresolution/src/Makefile.am
new file mode 100644 (file)
index 0000000..415e54b
--- /dev/null
@@ -0,0 +1,2 @@
+installdir = /usr/lib/enigma2/python/Plugins/SystemPlugins/AutoResolution
+install_PYTHON = *.py
diff --git a/autoresolution/src/__init__.py b/autoresolution/src/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/autoresolution/src/plugin.py b/autoresolution/src/plugin.py
new file mode 100644 (file)
index 0000000..f8b25a0
--- /dev/null
@@ -0,0 +1,230 @@
+from Screens.Screen import Screen
+from Screens.Setup import SetupSummary
+from Components.ConfigList import ConfigList, ConfigListScreen
+from Components.config import config, getConfigListEntry, ConfigSelection, ConfigSubsection, ConfigYesNo
+from Components.ServiceEventTracker import ServiceEventTracker
+from Components.ActionMap import ActionMap
+from Components.Label import Label
+from Components.Pixmap import Pixmap
+from enigma import iPlayableService, iServiceInformation, eTimer
+from ServiceReference import ServiceReference
+from Plugins.Plugin import PluginDescriptor
+import string
+# depends on Videomode Plugin
+from Plugins.SystemPlugins.Videomode.VideoHardware import video_hw
+
+session = [ ]
+
+preferedmodes = [mode[0] for mode in video_hw.getModeList(config.av.videoport.value)]
+default = config.av.videomode[config.av.videoport.value].value
+config.plugins.autoresolution = ConfigSubsection()
+config.plugins.autoresolution.enable = ConfigYesNo(default = False)
+config.plugins.autoresolution.i1080 = ConfigSelection(default = default, choices = preferedmodes)
+#config.plugins.autoresolution.p1080 = ConfigSelection(default = default, choices = preferedmodes)
+config.plugins.autoresolution.i576 = ConfigSelection(default = default, choices = preferedmodes)
+config.plugins.autoresolution.p576 = ConfigSelection(default = default, choices = preferedmodes)
+#config.plugins.autoresolution.i720 = ConfigSelection(default = default, choices = preferedmodes)
+config.plugins.autoresolution.p720 = ConfigSelection(default = default, choices = preferedmodes)
+config.plugins.autoresolution.i480 = ConfigSelection(default = default, choices = preferedmodes)
+config.plugins.autoresolution.p480 = ConfigSelection(default = default, choices = preferedmodes)
+config.plugins.autoresolution.showinfo = ConfigYesNo(default = True)
+config.plugins.autoresolution.testmode = ConfigYesNo(default = False)
+
+def build_switchdic():
+       dic = { '1080i': config.plugins.autoresolution.i1080.value, \
+#              '1080p': config.plugins.autoresolution.p1080.value, \
+               '576i':config.plugins.autoresolution.i576.value, \
+               '576p':config.plugins.autoresolution.p576.value, \
+               '480i':config.plugins.autoresolution.i480.value, \
+               '480p':config.plugins.autoresolution.p480.value, \
+#              '720i':config.plugins.autoresolution.i720.value, \
+               '720p':config.plugins.autoresolution.p720.value}
+       return dic
+switchdic = build_switchdic()
+
+
+class AutoResSetupMenu(Screen, ConfigListScreen):
+       def __init__(self, session):
+               Screen.__init__(self, session)
+               self.skinName = "Setup"
+               self.setup_title = "Autoresolution Videomode Setup"
+
+               self.onChangedEntry = [ ]
+               self.list = [ ]
+               ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changedEntry)
+
+               self["actions"] = ActionMap(["SetupActions"], 
+                       {
+                               "cancel": self.keyCancel,
+                               "save": self.apply,
+                       }, -2)
+
+               self["title"] = Label(_("Autoresolution Settings"))
+
+               self["oktext"] = Label(_("OK"))
+               self["canceltext"] = Label(_("Cancel"))
+
+               self["ok"] = Pixmap()
+               self["cancel"] = Pixmap()
+               
+               self.createSetup()
+               
+       def createSetup(self):
+               self.list = []
+               self.list.append(getConfigListEntry(_("Enable Autoresolution"), config.plugins.autoresolution.enable))
+               if config.plugins.autoresolution.enable.value:
+                       self.list.append(getConfigListEntry(_("%s Content" % "1080i"), config.plugins.autoresolution.i1080))
+#                      self.list.append(getConfigListEntry(_("%s Content" % "1080p"), config.plugins.autoresolution.p1080))
+#                      self.list.append(getConfigListEntry(_("%s Content" % "720i"), config.plugins.autoresolution.i720))
+                       self.list.append(getConfigListEntry(_("%s Content" % "720p"), config.plugins.autoresolution.p720))
+                       self.list.append(getConfigListEntry(_("%s Content" % "576i"), config.plugins.autoresolution.i576))
+                       self.list.append(getConfigListEntry(_("%s Content" % "576p"), config.plugins.autoresolution.p576))
+                       self.list.append(getConfigListEntry(_("%s Content" % "480p"), config.plugins.autoresolution.p480))
+                       self.list.append(getConfigListEntry(_("%s Content" % "480i"), config.plugins.autoresolution.i480))
+                       self.list.append(getConfigListEntry(_("Show Info Screen"), config.plugins.autoresolution.showinfo))
+                       self.list.append(getConfigListEntry(_("Running in Testmode"), config.plugins.autoresolution.testmode))
+               self["config"].list = self.list
+               self["config"].setList(self.list)
+       
+       def apply(self):
+               for x in self["config"].list:
+                       x[1].save()
+                       global switchdic
+                       switchdic = build_switchdic()
+               self.close()
+       
+       def keyLeft(self):
+               ConfigListScreen.keyLeft(self)
+               self.createSetup()
+
+       def keyRight(self):
+               ConfigListScreen.keyRight(self)
+               self.createSetup()
+       
+       # for summary:
+       def changedEntry(self):
+               for x in self.onChangedEntry:
+                       x()
+
+       def getCurrentEntry(self):
+               return self["config"].getCurrent()[0]
+
+       def getCurrentValue(self):
+               return str(self["config"].getCurrent()[1].getText())
+
+       def createSummary(self):
+               return SetupSummary
+       
+
+class AutoRes(Screen):
+       def __init__(self, session):
+               Screen.__init__(self, session)
+               self.__event_tracker = ServiceEventTracker(screen = self, eventmap =
+                       {
+                               iPlayableService.evVideoSizeChanged: self.__evVideoSizeChanged,
+                               iPlayableService.evVideoProgressiveChanged: self.__evVideoProgressiveChanged,
+                       })
+               
+               self.height, self.progressive = '','i'
+               
+       def __evVideoSizeChanged(self):
+               print "[AutoRes Debug] got event evVideoSizeChanged"
+               if config.plugins.autoresolution.enable.value:
+                       service = self.session.nav.getCurrentService()
+                       info = service and service.info()
+                       height = info and info.getInfo(iServiceInformation.sVideoHeight)
+                       print "[AutoRes Debug] VideoSize height = %s" % self.height
+                       if height != self.height:
+                               self.height = height
+                               self.changeVideomode()
+       
+       def __evVideoProgressiveChanged(self):
+               print "[AutoRes Debug] got event evVideoProgressiveChanged"
+               prog = 'i'
+               if config.plugins.autoresolution.enable.value:
+                       service = self.session.nav.getCurrentService()
+                       info = service and service.info()
+                       progressive = info and info.getInfo(iServiceInformation.sProgressive)
+                       print "[AutoRes Debug] progressive (%d)" % progressive
+                       if progressive == 1:
+                               prog = 'p'
+                       if prog != self.progressive:
+                               self.progressive = prog
+                               self.changeVideomode()
+                                              
+       def changeVideomode(self):
+               print "[AutoRes Debug] Resolution or content_is has changed"
+               content_mode = "%s%s" %(self.height, self.progressive)
+               print "[AutoRes Debug] New content mode is %s" % content_mode
+               if switchdic.has_key(content_mode):
+                       print "[AutoRes Debug] content_mode is in switchdic"
+                       if switchdic[content_mode] in preferedmodes:
+                               print "[AutoRes Debug] Resolution is in switchdic and in preferedmodes"
+                               port = config.av.videoport.value
+                               print "[AutoRes Debug] port=%s" % port
+                               mode = switchdic[content_mode]
+                               print "[AutoRes Debug] mode=%s" % mode
+                               rate = config.av.videorate[mode].value
+                               print "[AutoRes Debug] switching to %s %s %s" % (port, mode, rate)
+                               if config.plugins.autoresolution.showinfo.value:
+                                       resolutionlabel["restxt"].setText("%s %s %s" % (port, mode, rate))
+                                       resolutionlabel.show()
+               
+                               video_hw.setMode(port, mode, rate)
+                                               
+                               if config.plugins.autoresolution.testmode.value:
+                                       from Screens.MessageBox import MessageBox
+                                       self.session.openWithCallback(
+                                                       self.confirm, MessageBox, _("Autoresolution Plugin Testmode:\nIs %s %s %s videomode ok?" % ((port, mode, rate))), MessageBox.TYPE_YESNO, timeout = 15, default = False)
+                       else:
+                               print '[AutoRes Debug] TV dont support %s' % switchdic[self.height]
+
+       def confirm(self, confirmed):
+               if not confirmed:
+                       port = config.av.videoport.value
+                       mode = config.av.videomode[port].value
+                       rate = config.av.videorate[mode].value
+                       if config.plugins.autoresolution.showinfo.value:
+                               resolutionlabel["restxt"].setText("%s %s %s" % (port, mode, rate))
+                               resolutionlabel.show()
+                       video_hw.setMode(port, mode, rate)
+
+
+class ResolutionLabel(Screen):
+       skin = """
+               <screen position="50,30" size="140,20" flags="wfNoBorder" >
+                       <widget name="restxt" position="0,0" size="140,20" font="Regular;18" />
+               </screen>"""
+       def __init__(self, session):
+               Screen.__init__(self, session)
+               
+               from Components.Label import Label
+               self["restxt"] = Label()
+               
+               self.hideTimer = eTimer()
+               self.hideTimer.callback.append(self.hide)
+               
+               self.onShow.append(self.hide_me)
+       
+       def hide_me(self):
+               self.hideTimer.start(config.usage.infobar_timeout.index * 1000, True)
+
+       
+def autostart(reason, **kwargs):
+       global session, resolutionlabel
+       if "session" in kwargs:
+               session = kwargs["session"]
+               resolutionlabel = session.instantiateDialog(ResolutionLabel)
+               AutoRes(session)
+
+def startSetup(menuid):
+       if menuid != "system": 
+               return [ ]
+       return [(_("Autoresolution") + "...", autoresSetup, "autores_setup", 45)]
+
+def autoresSetup(session, **kwargs):
+       session.open(AutoResSetupMenu)
+
+def Plugins(path, **kwargs):
+       return [PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART], fnc = autostart), \
+               PluginDescriptor(name=_("Autoresolution"), description=_("Autoresolution Switch"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup) ]
index 0632964..c3399ac 100644 (file)
@@ -145,4 +145,7 @@ zaphistorybrowser/src/Makefile
 passwordchanger/Makefile
 passwordchanger/src/Makefile
 
+autoresolution/Makefile
+autoresolution/src/Makefile
+
 ])