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) { LoadRecordingFile(); }
38  RecordingInfo(const RecordingInfo &other) :
39  ProgramInfo(other),
40  m_oldrecstatus(other.m_oldrecstatus),
41  m_savedrecstatus(other.m_savedrecstatus),
42  m_future(other.m_future),
43  m_schedorder(other.m_schedorder),
44  m_mplexid(other.m_mplexid),
45  m_sgroupid(other.m_sgroupid),
46  m_desiredrecstartts(other.m_desiredrecstartts),
47  m_desiredrecendts(other.m_desiredrecendts) { LoadRecordingFile(); }
48  explicit RecordingInfo(const ProgramInfo &other) :
49  ProgramInfo(other),
50  m_desiredrecstartts(m_startts),
51  m_desiredrecendts(m_endts) { LoadRecordingFile(); }
52  explicit RecordingInfo(uint _recordedid) :
53  ProgramInfo(_recordedid),
54  m_desiredrecstartts(m_startts),
55  m_desiredrecendts(m_endts) { LoadRecordingFile(); }
56  RecordingInfo(uint _chanid, const QDateTime &_recstartts) :
57  ProgramInfo(_chanid, _recstartts),
58  m_desiredrecstartts(m_startts),
59  m_desiredrecendts(m_endts) { LoadRecordingFile(); }
60  RecordingInfo(QStringList::const_iterator &it,
61  QStringList::const_iterator end) :
62  ProgramInfo(it, end),
63  m_desiredrecstartts(m_startts),
64  m_desiredrecendts(m_endts) { LoadRecordingFile(); }
68  const QString &title,
69  const QString &sortTitle,
70  const QString &subtitle,
71  const QString &sortSubtitle,
72  const QString &description,
73  uint season,
74  uint episode,
75  uint totalepisodes,
76  const QString &syndicatedepisode,
77  const QString &category,
78 
79  uint chanid,
80  const QString &chanstr,
81  const QString &chansign,
82  const QString &channame,
83 
84  const QString &recgroup,
85  const QString &playgroup,
86 
87  const QString &hostname,
88  const QString &storagegroup,
89 
90  uint year,
91  uint partnumber,
92  uint parttotal,
93 
94  const QString &seriesid,
95  const QString &programid,
96  const QString &inetref,
97  const CategoryType catType,
98 
99  int recpriority,
100 
101  const QDateTime &startts,
102  const QDateTime &endts,
103  const QDateTime &recstartts,
104  const QDateTime &recendts,
105 
106  float stars,
107  const QDate &originalAirDate,
108 
109  bool repeat,
110 
111  RecStatus::Type oldrecstatus,
112  bool reactivate,
113 
114  uint recordid,
115  uint parentid,
116  RecordingType rectype,
117  RecordingDupInType dupin,
118  RecordingDupMethodType dupmethod,
119 
120  uint sourceid,
121  uint inputid,
122 
123  uint findid,
124 
125  bool commfree,
126  uint subtitleType,
127  uint videoproperties,
128  uint audioproperties,
129  bool future,
130  int schedorder,
131  uint mplexid,
132  uint sgroupid,
133  const QString &inputname);
134 
138  const QString &title,
139  const QString &sortTitle,
140  const QString &subtitle,
141  const QString &sortSubtitle,
142  const QString &description,
143  uint season,
144  uint episode,
145  const QString &category,
146 
147  uint chanid,
148  const QString &chanstr,
149  const QString &chansign,
150  const QString &channame,
151 
152  const QString &recgroup,
153  const QString &playgroup,
154 
155  const QString &seriesid,
156  const QString &programid,
157  const QString &inetref,
158 
159  int recpriority,
160 
161  const QDateTime &startts,
162  const QDateTime &endts,
163  const QDateTime &recstartts,
164  const QDateTime &recendts,
165 
166  RecStatus::Type recstatus,
167 
168  uint recordid,
169  RecordingType rectype,
170  RecordingDupInType dupin,
171  RecordingDupMethodType dupmethod,
172 
173  uint findid,
174 
175  bool commfree);
176 
177  // Create ProgramInfo that overlaps the desired time on the
178  // specified channel id.
179  typedef enum {
180  kNoProgram = 0,
181  kFoundProgram = 1,
182  kFakedLiveTVProgram = 2,
183  kFakedZeroMinProgram = 3,
184  } LoadStatus;
185  RecordingInfo(uint _chanid, const QDateTime &desiredts,
186  bool genUnknown, uint maxHours = 0,
187  LoadStatus *status = nullptr);
188 
189  typedef enum {
190  kDefaultRecGroup = 1, // Auto-increment columns start at one
191  kLiveTVRecGroup = 2,
192  kDeletedRecGroup = 3,
193  } SpecialRecordingGroups;
194 
195  public:
197  { RecordingInfo::clone(other); return *this; }
199  { RecordingInfo::clone(other); return *this; }
200  virtual void clone(const RecordingInfo &other,
201  bool ignore_non_serialized_data = false);
202  void clone(const ProgramInfo &other,
203  bool ignore_non_serialized_data = false) override; // ProgramInfo
204 
205  void clear(void) override; // ProgramInfo
206 
207  // Destructor
208  virtual ~RecordingInfo();
209 
210  // Serializers
211  void SubstituteMatches(QString &str) override; // ProgramInfo
212 
213  void SetRecordingID(uint _recordedid) override // ProgramInfo
214  { m_recordedid = _recordedid;
215  m_recordingFile->m_recordingId = _recordedid; }
216 
217  // Quick gets
220  QString MakeUniqueSchedulerKey(void) const
221  { return MakeUniqueKey(m_chanid, m_startts); }
222 
223  // Used to query and set RecordingRule info
224  RecordingRule *GetRecordingRule(void);
225  int getRecordID(void);
226  static bool QueryRecordedIdForKey(int & recordedid,
227  uint chanid, const QDateTime& recstartts);
228  int GetAutoRunJobs(void) const;
229  RecordingType GetProgramRecordingStatus(void);
230  QString GetProgramRecordingProfile(void) const;
231  void ApplyRecordStateChange(RecordingType newstate, bool save = true);
232  void ApplyRecordRecPriorityChange(int);
233  void QuickRecord(void);
234 
235  // Used in determining start and end for RecordingQuality determination
236  void SetDesiredStartTime(const QDateTime &dt) { m_desiredrecstartts = dt; }
237  void SetDesiredEndTime(const QDateTime &dt) { m_desiredrecendts = dt; }
238  QDateTime GetDesiredStartTime(void) const { return m_desiredrecstartts; }
239  QDateTime GetDesiredEndTime(void) const { return m_desiredrecendts; }
240 
241  // these five can be moved to programinfo
242  void AddHistory(bool resched = true, bool forcedup = false,
243  bool future = false);//pi
244  void DeleteHistory(void);//pi
245  void ForgetHistory(void);//pi
246  void SetDupHistory(void);//pi
247 
248  // Used to update database with recording info
249  void StartedRecording(const QString& ext);
250  void FinishedRecording(bool allowReRecord);
251  void UpdateRecordingEnd(void);//pi
252  void ReactivateRecording(void);//pi
253  void ApplyRecordRecID(void);//pi
254  void ApplyRecordRecGroupChange(const QString &newrecgroup);
255  void ApplyRecordRecGroupChange(int newrecgroupid);
256  void ApplyRecordPlayGroupChange(const QString &newplaygroup);
257  void ApplyStorageGroupChange(const QString &newstoragegroup);
258  void ApplyRecordRecTitleChange(const QString &newTitle,
259  const QString &newSubtitle,
260  const QString &newDescription);
261  void ApplyTranscoderProfileChange(const QString &profile) const;//pi
262  void ApplyTranscoderProfileChangeById(int);
263  void ApplyNeverRecord(void);
264 
265  // Temporary while we transition from string to integer
266  static QString GetRecgroupString(uint recGroupID);
267  static uint GetRecgroupID(const QString &recGroup);
268 
269  // File specific metdata
270  void LoadRecordingFile();
271  RecordingFile *GetRecordingFile() const { return m_recordingFile; }
272  void SaveFilesize(uint64_t fsize) override; // ProgramInfo
273  void SetFilesize( uint64_t fsize ) override; // ProgramInfo
274  uint64_t GetFilesize(void) const override; // ProgramInfo
275 
278  bool m_future {false};
279  int m_schedorder {0};
280  uint m_mplexid {0}; // Only valid within the scheduler
281  uint m_sgroupid {0}; // Only valid within the scheduler
283  QDateTime m_desiredrecendts;
284 
285  private:
286  mutable class RecordingRule *m_record {nullptr};
287  RecordingFile *m_recordingFile {nullptr};
288 
289  protected:
290  static bool InsertProgram(RecordingInfo *pg,
291  const RecordingRule *rule);
292 
293  static QString s_unknownTitle;
294 };
295 
298 
299 #endif // _RECORDING_INFO_H_
300 
301 /* 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
static QString s_unknownTitle
Holds information on a TV Program one might wish to record.
Definition: recordinginfo.h:34
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:331
virtual void clone(const RecordingInfo &other, bool ignore_non_serialized_data=false)
Copies important fields from other RecordingInfo.
RecordingInfo(const ProgramInfo &other)
Definition: recordinginfo.h:48
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.
QDateTime m_desiredrecendts
#define MTV_PUBLIC
Definition: mythtvexp.h:15
string hostname
Definition: caa.py:17
Internal representation of a recording rule, mirrors the record table.
Definition: recordingrule.h:32
Holds information on a recording file and it's video and audio streams.
Definition: recordingfile.h:29
RecordingInfo(uint _recordedid)
Definition: recordinginfo.h:52
virtual void clear(void)
RecordingInfo(const RecordingInfo &other)
Definition: recordinginfo.h:38
AutoDeleteDeque< RecordingInfo * > RecordingList
Definition: recordinginfo.h:30
QDateTime m_desiredrecstartts
RecordingInfo(QStringList::const_iterator &it, QStringList::const_iterator end)
Definition: recordinginfo.h:60
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)
RecordingInfo(uint _chanid, const QDateTime &_recstartts)
Definition: recordinginfo.h:56
void SetDesiredStartTime(const QDateTime &dt)
QDateTime GetDesiredStartTime(void) const