From: Felix Domke Date: Thu, 8 Dec 2005 00:35:27 +0000 (+0000) Subject: add slowmotion / fast forward X-Git-Tag: 2.6.0~4786 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/cd038ce28d53719a27e7009365dd74fec19357df?ds=sidebyside add slowmotion / fast forward --- diff --git a/lib/dvb/decoder.cpp b/lib/dvb/decoder.cpp index 835f434e..6794a056 100644 --- a/lib/dvb/decoder.cpp +++ b/lib/dvb/decoder.cpp @@ -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) diff --git a/lib/dvb/decoder.h b/lib/dvb/decoder.h index 7bd16fd1..d1f040ec 100644 --- a/lib/dvb/decoder.h +++ b/lib/dvb/decoder.h @@ -31,6 +31,8 @@ DECLARE_REF(eDVBVideo); private: ePtr 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(); diff --git a/lib/dvb/idvb.h b/lib/dvb/idvb.h index 742a3a32..460806a2 100644 --- a/lib/dvb/idvb.h +++ b/lib/dvb/idvb.h @@ -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. */ diff --git a/lib/service/iservice.h b/lib/service/iservice.h index 4ec12153..eb04eadd 100644 --- a/lib/service/iservice.h +++ b/lib/service/iservice.h @@ -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, iPauseableServicePtr); diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp index 307fb9f5..b3c15738 100644 --- a/lib/service/servicedvb.cpp +++ b/lib/service/servicedvb.cpp @@ -629,6 +629,22 @@ RESULT eDVBServicePlay::pause(ePtr &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 &ptr) { if (m_is_pvr) diff --git a/lib/service/servicedvb.h b/lib/service/servicedvb.h index 5f851357..6b93469d 100644 --- a/lib/service/servicedvb.h +++ b/lib/service/servicedvb.h @@ -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); diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp index 7bd4244f..27a010fb 100644 --- a/lib/service/servicemp3.cpp +++ b/lib/service/servicemp3.cpp @@ -152,6 +152,16 @@ RESULT eServiceMP3::pause(ePtr &ptr) return 0; } +RESULT eServiceMP3::setSlowMotion(int ratio) +{ + return -1; +} + +RESULT eServiceMP3::setFastForward(int ratio) +{ + return -1; +} + // iPausableService RESULT eServiceMP3::pause() { diff --git a/lib/service/servicemp3.h b/lib/service/servicemp3.h index dfdaa44c..ac174c41 100644 --- a/lib/service/servicemp3.h +++ b/lib/service/servicemp3.h @@ -56,6 +56,9 @@ public: RESULT start(); RESULT stop(); RESULT pause(ePtr &ptr); + RESULT setSlowMotion(int ratio); + RESULT setFastForward(int ratio); + // not implemented (yet) RESULT seek(ePtr &ptr) { ptr = 0; return -1; } RESULT audioTracks(ePtr &ptr) { ptr = 0; return -1; }