2002-06-16 12:57:31 +02:00
|
|
|
/*
|
|
|
|
* dvbplayer.c: The DVB player
|
|
|
|
*
|
|
|
|
* See the main source file 'vdr.c' for copyright information and
|
|
|
|
* how to reach the author.
|
|
|
|
*
|
2009-05-31 14:12:42 +02:00
|
|
|
* $Id: dvbplayer.c 2.17 2009/05/31 14:12:42 kls Exp $
|
2002-06-16 12:57:31 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "dvbplayer.h"
|
2009-01-24 11:42:24 +01:00
|
|
|
#include <math.h>
|
2002-08-11 10:47:11 +02:00
|
|
|
#include <stdlib.h>
|
2002-06-16 12:57:31 +02:00
|
|
|
#include "recording.h"
|
2003-04-27 09:55:53 +02:00
|
|
|
#include "remux.h"
|
2002-06-16 12:57:31 +02:00
|
|
|
#include "ringbuffer.h"
|
|
|
|
#include "thread.h"
|
2002-08-15 10:13:03 +02:00
|
|
|
#include "tools.h"
|
2002-06-16 12:57:31 +02:00
|
|
|
|
2009-03-13 14:45:12 +01:00
|
|
|
// --- cPtsIndex -------------------------------------------------------------
|
2002-06-16 12:57:31 +02:00
|
|
|
|
2009-04-05 09:08:02 +02:00
|
|
|
#define PTSINDEX_ENTRIES 500
|
2002-06-16 12:57:31 +02:00
|
|
|
|
2009-03-13 14:45:12 +01:00
|
|
|
class cPtsIndex {
|
2002-06-16 12:57:31 +02:00
|
|
|
private:
|
2009-03-13 14:45:12 +01:00
|
|
|
struct tPtsIndex {
|
|
|
|
uint32_t pts; // no need for 33 bit - some devices don't even supply the msb
|
|
|
|
int index;
|
|
|
|
};
|
|
|
|
tPtsIndex pi[PTSINDEX_ENTRIES];
|
|
|
|
int w, r;
|
|
|
|
int lastFound;
|
|
|
|
cMutex mutex;
|
2002-06-16 12:57:31 +02:00
|
|
|
public:
|
2009-03-13 14:45:12 +01:00
|
|
|
cPtsIndex(void);
|
2002-06-16 12:57:31 +02:00
|
|
|
void Clear(void);
|
2009-03-13 14:45:12 +01:00
|
|
|
void Put(uint32_t Pts, int Index);
|
|
|
|
int FindIndex(uint32_t Pts);
|
2002-06-16 12:57:31 +02:00
|
|
|
};
|
|
|
|
|
2009-03-13 14:45:12 +01:00
|
|
|
cPtsIndex::cPtsIndex(void)
|
2002-06-16 12:57:31 +02:00
|
|
|
{
|
2009-03-13 14:45:12 +01:00
|
|
|
lastFound = 0;
|
2002-06-16 12:57:31 +02:00
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
2009-03-13 14:45:12 +01:00
|
|
|
void cPtsIndex::Clear(void)
|
2002-06-16 12:57:31 +02:00
|
|
|
{
|
2009-03-13 14:45:12 +01:00
|
|
|
cMutexLock MutexLock(&mutex);
|
|
|
|
w = r = 0;
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
|
|
|
|
2009-03-13 14:45:12 +01:00
|
|
|
void cPtsIndex::Put(uint32_t Pts, int Index)
|
2002-06-16 12:57:31 +02:00
|
|
|
{
|
2009-03-13 14:45:12 +01:00
|
|
|
cMutexLock MutexLock(&mutex);
|
|
|
|
pi[w].pts = Pts;
|
|
|
|
pi[w].index = Index;
|
|
|
|
w = (w + 1) % PTSINDEX_ENTRIES;
|
|
|
|
if (w == r)
|
|
|
|
r = (r + 1) % PTSINDEX_ENTRIES;
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
|
|
|
|
2009-03-13 14:45:12 +01:00
|
|
|
int cPtsIndex::FindIndex(uint32_t Pts)
|
|
|
|
{
|
|
|
|
cMutexLock MutexLock(&mutex);
|
|
|
|
if (w == r)
|
|
|
|
return lastFound; // list is empty, let's not jump way off the last known position
|
|
|
|
uint32_t Delta = 0xFFFFFFFF;
|
|
|
|
int Index = -1;
|
|
|
|
for (int i = w; i != r; ) {
|
|
|
|
if (--i < 0)
|
|
|
|
i = PTSINDEX_ENTRIES - 1;
|
|
|
|
uint32_t d = pi[i].pts < Pts ? Pts - pi[i].pts : pi[i].pts - Pts;
|
|
|
|
if (d > 0x7FFFFFFF)
|
|
|
|
d = 0xFFFFFFFF - d; // handle rollover
|
|
|
|
if (d < Delta) {
|
|
|
|
Delta = d;
|
|
|
|
Index = pi[i].index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lastFound = Index;
|
|
|
|
return Index;
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
|
|
|
|
2003-01-19 15:43:58 +01:00
|
|
|
// --- cNonBlockingFileReader ------------------------------------------------
|
|
|
|
|
|
|
|
class cNonBlockingFileReader : public cThread {
|
|
|
|
private:
|
2005-10-31 13:14:26 +01:00
|
|
|
cUnbufferedFile *f;
|
2003-01-19 15:43:58 +01:00
|
|
|
uchar *buffer;
|
|
|
|
int wanted;
|
|
|
|
int length;
|
2004-10-16 09:36:28 +02:00
|
|
|
cCondWait newSet;
|
2006-02-19 14:23:17 +01:00
|
|
|
cCondVar newDataCond;
|
|
|
|
cMutex newDataMutex;
|
2003-01-19 15:43:58 +01:00
|
|
|
protected:
|
|
|
|
void Action(void);
|
|
|
|
public:
|
|
|
|
cNonBlockingFileReader(void);
|
|
|
|
~cNonBlockingFileReader();
|
|
|
|
void Clear(void);
|
2009-05-31 14:12:42 +02:00
|
|
|
void Request(cUnbufferedFile *File, int Length);
|
|
|
|
int Result(uchar **Buffer);
|
2003-01-19 15:43:58 +01:00
|
|
|
bool Reading(void) { return buffer; }
|
2006-02-19 14:23:17 +01:00
|
|
|
bool WaitForDataMs(int msToWait);
|
2003-01-19 15:43:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
cNonBlockingFileReader::cNonBlockingFileReader(void)
|
2003-10-18 12:29:08 +02:00
|
|
|
:cThread("non blocking file reader")
|
2003-01-19 15:43:58 +01:00
|
|
|
{
|
2005-10-31 13:14:26 +01:00
|
|
|
f = NULL;
|
2003-01-19 15:43:58 +01:00
|
|
|
buffer = NULL;
|
|
|
|
wanted = length = 0;
|
|
|
|
Start();
|
|
|
|
}
|
|
|
|
|
|
|
|
cNonBlockingFileReader::~cNonBlockingFileReader()
|
|
|
|
{
|
2004-10-16 09:36:28 +02:00
|
|
|
newSet.Signal();
|
2003-01-19 15:43:58 +01:00
|
|
|
Cancel(3);
|
|
|
|
free(buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cNonBlockingFileReader::Clear(void)
|
|
|
|
{
|
2004-10-16 09:36:28 +02:00
|
|
|
Lock();
|
2005-10-31 13:14:26 +01:00
|
|
|
f = NULL;
|
2003-05-24 09:10:07 +02:00
|
|
|
free(buffer);
|
2003-01-19 15:43:58 +01:00
|
|
|
buffer = NULL;
|
|
|
|
wanted = length = 0;
|
2009-05-31 14:12:42 +02:00
|
|
|
Unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cNonBlockingFileReader::Request(cUnbufferedFile *File, int Length)
|
|
|
|
{
|
|
|
|
Lock();
|
|
|
|
Clear();
|
|
|
|
wanted = Length;
|
|
|
|
buffer = MALLOC(uchar, wanted);
|
|
|
|
f = File;
|
2004-10-16 09:36:28 +02:00
|
|
|
Unlock();
|
|
|
|
newSet.Signal();
|
2003-01-19 15:43:58 +01:00
|
|
|
}
|
|
|
|
|
2009-05-31 14:12:42 +02:00
|
|
|
int cNonBlockingFileReader::Result(uchar **Buffer)
|
2003-01-19 15:43:58 +01:00
|
|
|
{
|
2009-05-31 14:12:42 +02:00
|
|
|
LOCK_THREAD;
|
|
|
|
if (buffer && length == wanted) {
|
|
|
|
*Buffer = buffer;
|
2003-01-19 15:43:58 +01:00
|
|
|
buffer = NULL;
|
2009-05-31 14:12:42 +02:00
|
|
|
return wanted;
|
2003-01-19 15:43:58 +01:00
|
|
|
}
|
|
|
|
errno = EAGAIN;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cNonBlockingFileReader::Action(void)
|
|
|
|
{
|
2005-08-14 11:24:57 +02:00
|
|
|
while (Running()) {
|
2004-10-16 09:36:28 +02:00
|
|
|
Lock();
|
2009-05-31 14:12:42 +02:00
|
|
|
if (f && buffer && length < wanted) {
|
2005-10-31 13:14:26 +01:00
|
|
|
int r = f->Read(buffer + length, wanted - length);
|
2009-05-31 14:12:42 +02:00
|
|
|
if (r > 0)
|
2003-01-19 15:43:58 +01:00
|
|
|
length += r;
|
2009-05-31 14:12:42 +02:00
|
|
|
else if (r == 0) { // r == 0 means EOF
|
|
|
|
if (length > 0)
|
|
|
|
wanted = length; // already read something, so return the rest
|
|
|
|
else
|
|
|
|
length = wanted = 0; // report EOF
|
2003-01-19 15:43:58 +01:00
|
|
|
}
|
2009-05-31 14:12:42 +02:00
|
|
|
else if (FATALERRNO) {
|
2003-01-19 15:43:58 +01:00
|
|
|
LOG_ERROR;
|
2009-05-31 14:12:42 +02:00
|
|
|
length = wanted = r; // this will forward the error status to the caller
|
|
|
|
}
|
|
|
|
if (length == wanted) {
|
|
|
|
cMutexLock NewDataLock(&newDataMutex);
|
|
|
|
newDataCond.Broadcast();
|
2003-01-19 15:43:58 +01:00
|
|
|
}
|
|
|
|
}
|
2004-10-16 09:36:28 +02:00
|
|
|
Unlock();
|
|
|
|
newSet.Wait(1000);
|
2003-01-19 15:43:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-19 14:23:17 +01:00
|
|
|
bool cNonBlockingFileReader::WaitForDataMs(int msToWait)
|
|
|
|
{
|
|
|
|
cMutexLock NewDataLock(&newDataMutex);
|
2009-05-31 14:12:42 +02:00
|
|
|
if (buffer && length == wanted)
|
2006-02-19 14:23:17 +01:00
|
|
|
return true;
|
|
|
|
return newDataCond.TimedWait(newDataMutex, msToWait);
|
|
|
|
}
|
|
|
|
|
2002-06-16 12:57:31 +02:00
|
|
|
// --- cDvbPlayer ------------------------------------------------------------
|
|
|
|
|
2004-10-16 09:36:28 +02:00
|
|
|
#define PLAYERBUFSIZE MEGABYTE(1)
|
2002-06-16 12:57:31 +02:00
|
|
|
|
2009-03-13 14:45:12 +01:00
|
|
|
#define RESUMEBACKUP 10 // number of seconds to back up when resuming an interrupted replay session
|
2009-04-05 09:08:02 +02:00
|
|
|
#define MAXSTUCKATEOF 3 // max. number of seconds to wait in case the device doesn't play the last frame
|
2002-06-16 12:57:31 +02:00
|
|
|
|
|
|
|
class cDvbPlayer : public cPlayer, cThread {
|
|
|
|
private:
|
|
|
|
enum ePlayModes { pmPlay, pmPause, pmSlow, pmFast, pmStill };
|
|
|
|
enum ePlayDirs { pdForward, pdBackward };
|
|
|
|
static int Speeds[];
|
2003-01-19 15:43:58 +01:00
|
|
|
cNonBlockingFileReader *nonBlockingFileReader;
|
2002-06-16 12:57:31 +02:00
|
|
|
cRingBufferFrame *ringBuffer;
|
2009-03-13 14:45:12 +01:00
|
|
|
cPtsIndex ptsIndex;
|
2002-06-16 12:57:31 +02:00
|
|
|
cFileName *fileName;
|
|
|
|
cIndexFile *index;
|
2005-10-31 13:14:26 +01:00
|
|
|
cUnbufferedFile *replayFile;
|
2009-01-06 14:41:11 +01:00
|
|
|
double framesPerSecond;
|
|
|
|
bool isPesRecording;
|
2002-06-16 12:57:31 +02:00
|
|
|
bool eof;
|
2003-04-27 09:55:53 +02:00
|
|
|
bool firstPacket;
|
2002-06-16 12:57:31 +02:00
|
|
|
ePlayModes playMode;
|
|
|
|
ePlayDirs playDir;
|
|
|
|
int trickSpeed;
|
2009-03-13 14:45:12 +01:00
|
|
|
int readIndex;
|
|
|
|
bool readIndependent;
|
2002-06-16 12:57:31 +02:00
|
|
|
cFrame *readFrame;
|
2003-04-27 09:55:53 +02:00
|
|
|
cFrame *playFrame;
|
2002-06-16 12:57:31 +02:00
|
|
|
void TrickSpeed(int Increment);
|
|
|
|
void Empty(void);
|
2009-03-28 17:14:53 +01:00
|
|
|
bool NextFile(uint16_t FileNumber = 0, off_t FileOffset = -1);
|
2002-06-16 12:57:31 +02:00
|
|
|
int Resume(void);
|
|
|
|
bool Save(void);
|
|
|
|
protected:
|
|
|
|
virtual void Activate(bool On);
|
|
|
|
virtual void Action(void);
|
|
|
|
public:
|
|
|
|
cDvbPlayer(const char *FileName);
|
|
|
|
virtual ~cDvbPlayer();
|
2005-08-14 11:24:57 +02:00
|
|
|
bool Active(void) { return cThread::Running(); }
|
2002-06-16 12:57:31 +02:00
|
|
|
void Pause(void);
|
|
|
|
void Play(void);
|
|
|
|
void Forward(void);
|
|
|
|
void Backward(void);
|
|
|
|
int SkipFrames(int Frames);
|
|
|
|
void SkipSeconds(int Seconds);
|
|
|
|
void Goto(int Position, bool Still = false);
|
2009-01-06 14:41:11 +01:00
|
|
|
virtual double FramesPerSecond(void) { return framesPerSecond; }
|
2002-07-13 11:16:27 +02:00
|
|
|
virtual bool GetIndex(int &Current, int &Total, bool SnapToIFrame = false);
|
|
|
|
virtual bool GetReplayMode(bool &Play, bool &Forward, int &Speed);
|
2002-06-16 12:57:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#define MAX_VIDEO_SLOWMOTION 63 // max. arg to pass to VIDEO_SLOWMOTION // TODO is this value correct?
|
|
|
|
#define NORMAL_SPEED 4 // the index of the '1' entry in the following array
|
|
|
|
#define MAX_SPEEDS 3 // the offset of the maximum speed from normal speed in either direction
|
|
|
|
#define SPEED_MULT 12 // the speed multiplier
|
|
|
|
int cDvbPlayer::Speeds[] = { 0, -2, -4, -8, 1, 2, 4, 12, 0 };
|
|
|
|
|
|
|
|
cDvbPlayer::cDvbPlayer(const char *FileName)
|
2003-10-18 12:29:08 +02:00
|
|
|
:cThread("dvbplayer")
|
2002-06-16 12:57:31 +02:00
|
|
|
{
|
2003-01-19 15:43:58 +01:00
|
|
|
nonBlockingFileReader = NULL;
|
2002-06-16 12:57:31 +02:00
|
|
|
ringBuffer = NULL;
|
|
|
|
index = NULL;
|
2009-01-06 14:41:11 +01:00
|
|
|
cRecording Recording(FileName);
|
|
|
|
framesPerSecond = Recording.FramesPerSecond();
|
|
|
|
isPesRecording = Recording.IsPesRecording();
|
2002-06-16 12:57:31 +02:00
|
|
|
eof = false;
|
2003-04-27 09:55:53 +02:00
|
|
|
firstPacket = true;
|
2002-06-16 12:57:31 +02:00
|
|
|
playMode = pmPlay;
|
|
|
|
playDir = pdForward;
|
|
|
|
trickSpeed = NORMAL_SPEED;
|
2009-03-13 14:45:12 +01:00
|
|
|
readIndex = -1;
|
|
|
|
readIndependent = false;
|
2002-06-16 12:57:31 +02:00
|
|
|
readFrame = NULL;
|
|
|
|
playFrame = NULL;
|
|
|
|
isyslog("replay %s", FileName);
|
2009-01-06 14:41:11 +01:00
|
|
|
fileName = new cFileName(FileName, false, false, isPesRecording);
|
2002-06-16 12:57:31 +02:00
|
|
|
replayFile = fileName->Open();
|
2005-10-31 13:14:26 +01:00
|
|
|
if (!replayFile)
|
2002-06-16 12:57:31 +02:00
|
|
|
return;
|
2004-10-16 09:36:28 +02:00
|
|
|
ringBuffer = new cRingBufferFrame(PLAYERBUFSIZE);
|
2002-06-16 12:57:31 +02:00
|
|
|
// Create the index file:
|
2009-01-06 14:41:11 +01:00
|
|
|
index = new cIndexFile(FileName, false, isPesRecording);
|
2002-06-16 12:57:31 +02:00
|
|
|
if (!index)
|
|
|
|
esyslog("ERROR: can't allocate index");
|
|
|
|
else if (!index->Ok()) {
|
|
|
|
delete index;
|
|
|
|
index = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cDvbPlayer::~cDvbPlayer()
|
|
|
|
{
|
|
|
|
Save();
|
2009-03-13 14:45:12 +01:00
|
|
|
Detach();
|
2005-05-05 12:53:43 +02:00
|
|
|
delete readFrame; // might not have been stored in the buffer in Action()
|
2002-06-16 12:57:31 +02:00
|
|
|
delete index;
|
|
|
|
delete fileName;
|
|
|
|
delete ringBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDvbPlayer::TrickSpeed(int Increment)
|
|
|
|
{
|
|
|
|
int nts = trickSpeed + Increment;
|
|
|
|
if (Speeds[nts] == 1) {
|
|
|
|
trickSpeed = nts;
|
|
|
|
if (playMode == pmFast)
|
|
|
|
Play();
|
|
|
|
else
|
|
|
|
Pause();
|
|
|
|
}
|
|
|
|
else if (Speeds[nts]) {
|
|
|
|
trickSpeed = nts;
|
|
|
|
int Mult = (playMode == pmSlow && playDir == pdForward) ? 1 : SPEED_MULT;
|
|
|
|
int sp = (Speeds[nts] > 0) ? Mult / Speeds[nts] : -Speeds[nts] * Mult;
|
|
|
|
if (sp > MAX_VIDEO_SLOWMOTION)
|
|
|
|
sp = MAX_VIDEO_SLOWMOTION;
|
|
|
|
DeviceTrickSpeed(sp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDvbPlayer::Empty(void)
|
|
|
|
{
|
2003-01-19 15:43:58 +01:00
|
|
|
LOCK_THREAD;
|
|
|
|
if (nonBlockingFileReader)
|
|
|
|
nonBlockingFileReader->Clear();
|
2009-03-13 14:45:12 +01:00
|
|
|
if (!firstPacket) // don't set the readIndex twice if Empty() is called more than once
|
2009-04-19 15:17:17 +02:00
|
|
|
readIndex = ptsIndex.FindIndex(DeviceGetSTC()) - 1; // Action() will first increment it!
|
2005-05-05 12:53:43 +02:00
|
|
|
delete readFrame; // might not have been stored in the buffer in Action()
|
2002-06-16 12:57:31 +02:00
|
|
|
readFrame = NULL;
|
|
|
|
playFrame = NULL;
|
|
|
|
ringBuffer->Clear();
|
2009-03-13 14:45:12 +01:00
|
|
|
ptsIndex.Clear();
|
2002-06-16 12:57:31 +02:00
|
|
|
DeviceClear();
|
2003-04-27 09:55:53 +02:00
|
|
|
firstPacket = true;
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
|
|
|
|
2009-03-28 17:14:53 +01:00
|
|
|
bool cDvbPlayer::NextFile(uint16_t FileNumber, off_t FileOffset)
|
2002-06-16 12:57:31 +02:00
|
|
|
{
|
|
|
|
if (FileNumber > 0)
|
|
|
|
replayFile = fileName->SetOffset(FileNumber, FileOffset);
|
2005-10-31 13:14:26 +01:00
|
|
|
else if (replayFile && eof)
|
2002-06-16 12:57:31 +02:00
|
|
|
replayFile = fileName->NextFile();
|
|
|
|
eof = false;
|
2005-10-31 13:14:26 +01:00
|
|
|
return replayFile != NULL;
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int cDvbPlayer::Resume(void)
|
|
|
|
{
|
|
|
|
if (index) {
|
|
|
|
int Index = index->GetResume();
|
|
|
|
if (Index >= 0) {
|
2009-01-06 14:41:11 +01:00
|
|
|
uint16_t FileNumber;
|
|
|
|
off_t FileOffset;
|
2002-06-16 12:57:31 +02:00
|
|
|
if (index->Get(Index, &FileNumber, &FileOffset) && NextFile(FileNumber, FileOffset))
|
|
|
|
return Index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cDvbPlayer::Save(void)
|
|
|
|
{
|
|
|
|
if (index) {
|
2009-03-13 14:45:12 +01:00
|
|
|
int Index = ptsIndex.FindIndex(DeviceGetSTC());
|
2002-06-16 12:57:31 +02:00
|
|
|
if (Index >= 0) {
|
2009-01-24 11:42:24 +01:00
|
|
|
Index -= int(round(RESUMEBACKUP * framesPerSecond));
|
2002-06-16 12:57:31 +02:00
|
|
|
if (Index > 0)
|
|
|
|
Index = index->GetNextIFrame(Index, false);
|
|
|
|
else
|
|
|
|
Index = 0;
|
|
|
|
if (Index >= 0)
|
|
|
|
return index->StoreResume(Index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDvbPlayer::Activate(bool On)
|
|
|
|
{
|
|
|
|
if (On) {
|
2005-10-31 13:14:26 +01:00
|
|
|
if (replayFile)
|
2002-06-16 12:57:31 +02:00
|
|
|
Start();
|
|
|
|
}
|
2005-08-13 13:17:24 +02:00
|
|
|
else
|
2005-05-22 11:29:19 +02:00
|
|
|
Cancel(9);
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cDvbPlayer::Action(void)
|
|
|
|
{
|
2003-04-27 09:55:53 +02:00
|
|
|
uchar *p = NULL;
|
2002-06-16 12:57:31 +02:00
|
|
|
int pc = 0;
|
|
|
|
|
|
|
|
readIndex = Resume();
|
|
|
|
if (readIndex >= 0)
|
2009-01-06 14:41:11 +01:00
|
|
|
isyslog("resuming replay at index %d (%s)", readIndex, *IndexToHMSF(readIndex, true, framesPerSecond));
|
2002-06-16 12:57:31 +02:00
|
|
|
|
2003-01-19 15:43:58 +01:00
|
|
|
nonBlockingFileReader = new cNonBlockingFileReader;
|
|
|
|
int Length = 0;
|
2005-05-08 14:07:00 +02:00
|
|
|
bool Sleep = false;
|
2006-02-19 14:23:17 +01:00
|
|
|
bool WaitingForData = false;
|
2009-04-05 09:08:02 +02:00
|
|
|
time_t StuckAtEof = 0;
|
|
|
|
uint32_t LastStc = 0;
|
|
|
|
int LastReadIFrame = -1;
|
2009-04-05 10:11:26 +02:00
|
|
|
int SwitchToPlayFrame = 0;
|
2003-01-19 15:43:58 +01:00
|
|
|
|
2009-04-18 14:28:15 +02:00
|
|
|
while (Running()) {
|
|
|
|
if (WaitingForData)
|
|
|
|
nonBlockingFileReader->WaitForDataMs(3); // this keeps the CPU load low, but reacts immediately on new data
|
|
|
|
else if (Sleep) {
|
|
|
|
cPoller Poller;
|
|
|
|
DevicePoll(Poller, 10);
|
2005-05-08 14:07:00 +02:00
|
|
|
Sleep = false;
|
|
|
|
}
|
2009-04-18 14:28:15 +02:00
|
|
|
{
|
|
|
|
LOCK_THREAD;
|
|
|
|
|
|
|
|
// Read the next frame from the file:
|
|
|
|
|
|
|
|
if (playMode != pmStill && playMode != pmPause) {
|
|
|
|
if (!readFrame && (replayFile || readIndex >= 0)) {
|
|
|
|
if (!nonBlockingFileReader->Reading()) {
|
|
|
|
if (!SwitchToPlayFrame && (playMode == pmFast || (playMode == pmSlow && playDir == pdBackward))) {
|
|
|
|
uint16_t FileNumber;
|
|
|
|
off_t FileOffset;
|
|
|
|
bool TimeShiftMode = index->IsStillRecording();
|
|
|
|
int Index = -1;
|
|
|
|
readIndependent = false;
|
|
|
|
if (DeviceHasIBPTrickSpeed() && playDir == pdForward) {
|
|
|
|
if (index->Get(readIndex + 1, &FileNumber, &FileOffset, &readIndependent, &Length))
|
|
|
|
Index = readIndex + 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int d = int(round(0.4 * framesPerSecond));
|
|
|
|
if (playDir != pdForward)
|
|
|
|
d = -d;
|
|
|
|
int NewIndex = readIndex + d;
|
|
|
|
if (NewIndex <= 0 && readIndex > 0)
|
|
|
|
NewIndex = 1; // make sure the very first frame is delivered
|
|
|
|
NewIndex = index->GetNextIFrame(NewIndex, playDir == pdForward, &FileNumber, &FileOffset, &Length, TimeShiftMode);
|
|
|
|
if (NewIndex < 0 && TimeShiftMode && playDir == pdForward)
|
|
|
|
SwitchToPlayFrame = Index;
|
|
|
|
Index = NewIndex;
|
|
|
|
readIndependent = true;
|
|
|
|
}
|
|
|
|
if (Index >= 0) {
|
|
|
|
readIndex = Index;
|
|
|
|
if (!NextFile(FileNumber, FileOffset))
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
eof = true;
|
|
|
|
}
|
|
|
|
else if (index) {
|
|
|
|
uint16_t FileNumber;
|
|
|
|
off_t FileOffset;
|
|
|
|
if (index->Get(readIndex + 1, &FileNumber, &FileOffset, &readIndependent, &Length) && NextFile(FileNumber, FileOffset))
|
|
|
|
readIndex++;
|
|
|
|
else
|
|
|
|
eof = true;
|
|
|
|
}
|
|
|
|
else // allows replay even if the index file is missing
|
|
|
|
Length = MAXFRAMESIZE;
|
|
|
|
if (Length == -1)
|
|
|
|
Length = MAXFRAMESIZE; // this means we read up to EOF (see cIndex)
|
|
|
|
else if (Length > MAXFRAMESIZE) {
|
|
|
|
esyslog("ERROR: frame larger than buffer (%d > %d)", Length, MAXFRAMESIZE);
|
|
|
|
Length = MAXFRAMESIZE;
|
|
|
|
}
|
2009-05-31 14:12:42 +02:00
|
|
|
if (!eof)
|
|
|
|
nonBlockingFileReader->Request(replayFile, Length);
|
2009-04-18 14:28:15 +02:00
|
|
|
}
|
2009-05-31 14:12:42 +02:00
|
|
|
if (!eof) {
|
|
|
|
uchar *b = NULL;
|
|
|
|
int r = nonBlockingFileReader->Result(&b);
|
2009-04-18 14:28:15 +02:00
|
|
|
if (r > 0) {
|
|
|
|
WaitingForData = false;
|
|
|
|
uint32_t Pts = 0;
|
|
|
|
if (readIndependent) {
|
|
|
|
Pts = isPesRecording ? PesGetPts(b) : TsGetPts(b, r);
|
|
|
|
LastReadIFrame = readIndex;
|
|
|
|
}
|
|
|
|
readFrame = new cFrame(b, -r, ftUnknown, readIndex, Pts); // hands over b to the ringBuffer
|
|
|
|
}
|
|
|
|
else if (r < 0 && errno == EAGAIN)
|
|
|
|
WaitingForData = true;
|
2009-05-31 10:02:20 +02:00
|
|
|
else {
|
|
|
|
if (r == 0)
|
|
|
|
eof = true;
|
|
|
|
else if (r < 0 && FATALERRNO) {
|
|
|
|
LOG_ERROR;
|
|
|
|
break;
|
|
|
|
}
|
2009-04-18 14:28:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Store the frame in the buffer:
|
|
|
|
|
|
|
|
if (readFrame) {
|
|
|
|
if (ringBuffer->Put(readFrame))
|
|
|
|
readFrame = NULL;
|
|
|
|
else
|
|
|
|
Sleep = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Sleep = true;
|
|
|
|
|
|
|
|
// Get the next frame from the buffer:
|
|
|
|
|
|
|
|
if (!playFrame) {
|
|
|
|
playFrame = ringBuffer->Get();
|
|
|
|
p = NULL;
|
|
|
|
pc = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Play the frame:
|
|
|
|
|
|
|
|
if (playFrame) {
|
|
|
|
if (!p) {
|
|
|
|
p = playFrame->Data();
|
|
|
|
pc = playFrame->Count();
|
|
|
|
if (p) {
|
2009-04-19 15:19:10 +02:00
|
|
|
if (playFrame->Index() >= 0 && playFrame->Pts() != 0)
|
2009-04-18 14:28:15 +02:00
|
|
|
ptsIndex.Put(playFrame->Pts(), playFrame->Index());
|
|
|
|
if (firstPacket) {
|
|
|
|
if (isPesRecording) {
|
|
|
|
PlayPes(NULL, 0);
|
|
|
|
cRemux::SetBrokenLink(p, pc);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
PlayTs(NULL, 0);
|
|
|
|
firstPacket = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (p) {
|
|
|
|
int w;
|
|
|
|
if (isPesRecording)
|
|
|
|
w = PlayPes(p, pc, playMode != pmPlay && !(playMode == pmSlow && playDir == pdForward) && DeviceIsPlayingVideo());
|
|
|
|
else
|
|
|
|
w = PlayTs(p, pc, playMode != pmPlay && !(playMode == pmSlow && playDir == pdForward) && DeviceIsPlayingVideo());
|
|
|
|
if (w > 0) {
|
|
|
|
p += w;
|
|
|
|
pc -= w;
|
|
|
|
}
|
|
|
|
else if (w < 0 && FATALERRNO)
|
|
|
|
LOG_ERROR;
|
|
|
|
else
|
|
|
|
Sleep = true;
|
|
|
|
}
|
|
|
|
if (pc <= 0) {
|
|
|
|
if (!eof || (playDir != pdForward && playFrame->Index() > 0) || (playDir == pdForward && playFrame->Index() < readIndex))
|
|
|
|
ringBuffer->Drop(playFrame); // the very first and last frame are continously repeated to flush data through the device
|
|
|
|
playFrame = NULL;
|
|
|
|
p = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Sleep = true;
|
|
|
|
|
|
|
|
// Handle hitting begin/end of recording:
|
|
|
|
|
|
|
|
if (eof || SwitchToPlayFrame) {
|
|
|
|
bool SwitchToPlay = false;
|
|
|
|
uint32_t Stc = DeviceGetSTC();
|
|
|
|
if (Stc != LastStc)
|
|
|
|
StuckAtEof = 0;
|
|
|
|
else if (!StuckAtEof)
|
|
|
|
StuckAtEof = time(NULL);
|
|
|
|
else if (time(NULL) - StuckAtEof > MAXSTUCKATEOF) {
|
|
|
|
if (playDir == pdForward)
|
|
|
|
break; // automatically stop at end of recording
|
|
|
|
SwitchToPlay = true;
|
|
|
|
}
|
|
|
|
LastStc = Stc;
|
|
|
|
int Index = ptsIndex.FindIndex(Stc);
|
|
|
|
if (playDir == pdForward && !SwitchToPlayFrame) {
|
|
|
|
if (Index >= LastReadIFrame)
|
|
|
|
break; // automatically stop at end of recording
|
|
|
|
}
|
|
|
|
else if (Index <= 0 || SwitchToPlayFrame && Index >= SwitchToPlayFrame)
|
|
|
|
SwitchToPlay = true;
|
|
|
|
if (SwitchToPlay) {
|
|
|
|
if (!SwitchToPlayFrame)
|
|
|
|
Empty();
|
|
|
|
DevicePlay();
|
|
|
|
playMode = pmPlay;
|
|
|
|
playDir = pdForward;
|
|
|
|
SwitchToPlayFrame = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
2009-04-05 12:29:27 +02:00
|
|
|
|
2003-01-19 15:43:58 +01:00
|
|
|
cNonBlockingFileReader *nbfr = nonBlockingFileReader;
|
|
|
|
nonBlockingFileReader = NULL;
|
|
|
|
delete nbfr;
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cDvbPlayer::Pause(void)
|
|
|
|
{
|
|
|
|
if (playMode == pmPause || playMode == pmStill)
|
|
|
|
Play();
|
|
|
|
else {
|
|
|
|
LOCK_THREAD;
|
2008-02-09 15:12:55 +01:00
|
|
|
if (playMode == pmFast || (playMode == pmSlow && playDir == pdBackward)) {
|
|
|
|
if (!(DeviceHasIBPTrickSpeed() && playDir == pdForward))
|
|
|
|
Empty();
|
|
|
|
}
|
2002-06-16 12:57:31 +02:00
|
|
|
DeviceFreeze();
|
|
|
|
playMode = pmPause;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDvbPlayer::Play(void)
|
|
|
|
{
|
|
|
|
if (playMode != pmPlay) {
|
|
|
|
LOCK_THREAD;
|
2008-02-09 15:12:55 +01:00
|
|
|
if (playMode == pmStill || playMode == pmFast || (playMode == pmSlow && playDir == pdBackward)) {
|
|
|
|
if (!(DeviceHasIBPTrickSpeed() && playDir == pdForward))
|
|
|
|
Empty();
|
|
|
|
}
|
2002-06-16 12:57:31 +02:00
|
|
|
DevicePlay();
|
|
|
|
playMode = pmPlay;
|
|
|
|
playDir = pdForward;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDvbPlayer::Forward(void)
|
|
|
|
{
|
|
|
|
if (index) {
|
|
|
|
switch (playMode) {
|
|
|
|
case pmFast:
|
|
|
|
if (Setup.MultiSpeedMode) {
|
|
|
|
TrickSpeed(playDir == pdForward ? 1 : -1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (playDir == pdForward) {
|
|
|
|
Play();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// run into pmPlay
|
|
|
|
case pmPlay: {
|
|
|
|
LOCK_THREAD;
|
2008-02-09 15:12:55 +01:00
|
|
|
if (!(DeviceHasIBPTrickSpeed() && playDir == pdForward))
|
|
|
|
Empty();
|
2009-01-25 11:39:43 +01:00
|
|
|
if (DeviceIsPlayingVideo())
|
|
|
|
DeviceMute();
|
2002-06-16 12:57:31 +02:00
|
|
|
playMode = pmFast;
|
|
|
|
playDir = pdForward;
|
|
|
|
trickSpeed = NORMAL_SPEED;
|
|
|
|
TrickSpeed(Setup.MultiSpeedMode ? 1 : MAX_SPEEDS);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case pmSlow:
|
|
|
|
if (Setup.MultiSpeedMode) {
|
|
|
|
TrickSpeed(playDir == pdForward ? -1 : 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (playDir == pdForward) {
|
|
|
|
Pause();
|
|
|
|
break;
|
|
|
|
}
|
2009-03-13 14:45:12 +01:00
|
|
|
Empty();
|
2002-06-16 12:57:31 +02:00
|
|
|
// run into pmPause
|
|
|
|
case pmStill:
|
|
|
|
case pmPause:
|
|
|
|
DeviceMute();
|
|
|
|
playMode = pmSlow;
|
|
|
|
playDir = pdForward;
|
|
|
|
trickSpeed = NORMAL_SPEED;
|
|
|
|
TrickSpeed(Setup.MultiSpeedMode ? -1 : -MAX_SPEEDS);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDvbPlayer::Backward(void)
|
|
|
|
{
|
|
|
|
if (index) {
|
|
|
|
switch (playMode) {
|
|
|
|
case pmFast:
|
|
|
|
if (Setup.MultiSpeedMode) {
|
|
|
|
TrickSpeed(playDir == pdBackward ? 1 : -1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (playDir == pdBackward) {
|
|
|
|
Play();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// run into pmPlay
|
|
|
|
case pmPlay: {
|
|
|
|
LOCK_THREAD;
|
|
|
|
Empty();
|
2009-01-25 11:39:43 +01:00
|
|
|
if (DeviceIsPlayingVideo())
|
|
|
|
DeviceMute();
|
2002-06-16 12:57:31 +02:00
|
|
|
playMode = pmFast;
|
|
|
|
playDir = pdBackward;
|
|
|
|
trickSpeed = NORMAL_SPEED;
|
|
|
|
TrickSpeed(Setup.MultiSpeedMode ? 1 : MAX_SPEEDS);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case pmSlow:
|
|
|
|
if (Setup.MultiSpeedMode) {
|
|
|
|
TrickSpeed(playDir == pdBackward ? -1 : 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (playDir == pdBackward) {
|
|
|
|
Pause();
|
|
|
|
break;
|
|
|
|
}
|
2009-03-13 14:45:12 +01:00
|
|
|
Empty();
|
2002-06-16 12:57:31 +02:00
|
|
|
// run into pmPause
|
|
|
|
case pmStill:
|
|
|
|
case pmPause: {
|
|
|
|
LOCK_THREAD;
|
|
|
|
Empty();
|
|
|
|
DeviceMute();
|
|
|
|
playMode = pmSlow;
|
|
|
|
playDir = pdBackward;
|
|
|
|
trickSpeed = NORMAL_SPEED;
|
|
|
|
TrickSpeed(Setup.MultiSpeedMode ? -1 : -MAX_SPEEDS);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int cDvbPlayer::SkipFrames(int Frames)
|
|
|
|
{
|
|
|
|
if (index && Frames) {
|
|
|
|
int Current, Total;
|
|
|
|
GetIndex(Current, Total, true);
|
|
|
|
int OldCurrent = Current;
|
2006-01-08 11:44:37 +01:00
|
|
|
// As GetNextIFrame() increments/decrements at least once, the
|
2005-08-29 15:45:38 +02:00
|
|
|
// destination frame (= Current + Frames) must be adjusted by
|
|
|
|
// -1/+1 respectively.
|
|
|
|
Current = index->GetNextIFrame(Current + Frames + (Frames > 0 ? -1 : 1), Frames > 0);
|
2002-06-16 12:57:31 +02:00
|
|
|
return Current >= 0 ? Current : OldCurrent;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDvbPlayer::SkipSeconds(int Seconds)
|
|
|
|
{
|
|
|
|
if (index && Seconds) {
|
|
|
|
LOCK_THREAD;
|
2009-03-13 14:45:12 +01:00
|
|
|
int Index = ptsIndex.FindIndex(DeviceGetSTC());
|
2002-06-16 12:57:31 +02:00
|
|
|
Empty();
|
|
|
|
if (Index >= 0) {
|
2009-01-06 14:41:11 +01:00
|
|
|
Index = max(Index + SecondsToFrames(Seconds, framesPerSecond), 0);
|
2002-06-16 12:57:31 +02:00
|
|
|
if (Index > 0)
|
|
|
|
Index = index->GetNextIFrame(Index, false, NULL, NULL, NULL, true);
|
|
|
|
if (Index >= 0)
|
2009-03-13 14:45:12 +01:00
|
|
|
readIndex = Index - 1; // Action() will first increment it!
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
|
|
|
Play();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDvbPlayer::Goto(int Index, bool Still)
|
|
|
|
{
|
|
|
|
if (index) {
|
|
|
|
LOCK_THREAD;
|
|
|
|
Empty();
|
|
|
|
if (++Index <= 0)
|
|
|
|
Index = 1; // not '0', to allow GetNextIFrame() below to work!
|
2009-01-06 14:41:11 +01:00
|
|
|
uint16_t FileNumber;
|
|
|
|
off_t FileOffset;
|
|
|
|
int Length;
|
2002-06-16 12:57:31 +02:00
|
|
|
Index = index->GetNextIFrame(Index, false, &FileNumber, &FileOffset, &Length);
|
|
|
|
if (Index >= 0 && NextFile(FileNumber, FileOffset) && Still) {
|
2009-01-06 14:41:11 +01:00
|
|
|
uchar b[MAXFRAMESIZE];
|
2002-06-16 12:57:31 +02:00
|
|
|
int r = ReadFrame(replayFile, b, Length, sizeof(b));
|
|
|
|
if (r > 0) {
|
|
|
|
if (playMode == pmPause)
|
|
|
|
DevicePlay();
|
|
|
|
DeviceStillPicture(b, r);
|
2009-03-13 14:45:12 +01:00
|
|
|
ptsIndex.Put(isPesRecording ? PesGetPts(b) : TsGetPts(b, r), Index);
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
|
|
|
playMode = pmStill;
|
|
|
|
}
|
2009-03-13 14:45:12 +01:00
|
|
|
readIndex = Index;
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-13 11:16:27 +02:00
|
|
|
bool cDvbPlayer::GetIndex(int &Current, int &Total, bool SnapToIFrame)
|
2002-06-16 12:57:31 +02:00
|
|
|
{
|
|
|
|
if (index) {
|
2009-03-13 14:45:12 +01:00
|
|
|
Current = ptsIndex.FindIndex(DeviceGetSTC());
|
|
|
|
if (SnapToIFrame) {
|
|
|
|
int i1 = index->GetNextIFrame(Current + 1, false);
|
|
|
|
int i2 = index->GetNextIFrame(Current, true);
|
|
|
|
Current = (abs(Current - i1) <= abs(Current - i2)) ? i1 : i2;
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
|
|
|
Total = index->Last();
|
2002-07-13 11:16:27 +02:00
|
|
|
return true;
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
2002-07-13 11:16:27 +02:00
|
|
|
Current = Total = -1;
|
|
|
|
return false;
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cDvbPlayer::GetReplayMode(bool &Play, bool &Forward, int &Speed)
|
|
|
|
{
|
|
|
|
Play = (playMode == pmPlay || playMode == pmFast);
|
|
|
|
Forward = (playDir == pdForward);
|
|
|
|
if (playMode == pmFast || playMode == pmSlow)
|
|
|
|
Speed = Setup.MultiSpeedMode ? abs(trickSpeed - NORMAL_SPEED) : 0;
|
|
|
|
else
|
|
|
|
Speed = -1;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- cDvbPlayerControl -----------------------------------------------------
|
|
|
|
|
2002-06-23 11:23:34 +02:00
|
|
|
cDvbPlayerControl::cDvbPlayerControl(const char *FileName)
|
|
|
|
:cControl(player = new cDvbPlayer(FileName))
|
2002-06-16 12:57:31 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
cDvbPlayerControl::~cDvbPlayerControl()
|
|
|
|
{
|
|
|
|
Stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cDvbPlayerControl::Active(void)
|
|
|
|
{
|
|
|
|
return player && player->Active();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDvbPlayerControl::Stop(void)
|
|
|
|
{
|
|
|
|
delete player;
|
|
|
|
player = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDvbPlayerControl::Pause(void)
|
|
|
|
{
|
|
|
|
if (player)
|
|
|
|
player->Pause();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDvbPlayerControl::Play(void)
|
|
|
|
{
|
|
|
|
if (player)
|
|
|
|
player->Play();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDvbPlayerControl::Forward(void)
|
|
|
|
{
|
|
|
|
if (player)
|
|
|
|
player->Forward();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDvbPlayerControl::Backward(void)
|
|
|
|
{
|
|
|
|
if (player)
|
|
|
|
player->Backward();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDvbPlayerControl::SkipSeconds(int Seconds)
|
|
|
|
{
|
|
|
|
if (player)
|
|
|
|
player->SkipSeconds(Seconds);
|
|
|
|
}
|
|
|
|
|
|
|
|
int cDvbPlayerControl::SkipFrames(int Frames)
|
|
|
|
{
|
|
|
|
if (player)
|
|
|
|
return player->SkipFrames(Frames);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cDvbPlayerControl::GetIndex(int &Current, int &Total, bool SnapToIFrame)
|
|
|
|
{
|
|
|
|
if (player) {
|
|
|
|
player->GetIndex(Current, Total, SnapToIFrame);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cDvbPlayerControl::GetReplayMode(bool &Play, bool &Forward, int &Speed)
|
|
|
|
{
|
|
|
|
return player && player->GetReplayMode(Play, Forward, Speed);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cDvbPlayerControl::Goto(int Position, bool Still)
|
|
|
|
{
|
|
|
|
if (player)
|
|
|
|
player->Goto(Position, Still);
|
|
|
|
}
|