diff --git a/CONTRIBUTORS b/CONTRIBUTORS index bbcc13ee..c51ead69 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -3469,6 +3469,8 @@ Aitugan Sarbassov Sergey Chernyavskiy for reporting truncated date/time strings in the skins on multi-byte UTF-8 for adding a short sleep to cTSBuffer::Action() to avoid high CPU usage + for making the SVDRP commands that deal with recordings use a unique id for each + recording Frank Richter for adding 'S3W ABS-3A' to sources.conf diff --git a/HISTORY b/HISTORY index 862cdd8d..b376b0f5 100644 --- a/HISTORY +++ b/HISTORY @@ -8953,3 +8953,9 @@ Video Disk Recorder Revision History an "SVDRP default host" has been set for normal timer recordings. - cOsdMenu::Display() now checks whether the OSD size has changed and if so calls SetDisplayMenu(). +- The SVDRP commands that deal with recordings (DELR, EDIT, LSTR, MOVR, and PLAY) + now use a unique id for each recording, which remains valid as long as this + instance of VDR is running. This means that recordings are no longer continuously + numbered from 1 to N in LSTR. There may be gaps in the sequence, in case recordings + have been deleted, and they are not necessarily listed in numeric order. + Thanks to Sergey Chernyavskiy. diff --git a/recording.c b/recording.c index 63980585..9f96b73d 100644 --- a/recording.c +++ b/recording.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: recording.c 4.7 2017/01/01 17:52:51 kls Exp $ + * $Id: recording.c 4.8 2017/04/03 13:34:30 kls Exp $ */ #include "recording.h" @@ -753,6 +753,7 @@ char *LimitNameLengths(char *s, int PathMax, int NameMax) cRecording::cRecording(cTimer *Timer, const cEvent *Event) { + id = 0; resume = RESUME_NOT_INITIALIZED; titleBuffer = NULL; sortBufferName = sortBufferTime = NULL; @@ -808,6 +809,7 @@ cRecording::cRecording(cTimer *Timer, const cEvent *Event) cRecording::cRecording(const char *FileName) { + id = 0; resume = RESUME_NOT_INITIALIZED; fileSizeMB = -1; // unknown channel = -1; @@ -1000,6 +1002,11 @@ void cRecording::ClearSortName(void) sortBufferName = sortBufferTime = NULL; } +void cRecording::SetId(int Id) +{ + id = Id; +} + int cRecording::GetResume(void) const { if (resume == RESUME_NOT_INITIALIZED) { @@ -1456,6 +1463,7 @@ void cVideoDirectoryScannerThread::ScanVideoDir(const char *DirName, int LinkLev cRecordings cRecordings::recordings; cRecordings cRecordings::deletedRecordings(true); +int cRecordings::lastRecordingId = 0; char *cRecordings::updateFileName = NULL; cVideoDirectoryScannerThread *cRecordings::videoDirectoryScannerThread = NULL; time_t cRecordings::lastUpdate = 0; @@ -1507,6 +1515,15 @@ void cRecordings::Update(bool Wait) } } +const cRecording *cRecordings::GetById(int Id) const +{ + for (const cRecording *Recording = First(); Recording; Recording = Next(Recording)) { + if (Recording->Id() == Id) + return Recording; + } + return NULL; +} + const cRecording *cRecordings::GetByName(const char *FileName) const { if (FileName) { @@ -1518,6 +1535,12 @@ const cRecording *cRecordings::GetByName(const char *FileName) const return NULL; } +void cRecordings::Add(cRecording *Recording) +{ + Recording->SetId(++lastRecordingId); + cList::Add(Recording); +} + void cRecordings::AddByName(const char *FileName, bool TriggerUpdate) { if (!GetByName(FileName)) { diff --git a/recording.h b/recording.h index b649f6fd..200af45a 100644 --- a/recording.h +++ b/recording.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: recording.h 4.4 2016/12/13 13:12:12 kls Exp $ + * $Id: recording.h 4.5 2017/04/03 13:31:16 kls Exp $ */ #ifndef __RECORDING_H @@ -97,6 +97,7 @@ public: class cRecording : public cListObject { friend class cRecordings; private: + int id; mutable int resume; mutable char *titleBuffer; mutable char *sortBufferName; @@ -116,6 +117,7 @@ private: static char *StripEpisodeName(char *s, bool Strip); char *SortName(void) const; void ClearSortName(void); + void SetId(int Id); // should only be set by cRecordings time_t start; int priority; int lifetime; @@ -124,6 +126,7 @@ public: cRecording(cTimer *Timer, const cEvent *Event); cRecording(const char *FileName); virtual ~cRecording(); + int Id(void) const { return id; } time_t Start(void) const { return start; } int Priority(void) const { return priority; } int Lifetime(void) const { return lifetime; } @@ -222,6 +225,7 @@ class cRecordings : public cList { private: static cRecordings recordings; static cRecordings deletedRecordings; + static int lastRecordingId; static char *updateFileName; static time_t lastUpdate; static cVideoDirectoryScannerThread *videoDirectoryScannerThread; @@ -254,8 +258,11 @@ public: static bool NeedsUpdate(void); void ResetResume(const char *ResumeFileName = NULL); void ClearSortNames(void); + const cRecording *GetById(int Id) const; + cRecording *GetById(int Id) { return const_cast(static_cast(this)->GetById(Id)); }; const cRecording *GetByName(const char *FileName) const; cRecording *GetByName(const char *FileName) { return const_cast(static_cast(this)->GetByName(FileName)); } + void Add(cRecording *Recording); void AddByName(const char *FileName, bool TriggerUpdate = true); void DelByName(const char *FileName); void UpdateByName(const char *FileName); diff --git a/svdrp.c b/svdrp.c index 1697cc6a..2b3ade10 100644 --- a/svdrp.c +++ b/svdrp.c @@ -10,7 +10,7 @@ * and interact with the Video Disk Recorder - or write a full featured * graphical interface that sits on top of an SVDRP connection. * - * $Id: svdrp.c 4.11 2016/12/08 10:48:53 kls Exp $ + * $Id: svdrp.c 4.12 2017/04/03 13:56:52 kls Exp $ */ #include "svdrp.h" @@ -723,18 +723,19 @@ const char *HelpPages[] = { " interfere with data from the broadcasters.", "DELC \n" " Delete channel.", - "DELR \n" - " Delete the recording with the given number. Before a recording can be\n" - " deleted, an LSTR command must have been executed in order to retrieve\n" - " the recording numbers. The numbers don't change during subsequent DELR\n" - " commands. CAUTION: THERE IS NO CONFIRMATION PROMPT WHEN DELETING A\n" + "DELR \n" + " Delete the recording with the given id. Before a recording can be\n" + " deleted, an LSTR command should have been executed in order to retrieve\n" + " the recording ids. The ids are unique and don't change while this\n" + " instance of VDR is running.\n" + " CAUTION: THERE IS NO CONFIRMATION PROMPT WHEN DELETING A\n" " RECORDING - BE SURE YOU KNOW WHAT YOU ARE DOING!", "DELT \n" " Delete timer.", - "EDIT \n" - " Edit the recording with the given number. Before a recording can be\n" - " edited, an LSTR command must have been executed in order to retrieve\n" - " the recording numbers.", + "EDIT \n" + " Edit the recording with the given id. Before a recording can be\n" + " edited, an LSTR command should have been executed in order to retrieve\n" + " the recording ids.", "GRAB [ [ ] ]\n" " Grab the current frame and save it to the given file. Images can\n" " be stored as JPEG or PNM, depending on the given file name extension.\n" @@ -764,11 +765,13 @@ const char *HelpPages[] = { " only data for that channel is listed. 'now', 'next', or 'at