13 #define RECORDERBUFSIZE (MEGABYTE(20) / TS_SIZE * TS_SIZE)
17 #define MAXBROKENTIMEOUT 30000
19 #define MINFREEDISKSPACE (512)
20 #define DISKCHECKINTERVAL 100
33 #define TS_CC_UNKNOWN 0xFF
39 void Report(
int Pid,
const char *Message);
56 fprintf(stderr,
"%s: TS error #%d on PID %d (%s)\n", *
TimeToString(time(NULL)),
errors, Pid, Message);
61 int Pid =
TsPid(Data);
82 #define MAX_BACK_REFS 32
91 void Report(
const char *Message,
int NumErrors = 1);
113 fprintf(stderr,
"%s: frame error #%d (%s)\n", *
TimeToString(time(NULL)),
errors, Message);
118 int64_t Pts =
TsGetPts(Data, Length);
126 Report(
"missing backref");
138 int b = 1 << (Diff - 1);
140 Report(
"duplicate backref");
144 Report(
"rev diff too big");
159 Report(
"missed", MissedFrames);
186 int Pid = Channel->
Vpid();
187 int Type = Channel->
Vtype();
188 if (!Pid && Channel->
Apid(0)) {
189 Pid = Channel->
Apid(0);
192 if (!Pid && Channel->
Dpid(0)) {
193 Pid = Channel->
Dpid(0);
202 int PatVersion, PmtVersion;
212 esyslog(
"ERROR: can't allocate index");
228 #define ERROR_LOG_DELTA 1
286 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
287 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
288 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
289 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
290 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
291 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
292 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
293 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
294 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
295 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
296 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
297 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
298 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
299 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
300 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
301 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
302 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
303 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
305 if ((Data[3] & 0b00110000) == 0b00100000 && !memcmp(Data + 4, aff,
sizeof(aff)))
318 bool InfoWritten =
false;
373 esyslog(
"ERROR: video data stream broken");
cUnbufferedFile * NextFile(void)
cUnbufferedFile * Open(void)
bool GetLastPatPmtVersions(int &PatVersion, int &PmtVersion)
void CheckFrame(const uchar *Data, int Length)
void Report(const char *Message, int NumErrors=1)
void SetFrameDelta(int FrameDelta)
bool Synced(void)
Returns true if the frame detector has synced on the data stream.
bool IndependentFrame(void)
Returns true if a new frame was detected and this is an independent frame (i.e.
double FramesPerSecond(void)
Returns the number of frames per second, or 0 if this information is not available.
int Analyze(const uchar *Data, int Length)
Analyzes the TS packets pointed to by Data.
bool NewFrame(void)
Returns true if the data given to the last call to Analyze() started a new frame.
bool Write(bool Independent, uint16_t FileNumber, off_t FileOffset)
uchar * GetPmt(int &Index)
Returns a pointer to the Index'th TS packet of the PMT section.
void SetChannel(const cChannel *Channel)
Sets the Channel for which the PAT/PMT shall be generated.
void SetVersions(int PatVersion, int PmtVersion)
Sets the version numbers for the generated PAT and PMT, in case this generator is used to,...
uchar * GetPat(void)
Returns a pointer to the PAT section, which consists of exactly one TS packet.
cRecorder(const char *FileName, const cChannel *Channel, int Priority)
Creates a new recorder for the given Channel and the given Priority that will record into the file Fi...
virtual void Receive(const uchar *Data, int Length)
This function is called from the cDevice we are attached to, and delivers one TS packet from the set ...
void HandleErrors(bool Force=false)
cRecordingInfo * recordingInfo
virtual void Action(void)
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
cFrameDetector * frameDetector
time_t lastDiskSpaceCheck
cUnbufferedFile * recordFile
cRingBufferLinear * ringBuffer
bool RunningLowOnDiskSpace(void)
virtual void Activate(bool On)
If you override Activate() you need to call Detach() (which is a member of the cReceiver class) from ...
cFrameChecker * frameChecker
cPatPmtGenerator patPmtGenerator
void SetFramesPerSecond(double FramesPerSecond)
bool Write(FILE *f, const char *Prefix="") const
void SetErrors(int Errors)
double FramesPerSecond(void) const
static void InvokeCommand(const char *State, const char *RecordingFileName, const char *SourceFileName=NULL)
void Del(int Count)
Deletes at most Count bytes from the ring buffer.
int Put(const uchar *Data, int Count)
Puts at most Count bytes of Data into the ring buffer.
uchar * Get(int &Count)
Gets data from the ring buffer.
void SetTimeouts(int PutTimeout, int GetTimeout)
void ReportOverflow(int Bytes)
void RequestEmergencyExit(void)
Requests an emergency exit of the VDR main loop.
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.
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 Set(int Ms=0)
Sets the timer.
bool TimedOut(void) const
void CheckTs(const uchar *Data, int Length)
void Report(int Pid, const char *Message)
ssize_t Write(const void *Data, size_t Size)
#define DISKCHECKINTERVAL
#define DEFAULTFRAMESPERSECOND
#define LOCK_RECORDINGS_WRITE
#define RUC_STARTRECORDING
int64_t PtsDiff(int64_t Pts1, int64_t Pts2)
Returns the difference between two PTS values.
int64_t TsGetPts(const uchar *p, int l)
bool TsError(const uchar *p)
int TsPid(const uchar *p)
bool TsHasPayload(const uchar *p)
bool TsIsScrambled(const uchar *p)
uchar TsContinuityCounter(const uchar *p)
#define MIN_TS_PACKETS_FOR_FRAME_DETECTOR
cShutdownHandler ShutdownHandler