Go to the documentation of this file.
20 #define PTSINDEX_ENTRIES 1024
37 void Put(uint32_t Pts,
int Index,
bool Independent);
76 uint32_t Delta = 0xFFFFFFFF;
78 for (
int i =
w; i !=
r; ) {
101 int UnplayedIFrame = 2;
102 for (
int i =
r; i !=
w && UnplayedIFrame; ) {
107 if (
pi[i].independent) {
115 if (
pi[i].independent)
120 return Valid ? FrameNumber :
FindIndex(Pts);
147 :
cThread(
"non blocking file reader")
233 #define PLAYERBUFSIZE (MAXFRAMESIZE * 5)
235 #define RESUMEBACKUP 10 // number of seconds to back up when resuming an interrupted replay session
236 #define MAXSTUCKATEOF 3 // max. number of seconds to wait in case the device doesn't play the last frame
266 bool NextFile(uint16_t FileNumber = 0, off_t FileOffset = -1);
271 virtual void Action(
void);
273 cDvbPlayer(
const char *FileName,
bool PauseLive);
283 void Goto(
int Position,
bool Still =
false);
286 virtual bool GetIndex(
int &Current,
int &Total,
bool SnapToIFrame =
false);
291 #define MAX_VIDEO_SLOWMOTION 63 // max. arg to pass to VIDEO_SLOWMOTION // TODO is this value correct?
292 #define NORMAL_SPEED 4 // the index of the '1' entry in the following array
293 #define MAX_SPEEDS 3 // the offset of the maximum speed from normal speed in either direction
294 #define SPEED_MULT 12 // the speed multiplier
319 isyslog(
"replay %s", FileName);
328 esyslog(
"ERROR: can't allocate index");
407 if (
index->
Get(Index, &FileNumber, &FileOffset) &&
NextFile(FileNumber, FileOffset))
463 if (
index->
Get(Index, &FileNumber, &FileOffset) &&
NextFile(FileNumber, FileOffset)) {
476 bool WaitingForData =
false;
477 time_t StuckAtEof = 0;
478 uint32_t LastStc = 0;
479 int LastReadFrame = -1;
480 int SwitchToPlayFrame = 0;
482 bool AtLastMark =
false;
519 if (NewIndex <= 0 && readIndex > 0)
529 if (!
NextFile(FileNumber, FileOffset))
544 if (m && (m->
Index() & 0x01) != 0) {
582 WaitingForData =
false;
589 WaitingForData =
true;
658 w =
PlayTs(p, pc, VideoOnly);
688 if (
eof || SwitchToPlayFrame) {
689 bool SwitchToPlay =
false;
693 else if (!StuckAtEof)
694 StuckAtEof = time(NULL);
703 if (Index >= LastReadFrame)
706 else if (Index <= 0 || SwitchToPlayFrame && Index >= SwitchToPlayFrame)
709 if (!SwitchToPlayFrame)
714 SwitchToPlayFrame = 0;
805 default:
esyslog(
"ERROR: unknown playMode %d (%s)",
playMode, __FUNCTION__);
857 default:
esyslog(
"ERROR: unknown playMode %d (%s)",
playMode, __FUNCTION__);
864 if (
index && Frames) {
867 int OldCurrent = Current;
872 return Current >= 0 ? Current : OldCurrent;
879 if (
index && Seconds) {
907 if (
NextFile(FileNumber, FileOffset)) {
950 Current = (abs(Current - i1) <= abs(Current - i2)) ? i1 : i2;
955 Current = Total = -1;
966 Current = Total = -1;
bool Independent(void) const
cNonBlockingFileReader * nonBlockingFileReader
bool DeviceHasIBPTrickSpeed(void)
int SkipFrames(int Frames)
int ReadFrame(cUnbufferedFile *f, uchar *b, int Length, int Max)
void Request(cUnbufferedFile *File, int Length)
void SkipSeconds(int Seconds)
bool IsPesRecording(void) const
int FindIndex(uint32_t Pts)
virtual void SetAudioTrack(eTrackType Type, const tTrackId *TrackId)
void Signal(void)
Signals a caller of Wait() that the condition it is waiting for is met.
cUnbufferedFile * SetOffset(int Number, off_t Offset=0)
bool DeviceIsPlayingVideo(void)
cUnbufferedFile * NextFile(void)
cUnbufferedFile * Open(void)
cDvbPlayer(const char *FileName, bool PauseLive)
ssize_t Read(void *Data, size_t Size)
void Cancel(int WaitSeconds=0)
Cancels the thread by first setting 'running' to false, so that the Action() loop can finish in an or...
int SecondsToFrames(int Seconds, double FramesPerSecond)
~cNonBlockingFileReader()
cUnbufferedFile is used for large files that are mainly written or read in a streaming manner,...
const cMark * Get(int Position) const
int PlayTs(const uchar *Data, int Length, bool VideoOnly=false)
cString IndexToHMSF(int Index, bool WithFrame, double FramesPerSecond)
bool WaitForDataMs(int msToWait)
bool Wait(int TimeoutMs=0)
Waits at most TimeoutMs milliseconds for a call to Signal(), or forever if TimeoutMs is 0.
bool Running(void)
Returns false if a derived cThread object shall leave its Action() function.
void Goto(int Position, bool Still=false)
virtual bool GetIndex(int &Current, int &Total, bool SnapToIFrame=false)
cDvbPlayerControl(const char *FileName, bool PauseLive=false)
bool GetIndex(int &Current, int &Total, bool SnapToIFrame=false)
double FramesPerSecond(void) const
bool Lock(cStateKey &StateKey, bool Write=false, int TimeoutMs=0) const
Tries to get a lock on this list and returns true if successful.
void SkipSeconds(int Seconds)
const cMark * GetNextBegin(const cMark *EndMark=NULL) const
Returns the next "begin" mark after EndMark, skipping any marks at the same position as EndMark.
void TrickSpeed(int Increment)
static void SetBrokenLink(uchar *Data, int Length)
void SetMarks(const cMarks *Marks)
bool StoreResume(int Index)
virtual double FramesPerSecond(void)
void Remove(bool IncState=true)
Removes this key from the lock it was previously used with.
bool DevicePoll(cPoller &Poller, int TimeoutMs=0)
int SkipFrames(int Frames)
virtual ~cDvbPlayerControl()
static tThreadId IsMainThread(void)
const T * First(void) const
Returns the first element in this list, or NULL if the list is empty.
cRingBufferFrame * ringBuffer
bool GetReplayMode(bool &Play, bool &Forward, int &Speed)
void DeviceTrickSpeed(int Speed, bool Forward)
uint64_t DeviceGetSTC(void)
bool IsStillRecording(void)
virtual bool GetReplayMode(bool &Play, bool &Forward, int &Speed)
void Goto(int Index, bool Still=false)
cUnbufferedFile * replayFile
static void SleepMs(int TimeoutMs)
Creates a cCondWait object and uses it to sleep for TimeoutMs milliseconds, immediately giving up the...
int Last(void)
Returns the index of the last entry in this file, or -1 if the file is empty.
bool NextFile(uint16_t FileNumber=0, off_t FileOffset=-1)
cNonBlockingFileReader(void)
void Action(void)
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
bool TimedWait(cMutex &Mutex, int TimeoutMs)
int GetNextIFrame(int Index, bool Forward, uint16_t *FileNumber=NULL, off_t *FileOffset=NULL, int *Length=NULL)
int PlayPes(const uchar *Data, int Length, bool VideoOnly=false)
int FindFrameNumber(uint32_t Pts)
virtual void Action(void)
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
bool GetFrameNumber(int &Current, int &Total)
void bool Start(void)
Sets the description of this thread, which will be used when logging starting or stopping of the thre...
int Result(uchar **Buffer)
void Put(uint32_t Pts, int Index, bool Independent)
int64_t PesGetPts(const uchar *p)
bool Get(int Index, uint16_t *FileNumber, off_t *FileOffset, bool *Independent=NULL, int *Length=NULL)
#define MAX_VIDEO_SLOWMOTION
int64_t TsGetPts(const uchar *p, int l)
virtual void Activate(bool On)
tPtsIndex pi[PTSINDEX_ENTRIES]
virtual bool GetFrameNumber(int &Current, int &Total)
void DeviceStillPicture(const uchar *Data, int Length)
bool PesHasPts(const uchar *p)
void SetMarks(const cMarks *Marks)