MythTV  master
programinfo.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 
3 #ifndef MYTHPROGRAM_H_
4 #define MYTHPROGRAM_H_
5 
6 // ANSI C
7 #include <cstdint> // for [u]int[32,64]_t
8 #include <utility>
9 #include <vector> // for GetNextRecordingList
10 
11 #include <QStringList>
12 #include <QDateTime>
13 
14 // MythTV headers
15 #include "autodeletedeque.h"
16 #include "recordingtypes.h"
17 #include "programtypes.h"
18 #include "mythdbcon.h"
19 #include "mythexp.h"
20 #include "mythdate.h"
21 #include "mythtypes.h"
22 #include "enums/recStatus.h"
23 
24 /* If NUMPROGRAMLINES gets updated, then MYTH_PROTO_VERSION and MYTH_PROTO_TOKEN
25  in mythversion.h need to be bumped, and also follow the instructions in
26  myth_version.h about other changes needed when the network protocol changes.
27 */
28 #define NUMPROGRAMLINES 52
29 
30 class ProgramInfo;
32 
63 class MSqlQuery;
64 class ProgramInfoUpdater;
65 class PMapDBReplacement;
66 
68 {
69  friend int pginfo_init_statics(void);
70  public:
71  enum CategoryType { kCategoryNone, kCategoryMovie, kCategorySeries,
72  kCategorySports, kCategoryTVShow };
73 
75  ProgramInfo(void) { ensureSortFields(); }
77  ProgramInfo(const ProgramInfo &other);
79  explicit ProgramInfo(uint recordedid);
81  ProgramInfo(uint chanid, const QDateTime &recstartts);
83  ProgramInfo(uint recordedid,
84  QString title,
85  QString sortTitle,
86  QString subtitle,
87  QString sortSubtitle,
88  QString description,
89  uint season,
90  uint episode,
91  uint totalepisodes,
92  QString syndicatedepisode,
93  QString category,
94 
95  uint chanid,
96  QString channum,
97  QString chansign,
98  QString channame,
99  QString chanplaybackfilters,
100 
101  QString recgroup,
102  QString playgroup,
103 
104  const QString &pathname,
105 
106  QString hostname,
107  QString storagegroup,
108 
109  QString seriesid,
110  QString programid,
111  QString inetref,
112  CategoryType catType,
113 
114  int recpriority,
115 
116  uint64_t filesize,
117 
118  QDateTime startts,
119  QDateTime endts,
120  QDateTime recstartts,
121  QDateTime recendts,
122 
123  float stars,
124 
125  uint year,
126  uint partnumber,
127  uint parttotal,
128 
129  const QDate &originalAirDate,
130  QDateTime lastmodified,
131 
132  RecStatus::Type recstatus,
133 
134  uint recordid,
135 
136  RecordingDupInType dupin,
137  RecordingDupMethodType dupmethod,
138 
139  uint findid,
140 
141  uint programflags,
142  uint audioproperties,
143  uint videoproperties,
144  uint subtitleType,
145  QString inputname,
146  QDateTime bookmarkupdate);
147 
149  ProgramInfo(QString title,
150  QString sortTitle,
151  QString subtitle,
152  QString sortSubtitle,
153  QString description,
154  uint season,
155  uint episode,
156  QString category,
157 
158  uint chanid,
159  QString channum,
160  QString chansign,
161  QString channame,
162 
163  QString seriesid,
164  QString programid,
165  QString inetref,
166 
167  QDateTime startts,
168  QDateTime endts,
169  QDateTime recstartts,
170  QDateTime recendts,
171 
172  RecStatus::Type recstatus,
173 
174  uint recordid,
175 
176  RecordingType rectype,
177 
178  uint findid,
179 
180  bool duplicate);
181 
183  ProgramInfo(QString title,
184  QString sortTitle,
185  QString subtitle,
186  QString sortSubtitle,
187  QString description,
188  QString syndicatedepisode,
189  QString category,
190 
191  uint chanid,
192  QString channum,
193  QString chansign,
194  QString channame,
195  QString chanplaybackfilters,
196 
197  QDateTime startts,
198  QDateTime endts,
199  QDateTime recstartts,
200  QDateTime recendts,
201 
202  QString seriesid,
203  QString programid,
204  CategoryType catType,
205 
206  float stars,
207  uint year,
208  uint partnumber,
209  uint parttotal,
210  const QDate &originalAirDate,
211  RecStatus::Type recstatus,
212  uint recordid,
213  RecordingType rectype,
214  uint findid,
215 
216  bool commfree,
217  bool repeat,
218 
219  uint videoproperties,
220  uint audioproperties,
221  uint subtitletype,
222 
223  uint season,
224  uint episode,
225  uint totalepisodes,
226 
227  const ProgramList &schedList);
229  ProgramInfo(QString title,
230  QString sortTitle,
231  QString subtitle,
232  QString sortSubtitle,
233  QString description,
234  uint season,
235  uint episode,
236  uint totalepisodes,
237  QString category,
238 
239  uint chanid,
240  QString channum,
241  QString chansign,
242  QString channame,
243  QString chanplaybackfilters,
244 
245  QString recgroup,
246  QString playgroup,
247 
248  QDateTime startts,
249  QDateTime endts,
250  QDateTime recstartts,
251  QDateTime recendts,
252 
253  QString seriesid,
254  QString programid,
255  QString inetref,
256  QString inputname);
258  explicit ProgramInfo(const QString &pathname);
260  ProgramInfo(const QString &pathname,
261  const QString &plot,
262  const QString &title,
263  const QString &sortTitle,
264  const QString &subtitle,
265  const QString &sortSubtitle,
266  const QString &director,
267  int season, int episode,
268  const QString &inetref,
269  uint length_in_minutes,
270  uint year,
271  const QString &programid);
273  ProgramInfo(const QString &_title, uint _chanid,
274  const QDateTime &_startts, const QDateTime &_endts);
276  ProgramInfo(QString _title, QString _category,
277  QDateTime _startts, QDateTime _endts)
278  : m_title(std::move(_title)), m_category(std::move(_category)),
279  m_startTs(std::move(_startts)), m_endTs(std::move(_endts))
280  { ensureSortFields(); }
281  ProgramInfo(QStringList::const_iterator &it,
282  const QStringList::const_iterator& end)
283  {
284  if (!FromStringList(it, end))
286  }
287  explicit ProgramInfo(const QStringList &list)
288  {
289  QStringList::const_iterator it = list.begin();
290  if (!FromStringList(it, list.end()))
292  }
293 
294  bool operator==(const ProgramInfo& rhs);
295  ProgramInfo &operator=(const ProgramInfo &other);
296  virtual void clone(const ProgramInfo &other,
297  bool ignore_non_serialized_data = false);
298  void ensureSortFields(void);
299 
300  virtual void clear(void);
301 
302  // Destructor
303  virtual ~ProgramInfo() = default;
304 
305  // Serializers
306  void ToStringList(QStringList &list) const;
307  virtual void ToMap(InfoMap &progMap,
308  bool showrerecord = false,
309  uint star_range = 10) const;
310  virtual void SubstituteMatches(QString &str);
311 
312  // Used for scheduling recordings
313  bool IsSameProgram(const ProgramInfo &other) const; // Exact same program
314  bool IsDuplicateProgram(const ProgramInfo &other) const; // Is this program considered a duplicate according to rule type and dup method (scheduler only)
315  bool IsSameProgramAndStartTime(const ProgramInfo &other) const; // Exact same program and same starttime, Any channel
316  bool IsSameTitleStartTimeAndChannel(const ProgramInfo &other) const; // Same title, starttime and channel
317  bool IsSameTitleTimeslotAndChannel(const ProgramInfo &other) const;//sched only - Same title, starttime, endtime and channel
318  static bool UsingProgramIDAuthority(void)
319  {
320  return s_usingProgIDAuth;
321  };
322  static void CheckProgramIDAuthorities(void);//sched only
323 
324  // Used for extending scheduled recordings
325  bool IsSameProgramWeakCheck(const ProgramInfo &other) const;
326  bool IsSameRecording(const ProgramInfo &other) const
327  { return m_chanId == other.m_chanId && m_recStartTs == other.m_recStartTs; }
328  bool IsSameChannel(const ProgramInfo &other) const;
329 
330  // Quick gets
333  QString MakeUniqueKey(void) const
334  { return MakeUniqueKey(m_chanId, m_recStartTs); }
335  uint GetSecondsInRecording(void) const;
336  QString ChannelText(const QString& format) const;
337  QString GetPathname(void) const { return m_pathname; }
338  QString GetBasename(void) const { return m_pathname.section('/', -1); }
339  bool IsVideoFile(void) const
340  { return GetProgramInfoType() == kProgramInfoTypeVideoFile; }
341  bool IsVideoDVD(void) const
342  { return GetProgramInfoType() == kProgramInfoTypeVideoDVD; }
343  bool IsVideoBD(void) const
344  { return GetProgramInfoType() == kProgramInfoTypeVideoBD; }
345  bool IsLocal(void) const { return m_pathname.startsWith("/")
346 #ifdef _WIN32
347  || m_pathname.at(1) == ':'
348 #endif
349  ; }
350  bool IsMythStream(void) const { return m_pathname.startsWith("myth://"); }
351  bool IsPathSet(void) const { return GetBasename() != m_pathname; }
352  bool HasPathname(void) const { return !GetPathname().isEmpty(); }
353  bool IsFileReadable(void);
354 
355  QString GetTitle(void) const { return m_title; }
356  QString GetSortTitle(void) const { return m_sortTitle; }
357  QString GetSubtitle(void) const { return m_subtitle; }
358  QString GetSortSubtitle(void) const { return m_sortSubtitle; }
359  QString GetDescription(void) const { return m_description; }
360  uint GetSeason(void) const { return m_season; }
361  uint GetEpisode(void) const { return m_episode; }
362  uint GetEpisodeTotal(void) const { return m_totalEpisodes; }
363  QString GetCategory(void) const { return m_category; }
366  uint GetChanID(void) const { return m_chanId; }
370  QString GetChanNum(void) const { return m_chanStr; }
377  QString GetChannelSchedulingID(void) const { return m_chanSign; }
380  QString GetChannelName(void) const { return m_chanName; }
381  QString GetChannelPlaybackFilters(void) const
382  { return m_chanPlaybackFilters; }
384  QDateTime GetScheduledStartTime(void) const { return m_startTs; }
387  {
388  return MythDate::toString(m_startTs, fmt);
389  }
391  QDateTime GetScheduledEndTime(void) const { return m_endTs; }
394  {
395  return MythDate::toString(m_endTs, fmt);
396  }
398  QDateTime GetRecordingStartTime(void) const { return m_recStartTs; }
401  {
402  return MythDate::toString(m_recStartTs, fmt);
403  }
406  QDateTime GetRecordingEndTime(void) const { return m_recEndTs; }
410  {
411  return MythDate::toString(m_recEndTs, fmt);
412  }
413  QString GetRecordingGroup(void) const { return m_recGroup; }
414  QString GetPlaybackGroup(void) const { return m_playGroup; }
415  QString GetHostname(void) const { return m_hostname; }
416  QString GetStorageGroup(void) const { return m_storageGroup; }
418  {
419  return ((m_year) ? m_year :
420  (m_originalAirDate.isValid()) ? m_originalAirDate.year() : 0);
421  }
422  QDate GetOriginalAirDate(void) const { return m_originalAirDate; }
423  QDateTime GetLastModifiedTime(void) const { return m_lastModified; }
425  {
426  return MythDate::toString(m_lastModified, fmt);
427  }
428  virtual uint64_t GetFilesize(void) const; // TODO Remove
429  QString GetSeriesID(void) const { return m_seriesId; }
430  QString GetProgramID(void) const { return m_programId; }
431  QString GetInetRef(void) const { return m_inetRef; }
432  CategoryType GetCategoryType(void) const { return m_catType; }
433  QString GetCategoryTypeString(void) const;
434  int GetRecordingPriority(void) const { return m_recPriority; }
435  int GetRecordingPriority2(void) const { return m_recPriority2; }
436  float GetStars(void) const { return m_stars; }
437  uint GetStars(uint range_max) const
438  { return lroundf(m_stars * range_max); }
439 
440  uint GetRecordingID(void) const { return m_recordedId; }
442  { return (RecStatus::Type)m_recStatus; }
443  uint GetRecordingRuleID(void) const { return m_recordId; }
444  uint GetParentRecordingRuleID(void) const { return m_parentId; }
446  { return (RecordingType)m_recType; }
447 
450  { return (RecordingDupInType)m_dupIn; }
451 
454  { return (RecordingDupMethodType)m_dupMethod; }
455 
456  uint GetSourceID(void) const { return m_sourceId; }
457  uint GetInputID(void) const { return m_inputId; }
458  QString GetInputName(void) const { return m_inputName; }
459  QString GetShortInputName(void) const
460  { return m_inputName.isRightToLeft() ?
461  m_inputName.left(2) : m_inputName.right(2); }
462  void ClearInputName(void) { m_inputName.clear(); }
463 
464  uint GetFindID(void) const { return m_findId; }
465 
466  uint32_t GetProgramFlags(void) const { return m_programFlags; }
468  { return (ProgramInfoType)((m_programFlags & FL_TYPEMASK) >> 20); }
469  QDateTime GetBookmarkUpdate(void) const { return m_bookmarkUpdate; }
470  bool IsGeneric(void) const;
471  bool IsInUsePlaying(void) const { return m_programFlags & FL_INUSEPLAYING;}
472  bool IsCommercialFree(void) const { return m_programFlags & FL_CHANCOMMFREE;}
473  bool HasCutlist(void) const { return m_programFlags & FL_CUTLIST; }
474  bool IsBookmarkSet(void) const { return m_programFlags & FL_BOOKMARK; }
475  bool IsWatched(void) const { return m_programFlags & FL_WATCHED; }
476  bool IsAutoExpirable(void) const { return m_programFlags & FL_AUTOEXP; }
477  bool IsPreserved(void) const { return m_programFlags & FL_PRESERVED; }
478  bool IsVideo(void) const { return m_programFlags & FL_TYPEMASK; }
479  bool IsRecording(void) const { return !IsVideo(); }
480  bool IsRepeat(void) const { return m_programFlags & FL_REPEAT; }
481  bool IsDuplicate(void) const { return m_programFlags & FL_DUPLICATE; }
482  bool IsReactivated(void) const { return m_programFlags & FL_REACTIVATE; }
483  bool IsDeletePending(void) const
484  { return m_programFlags & FL_DELETEPENDING; }
485 
486  uint GetSubtitleType(void) const
487  { return (m_properties&kSubtitlePropertyMask)>>kSubtitlePropertyOffset; }
489  { return (m_properties & kVideoPropertyMask) >> kVideoPropertyOffset; }
491  { return (m_properties & kAudioPropertyMask) >> kAudioPropertyOffset; }
492 
494  {
499  };
500  QString toString(Verbosity v = kLongDescription, const QString& sep = ":",
501  const QString& grp = "\"") const;
502 
503  // Quick sets
504  void SetTitle(const QString &t, const QString &st = nullptr);
505  void SetSubtitle(const QString &st, const QString &sst = nullptr);
507  { m_programFlags &= ~FL_TYPEMASK; m_programFlags |= ((uint32_t)t<<20); }
508  void SetPathname(const QString& pn);
509  void SetChanID(uint _chanid) { m_chanId = _chanid; }
510  void SetScheduledStartTime(const QDateTime &dt) { m_startTs = dt; }
511  void SetScheduledEndTime( const QDateTime &dt) { m_endTs = dt; }
512  void SetRecordingStartTime(const QDateTime &dt) { m_recStartTs = dt; }
513  void SetRecordingEndTime( const QDateTime &dt) { m_recEndTs = dt; }
514  void SetRecordingGroup(const QString &group) { m_recGroup = group; }
515  void SetPlaybackGroup( const QString &group) { m_playGroup = group; }
516  void SetHostname( const QString &host) { m_hostname = host; }
517  void SetStorageGroup( const QString &group) { m_storageGroup = group; }
518  virtual void SetFilesize( uint64_t sz);
519  void SetSeriesID( const QString &id) { m_seriesId = id; }
520  void SetProgramID( const QString &id) { m_programId = id; }
521  void SetCategory( const QString &cat) { m_category = cat; }
522  void SetCategoryType( const CategoryType type) { m_catType = type; }
523  void SetRecordingPriority(int priority) { m_recPriority = priority; }
524  void SetRecordingPriority2(int priority) { m_recPriority2 = priority; }
525  void SetRecordingRuleID(uint id) { m_recordId = id; }
526  void SetSourceID(uint id) { m_sourceId = id; }
527  void SetInputID(uint id) { m_inputId = id; }
528  void SetReactivated(bool reactivate)
529  {
530  m_programFlags &= ~FL_REACTIVATE;
531  m_programFlags |= (reactivate) ? FL_REACTIVATE : 0;
532  }
533  void SetEditing(bool editing)
534  {
535  m_programFlags &= ~FL_EDITING;
536  m_programFlags |= (editing) ? FL_EDITING : 0;
537  }
538  void SetFlagging(bool flagging)
539  {
540  m_programFlags &= ~FL_COMMFLAG;
541  m_programFlags |= (flagging) ? FL_COMMFLAG : 0;
542  }
545  void SetIgnoreBookmark(bool ignore)
546  {
547  m_programFlags &= ~FL_IGNOREBOOKMARK;
548  m_programFlags |= (ignore) ? FL_IGNOREBOOKMARK : 0;
549  }
552  void SetIgnoreProgStart(bool ignore)
553  {
554  m_programFlags &= ~FL_IGNOREPROGSTART;
555  m_programFlags |= (ignore) ? FL_IGNOREPROGSTART : 0;
556  }
560  void SetAllowLastPlayPos(bool allow)
561  {
562  m_programFlags &= ~FL_ALLOWLASTPLAYPOS;
563  m_programFlags |= (allow) ? FL_ALLOWLASTPLAYPOS : 0;
564  }
565  virtual void SetRecordingID(uint _recordedid)
566  { m_recordedId = _recordedid; }
567  void SetRecordingStatus(RecStatus::Type status) { m_recStatus = status; }
570  { m_positionMapDBReplacement = pmap; }
571 
572  // Slow DB gets
573  QString QueryBasename(void) const;
574 // uint64_t QueryFilesize(void) const; // TODO Remove
575  uint QueryMplexID(void) const;
576  QDateTime QueryBookmarkTimeStamp(void) const;
577  uint64_t QueryBookmark(void) const;
578  uint64_t QueryProgStart(void) const;
579  uint64_t QueryLastPlayPos(void) const;
580  CategoryType QueryCategoryType(void) const;
581  QStringList QueryDVDBookmark(const QString &serialid) const;
582  QStringList QueryBDBookmark(const QString &serialid) const;
583  bool QueryIsEditing(void) const;
584  bool QueryIsInUse(QStringList &byWho) const;
585  bool QueryIsInUse(QString &byWho) const;
586  bool QueryIsDeleteCandidate(bool one_playback_allowed = false) const;
587  AutoExpireType QueryAutoExpire(void) const;
588  TranscodingStatus QueryTranscodeStatus(void) const;
589  bool QueryTuningInfo(QString &channum, QString &input) const;
590  QString QueryInputDisplayName(void) const;
591  uint QueryAverageWidth(void) const;
592  uint QueryAverageHeight(void) const;
593  uint QueryAverageFrameRate(void) const;
594  MarkTypes QueryAverageAspectRatio(void) const;
595  uint32_t QueryTotalDuration(void) const;
596  int64_t QueryTotalFrames(void) const;
597  QString QueryRecordingGroup(void) const;
598  bool QueryMarkupFlag(MarkTypes type) const;
599  uint QueryTranscoderID(void) const;
600  uint64_t QueryLastFrameInPosMap(void) const;
601  bool Reload(void);
602 
603  // Slow DB sets
604  virtual void SaveFilesize(uint64_t fsize);
605  void SaveBookmark(uint64_t frame);
606  static void SaveDVDBookmark(const QStringList &fields) ;
607  static void SaveBDBookmark(const QStringList &fields) ;
608  void SaveEditing(bool edit);
609  void SaveTranscodeStatus(TranscodingStatus trans);
610  void SaveWatched(bool watchedFlag);
611  void SaveDeletePendingFlag(bool deleteFlag);
612  void SaveCommFlagged(CommFlagStatus flag); // 1 = flagged, 2 = processing
613  void SaveAutoExpire(AutoExpireType autoExpire, bool updateDelete = false);
614  void SavePreserve(bool preserveEpisode);
615  bool SaveBasename(const QString &basename);
616  void SaveAspect(uint64_t frame, MarkTypes type, uint customAspect);
617  void SaveResolution(uint64_t frame, uint width, uint height);
618  void SaveFrameRate(uint64_t frame, uint framerate);
619  void SaveTotalDuration(int64_t duration);
620  void SaveTotalFrames(int64_t frames);
621  void SaveVideoProperties(uint mask, uint video_property_flags);
622  void SaveMarkupFlag(MarkTypes type) const;
623  void ClearMarkupFlag(MarkTypes type) const { ClearMarkupMap(type); }
624  void UpdateLastDelete(bool setTime) const;
625  void MarkAsInUse(bool inuse, const QString& usedFor = "");
626  void UpdateInUseMark(bool force = false);
627  void SaveSeasonEpisode(uint seas, uint ep);
628  void SaveInetRef(const QString &inet);
629 
630  // Extremely slow functions that cannot be called from the UI thread.
631  QString DiscoverRecordingDirectory(void);
632  QString GetPlaybackURL(bool checkMaster = false,
633  bool forceCheckLocal = false);
634  ProgramInfoType DiscoverProgramInfoType(void) const;
635 
636  // Edit flagging map
637  bool QueryCutList(frm_dir_map_t &delMap, bool loadAutosave=false) const;
638  void SaveCutList(frm_dir_map_t &delMap, bool isAutoSave=false) const;
639 
640  // Commercial flagging map
641  void QueryCommBreakList(frm_dir_map_t &frames) const;
642  void SaveCommBreakList(frm_dir_map_t &frames) const;
643 
644  // Keyframe positions map
645  void QueryPositionMap(frm_pos_map_t &posMap, MarkTypes type) const;
646  void ClearPositionMap(MarkTypes type) const;
647  void SavePositionMap(frm_pos_map_t &posMap, MarkTypes type,
648  int64_t min_frame = -1, int64_t max_frame = -1) const;
649  void SavePositionMapDelta(frm_pos_map_t &posMap, MarkTypes type) const;
650 
651  // Get position/duration for keyframe and vice versa
652  bool QueryKeyFrameInfo(uint64_t *result, uint64_t position_or_keyframe,
653  bool backwards,
654  MarkTypes type, const char *from_filemarkup_asc,
655  const char *from_filemarkup_desc,
656  const char *from_recordedseek_asc,
657  const char *from_recordedseek_desc) const;
658  bool QueryKeyFramePosition(uint64_t *position, uint64_t keyframe,
659  bool backwards) const;
660  bool QueryPositionKeyFrame(uint64_t *keyframe, uint64_t position,
661  bool backwards) const;
662  bool QueryKeyFrameDuration(uint64_t *duration, uint64_t keyframe,
663  bool backwards) const;
664  bool QueryDurationKeyFrame(uint64_t *keyframe, uint64_t duration,
665  bool backwards) const;
666 
667  // Get/set all markup
668  struct MarkupEntry
669  {
670  int type { -1 }; // MarkTypes
671  uint64_t frame { 0 };
672  uint64_t data { 0 };
673  bool isDataNull { true };
674  MarkupEntry(int t, uint64_t f, uint64_t d, bool n)
675  : type(t), frame(f), data(d), isDataNull(n) {}
676  MarkupEntry(void) = default;
677  };
678  void QueryMarkup(QVector<MarkupEntry> &mapMark,
679  QVector<MarkupEntry> &mapSeek) const;
680  void SaveMarkup(const QVector<MarkupEntry> &mapMark,
681  const QVector<MarkupEntry> &mapSeek) const;
682 
684  void SendUpdateEvent(void);
686  void SendAddedEvent(void) const;
688  void SendDeletedEvent(void) const;
689 
691  static QString i18n(const QString &msg);
692 
693  static QString MakeUniqueKey(uint chanid, const QDateTime &recstartts);
694  static bool ExtractKey(const QString &uniquekey,
695  uint &chanid, QDateTime &recstartts);
696  static bool ExtractKeyFromPathname(
697  const QString &pathname, uint &chanid, QDateTime &recstartts);
698  static bool QueryKeyFromPathname(
699  const QString &pathname, uint &chanid, QDateTime &recstartts);
700  static bool QueryRecordedIdFromPathname(const QString &pathname,
701  uint &recordedid);
702 
703  static QString QueryRecordingGroupPassword(const QString &group);
704  static uint64_t QueryBookmark(uint chanid, const QDateTime &recstartts);
705  static QMap<QString,uint32_t> QueryInUseMap(void);
706  static QMap<QString,bool> QueryJobsRunning(int type);
707  static QStringList LoadFromScheduler(const QString &tmptable, int recordid);
708 
709  // Flagging map support methods
710  void QueryMarkupMap(frm_dir_map_t&marks, MarkTypes type,
711  bool merge = false) const;
712  void SaveMarkupMap(const frm_dir_map_t &marks, MarkTypes type = MARK_ALL,
713  int64_t min_frame = -1, int64_t max_frame = -1) const;
714  void ClearMarkupMap(MarkTypes type = MARK_ALL,
715  int64_t min_frame = -1, int64_t max_frame = -1) const;
716 
717  protected:
718  // Creates a basename from the start and end times
719  QString CreateRecordBasename(const QString &ext) const;
720 
721  bool LoadProgramFromRecorded(
722  uint chanid, const QDateTime &recstartts);
723 
724  bool FromStringList(QStringList::const_iterator &it,
725  const QStringList::const_iterator& end);
726 
727  static void QueryMarkupMap(
728  const QString &video_pathname,
729  frm_dir_map_t &marks, MarkTypes type, bool merge = false);
730  static void QueryMarkupMap(
731  uint chanid, const QDateTime &recstartts,
732  frm_dir_map_t &marks, MarkTypes type, bool merge = false);
733 
734  static int InitStatics(void);
735 
736  protected:
737  QString m_title;
738  QString m_sortTitle;
739  QString m_subtitle;
740  QString m_sortSubtitle;
741  QString m_description;
742  uint m_season {0};
743  uint m_episode {0};
744  uint m_totalEpisodes {0};
746  QString m_category;
747  QString m_director;
748 
749  int32_t m_recPriority {0};
750 
751  uint32_t m_chanId {0};
752  QString m_chanStr; // Channum
753  QString m_chanSign; // Callsign
754  QString m_chanName;
756 
757  QString m_recGroup {"Default"};
758  QString m_playGroup {"Default"};
759 
760  mutable QString m_pathname;
761 
762  QString m_hostname;
763  QString m_storageGroup {"Default"};
764 
765  QString m_seriesId;
766  QString m_programId;
767  QString m_inetRef;
768  CategoryType m_catType {kCategoryNone};
769 
770  uint64_t m_fileSize {0ULL};
771 
772  QDateTime m_startTs {MythDate::current(true)};
773  QDateTime m_endTs {m_startTs};
774  QDateTime m_recStartTs {m_startTs};
775  QDateTime m_recEndTs {m_startTs};
776 
777  float m_stars {0.0F};
779  QDateTime m_lastModified {m_startTs};
780  QDateTime m_lastInUseTime {m_startTs.addSecs(-4 * 60 * 60)};
781 
782  int32_t m_recPriority2 {0};
783 
784  uint32_t m_recordId {0};
785  uint32_t m_parentId {0};
786 
787  uint32_t m_sourceId {0};
788  uint32_t m_inputId {0};
789  uint32_t m_findId {0};
790 
791  uint32_t m_programFlags {FL_NONE};
792  uint16_t m_properties {0};
794  uint16_t m_year {0};
795  uint16_t m_partNumber {0};
796  uint16_t m_partTotal {0};
797 
798  int8_t m_recStatus {RecStatus::Unknown};
799  uint8_t m_recType {kNotRecording};
800  uint8_t m_dupIn {kDupsInAll};
801  uint8_t m_dupMethod {kDupCheckSubThenDesc};
802 
803  uint m_recordedId {0};
804  QString m_inputName;
805  QDateTime m_bookmarkUpdate;
806 
807 // everything below this line is not serialized
808  uint8_t m_availableStatus {asAvailable}; // only used for playbackbox.cpp
809  public:
810  void SetAvailableStatus(AvailableStatusType status, const QString &where);
812  { return (AvailableStatusType) m_availableStatus; }
813  int8_t m_spread {-1}; // only used in guidegrid.cpp
814  int8_t m_startCol {-1}; // only used in guidegrid.cpp
815 
816  static const QString kFromRecordedQuery;
817 
818  protected:
819  QString m_inUseForWhat;
820  PMapDBReplacement *m_positionMapDBReplacement {nullptr};
821 
822  static QMutex s_staticDataLock;
824  static bool s_usingProgIDAuth;
825 };
826 
828  ProgramList &destination,
829  const QString &where,
830  const QString &groupBy,
831  const QString &orderBy,
832  const MSqlBindings &bindings,
833  const ProgramList &schedList);
834 
836  ProgramList &destination,
837  const QString &sql,
838  const MSqlBindings &bindings,
839  const ProgramList &schedList);
840 
842  ProgramList &destination,
843  const QString &sql,
844  const MSqlBindings &bindings,
845  const ProgramList &schedList,
846  const uint &start,
847  const uint &limit,
848  uint &count);
849 
851  uint chanid, const QDateTime &starttime);
852 
854  ProgramList &destination,
855  const QString &sql,
856  const MSqlBindings &bindings);
857 
859  ProgramList &destination,
860  const QString &sql,
861  const MSqlBindings &bindings,
862  const uint &start,
863  const uint &limit,
864  uint &count);
865 
867  ProgramList &destination,
868  bool possiblyInProgressRecordingsOnly,
869  const QMap<QString,uint32_t> &inUseMap,
870  const QMap<QString,bool> &isJobRunning,
871  const QMap<QString, ProgramInfo*> &recMap,
872  int sort = 0,
873  const QString &sortBy = "");
874 
875 
876 template<typename TYPE>
878  AutoDeleteDeque<TYPE*> &destination,
879  bool &hasConflicts,
880  const QString& altTable = "",
881  int recordid = -1)
882 {
883  destination.clear();
884  hasConflicts = false;
885 
886  QStringList slist = ProgramInfo::LoadFromScheduler(altTable, recordid);
887  if (slist.empty())
888  return false;
889 
890  hasConflicts = slist[0].toInt();
891 
892  QStringList::const_iterator sit = slist.begin()+2;
893  while (sit != slist.end())
894  {
895  TYPE *p = new TYPE(sit, slist.end());
896  destination.push_back(p);
897 
898  if (!p->HasPathname() && !p->GetChanID())
899  {
900  delete p;
901  destination.clear();
902  return false;
903  }
904  }
905 
906  if (destination.size() != slist[1].toUInt())
907  {
908  destination.clear();
909  return false;
910  }
911 
912  return true;
913 }
914 
915 template<typename T>
917 {
918  bool dummyConflicts = false;
919  return LoadFromScheduler(destination, dummyConflicts, "", -1);
920 }
921 
922 // Moved from programdetails.cpp/h, used by MythWelcome/MythShutdown
923 // could be factored out
924 MPUBLIC bool GetNextRecordingList(QDateTime &nextRecordingStart,
925  bool *hasConflicts = nullptr,
926  std::vector<ProgramInfo> *list = nullptr);
927 
928 class QMutex;
930 {
931  public:
934  QMutex *lock;
935  QMap<MarkTypes,frm_pos_map_t> map;
936 };
937 
938 MPUBLIC QString format_season_and_episode(int seasEp, int digits = -1);
939 
942 
944 
945 #endif // MYTHPROGRAM_H_
946 
947 /* vim: set expandtab tabstop=4 shiftwidth=4: */
MPUBLIC bool LoadFromProgram(ProgramList &destination, const QString &where, const QString &groupBy, const QString &orderBy, const MSqlBindings &bindings, const ProgramList &schedList)
RecordingDupInType
void SetStorageGroup(const QString &group)
Definition: programinfo.h:517
QString m_seriesId
Definition: programinfo.h:765
float GetStars(void) const
Definition: programinfo.h:436
#define kAudioPropertyMask
Definition: programtypes.h:179
uint32_t m_chanId
Definition: programinfo.h:751
ProgramInfoType GetProgramInfoType(void) const
Definition: programinfo.h:467
QString m_sortTitle
Definition: programinfo.h:738
bool IsPreserved(void) const
Definition: programinfo.h:477
uint GetInputID(void) const
Definition: programinfo.h:457
void push_back(T info)
void SetAllowLastPlayPos(bool allow)
If "ignore" is true QueryLastPlayPos() will return 0, otherwise QueryLastPlayPos() will return the la...
Definition: programinfo.h:560
RecordingDupMethodType GetDuplicateCheckMethod(void) const
What should be compared to determine if two programs are the same?
Definition: programinfo.h:453
QDateTime GetBookmarkUpdate(void) const
Definition: programinfo.h:469
QString GetChannelName(void) const
This is the channel name in the local market, i.e.
Definition: programinfo.h:380
AutoExpireType
Definition: programtypes.h:230
void SetEditing(bool editing)
Definition: programinfo.h:533
QMap< MarkTypes, frm_pos_map_t > map
Definition: programinfo.h:935
#define MPUBLIC
Definition: mythexp.h:10
bool IsVideo(void) const
Definition: programinfo.h:478
QString m_description
Definition: programinfo.h:741
bool IsReactivated(void) const
Definition: programinfo.h:482
void SetScheduledStartTime(const QDateTime &dt)
Definition: programinfo.h:510
QString toString(MarkTypes type)
void SetProgramInfoType(ProgramInfoType t)
Definition: programinfo.h:506
void SetCategoryType(const CategoryType type)
Definition: programinfo.h:522
void SetIgnoreBookmark(bool ignore)
If "ignore" is true GetBookmark() will return 0, otherwise GetBookmark() will return the bookmark pos...
Definition: programinfo.h:545
QDate m_originalAirDate
Definition: programinfo.h:778
QString m_chanName
Definition: programinfo.h:754
MPUBLIC QString format_season_and_episode(int seasEp, int digits=-1)
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
uint GetSourceID(void) const
Definition: programinfo.h:456
void SetRecordingPriority2(int priority)
Definition: programinfo.h:524
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:125
ProgramInfoType
Definition: programtypes.h:157
bool IsVideoDVD(void) const
Definition: programinfo.h:341
uint GetParentRecordingRuleID(void) const
Definition: programinfo.h:444
QString GetRecordingEndTime(MythDate::Format fmt) const
Approximate time the recording should have ended, did end, or is intended to end (with formatting).
Definition: programinfo.h:409
QString GetTitle(void) const
Definition: programinfo.h:355
TranscodingStatus
Definition: programtypes.h:120
CommFlagStatus
Definition: programtypes.h:83
void SetRecordingRuleID(uint id)
Definition: programinfo.h:525
void SetSourceID(uint id)
Definition: programinfo.h:526
bool operator==(MusicMetadata &a, MusicMetadata &b)
QString m_chanPlaybackFilters
Definition: programinfo.h:755
bool IsCommercialFree(void) const
Definition: programinfo.h:472
size_t size(void) const
ProgramInfo(const QStringList &list)
Definition: programinfo.h:287
void SetReactivated(bool reactivate)
Definition: programinfo.h:528
int GetRecordingPriority(void) const
Definition: programinfo.h:434
#define kAudioPropertyOffset
Definition: programtypes.h:178
void SetFlagging(bool flagging)
Definition: programinfo.h:538
uint GetStars(uint range_max) const
Definition: programinfo.h:437
QString GetChanNum(void) const
This is the channel "number", in the form 1, 1_2, 1-2, 1#1, etc.
Definition: programinfo.h:370
Q_DECLARE_METATYPE(GrabberScript *)
uint GetAudioProperties(void) const
Definition: programinfo.h:490
QString GetChannelPlaybackFilters(void) const
Definition: programinfo.h:381
bool IsBookmarkSet(void) const
Definition: programinfo.h:474
static bool s_usingProgIDAuth
Definition: programinfo.h:824
QDateTime m_recStartTs
Definition: programinfo.h:774
uint GetVideoProperties(void) const
Definition: programinfo.h:488
static QStringList LoadFromScheduler(const QString &tmptable, int recordid)
QString GetInetRef(void) const
Definition: programinfo.h:431
static QMutex s_staticDataLock
Definition: programinfo.h:822
QDate GetOriginalAirDate(void) const
Definition: programinfo.h:422
MPUBLIC bool LoadFromRecorded(ProgramList &destination, bool possiblyInProgressRecordingsOnly, const QMap< QString, uint32_t > &inUseMap, const QMap< QString, bool > &isJobRunning, const QMap< QString, ProgramInfo * > &recMap, int sort=0, const QString &sortBy="")
ProgramInfo(QStringList::const_iterator &it, const QStringList::const_iterator &end)
Definition: programinfo.h:281
QString GetStorageGroup(void) const
Definition: programinfo.h:416
QMap< long long, long long > frm_pos_map_t
Frame # -> File offset map.
Definition: programtypes.h:46
RecordingDupMethodType
QDateTime GetScheduledStartTime(void) const
The scheduled start time of program.
Definition: programinfo.h:384
QString MakeUniqueKey(void) const
Creates a unique string that can be used to identify an existing recording.
Definition: programinfo.h:333
ProgramInfo(QString _title, QString _category, QDateTime _startts, QDateTime _endts)
Constructs a Dummy ProgramInfo (used by GuideGrid)
Definition: programinfo.h:276
MarkTypes
Definition: programtypes.h:48
Holds information on recordings and videos.
Definition: programinfo.h:67
MPUBLIC bool GetNextRecordingList(QDateTime &nextRecordingStart, bool *hasConflicts=nullptr, std::vector< ProgramInfo > *list=nullptr)
void SetScheduledEndTime(const QDateTime &dt)
Definition: programinfo.h:511
void ClearMarkupFlag(MarkTypes type) const
Definition: programinfo.h:623
QMap< QString, QVariant > MSqlBindings
typedef for a map of string -> string bindings for generic queries.
Definition: mythdbcon.h:98
QString m_sortSubtitle
Definition: programinfo.h:740
bool IsWatched(void) const
Definition: programinfo.h:475
void clear(void)
QString GetChannelSchedulingID(void) const
This is the unique programming identifier of a channel.
Definition: programinfo.h:377
uint32_t GetProgramFlags(void) const
Definition: programinfo.h:466
static void clear(SettingsMap &cache, SettingsMap &overrides, const QString &myKey)
Definition: mythdb.cpp:846
bool IsRecording(void) const
Definition: programinfo.h:479
QString GetDescription(void) const
Definition: programinfo.h:359
QString GetBasename(void) const
Definition: programinfo.h:338
static const uint16_t * d
QString GetScheduledEndTime(MythDate::Format fmt) const
The scheduled end time of the program (with formatting).
Definition: programinfo.h:393
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:10
bool IsVideoBD(void) const
Definition: programinfo.h:343
#define kSubtitlePropertyMask
Definition: programtypes.h:210
QString GetSortSubtitle(void) const
Definition: programinfo.h:358
bool HasCutlist(void) const
Definition: programinfo.h:473
QString GetShortInputName(void) const
Definition: programinfo.h:459
QString GetSubtitle(void) const
Definition: programinfo.h:357
ProgramInfo(void)
Null constructor.
Definition: programinfo.h:75
bool IsLocal(void) const
Definition: programinfo.h:345
bool IsRepeat(void) const
Definition: programinfo.h:480
AvailableStatusType GetAvailableStatus(void) const
Definition: programinfo.h:811
QString GetRecordingStartTime(MythDate::Format fmt) const
Approximate time the recording started (with formatting).
Definition: programinfo.h:400
QString GetRecordingGroup(void) const
Definition: programinfo.h:413
QString m_hostname
Definition: programinfo.h:762
bool IsAutoExpirable(void) const
Definition: programinfo.h:476
uint GetRecordingID(void) const
Definition: programinfo.h:440
string hostname
Definition: caa.py:17
uint GetSeason(void) const
Definition: programinfo.h:360
static bool UsingProgramIDAuthority(void)
Definition: programinfo.h:318
unsigned int uint
Definition: compat.h:140
void SetRecordingStatus(RecStatus::Type status)
Definition: programinfo.h:567
void SetSeriesID(const QString &id)
TODO Move to RecordingInfo.
Definition: programinfo.h:519
bool IsDeletePending(void) const
Definition: programinfo.h:483
void ClearInputName(void)
Definition: programinfo.h:462
QString GetLastModifiedTime(MythDate::Format fmt) const
Definition: programinfo.h:424
QDateTime GetScheduledEndTime(void) const
The scheduled end time of the program.
Definition: programinfo.h:391
MPUBLIC QString myth_category_type_to_string(ProgramInfo::CategoryType category_type)
QString m_chanStr
Definition: programinfo.h:752
MPUBLIC bool LoadFromOldRecorded(ProgramList &destination, const QString &sql, const MSqlBindings &bindings)
AvailableStatusType
Definition: programtypes.h:213
virtual void SetRecordingID(uint _recordedid)
Definition: programinfo.h:565
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
Definition: mythdate.cpp:101
static struct mark marks[16]
QString GetPlaybackGroup(void) const
Definition: programinfo.h:414
QString m_inetRef
Definition: programinfo.h:767
bool IsVideoFile(void) const
Definition: programinfo.h:339
#define kVideoPropertyOffset
Definition: programtypes.h:195
QString GetSeriesID(void) const
Definition: programinfo.h:429
static ProgramInfoUpdater * s_updater
Definition: programinfo.h:823
QString m_inUseForWhat
Definition: programinfo.h:819
void SetCategory(const QString &cat)
Definition: programinfo.h:521
uint GetYearOfInitialRelease(void) const
Definition: programinfo.h:417
void SetChanID(uint _chanid)
Definition: programinfo.h:509
void SetInputID(uint id)
Definition: programinfo.h:527
#define kVideoPropertyMask
Definition: programtypes.h:196
uint GetSubtitleType(void) const
Definition: programinfo.h:486
QString m_chanSign
Definition: programinfo.h:753
RecStatus::Type GetRecordingStatus(void) const
Definition: programinfo.h:441
bool IsSameRecording(const ProgramInfo &other) const
Definition: programinfo.h:326
unsigned short uint16_t
Definition: iso6937tables.h:1
uint GetEpisodeTotal(void) const
Definition: programinfo.h:362
int GetRecordingPriority2(void) const
Definition: programinfo.h:435
QString GetSortTitle(void) const
Definition: programinfo.h:356
static const QString kFromRecordedQuery
Definition: programinfo.h:816
void SetPositionMapDBReplacement(PMapDBReplacement *pmap)
Definition: programinfo.h:569
virtual void clear(void)
RecordingType GetRecordingRuleType(void) const
Definition: programinfo.h:445
void SetHostname(const QString &host)
Definition: programinfo.h:516
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
Definition: programinfo.h:366
QString GetPlaybackURL(ProgramInfo *pginfo, bool storePath)
QString m_inputName
Definition: programinfo.h:804
void SetRecordingRuleType(RecordingType type)
Definition: programinfo.h:568
uint GetRecordingRuleID(void) const
Definition: programinfo.h:443
QString GetProgramID(void) const
Definition: programinfo.h:430
uint GetFindID(void) const
Definition: programinfo.h:464
void SetProgramID(const QString &id)
Definition: programinfo.h:520
void SetRecordingStartTime(const QDateTime &dt)
Definition: programinfo.h:512
QDateTime GetRecordingStartTime(void) const
Approximate time the recording started.
Definition: programinfo.h:398
QDateTime m_bookmarkUpdate
Definition: programinfo.h:805
void SetRecordingEndTime(const QDateTime &dt)
Definition: programinfo.h:513
QDateTime GetRecordingEndTime(void) const
Approximate time the recording should have ended, did end, or is intended to end.
Definition: programinfo.h:406
const char * frames[3]
Definition: element.c:46
QString m_subtitle
Definition: programinfo.h:739
QString m_title
Definition: programinfo.h:737
QDateTime GetLastModifiedTime(void) const
Definition: programinfo.h:423
QString GetHostname(void) const
Definition: programinfo.h:415
QString GetInputName(void) const
Definition: programinfo.h:458
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.
Definition: programtypes.h:81
MarkupEntry(int t, uint64_t f, uint64_t d, bool n)
Definition: programinfo.h:674
QString m_pathname
Definition: programinfo.h:760
bool IsMythStream(void) const
Definition: programinfo.h:350
void SetIgnoreProgStart(bool ignore)
If "ignore" is true QueryProgStart() will return 0, otherwise QueryProgStart() will return the progst...
Definition: programinfo.h:552
QString GetCategory(void) const
Definition: programinfo.h:363
RecordingDupInType GetDuplicateCheckSource(void) const
Where should we check for duplicates?
Definition: programinfo.h:449
bool LoadFromScheduler(AutoDeleteDeque< TYPE * > &destination, bool &hasConflicts, const QString &altTable="", int recordid=-1)
Definition: programinfo.h:877
#define kSubtitlePropertyOffset
Definition: programtypes.h:209
void SetRecordingGroup(const QString &group)
Definition: programinfo.h:514
void SetRecordingPriority(int priority)
Definition: programinfo.h:523
QString GetScheduledStartTime(MythDate::Format fmt) const
The scheduled start time of program (with formatting).
Definition: programinfo.h:386
QString GetPathname(void) const
Definition: programinfo.h:337
QString m_director
Definition: programinfo.h:747
CategoryType GetCategoryType(void) const
Definition: programinfo.h:432
bool IsInUsePlaying(void) const
Definition: programinfo.h:471
bool HasPathname(void) const
Definition: programinfo.h:352
MPUBLIC ProgramInfo::CategoryType string_to_myth_category_type(const QString &type)
QString m_category
Definition: programinfo.h:746
QString m_programId
Definition: programinfo.h:766
MPUBLIC ProgramInfo * LoadProgramFromProgram(uint chanid, const QDateTime &starttime)
uint GetEpisode(void) const
Definition: programinfo.h:361
bool IsDuplicate(void) const
Definition: programinfo.h:481
QString m_syndicatedEpisode
Definition: programinfo.h:745
bool IsPathSet(void) const
Definition: programinfo.h:351
void SetPlaybackGroup(const QString &group)
Definition: programinfo.h:515
int pginfo_init_statics()
Definition: programinfo.cpp:44