-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathepg_events.h
262 lines (175 loc) · 7.43 KB
/
epg_events.h
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
#ifndef VDR_LIVE_EPG_EVENTS_H
#define VDR_LIVE_EPG_EVENTS_H
#include "stdext.h"
// STL headers need to be before VDR tools.h (included by <vdr/channels.h>)
#include <string>
#include <list>
#if TNTVERSION >= 30000
#include <cxxtools/log.h> // must be loaded before any VDR include because of duplicate macros (LOG_ERROR, LOG_DEBUG, LOG_INFO)
#endif
#include "services.h"
#include "recman.h"
#include <vdr/channels.h>
#include <vdr/epg.h>
#include <vdr/recording.h>
namespace vdrlive
{
class EpgInfo;
typedef std::shared_ptr<EpgInfo> EpgInfoPtr;
// -------------------------------------------------------------------------
namespace EpgEvents {
std::string EncodeDomId(tChannelID const &chanId, tEventID eventId);
void DecodeDomId(cSv epgid, tChannelID &chanId, tEventID &eventId);
const cEvent *GetEventByEpgId(cSv epgid);
/**
* Allocate and initialize an epgEvent instance with the
* passed channel and event information.
* Never call this function with a NULL chan pointer
*/
EpgInfoPtr CreateEpgInfo(cChannel const *chan, cEvent const *event, cSv idOverride = cSv());
/**
* This is the inverse creator for epgInfos to the creator above.
*/
EpgInfoPtr CreateEpgInfo(cSv epgid, cSchedules const *schedules);
/**
* Allocate and initialize an epgEvent instance with the
* passed recording information.
*/
EpgInfoPtr CreateEpgInfo(cSv recid, cRecording const *recording, char const *caption = 0);
/**
* Allocate and initialize an epgEvent instance with the
* passed string informations
*/
EpgInfoPtr CreateEpgInfo(cSv id, cSv caption, cSv info);
/**
* Return a list of EpgImage paths for a given epgid.
*/
bool PosterTvscraper(cTvMedia &media, const cEvent *event, const cRecording *recording);
std::list<std::string> EpgImages(cSv epgid);
/**
* Return a list of RecImages in the given folder.
*/
std::list<std::string> RecImages(cSv epgid, cSv recfolder);
/**
* Calculate the duration. A duration can be zero or
* negative. Negative durations are considered invalid by
* LIVE.
*/
int Duration(time_t const startTime, time_t const endTime);
/**
* Calculate the elapsed time of a positive duration. This
* takes into account the startTime and the current time. If
* the current time is not in the interval startTime <=
* currTime <= endTime the return value is -1.
*/
int ElapsedTime(time_t const startTime, time_t const endTime);
} // namespace EpgEvents
// -------------------------------------------------------------------------
class EpgInfo
{
public:
EpgInfo(cSv id, cSv caption);
virtual ~EpgInfo();
virtual cSv Id() const { return m_eventId; }
virtual cSv Caption() const { return m_caption; }
virtual cSv Title() const = 0;
virtual cSv ShortDescr() const = 0;
virtual cSv LongDescr() const = 0;
virtual cChannel const * Channel() const { return 0; }
virtual cSv ChannelName() const;
virtual cSv Archived() const { return cSv(); }
virtual cSv FileName() const { return cSv(); }
virtual std::string const StartTime(const char* format) const;
virtual std::string const EndTime(const char* format) const;
virtual std::string const CurrentTime(const char* format) const;
virtual int Duration() const; // for recordings, this is the length of the recording
virtual int EventDuration() const { return -1; }; // this is always the event duration
virtual int Elapsed() const;
virtual time_t GetStartTime() const = 0;
virtual time_t GetEndTime() const = 0;
virtual cEvent const *Event() const { return NULL; }
private:
std::string m_eventId;
std::string m_caption;
};
// -------------------------------------------------------------------------
class EpgString : public EpgInfo
{
friend EpgInfoPtr EpgEvents::CreateEpgInfo(cSv, cSv, cSv);
public:
EpgString(cSv id, cSv caption, cSv info);
virtual ~EpgString();
virtual cSv Title() const;
virtual cSv ShortDescr() const;
virtual cSv LongDescr() const;
virtual time_t GetStartTime() const;
virtual time_t GetEndTime() const;
virtual cSv FileName() const { return cSv(); }
private:
const std::string m_info;
};
// -------------------------------------------------------------------------
class EpgEvent : public EpgInfo
{
friend EpgInfoPtr EpgEvents::CreateEpgInfo(cChannel const *, cEvent const *, cSv);
public:
EpgEvent(cSv id, cEvent const *event, char const *channelName);
virtual ~EpgEvent();
virtual cSv Title() const { return m_event->Title(); }
virtual cSv ShortDescr() const { return m_event->ShortText(); }
virtual cSv LongDescr() const { return m_event->Description(); }
virtual time_t GetStartTime() const { return m_event->StartTime(); }
virtual time_t GetEndTime() const { return m_event->EndTime(); }
virtual cChannel const * Channel() const { LOCK_CHANNELS_READ; return Channels->GetByChannelID(m_event->ChannelID());}
virtual cSv FileName() const { return cSv(); }
virtual cEvent const *Event() const { return m_event; }
private:
cEvent const * m_event;
};
// -------------------------------------------------------------------------
class EmptyEvent : public EpgInfo
{
friend EpgInfoPtr EpgEvents::CreateEpgInfo(cChannel const *, cEvent const *, cSv);
public:
EmptyEvent(cSv id, tChannelID const &channelID, const char* channelName);
virtual ~EmptyEvent();
virtual cSv Title() const { return tr("No EPG information available"); }
virtual cSv ShortDescr() const { return cSv(); }
virtual cSv LongDescr() const { return cSv(); }
virtual time_t GetStartTime() const { return 0; }
virtual time_t GetEndTime() const { return 0; }
virtual cChannel const * Channel() const { LOCK_CHANNELS_READ; return Channels->GetByChannelID(m_channelID);}
virtual cSv FileName() const { return cSv(); }
private:
tChannelID m_channelID;
};
// -------------------------------------------------------------------------
class EpgRecording : public EpgInfo
{
friend EpgInfoPtr EpgEvents::CreateEpgInfo(cSv, cRecording const *, const char *);
protected:
cSv Name() const;
public:
EpgRecording(cSv recid, cRecording const *recording, char const *caption);
virtual ~EpgRecording();
virtual cSv Caption() const;
virtual cSv Title() const;
virtual cSv ShortDescr() const;
virtual cSv LongDescr() const;
virtual cSv ChannelName() const;
virtual cSv Archived() const;
virtual cSv FileName() const;
virtual time_t GetStartTime() const;
virtual time_t GetEndTime() const;
virtual int EventDuration() const; // this is always the event duration
virtual int Elapsed() const;
private:
const cRecording* m_recording;
bool m_ownCaption;
mutable bool m_checkedArchived;
mutable std::string m_archived;
};
bool appendEpgItem(cToSvConcat<0> &epg_item, RecordingsItemRecPtr &recItem, const cEvent *Event, const cChannel *Channel, bool withChannel);
std::string appendEpgItemWithRecItem(cToSvConcat<0> &epg_item, cSv lastDay, const cEvent *Event, const cChannel *Channel, bool withChannel);
}; // namespace vdrlive
#endif // VDR_LIVE_EPG_EVENTS_H