MythTV  master
recordinginfo.h
Go to the documentation of this file.
1 #ifndef _RECORDING_INFO_H_
2 #define _RECORDING_INFO_H_
3 
4 #include <QDateTime>
5 #include <QString>
6 
7 #include "mythtvexp.h"
8 #include "programinfo.h"
9 #include "recordingfile.h"
10 #include "enums/recStatus.h"
11 
12 class RecordingRule;
13 
22 // Note: methods marked with "//pi" could be moved to ProgramInfo without
23 // breaking linkage or adding new classes to libmyth. For some of them
24 // RecordingRule::signalChange would need to be moved to remoteutil.{cpp,h},
25 // but that is a static method which is fairly easy to move.
26 // These methods are in RecordingInfo because it currently makes sense
27 // for them to be in this class in terms of related functions being here.
28 
29 class RecordingInfo;
31 
33 
35 {
36  public:
37  RecordingInfo(void) :
38  oldrecstatus(RecStatus::Unknown),
39  savedrecstatus(RecStatus::Unknown),
40  future(false),
41  schedorder(0),
42  mplexid(0),
43  sgroupid(0),
44  desiredrecstartts(),
45  desiredrecendts(),
46  record(nullptr),
47  m_recordingFile(nullptr) { LoadRecordingFile(); }
48  RecordingInfo(const RecordingInfo &other) :
49  ProgramInfo(other),
50  oldrecstatus(other.oldrecstatus),
51  savedrecstatus(other.savedrecstatus),
52  future(other.future),
53  schedorder(other.schedorder),
54  mplexid(other.mplexid),
55  sgroupid(other.sgroupid),
56  desiredrecstartts(other.desiredrecstartts),
57  desiredrecendts(other.desiredrecendts),
58  record(nullptr),
59  m_recordingFile(nullptr) { LoadRecordingFile(); }
60  explicit RecordingInfo(const ProgramInfo &other) :
61  ProgramInfo(other),
62  oldrecstatus(RecStatus::Unknown),
63  savedrecstatus(RecStatus::Unknown),
64  future(false),
65  schedorder(0),
66  mplexid(0),
67  sgroupid(0),
68  desiredrecstartts(startts),
69  desiredrecendts(endts),
70  record(nullptr),
71  m_recordingFile(nullptr) { LoadRecordingFile(); }
72  explicit RecordingInfo(uint _recordedid) :
73  ProgramInfo(_recordedid),
74  oldrecstatus(RecStatus::Unknown),
75  savedrecstatus(RecStatus::Unknown),
76  future(false),
77  schedorder(0),
78  mplexid(0),
79  sgroupid(0),
80  desiredrecstartts(startts),
81  desiredrecendts(endts),
82  record(nullptr),
83  m_recordingFile(nullptr) { LoadRecordingFile(); }
84  RecordingInfo(uint _chanid, const QDateTime &_recstartts) :
85  ProgramInfo(_chanid, _recstartts),
86  oldrecstatus(RecStatus::Unknown),
87  savedrecstatus(RecStatus::Unknown),
88  future(false),
89  schedorder(0),
90  mplexid(0),
91  sgroupid(0),
92  desiredrecstartts(startts),
93  desiredrecendts(endts),
94  record(nullptr),
95  m_recordingFile(nullptr) { LoadRecordingFile(); }
96  RecordingInfo(QStringList::const_iterator &it,
97  QStringList::const_iterator end) :
98  ProgramInfo(it, end),
99  oldrecstatus(RecStatus::Unknown),
100  savedrecstatus(RecStatus::Unknown),
101  future(false),
102  schedorder(0),
103  mplexid(0),
104  sgroupid(0),
105  desiredrecstartts(startts),
106  desiredrecendts(endts),
107  record(nullptr),
108  m_recordingFile(nullptr) { LoadRecordingFile(); }
112  const QString &title,
113  const QString &sortTitle,
114  const QString &subtitle,
115  const QString &sortSubtitle,
116  const QString &description,
117  uint season,
118  uint episode,
119  uint totalepisodes,
120  const QString &syndicatedepisode,
121  const QString &category,
122 
123  uint chanid,
124  const QString &chanstr,
125  const QString &chansign,
126  const QString &channame,
127 
128  const QString &recgroup,
129  const QString &playgroup,
130 
131  const QString &hostname,
132  const QString &storagegroup,
133 
134  uint year,
135  uint partnumber,
136  uint parttotal,
137 
138  const QString &seriesid,
139  const QString &programid,
140  const QString &inetref,
141  const CategoryType catType,
142 
143  int recpriority,
144 
145  const QDateTime &startts,
146  const QDateTime &endts,
147  const QDateTime &recstartts,
148  const QDateTime &recendts,
149 
150  float stars,
151  const QDate &originalAirDate,
152 
153  bool repeat,
154 
155  RecStatus::Type oldrecstatus,
156  bool reactivate,
157 
158  uint recordid,
159  uint parentid,
160  RecordingType rectype,
161  RecordingDupInType dupin,
162  RecordingDupMethodType dupmethod,
163 
164  uint sourceid,
165  uint cardid,
166 
167  uint findid,
168 
169  bool commfree,
170  uint subtitleType,
171  uint videoproperties,
172  uint audioproperties,
173  bool future,
174  int schedorder,
175  uint mplexid,
176  uint sgroupid,
177  const QString &inputname);
178 
182  const QString &title,
183  const QString &sortTitle,
184  const QString &subtitle,
185  const QString &sortSubtitle,
186  const QString &description,
187  uint season,
188  uint episode,
189  const QString &category,
190 
191  uint chanid,
192  const QString &chanstr,
193  const QString &chansign,
194  const QString &channame,
195 
196  const QString &recgroup,
197  const QString &playgroup,
198 
199  const QString &seriesid,
200  const QString &programid,
201  const QString &inetref,
202 
203  int recpriority,
204 
205  const QDateTime &startts,
206  const QDateTime &endts,
207  const QDateTime &recstartts,
208  const QDateTime &recendts,
209 
210  RecStatus::Type recstatus,
211 
212  uint recordid,
213  RecordingType rectype,
214  RecordingDupInType dupin,
215  RecordingDupMethodType dupmethod,
216 
217  uint findid,
218 
219  bool commfree);
220 
221  // Create ProgramInfo that overlaps the desired time on the
222  // specified channel id.
223  typedef enum {
224  kNoProgram = 0,
225  kFoundProgram = 1,
226  kFakedLiveTVProgram = 2,
227  kFakedZeroMinProgram = 3,
228  } LoadStatus;
229  RecordingInfo(uint _chanid, const QDateTime &desiredts,
230  bool genUnknown, uint maxHours = 0,
231  LoadStatus *status = nullptr);
232 
233  typedef enum {
234  kDefaultRecGroup = 1, // Auto-increment columns start at one
235  kLiveTVRecGroup = 2,
236  kDeletedRecGroup = 3,
237  } SpecialRecordingGroups;
238 
239  public:
241  { clone(other); return *this; }
243  { clone(other); return *this; }
244  virtual void clone(const RecordingInfo &other,
245  bool ignore_non_serialized_data = false);
246  void clone(const ProgramInfo &other,
247  bool ignore_non_serialized_data = false) override; // ProgramInfo
248 
249  void clear(void) override; // ProgramInfo
250 
251  // Destructor
252  virtual ~RecordingInfo();
253 
254  // Serializers
255  void SubstituteMatches(QString &str) override; // ProgramInfo
256 
257  void SetRecordingID(uint _recordedid) override // ProgramInfo
258  { recordedid = _recordedid;
259  m_recordingFile->m_recordingId = _recordedid; }
260 
261  // Quick gets
264  QString MakeUniqueSchedulerKey(void) const
265  { return MakeUniqueKey(chanid, startts); }
266 
267  // Used to query and set RecordingRule info
268  RecordingRule *GetRecordingRule(void);
269  int getRecordID(void);
270  static bool QueryRecordedIdForKey(int & recordedid,
271  uint chanid, QDateTime recstartts);
272  int GetAutoRunJobs(void) const;
273  RecordingType GetProgramRecordingStatus(void);
274  QString GetProgramRecordingProfile(void) const;
275  void ApplyRecordStateChange(RecordingType newstate, bool save = true);
276  void ApplyRecordRecPriorityChange(int);
277  void QuickRecord(void);
278 
279  // Used in determining start and end for RecordingQuality determination
280  void SetDesiredStartTime(const QDateTime &dt) { desiredrecstartts = dt; }
281  void SetDesiredEndTime(const QDateTime &dt) { desiredrecendts = dt; }
282  QDateTime GetDesiredStartTime(void) const { return desiredrecstartts; }
283  QDateTime GetDesiredEndTime(void) const { return desiredrecendts; }
284 
285  // these five can be moved to programinfo
286  void AddHistory(bool resched = true, bool forcedup = false,
287  bool future = false);//pi
288  void DeleteHistory(void);//pi
289  void ForgetHistory(void);//pi
290  void SetDupHistory(void);//pi
291 
292  // Used to update database with recording info
293  void StartedRecording(QString ext);
294  void FinishedRecording(bool allowReRecord);
295  void UpdateRecordingEnd(void);//pi
296  void ReactivateRecording(void);//pi
297  void ApplyRecordRecID(void);//pi
298  void ApplyRecordRecGroupChange(const QString &newrecgroup);
299  void ApplyRecordRecGroupChange(int newrecgroupid);
300  void ApplyRecordPlayGroupChange(const QString &newrecgroup);
301  void ApplyStorageGroupChange(const QString &newstoragegroup);
302  void ApplyRecordRecTitleChange(const QString &newTitle,
303  const QString &newSubtitle,
304  const QString &newDescription);
305  void ApplyTranscoderProfileChange(const QString &profile) const;//pi
306  void ApplyTranscoderProfileChangeById(int);
307  void ApplyNeverRecord(void);
308 
309  // Temporary while we transition from string to integer
310  static QString GetRecgroupString(uint recGroupID);
311  static uint GetRecgroupID(const QString &recGroup);
312 
313  // File specific metdata
314  void LoadRecordingFile();
315  RecordingFile *GetRecordingFile() const { return m_recordingFile; }
316  void SaveFilesize(uint64_t fsize) override; // ProgramInfo
317  void SetFilesize( uint64_t sz ) override; // ProgramInfo
318  uint64_t GetFilesize(void) const override; // ProgramInfo
319 
322  bool future;
324  uint mplexid; // Only valid within the scheduler
325  uint sgroupid; // Only valid within the scheduler
326  QDateTime desiredrecstartts;
327  QDateTime desiredrecendts;
328 
329  private:
330  mutable class RecordingRule *record;
332 
333  protected:
334  static bool InsertProgram(RecordingInfo *pg,
335  const RecordingRule *rule);
336 
337  static QString unknownTitle;
338 };
339 
342 
343 #endif // _RECORDING_INFO_H_
344 
345 /* vim: set expandtab tabstop=4 shiftwidth=4: */
RecordingInfo & operator=(const RecordingInfo &other)
virtual uint64_t GetFilesize(void) const
void SetRecordingID(uint _recordedid) override
virtual void SubstituteMatches(QString &str)
Subsitute MATCH% type variable names in the given string.
enum RecordingDupInTypes RecordingDupInType
QDateTime GetDesiredEndTime(void) const
RecordingInfo(void)
Definition: recordinginfo.h:37
RecordingFile * m_recordingFile
Holds information on a TV Program one might wish to record.
Definition: recordinginfo.h:34
QDateTime desiredrecstartts
unsigned int uint
Definition: compat.h:140
RecordingFile * GetRecordingFile() const
void SetDesiredEndTime(const QDateTime &dt)
Q_DECLARE_METATYPE(GrabberScript *)
QString MakeUniqueSchedulerKey(void) const
Creates a unique string that can be used to identify a scheduled recording.
RecordingDupMethodType
QString MakeUniqueKey(void) const
Creates a unique string that can be used to identify an existing recording.
Definition: programinfo.h:333
RecordingInfo(const ProgramInfo &other)
Definition: recordinginfo.h:60
Holds information on recordings and videos.
Definition: programinfo.h:66
virtual void SaveFilesize(uint64_t fsize)
Sets recording file size in database, and sets "filesize" field.
VERBOSE_PREAMBLE false
Definition: verbosedefs.h:85
#define MTV_PUBLIC
Definition: mythtvexp.h:15
string hostname
Definition: caa.py:17
static QString unknownTitle
Internal representation of a recording rule, mirrors the record table.
Definition: recordingrule.h:31
Holds information on a recording file and it's video and audio streams.
Definition: recordingfile.h:29
RecStatus::Type oldrecstatus
class RecordingRule * record
RecordingInfo(uint _recordedid)
Definition: recordinginfo.h:72
virtual void clear(void)
RecordingInfo(const RecordingInfo &other)
Definition: recordinginfo.h:48
AutoDeleteDeque< RecordingInfo * > RecordingList
Definition: recordinginfo.h:30
QDateTime desiredrecendts
RecordingInfo(QStringList::const_iterator &it, QStringList::const_iterator end)
Definition: recordinginfo.h:96
virtual void SetFilesize(uint64_t sz)
virtual void clone(const ProgramInfo &other, bool ignore_non_serialized_data=false)
Copies important fields from other ProgramInfo.
RecordingInfo & operator=(const ProgramInfo &other)
RecStatus::Type savedrecstatus
RecordingInfo(uint _chanid, const QDateTime &_recstartts)
Definition: recordinginfo.h:84
void SetDesiredStartTime(const QDateTime &dt)
QDateTime GetDesiredStartTime(void) const