21 #define FOLDERDELIMCHAR '~' 56 cResumeFile(
const char *FileName,
bool IsPesRecording);
77 void SetData(
const char *
Title,
const char *ShortText,
const char *Description);
78 void SetAux(
const char *Aux);
85 const char *
Title(
void)
const {
return event->Title(); }
86 const char *
ShortText(
void)
const {
return event->ShortText(); }
87 const char *
Description(
void)
const {
return event->Description(); }
89 const char *
Aux(
void)
const {
return aux; }
92 void SetFileName(
const char *
FileName);
93 bool Write(FILE *f,
const char *Prefix =
"")
const;
95 bool Write(
void)
const;
118 static char *StripEpisodeName(
char *s,
bool Strip);
119 char *SortName(
void)
const;
120 void ClearSortName(
void);
130 int Id(
void)
const {
return id; }
131 time_t
Start(
void)
const {
return start; }
134 time_t
Deleted(
void)
const {
return deleted; }
136 virtual int Compare(
const cListObject &ListObject)
const;
137 bool IsInPath(
const char *Path)
const;
146 const char *
Name(
void)
const {
return name; }
149 const char *FileName(
void)
const;
152 const char *Title(
char Delimiter =
' ',
bool NewIndicator =
false,
int Level = -1)
const;
154 const char *PrefixFileName(
char Prefix);
155 int HierarchyLevels(
void)
const;
158 int NumFrames(
void)
const;
161 int LengthInSeconds(
void)
const;
163 int FileSizeMB(
void)
const;
166 int GetResume(
void)
const;
169 bool IsNew(
void)
const {
return GetResume() <= 0; }
170 bool IsEdited(
void)
const;
172 bool IsOnVideoDirectoryFileSystem(
void)
const;
173 bool HasMarks(
void)
const;
175 bool DeleteMarks(
void);
180 bool WriteInfo(
const char *OtherFileName = NULL);
184 void SetStartTime(time_t Start);
192 bool ChangePriorityLifetime(
int NewPriority,
int NewLifetime);
196 bool ChangeName(
const char *NewName);
213 int IsInUse(
void)
const;
233 static const char *UpdateFileName(
void);
249 static void Update(
bool Wait =
false);
253 static void TouchUpdate(
void);
259 static bool NeedsUpdate(
void);
260 void ResetResume(
const char *ResumeFileName = NULL);
261 void ClearSortNames(
void);
264 const cRecording *GetByName(
const char *FileName)
const;
267 void AddByName(
const char *FileName,
bool TriggerUpdate =
true);
268 void DelByName(
const char *FileName);
269 void UpdateByName(
const char *FileName);
270 int TotalFileSizeMB(
void)
const;
271 double MBperMinute(
void)
const;
274 int PathIsInUse(
const char *Path)
const;
282 int GetNumRecordingsInPath(
const char *Path)
const;
286 bool MoveRecordings(
const char *OldPath,
const char *NewPath);
306 #define LOCK_RECORDINGS_READ USE_LIST_LOCK_READ(Recordings) 307 #define LOCK_RECORDINGS_WRITE USE_LIST_LOCK_WRITE(Recordings) 308 #define LOCK_DELETEDRECORDINGS_READ USE_LIST_LOCK_READ2(Recordings, DeletedRecordings) 309 #define LOCK_DELETEDRECORDINGS_WRITE USE_LIST_LOCK_WRITE2(Recordings, DeletedRecordings) 321 virtual void Action(
void);
325 bool Add(
int Usage,
const char *FileNameSrc,
const char *FileNameDst = NULL);
333 void Del(
const char *FileName);
340 int GetUsage(
const char *FileName);
342 bool Finished(
bool &Error);
351 #define DEFAULTFRAMESPERSECOND 25.0 363 const char *
Comment(
void)
const {
return comment; }
367 bool Parse(
const char *s);
385 static bool DeleteMarksFile(
const cRecording *Recording);
386 bool Load(
const char *RecordingFileName,
double FramesPerSecond =
DEFAULTFRAMESPERSECOND,
bool IsPesRecording =
false);
391 void Add(
int Position);
397 const cMark *Get(
int Position)
const;
398 const cMark *GetPrev(
int Position)
const;
399 const cMark *GetNext(
int Position)
const;
400 const cMark *GetNextBegin(
const cMark *EndMark = NULL)
const;
404 const cMark *GetNextEnd(
const cMark *BeginMark)
const;
407 int GetNumSequences(
void)
const;
420 #define RUC_BEFORERECORDING "before" 421 #define RUC_STARTRECORDING "started" 422 #define RUC_AFTERRECORDING "after" 423 #define RUC_EDITINGRECORDING "editing" 424 #define RUC_EDITEDRECORDING "edited" 425 #define RUC_DELETERECORDING "deleted" 431 static void SetCommand(
const char *Command) { command = Command; }
432 static void InvokeCommand(
const char *State,
const char *RecordingFileName,
const char *SourceFileName = NULL);
436 #define MAXFRAMESIZE (KILOBYTE(1024) / TS_SIZE * TS_SIZE) // multiple of TS_SIZE to avoid breaking up TS packets 443 #define MAXVIDEOFILESIZETS 1048570 // MB 444 #define MAXVIDEOFILESIZEPES 2000 // MB 445 #define MINVIDEOFILESIZE 100 // MB 446 #define MAXVIDEOFILESIZEDEFAULT MAXVIDEOFILESIZEPES 461 void ConvertFromPes(
tIndexTs *IndexTs,
int Count);
462 void ConvertToPes(
tIndexTs *IndexTs,
int Count);
463 bool CatchUp(
int Index = -1);
465 cIndexFile(
const char *FileName,
bool Record,
bool IsPesRecording =
false,
bool PauseLive =
false,
bool Update =
false);
467 bool Ok(
void) {
return index != NULL; }
468 bool Write(
bool Independent, uint16_t FileNumber, off_t FileOffset);
469 bool Get(
int Index, uint16_t *FileNumber, off_t *FileOffset,
bool *Independent = NULL,
int *Length = NULL);
470 int GetNextIFrame(
int Index,
bool Forward, uint16_t *FileNumber = NULL, off_t *FileOffset = NULL,
int *Length = NULL);
471 int GetClosestIFrame(
int Index);
476 int Get(uint16_t FileNumber, off_t FileOffset);
477 int Last(
void) { CatchUp();
return last; }
481 bool IsStillRecording(
void);
483 static int GetLength(
const char *FileName,
bool IsPesRecording =
false);
486 static cString IndexFileName(
const char *FileName,
bool IsPesRecording);
498 cFileName(
const char *FileName,
bool Record,
bool Blocking =
false,
bool IsPesRecording =
false);
501 uint16_t
Number(
void) {
return fileNumber; }
502 bool GetLastPatPmtVersions(
int &PatVersion,
int &PmtVersion);
524 bool GenerateIndex(
const char *FileName,
bool Update =
false);
541 #endif //__RECORDING_H bool Lock(cStateKey &StateKey, bool Write=false, int TimeoutMs=0) const
Tries to get a lock on this list and returns true if successful.
cMark * GetNext(int Position)
DEF_LIST_LOCK(Recordings)
cString GetRecordingTimerId(const char *Directory)
#define DEFAULTFRAMESPERSECOND
const cRecordingInfo * Info(void) const
void ResetResume(const char *ResumeFileName=NULL)
cMark * GetNextBegin(const cMark *EndMark=NULL)
cResumeFile(const char *FileName, bool IsPesRecording)
const char * ShortText(void) const
int HMSFToIndex(const char *HMSF, double FramesPerSecond=DEFAULTFRAMESPERSECOND)
double FramesPerSecond(void) const
const char * Title(char Delimiter= ' ', bool NewIndicator=false, int Level=-1) const
static cRecordings deletedRecordings
cRecording * GetById(int Id)
static const cRecordings * GetRecordingsRead(cStateKey &StateKey, int TimeoutMs=0)
Gets the list of recordings for read access.
static cRecordings recordings
const cComponents * Components(void) const
void SetRecordingTimerId(const char *Directory, const char *TimerId)
cString IndexToHMSF(int Index, bool WithFrame=false, double FramesPerSecond=DEFAULTFRAMESPERSECOND)
double FramesPerSecond(void) const
static cRecordings * GetRecordingsWrite(cStateKey &StateKey, int TimeoutMs=0)
Gets the list of recordings for write access.
int Last(void)
Returns the index of the last entry in this file, or -1 if the file is empty.
void SetPosition(int Position)
cUnbufferedFile is used for large files that are mainly written or read in a streaming manner...
static void SetCommand(const char *Command)
static const char * command
bool GenerateIndex(const char *FileName, bool Update=false)
Generates the index of the existing recording with the given FileName.
bool HasRecordingsSortMode(const char *Directory)
void IncRecordingsSortMode(const char *Directory)
eRecordingsSortMode RecordingsSortMode
static int lastRecordingId
const char * Comment(void) const
cMark * GetPrev(int Position)
void RemoveDeletedRecordings(void)
char * ExchangeChars(char *s, bool ToFileSystem)
time_t Deleted(void) const
static const cRecordings * GetDeletedRecordingsRead(cStateKey &StateKey, int TimeoutMs=0)
Gets the list of deleted recordings for read access.
void AssertFreeDiskSpace(int Priority=0, bool Force=false)
The special Priority value -1 means that we shall get rid of any deleted recordings faster than norma...
tChannelID ChannelID(void) const
int isOnVideoDirectoryFileSystem
cRecording * GetByName(const char *FileName)
static char * updateFileName
int SecondsToFrames(int Seconds, double FramesPerSecond=DEFAULTFRAMESPERSECOND)
static cRecordings * GetDeletedRecordingsWrite(cStateKey &StateKey, int TimeoutMs=0)
Gets the list of deleted recordings for write access.
bool StoreResume(int Index)
cIndexFileGenerator * indexFileGenerator
void GetRecordingsSortMode(const char *Directory)
int ReadFrame(cUnbufferedFile *f, uchar *b, int Length, int Max)
void SetRecordingsSortMode(const char *Directory, eRecordingsSortMode SortMode)
cRecordingsHandler RecordingsHandler
static cVideoDirectoryScannerThread * videoDirectoryScannerThread
const cEvent * GetEvent(void) const
const char * Description(void) const
const char * Name(void) const
Returns the full name of the recording (without the video directory).
DEF_LIST_LOCK2(Recordings, DeletedRecordings)
const char * Title(void) const
cList< cRecordingsHandlerEntry > operations
cMark * Get(int Position)
cMark * GetNextEnd(const cMark *BeginMark)
const char * ChannelName(void) const
void SetComment(const char *Comment)
const char * Aux(void) const
static const uint8_t * GetLength(const uint8_t *Data, int &Length)
cString recordingFileName
const char * FileName(void) const
Returns the full path name to the recording directory, including the video directory and the actual '...
bool IsPesRecording(void) const