add slowmotion / fast forward
authorFelix Domke <tmbinc@elitedvb.net>
Thu, 8 Dec 2005 00:35:27 +0000 (00:35 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Thu, 8 Dec 2005 00:35:27 +0000 (00:35 +0000)
lib/dvb/decoder.cpp
lib/dvb/decoder.h
lib/dvb/idvb.h
lib/service/iservice.h
lib/service/servicedvb.cpp
lib/service/servicedvb.h
lib/service/servicemp3.cpp
lib/service/servicemp3.h

index 835f434e1f10160f9393669fba5f9e02498d4aba..6794a056865e6062aebe5b8d9509dd1d391ed949 100644 (file)
@@ -125,7 +125,7 @@ void eDVBAudio::freeze()
        if (::ioctl(m_fd, AUDIO_PAUSE) < 0)
                eDebug("video: AUDIO_PAUSE: %m");
 }
-       
+
 void eDVBAudio::unfreeze()
 {
        if (::ioctl(m_fd, AUDIO_CONTINUE) < 0)
@@ -191,12 +191,13 @@ int eDVBVideo::startPid(int pid)
        
 void eDVBVideo::stop()
 {
-       if (::ioctl(m_fd, VIDEO_STOP, 1) < 0)
-               eWarning("video: VIDEO_STOP: %m");
 #if HAVE_DVB_API_VERSION > 2
        if (::ioctl(m_fd_demux, DMX_STOP) < 0)
                eWarning("video: DMX_STOP: %m");
 #endif
+       eDebug("VIDEO_STOP");
+       if (::ioctl(m_fd, VIDEO_STOP, 1) < 0)
+               eWarning("video: VIDEO_STOP: %m");
 }
 
 #if HAVE_DVB_API_VERSION < 3
@@ -225,8 +226,24 @@ void eDVBVideo::unfreeze()
                eDebug("video: VIDEO_CONTINUE: %m");
 }
        
+int eDVBVideo::setSlowMotion(int repeat)
+{
+       m_is_slow_motion = repeat;
+       return ::ioctl(m_fd, VIDEO_SLOWMOTION, repeat);
+}
+
+int eDVBVideo::setFastForward(int skip)
+{
+       m_is_fast_forward = skip;
+       return ::ioctl(m_fd, VIDEO_FAST_FORWARD, skip);
+}
+       
 eDVBVideo::~eDVBVideo()
 {
+       if (m_is_slow_motion)
+               setSlowMotion(0);
+       if (m_is_fast_forward)
+               setFastForward(0);
        if (m_fd >= 0)
                ::close(m_fd);
        if (m_fd_demux >= 0)
@@ -342,11 +359,16 @@ int eTSMPEGDecoder::setState()
 #else
        if (m_changed & changeVideo)
        {
+               eDebug("VIDEO CHANGED (to %04x)", m_vpid);
                if (m_video)
+               {       
+                       eDebug("STOP");
                        m_video->stop();
+               }
                m_video = 0;
                if ((m_vpid >= 0) && (m_vpid < 0x1FFF))
                {
+                       eDebug("new video");
                        m_video = new eDVBVideo(m_demux, 0);
                        if (m_video->startPid(m_vpid))
                        {
@@ -395,6 +417,7 @@ int eTSMPEGDecoder::setState()
 eTSMPEGDecoder::eTSMPEGDecoder(eDVBDemux *demux, int decoder): m_demux(demux), m_changed(0)
 {
        demux->connectEvent(slot(*this, &eTSMPEGDecoder::demux_event), m_demux_event);
+       eDebug("eTSMPEGDecoder::eTSMPEGDecoder %p", this);
 }
 
 eTSMPEGDecoder::~eTSMPEGDecoder()
@@ -402,6 +425,7 @@ eTSMPEGDecoder::~eTSMPEGDecoder()
        m_vpid = m_apid = m_pcrpid = pidNone;
        m_changed = -1;
        setState();
+       eDebug("~eTSMPEGDecoder %p", this);
 }
 
 RESULT eTSMPEGDecoder::setVideoPID(int vpid)
@@ -477,9 +501,20 @@ RESULT eTSMPEGDecoder::setPictureSkipMode(int what)
        return -1;
 }
 
+RESULT eTSMPEGDecoder::setFastForward(int frames_to_skip)
+{
+       if (m_video)
+               return m_video->setFastForward(frames_to_skip);
+       else
+               return -1;
+}
+
 RESULT eTSMPEGDecoder::setSlowMotion(int repeat)
 {
-       return -1;
+       if (m_video)
+               return m_video->setSlowMotion(repeat);
+       else
+               return -1;
 }
 
 RESULT eTSMPEGDecoder::setZoom(int what)
index 7bd16fd1bb3b077457c2b5e727739e30a5ec1e2b..d1f040ec180852f8d2abacbefd5c1ebd1cdae0e1 100644 (file)
@@ -31,6 +31,8 @@ DECLARE_REF(eDVBVideo);
 private:
        ePtr<eDVBDemux> m_demux;
        int m_fd, m_fd_demux;
+       
+       int m_is_slow_motion, m_is_fast_forward;
 public:
        eDVBVideo(eDVBDemux *demux, int dev);
        int startPid(int pid);
@@ -41,6 +43,8 @@ public:
 #endif
        void flush();
        void freeze();
+       int setSlowMotion(int repeat);
+       int setFastForward(int skip);
        void unfreeze();
        virtual ~eDVBVideo();
 };
@@ -91,6 +95,7 @@ public:
        RESULT unfreeze();
        RESULT setSinglePictureMode(int when);
        RESULT setPictureSkipMode(int what);
+       RESULT setFastForward(int frames_to_skip);
        RESULT setSlowMotion(int repeat);
        RESULT setZoom(int what);
        RESULT flush();
index 742a3a32cca0bfefd1be9bc6cf8761dfb35e40d8..460806a2e74e33756bb207a84eccc25c62d65be1 100644 (file)
@@ -474,6 +474,9 @@ public:
                /** Continue after freeze. */
        virtual RESULT unfreeze()=0;
        
+               /** fast forward by skipping frames. 0 is disabled, 2 is twice-the-speed, ... */
+       virtual RESULT setFastForward(int skip=0)=0;
+       
                // stop on .. Picture
        enum { spm_I, spm_Ref, spm_Any };
                /** Stop on specific decoded picture. For I-Frame display. */
index 4ec12153d308462f53494d6cc86da557e528e148..eb04eaddb2230b769555ea6845a6e6dd8eb31e17 100644 (file)
@@ -241,6 +241,10 @@ class iPauseableService: public iObject
 public:
        virtual RESULT pause()=0;
        virtual RESULT unpause()=0;
+       
+               /* hm. */
+       virtual RESULT setSlowMotion(int ratio=0)=0;
+       virtual RESULT setFastForward(int ratio=0)=0;
 };
 
 TEMPLATE_TYPEDEF(ePtr<iPauseableService>, iPauseableServicePtr);
index 307fb9f5fc8b8cd490d8613d23e112675d4fcafb..b3c157389d540f29aba9629af831647c37d1cf88 100644 (file)
@@ -629,6 +629,22 @@ RESULT eDVBServicePlay::pause(ePtr<iPauseableService> &ptr)
        return -1;
 }
 
+RESULT eDVBServicePlay::setSlowMotion(int ratio)
+{
+       if (m_decoder)
+               return m_decoder->setSlowMotion(ratio);
+       else
+               return -1;
+}
+
+RESULT eDVBServicePlay::setFastForward(int ratio)
+{
+       if (m_decoder)
+               m_decoder->setFastForward(ratio);
+       else
+               return -1;
+}
+    
 RESULT eDVBServicePlay::seek(ePtr<iSeekableService> &ptr)
 {
        if (m_is_pvr)
index 5f851357413b785b2b887c041546e0ba4036f986..6b93469dc837cbf15a0b77ea2fb51c11e775bf22 100644 (file)
@@ -75,7 +75,9 @@ public:
                // iPauseableService
        RESULT pause();
        RESULT unpause();
-       
+       RESULT setSlowMotion(int ratio);
+       RESULT setFastForward(int ratio);
+       
                // iSeekableService
        RESULT getLength(pts_t &len);
        RESULT seekTo(pts_t to);
index 7bd4244f8b284e830dde243866d18038d9f01d56..27a010fb62b0c16d08ad5cabe965c04e17a4a78f 100644 (file)
@@ -152,6 +152,16 @@ RESULT eServiceMP3::pause(ePtr<iPauseableService> &ptr)
        return 0;
 }
 
+RESULT eServiceMP3::setSlowMotion(int ratio)
+{
+       return -1;
+}
+
+RESULT eServiceMP3::setFastForward(int ratio)
+{
+       return -1;
+}
+  
                // iPausableService
 RESULT eServiceMP3::pause()
 {
index dfdaa44c665e96be4924078ba10f4c0f8e949ded..ac174c4121449c5ed90240137308c1761f83c9ef 100644 (file)
@@ -56,6 +56,9 @@ public:
        RESULT start();
        RESULT stop();
        RESULT pause(ePtr<iPauseableService> &ptr);
+       RESULT setSlowMotion(int ratio);
+       RESULT setFastForward(int ratio);
+
                // not implemented (yet)
        RESULT seek(ePtr<iSeekableService> &ptr) { ptr = 0; return -1; }
        RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr) { ptr = 0; return -1; }