cRecording now fetches priority, lifetime and framesPerSecond from cRecordingInfo

This commit is contained in:
Klaus Schmidinger
2025-04-15 19:38:46 +02:00
parent a069c388f7
commit e5b8ac3370
4 changed files with 37 additions and 34 deletions

View File

@@ -10119,6 +10119,8 @@ Video Disk Recorder Revision History
- Now deleting old recording info before reading modified info file (suggested by
Stefan Hofmann).
2025-04-12:
2025-04-15:
- Fixed some misplaced 'override' keywords in the 'hello' and 'skincurses' plugins.
- cRecording now fetches priority, lifetime and framesPerSecond from cRecordingInfo.
APIVERSNUM is now 30008.

View File

@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: config.h 5.30 2025/04/12 08:32:04 kls Exp $
* $Id: config.h 5.31 2025/04/15 19:38:46 kls Exp $
*/
#ifndef __CONFIG_H
@@ -27,8 +27,8 @@
// The plugin API's version number:
#define APIVERSION "7"
#define APIVERSNUM 30007
#define APIVERSION "8"
#define APIVERSNUM 30008
// When loading plugins, VDR searches files by their APIVERSION, which
// is different from VDRVERSION. APIVERSION is a plain number, incremented

View File

@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: recording.c 5.39 2025/04/11 12:39:03 kls Exp $
* $Id: recording.c 5.40 2025/04/15 19:38:46 kls Exp $
*/
#include "recording.h"
@@ -467,6 +467,16 @@ void cRecordingInfo::SetFramesPerSecond(double FramesPerSecond)
framesPerSecond = FramesPerSecond;
}
void cRecordingInfo::SetPriority(int Priority)
{
priority = Priority;
}
void cRecordingInfo::SetLifetime(int Lifetime)
{
lifetime = Lifetime;
}
void cRecordingInfo::SetFrameParams(uint16_t FrameWidth, uint16_t FrameHeight, eScanType ScanType, eAspectRatio AspectRatio)
{
frameWidth = FrameWidth;
@@ -869,7 +879,6 @@ cRecording::cRecording(cTimer *Timer, const cEvent *Event)
instanceId = InstanceId;
isPesRecording = false;
isOnVideoDirectoryFileSystem = -1; // unknown
framesPerSecond = DEFAULTFRAMESPERSECOND;
numFrames = -1;
deleted = 0;
// set up the actual name:
@@ -903,13 +912,11 @@ cRecording::cRecording(cTimer *Timer, const cEvent *Event)
// substitute characters that would cause problems in file names:
strreplace(name, '\n', ' ');
start = Timer->StartTime();
priority = Timer->Priority();
lifetime = Timer->Lifetime();
// handle info:
info = new cRecordingInfo(Timer->Channel(), Event);
info->SetAux(Timer->Aux());
info->priority = priority;
info->lifetime = lifetime;
info->SetPriority(Timer->Priority());
info->SetLifetime(Timer->Lifetime());
}
cRecording::cRecording(const char *FileName)
@@ -919,11 +926,8 @@ cRecording::cRecording(const char *FileName)
fileSizeMB = -1; // unknown
channel = -1;
instanceId = -1;
priority = MAXPRIORITY; // assume maximum in case there is no info file
lifetime = MAXLIFETIME;
isPesRecording = false;
isOnVideoDirectoryFileSystem = -1; // unknown
framesPerSecond = DEFAULTFRAMESPERSECOND;
numFrames = -1;
deleted = 0;
titleBuffer = NULL;
@@ -942,6 +946,8 @@ cRecording::cRecording(const char *FileName)
struct tm tm_r;
struct tm t = *localtime_r(&now, &tm_r); // this initializes the time zone in 't'
t.tm_isdst = -1; // makes sure mktime() will determine the correct DST setting
int priority = MAXPRIORITY;
int lifetime = MAXLIFETIME;
if (7 == sscanf(p + 1, DATAFORMATTS, &t.tm_year, &t.tm_mon, &t.tm_mday, &t.tm_hour, &t.tm_min, &channel, &instanceId)
|| 7 == sscanf(p + 1, DATAFORMATPES, &t.tm_year, &t.tm_mon, &t.tm_mday, &t.tm_hour, &t.tm_min, &priority, &lifetime)) {
t.tm_year -= 1900;
@@ -963,10 +969,9 @@ cRecording::cRecording(const char *FileName)
if (f) {
if (!info->Read(f))
esyslog("ERROR: EPG data problem in file %s", *InfoFileName);
else if (!isPesRecording) {
priority = info->priority;
lifetime = info->lifetime;
framesPerSecond = info->framesPerSecond;
else if (isPesRecording) {
info->SetPriority(priority);
info->SetLifetime(lifetime);
}
fclose(f);
}
@@ -1156,8 +1161,8 @@ const char *cRecording::FileName(void) const
struct tm tm_r;
struct tm *t = localtime_r(&start, &tm_r);
const char *fmt = isPesRecording ? NAMEFORMATPES : NAMEFORMATTS;
int ch = isPesRecording ? priority : channel;
int ri = isPesRecording ? lifetime : instanceId;
int ch = isPesRecording ? info->Priority() : channel;
int ri = isPesRecording ? info->Lifetime() : instanceId;
char *Name = LimitNameLengths(strdup(name), DirectoryPathMax - strlen(cVideoDirectory::Name()) - 1 - 42, DirectoryNameMax); // 42 = length of an actual recording directory name (generated with DATAFORMATTS) plus some reserve
if (strcmp(Name, name) != 0)
dsyslog("recording file name '%s' truncated to '%s'", name, Name);
@@ -1279,9 +1284,6 @@ bool cRecording::DeleteMarks(void)
void cRecording::ReadInfo(void)
{
info->Read();
priority = info->priority;
lifetime = info->lifetime;
framesPerSecond = info->framesPerSecond;
}
bool cRecording::WriteInfo(const char *OtherFileName)
@@ -1316,10 +1318,10 @@ bool cRecording::ChangePriorityLifetime(int NewPriority, int NewLifetime)
{
if (NewPriority != Priority() || NewLifetime != Lifetime()) {
dsyslog("changing priority/lifetime of '%s' to %d/%d", Name(), NewPriority, NewLifetime);
info->SetPriority(NewPriority);
info->SetLifetime(NewLifetime);
if (IsPesRecording()) {
cString OldFileName = FileName();
priority = NewPriority;
lifetime = NewLifetime;
free(fileName);
fileName = NULL;
cString NewFileName = FileName();
@@ -1328,8 +1330,6 @@ bool cRecording::ChangePriorityLifetime(int NewPriority, int NewLifetime)
info->SetFileName(NewFileName);
}
else {
priority = info->priority = NewPriority;
lifetime = info->lifetime = NewLifetime;
if (!WriteInfo())
return false;
}
@@ -1465,7 +1465,7 @@ int cRecording::NumFramesAfterEdit(void) const
int IndexLength = cIndexFile::GetLength(fileName, isPesRecording);
if (IndexLength > 0) {
cMarks Marks;
if (Marks.Load(fileName, framesPerSecond, isPesRecording))
if (Marks.Load(fileName, FramesPerSecond(), isPesRecording))
return Marks.GetFrameAfterEdit(IndexLength - 1, IndexLength - 1);
}
return -1;

View File

@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: recording.h 5.13 2025/03/02 11:03:35 kls Exp $
* $Id: recording.h 5.14 2025/04/15 19:38:46 kls Exp $
*/
#ifndef __RECORDING_H
@@ -93,6 +93,8 @@ public:
const cComponents *Components(void) const { return event->Components(); }
const char *Aux(void) const { return aux; }
double FramesPerSecond(void) const { return framesPerSecond; }
int Priority(void) const { return priority; }
int Lifetime(void) const { return lifetime; }
uint16_t FrameWidth(void) const { return frameWidth; }
uint16_t FrameHeight(void) const { return frameHeight; }
eScanType ScanType(void) const { return scanType; }
@@ -101,6 +103,8 @@ public:
const char *AspectRatioText(void) const { return AspectRatioTexts[aspectRatio]; }
cString FrameParams(void) const;
void SetFramesPerSecond(double FramesPerSecond);
void SetPriority(int Priority);
void SetLifetime(int Lifetime);
void SetFrameParams(uint16_t FrameWidth, uint16_t FrameHeight, eScanType ScanType, eAspectRatio AspectRatio);
void SetFileName(const char *FileName);
int Errors(void) const { return errors; } // returns -1 if undefined
@@ -128,7 +132,6 @@ private:
int instanceId;
bool isPesRecording;
mutable int isOnVideoDirectoryFileSystem; // -1 = unknown, 0 = no, 1 = yes
double framesPerSecond;
cRecordingInfo *info;
cRecording(const cRecording&); // can't copy cRecording
cRecording &operator=(const cRecording &); // can't assign cRecording
@@ -137,8 +140,6 @@ private:
void ClearSortName(void);
void SetId(int Id); // should only be set by cRecordings
time_t start;
int priority;
int lifetime;
time_t deleted;
public:
cRecording(cTimer *Timer, const cEvent *Event);
@@ -146,8 +147,8 @@ public:
virtual ~cRecording() override;
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; }
int Priority(void) const { return info->Priority(); }
int Lifetime(void) const { return info->Lifetime(); }
time_t Deleted(void) const { return deleted; }
void SetDeleted(void) { deleted = time(NULL); }
virtual int Compare(const cListObject &ListObject) const override;
@@ -171,7 +172,7 @@ public:
const char *PrefixFileName(char Prefix);
int HierarchyLevels(void) const;
void ResetResume(void) const;
double FramesPerSecond(void) const { return framesPerSecond; }
double FramesPerSecond(void) const { return info->FramesPerSecond(); }
int NumFrames(void) const;
///< Returns the number of frames in this recording.
///< If the number of frames is unknown, -1 will be returned.