diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2000-07-30 14:34:07 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2000-07-30 14:34:07 +0200 |
commit | f8b74033666f89b7f87c06ba8832e5255092e631 (patch) | |
tree | 3da7430cf87bc7672f13564a085ad6fb4eedb359 /dvbapi.c | |
parent | 5591027638f8541910fccb2db8bc91e84644c5ae (diff) | |
download | vdr-f8b74033666f89b7f87c06ba8832e5255092e631.tar.gz vdr-f8b74033666f89b7f87c06ba8832e5255092e631.tar.bz2 |
Slow forward/back mode
Diffstat (limited to 'dvbapi.c')
-rw-r--r-- | dvbapi.c | 45 |
1 files changed, 34 insertions, 11 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: dvbapi.c 1.17 2000/07/29 19:00:19 kls Exp $ + * $Id: dvbapi.c 1.18 2000/07/30 14:34:07 kls Exp $ */ #include "dvbapi.h" @@ -345,7 +345,7 @@ protected: int Free(void) { return ((tail >= head) ? size + head - tail : head - tail) - 1; } int Available(void) { return (tail >= head) ? tail - head : size - head + tail; } int Readable(void) { return (tail >= head) ? size - tail - (head ? 0 : 1) : head - tail - 1; } // keep a 1 byte gap! - int Writeable(void) { return (tail > head) ? tail - head : size - head; } + int Writeable(void) { return (tail >= head) ? tail - head : size - head; } int Byte(int Offset); bool WaitForOutFile(int Timeout); public: @@ -803,7 +803,7 @@ int cRecordBuffer::WriteWithTimeout(bool EndIfEmpty) // --- cReplayBuffer --------------------------------------------------------- -enum eReplayMode { rmPlay, rmFastForward, rmFastRewind }; +enum eReplayMode { rmPlay, rmFastForward, rmFastRewind, rmSlowRewind }; class cReplayBuffer : public cFileBuffer { private: @@ -812,6 +812,7 @@ private: eReplayMode mode; bool skipAudio; int lastIndex; + int brakeCounter; void SkipAudioBlocks(void); bool NextFile(uchar FileNumber = 0, int FileOffset = -1); void Close(void); @@ -833,6 +834,7 @@ cReplayBuffer::cReplayBuffer(int *OutFile, const char *FileName) fileOffset = 0; replayFile = -1; mode = rmPlay; + brakeCounter = 0; skipAudio = false; lastIndex = -1; if (!fileName) @@ -863,6 +865,7 @@ void cReplayBuffer::SetMode(eReplayMode Mode) { mode = Mode; skipAudio = Mode != rmPlay; + brakeCounter = 0; if (mode != rmPlay) Clear(); } @@ -996,6 +999,10 @@ int cReplayBuffer::Read(int Max = -1) if (Index >= 0) { uchar FileNumber; int FileOffset, Length; + if (mode == rmSlowRewind && (brakeCounter++ % 24) != 0) { + // show every I_FRAME 24 times in rmSlowRewind mode to achieve roughly the same speed as in slow forward mode + Index = index->GetNextIFrame(Index, true, &FileNumber, &FileOffset, &Length); //springe eine Frame vorwärts! + } Index = index->GetNextIFrame(Index, mode == rmFastForward, &FileNumber, &FileOffset, &Length); if (Index >= 0) { if (!NextFile(FileNumber, FileOffset)) @@ -1601,18 +1608,34 @@ bool cDvbApi::StartReplay(const char *FileName, const char *Title) Buffer->SetMode(rmPlay); break; case dvbFastForward: SetReplayMode(VID_PLAY_CLEAR_BUFFER); - SetReplayMode(VID_PLAY_NORMAL); - FastForward = !FastForward; - FastRewind = Paused = false; Buffer->Clear(); - Buffer->SetMode(FastForward ? rmFastForward : rmPlay); + FastForward = !FastForward; + FastRewind = false; + if (Paused) { + Buffer->SetMode(rmPlay); + Buffer->Read(); + SetReplayMode(FastForward ? VID_PLAY_SLOW_MOTION : VID_PLAY_PAUSE); + Buffer->Write(); + } + else { + SetReplayMode(VID_PLAY_NORMAL); + Buffer->SetMode(FastForward ? rmFastForward : rmPlay); + } break; case dvbFastRewind: SetReplayMode(VID_PLAY_CLEAR_BUFFER); - SetReplayMode(VID_PLAY_NORMAL); - FastRewind = !FastRewind; - FastForward = Paused = false; Buffer->Clear(); - Buffer->SetMode(FastRewind ? rmFastRewind : rmPlay); + FastRewind = !FastRewind; + FastForward = false; + if (Paused) { + Buffer->SetMode(FastRewind ? rmSlowRewind : rmPlay); + Buffer->Read(); + SetReplayMode(FastRewind ? VID_PLAY_NORMAL : VID_PLAY_PAUSE); + Buffer->Write(); + } + else { + SetReplayMode(VID_PLAY_NORMAL); + Buffer->SetMode(FastRewind ? rmFastRewind : rmPlay); + } break; case dvbSkip: { int Seconds; |