store subtitle data in service cache and reenable subtitles on next zap to
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Wed, 1 Nov 2006 14:33:57 +0000 (14:33 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Wed, 1 Nov 2006 14:33:57 +0000 (14:33 +0000)
the same service

lib/dvb/idvb.h
lib/python/Screens/InfoBarGenerics.py
lib/python/Screens/Subtitles.py
lib/service/iservice.h
lib/service/servicedvb.cpp
lib/service/servicedvb.h

index 46d3e5d6aaadd3fdfe5dce0f2444e334d6ee7c4f..1f8aebdaf1aa8b2bbdf2020991d53503d62dc451 100644 (file)
@@ -235,7 +235,8 @@ public:
        enum cacheID
        {
                cVPID, cAPID, cTPID, cPCRPID, cAC3PID,
-               cVTYPE, cACHANNEL, cAC3DELAY, cPCMDELAY, cacheMax
+               cVTYPE, cACHANNEL, cAC3DELAY, cPCMDELAY,
+               cSUBTITLE, cacheMax
        };
 
        int getCacheEntry(cacheID);
index b69ef4e1e0981f4f18d06be215468f396d2b0416..a85bcc97d0015b1e621ae0889651ae729a632d63 100644 (file)
@@ -1750,14 +1750,24 @@ class InfoBarSubtitleSupport(object):
                self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
                        {
                                iPlayableService.evStart: self.__serviceStarted,
+                               iPlayableService.evUpdatedInfo: self.__updatedInfo
                        })
 
        def __serviceStarted(self):
-               # reenable if it was enabled
-               r = self.__subtitles_enabled
+               self.cached_subtitle_checked = False
+               self.subtitle_window.hide()
                self.__subtitles_enabled = False
-               self.__selected_subtitle = None
-               self.setSubtitlesEnable(r)
+
+       def __updatedInfo(self):
+               if not self.cached_subtitle_checked:
+                       subtitle = self.getCurrentServiceSubtitle()
+                       self.cached_subtitle_checked = True
+                       if subtitle:
+                               self.__selected_subtitle = subtitle.getCachedSubtitle()
+                       if self.__selected_subtitle:
+                               subtitle.enableSubtitles(self.subtitle_window.instance, self.selected_subtitle)
+                               self.subtitle_window.show()
+                               self.__subtitles_enabled = True
 
        def getCurrentServiceSubtitle(self):
                service = self.session.nav.getCurrentService()
@@ -1773,17 +1783,11 @@ class InfoBarSubtitleSupport(object):
                else:
                        if subtitle:
                                subtitle.disableSubtitles(self.subtitle_window.instance)
-
-                       self.subtitle_window.hide()
                        self.__subtitles_enabled = False
+                       self.subtitle_window.hide()
 
        def setSelectedSubtitle(self, subtitle):
-               if self.__selected_subtitle != subtitle and self.subtitles_enabled:
-                       # kick
-                       self.__selected_subtitle = subtitle
-                       self.__serviceStarted()
-               else:
-                       self.__selected_subtitle = subtitle
+               self.__selected_subtitle = subtitle
 
        subtitles_enabled = property(lambda self: self.__subtitles_enabled, setSubtitlesEnable)
        selected_subtitle = property(lambda self: self.__selected_subtitle, setSelectedSubtitle)
index 6a1deedb5bdb16f3abdc560a65319adcdd0888a5..d72ea336c1ef5c183d74114cd670bc604b247bdb 100644 (file)
@@ -25,7 +25,7 @@ class Subtitles(Screen, ConfigListScreen):
                else:
                        sel = None
                for x in self.getSubtitleList():
-                       if sel and sel == x:
+                       if sel and sel[:4] == x[:4]: #ignore Language code in compare
                                text = _("Running")
                        else:
                                text = _("Enable")
@@ -50,7 +50,6 @@ class Subtitles(Screen, ConfigListScreen):
 
        def enableSubtitle(self, subtitles):
                if self.infobar.selected_subtitle != subtitles:
-                       print "enable subtitles", subtitles
                        self.infobar.subtitles_enabled = False
                        self.infobar.selected_subtitle = subtitles
                        self.infobar.subtitles_enabled = True
index 73d35eed1f5c5c9dafb8d66d0f5d2ee3717d40a7..71c82ab052775a6f8d6d10b66a48abeedddcfc5e 100644 (file)
@@ -476,6 +476,7 @@ public:
        virtual RESULT enableSubtitles(eWidget *parent, PyObject *entry)=0;
        virtual RESULT disableSubtitles(eWidget *parent)=0;
        virtual PyObject *getSubtitleList()=0;
+       virtual PyObject *getCachedSubtitle()=0;
 };
 
 TEMPLATE_TYPEDEF(ePtr<iSubtitleOutput>, iSubtitleOutputPtr);
index e6a214394ad88fddff133047a51e7cf3b3caa400..5a6ea0cd05ab989648c3c9f0bafb66bc0ac8a4b5 100644 (file)
@@ -2013,7 +2013,7 @@ RESULT eDVBServicePlay::enableSubtitles(eWidget *parent, PyObject *tuple)
 
        if (type == 1)  // teletext subtitles
        {
-               int page, magazine;
+               int page, magazine, pid;
                if (tuplesize < 4)
                        goto error_out;
 
@@ -2023,7 +2023,11 @@ RESULT eDVBServicePlay::enableSubtitles(eWidget *parent, PyObject *tuple)
                        return -1;
                }
 
-               // PyTuple_GET_ITEM(tuple, 1);  //we dont need pid yet
+               entry = PyTuple_GET_ITEM(tuple, 1);
+               if (!PyInt_Check(entry))
+                       goto error_out;
+               pid = PyInt_AsLong(entry);
+
                entry = PyTuple_GET_ITEM(tuple, 2);
                if (!PyInt_Check(entry))
                        goto error_out;
@@ -2037,6 +2041,8 @@ RESULT eDVBServicePlay::enableSubtitles(eWidget *parent, PyObject *tuple)
                m_subtitle_widget = new eSubtitleWidget(parent);
                m_subtitle_widget->resize(parent->size()); /* full size */
                m_teletext_parser->setPageAndMagazine(page, magazine);
+               if (m_dvb_service)
+                       m_dvb_service->setCacheEntry(eDVBService::cSUBTITLE,((pid&0xFFFF)<<16)|((page&0xFF)<<8)|(magazine&0xFF));
        }
        else if (type == 0)
        {
@@ -2067,6 +2073,8 @@ RESULT eDVBServicePlay::enableSubtitles(eWidget *parent, PyObject *tuple)
                m_subtitle_widget = new eSubtitleWidget(parent);
                m_subtitle_widget->resize(parent->size()); /* full size */
                m_subtitle_parser->start(pid, composition_page_id, ancillary_page_id);
+               if (m_dvb_service)
+                       m_dvb_service->setCacheEntry(eDVBService::cSUBTITLE, ((pid&0xFFFF)<<16)|((composition_page_id&0xFF)<<8)|(ancillary_page_id&0xFF));
        }
        else
                goto error_out;
@@ -2092,9 +2100,40 @@ RESULT eDVBServicePlay::disableSubtitles(eWidget *parent)
                m_teletext_parser->setPageAndMagazine(0,0);
                m_subtitle_pages.clear();
        }
+       if (m_dvb_service)
+               m_dvb_service->setCacheEntry(eDVBService::cSUBTITLE, -1);
        return 0;
 }
 
+PyObject *eDVBServicePlay::getCachedSubtitle()
+{
+       if (m_dvb_service)
+       {
+               int tmp = m_dvb_service->getCacheEntry(eDVBService::cSUBTITLE);
+               if (tmp != -1)
+               {
+                       unsigned int data = (unsigned int)tmp;
+                       int pid = (data&0xFFFF0000)>>16;
+                       PyObject *tuple = PyTuple_New(4);
+                       eDVBServicePMTHandler::program program;
+                       eDVBServicePMTHandler &h = m_timeshift_active ? m_service_handler_timeshift : m_service_handler;
+                       if (!h.getProgramInfo(program))
+                       {
+                               if (program.textPid==pid) // teletext
+                                       PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(1)); // type teletext
+                               else
+                                       PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(0)); // type dvb
+                               PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong((data&0xFFFF0000)>>16)); // pid
+                               PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong((data&0xFF00)>>8)); // composition_page / page
+                               PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(data&0xFF)); // ancillary_page / magazine
+                               return tuple;
+                       }
+               }
+       }
+       Py_INCREF(Py_None);
+       return Py_None;
+}
+
 PyObject *eDVBServicePlay::getSubtitleList()
 {
        if (!m_teletext_parser)
index 62d341692609bd11dc20bc25ae0e6febe270e43e..5e0cf0b4e17b137232fd0787e9d1cd6222d35a2f 100644 (file)
@@ -158,6 +158,7 @@ public:
        RESULT enableSubtitles(eWidget *parent, PyObject *entry);
        RESULT disableSubtitles(eWidget *parent);
        PyObject *getSubtitleList();
+       PyObject *getCachedSubtitle();
 
                // iAudioDelay
        int getAC3Delay();