vdr 2.6.1
recording.h
Go to the documentation of this file.
1/*
2 * recording.h: Recording file handling
3 *
4 * See the main source file 'vdr.c' for copyright information and
5 * how to reach the author.
6 *
7 * $Id: recording.h 5.5 2021/05/23 15:03:17 kls Exp $
8 */
9
10#ifndef __RECORDING_H
11#define __RECORDING_H
12
13#include <time.h>
14#include "channels.h"
15#include "config.h"
16#include "epg.h"
17#include "thread.h"
18#include "timers.h"
19#include "tools.h"
20
21#define FOLDERDELIMCHAR '~'
22
23extern int DirectoryPathMax;
24extern int DirectoryNameMax;
25extern bool DirectoryEncoding;
26extern int InstanceId;
27
29 ruNone = 0x0000, // the recording is currently unused
30 ruTimer = 0x0001, // the recording is currently written to by a timer
31 ruReplay = 0x0002, // the recording is being replayed
32 // mutually exclusive:
33 ruCut = 0x0004, // the recording is being cut
34 ruMove = 0x0008, // the recording is being moved
35 ruCopy = 0x0010, // the recording is being copied
36 // mutually exclusive:
37 ruSrc = 0x0020, // the recording is the source of a cut, move or copy process
38 ruDst = 0x0040, // the recording is the destination of a cut, move or copy process
39 //
40 ruPending = 0x0080, // the recording is pending a cut, move or copy process
41 ruCanceled = 0x8000, // the operation has been canceled, waiting for cleanup
42 };
43
45void AssertFreeDiskSpace(int Priority = 0, bool Force = false);
50
51class cResumeFile {
52private:
53 char *fileName;
54 bool isPesRecording;
55public:
56 cResumeFile(const char *FileName, bool IsPesRecording);
58 int Read(void);
59 bool Save(int Index);
60 void Delete(void);
61 };
62
63class cRecordingInfo {
64 friend class cRecording;
65private:
67 char *channelName;
68 const cEvent *event;
70 char *aux;
71 double framesPerSecond;
72 int priority;
73 int lifetime;
74 char *fileName;
75 int errors;
76 cRecordingInfo(const cChannel *Channel = NULL, const cEvent *Event = NULL);
77 bool Read(FILE *f);
78public:
81 tChannelID ChannelID(void) const { return channelID; }
82 const char *ChannelName(void) const { return channelName; }
83 const cEvent *GetEvent(void) const { return event; }
84 const char *Title(void) const { return event->Title(); }
85 const char *ShortText(void) const { return event->ShortText(); }
86 const char *Description(void) const { return event->Description(); }
87 const cComponents *Components(void) const { return event->Components(); }
88 const char *Aux(void) const { return aux; }
89 double FramesPerSecond(void) const { return framesPerSecond; }
91 void SetFileName(const char *FileName);
92 int Errors(void) const { return errors; } // returns -1 if undefined
93 void SetErrors(int Errors);
94 bool Write(FILE *f, const char *Prefix = "") const;
95 bool Read(void);
96 bool Write(void) const;
97 void SetData(const char *Title, const char *ShortText, const char *Description);
98 void SetAux(const char *Aux);
99 };
100
101class cRecording : public cListObject {
102 friend class cRecordings;
103private:
104 int id;
105 mutable int resume;
106 mutable char *titleBuffer;
107 mutable char *sortBufferName;
108 mutable char *sortBufferTime;
109 mutable char *fileName;
110 mutable char *name;
111 mutable int fileSizeMB;
112 mutable int numFrames;
113 int channel;
114 int instanceId;
115 bool isPesRecording;
116 mutable int isOnVideoDirectoryFileSystem; // -1 = unknown, 0 = no, 1 = yes
117 double framesPerSecond;
119 cRecording(const cRecording&); // can't copy cRecording
120 cRecording &operator=(const cRecording &); // can't assign cRecording
121 static char *StripEpisodeName(char *s, bool Strip);
122 char *SortName(void) const;
123 void ClearSortName(void);
124 void SetId(int Id); // should only be set by cRecordings
125 time_t start;
126 int priority;
127 int lifetime;
128 time_t deleted;
129public:
130 cRecording(cTimer *Timer, const cEvent *Event);
131 cRecording(const char *FileName);
132 virtual ~cRecording();
133 int Id(void) const { return id; }
134 time_t Start(void) const { return start; }
135 int Priority(void) const { return priority; }
136 int Lifetime(void) const { return lifetime; }
137 time_t Deleted(void) const { return deleted; }
138 void SetDeleted(void) { deleted = time(NULL); }
139 virtual int Compare(const cListObject &ListObject) const;
140 bool IsInPath(const char *Path) const;
143 cString Folder(void) const;
146 cString BaseName(void) const;
149 const char *Name(void) const { return name; }
152 const char *FileName(void) const;
155 const char *Title(char Delimiter = ' ', bool NewIndicator = false, int Level = -1) const;
156 cRecordingInfo *Info(void) const { return info; }
157 const char *PrefixFileName(char Prefix);
158 int HierarchyLevels(void) const;
159 void ResetResume(void) const;
160 double FramesPerSecond(void) const { return framesPerSecond; }
161 int NumFrames(void) const;
164 int LengthInSeconds(void) const;
166 int FileSizeMB(void) const;
169 int GetResume(void) const;
172 bool IsNew(void) const { return GetResume() <= 0; }
173 bool IsEdited(void) const;
174 bool IsPesRecording(void) const { return isPesRecording; }
176 bool HasMarks(void) const;
178 bool DeleteMarks(void);
182 void ReadInfo(void);
183 bool WriteInfo(const char *OtherFileName = NULL);
187 void SetStartTime(time_t Start);
195 bool ChangePriorityLifetime(int NewPriority, int NewLifetime);
199 bool ChangeName(const char *NewName);
206 bool Delete(void);
209 bool Remove(void);
212 bool Undelete(void);
216 int IsInUse(void) const;
224 };
225
227
228class cRecordings : public cList<cRecording> {
229private:
230 static cRecordings recordings;
232 static int lastRecordingId;
233 static char *updateFileName;
234 static time_t lastUpdate;
236 static const char *UpdateFileName(void);
237public:
238 cRecordings(bool Deleted = false);
239 virtual ~cRecordings();
240 static const cRecordings *GetRecordingsRead(cStateKey &StateKey, int TimeoutMs = 0) { return recordings.Lock(StateKey, false, TimeoutMs) ? &recordings : NULL; }
243 static cRecordings *GetRecordingsWrite(cStateKey &StateKey, int TimeoutMs = 0) { return recordings.Lock(StateKey, true, TimeoutMs) ? &recordings : NULL; }
246 static const cRecordings *GetDeletedRecordingsRead(cStateKey &StateKey, int TimeoutMs = 0) { return deletedRecordings.Lock(StateKey, false, TimeoutMs) ? &deletedRecordings : NULL; }
249 static cRecordings *GetDeletedRecordingsWrite(cStateKey &StateKey, int TimeoutMs = 0) { return deletedRecordings.Lock(StateKey, true, TimeoutMs) ? &deletedRecordings : NULL; }
252 static void Update(bool Wait = false);
256 static void TouchUpdate(void);
260 static bool NeedsUpdate(void);
261 void ResetResume(const char *ResumeFileName = NULL);
262 void ClearSortNames(void);
263 const cRecording *GetById(int Id) const;
264 cRecording *GetById(int Id) { return const_cast<cRecording *>(static_cast<const cRecordings *>(this)->GetById(Id)); };
265 const cRecording *GetByName(const char *FileName) const;
266 cRecording *GetByName(const char *FileName) { return const_cast<cRecording *>(static_cast<const cRecordings *>(this)->GetByName(FileName)); }
267 void Add(cRecording *Recording);
268 void AddByName(const char *FileName, bool TriggerUpdate = true);
269 void DelByName(const char *FileName);
270 void UpdateByName(const char *FileName);
271 int TotalFileSizeMB(void) const;
272 double MBperMinute(void) const;
275 int PathIsInUse(const char *Path) const;
283 int GetNumRecordingsInPath(const char *Path) const;
287 bool MoveRecordings(const char *OldPath, const char *NewPath);
296 };
297
298// Provide lock controlled access to the list:
299
300DEF_LIST_LOCK(Recordings);
301DEF_LIST_LOCK2(Recordings, DeletedRecordings);
302
303// These macros provide a convenient way of locking the global recordings list
304// and making sure the lock is released as soon as the current scope is left
305// (note that these macros wait forever to obtain the lock!):
306
307#define LOCK_RECORDINGS_READ USE_LIST_LOCK_READ(Recordings)
308#define LOCK_RECORDINGS_WRITE USE_LIST_LOCK_WRITE(Recordings)
309#define LOCK_DELETEDRECORDINGS_READ USE_LIST_LOCK_READ2(Recordings, DeletedRecordings)
310#define LOCK_DELETEDRECORDINGS_WRITE USE_LIST_LOCK_WRITE2(Recordings, DeletedRecordings)
311
313
314class cRecordingsHandler : public cThread {
315private:
318 bool finished;
319 bool error;
320 cRecordingsHandlerEntry *Get(const char *FileName);
321protected:
322 virtual void Action(void);
323public:
326 bool Add(int Usage, const char *FileNameSrc, const char *FileNameDst = NULL);
334 void Del(const char *FileName);
339 void DelAll(void);
341 int GetUsage(const char *FileName);
343 bool Finished(bool &Error);
348 };
349
351
352#define DEFAULTFRAMESPERSECOND 25.0
353
354class cMark : public cListObject {
355 friend class cMarks; // for sorting
356private:
357 double framesPerSecond;
358 int position;
360public:
361 cMark(int Position = 0, const char *Comment = NULL, double FramesPerSecond = DEFAULTFRAMESPERSECOND);
362 virtual ~cMark();
363 int Position(void) const { return position; }
364 const char *Comment(void) const { return comment; }
366 void SetComment(const char *Comment) { comment = Comment; }
368 bool Parse(const char *s);
369 bool Save(FILE *f);
370 };
371
372class cMarks : public cConfig<cMark> {
373private:
376 double framesPerSecond;
377 bool isPesRecording;
378 time_t nextUpdate;
379 time_t lastFileTime;
380 time_t lastChange;
381public:
382 cMarks(void): cConfig<cMark>("Marks") {};
383 static cString MarksFileName(const cRecording *Recording);
386 static bool DeleteMarksFile(const cRecording *Recording);
387 bool Load(const char *RecordingFileName, double FramesPerSecond = DEFAULTFRAMESPERSECOND, bool IsPesRecording = false);
388 bool Update(void);
389 bool Save(void);
390 void Align(void);
391 void Sort(void);
392 void Add(int Position);
398 const cMark *Get(int Position) const;
399 const cMark *GetPrev(int Position) const;
400 const cMark *GetNext(int Position) const;
401 const cMark *GetNextBegin(const cMark *EndMark = NULL) const;
405 const cMark *GetNextEnd(const cMark *BeginMark) const;
408 int GetNumSequences(void) const;
414 cMark *Get(int Position) { return const_cast<cMark *>(static_cast<const cMarks *>(this)->Get(Position)); }
415 cMark *GetPrev(int Position) { return const_cast<cMark *>(static_cast<const cMarks *>(this)->GetPrev(Position)); }
416 cMark *GetNext(int Position) { return const_cast<cMark *>(static_cast<const cMarks *>(this)->GetNext(Position)); }
417 cMark *GetNextBegin(const cMark *EndMark = NULL) { return const_cast<cMark *>(static_cast<const cMarks *>(this)->GetNextBegin(EndMark)); }
418 cMark *GetNextEnd(const cMark *BeginMark) { return const_cast<cMark *>(static_cast<const cMarks *>(this)->GetNextEnd(BeginMark)); }
419 };
420
421#define RUC_BEFORERECORDING "before"
422#define RUC_STARTRECORDING "started"
423#define RUC_AFTERRECORDING "after"
424#define RUC_EDITINGRECORDING "editing"
425#define RUC_EDITEDRECORDING "edited"
426#define RUC_DELETERECORDING "deleted"
427#define RUC_RENAMEDRECORDING "renamed" // same directory, only the base name is changed
428#define RUC_MOVEDRECORDING "moved" // different directory (and maybe base name), or "copy" to other filesystem + delete original (triggers copying->copied->deleted)
429#define RUC_COPYINGRECORDING "copying"
430#define RUC_COPIEDRECORDING "copied"
431
433private:
434 static const char *command;
435public:
436 static void SetCommand(const char *Command) { command = Command; }
437 static void InvokeCommand(const char *State, const char *RecordingFileName, const char *SourceFileName = NULL);
438 };
439
440// The maximum size of a single frame (up to HDTV 1920x1080):
441#define MAXFRAMESIZE (KILOBYTE(1024) / TS_SIZE * TS_SIZE) // multiple of TS_SIZE to avoid breaking up TS packets
442
443// The maximum file size is limited by the range that can be covered
444// with a 40 bit 'unsigned int', which is 1TB. The actual maximum value
445// used is 6MB below the theoretical maximum, to have some safety (the
446// actual file size may be slightly higher because we stop recording only
447// before the next independent frame, to have a complete Group Of Pictures):
448#define MAXVIDEOFILESIZETS 1048570 // MB
449#define MAXVIDEOFILESIZEPES 2000 // MB
450#define MINVIDEOFILESIZE 100 // MB
451#define MAXVIDEOFILESIZEDEFAULT MAXVIDEOFILESIZEPES
452
453struct tIndexTs;
455
456class cIndexFile {
457private:
458 int f;
460 int size, last;
461 tIndexTs *index;
462 bool isPesRecording;
466 void ConvertFromPes(tIndexTs *IndexTs, int Count);
467 void ConvertToPes(tIndexTs *IndexTs, int Count);
468 bool CatchUp(int Index = -1);
469public:
470 cIndexFile(const char *FileName, bool Record, bool IsPesRecording = false, bool PauseLive = false, bool Update = false);
472 bool Ok(void) { return index != NULL; }
473 bool Write(bool Independent, uint16_t FileNumber, off_t FileOffset);
474 bool Get(int Index, uint16_t *FileNumber, off_t *FileOffset, bool *Independent = NULL, int *Length = NULL);
475 int GetNextIFrame(int Index, bool Forward, uint16_t *FileNumber = NULL, off_t *FileOffset = NULL, int *Length = NULL);
476 int GetClosestIFrame(int Index);
481 int Get(uint16_t FileNumber, off_t FileOffset);
482 int Last(void) { CatchUp(); return last; }
484 int GetResume(void) { return resumeFile.Read(); }
485 bool StoreResume(int Index) { return resumeFile.Save(Index); }
487 void Delete(void);
488 static int GetLength(const char *FileName, bool IsPesRecording = false);
491 static cString IndexFileName(const char *FileName, bool IsPesRecording);
492 };
493
494class cFileName {
495private:
497 uint16_t fileNumber;
498 char *fileName, *pFileNumber;
499 bool record;
500 bool blocking;
501 bool isPesRecording;
502public:
503 cFileName(const char *FileName, bool Record, bool Blocking = false, bool IsPesRecording = false);
505 const char *Name(void) { return fileName; }
506 uint16_t Number(void) { return fileNumber; }
507 bool GetLastPatPmtVersions(int &PatVersion, int &PmtVersion);
509 void Close(void);
510 cUnbufferedFile *SetOffset(int Number, off_t Offset = 0); // yes, Number is int for easier internal calculating
512 };
513
514class cDoneRecordings {
515private:
518 void Add(const char *Title);
519public:
520 bool Load(const char *FileName);
521 bool Save(void) const;
522 void Append(const char *Title);
523 bool Contains(const char *Title) const;
524 };
525
527
528cString IndexToHMSF(int Index, bool WithFrame = false, double FramesPerSecond = DEFAULTFRAMESPERSECOND);
529 // Converts the given index to a string, optionally containing the frame number.
530int HMSFToIndex(const char *HMSF, double FramesPerSecond = DEFAULTFRAMESPERSECOND);
531 // Converts the given string (format: "hh:mm:ss.ff") to an index.
532int SecondsToFrames(int Seconds, double FramesPerSecond = DEFAULTFRAMESPERSECOND);
533 // Returns the number of frames corresponding to the given number of seconds.
534
535int ReadFrame(cUnbufferedFile *f, uchar *b, int Length, int Max);
536
537char *ExchangeChars(char *s, bool ToFileSystem);
538 // Exchanges the characters in the given string to or from a file system
539 // specific representation (depending on ToFileSystem). The given string will
540 // be modified and may be reallocated if more space is needed. The return
541 // value points to the resulting string, which may be different from s.
542
543bool GenerateIndex(const char *FileName, bool Update = false);
548
552bool HasRecordingsSortMode(const char *Directory);
553void GetRecordingsSortMode(const char *Directory);
554void SetRecordingsSortMode(const char *Directory, eRecordingsSortMode SortMode);
555void IncRecordingsSortMode(const char *Directory);
556
557void SetRecordingTimerId(const char *Directory, const char *TimerId);
558cString GetRecordingTimerId(const char *Directory);
559
560#endif //__RECORDING_H
bool Save(void) const
void Add(const char *Title)
void Append(const char *Title)
bool Load(const char *FileName)
bool Contains(const char *Title) const
Definition: epg.h:73
cUnbufferedFile * NextFile(void)
uint16_t Number(void)
Definition: recording.h:506
void Close(void)
cUnbufferedFile * Open(void)
cFileName(const char *FileName, bool Record, bool Blocking=false, bool IsPesRecording=false)
cUnbufferedFile * file
const char * Name(void)
Definition: recording.h:505
bool GetLastPatPmtVersions(int &PatVersion, int &PmtVersion)
cUnbufferedFile * SetOffset(int Number, off_t Offset=0)
int GetNextIFrame(int Index, bool Forward, uint16_t *FileNumber=NULL, off_t *FileOffset=NULL, int *Length=NULL)
cResumeFile resumeFile
bool IsStillRecording(void)
void ConvertFromPes(tIndexTs *IndexTs, int Count)
bool Write(bool Independent, uint16_t FileNumber, off_t FileOffset)
static int GetLength(const char *FileName, bool IsPesRecording=false)
Calculates the recording length (number of frames) without actually reading the index file.
bool CatchUp(int Index=-1)
int GetResume(void)
Definition: recording.h:484
void ConvertToPes(tIndexTs *IndexTs, int Count)
static cString IndexFileName(const char *FileName, bool IsPesRecording)
int Get(uint16_t FileNumber, off_t FileOffset)
bool StoreResume(int Index)
Definition: recording.h:485
cIndexFile(const char *FileName, bool Record, bool IsPesRecording=false, bool PauseLive=false, bool Update=false)
bool Get(int Index, uint16_t *FileNumber, off_t *FileOffset, bool *Independent=NULL, int *Length=NULL)
int GetClosestIFrame(int Index)
Returns the index of the I-frame that is closest to the given Index (or Index itself,...
bool Ok(void)
Definition: recording.h:472
void Delete(void)
int Last(void)
Returns the index of the last entry in this file, or -1 if the file is empty.
Definition: recording.h:482
cIndexFileGenerator * indexFileGenerator
bool Lock(cStateKey &StateKey, bool Write=false, int TimeoutMs=0) const
Tries to get a lock on this list and returns true if successful.
Definition: tools.c:2175
cMark(int Position=0, const char *Comment=NULL, double FramesPerSecond=DEFAULTFRAMESPERSECOND)
bool Parse(const char *s)
bool Save(FILE *f)
cString ToText(void)
const char * Comment(void) const
virtual ~cMark()
double framesPerSecond
void SetPosition(int Position)
Definition: recording.h:365
int Position(void) const
void SetComment(const char *Comment)
Definition: recording.h:366
int GetNumSequences(void) const
Returns the actual number of sequences to be cut from the recording.
double framesPerSecond
void Add(int Position)
If this cMarks object is used by multiple threads, the caller must Lock() it before calling Add() and...
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 * GetNext(int Position) const
bool Update(void)
bool Load(const char *RecordingFileName, double FramesPerSecond=DEFAULTFRAMESPERSECOND, bool IsPesRecording=false)
const cMark * GetNextEnd(const cMark *BeginMark) const
Returns the next "end" mark after BeginMark, skipping any marks at the same position as BeginMark.
const cMark * Get(int Position) const
cString recordingFileName
static bool DeleteMarksFile(const cRecording *Recording)
void Align(void)
void Sort(void)
cMark * Get(int Position)
Definition: recording.h:414
static cString MarksFileName(const cRecording *Recording)
Returns the marks file name for the given Recording (regardless whether such a file actually exists).
cMark * GetNextEnd(const cMark *BeginMark)
Definition: recording.h:418
cMarks(void)
Definition: recording.h:382
cMark * GetNextBegin(const cMark *EndMark=NULL)
Definition: recording.h:417
cMark * GetPrev(int Position)
Definition: recording.h:415
cMark * GetNext(int Position)
Definition: recording.h:416
bool Save(void)
const cMark * GetPrev(int Position) const
const char * ChannelName(void) const
Definition: recording.h:82
void SetFramesPerSecond(double FramesPerSecond)
const cEvent * GetEvent(void) const
Definition: recording.h:83
int Errors(void) const
Definition: recording.h:92
const char * ShortText(void) const
Definition: recording.h:85
cRecordingInfo(const cChannel *Channel=NULL, const cEvent *Event=NULL)
bool Write(void) const
bool Write(FILE *f, const char *Prefix="") const
const char * Title(void) const
Definition: recording.h:84
bool Read(void)
cRecordingInfo(const char *FileName)
const char * Aux(void) const
Definition: recording.h:88
tChannelID ChannelID(void) const
Definition: recording.h:81
void SetFileName(const char *FileName)
bool Read(FILE *f)
void SetErrors(int Errors)
void SetAux(const char *Aux)
const cEvent * event
void SetData(const char *Title, const char *ShortText, const char *Description)
const char * Description(void) const
Definition: recording.h:86
double FramesPerSecond(void) const
Definition: recording.h:89
const cComponents * Components(void) const
Definition: recording.h:87
static void InvokeCommand(const char *State, const char *RecordingFileName, const char *SourceFileName=NULL)
static const char * command
static void SetCommand(const char *Command)
Definition: recording.h:436
cRecordingInfo * info
bool ChangePriorityLifetime(int NewPriority, int NewLifetime)
Changes the priority and lifetime of this recording to the given values.
bool HasMarks(void) const
Returns true if this recording has any editing marks.
cRecording & operator=(const cRecording &)
bool WriteInfo(const char *OtherFileName=NULL)
Writes in info file of this recording.
int IsInUse(void) const
Checks whether this recording is currently in use and therefore shall not be tampered with.
bool ChangeName(const char *NewName)
Changes the name of this recording to the given value.
bool Undelete(void)
Changes the file name so that it will be visible in the "Recordings" menu again and not processed by ...
void ResetResume(void) const
cRecording(cTimer *Timer, const cEvent *Event)
bool IsNew(void) const
Definition: recording.h:172
bool Delete(void)
Changes the file name so that it will no longer be visible in the "Recordings" menu Returns false in ...
cString Folder(void) const
Returns the name of the folder this recording is stored in (without the video directory).
void ClearSortName(void)
int NumFrames(void) const
Returns the number of frames in this recording.
bool IsEdited(void) const
int Id(void) const
cRecording(const char *FileName)
int GetResume(void) const
Returns the index of the frame where replay of this recording shall be resumed, or -1 in case of an e...
bool IsInPath(const char *Path) const
Returns true if this recording is stored anywhere under the given Path.
void SetId(int Id)
void SetStartTime(time_t Start)
Sets the start time of this recording to the given value.
char * SortName(void) const
const char * Name(void) const
Returns the full name of the recording (without the video directory).
Definition: recording.h:149
time_t Start(void) const
Definition: recording.h:134
int Lifetime(void) const
Definition: recording.h:136
const char * FileName(void) const
Returns the full path name to the recording directory, including the video directory and the actual '...
Definition: recording.c:1066
cRecordingInfo * Info(void) const
Definition: recording.h:156
virtual ~cRecording()
const char * PrefixFileName(char Prefix)
static char * StripEpisodeName(char *s, bool Strip)
bool DeleteMarks(void)
Deletes the editing marks from this recording (if any).
bool IsOnVideoDirectoryFileSystem(void) const
int HierarchyLevels(void) const
int FileSizeMB(void) const
Returns the total file size of this recording (in MB), or -1 if the file size is unknown.
cString BaseName(void) const
Returns the base name of this recording (without the video directory and folder).
void SetDeleted(void)
Definition: recording.h:138
int Priority(void) const
Definition: recording.h:135
void ReadInfo(void)
const char * Title(char Delimiter=' ', bool NewIndicator=false, int Level=-1) const
virtual int Compare(const cListObject &ListObject) const
Must return 0 if this object is equal to ListObject, a positive value if it is "greater",...
bool Remove(void)
Actually removes the file from the disk Returns false in case of error.
cRecording(const cRecording &)
double FramesPerSecond(void) const
Definition: recording.h:160
bool IsPesRecording(void) const
Definition: recording.h:174
time_t Deleted(void) const
Definition: recording.h:137
int LengthInSeconds(void) const
Returns the length (in seconds) of this recording, or -1 in case of error.
void DelAll(void)
Deletes/terminates all operations.
cRecordingsHandlerEntry * Get(const char *FileName)
bool Add(int Usage, const char *FileNameSrc, const char *FileNameDst=NULL)
Adds the given FileNameSrc to the recordings handler for (later) processing.
bool Finished(bool &Error)
Returns true if all operations in the list have been finished.
virtual void Action(void)
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
virtual ~cRecordingsHandler()
int GetUsage(const char *FileName)
Returns the usage type for the given FileName.
cList< cRecordingsHandlerEntry > operations
void Del(const char *FileName)
Deletes the given FileName from the list of operations.
void ResetResume(const char *ResumeFileName=NULL)
static cVideoDirectoryScannerThread * videoDirectoryScannerThread
void UpdateByName(const char *FileName)
double MBperMinute(void) const
Returns the average data rate (in MB/min) of all recordings, or -1 if this value is unknown.
cRecording * GetByName(const char *FileName)
Definition: recording.h:266
cRecordings(bool Deleted=false)
static cRecordings deletedRecordings
int GetNumRecordingsInPath(const char *Path) const
Returns the total number of recordings in the given Path, including all sub-folders of Path.
static const cRecordings * GetRecordingsRead(cStateKey &StateKey, int TimeoutMs=0)
Gets the list of recordings for read access.
Definition: recording.h:240
const cRecording * GetById(int Id) const
static int lastRecordingId
static void TouchUpdate(void)
Touches the '.update' file in the video directory, so that other instances of VDR that access the sam...
static const cRecordings * GetDeletedRecordingsRead(cStateKey &StateKey, int TimeoutMs=0)
Gets the list of deleted recordings for read access.
Definition: recording.h:246
static cRecordings * GetDeletedRecordingsWrite(cStateKey &StateKey, int TimeoutMs=0)
Gets the list of deleted recordings for write access.
Definition: recording.h:249
void AddByName(const char *FileName, bool TriggerUpdate=true)
int TotalFileSizeMB(void) const
static cRecordings * GetRecordingsWrite(cStateKey &StateKey, int TimeoutMs=0)
Gets the list of recordings for write access.
Definition: recording.h:243
static time_t lastUpdate
virtual ~cRecordings()
void Add(cRecording *Recording)
static cRecordings recordings
void DelByName(const char *FileName)
bool MoveRecordings(const char *OldPath, const char *NewPath)
Moves all recordings in OldPath to NewPath.
static const char * UpdateFileName(void)
cRecording * GetById(int Id)
Definition: recording.h:264
void ClearSortNames(void)
static bool NeedsUpdate(void)
static char * updateFileName
const cRecording * GetByName(const char *FileName) const
static void Update(bool Wait=false)
Triggers an update of the list of recordings, which will run as a separate thread if Wait is false.
int PathIsInUse(const char *Path) const
Checks whether any recording in the given Path is currently in use and therefore the whole Path shall...
bool Save(int Index)
int Read(void)
void Delete(void)
cResumeFile(const char *FileName, bool IsPesRecording)
cUnbufferedFile is used for large files that are mainly written or read in a streaming manner,...
eRecordingsSortMode
eRecordingsSortDir
unsigned char uchar
@ ruSrc
Definition: recording.h:37
@ ruCut
Definition: recording.h:33
@ ruReplay
Definition: recording.h:31
@ ruCopy
Definition: recording.h:35
@ ruCanceled
Definition: recording.h:41
@ ruTimer
Definition: recording.h:30
@ ruDst
Definition: recording.h:38
@ ruNone
Definition: recording.h:29
@ ruMove
Definition: recording.h:34
@ ruPending
Definition: recording.h:40
int DirectoryNameMax
Definition: recording.c:77
cString GetRecordingTimerId(const char *Directory)
Definition: recording.c:3283
@ rsmName
Definition: recording.h:550
@ rsmTime
Definition: recording.h:550
#define DEFAULTFRAMESPERSECOND
Definition: recording.h:352
int HMSFToIndex(const char *HMSF, double FramesPerSecond=DEFAULTFRAMESPERSECOND)
Definition: recording.c:3194
@ rsdDescending
Definition: recording.h:549
@ rsdAscending
Definition: recording.h:549
int DirectoryPathMax
Definition: recording.c:76
void GetRecordingsSortMode(const char *Directory)
Definition: recording.c:3235
eRecordingsSortMode RecordingsSortMode
Definition: recording.c:3228
bool HasRecordingsSortMode(const char *Directory)
Definition: recording.c:3230
DEF_LIST_LOCK(Recordings)
int InstanceId
Definition: recording.c:79
char * ExchangeChars(char *s, bool ToFileSystem)
Definition: recording.c:600
bool DirectoryEncoding
Definition: recording.c:78
void IncRecordingsSortMode(const char *Directory)
Definition: recording.c:3254
void SetRecordingsSortMode(const char *Directory, eRecordingsSortMode SortMode)
Definition: recording.c:3246
cDoneRecordings DoneRecordingsPattern
Definition: recording.c:3085
DEF_LIST_LOCK2(Recordings, DeletedRecordings)
int ReadFrame(cUnbufferedFile *f, uchar *b, int Length, int Max)
Definition: recording.c:3212
cRecordingsHandler RecordingsHandler
Definition: recording.c:2000
void SetRecordingTimerId(const char *Directory, const char *TimerId)
Definition: recording.c:3265
void RemoveDeletedRecordings(void)
Definition: recording.c:137
int SecondsToFrames(int Seconds, double FramesPerSecond=DEFAULTFRAMESPERSECOND)
Definition: recording.c:3205
cString IndexToHMSF(int Index, bool WithFrame=false, double FramesPerSecond=DEFAULTFRAMESPERSECOND)
Definition: recording.c:3178
bool GenerateIndex(const char *FileName, bool Update=false)
Generates the index of the existing recording with the given FileName.
Definition: recording.c:2891
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...
Definition: recording.c:154