Beispiel #1
0
class VBMain(Screen):
    skin = """<screen name="VBMAIN" position="0,0" size="0,0" backgroundColor="transparent" flags="wfNoBorder" title=" "></screen>"""

    def __init__(self, session):
        Screen.__init__(self, session)

        self.vbcallback = None
        self.vbhandler = VBHandler(session)
        self.vbserver = VBServerThread()
        self.vbserver.open(1)
        self.vbserver.start()

        # comment for dev
        self.restart_browser()
        vbcfg.LOG("browser start")

        self._timer_infobar = eTimer()
        self._timer_infobar.callback.append(self._cb_register_infobar)
        self._timer_infobar.start(1000)

        self._event = ServiceEventTracker(screen=self,
                                          eventmap={
                                              iPlayableService.evHBBTVInfo:
                                              self._cb_ait_detected,
                                              iPlayableService.evUpdatedInfo:
                                              self._cb_info_updated
                                          })
        self._applicationList = None
        self._app_info = None

        try:
            from Screens.InfoBarGenerics import gHbbtvApplication
            self.m_vuplus = gHbbtvApplication.getUseAit()
        except:
            self.m_vuplus = False

    def _cb_register_infobar(self):
        if InfoBar.instance:
            self._timer_infobar.stop()
            if self._cb_hbbtv_activated not in InfoBar.instance.onHBBTVActivation:
                InfoBar.instance.onHBBTVActivation.append(
                    self._cb_hbbtv_activated)
        vbcfg.DEBUG("registred HbbTV in InfoBar")

    def _cb_hbbtv_activated(self, url=None, app_info=None):
        if not self.check_browser():
            message = _(
                "HbbTV Browser was not running.\nPlease running browser before start HbbTV Application."
            )
            self.session.open(MessageBox, message, MessageBox.TYPE_INFO)
            return
        self.start_hbbtv_application(url, app_info)

    def _cb_ait_detected(self):
        vbcfg.g_channel_info = None
        self._applicationList = None
        self._app_info = self.get_autostart_application()
        vbcfg.DEBUG("detected AIT")

    def _cb_info_updated(self):
        vbcfg.g_service = self.session.nav.getCurrentlyPlayingServiceReference(
        )
        vbcfg.DEBUG("updated channel info")

    def start_hbbtv_application(self, url, app_info):
        if vbcfg.need_restart:
            self.restart_browser()
            os.time.sleep(2)
            vbcfg.need_restart = False

        if not app_info:
            app_info = self._app_info
        self.session.open(HbbTVWindow, url, app_info)

    def menu_toggle_browser(self, callback=None):
        mode = []
        self.vbcallback = callback
        if self.check_browser():
            mode.append((_('Stop'), 'Stop'))
        else:
            mode.append((_('Start'), 'Start'))
        self.session.openWithCallback(self.toggle_browser,
                                      ChoiceBox,
                                      title=_("Please choose one."),
                                      list=mode)

    def toggle_browser(self, selected):
        if selected is not None:
            if self.vbcallback:
                self.vbcallback()
            try:
                mode = selected[1]
                if mode == 'Start':
                    if not self.check_browser():
                        self.start_browser()
                elif mode == 'Stop':
                    self.stop_browser()

            except Exception as ErrMsg:
                vbcfg.ERR("toggle browser: %s" % ErrMsg)

    def menu_hbbtv_applications(self):
        applications = []
        if self._applicationList is not None:
            for x in self._applicationList:
                applications.append((x["name"], x))
        else:
            applications.append((_("No detected HbbTV applications."), None))
        self.session.openWithCallback(
            self.start_application_selected,
            ChoiceBox,
            title=_("Please choose an HbbTV application."),
            list=applications)

    def start_application_selected(self, selected):
        vbcfg.DEBUG(selected)
        try:
            if selected[1] is not None:
                self._cb_hbbtv_activated(selected[1]["url"], selected[1])
        except Exception as ErrMsg:
            vbcfg.ERR(ErrMsg)

    def get_autostart_application(self):
        if self._applicationList is None:
            service = self.session.nav.getCurrentService()
            info = service and service.info()
            if info is not None:
                sid = info.getInfo(iServiceInformation.sSID)
                onid = info.getInfo(iServiceInformation.sONID)
                tsid = info.getInfo(iServiceInformation.sTSID)
                name = info.getName()
                vbcfg.g_channel_info = (sid, onid, tsid, name)

                pmtid = info.getInfo(iServiceInformation.sPMTPID)
                demux = info.getInfoString(
                    iServiceInformation.sLiveStreamDemuxId)
                vbcfg.DEBUG("demux = %s, pmtid = 0x%x, sid = 0x%x" %
                            (demux, pmtid, sid))

                from aitreader import eAITSectionReader
                reader = eAITSectionReader(demux, pmtid, sid)
                if reader.doOpen(info, self.m_vuplus):
                    reader.doParseApplications()
                    #reader.doDump()
                else:
                    vbcfg.ERR("no AIT")

                try:
                    self._applicationList = reader.getApplicationList()
                except:
                    pass

        if self._applicationList is not None:
            for app in self._applicationList:
                if app["control"] in (1, -1):
                    return app
        return None

    def start_browser(self):
        if not self.check_browser():
            os.system("%s/%s start" % (vbcfg.APPROOT, vbcfg.APP_RUN))
        return True

    def stop_browser(self):
        VBController.command('CONTROL_EXIT')
        return True
        try:
            os.system("%s/%s stop" % (vbcfg.APPROOT, vbcfg.APP_RUN))
        except:
            pass
        return True

    def check_browser(self):
        try:
            ret = os.popen('%s/%s check' %
                           (vbcfg.APPROOT, vbcfg.APP_RUN)).read()
            return ret.strip() != "0"
        except Exception as ErrMsg:
            vbcfg.ERR("check browser running: %s" % ErrMsg)
        return False

    def restart_browser(self):
        try:
            os.system("%s/%s restart" % (vbcfg.APPROOT, vbcfg.APP_RUN))
        except:
            pass
        return True
Beispiel #2
0
class VBMain(Screen):
    skin = """<screen name="VBMAIN" position="0,0" size="0,0" backgroundColor="transparent" flags="wfNoBorder" title=" "></screen>"""

    def __init__(self, session):
        Screen.__init__(self, session)

        self.vbcallback = None
        self.vbhandler = VBHandler(session)
        self.vbserver = VBServerThread()
        self.vbserver.open(1)
        self.vbserver.start()

        self._timer_infobar = eTimer()
        self._timer_infobar.callback.append(self._cb_register_infobar)
        self._timer_infobar.start(1000)

        self._timer_update_video_size = eTimer()
        self._timer_update_video_size.callback.append(
            self._cb_update_video_size)

        self._event = ServiceEventTracker(screen=self,
                                          eventmap={
                                              iPlayableService.evHBBTVInfo:
                                              self._cb_ait_detected,
                                              iPlayableService.evUpdatedInfo:
                                              self._cb_info_updated
                                          })
        self._applicationList = None
        self._app_info = None

        try:
            from Screens.InfoBarGenerics import gHbbtvApplication
            self.aitReader = gHbbtvApplication.getUseAit()
        except:
            self.aitReader = False

    def _cb_register_infobar(self):
        if InfoBar.instance:
            self._timer_infobar.stop()
            if self._cb_hbbtv_activated not in InfoBar.instance.onHBBTVActivation:
                InfoBar.instance.onHBBTVActivation.append(
                    self._cb_hbbtv_activated)
        vbcfg.DEBUG("registred HbbTV in InfoBar")

    def _cb_update_video_size(self):
        file = open("/proc/stb/vmpeg/0/dst_left", "r")
        dst_left = int(file.read().strip(), 16)
        file.close()
        file = open("/proc/stb/vmpeg/0/dst_width", "r")
        dst_width = int(file.read().strip(), 16)
        file.close()
        file = open("/proc/stb/vmpeg/0/dst_top", "r")
        dst_top = int(file.read().strip(), 16)
        file.close()
        file = open("/proc/stb/vmpeg/0/dst_height", "r")
        dst_height = int(file.read().strip(), 16)
        file.close()

        global g_dst_left, g_dst_width, g_dst_top, g_dst_height
        if (g_dst_left != dst_left) or (g_dst_width != dst_width) or (
                g_dst_top != dst_top) or (g_dst_height != dst_height):
            g_dst_left = dst_left
            g_dst_width = dst_width
            g_dst_top = dst_top
            g_dst_height = dst_height

            file = open("/proc/stb/vmpeg/0/dst_apply", "w")
            file.write("1")
            file.close()

    def _cb_hbbtv_activated(self, url=None, app_info=None):
        self.start_hbbtv_application(url, app_info)

    def _cb_ait_detected(self):
        vbcfg.g_channel_info = None
        self._applicationList = None
        self._app_info = self.get_autostart_application()
        vbcfg.DEBUG("detected AIT")

    def _cb_info_updated(self):
        vbcfg.g_service = self.session.nav.getCurrentlyPlayingServiceReference(
        )
        vbcfg.DEBUG("updated channel info")

    def start_hbbtv_application(self, url, app_info):
        if vbcfg.need_restart:
            vbcfg.need_restart = False

        if not app_info:
            app_info = self._app_info

        InfoBar.instance.hide()
        self.session.open(HbbTVWindow, url, app_info)

    def menu_hbbtv_applications(self):
        applications = []
        if self._applicationList is not None:
            for x in self._applicationList:
                applications.append((x["name"], x))
        else:
            applications.append((_("No detected HbbTV applications."), None))
        self.session.openWithCallback(
            self.start_application_selected,
            ChoiceBox,
            title=_("Please choose an HbbTV application."),
            list=applications)

    def start_application_selected(self, selected):
        vbcfg.DEBUG(selected)
        try:
            if selected[1] is not None:
                self._cb_hbbtv_activated(selected[1]["url"], selected[1])
        except Exception, ErrMsg:
            vbcfg.ERR(ErrMsg)
class VBMain(Screen):
	skin = """<screen name="VBMAIN" position="0,0" size="0,0" backgroundColor="transparent" flags="wfNoBorder" title=" "></screen>"""
	def __init__(self, session):
		Screen.__init__(self, session)

		self.vbcallback = None
		self.vbhandler = VBHandler(session)
		self.vbserver = VBServerThread()
		self.vbserver.open(1)
		self.vbserver.start()

		# comment for dev
		self.restart_browser()
		vbcfg.LOG("browser start")

		self._timer_infobar = eTimer()
		self._timer_infobar.callback.append(self._cb_register_infobar)
		self._timer_infobar.start(1000)

		self._event = ServiceEventTracker(screen=self, eventmap={
				iPlayableService.evHBBTVInfo: self._cb_ait_detected,
				iPlayableService.evUpdatedInfo: self._cb_info_updated
			})
		self._applicationList = None
		self._app_info = None

		try:
			from Screens.InfoBarGenerics import gHbbtvApplication
			self.m_vuplus = gHbbtvApplication.getUseAit()
		except:
			self.m_vuplus = False

	def _cb_register_infobar(self):
		if InfoBar.instance:
			self._timer_infobar.stop()
			if self._cb_hbbtv_activated not in InfoBar.instance.onHBBTVActivation:
				InfoBar.instance.onHBBTVActivation.append(self._cb_hbbtv_activated)
		vbcfg.DEBUG("registred HbbTV in InfoBar")

	def _cb_hbbtv_activated(self, url=None, app_info=None):
		if not self.check_browser():
			message = _("HbbTV Browser was not running.\nPlease running browser before start HbbTV Application.")
			self.session.open(MessageBox, message, MessageBox.TYPE_INFO)
			return
		self.start_hbbtv_application(url, app_info)

	def _cb_ait_detected(self):
		vbcfg.g_channel_info = None
		self._applicationList = None
		self._app_info = self.get_autostart_application()
		vbcfg.DEBUG("detected AIT")

	def _cb_info_updated(self):
		vbcfg.g_service = self.session.nav.getCurrentlyPlayingServiceReference()
		vbcfg.DEBUG("updated channel info")

	def start_hbbtv_application(self, url, app_info):
		if vbcfg.need_restart:
			self.restart_browser()
			os.time.sleep(2)
			vbcfg.need_restart = False

		if not app_info:
			app_info = self._app_info
		self.session.open(HbbTVWindow, url, app_info)

	def menu_toggle_browser(self, callback=None):
		mode = []
		self.vbcallback = callback
		if self.check_browser():
			mode.append((_('Stop'), 'Stop'))
		else:
			mode.append((_('Start'), 'Start'))
		self.session.openWithCallback(self.toggle_browser, ChoiceBox, title=_("Please choose one."), list=mode)

	def toggle_browser(self, selected):
		if selected is not None:
			if self.vbcallback:
				self.vbcallback()
			try:
				mode = selected[1]
				if mode == 'Start':
					if not self.check_browser():
						self.start_browser()
				elif mode == 'Stop':
					self.stop_browser()

			except Exception, ErrMsg:
				vbcfg.ERR("toggle browser: %s" % ErrMsg)
Beispiel #4
0
class VBMain(Screen):
    skin = """<screen name="VBMAIN" position="0,0" size="0,0" backgroundColor="transparent" flags="wfNoBorder" title=" "></screen>"""

    def __init__(self, session):
        Screen.__init__(self, session)

        self.vbcallback = None
        self.vbhandler = VBHandler(session)
        self.vbserver = VBServerThread()
        self.vbserver.open(1)
        self.vbserver.start()

        # comment for dev
        self.restart_browser()
        vbcfg.LOG("browser start")

        self._timer_infobar = eTimer()
        self._timer_infobar.callback.append(self._cb_register_infobar)
        self._timer_infobar.start(1000)

        self._event = ServiceEventTracker(
            screen=self,
            eventmap={
                iPlayableService.evHBBTVInfo: self._cb_ait_detected,
                iPlayableService.evUpdatedInfo: self._cb_info_updated,
            },
        )
        self._applicationList = None
        self._app_info = None

        try:
            from Screens.InfoBarGenerics import gHbbtvApplication

            self.m_vuplus = gHbbtvApplication.getUseAit()
        except:
            self.m_vuplus = False

    def _cb_register_infobar(self):
        if InfoBar.instance:
            self._timer_infobar.stop()
            if self._cb_hbbtv_activated not in InfoBar.instance.onHBBTVActivation:
                InfoBar.instance.onHBBTVActivation.append(self._cb_hbbtv_activated)
        vbcfg.DEBUG("registred HbbTV in InfoBar")

    def _cb_hbbtv_activated(self, url=None, app_info=None):
        if not self.check_browser():
            message = _("HbbTV Browser was not running.\nPlease running browser before start HbbTV Application.")
            self.session.open(MessageBox, message, MessageBox.TYPE_INFO)
            return
        self.start_hbbtv_application(url, app_info)

    def _cb_ait_detected(self):
        vbcfg.g_channel_info = None
        self._applicationList = None
        self._app_info = self.get_autostart_application()
        vbcfg.DEBUG("detected AIT")

    def _cb_info_updated(self):
        vbcfg.g_service = self.session.nav.getCurrentlyPlayingServiceReference()
        vbcfg.DEBUG("updated channel info")

    def start_hbbtv_application(self, url, app_info):
        if vbcfg.need_restart:
            self.restart_browser()
            os.time.sleep(2)
            vbcfg.need_restart = False

        if not app_info:
            app_info = self._app_info
        self.session.open(HbbTVWindow, url, app_info)

    def menu_toggle_browser(self, callback=None):
        mode = []
        self.vbcallback = callback
        if self.check_browser():
            mode.append((_("Stop"), "Stop"))
        else:
            mode.append((_("Start"), "Start"))
        self.session.openWithCallback(self.toggle_browser, ChoiceBox, title=_("Please choose one."), list=mode)

    def toggle_browser(self, selected):
        if selected is not None:
            if self.vbcallback:
                self.vbcallback()
            try:
                mode = selected[1]
                if mode == "Start":
                    if not self.check_browser():
                        self.start_browser()
                elif mode == "Stop":
                    self.stop_browser()

            except Exception, ErrMsg:
                vbcfg.ERR("toggle browser: %s" % ErrMsg)