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 <vector> // for GetNextRecordingList
9 
10 #include <QStringList>
11 #include <QDateTime>
12 
13 // MythTV headers
14 #include "autodeletedeque.h"
15 #include "recordingtypes.h"
16 #include "programtypes.h"
17 #include "mythdbcon.h"
18 #include "mythexp.h"
19 #include "mythdate.h"
20 #include "mythtypes.h"
21 #include "enums/recStatus.h"
22 
23 /* If NUMPROGRAMLINES gets updated, then MYTH_PROTO_VERSION and MYTH_PROTO_TOKEN
24  in mythversion.h need to be bumped, and also follow the instructions in
25  myth_version.h about other changes needed when the network protocol changes.
26 */
27 #define NUMPROGRAMLINES 52
28 
31 
62 class MSqlQuery;
63 class ProgramInfoUpdater;
64 class PMapDBReplacement;
65 
67 {
68  friend int pginfo_init_statics(void);
69  public:
70  enum CategoryType { kCategoryNone, kCategoryMovie, kCategorySeries,
71  kCategorySports, kCategoryTVShow };
72 
74  ProgramInfo(void);
76  ProgramInfo(const ProgramInfo &other);
78  explicit ProgramInfo(uint recordedid);
80  ProgramInfo(uint chanid, const QDateTime &recstartts);
82  ProgramInfo(uint recordedid,
83  const QString &title,
84  const QString &sortTitle,
85  const QString &subtitle,
86  const QString &sortSubtitle,
87  const QString &description,
88  uint season,
89  uint episode,
90  uint totalepisodes,
91  const QString &syndicatedepisode,
92  const QString &category,
93 
94  uint chanid,
95  const QString &channum,
96  const QString &chansign,
97  const QString &channame,
98  const QString &chanplaybackfilters,
99 
100  const QString &recgroup,
101  const QString &playgroup,
102 
103  const QString &pathname,
104 
105  const QString &hostname,
106  const QString &storagegroup,
107 
108  const QString &seriesid,
109  const QString &programid,
110  const QString &inetref,
111  CategoryType catType,
112 
113  int recpriority,
114 
115  uint64_t filesize,
116 
117  const QDateTime &startts,
118  const QDateTime &endts,
119  const QDateTime &recstartts,
120  const QDateTime &recendts,
121 
122  float stars,
123 
124  uint year,
125  uint partnumber,
126  uint parttotal,
127 
128  const QDate &originalAirDate,
129  const QDateTime &lastmodified,
130 
131  RecStatus::Type recstatus,
132 
133  uint recordid,
134 
135  RecordingDupInType dupin,
136  RecordingDupMethodType dupmethod,
137 
138  uint findid,
139 
140  uint programflags,
141  uint audioproperties,
142  uint videoproperties,
143  uint subtitleType,
144  const QString &inputname,
145  const QDateTime &bookmarkupdate);
146 
148  ProgramInfo(const QString &title,
149  const QString &sortTitle,
150  const QString &subtitle,
151  const QString &sortSubtitle,
152  const QString &description,
153  uint season,
154  uint episode,
155  const QString &category,
156 
157  uint chanid,
158  const QString &channum,
159  const QString &chansign,
160  const QString &channame,
161 
162  const QString &seriesid,
163  const QString &programid,
164  const QString &inetref,
165 
166  const QDateTime &startts,
167  const QDateTime &endts,
168  const QDateTime &recstartts,
169  const QDateTime &recendts,
170 
171  RecStatus::Type recstatus,
172 
173  uint recordid,
174 
175  RecordingType rectype,
176 
177  uint findid,
178 
179  bool duplicate);
180 
182  ProgramInfo(const QString &title,
183  const QString &sortTitle,
184  const QString &subtitle,
185  const QString &sortSubtitle,
186  const QString &description,
187  const QString &syndicatedepisode,
188  const QString &category,
189 
190  uint chanid,
191  const QString &channum,
192  const QString &chansign,
193  const QString &channame,
194  const QString &chanplaybackfilters,
195 
196  const QDateTime &startts,
197  const QDateTime &endts,
198  const QDateTime &recstartts,
199  const QDateTime &recendts,
200 
201  const QString &seriesid,
202  const QString &programid,
203  const CategoryType catType,
204 
205  float stars,
206  uint year,
207  uint partnumber,
208  uint parttotal,
209  const QDate &originalAirDate,
210  RecStatus::Type recstatus,
211  uint recordid,
212  RecordingType rectype,
213  uint findid,
214 
215  bool commfree,
216  bool repeat,
217 
218  uint videoprops,
219  uint audioprops,
220  uint subtitletype,
221 
222  uint season,
223  uint episode,
224  uint totalepisodes,
225 
226  const ProgramList &schedList);
228  ProgramInfo(const QString &title,
229  const QString &sortTitle,
230  const QString &subtitle,
231  const QString &sortSubtitle,
232  const QString &description,
233  uint season,
234  uint episode,
235  uint totalepisodes,
236  const QString &category,
237 
238  uint chanid,
239  const QString &channum,
240  const QString &chansign,
241  const QString &channame,
242  const QString &chanplaybackfilters,
243 
244  const QString &recgroup,
245  const QString &playgroup,
246 
247  const QDateTime &startts,
248  const QDateTime &endts,
249  const QDateTime &recstartts,
250  const QDateTime &recendts,
251 
252  const QString &seriesid,
253  const QString &programid,
254  const QString &inetref,
255  const QString &inputname);
257  explicit ProgramInfo(const QString &pathname);
259  ProgramInfo(const QString &pathname,
260  const QString &plot,
261  const QString &title,
262  const QString &sortTitle,
263  const QString &subtitle,
264  const QString &sortSubtitle,
265  const QString &director,
266  int season, int episode,
267  const QString &inetref,
268  uint length_in_minutes,
269  uint year,
270  const QString &programid);
272  ProgramInfo(const QString &_title, uint _chanid,
273  const QDateTime &_startts, const QDateTime &_endts);
275  ProgramInfo(const QString &_title, const QString &_category,
276  const QDateTime &_startts, const QDateTime &_endts);
277  ProgramInfo(QStringList::const_iterator &it,
278  QStringList::const_iterator end) :
279  chanid(0),
280  positionMapDBReplacement(nullptr)
281  {
282  if (!FromStringList(it, end))
283  clear();
284  }
285  explicit ProgramInfo(const QStringList &list) :
286  chanid(0),
287  positionMapDBReplacement(nullptr)
288  {
289  QStringList::const_iterator it = list.begin();
290  if (!FromStringList(it, list.end()))
291  clear();
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 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 chanid == other.chanid && recstartts == other.recstartts; }
328  bool IsSameChannel(const ProgramInfo &other) const;
329 
330  // Quick gets
333  QString MakeUniqueKey(void) const
334  { return MakeUniqueKey(chanid, recstartts); }
335  uint GetSecondsInRecording(void) const;
336  QString ChannelText(const QString&) const;
337  QString GetPathname(void) const { return pathname; }
338  QString GetBasename(void) const { return 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 pathname.startsWith("/")
346 #ifdef _WIN32
347  || pathname.at(1) == ':'
348 #endif
349  ; }
350  bool IsMythStream(void) const { return pathname.startsWith("myth://"); }
351  bool IsPathSet(void) const { return GetBasename() != pathname; }
352  bool HasPathname(void) const { return !GetPathname().isEmpty(); }
353  bool IsFileReadable(void) const;
354 
355  QString GetTitle(void) const { return title; }
356  QString GetSortTitle(void) const { return sortTitle; }
357  QString GetSubtitle(void) const { return subtitle; }
358  QString GetSortSubtitle(void) const { return sortSubtitle; }
359  QString GetDescription(void) const { return description; }
360  uint GetSeason(void) const { return season; }
361  uint GetEpisode(void) const { return episode; }
362  uint GetEpisodeTotal(void) const { return totalepisodes; }
363  QString GetCategory(void) const { return category; }
366  uint GetChanID(void) const { return chanid; }
370  QString GetChanNum(void) const { return chanstr; }
377  QString GetChannelSchedulingID(void) const { return chansign; }
380  QString GetChannelName(void) const { return channame; }
381  QString GetChannelPlaybackFilters(void) const
382  { return chanplaybackfilters; }
384  QDateTime GetScheduledStartTime(void) const { return startts; }
387  {
388  return MythDate::toString(startts, fmt);
389  }
391  QDateTime GetScheduledEndTime(void) const { return endts; }
394  {
395  return MythDate::toString(endts, fmt);
396  }
398  QDateTime GetRecordingStartTime(void) const { return recstartts; }
401  {
402  return MythDate::toString(recstartts, fmt);
403  }
406  QDateTime GetRecordingEndTime(void) const { return recendts; }
410  {
411  return MythDate::toString(recendts, fmt);
412  }
413  QString GetRecordingGroup(void) const { return recgroup; }
414  QString GetPlaybackGroup(void) const { return playgroup; }
415  QString GetHostname(void) const { return hostname; }
416  QString GetStorageGroup(void) const { return storagegroup; }
418  {
419  return ((year) ? year :
420  (originalAirDate.isValid()) ? originalAirDate.year() : 0);
421  }
422  QDate GetOriginalAirDate(void) const { return originalAirDate; }
423  QDateTime GetLastModifiedTime(void) const { return lastmodified; }
425  {
426  return MythDate::toString(lastmodified, fmt);
427  }
428  virtual uint64_t GetFilesize(void) const; // TODO Remove
429  QString GetSeriesID(void) const { return seriesid; }
430  QString GetProgramID(void) const { return programid; }
431  QString GetInetRef(void) const { return inetref; }
432  CategoryType GetCategoryType(void) const { return catType; }
433  QString GetCategoryTypeString(void) const;
434  int GetRecordingPriority(void) const { return recpriority; }
435  int GetRecordingPriority2(void) const { return recpriority2; }
436  float GetStars(void) const { return stars; }
437  uint GetStars(uint range_max) const
438  { return (int)(stars * range_max + 0.5f); }
439 
440  uint GetRecordingID(void) const { return recordedid; }
442  { return (RecStatus::Type)recstatus; }
443  uint GetRecordingRuleID(void) const { return recordid; }
444  uint GetParentRecordingRuleID(void) const { return parentid; }
446  { return (RecordingType)rectype; }
447 
450  { return (RecordingDupInType)dupin; }
451 
454  { return (RecordingDupMethodType)dupmethod; }
455 
456  uint GetSourceID(void) const { return sourceid; }
457  uint GetInputID(void) const { return inputid; }
458  QString GetInputName(void) const { return inputname; }
459  QString GetShortInputName(void) const
460  { return inputname.isRightToLeft() ?
461  inputname.left(2) : inputname.right(2); }
462  void ClearInputName(void) { inputname.clear(); }
463 
464  uint GetFindID(void) const { return findid; }
465 
466  uint32_t GetProgramFlags(void) const { return programflags; }
468  { return (ProgramInfoType)((programflags & FL_TYPEMASK) >> 20); }
469  QDateTime GetBookmarkUpdate(void) const { return bookmarkupdate; }
470  bool IsGeneric(void) const;
471  bool IsInUsePlaying(void) const { return programflags & FL_INUSEPLAYING;}
472  bool IsCommercialFree(void) const { return programflags & FL_CHANCOMMFREE;}
473  bool HasCutlist(void) const { return programflags & FL_CUTLIST; }
474  bool IsBookmarkSet(void) const { return programflags & FL_BOOKMARK; }
475  bool IsWatched(void) const { return programflags & FL_WATCHED; }
476  bool IsAutoExpirable(void) const { return programflags & FL_AUTOEXP; }
477  bool IsPreserved(void) const { return programflags & FL_PRESERVED; }
478  bool IsVideo(void) const { return programflags & FL_TYPEMASK; }
479  bool IsRecording(void) const { return !IsVideo(); }
480  bool IsRepeat(void) const { return programflags & FL_REPEAT; }
481  bool IsDuplicate(void) const { return programflags & FL_DUPLICATE; }
482  bool IsReactivated(void) const { return programflags & FL_REACTIVATE; }
483  bool IsDeletePending(void) const
484  { return programflags & FL_DELETEPENDING; }
485 
486  uint GetSubtitleType(void) const
487  { return (properties&kSubtitlePropertyMask)>>kSubtitlePropertyOffset; }
489  { return (properties & kVideoPropertyMask) >> kVideoPropertyOffset; }
491  { return (properties & kAudioPropertyMask) >> kAudioPropertyOffset; }
492 
493  typedef enum
494  {
499  } Verbosity;
500  QString toString(Verbosity v = kLongDescription, QString sep = ":",
501  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  { programflags &= ~FL_TYPEMASK; programflags |= ((uint32_t)t<<20); }
508  void SetPathname(const QString&) const;
509  void SetChanID(uint _chanid) { chanid = _chanid; }
510  void SetScheduledStartTime(const QDateTime &dt) { startts = dt; }
511  void SetScheduledEndTime( const QDateTime &dt) { endts = dt; }
512  void SetRecordingStartTime(const QDateTime &dt) { recstartts = dt; }
513  void SetRecordingEndTime( const QDateTime &dt) { recendts = dt; }
514  void SetRecordingGroup(const QString &group) { recgroup = group; }
515  void SetPlaybackGroup( const QString &group) { playgroup = group; }
516  void SetHostname( const QString &host) { hostname = host; }
517  void SetStorageGroup( const QString &group) { storagegroup = group; }
518  virtual void SetFilesize( uint64_t sz);
519  void SetSeriesID( const QString &id) { seriesid = id; }
520  void SetProgramID( const QString &id) { programid = id; }
521  void SetCategory( const QString &cat) { category = cat; }
522  void SetCategoryType( const CategoryType type) { catType = type; }
523  void SetRecordingPriority(int priority) { recpriority = priority; }
524  void SetRecordingPriority2(int priority) { recpriority2 = priority; }
525  void SetRecordingRuleID(uint id) { recordid = id; }
526  void SetSourceID(uint id) { sourceid = id; }
527  void SetInputID(uint id) { inputid = id; }
528  void SetReactivated(bool reactivate)
529  {
530  programflags &= ~FL_REACTIVATE;
531  programflags |= (reactivate) ? FL_REACTIVATE : 0;
532  }
533  void SetEditing(bool editing)
534  {
535  programflags &= ~FL_EDITING;
536  programflags |= (editing) ? FL_EDITING : 0;
537  }
538  void SetFlagging(bool flagging)
539  {
540  programflags &= ~FL_COMMFLAG;
541  programflags |= (flagging) ? FL_COMMFLAG : 0;
542  }
545  void SetIgnoreBookmark(bool ignore)
546  {
547  programflags &= ~FL_IGNOREBOOKMARK;
548  programflags |= (ignore) ? FL_IGNOREBOOKMARK : 0;
549  }
552  void SetIgnoreProgStart(bool ignore)
553  {
554  programflags &= ~FL_IGNOREPROGSTART;
555  programflags |= (ignore) ? FL_IGNOREPROGSTART : 0;
556  }
560  void SetAllowLastPlayPos(bool allow)
561  {
562  programflags &= ~FL_ALLOWLASTPLAYPOS;
563  programflags |= (allow) ? FL_ALLOWLASTPLAYPOS : 0;
564  }
565  virtual void SetRecordingID(uint _recordedid) { recordedid = _recordedid; }
566  void SetRecordingStatus(RecStatus::Type status) { recstatus = status; }
569  { positionMapDBReplacement = pmap; }
570 
571  // Slow DB gets
572  QString QueryBasename(void) const;
573 // uint64_t QueryFilesize(void) const; // TODO Remove
574  uint QueryMplexID(void) const;
575  QDateTime QueryBookmarkTimeStamp(void) const;
576  uint64_t QueryBookmark(void) const;
577  uint64_t QueryProgStart(void) const;
578  uint64_t QueryLastPlayPos(void) const;
579  CategoryType QueryCategoryType(void) const;
580  QStringList QueryDVDBookmark(const QString &serialid) const;
581  QStringList QueryBDBookmark(const QString &serialid) const;
582  bool QueryIsEditing(void) const;
583  bool QueryIsInUse(QStringList &byWho) const;
584  bool QueryIsInUse(QString &byWho) const;
585  bool QueryIsDeleteCandidate(bool one_player_allowed = false) const;
586  AutoExpireType QueryAutoExpire(void) const;
587  TranscodingStatus QueryTranscodeStatus(void) const;
588  bool QueryTuningInfo(QString &channum, QString &input) const;
589  QString QueryInputDisplayName(void) const;
590  uint QueryAverageWidth(void) const;
591  uint QueryAverageHeight(void) const;
592  uint QueryAverageFrameRate(void) const;
593  MarkTypes QueryAverageAspectRatio(void) const;
594  uint32_t QueryTotalDuration(void) const;
595  int64_t QueryTotalFrames(void) const;
596  QString QueryRecordingGroup(void) const;
597  bool QueryMarkupFlag(MarkTypes type) const;
598  uint QueryTranscoderID(void) const;
599  uint64_t QueryLastFrameInPosMap(void) const;
600  bool Reload(void);
601 
602  // Slow DB sets
603  virtual void SaveFilesize(uint64_t fsize);
604  void SaveBookmark(uint64_t frame);
605  void SaveDVDBookmark(const QStringList &fields) const;
606  void SaveBDBookmark(const QStringList &fields) const;
607  void SaveEditing(bool edit);
608  void SaveTranscodeStatus(TranscodingStatus trans);
609  void SaveWatched(bool watchedFlag);
610  void SaveDeletePendingFlag(bool deleteFlag);
611  void SaveCommFlagged(CommFlagStatus flag); // 1 = flagged, 2 = processing
612  void SaveAutoExpire(AutoExpireType autoExpire, bool updateDelete = false);
613  void SavePreserve(bool preserveEpisode);
614  bool SaveBasename(const QString &basename);
615  void SaveAspect(uint64_t frame, MarkTypes type, uint customAspect);
616  void SaveResolution(uint64_t frame, uint width, uint height);
617  void SaveFrameRate(uint64_t frame, uint framerate);
618  void SaveTotalDuration(int64_t duration);
619  void SaveTotalFrames(int64_t frames);
620  void SaveVideoProperties(uint mask, uint video_property_flags);
621  void SaveMarkupFlag(MarkTypes type) const;
622  void ClearMarkupFlag(MarkTypes type) const { ClearMarkupMap(type); }
623  void UpdateLastDelete(bool setTime) const;
624  void MarkAsInUse(bool inuse, QString usedFor = "");
625  void UpdateInUseMark(bool force = false);
626  void SaveSeasonEpisode(uint seas, uint ep);
627  void SaveInetRef(const QString &inet);
628 
629  // Extremely slow functions that cannot be called from the UI thread.
630  QString DiscoverRecordingDirectory(void) const;
631  QString GetPlaybackURL(bool checkMaster = false,
632  bool forceCheckLocal = false) const;
633  ProgramInfoType DiscoverProgramInfoType(void) const;
634 
635  // Edit flagging map
636  bool QueryCutList(frm_dir_map_t &, bool loadAutosave=false) const;
637  void SaveCutList(frm_dir_map_t &, bool isAutoSave=false) const;
638 
639  // Commercial flagging map
640  void QueryCommBreakList(frm_dir_map_t &) const;
641  void SaveCommBreakList(frm_dir_map_t &) const;
642 
643  // Keyframe positions map
644  void QueryPositionMap(frm_pos_map_t &, MarkTypes type) const;
645  void ClearPositionMap(MarkTypes type) const;
646  void SavePositionMap(frm_pos_map_t &, MarkTypes type,
647  int64_t min_frm = -1, int64_t max_frm = -1) const;
648  void SavePositionMapDelta(frm_pos_map_t &, MarkTypes type) const;
649 
650  // Get position/duration for keyframe and vice versa
651  bool QueryKeyFrameInfo(uint64_t *, uint64_t position_or_keyframe,
652  bool backwards,
653  MarkTypes type, const char *from_filemarkup_asc,
654  const char *from_filemarkup_desc,
655  const char *from_recordedseek_asc,
656  const char *from_recordedseek_desc) const;
657  bool QueryKeyFramePosition(uint64_t *, uint64_t keyframe,
658  bool backwards) const;
659  bool QueryPositionKeyFrame(uint64_t *, uint64_t position,
660  bool backwards) const;
661  bool QueryKeyFrameDuration(uint64_t *, uint64_t keyframe,
662  bool backwards) const;
663  bool QueryDurationKeyFrame(uint64_t *, uint64_t duration,
664  bool backwards) const;
665 
666  // Get/set all markup
667  struct MarkupEntry
668  {
669  int type; // MarkTypes
670  uint64_t frame;
671  uint64_t data;
673  MarkupEntry(int t, uint64_t f, uint64_t d, bool n)
674  : type(t), frame(f), data(d), isDataNull(n) {}
676  : type(-1), frame(0), data(0), isDataNull(true) {}
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&);
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 &altTable, int recordid);
708 
709  // Flagging map support methods
710  void QueryMarkupMap(frm_dir_map_t&, MarkTypes type,
711  bool merge = false) const;
712  void SaveMarkupMap(const frm_dir_map_t &, MarkTypes type = MARK_ALL,
713  int64_t min_frm = -1, int64_t max_frm = -1) const;
714  void ClearMarkupMap(MarkTypes type = MARK_ALL,
715  int64_t min_frm = -1, int64_t max_frm = -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  const uint chanid, const QDateTime &recstarttime);
723 
724  bool FromStringList(QStringList::const_iterator &it,
725  QStringList::const_iterator end);
726 
727  static void QueryMarkupMap(
728  const QString &video_pathname,
729  frm_dir_map_t&, MarkTypes type, bool merge = false);
730  static void QueryMarkupMap(
731  uint chanid, const QDateTime &recstartts,
732  frm_dir_map_t&, MarkTypes type, bool merge = false);
733 
734  static int InitStatics(void);
735 
736  protected:
737  QString title;
738  QString sortTitle;
739  QString subtitle;
740  QString sortSubtitle;
741  QString description;
746  QString category;
747  QString director;
748 
749  int32_t recpriority;
750 
751  uint32_t chanid;
752  QString chanstr; // Channum
753  QString chansign; // Callsign
754  QString channame;
756 
757  QString recgroup;
758  QString playgroup;
759 
760  mutable QString pathname;
761 
762  QString hostname;
763  QString storagegroup;
764 
765  QString seriesid;
766  QString programid;
767  QString inetref;
769 
770  uint64_t filesize;
771 
772  QDateTime startts;
773  QDateTime endts;
774  QDateTime recstartts;
775  QDateTime recendts;
776 
777  float stars;
779  QDateTime lastmodified;
780  QDateTime lastInUseTime;
781 
782  int32_t recpriority2;
783 
784  uint32_t recordid;
785  uint32_t parentid;
786 
787  uint32_t sourceid;
788  uint32_t inputid;
789  uint32_t findid;
790 
791  uint32_t programflags;
796 
797  int8_t recstatus;
798  uint8_t rectype;
799  uint8_t dupin;
800  uint8_t dupmethod;
801 
803  QString inputname;
804  QDateTime bookmarkupdate;
805 
806 // everything below this line is not serialized
807  uint8_t availableStatus; // only used for playbackbox.cpp
808  public:
809  void SetAvailableStatus(AvailableStatusType status, const QString &where);
811  { return (AvailableStatusType) availableStatus; }
812  int8_t spread; // only used in guidegrid.cpp
813  int8_t startCol; // only used in guidegrid.cpp
814 
815  static const QString kFromRecordedQuery;
816 
817  protected:
818  QString inUseForWhat;
820 
821  static QMutex staticDataLock;
823  static bool usingProgIDAuth;
824 };
825 
827  ProgramList &destination,
828  const QString &where,
829  const QString &groupBy,
830  const QString &orderBy,
831  const MSqlBindings &bindings,
832  const ProgramList &schedList);
833 
835  ProgramList &destination,
836  const QString &sql,
837  const MSqlBindings &bindings,
838  const ProgramList &schedList);
839 
841  ProgramList &destination,
842  const QString &sql,
843  const MSqlBindings &bindings,
844  const ProgramList &schedList,
845  const uint &start,
846  const uint &limit,
847  uint &count);
848 
850  const uint chanid, const QDateTime &starttime);
851 
853  ProgramList &destination,
854  const QString &sql,
855  const MSqlBindings &bindings);
856 
858  ProgramList &destination,
859  const QString &sql,
860  const MSqlBindings &bindings,
861  const uint &start,
862  const uint &limit,
863  uint &count);
864 
866  ProgramList &destination,
867  bool possiblyInProgressRecordingsOnly,
868  const QMap<QString,uint32_t> &inUseMap,
869  const QMap<QString,bool> &isJobRunning,
870  const QMap<QString, ProgramInfo*> &recMap,
871  int sort = 0,
872  const QString &sortBy = "");
873 
874 
875 template<typename TYPE>
877  AutoDeleteDeque<TYPE*> &destination,
878  bool &hasConflicts,
879  QString altTable = "",
880  int recordid = -1)
881 {
882  destination.clear();
883  hasConflicts = false;
884 
885  QStringList slist = ProgramInfo::LoadFromScheduler(altTable, recordid);
886  if (slist.empty())
887  return false;
888 
889  hasConflicts = slist[0].toInt();
890 
891  QStringList::const_iterator sit = slist.begin()+2;
892  while (sit != slist.end())
893  {
894  TYPE *p = new TYPE(sit, slist.end());
895  destination.push_back(p);
896 
897  if (!p->HasPathname() && !p->GetChanID())
898  {
899  delete p;
900  destination.clear();
901  return false;
902  }
903  }
904 
905  if (destination.size() != slist[1].toUInt())
906  {
907  destination.clear();
908  return false;
909  }
910 
911  return true;
912 }
913 
914 template<typename T>
916 {
917  bool dummyConflicts;
918  return LoadFromScheduler(destination, dummyConflicts, "", -1);
919 }
920 
921 // Moved from programdetails.cpp/h, used by MythWelcome/MythShutdown
922 // could be factored out
923 MPUBLIC bool GetNextRecordingList(QDateTime &nextRecordingStart,
924  bool *hasConflicts = nullptr,
925  std::vector<ProgramInfo> *list = nullptr);
926 
927 class QMutex;
929 {
930  public:
933  QMutex *lock;
934  QMap<MarkTypes,frm_pos_map_t> map;
935 };
936 
937 MPUBLIC QString format_season_and_episode(int seasEp, int digits = -1);
938 
941 
943 
944 #endif // MYTHPROGRAM_H_
945 
946 /* 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)
QString playgroup
Definition: programinfo.h:758
void SetStorageGroup(const QString &group)
Definition: programinfo.h:517
QDateTime lastInUseTime
Definition: programinfo.h:780
float GetStars(void) const
Definition: programinfo.h:436
int32_t recpriority2
Definition: programinfo.h:782
#define kAudioPropertyMask
Definition: programtypes.h:179
ProgramInfoType GetProgramInfoType(void) const
Definition: programinfo.h:467
bool IsPreserved(void) const
Definition: programinfo.h:477
uint GetInputID(void) const
Definition: programinfo.h:457
uint32_t parentid
Definition: programinfo.h:785
uint32_t inputid
Definition: programinfo.h:788
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
QString channame
Definition: programinfo.h:754
VERBOSE_PREAMBLE Most true
Definition: verbosedefs.h:91
void SetEditing(bool editing)
Definition: programinfo.h:533
QMap< MarkTypes, frm_pos_map_t > map
Definition: programinfo.h:934
#define MPUBLIC
Definition: mythexp.h:10
bool IsVideo(void) const
Definition: programinfo.h:478
QString chanstr
Definition: programinfo.h:752
bool IsReactivated(void) const
Definition: programinfo.h:482
void SetScheduledStartTime(const QDateTime &dt)
Definition: programinfo.h:510
QString toString(MarkTypes type)
QString sortTitle
Definition: programinfo.h:738
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
MPUBLIC QString format_season_and_episode(int seasEp, int digits=-1)
QString inetref
Definition: programinfo.h:767
uint32_t chanid
Definition: programinfo.h:751
uint8_t availableStatus
Definition: programinfo.h:807
uint GetSourceID(void) const
Definition: programinfo.h:456
enum RecordingDupInTypes RecordingDupInType
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
QDateTime bookmarkupdate
Definition: programinfo.h:804
bool IsVideoDVD(void) const
Definition: programinfo.h:341
int32_t recpriority
Definition: programinfo.h:749
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
void SetRecordingRuleID(uint id)
Definition: programinfo.h:525
void SetSourceID(uint id)
Definition: programinfo.h:526
bool IsCommercialFree(void) const
Definition: programinfo.h:472
static QStringList LoadFromScheduler(const QString &altTable, int recordid)
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.
Definition: programtypes.h:81
unsigned int uint
Definition: compat.h:140
AutoDeleteDeque< ProgramInfo * > ProgramList
Definition: programinfo.h:29
size_t size(void) const
ProgramInfo(const QStringList &list)
Definition: programinfo.h:285
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
QDateTime recendts
Definition: programinfo.h:775
QDateTime lastmodified
Definition: programinfo.h:779
QDateTime endts
Definition: programinfo.h:773
QString GetChannelPlaybackFilters(void) const
Definition: programinfo.h:381
bool IsBookmarkSet(void) const
Definition: programinfo.h:474
uint32_t recordid
Definition: programinfo.h:784
uint GetVideoProperties(void) const
Definition: programinfo.h:488
QString GetInetRef(void) const
Definition: programinfo.h:431
uint16_t properties
SubtitleType,VideoProperty,AudioProperty.
Definition: programinfo.h:792
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="")
QString GetStorageGroup(void) const
Definition: programinfo.h:416
RecordingDupMethodType
QDateTime GetScheduledStartTime(void) const
The scheduled start time of program.
Definition: programinfo.h:384
QString chansign
Definition: programinfo.h:753
QString MakeUniqueKey(void) const
Creates a unique string that can be used to identify an existing recording.
Definition: programinfo.h:333
MarkTypes
Definition: programtypes.h:48
static bool usingProgIDAuth
Definition: programinfo.h:823
Holds information on recordings and videos.
Definition: programinfo.h:66
MPUBLIC bool GetNextRecordingList(QDateTime &nextRecordingStart, bool *hasConflicts=nullptr, std::vector< ProgramInfo > *list=nullptr)
uint totalepisodes
Definition: programinfo.h:744
QString inputname
Definition: programinfo.h:803
void SetScheduledEndTime(const QDateTime &dt)
Definition: programinfo.h:511
void ClearMarkupFlag(MarkTypes type) const
Definition: programinfo.h:622
QString storagegroup
Definition: programinfo.h:763
uint32_t sourceid
Definition: programinfo.h:787
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:830
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
bool IsRecording(void) const
Definition: programinfo.h:479
QString GetDescription(void) const
Definition: programinfo.h:359
MPUBLIC ProgramInfo * LoadProgramFromProgram(const uint chanid, const QDateTime &starttime)
uint8_t dupmethod
Definition: programinfo.h:800
QString GetBasename(void) const
Definition: programinfo.h:338
QString pathname
Definition: programinfo.h:760
static const uint16_t * d
uint32_t programflags
ProgramFlag.
Definition: programinfo.h:791
QString GetScheduledEndTime(MythDate::Format fmt) const
The scheduled end time of the program (with formatting).
Definition: programinfo.h:393
bool IsVideoBD(void) const
Definition: programinfo.h:343
#define kSubtitlePropertyMask
Definition: programtypes.h:210
unsigned char t
Definition: ParseText.cpp:340
QString GetSortSubtitle(void) const
Definition: programinfo.h:358
uint32_t findid
Definition: programinfo.h:789
QString programid
Definition: programinfo.h:766
bool HasCutlist(void) const
Definition: programinfo.h:473
QString GetShortInputName(void) const
Definition: programinfo.h:459
QString GetSubtitle(void) const
Definition: programinfo.h:357
bool IsLocal(void) const
Definition: programinfo.h:345
bool IsRepeat(void) const
Definition: programinfo.h:480
float stars
Rating, range [0..1].
Definition: programinfo.h:777
AvailableStatusType GetAvailableStatus(void) const
Definition: programinfo.h:810
uint recordedid
Definition: programinfo.h:802
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
bool IsAutoExpirable(void) const
Definition: programinfo.h:476
unsigned short uint16_t
Definition: iso6937tables.h:1
uint GetRecordingID(void) const
Definition: programinfo.h:440
string hostname
Definition: caa.py:17
uint GetSeason(void) const
Definition: programinfo.h:360
enum TranscodingStatuses TranscodingStatus
static bool UsingProgramIDAuthority(void)
Definition: programinfo.h:318
void SetRecordingStatus(RecStatus::Type status)
Definition: programinfo.h:566
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)
MPUBLIC bool LoadFromOldRecorded(ProgramList &destination, const QString &sql, const MSqlBindings &bindings)
QDateTime recstartts
Definition: programinfo.h:774
QString category
Definition: programinfo.h:746
virtual void SetRecordingID(uint _recordedid)
Definition: programinfo.h:565
enum CommFlagStatuses CommFlagStatus
QString title
Definition: programinfo.h:737
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
Definition: mythdate.cpp:101
QString director
Definition: programinfo.h:747
QString GetPlaybackGroup(void) const
Definition: programinfo.h:414
uint8_t rectype
Definition: programinfo.h:798
bool IsVideoFile(void) const
Definition: programinfo.h:339
#define kVideoPropertyOffset
Definition: programtypes.h:195
QString GetSeriesID(void) const
Definition: programinfo.h:429
QDateTime startts
Definition: programinfo.h:772
void SetCategory(const QString &cat)
Definition: programinfo.h:521
QString chanplaybackfilters
Definition: programinfo.h:755
uint GetYearOfInitialRelease(void) const
Definition: programinfo.h:417
enum AvailableStatusTypes AvailableStatusType
void SetChanID(uint _chanid)
Definition: programinfo.h:509
QString sortSubtitle
Definition: programinfo.h:740
void SetInputID(uint id)
Definition: programinfo.h:527
#define kVideoPropertyMask
Definition: programtypes.h:196
uint GetSubtitleType(void) const
Definition: programinfo.h:486
static QMutex staticDataLock
Definition: programinfo.h:821
RecStatus::Type GetRecordingStatus(void) const
Definition: programinfo.h:441
bool IsSameRecording(const ProgramInfo &other) const
Definition: programinfo.h:326
uint GetEpisodeTotal(void) const
Definition: programinfo.h:362
PMapDBReplacement * positionMapDBReplacement
Definition: programinfo.h:819
int GetRecordingPriority2(void) const
Definition: programinfo.h:435
QString GetSortTitle(void) const
Definition: programinfo.h:356
static const QString kFromRecordedQuery
Definition: programinfo.h:815
void SetPositionMapDBReplacement(PMapDBReplacement *pmap)
Definition: programinfo.h:568
bool operator==(const DialogCode &a, const QDialog::DialogCode &b)
Definition: mythdialogs.h:38
RecordingType GetRecordingRuleType(void) const
Definition: programinfo.h:445
uint16_t year
Definition: programinfo.h:793
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 inUseForWhat
Definition: programinfo.h:818
uint16_t parttotal
Definition: programinfo.h:795
QDate originalAirDate
Definition: programinfo.h:778
enum AutoExpireTypes AutoExpireType
void SetRecordingRuleType(RecordingType type)
Definition: programinfo.h:567
QString subtitle
Definition: programinfo.h:739
uint GetRecordingRuleID(void) const
Definition: programinfo.h:443
bool LoadFromScheduler(AutoDeleteDeque< TYPE * > &destination, bool &hasConflicts, QString altTable="", int recordid=-1)
Definition: programinfo.h:876
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
int8_t spread
Definition: programinfo.h:812
void SetRecordingStartTime(const QDateTime &dt)
Definition: programinfo.h:512
QDateTime GetRecordingStartTime(void) const
Approximate time the recording started.
Definition: programinfo.h:398
QString description
Definition: programinfo.h:741
uint64_t filesize
Definition: programinfo.h:770
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
QDateTime GetLastModifiedTime(void) const
Definition: programinfo.h:423
QString seriesid
Definition: programinfo.h:765
QString GetHostname(void) const
Definition: programinfo.h:415
static ProgramInfoUpdater * updater
Definition: programinfo.h:822
QString GetInputName(void) const
Definition: programinfo.h:458
QMap< QString, QVariant > MSqlBindings
typedef for a map of string -> string bindings for generic queries.
Definition: mythdbcon.h:98
MarkupEntry(int t, uint64_t f, uint64_t d, bool n)
Definition: programinfo.h:673
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
QMap< long long, long long > frm_pos_map_t
Frame # -> File offset map.
Definition: programtypes.h:46
RecordingDupInType GetDuplicateCheckSource(void) const
Where should we check for duplicates?
Definition: programinfo.h:449
#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
int8_t recstatus
Definition: programinfo.h:797
QString recgroup
Definition: programinfo.h:757
int8_t startCol
Definition: programinfo.h:813
QString GetPathname(void) const
Definition: programinfo.h:337
CategoryType catType
Definition: programinfo.h:768
CategoryType GetCategoryType(void) const
Definition: programinfo.h:432
bool IsInUsePlaying(void) const
Definition: programinfo.h:471
QString hostname
Definition: programinfo.h:762
bool HasPathname(void) const
Definition: programinfo.h:352
MPUBLIC ProgramInfo::CategoryType string_to_myth_category_type(const QString &type)
uint8_t dupin
Definition: programinfo.h:799
ProgramInfo(QStringList::const_iterator &it, QStringList::const_iterator end)
Definition: programinfo.h:277
enum MythDate::Formats Format
QString syndicatedepisode
Definition: programinfo.h:745
uint GetEpisode(void) const
Definition: programinfo.h:361
uint16_t partnumber
Definition: programinfo.h:794
bool IsDuplicate(void) const
Definition: programinfo.h:481
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