add isTimeshiftActive, activateTimeshift functions
authorFelix Domke <tmbinc@elitedvb.net>
Wed, 18 Jan 2006 02:35:18 +0000 (02:35 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Wed, 18 Jan 2006 02:35:18 +0000 (02:35 +0000)
lib/service/iservice.h
lib/service/servicedvb.cpp
lib/service/servicedvb.h

index 5a5a6cee312cbe7bdbb37eab9530f21da308bdc4..2b42510d61c2f712f4fc62cfeb7ac64154582d98 100644 (file)
@@ -365,6 +365,10 @@ class iTimeshiftService: public iObject
 public:
        virtual RESULT startTimeshift()=0;
        virtual RESULT stopTimeshift()=0;
 public:
        virtual RESULT startTimeshift()=0;
        virtual RESULT stopTimeshift()=0;
+       
+       virtual int isTimeshiftActive()=0;
+                       /* this essentially seeks to the relative end of the timeshift buffer */
+       virtual RESULT activateTimeshift()=0;
 };
 
 TEMPLATE_TYPEDEF(ePtr<iTimeshiftService>, iTimeshiftServicePtr);
 };
 
 TEMPLATE_TYPEDEF(ePtr<iTimeshiftService>, iTimeshiftServicePtr);
@@ -386,6 +390,9 @@ public:
                        // when iServiceInformation is implemented:
                evUpdatedEventInfo,
                evUpdatedInfo,
                        // when iServiceInformation is implemented:
                evUpdatedEventInfo,
                evUpdatedInfo,
+
+                       /* when seek() is implemented: */               
+               evSeekableStatusChanged, /* for example when timeshifting */
                
                evEOF
        };
                
                evEOF
        };
index ed6544f5f1701dc5232d95a8cb1935c428ef6fbd..85647ff751e764171d2061954e8535bb34a75065 100644 (file)
@@ -553,7 +553,10 @@ void eDVBServicePlay::serviceEvent(int event)
                break;
        }
        case eDVBServicePMTHandler::eventEOF:
                break;
        }
        case eDVBServicePMTHandler::eventEOF:
+       {
                m_event((iPlayableService*)this, evEnd);
                m_event((iPlayableService*)this, evEnd);
+               break;
+       }
        }
 }
 
        }
 }
 
@@ -565,6 +568,9 @@ void eDVBServicePlay::serviceEventTimeshift(int event)
                if (m_timeshift_active)
                        updateDecoder();
                break;
                if (m_timeshift_active)
                        updateDecoder();
                break;
+       case eDVBServicePMTHandler::eventEOF:
+               switchToLive();
+               break;
        }
 }
 
        }
 }
 
@@ -620,7 +626,7 @@ RESULT eDVBServicePlay::setFastForward(int ratio)
     
 RESULT eDVBServicePlay::seek(ePtr<iSeekableService> &ptr)
 {
     
 RESULT eDVBServicePlay::seek(ePtr<iSeekableService> &ptr)
 {
-       if (m_is_pvr || m_timeshift_enabled)
+       if (m_is_pvr || m_timeshift_active)
        {
                ptr = this;
                return 0;
        {
                ptr = this;
                return 0;
@@ -645,11 +651,6 @@ RESULT eDVBServicePlay::getLength(pts_t &len)
 
 RESULT eDVBServicePlay::pause()
 {
 
 RESULT eDVBServicePlay::pause()
 {
-       if (m_timeshift_enabled && !m_timeshift_active)
-       {
-               switchToTimeshift();
-               return 0;
-       }
        if (!m_is_paused && m_decoder)
        {
                m_is_paused = 1;
        if (!m_is_paused && m_decoder)
        {
                m_is_paused = 1;
@@ -677,7 +678,7 @@ RESULT eDVBServicePlay::seekTo(pts_t to)
 
        ePtr<iDVBPVRChannel> pvr_channel;
        
 
        ePtr<iDVBPVRChannel> pvr_channel;
        
-       if (m_service_handler.getPVRChannel(pvr_channel))
+       if ((m_timeshift_enabled ? m_service_handler_timeshift : m_service_handler).getPVRChannel(pvr_channel))
                return -1;
        
        return pvr_channel->seekTo(m_decode_demux, 0, to);
                return -1;
        
        return pvr_channel->seekTo(m_decode_demux, 0, to);
@@ -692,7 +693,7 @@ RESULT eDVBServicePlay::seekRelative(int direction, pts_t to)
 
        ePtr<iDVBPVRChannel> pvr_channel;
        
 
        ePtr<iDVBPVRChannel> pvr_channel;
        
-       if (m_service_handler.getPVRChannel(pvr_channel))
+       if ((m_timeshift_enabled ? m_service_handler_timeshift : m_service_handler).getPVRChannel(pvr_channel))
                return -1;
        
        to *= direction;
                return -1;
        
        to *= direction;
@@ -707,7 +708,7 @@ RESULT eDVBServicePlay::getPlayPosition(pts_t &pos)
        if (!m_decode_demux)
                return -1;
        
        if (!m_decode_demux)
                return -1;
        
-       if (m_service_handler.getPVRChannel(pvr_channel))
+       if ((m_timeshift_enabled ? m_service_handler_timeshift : m_service_handler).getPVRChannel(pvr_channel))
                return -1;
        
        return pvr_channel->getCurrentPosition(m_decode_demux, pos, 1);
                return -1;
        
        return pvr_channel->getCurrentPosition(m_decode_demux, pos, 1);
@@ -1030,6 +1031,25 @@ RESULT eDVBServicePlay::stopTimeshift()
        return 0;
 }
 
        return 0;
 }
 
+int eDVBServicePlay::isTimeshiftActive()
+{
+       return m_timeshift_enabled && m_timeshift_active;
+}
+
+RESULT eDVBServicePlay::activateTimeshift()
+{
+       if (!m_timeshift_enabled)
+               return -1;
+       
+       if (!m_timeshift_active)
+       {
+               switchToTimeshift();
+               return 0;
+       }
+       
+       return -2;
+}
+
 void eDVBServicePlay::updateTimeshiftPids()
 {
        if (!m_record)
 void eDVBServicePlay::updateTimeshiftPids()
 {
        if (!m_record)
@@ -1090,6 +1110,8 @@ void eDVBServicePlay::switchToLive()
        m_service_handler_timeshift.free();
        m_timeshift_active = 0;
        
        m_service_handler_timeshift.free();
        m_timeshift_active = 0;
        
+       m_event((iPlayableService*)this, evSeekableStatusChanged);
+       
        updateDecoder();
 }
 
        updateDecoder();
 }
 
@@ -1103,6 +1125,8 @@ void eDVBServicePlay::switchToTimeshift()
        m_decoder = 0;
        
        m_timeshift_active = 1;
        m_decoder = 0;
        
        m_timeshift_active = 1;
+
+       m_event((iPlayableService*)this, evSeekableStatusChanged);
        
        eServiceReferenceDVB r = (eServiceReferenceDVB&)m_reference;
        r.path = m_timeshift_file;
        
        eServiceReferenceDVB r = (eServiceReferenceDVB&)m_reference;
        r.path = m_timeshift_file;
index c7c36e1c6936c461850caeba920996c14e9cdeeb..61baf6a2d270dd003d491e74cac1d34b011c1b4d 100644 (file)
@@ -107,6 +107,8 @@ public:
                // iTimeshiftService
        RESULT startTimeshift();
        RESULT stopTimeshift();
                // iTimeshiftService
        RESULT startTimeshift();
        RESULT stopTimeshift();
+       int isTimeshiftActive();
+       RESULT activateTimeshift();
 
 private:
        friend class eServiceFactoryDVB;
 
 private:
        friend class eServiceFactoryDVB;