1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
/*
* status.h: A plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
*/
#ifndef __status_h_
#define __status_h_
#include <vdr/status.h>
// #include <chrono>
#include "setup.h"
#if __GNUC__ > 3
#define UNUSED(v) UNUSED_ ## v __attribute__((unused))
#else
#define UNUSED(x) x
#endif
enum eVpsLog {
VPS_ERROR = 0,
VPS_INFO = 1,
VPS_DEBUG = 2,
};
class cEpgEventLog;
struct sRecording {
char *title = nullptr;
char *fileName = nullptr;
pid_t pid = 0;
char status = 0;
bool changedByUser = false;
bool ignoreEIT = false;
// event
char *eventTitle = nullptr;
tEventID eventID = 0;
tEventID eventNextID = 0;
tEventID eitEventID = 0;
tEventID eitEventNextID = 0;
time_t eventStartTime = 0;
time_t eventStopTime = 0;
tChannelID eventChannelID = tChannelID::InvalidID;
// timer
time_t timerStartTime = 0;
time_t timerStopTime = 0;
bool timerVPS = false;
tChannelID timerChannelID = tChannelID::InvalidID;
char *timerChannelName = nullptr;
// VPS
int runningStatus = 0;
time_t recStart = 0;
time_t vpsStartTime = 0;
time_t vpsStopTime = 0;
time_t vpsPauseStartTime = 0;
time_t vpsPauseStopTime = 0;
cEpgEventLog *epgEventLog;
};
// epg event log
class cEpgEventLog {
public:
explicit cEpgEventLog(const char *recDir);
~cEpgEventLog();
cEpgEventLog(const cEpgEventLog &origin) { // copy constructor, not used, only for formal reason
eventLogFile = nullptr;
};
cEpgEventLog &operator =(const cEpgEventLog *origin) { // operator=, not used, only for formal reason
eventLogFile = nullptr;
return *this;
};
void LogState(const int severity, const sRecording *recording, const int newState, const char* action);
void LogEvent(const int severity, const char *title, char *eventLog);
private:
FILE *eventLogFile = nullptr;
};
class cEpgHandlerMarkad;
// --- cStatusMarkAd
class cStatusMarkAd : public cStatus {
private:
struct sRecording recs[MAXDEVICES*MAXRECEIVERS];
int max_recs = -1;
const char *bindir = nullptr;
const char *logodir = nullptr;
int actpos = 0;
struct setup *setup = nullptr;
int runningRecordings = 0;
bool getPid(int Position);
bool getStatus(int Position);
bool Replaying();
int Get(const char *FileName, const char *Name = nullptr);
int Add(const char *Name, const char *FileName, sRecording *recording);
void Remove(int pos, bool Kill = false);
void Remove(const char *Name, bool Kill = false);
void Pause(const char *FileName);
void Continue(const char *FileName);
bool LogoExists(const cDevice *Device, const char *FileName);
void GetEventID(const cDevice *Device,const char *Name, sRecording *recording);
void SaveVPSTimer(const char *FileName, const bool timerVPS);
void SaveVPSEvents(const int index);
bool StoreVPSStatus(const char *status, const int index);
cEpgHandlerMarkad *epgHandlerMarkad = nullptr;
protected:
virtual void Recording(const cDevice *Device, const char *Name, const char *FileName, bool On);
virtual void Replaying(const cControl *Control, const char *Name, const char *FileName, bool On);
virtual void TimerChange(const cTimer *Timer, eTimerChange Change);
public:
cStatusMarkAd(const char *BinDir, const char *LogoDir, struct setup *Setup);
~cStatusMarkAd();
bool MarkAdRunning(void);
void ResetActPos(void) {
actpos=0;
}
char *GetStatus();
void Check(void);
bool GetNextActive(struct sRecording **RecEntry);
bool Start(const char *Name, const char *FileName, const bool direct, sRecording *recording);
int Get_EIT_EventID(const sRecording *recording, const cEvent *event, const SI::EIT::Event *eitEvent, const cSchedule *schedule, const bool nextEvent);
void FindRecording(const cEvent *event, const SI::EIT::Event *eitEvent, const cSchedule *Schedule);
void SetVPSStatus(const int index, int runningStatus, const bool eventEIT);
};
// epg handler
class cEpgHandlerMarkad : public cEpgHandler {
public:
explicit cEpgHandlerMarkad(cStatusMarkAd *statusMonitor) {
StatusMarkAd = statusMonitor;
};
~cEpgHandlerMarkad(void) {};
virtual bool HandleEitEvent(cSchedule *Schedule, const SI::EIT::Event *EitEvent, uchar TableID, uchar Version);
virtual bool HandleEvent(cEvent *Event);
private:
cStatusMarkAd *StatusMarkAd = nullptr;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
};
#endif
|