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 835f434..6794a05 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 7bd16fd..d1f040e 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 742a3a3..460806a 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 4ec1215..eb04ead 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 307fb9f..b3c1573 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 5f85135..6b93469 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 7bd4244..27a010f 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 dfdaa44..ac174c4 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; }