20#define PTSINDEX_ENTRIES 1024
37 void Put(uint32_t Pts,
int Index,
bool Independent);
74 if (
w ==
r || Pts == 0 && !Still)
76 uint32_t Delta = 0xFFFFFFFF;
78 for (
int i =
w; i !=
r; ) {
98 if (
w ==
r || Pts == 0 && !Still)
102 int UnplayedIFrame = 2;
103 for (
int i =
r; i !=
w && UnplayedIFrame; ) {
104 int32_t d = int32_t(Pts -
pi[i].pts);
106 if (
pi[i].independent) {
115 else if (
pi[i].independent)
152:
cThread(
"non blocking file reader")
239#define PLAYERBUFSIZE (MAXFRAMESIZE * 5)
241#define RESUMEBACKUP 10
242#define MAXSTUCKATEOF 3
272 bool NextFile(uint16_t FileNumber = 0, off_t FileOffset = -1);
276 virtual void Activate(
bool On)
override;
277 virtual void Action(
void)
override;
279 cDvbPlayer(
const char *FileName,
bool PauseLive);
289 void Goto(
int Position,
bool Still =
false);
293 virtual bool GetIndex(
int &Current,
int &Total,
bool SnapToIFrame =
false)
override;
298#define MAX_VIDEO_SLOWMOTION 63
299#define NORMAL_SPEED 4
325 isyslog(
"replay %s", FileName);
334 esyslog(
"ERROR: can't allocate index");
414 if (
index->
Get(Index, &FileNumber, &FileOffset) &&
NextFile(FileNumber, FileOffset)) {
472 if (
index->
Get(Index, &FileNumber, &FileOffset) &&
NextFile(FileNumber, FileOffset)) {
485 bool WaitingForData =
false;
486 time_t StuckAtEof = 0;
487 uint32_t LastStc = 0;
488 int SwitchToPlayFrame = 0;
490 bool AtLastMark =
false;
528 if (NewIndex <= 0 && readIndex > 0)
538 if (!
NextFile(FileNumber, FileOffset))
553 if (m && (m->
Index() & 0x01) != 0) {
591 WaitingForData =
false;
601 WaitingForData =
true;
668 w =
PlayTs(p, pc, VideoOnly);
700 if (
eof || SwitchToPlayFrame) {
701 bool SwitchToPlay =
false;
712 else if (Stc != LastStc)
714 else if (!StuckAtEof)
715 StuckAtEof = time(NULL);
720 if ((
playDir !=
pdForward || SwitchToPlayFrame) && (Index <= 0 || SwitchToPlayFrame && Index >= SwitchToPlayFrame))
723 if (!SwitchToPlayFrame) {
730 SwitchToPlayFrame = 0;
823 default:
esyslog(
"ERROR: unknown playMode %d (%s)",
playMode.load(), __FUNCTION__);
875 default:
esyslog(
"ERROR: unknown playMode %d (%s)",
playMode.load(), __FUNCTION__);
882 if (
index && Frames) {
885 int OldCurrent = Current;
890 return Current >= 0 ? Current : OldCurrent;
897 if (
index && Seconds) {
925 if (
NextFile(FileNumber, FileOffset)) {
975 Current = (abs(Current - i1) <= abs(Current - i2)) ? i1 : i2;
980 Current = Total = -1;
991 Current = Total = -1;
bool TimedWait(cMutex &Mutex, int TimeoutMs)
bool Wait(int TimeoutMs=0)
Waits at most TimeoutMs milliseconds for a call to Signal(), or forever if TimeoutMs is 0.
void Signal(void)
Signals a caller of Wait() that the condition it is waiting for is met.
static void SleepMs(int TimeoutMs)
Creates a cCondWait object and uses it to sleep for TimeoutMs milliseconds, immediately giving up the...
void SetPlayer(cPlayer *Player)
cControl(cPlayer *Player, bool Hidden=false)
void SetMarks(const cMarks *Marks)
virtual ~cDvbPlayerControl() override
bool GetIndex(int &Current, int &Total, bool SnapToIFrame=false)
const cErrors * GetErrors(void)
void SkipSeconds(int Seconds)
cDvbPlayerControl(const char *FileName, bool PauseLive=false)
bool GetReplayMode(bool &Play, bool &Forward, int &Speed)
int SkipFrames(int Frames)
void Goto(int Index, bool Still=false)
bool GetFrameNumber(int &Current, int &Total)
virtual const cErrors * GetErrors(void) override
std::atomic< ePlayModes > playMode
cRingBufferFrame * ringBuffer
void SetMarks(const cMarks *Marks)
virtual void Action(void) override
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
virtual bool GetReplayMode(bool &Play, bool &Forward, int &Speed) override
virtual void Activate(bool On) override
std::atomic< int > trickSpeed
void SkipSeconds(int Seconds)
cDvbPlayer(const char *FileName, bool PauseLive)
cNonBlockingFileReader * nonBlockingFileReader
cUnbufferedFile * replayFile
virtual void SetAudioTrack(eTrackType Type, const tTrackId *TrackId) override
void Goto(int Position, bool Still=false)
std::atomic< ePlayDirs > playDir
bool NextFile(uint16_t FileNumber=0, off_t FileOffset=-1)
std::atomic< int > readIndex
virtual ~cDvbPlayer() override
virtual bool GetFrameNumber(int &Current, int &Total) override
void TrickSpeed(int Increment)
virtual double FramesPerSecond(void) override
int SkipFrames(int Frames)
virtual bool GetIndex(int &Current, int &Total, bool SnapToIFrame=false) override
cUnbufferedFile * NextFile(void)
cUnbufferedFile * Open(void)
cFileName(const char *FileName, bool Record, bool Blocking=false, bool IsPesRecording=false)
cUnbufferedFile * SetOffset(int Number, off_t Offset=0)
bool Independent(void) const
cFrame(const uchar *Data, int Count, eFrameType=ftUnknown, int Index=-1, uint32_t Pts=0, bool independent=false)
Creates a new cFrame object.
int GetNextIFrame(int Index, bool Forward, uint16_t *FileNumber=NULL, off_t *FileOffset=NULL, int *Length=NULL)
bool IsStillRecording(void)
cIndexFile(const char *FileName, bool Record, bool IsPesRecording=false, bool PauseLive=false)
const cErrors * GetErrors(void)
Returns the frame indexes of errors in the recording (if any).
bool StoreResume(int Index)
bool Get(int Index, uint16_t *FileNumber, off_t *FileOffset, bool *Independent=NULL, int *Length=NULL, bool *Errors=NULL, bool *Missing=NULL)
int Last(void)
Returns the index of the last entry in this file, or -1 if the file is empty.
bool Lock(cStateKey &StateKey, bool Write=false, int TimeoutMs=0) const
Tries to get a lock on this list and returns true if successful.
const T * First(void) const
Returns the first element in this list, or NULL if the list is empty.
const cMark * GetNextBegin(const cMark *EndMark=NULL) const
Returns the next "begin" mark after EndMark, skipping any marks at the same position as EndMark.
const cMark * Get(int Position) const
std::atomic< int > wanted
std::atomic< uchar * > buffer
std::atomic< int > length
void Request(cUnbufferedFile *File, int Length)
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 WaitForDataMs(int msToWait)
int Result(uchar **Buffer)
~cNonBlockingFileReader()
void DeviceStillPicture(const uchar *Data, int Length)
uint64_t DeviceGetSTC(void)
int PlayTs(const uchar *Data, int Length, bool VideoOnly=false)
int PlayPes(const uchar *Data, int Length, bool VideoOnly=false)
bool DevicePoll(cPoller &Poller, int TimeoutMs=0)
void DeviceSetTempSubtitles(void)
bool DeviceHasIBPTrickSpeed(void)
cPlayer(ePlayMode PlayMode=pmAudioVideo)
bool DeviceIsPlayingVideo(void)
void DeviceTrickSpeed(int Speed, bool Forward)
int FindIndex(uint32_t Pts, bool Still)
int FindFrameNumber(uint32_t Pts, bool Forward, bool Still)
tPtsIndex pi[PTSINDEX_ENTRIES]
void Put(uint32_t Pts, int Index, bool Independent)
cRecording(const cRecording &)
double FramesPerSecond(void) const
bool IsPesRecording(void) const
static void SetBrokenLink(uchar *Data, int Length)
virtual void Clear(void) override
cRingBufferFrame(int Size, bool Statistics=false)
void Remove(bool IncState=true)
Removes this key from the lock it was previously used with.
void bool Start(void)
Sets the description of this thread, which will be used when logging starting or stopping of the thre...
bool Running(void)
Returns false if a derived cThread object shall leave its Action() function.
cThread(const char *Description=NULL, bool LowPriority=false)
Creates a new thread.
void Cancel(int WaitSeconds=0)
Cancels the thread by first setting 'running' to false, so that the Action() loop can finish in an or...
static tThreadId IsMainThread(void)
cUnbufferedFile is used for large files that are mainly written or read in a streaming manner,...
ssize_t Read(void *Data, size_t Size)
#define MAX_VIDEO_SLOWMOTION
cString IndexToHMSF(int Index, bool WithFrame, double FramesPerSecond)
int SecondsToFrames(int Seconds, double FramesPerSecond)
int ReadFrame(cUnbufferedFile *f, uchar *b, int Length, int Max)
int64_t PtsDiff(int64_t Pts1, int64_t Pts2)
Returns the difference between two PTS values.
int64_t TsGetPts(const uchar *p, int l, int Pid)
bool PesHasPts(const uchar *p)
int64_t PesGetPts(const uchar *p)