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