vdr 2.7.5
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.13 2025/03/02 11:03:35 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#include "remux.h"
21
22#define FOLDERDELIMCHAR '~'
23
24extern int DirectoryPathMax;
25extern int DirectoryNameMax;
26extern bool DirectoryEncoding;
27extern int InstanceId;
28
30 ruNone = 0x0000, // the recording is currently unused
31 ruTimer = 0x0001, // the recording is currently written to by a timer
32 ruReplay = 0x0002, // the recording is being replayed
33 // mutually exclusive:
34 ruCut = 0x0004, // the recording is being cut
35 ruMove = 0x0008, // the recording is being moved
36 ruCopy = 0x0010, // the recording is being copied
37 // mutually exclusive:
38 ruSrc = 0x0020, // the recording is the source of a cut, move or copy process
39 ruDst = 0x0040, // the recording is the destination of a cut, move or copy process
40 //
41 ruPending = 0x0080, // the recording is pending a cut, move or copy process
42 ruCanceled = 0x8000, // the operation has been canceled, waiting for cleanup
43 };
44
46void AssertFreeDiskSpace(int Priority = 0, bool Force = false);
51
53private:
54 char *fileName;
56public:
57 cResumeFile(const char *FileName, bool IsPesRecording);
59 int Read(void);
60 bool Save(int Index);
61 void Delete(void);
62 };
63
65 friend class cRecording;
66private:
67 time_t modified;
70 const cEvent *event;
72 char *aux;
74 uint16_t frameWidth;
75 uint16_t frameHeight;
80 char *fileName;
81 int errors;
82 cRecordingInfo(const cChannel *Channel = NULL, const cEvent *Event = NULL);
83 bool Read(FILE *f);
84public:
85 cRecordingInfo(const char *FileName);
87 tChannelID ChannelID(void) const { return channelID; }
88 const char *ChannelName(void) const { return channelName; }
89 const cEvent *GetEvent(void) const { return event; }
90 const char *Title(void) const { return event->Title(); }
91 const char *ShortText(void) const { return event->ShortText(); }
92 const char *Description(void) const { return event->Description(); }
93 const cComponents *Components(void) const { return event->Components(); }
94 const char *Aux(void) const { return aux; }
95 double FramesPerSecond(void) const { return framesPerSecond; }
96 uint16_t FrameWidth(void) const { return frameWidth; }
97 uint16_t FrameHeight(void) const { return frameHeight; }
98 eScanType ScanType(void) const { return scanType; }
99 char ScanTypeChar(void) const { return ScanTypeChars[scanType]; }
100 eAspectRatio AspectRatio(void) const { return aspectRatio; }
101 const char *AspectRatioText(void) const { return AspectRatioTexts[aspectRatio]; }
102 cString FrameParams(void) const;
105 void SetFileName(const char *FileName);
106 int Errors(void) const { return errors; } // returns -1 if undefined
107 void SetErrors(int Errors);
108 bool Write(FILE *f, const char *Prefix = "") const;
109 bool Read(void);
110 bool Write(void) const;
111 void SetData(const char *Title, const char *ShortText, const char *Description);
112 void SetAux(const char *Aux);
113 };
114
115class cRecording : public cListObject {
116 friend class cRecordings;
117private:
118 int id;
119 mutable int resume;
120 mutable char *titleBuffer;
121 mutable char *sortBufferName;
122 mutable char *sortBufferTime;
123 mutable char *fileName;
124 mutable char *name;
125 mutable int fileSizeMB;
126 mutable int numFrames;
130 mutable int isOnVideoDirectoryFileSystem; // -1 = unknown, 0 = no, 1 = yes
133 cRecording(const cRecording&); // can't copy cRecording
134 cRecording &operator=(const cRecording &); // can't assign cRecording
135 static char *StripEpisodeName(char *s, bool Strip);
136 char *SortName(void) const;
137 void ClearSortName(void);
138 void SetId(int Id); // should only be set by cRecordings
139 time_t start;
142 time_t deleted;
143public:
144 cRecording(cTimer *Timer, const cEvent *Event);
145 cRecording(const char *FileName);
146 virtual ~cRecording() override;
147 int Id(void) const { return id; }
148 time_t Start(void) const { return start; }
149 int Priority(void) const { return priority; }
150 int Lifetime(void) const { return lifetime; }
151 time_t Deleted(void) const { return deleted; }
152 void SetDeleted(void) { deleted = time(NULL); }
153 virtual int Compare(const cListObject &ListObject) const override;
154 bool IsInPath(const char *Path) const;
157 cString Folder(void) const;
160 cString BaseName(void) const;
163 const char *Name(void) const { return name; }
166 const char *FileName(void) const;
169 const char *Title(char Delimiter = ' ', bool NewIndicator = false, int Level = -1) const;
170 cRecordingInfo *Info(void) const { return info; }
171 const char *PrefixFileName(char Prefix);
172 int HierarchyLevels(void) const;
173 void ResetResume(void) const;
174 double FramesPerSecond(void) const { return framesPerSecond; }
175 int NumFrames(void) const;
178 int NumFramesAfterEdit(void) const;
182 int LengthInSeconds(void) const;
184 int LengthInSecondsAfterEdit(void) const;
187 int FileSizeMB(void) const;
190 int GetResume(void) const;
193 bool IsNew(void) const { return GetResume() <= 0; }
194 bool IsEdited(void) const;
195 bool IsPesRecording(void) const { return isPesRecording; }
196 bool IsOnVideoDirectoryFileSystem(void) const;
197 bool HasMarks(void) const;
199 bool DeleteMarks(void);
203 void ReadInfo(void);
204 bool WriteInfo(const char *OtherFileName = NULL);
208 void SetStartTime(time_t Start);
216 bool ChangePriorityLifetime(int NewPriority, int NewLifetime);
220 bool ChangeName(const char *NewName);
227 bool Delete(void);
230 bool Remove(void);
233 bool Undelete(void);
237 int IsInUse(void) const;
245 };
246
248
249class cRecordings : public cList<cRecording> {
250private:
253 static int lastRecordingId;
254 static char *updateFileName;
255 static time_t lastUpdate;
257 static const char *UpdateFileName(void);
258public:
259 cRecordings(bool Deleted = false);
260 virtual ~cRecordings() override;
261 static const cRecordings *GetRecordingsRead(cStateKey &StateKey, int TimeoutMs = 0) { return recordings.Lock(StateKey, false, TimeoutMs) ? &recordings : NULL; }
264 static cRecordings *GetRecordingsWrite(cStateKey &StateKey, int TimeoutMs = 0) { return recordings.Lock(StateKey, true, TimeoutMs) ? &recordings : NULL; }
267 static const cRecordings *GetDeletedRecordingsRead(cStateKey &StateKey, int TimeoutMs = 0) { return deletedRecordings.Lock(StateKey, false, TimeoutMs) ? &deletedRecordings : NULL; }
270 static cRecordings *GetDeletedRecordingsWrite(cStateKey &StateKey, int TimeoutMs = 0) { return deletedRecordings.Lock(StateKey, true, TimeoutMs) ? &deletedRecordings : NULL; }
273 static void Update(bool Wait = false);
277 static void TouchUpdate(void);
281 static bool NeedsUpdate(void);
282 void ResetResume(const char *ResumeFileName = NULL);
283 void ClearSortNames(void);
284 const cRecording *GetById(int Id) const;
285 cRecording *GetById(int Id) { return const_cast<cRecording *>(static_cast<const cRecordings *>(this)->GetById(Id)); };
286 const cRecording *GetByName(const char *FileName) const;
287 cRecording *GetByName(const char *FileName) { return const_cast<cRecording *>(static_cast<const cRecordings *>(this)->GetByName(FileName)); }
288 void Add(cRecording *Recording);
289 void AddByName(const char *FileName, bool TriggerUpdate = true);
290 void DelByName(const char *FileName);
291 void UpdateByName(const char *FileName);
292 int TotalFileSizeMB(void) const;
293 double MBperMinute(void) const;
296 int PathIsInUse(const char *Path) const;
304 int GetNumRecordingsInPath(const char *Path) const;
308 bool MoveRecordings(const char *OldPath, const char *NewPath);
317 };
318
319// Provide lock controlled access to the list:
320
321DEF_LIST_LOCK(Recordings);
322DEF_LIST_LOCK2(Recordings, DeletedRecordings);
323
324// These macros provide a convenient way of locking the global recordings list
325// and making sure the lock is released as soon as the current scope is left
326// (note that these macros wait forever to obtain the lock!):
327
328#define LOCK_RECORDINGS_READ USE_LIST_LOCK_READ(Recordings)
329#define LOCK_RECORDINGS_WRITE USE_LIST_LOCK_WRITE(Recordings)
330#define LOCK_DELETEDRECORDINGS_READ USE_LIST_LOCK_READ2(Recordings, DeletedRecordings)
331#define LOCK_DELETEDRECORDINGS_WRITE USE_LIST_LOCK_WRITE2(Recordings, DeletedRecordings)
332
334
336private:
340 bool error;
341 cRecordingsHandlerEntry *Get(const char *FileName);
342protected:
343 virtual void Action(void) override;
344public:
345 cRecordingsHandler(void);
346 virtual ~cRecordingsHandler() override;
347 bool Add(int Usage, const char *FileNameSrc, const char *FileNameDst = NULL);
355 void Del(const char *FileName);
360 void DelAll(void);
362 int GetUsage(const char *FileName);
364 int GetRequiredDiskSpaceMB(const char *FileName = NULL);
368 bool Finished(bool &Error);
373 };
374
376
377#define DEFAULTFRAMESPERSECOND 25.0
378
379class cMark : public cListObject {
380 friend class cMarks; // for sorting
381private:
385public:
386 cMark(int Position = 0, const char *Comment = NULL, double FramesPerSecond = DEFAULTFRAMESPERSECOND);
387 virtual ~cMark() override;
388 int Position(void) const { return position; }
389 const char *Comment(void) const { return comment; }
391 void SetComment(const char *Comment) { comment = Comment; }
392 cString ToText(void);
393 bool Parse(const char *s);
394 bool Save(FILE *f);
395 };
396
397class cMarks : public cConfig<cMark> {
398private:
406public:
407 cMarks(void): cConfig<cMark>("Marks") {};
408 static cString MarksFileName(const cRecording *Recording);
411 static bool DeleteMarksFile(const cRecording *Recording);
412 bool Load(const char *RecordingFileName, double FramesPerSecond = DEFAULTFRAMESPERSECOND, bool IsPesRecording = false);
413 bool Update(void);
414 bool Save(void);
415 void Align(void);
416 void Sort(void);
417 void Add(int Position);
423 const cMark *Get(int Position) const;
424 const cMark *GetPrev(int Position) const;
425 const cMark *GetNext(int Position) const;
426 const cMark *GetNextBegin(const cMark *EndMark = NULL) const;
430 const cMark *GetNextEnd(const cMark *BeginMark) const;
433 int GetNumSequences(void) const;
439 int GetFrameAfterEdit(int Frame, int LastFrame) const;
443 cMark *Get(int Position) { return const_cast<cMark *>(static_cast<const cMarks *>(this)->Get(Position)); }
444 cMark *GetPrev(int Position) { return const_cast<cMark *>(static_cast<const cMarks *>(this)->GetPrev(Position)); }
445 cMark *GetNext(int Position) { return const_cast<cMark *>(static_cast<const cMarks *>(this)->GetNext(Position)); }
446 cMark *GetNextBegin(const cMark *EndMark = NULL) { return const_cast<cMark *>(static_cast<const cMarks *>(this)->GetNextBegin(EndMark)); }
447 cMark *GetNextEnd(const cMark *BeginMark) { return const_cast<cMark *>(static_cast<const cMarks *>(this)->GetNextEnd(BeginMark)); }
448 };
449
450class cErrors : public cVector<int> {
451 };
452
453#define RUC_BEFORERECORDING "before"
454#define RUC_STARTRECORDING "started"
455#define RUC_AFTERRECORDING "after"
456#define RUC_EDITINGRECORDING "editing"
457#define RUC_EDITEDRECORDING "edited"
458#define RUC_DELETERECORDING "deleted"
459#define RUC_RENAMEDRECORDING "renamed" // same directory, only the base name is changed
460#define RUC_MOVEDRECORDING "moved" // different directory (and maybe base name), or "copy" to other filesystem + delete original (triggers copying->copied->deleted)
461#define RUC_COPYINGRECORDING "copying"
462#define RUC_COPIEDRECORDING "copied"
463
465private:
466 static const char *command;
467public:
468 static void SetCommand(const char *Command) { command = Command; }
469 static void InvokeCommand(const char *State, const char *RecordingFileName, const char *SourceFileName = NULL);
470 };
471
472// The maximum size of a single frame (up to HDTV 1920x1080):
473#define MAXFRAMESIZE (KILOBYTE(1024) / TS_SIZE * TS_SIZE) // multiple of TS_SIZE to avoid breaking up TS packets
474
475// The maximum file size is limited by the range that can be covered
476// with a 40 bit 'unsigned int', which is 1TB. The actual maximum value
477// used is 6MB below the theoretical maximum, to have some safety (the
478// actual file size may be slightly higher because we stop recording only
479// before the next independent frame, to have a complete Group Of Pictures):
480#define MAXVIDEOFILESIZETS 1048570 // MB
481#define MAXVIDEOFILESIZEPES 2000 // MB
482#define MINVIDEOFILESIZE 100 // MB
483#define MAXVIDEOFILESIZEDEFAULT MAXVIDEOFILESIZEPES
484
485struct tIndexTs;
487
489private:
490 int f;
492 int size, last;
494 tIndexTs *index;
500 void ConvertFromPes(tIndexTs *IndexTs, int Count);
501 void ConvertToPes(tIndexTs *IndexTs, int Count);
502 bool CatchUp(int Index = -1);
503public:
504 cIndexFile(const char *FileName, bool Record, bool IsPesRecording = false, bool PauseLive = false, bool Update = false);
505 ~cIndexFile();
506 bool Ok(void) { return index != NULL; }
507 bool Write(bool Independent, uint16_t FileNumber, off_t FileOffset, bool Errors = false, bool Missing = false);
508 bool Get(int Index, uint16_t *FileNumber, off_t *FileOffset, bool *Independent = NULL, int *Length = NULL, bool *Errors = NULL, bool *Missing = NULL);
509 const cErrors *GetErrors(void);
511 int GetNextIFrame(int Index, bool Forward, uint16_t *FileNumber = NULL, off_t *FileOffset = NULL, int *Length = NULL);
512 int GetClosestIFrame(int Index);
517 int Get(uint16_t FileNumber, off_t FileOffset);
518 int Last(void) { CatchUp(); return last; }
520 int GetResume(void) { return resumeFile.Read(); }
521 bool StoreResume(int Index) { return resumeFile.Save(Index); }
522 bool IsStillRecording(void);
523 void Delete(void);
524 static int GetLength(const char *FileName, bool IsPesRecording = false);
527 static cString IndexFileName(const char *FileName, bool IsPesRecording);
528 };
529
531private:
533 uint16_t fileNumber;
535 bool record;
538public:
539 cFileName(const char *FileName, bool Record, bool Blocking = false, bool IsPesRecording = false);
540 ~cFileName();
541 const char *Name(void) { return fileName; }
542 uint16_t Number(void) { return fileNumber; }
543 bool GetLastPatPmtVersions(int &PatVersion, int &PmtVersion);
544 cUnbufferedFile *Open(void);
545 void Close(void);
546 cUnbufferedFile *SetOffset(int Number, off_t Offset = 0); // yes, Number is int for easier internal calculating
548 };
549
551private:
554 void Add(const char *Title);
555public:
556 bool Load(const char *FileName);
557 bool Save(void) const;
558 void Append(const char *Title);
559 bool Contains(const char *Title) const;
560 };
561
563
564cString IndexToHMSF(int Index, bool WithFrame = false, double FramesPerSecond = DEFAULTFRAMESPERSECOND);
565 // Converts the given index to a string, optionally containing the frame number.
566int HMSFToIndex(const char *HMSF, double FramesPerSecond = DEFAULTFRAMESPERSECOND);
567 // Converts the given string (format: "hh:mm:ss.ff") to an index.
568int SecondsToFrames(int Seconds, double FramesPerSecond = DEFAULTFRAMESPERSECOND);
569 // Returns the number of frames corresponding to the given number of seconds.
570
571int ReadFrame(cUnbufferedFile *f, uchar *b, int Length, int Max);
572
573char *ExchangeChars(char *s, bool ToFileSystem);
574 // Exchanges the characters in the given string to or from a file system
575 // specific representation (depending on ToFileSystem). The given string will
576 // be modified and may be reallocated if more space is needed. The return
577 // value points to the resulting string, which may be different from s.
578
579bool GenerateIndex(const char *FileName, bool Update = false);
584
588bool HasRecordingsSortMode(const char *Directory);
589void GetRecordingsSortMode(const char *Directory);
590void SetRecordingsSortMode(const char *Directory, eRecordingsSortMode SortMode);
591void IncRecordingsSortMode(const char *Directory);
592
593void SetRecordingTimerId(const char *Directory, const char *TimerId);
594cString GetRecordingTimerId(const char *Directory);
595
596int FileSizeMBafterEdit(const char *FileName);
597bool EnoughFreeDiskSpaceForEdit(const char *FileName);
598
599#endif //__RECORDING_H
cConfig(const char *NeedsLocking=NULL)
Definition config.h:132
cStringList doneRecordings
Definition recording.h:553
bool Save(void) const
Definition recording.c:3330
void Add(const char *Title)
Definition recording.c:3349
cString fileName
Definition recording.h:552
void Append(const char *Title)
Definition recording.c:3354
bool Load(const char *FileName)
Definition recording.c:3309
bool Contains(const char *Title) const
Definition recording.c:3377
Definition epg.h:73
bool isPesRecording
Definition recording.h:537
cUnbufferedFile * NextFile(void)
Definition recording.c:3300
uint16_t Number(void)
Definition recording.h:542
bool record
Definition recording.h:535
void Close(void)
Definition recording.c:3248
uint16_t fileNumber
Definition recording.h:533
cUnbufferedFile * Open(void)
Definition recording.c:3224
cFileName(const char *FileName, bool Record, bool Blocking=false, bool IsPesRecording=false)
Definition recording.c:3149
char * fileName
Definition recording.h:534
char * pFileNumber
Definition recording.h:534
const char * Name(void)
Definition recording.h:541
bool GetLastPatPmtVersions(int &PatVersion, int &PmtVersion)
Definition recording.c:3173
bool blocking
Definition recording.h:536
cUnbufferedFile * SetOffset(int Number, off_t Offset=0)
Definition recording.c:3258
cUnbufferedFile * file
Definition recording.h:532
int GetNextIFrame(int Index, bool Forward, uint16_t *FileNumber=NULL, off_t *FileOffset=NULL, int *Length=NULL)
Definition recording.c:3007
bool Write(bool Independent, uint16_t FileNumber, off_t FileOffset, bool Errors=false, bool Missing=false)
Definition recording.c:2949
cResumeFile resumeFile
Definition recording.h:496
bool IsStillRecording(void)
Definition recording.c:3087
void ConvertFromPes(tIndexTs *IndexTs, int Count)
Definition recording.c:2868
static int GetLength(const char *FileName, bool IsPesRecording=false)
Calculates the recording length (number of frames) without actually reading the index file.
Definition recording.c:3104
bool CatchUp(int Index=-1)
Definition recording.c:2893
const cErrors * GetErrors(void)
Returns the frame indexes of errors in the recording (if any).
Definition recording.c:2996
int GetResume(void)
Definition recording.h:520
void ConvertToPes(tIndexTs *IndexTs, int Count)
Definition recording.c:2880
bool isPesRecording
Definition recording.h:495
cErrors errors
Definition recording.h:497
int lastErrorIndex
Definition recording.h:493
cString fileName
Definition recording.h:491
bool StoreResume(int Index)
Definition recording.h:521
cIndexFile(const char *FileName, bool Record, bool IsPesRecording=false, bool PauseLive=false, bool Update=false)
Definition recording.c:2765
cIndexFileGenerator * indexFileGenerator
Definition recording.h:498
static cString IndexFileName(const char *FileName, bool IsPesRecording)
Definition recording.c:2863
int GetClosestIFrame(int Index)
Returns the index of the I-frame that is closest to the given Index (or Index itself,...
Definition recording.c:3045
bool Ok(void)
Definition recording.h:506
cMutex mutex
Definition recording.h:499
bool Get(int Index, uint16_t *FileNumber, off_t *FileOffset, bool *Independent=NULL, int *Length=NULL, bool *Errors=NULL, bool *Missing=NULL)
Definition recording.c:2966
void Delete(void)
Definition recording.c:3092
int Last(void)
Returns the index of the last entry in this file, or -1 if the file is empty.
Definition recording.h:518
tIndexTs * index
Definition recording.h:494
cListObject(const cListObject &ListObject)
Definition tools.h:534
Definition tools.h:631
cList(const char *NeedsLocking=NULL)
Definition tools.h:633
cMark(int Position=0, const char *Comment=NULL, double FramesPerSecond=DEFAULTFRAMESPERSECOND)
Definition recording.c:2263
cString comment
Definition recording.h:384
int position
Definition recording.h:383
bool Parse(const char *s)
Definition recording.c:2279
friend class cMarks
Definition recording.h:380
bool Save(FILE *f)
Definition recording.c:2293
cString ToText(void)
Definition recording.c:2274
const char * Comment(void) const
Definition recording.h:389
double framesPerSecond
Definition recording.h:382
void SetPosition(int Position)
Definition recording.h:390
int Position(void) const
Definition recording.h:388
virtual ~cMark() override
Definition recording.c:2270
void SetComment(const char *Comment)
Definition recording.h:391
int GetNumSequences(void) const
Returns the actual number of sequences to be cut from the recording.
Definition recording.c:2459
double framesPerSecond
Definition recording.h:401
void Add(int Position)
If this cMarks object is used by multiple threads, the caller must Lock() it before calling Add() and...
Definition recording.c:2392
const cMark * GetNextBegin(const cMark *EndMark=NULL) const
Returns the next "begin" mark after EndMark, skipping any marks at the same position as EndMark.
Definition recording.c:2425
const cMark * GetNext(int Position) const
Definition recording.c:2416
bool Update(void)
Definition recording.c:2328
bool Load(const char *RecordingFileName, double FramesPerSecond=DEFAULTFRAMESPERSECOND, bool IsPesRecording=false)
Definition recording.c:2316
time_t lastFileTime
Definition recording.h:404
const cMark * GetNextEnd(const cMark *BeginMark) const
Returns the next "end" mark after BeginMark, skipping any marks at the same position as BeginMark.
Definition recording.c:2441
const cMark * Get(int Position) const
Definition recording.c:2398
cString recordingFileName
Definition recording.h:399
bool isPesRecording
Definition recording.h:402
time_t nextUpdate
Definition recording.h:403
cString fileName
Definition recording.h:400
static bool DeleteMarksFile(const cRecording *Recording)
Definition recording.c:2305
void Align(void)
Definition recording.c:2368
int GetFrameAfterEdit(int Frame, int LastFrame) const
Returns the number of the given Frame within the region covered by begin/end sequences.
Definition recording.c:2476
void Sort(void)
Definition recording.c:2380
cMark * Get(int Position)
Definition recording.h:443
cMark * GetNextEnd(const cMark *BeginMark)
Definition recording.h:447
cMarks(void)
Definition recording.h:407
cMark * GetNextBegin(const cMark *EndMark=NULL)
Definition recording.h:446
cMark * GetPrev(int Position)
Definition recording.h:444
static cString MarksFileName(const cRecording *Recording)
Returns the marks file name for the given Recording (regardless whether such a file actually exists).
Definition recording.c:2300
cMark * GetNext(int Position)
Definition recording.h:445
bool Save(void)
Definition recording.c:2359
const cMark * GetPrev(int Position) const
Definition recording.c:2407
time_t lastChange
Definition recording.h:405
char ScanTypeChar(void) const
Definition recording.h:99
const char * ChannelName(void) const
Definition recording.h:88
void SetFramesPerSecond(double FramesPerSecond)
Definition recording.c:465
cEvent * ownEvent
Definition recording.h:71
const cEvent * GetEvent(void) const
Definition recording.h:89
uint16_t FrameHeight(void) const
Definition recording.h:97
const cEvent * event
Definition recording.h:70
uint16_t frameHeight
Definition recording.h:75
int Errors(void) const
Definition recording.h:106
const char * AspectRatioText(void) const
Definition recording.h:101
const char * ShortText(void) const
Definition recording.h:91
eAspectRatio aspectRatio
Definition recording.h:77
eScanType ScanType(void) const
Definition recording.h:98
cRecordingInfo(const cChannel *Channel=NULL, const cEvent *Event=NULL)
Definition recording.c:357
bool Write(void) const
Definition recording.c:625
const char * Title(void) const
Definition recording.h:90
bool Read(void)
Definition recording.c:607
tChannelID channelID
Definition recording.h:68
cString FrameParams(void) const
Definition recording.c:641
const char * Aux(void) const
Definition recording.h:94
eScanType scanType
Definition recording.h:76
friend class cRecording
Definition recording.h:65
tChannelID ChannelID(void) const
Definition recording.h:87
void SetFileName(const char *FileName)
Definition recording.c:478
time_t modified
Definition recording.h:67
char * channelName
Definition recording.h:69
uint16_t FrameWidth(void) const
Definition recording.h:96
void SetFrameParams(uint16_t FrameWidth, uint16_t FrameHeight, eScanType ScanType, eAspectRatio AspectRatio)
Definition recording.c:470
void SetErrors(int Errors)
Definition recording.c:485
void SetAux(const char *Aux)
Definition recording.c:459
void SetData(const char *Title, const char *ShortText, const char *Description)
Definition recording.c:449
const char * Description(void) const
Definition recording.h:92
eAspectRatio AspectRatio(void) const
Definition recording.h:100
uint16_t frameWidth
Definition recording.h:74
double framesPerSecond
Definition recording.h:73
double FramesPerSecond(void) const
Definition recording.h:95
char * fileName
Definition recording.h:80
const cComponents * Components(void) const
Definition recording.h:93
static const char * command
Definition recording.h:466
static void InvokeCommand(const char *State, const char *RecordingFileName, const char *SourceFileName=NULL)
Definition recording.c:2512
static void SetCommand(const char *Command)
Definition recording.h:468
virtual int Compare(const cListObject &ListObject) const override
Must return 0 if this object is equal to ListObject, a positive value if it is "greater",...
Definition recording.c:1124
int isOnVideoDirectoryFileSystem
Definition recording.h:130
virtual ~cRecording() override
Definition recording.c:1040
time_t deleted
Definition recording.h:142
cRecordingInfo * info
Definition recording.h:132
bool ChangePriorityLifetime(int NewPriority, int NewLifetime)
Changes the priority and lifetime of this recording to the given values.
Definition recording.c:1315
bool HasMarks(void) const
Returns true if this recording has any editing marks.
Definition recording.c:1269
cRecording & operator=(const cRecording &)
bool WriteInfo(const char *OtherFileName=NULL)
Writes in info file of this recording.
Definition recording.c:1287
int IsInUse(void) const
Checks whether this recording is currently in use and therefore shall not be tampered with.
Definition recording.c:1431
bool ChangeName(const char *NewName)
Changes the name of this recording to the given value.
Definition recording.c:1340
bool Undelete(void)
Changes the file name so that it will be visible in the "Recordings" menu again and not processed by ...
Definition recording.c:1405
void ResetResume(void) const
Definition recording.c:1447
bool IsNew(void) const
Definition recording.h:193
double framesPerSecond
Definition recording.h:131
bool Delete(void)
Changes the file name so that it will no longer be visible in the "Recordings" menu Returns false in ...
Definition recording.c:1368
cString Folder(void) const
Returns the name of the folder this recording is stored in (without the video directory).
Definition recording.c:1141
bool isPesRecording
Definition recording.h:129
void ClearSortName(void)
Definition recording.c:1103
char * sortBufferName
Definition recording.h:121
int NumFrames(void) const
Returns the number of frames in this recording.
Definition recording.c:1452
bool IsEdited(void) const
Definition recording.c:1256
int Id(void) const
Definition recording.h:147
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...
Definition recording.c:1115
bool IsInPath(const char *Path) const
Returns true if this recording is stored anywhere under the given Path.
Definition recording.c:1133
int fileSizeMB
Definition recording.h:125
void SetId(int Id)
Definition recording.c:1110
void SetStartTime(time_t Start)
Sets the start time of this recording to the given value.
Definition recording.c:1308
char * SortName(void) const
Definition recording.c:1079
const char * Name(void) const
Returns the full name of the recording (without the video directory).
Definition recording.h:163
time_t Start(void) const
Definition recording.h:148
int Lifetime(void) const
Definition recording.h:150
int NumFramesAfterEdit(void) const
Returns the number of frames in the edited version of this recording.
Definition recording.c:1463
const char * FileName(void) const
Returns the full path name to the recording directory, including the video directory and the actual '...
Definition recording.c:1153
cRecordingInfo * Info(void) const
Definition recording.h:170
const char * PrefixFileName(char Prefix)
Definition recording.c:1234
bool DeleteMarks(void)
Deletes the editing marks from this recording (if any).
Definition recording.c:1274
bool IsOnVideoDirectoryFileSystem(void) const
Definition recording.c:1262
int HierarchyLevels(void) const
Definition recording.c:1245
int FileSizeMB(void) const
Returns the total file size of this recording (in MB), or -1 if the file size is unknown.
Definition recording.c:1490
cString BaseName(void) const
Returns the base name of this recording (without the video directory and folder).
Definition recording.c:1148
char * fileName
Definition recording.h:123
char * titleBuffer
Definition recording.h:120
void SetDeleted(void)
Definition recording.h:152
int Priority(void) const
Definition recording.h:149
void ReadInfo(void)
Definition recording.c:1279
const char * Title(char Delimiter=' ', bool NewIndicator=false, int Level=-1) const
Definition recording.c:1171
int instanceId
Definition recording.h:128
bool Remove(void)
Actually removes the file from the disk Returns false in case of error.
Definition recording.c:1394
char * name
Definition recording.h:124
cRecording(const cRecording &)
char * sortBufferTime
Definition recording.h:122
int LengthInSecondsAfterEdit(void) const
Returns the length (in seconds) of the edited version of this recording, or -1 in case of error.
Definition recording.c:1482
time_t start
Definition recording.h:139
int numFrames
Definition recording.h:126
double FramesPerSecond(void) const
Definition recording.h:174
bool IsPesRecording(void) const
Definition recording.h:195
time_t Deleted(void) const
Definition recording.h:151
static char * StripEpisodeName(char *s, bool Strip)
Definition recording.c:1050
int LengthInSeconds(void) const
Returns the length (in seconds) of this recording, or -1 in case of error.
Definition recording.c:1474
friend class cRecordings
Definition recording.h:116
void DelAll(void)
Deletes/terminates all operations.
Definition recording.c:2213
virtual ~cRecordingsHandler() override
Definition recording.c:2132
cRecordingsHandlerEntry * Get(const char *FileName)
Definition recording.c:2162
bool Add(int Usage, const char *FileNameSrc, const char *FileNameDst=NULL)
Adds the given FileNameSrc to the recordings handler for (later) processing.
Definition recording.c:2175
bool Finished(bool &Error)
Returns true if all operations in the list have been finished.
Definition recording.c:2246
int GetUsage(const char *FileName)
Returns the usage type for the given FileName.
Definition recording.c:2220
cList< cRecordingsHandlerEntry > operations
Definition recording.h:338
void Del(const char *FileName)
Deletes the given FileName from the list of operations.
Definition recording.c:2206
virtual void Action(void) override
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
Definition recording.c:2137
int GetRequiredDiskSpaceMB(const char *FileName=NULL)
Returns the total disk space required to process all actions.
Definition recording.c:2228
void ResetResume(const char *ResumeFileName=NULL)
Definition recording.c:1811
void UpdateByName(const char *FileName)
Definition recording.c:1731
static const char * UpdateFileName(void)
Definition recording.c:1637
double MBperMinute(void) const
Returns the average data rate (in MB/min) of all recordings, or -1 if this value is unknown.
Definition recording.c:1750
cRecording * GetByName(const char *FileName)
Definition recording.h:287
virtual ~cRecordings() override
Definition recording.c:1630
cRecordings(bool Deleted=false)
Definition recording.c:1625
int GetNumRecordingsInPath(const char *Path) const
Returns the total number of recordings in the given Path, including all sub-folders of Path.
Definition recording.c:1781
static const cRecordings * GetRecordingsRead(cStateKey &StateKey, int TimeoutMs=0)
Gets the list of recordings for read access.
Definition recording.h:261
const cRecording * GetById(int Id) const
Definition recording.c:1672
static const cRecordings * GetDeletedRecordingsRead(cStateKey &StateKey, int TimeoutMs=0)
Gets the list of deleted recordings for read access.
Definition recording.h:267
static cRecordings * GetDeletedRecordingsWrite(cStateKey &StateKey, int TimeoutMs=0)
Gets the list of deleted recordings for write access.
Definition recording.h:270
static time_t lastUpdate
Definition recording.h:255
static cRecordings deletedRecordings
Definition recording.h:252
void AddByName(const char *FileName, bool TriggerUpdate=true)
Definition recording.c:1698
static cRecordings recordings
Definition recording.h:251
int TotalFileSizeMB(void) const
Definition recording.c:1739
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.
Definition recording.c:1660
static cRecordings * GetRecordingsWrite(cStateKey &StateKey, int TimeoutMs=0)
Gets the list of recordings for write access.
Definition recording.h:264
static void TouchUpdate(void)
Touches the '.update' file in the video directory, so that other instances of VDR that access the sam...
Definition recording.c:1644
void Add(cRecording *Recording)
Definition recording.c:1692
static cVideoDirectoryScannerThread * videoDirectoryScannerThread
Definition recording.h:256
void DelByName(const char *FileName)
Definition recording.c:1709
bool MoveRecordings(const char *OldPath, const char *NewPath)
Moves all recordings in OldPath to NewPath.
Definition recording.c:1791
static bool NeedsUpdate(void)
Definition recording.c:1652
cRecording * GetById(int Id)
Definition recording.h:285
void ClearSortNames(void)
Definition recording.c:1819
static int lastRecordingId
Definition recording.h:253
const cRecording * GetByName(const char *FileName) const
Definition recording.c:1681
static char * updateFileName
Definition recording.h:254
int PathIsInUse(const char *Path) const
Checks whether any recording in the given Path is currently in use and therefore the whole Path shall...
Definition recording.c:1771
bool isPesRecording
Definition recording.h:55
bool Save(int Index)
Definition recording.c:305
char * fileName
Definition recording.h:54
int Read(void)
Definition recording.c:260
void Delete(void)
Definition recording.c:343
cResumeFile(const char *FileName, bool IsPesRecording)
Definition recording.c:242
cThread(const char *Description=NULL, bool LowPriority=false)
Creates a new thread.
Definition thread.c:238
cUnbufferedFile is used for large files that are mainly written or read in a streaming manner,...
Definition tools.h:494
cVector(const cVector &Vector)
Definition tools.h:707
int DirectoryNameMax
Definition recording.c:75
int DirectoryPathMax
Definition recording.c:74
eRecordingsSortMode RecordingsSortMode
Definition recording.c:3450
int InstanceId
Definition recording.c:77
bool DirectoryEncoding
Definition recording.c:76
cDoneRecordings DoneRecordingsPattern
Definition recording.c:3307
cRecordingsHandler RecordingsHandler
Definition recording.c:2123
eRecordingUsage
Definition recording.h:29
@ ruSrc
Definition recording.h:38
@ ruCut
Definition recording.h:34
@ ruReplay
Definition recording.h:32
@ ruCopy
Definition recording.h:36
@ ruCanceled
Definition recording.h:42
@ ruTimer
Definition recording.h:31
@ ruDst
Definition recording.h:39
@ ruNone
Definition recording.h:30
@ ruMove
Definition recording.h:35
@ ruPending
Definition recording.h:41
cString GetRecordingTimerId(const char *Directory)
Definition recording.c:3505
eRecordingsSortMode
Definition recording.h:586
@ rsmName
Definition recording.h:586
@ rsmTime
Definition recording.h:586
#define DEFAULTFRAMESPERSECOND
Definition recording.h:377
int HMSFToIndex(const char *HMSF, double FramesPerSecond=DEFAULTFRAMESPERSECOND)
Definition recording.c:3416
eRecordingsSortDir
Definition recording.h:585
@ rsdDescending
Definition recording.h:585
@ rsdAscending
Definition recording.h:585
void GetRecordingsSortMode(const char *Directory)
Definition recording.c:3457
bool HasRecordingsSortMode(const char *Directory)
Definition recording.c:3452
bool EnoughFreeDiskSpaceForEdit(const char *FileName)
Definition recording.c:3537
char * ExchangeChars(char *s, bool ToFileSystem)
Definition recording.c:687
void IncRecordingsSortMode(const char *Directory)
Definition recording.c:3476
void SetRecordingsSortMode(const char *Directory, eRecordingsSortMode SortMode)
Definition recording.c:3468
int FileSizeMBafterEdit(const char *FileName)
Definition recording.c:3522
int ReadFrame(cUnbufferedFile *f, uchar *b, int Length, int Max)
Definition recording.c:3434
void SetRecordingTimerId(const char *Directory, const char *TimerId)
Definition recording.c:3487
void RemoveDeletedRecordings(void)
Definition recording.c:135
int SecondsToFrames(int Seconds, double FramesPerSecond=DEFAULTFRAMESPERSECOND)
Definition recording.c:3427
cString IndexToHMSF(int Index, bool WithFrame=false, double FramesPerSecond=DEFAULTFRAMESPERSECOND)
Definition recording.c:3400
bool GenerateIndex(const char *FileName, bool Update=false)
Generates the index of the existing recording with the given FileName.
Definition recording.c:3113
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:152
const char * AspectRatioTexts[]
Definition remux.c:2096
const char * ScanTypeChars
Definition remux.c:2095
eAspectRatio
Definition remux.h:514
eScanType
Definition remux.h:507
#define DEF_LIST_LOCK(Class)
Definition tools.h:686
unsigned char uchar
Definition tools.h:31
#define DEF_LIST_LOCK2(Class, Name)
Definition tools.h:669