add pause support
authorFelix Domke <tmbinc@elitedvb.net>
Fri, 11 Nov 2005 15:41:18 +0000 (15:41 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Fri, 11 Nov 2005 15:41:18 +0000 (15:41 +0000)
data/keymap.xml
lib/dvb/decoder.cpp
lib/dvb/decoder.h
lib/python/Screens/InfoBar.py
lib/service/servicedvb.cpp
lib/service/servicedvb.h

index b8f234c..fa252fc 100644 (file)
@@ -83,6 +83,9 @@
                <key id="KEY_8" mapto="8" flags="m" />
                <key id="KEY_9" mapto="9" flags="m" />
                <key id="KEY_0" mapto="0" flags="m" />
+               
+               <key id="KEY_YELLOW" mapto="pauseService" flags="m" />
+               <key id="KEY_GREEN" mapto="unPauseService" flags="m" />
        </map>
        
        <map context="ChannelSelectActions">
index b711855..751796a 100644 (file)
@@ -183,6 +183,18 @@ void eDVBVideo::flush()
                eDebug("video: VIDEO_CLEAR_BUFFER: %m");
 }
        
+void eDVBVideo::freeze()
+{
+       if (::ioctl(m_fd, VIDEO_FREEZE) < 0)
+               eDebug("video: VIDEO_FREEZE: %m");
+}
+       
+void eDVBVideo::unfreeze()
+{
+       if (::ioctl(m_fd, VIDEO_CONTINUE) < 0)
+               eDebug("video: VIDEO_CONTINUE: %m");
+}
+       
 eDVBVideo::~eDVBVideo()
 {
        if (m_fd >= 0)
@@ -407,12 +419,20 @@ RESULT eTSMPEGDecoder::start()
 
 RESULT eTSMPEGDecoder::freeze(int cont)
 {
-       return -1;
+       if (m_video)
+               m_video->freeze();
+       else
+               return -1;
+       return 0;
 }
 
 RESULT eTSMPEGDecoder::unfreeze()
 {
-       return -1;
+       if (m_video)
+               m_video->unfreeze();
+       else
+               return -1;
+       return 0;
 }
 
 RESULT eTSMPEGDecoder::setSinglePictureMode(int when)
index a26d6cf..68262fe 100644 (file)
@@ -37,6 +37,8 @@ public:
        void stopPid();
 #endif
        void flush();
+       void freeze();
+       void unfreeze();
        virtual ~eDVBVideo();
 };
 
index 065097f..bf1d904 100644 (file)
@@ -115,7 +115,10 @@ class InfoBar(Screen):
                                "8": self.keyNumberGlobal,
                                "9": self.keyNumberGlobal,
                                "0": self.keyNumberGlobal,
-                               "showEPGList": self.showEPGList
+                               "showEPGList": self.showEPGList,
+                               
+                               "pauseService": self.pauseService,
+                               "unPauseService": self.unPauseService,
                        })
 #              self["okbutton"] = Button("mainMenu", [self.mainMenu])
                
@@ -240,7 +243,7 @@ class InfoBar(Screen):
                        pass
                
                # fix me, description. 
-               self.recording = self.session.nav.recordWithTimer(time.time(), time.time() + 30, serviceref, epg, "instant record")
+               self.recording = self.session.nav.recordWithTimer(time.time(), time.time() + 3600, serviceref, epg, "instant record")
 
        def recordQuestionCallback(self, answer):
                if answer == False:
@@ -259,3 +262,9 @@ class InfoBar(Screen):
 
        def showMovies(self):
                self.session.open(MovieSelection)
+
+       def pauseService(self):
+               self.session.nav.pause(1)
+               
+       def unPauseService(self):
+               self.session.nav.pause(0)
index fdf93d7..f3215d8 100644 (file)
@@ -365,7 +365,7 @@ RESULT eServiceFactoryDVB::lookupService(ePtr<eDVBService> &service, const eServ
 }
 
 eDVBServicePlay::eDVBServicePlay(const eServiceReference &ref, eDVBService *service): 
-       m_reference(ref), m_dvb_service(service), m_service_handler(0)
+       m_reference(ref), m_dvb_service(service), m_service_handler(0), m_is_paused(0)
 {
        m_is_pvr = !ref.path.empty();
        
@@ -518,7 +518,12 @@ RESULT eDVBServicePlay::connectEvent(const Slot2<void,iPlayableService*,int> &ev
 
 RESULT eDVBServicePlay::pause(ePtr<iPauseableService> &ptr)
 {
-               // not yet possible, maybe later...
+       if (m_is_pvr)
+       {
+               ptr = this;
+               return 0;
+       }
+
        ptr = 0;
        return -1;
 }
@@ -548,6 +553,26 @@ RESULT eDVBServicePlay::getLength(pts_t &len)
        return pvr_channel->getLength(len);
 }
 
+RESULT eDVBServicePlay::pause()
+{
+       if (!m_is_paused && m_decoder)
+       {
+               m_is_paused = 1;
+               return m_decoder->freeze(0);
+       } else
+               return -1;
+}
+
+RESULT eDVBServicePlay::unpause()
+{
+       if (m_is_paused && m_decoder)
+       {
+               m_is_paused = 0;
+               return m_decoder->unfreeze();
+       } else
+               return -1;
+}
+
 RESULT eDVBServicePlay::seekTo(pts_t to)
 {
        return -1;
index 57dca9a..f47c390 100644 (file)
@@ -41,28 +41,9 @@ private:
        ePtr<iDVBChannelListQuery> m_query;
 };
 
-class eDVBServicePlay: public iPlayableService, iSeekableService, public Object, public iServiceInformation
+class eDVBServicePlay: public iPlayableService, public iPauseableService, public iSeekableService, public Object, public iServiceInformation
 {
 DECLARE_REF(eDVBServicePlay);
-private:
-       friend class eServiceFactoryDVB;
-       eServiceReference m_reference;
-       
-       ePtr<eDVBService> m_dvb_service;
-       
-       ePtr<iTSMPEGDecoder> m_decoder;
-       
-       eDVBServicePMTHandler m_service_handler;
-       eDVBServiceEITHandler m_event_handler;
-       
-       eDVBServicePlay(const eServiceReference &ref, eDVBService *service);
-       
-       void gotNewEvent();
-       
-       void serviceEvent(int event);
-       Signal2<void,iPlayableService*,int> m_event;
-       
-       int m_is_pvr;
 public:
        virtual ~eDVBServicePlay();
 
@@ -74,6 +55,10 @@ public:
        RESULT pause(ePtr<iPauseableService> &ptr);
        RESULT info(ePtr<iServiceInformation> &ptr);
        
+               // iPauseableService
+       RESULT pause();
+       RESULT unpause();
+       
                // iSeekableService
        RESULT getLength(pts_t &len);
        RESULT seekTo(pts_t to);
@@ -82,6 +67,26 @@ public:
                // iServiceInformation
        RESULT getName(std::string &name);
        RESULT getEvent(ePtr<eServiceEvent> &evt, int nownext);
+
+private:
+       friend class eServiceFactoryDVB;
+       eServiceReference m_reference;
+       
+       ePtr<eDVBService> m_dvb_service;
+       
+       ePtr<iTSMPEGDecoder> m_decoder;
+       
+       eDVBServicePMTHandler m_service_handler;
+       eDVBServiceEITHandler m_event_handler;
+       
+       eDVBServicePlay(const eServiceReference &ref, eDVBService *service);
+       
+       void gotNewEvent();
+       
+       void serviceEvent(int event);
+       Signal2<void,iPlayableService*,int> m_event;
+       
+       int m_is_pvr, m_is_paused;
 };
 
 #endif