20 #define PTSINDEX_ENTRIES 500 36 void Put(uint32_t Pts,
int Index);
73 uint32_t Delta = 0xFFFFFFFF;
75 for (
int i =
w; i !=
r; ) {
108 int Result(
uchar **Buffer);
110 bool WaitForDataMs(
int msToWait);
114 :
cThread(
"non blocking file reader")
200 #define PLAYERBUFSIZE MEGABYTE(1) 202 #define RESUMEBACKUP 10 // number of seconds to back up when resuming an interrupted replay session 203 #define MAXSTUCKATEOF 3 // max. number of seconds to wait in case the device doesn't play the last frame 207 enum ePlayModes { pmPlay, pmPause, pmSlow, pmFast, pmStill };
231 void TrickSpeed(
int Increment);
233 bool NextFile(uint16_t FileNumber = 0, off_t FileOffset = -1);
237 virtual void Activate(
bool On);
238 virtual void Action(
void);
240 cDvbPlayer(
const char *FileName,
bool PauseLive);
242 void SetMarks(
cMarks *Marks);
248 int SkipFrames(
int Frames);
249 void SkipSeconds(
int Seconds);
250 void Goto(
int Position,
bool Still =
false);
253 virtual bool GetIndex(
int &Current,
int &Total,
bool SnapToIFrame =
false);
254 virtual bool GetReplayMode(
bool &Play,
bool &Forward,
int &Speed);
257 #define MAX_VIDEO_SLOWMOTION 63 // max. arg to pass to VIDEO_SLOWMOTION // TODO is this value correct? 258 #define NORMAL_SPEED 4 // the index of the '1' entry in the following array 259 #define MAX_SPEEDS 3 // the offset of the maximum speed from normal speed in either direction 260 #define SPEED_MULT 12 // the speed multiplier 285 isyslog(
"replay %s", FileName);
294 esyslog(
"ERROR: can't allocate index");
373 if (
index->
Get(Index, &FileNumber, &FileOffset) &&
NextFile(FileNumber, FileOffset))
427 if (
index->
Get(Index, &FileNumber, &FileOffset) &&
NextFile(FileNumber, FileOffset)) {
438 bool WaitingForData =
false;
439 time_t StuckAtEof = 0;
440 uint32_t LastStc = 0;
441 int LastReadIFrame = -1;
442 int SwitchToPlayFrame = 0;
444 bool AtLastMark =
false;
481 if (NewIndex <= 0 && readIndex > 0)
491 if (!
NextFile(FileNumber, FileOffset))
505 if (m && (m->
Index() & 0x01) != 0) {
543 WaitingForData =
false;
553 WaitingForData =
true;
622 w =
PlayTs(p, pc, VideoOnly);
652 if (
eof || SwitchToPlayFrame) {
653 bool SwitchToPlay =
false;
657 else if (!StuckAtEof)
658 StuckAtEof = time(NULL);
667 if (Index >= LastReadIFrame)
670 else if (Index <= 0 || SwitchToPlayFrame && Index >= SwitchToPlayFrame)
673 if (!SwitchToPlayFrame)
678 SwitchToPlayFrame = 0;
769 default:
esyslog(
"ERROR: unknown playMode %d (%s)",
playMode, __FUNCTION__);
821 default:
esyslog(
"ERROR: unknown playMode %d (%s)",
playMode, __FUNCTION__);
828 if (
index && Frames) {
831 int OldCurrent = Current;
836 return Current >= 0 ? Current : OldCurrent;
843 if (
index && Seconds) {
871 if (
NextFile(FileNumber, FileOffset)) {
914 Current = (abs(Current - i1) <= abs(Current - i2)) ? i1 : i2;
919 Current = Total = -1;
int FindIndex(uint32_t Pts)
cRingBufferFrame * ringBuffer
virtual void Activate(bool On)
double FramesPerSecond(void) const
ssize_t Read(void *Data, size_t Size)
cMark * GetNextBegin(cMark *EndMark=NULL)
Returns the next "begin" mark after EndMark, skipping any marks at the same position as EndMark...
cUnbufferedFile * SetOffset(int Number, off_t Offset=0)
void Signal(void)
Signals a caller of Wait() that the condition it is waiting for is met.
int64_t PesGetPts(const uchar *p)
int GetNextIFrame(int Index, bool Forward, uint16_t *FileNumber=NULL, off_t *FileOffset=NULL, int *Length=NULL)
cNonBlockingFileReader * nonBlockingFileReader
void Goto(int Position, bool Still=false)
void SetMarks(cMarks *Marks)
void SkipSeconds(int Seconds)
static tThreadId IsMainThread(void)
cUnbufferedFile * NextFile(void)
int ReadFrame(cUnbufferedFile *f, uchar *b, int Length, int Max)
tPtsIndex pi[PTSINDEX_ENTRIES]
int Last(void)
Returns the index of the last entry in this file, or -1 if the file is empty.
virtual bool GetIndex(int &Current, int &Total, bool SnapToIFrame=false)
cNonBlockingFileReader(void)
int PlayPes(const uchar *Data, int Length, bool VideoOnly=false)
virtual void Action(void)
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
cUnbufferedFile is used for large files that are mainly written or read in a streaming manner...
bool DeviceHasIBPTrickSpeed(void)
void Action(void)
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
cString IndexToHMSF(int Index, bool WithFrame, double FramesPerSecond)
virtual double FramesPerSecond(void)
virtual ~cDvbPlayerControl()
cDvbPlayerControl(const char *FileName, bool PauseLive=false)
virtual bool GetReplayMode(bool &Play, bool &Forward, int &Speed)
int Result(uchar **Buffer)
bool NextFile(uint16_t FileNumber=0, off_t FileOffset=-1)
void DeviceStillPicture(const uchar *Data, int Length)
static void SleepMs(int TimeoutMs)
Creates a cCondWait object and uses it to sleep for TimeoutMs milliseconds, immediately giving up the...
void bool Start(void)
Sets the description of this thread, which will be used when logging starting or stopping of the thre...
cDvbPlayer(const char *FileName, bool PauseLive)
cUnbufferedFile * Open(void)
void SetMarks(cMarks *Marks)
bool Running(void)
Returns false if a derived cThread object shall leave its Action() function.
bool Wait(int TimeoutMs=0)
Waits at most TimeoutMs milliseconds for a call to Signal(), or forever if TimeoutMs is 0...
bool TimedWait(cMutex &Mutex, int TimeoutMs)
void Request(cUnbufferedFile *File, int Length)
bool GetIndex(int &Current, int &Total, bool SnapToIFrame=false)
virtual void SetAudioTrack(eTrackType Type, const tTrackId *TrackId)
bool StoreResume(int Index)
bool DevicePoll(cPoller &Poller, int TimeoutMs=0)
bool GetReplayMode(bool &Play, bool &Forward, int &Speed)
static void SetBrokenLink(uchar *Data, int Length)
bool DeviceIsPlayingVideo(void)
void Put(uint32_t Pts, int Index)
int PlayTs(const uchar *Data, int Length, bool VideoOnly=false)
void DeviceTrickSpeed(int Speed, bool Forward)
uint64_t DeviceGetSTC(void)
cMark * Get(int Position)
int64_t TsGetPts(const uchar *p, int l)
int SecondsToFrames(int Seconds, double FramesPerSecond)
bool WaitForDataMs(int msToWait)
bool Get(int Index, uint16_t *FileNumber, off_t *FileOffset, bool *Independent=NULL, int *Length=NULL)
bool IsStillRecording(void)
void Goto(int Index, bool Still=false)
int SkipFrames(int Frames)
#define MAX_VIDEO_SLOWMOTION
~cNonBlockingFileReader()
int SkipFrames(int Frames)
void Cancel(int WaitSeconds=0)
Cancels the thread by first setting 'running' to false, so that the Action() loop can finish in an or...
void SkipSeconds(int Seconds)
void TrickSpeed(int Increment)
bool IsPesRecording(void) const
cUnbufferedFile * replayFile