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 
29 class ProgramInfo;
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) { ensureSortFields(); }
76  ProgramInfo(const ProgramInfo &other);
78  explicit ProgramInfo(uint recordedid);
80  ProgramInfo(uint chanid, const QDateTime &recstartts);
82  ProgramInfo(uint recordedid,
83  QString title,
84  QString sortTitle,
85  QString subtitle,
86  QString sortSubtitle,
87  QString description,
88  uint season,
89  uint episode,
90  uint totalepisodes,
91  QString syndicatedepisode,
92  QString category,
93 
94  uint chanid,
95  QString channum,
96  QString chansign,
97  QString channame,
98  QString chanplaybackfilters,
99 
100  QString recgroup,
101  QString playgroup,
102 
103  const QString &pathname,
104 
105  QString hostname,
106  QString storagegroup,
107 
108  QString seriesid,
109  QString programid,
110  QString inetref,
111  CategoryType catType,
112 
113  int recpriority,
114 
115  uint64_t filesize,
116 
117  QDateTime startts,
118  QDateTime endts,
119  QDateTime recstartts,
120  QDateTime recendts,
121 
122  float stars,
123 
124  uint year,
125  uint partnumber,
126  uint parttotal,
127 
128  const QDate &originalAirDate,
129  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  QString inputname,
145  QDateTime bookmarkupdate);
146 
148  ProgramInfo(QString title,
149  QString sortTitle,
150  QString subtitle,
151  QString sortSubtitle,
152  QString description,
153  uint season,
154  uint episode,
155  QString category,
156 
157  uint chanid,
158  QString channum,
159  QString chansign,
160  QString channame,
161 
162  QString seriesid,
163  QString programid,
164  QString inetref,
165 
166  QDateTime startts,
167  QDateTime endts,
168  QDateTime recstartts,
169  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(QString title,
183  QString sortTitle,
184  QString subtitle,
185  QString sortSubtitle,
186  QString description,
187  QString syndicatedepisode,
188  QString category,
189 
190  uint chanid,
191  QString channum,
192  QString chansign,
193  QString channame,
194  QString chanplaybackfilters,
195 
196  QDateTime startts,
197  QDateTime endts,
198  QDateTime recstartts,
199  QDateTime recendts,
200 
201  QString seriesid,
202  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 videoproperties,
219  uint audioproperties,
220  uint subtitletype,
221 
222  uint season,
223  uint episode,
224  uint totalepisodes,
225 
226  const ProgramList &schedList);
228  ProgramInfo(QString title,
229  QString sortTitle,
230  QString subtitle,
231  QString sortSubtitle,
232  QString description,
233  uint season,
234  uint episode,
235  uint totalepisodes,
236  QString category,
237 
238  uint chanid,
239  QString channum,
240  QString chansign,
241  QString channame,
242  QString chanplaybackfilters,
243 
244  QString recgroup,
245  QString playgroup,
246 
247  QDateTime startts,
248  QDateTime endts,
249  QDateTime recstartts,
250  QDateTime recendts,
251 
252  QString seriesid,
253  QString programid,
254  QString inetref,
255  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  : m_title(_title), m_category(_category),
278  m_startts(_startts), m_endts(_endts) { ensureSortFields(); }
279  ProgramInfo(QStringList::const_iterator &it,
280  QStringList::const_iterator end)
281  {
282  if (!FromStringList(it, end))
284  }
285  explicit ProgramInfo(const QStringList &list)
286  {
287  QStringList::const_iterator it = list.begin();
288  if (!FromStringList(it, list.end()))
290  }
291 
292  bool operator==(const ProgramInfo& rhs);
293  ProgramInfo &operator=(const ProgramInfo &other);
294  virtual void clone(const ProgramInfo &other,
295  bool ignore_non_serialized_data = false);
296  void ensureSortFields(void);
297 
298  virtual void clear(void);
299 
300  // Destructor
301  virtual ~ProgramInfo() = default;
302 
303  // Serializers
304  void ToStringList(QStringList &list) const;
305  virtual void ToMap(InfoMap &progMap,
306  bool showrerecord = false,
307  uint star_range = 10) const;
308  virtual void SubstituteMatches(QString &str);
309 
310  // Used for scheduling recordings
311  bool IsSameProgram(const ProgramInfo &other) const; // Exact same program
312  bool IsDuplicateProgram(const ProgramInfo &other) const; // Is this program considered a duplicate according to rule type and dup method (scheduler only)
313  bool IsSameProgramAndStartTime(const ProgramInfo &other) const; // Exact same program and same starttime, Any channel
314  bool IsSameTitleStartTimeAndChannel(const ProgramInfo &other) const; // Same title, starttime and channel
315  bool IsSameTitleTimeslotAndChannel(const ProgramInfo &other) const;//sched only - Same title, starttime, endtime and channel
316  static bool UsingProgramIDAuthority(void)
317  {
318  return s_usingProgIDAuth;
319  };
320  static void CheckProgramIDAuthorities(void);//sched only
321 
322  // Used for extending scheduled recordings
323  bool IsSameProgramWeakCheck(const ProgramInfo &other) const;
324  bool IsSameRecording(const ProgramInfo &other) const
325  { return m_chanid == other.m_chanid && m_recstartts == other.m_recstartts; }
326  bool IsSameChannel(const ProgramInfo &other) const;
327 
328  // Quick gets
331  QString MakeUniqueKey(void) const
332  { return MakeUniqueKey(m_chanid, m_recstartts); }
333  uint GetSecondsInRecording(void) const;
334  QString ChannelText(const QString&) const;
335  QString GetPathname(void) const { return m_pathname; }
336  QString GetBasename(void) const { return m_pathname.section('/', -1); }
337  bool IsVideoFile(void) const
338  { return GetProgramInfoType() == kProgramInfoTypeVideoFile; }
339  bool IsVideoDVD(void) const
340  { return GetProgramInfoType() == kProgramInfoTypeVideoDVD; }
341  bool IsVideoBD(void) const
342  { return GetProgramInfoType() == kProgramInfoTypeVideoBD; }
343  bool IsLocal(void) const { return m_pathname.startsWith("/")
344 #ifdef _WIN32
345  || m_pathname.at(1) == ':'
346 #endif
347  ; }
348  bool IsMythStream(void) const { return m_pathname.startsWith("myth://"); }
349  bool IsPathSet(void) const { return GetBasename() != m_pathname; }
350  bool HasPathname(void) const { return !GetPathname().isEmpty(); }
351  bool IsFileReadable(void);
352 
353  QString GetTitle(void) const { return m_title; }
354  QString GetSortTitle(void) const { return m_sortTitle; }
355  QString GetSubtitle(void) const { return m_subtitle; }
356  QString GetSortSubtitle(void) const { return m_sortSubtitle; }
357  QString GetDescription(void) const { return m_description; }
358  uint GetSeason(void) const { return m_season; }
359  uint GetEpisode(void) const { return m_episode; }
360  uint GetEpisodeTotal(void) const { return m_totalepisodes; }
361  QString GetCategory(void) const { return m_category; }
364  uint GetChanID(void) const { return m_chanid; }
368  QString GetChanNum(void) const { return m_chanstr; }
375  QString GetChannelSchedulingID(void) const { return m_chansign; }
378  QString GetChannelName(void) const { return m_channame; }
379  QString GetChannelPlaybackFilters(void) const
380  { return m_chanplaybackfilters; }
382  QDateTime GetScheduledStartTime(void) const { return m_startts; }
385  {
386  return MythDate::toString(m_startts, fmt);
387  }
389  QDateTime GetScheduledEndTime(void) const { return m_endts; }
392  {
393  return MythDate::toString(m_endts, fmt);
394  }
396  QDateTime GetRecordingStartTime(void) const { return m_recstartts; }
399  {
400  return MythDate::toString(m_recstartts, fmt);
401  }
404  QDateTime GetRecordingEndTime(void) const { return m_recendts; }
408  {
409  return MythDate::toString(m_recendts, fmt);
410  }
411  QString GetRecordingGroup(void) const { return m_recgroup; }
412  QString GetPlaybackGroup(void) const { return m_playgroup; }
413  QString GetHostname(void) const { return m_hostname; }
414  QString GetStorageGroup(void) const { return m_storagegroup; }
416  {
417  return ((m_year) ? m_year :
418  (m_originalAirDate.isValid()) ? m_originalAirDate.year() : 0);
419  }
420  QDate GetOriginalAirDate(void) const { return m_originalAirDate; }
421  QDateTime GetLastModifiedTime(void) const { return m_lastmodified; }
423  {
424  return MythDate::toString(m_lastmodified, fmt);
425  }
426  virtual uint64_t GetFilesize(void) const; // TODO Remove
427  QString GetSeriesID(void) const { return m_seriesid; }
428  QString GetProgramID(void) const { return m_programid; }
429  QString GetInetRef(void) const { return m_inetref; }
430  CategoryType GetCategoryType(void) const { return m_catType; }
431  QString GetCategoryTypeString(void) const;
432  int GetRecordingPriority(void) const { return m_recpriority; }
433  int GetRecordingPriority2(void) const { return m_recpriority2; }
434  float GetStars(void) const { return m_stars; }
435  uint GetStars(uint range_max) const
436  { return (int)(m_stars * range_max + 0.5F); }
437 
438  uint GetRecordingID(void) const { return m_recordedid; }
440  { return (RecStatus::Type)m_recstatus; }
441  uint GetRecordingRuleID(void) const { return m_recordid; }
442  uint GetParentRecordingRuleID(void) const { return m_parentid; }
444  { return (RecordingType)m_rectype; }
445 
448  { return (RecordingDupInType)m_dupin; }
449 
452  { return (RecordingDupMethodType)m_dupmethod; }
453 
454  uint GetSourceID(void) const { return m_sourceid; }
455  uint GetInputID(void) const { return m_inputid; }
456  QString GetInputName(void) const { return m_inputname; }
457  QString GetShortInputName(void) const
458  { return m_inputname.isRightToLeft() ?
459  m_inputname.left(2) : m_inputname.right(2); }
460  void ClearInputName(void) { m_inputname.clear(); }
461 
462  uint GetFindID(void) const { return m_findid; }
463 
464  uint32_t GetProgramFlags(void) const { return m_programflags; }
466  { return (ProgramInfoType)((m_programflags & FL_TYPEMASK) >> 20); }
467  QDateTime GetBookmarkUpdate(void) const { return m_bookmarkupdate; }
468  bool IsGeneric(void) const;
469  bool IsInUsePlaying(void) const { return m_programflags & FL_INUSEPLAYING;}
470  bool IsCommercialFree(void) const { return m_programflags & FL_CHANCOMMFREE;}
471  bool HasCutlist(void) const { return m_programflags & FL_CUTLIST; }
472  bool IsBookmarkSet(void) const { return m_programflags & FL_BOOKMARK; }
473  bool IsWatched(void) const { return m_programflags & FL_WATCHED; }
474  bool IsAutoExpirable(void) const { return m_programflags & FL_AUTOEXP; }
475  bool IsPreserved(void) const { return m_programflags & FL_PRESERVED; }
476  bool IsVideo(void) const { return m_programflags & FL_TYPEMASK; }
477  bool IsRecording(void) const { return !IsVideo(); }
478  bool IsRepeat(void) const { return m_programflags & FL_REPEAT; }
479  bool IsDuplicate(void) const { return m_programflags & FL_DUPLICATE; }
480  bool IsReactivated(void) const { return m_programflags & FL_REACTIVATE; }
481  bool IsDeletePending(void) const
482  { return m_programflags & FL_DELETEPENDING; }
483 
484  uint GetSubtitleType(void) const
485  { return (m_properties&kSubtitlePropertyMask)>>kSubtitlePropertyOffset; }
487  { return (m_properties & kVideoPropertyMask) >> kVideoPropertyOffset; }
489  { return (m_properties & kAudioPropertyMask) >> kAudioPropertyOffset; }
490 
492  {
497  };
498  QString toString(Verbosity v = kLongDescription, const QString& sep = ":",
499  const QString& grp = "\"") const;
500 
501  // Quick sets
502  void SetTitle(const QString &t, const QString &st = nullptr);
503  void SetSubtitle(const QString &st, const QString &sst = nullptr);
505  { m_programflags &= ~FL_TYPEMASK; m_programflags |= ((uint32_t)t<<20); }
506  void SetPathname(const QString&);
507  void SetChanID(uint _chanid) { m_chanid = _chanid; }
508  void SetScheduledStartTime(const QDateTime &dt) { m_startts = dt; }
509  void SetScheduledEndTime( const QDateTime &dt) { m_endts = dt; }
510  void SetRecordingStartTime(const QDateTime &dt) { m_recstartts = dt; }
511  void SetRecordingEndTime( const QDateTime &dt) { m_recendts = dt; }
512  void SetRecordingGroup(const QString &group) { m_recgroup = group; }
513  void SetPlaybackGroup( const QString &group) { m_playgroup = group; }
514  void SetHostname( const QString &host) { m_hostname = host; }
515  void SetStorageGroup( const QString &group) { m_storagegroup = group; }
516  virtual void SetFilesize( uint64_t sz);
517  void SetSeriesID( const QString &id) { m_seriesid = id; }
518  void SetProgramID( const QString &id) { m_programid = id; }
519  void SetCategory( const QString &cat) { m_category = cat; }
520  void SetCategoryType( const CategoryType type) { m_catType = type; }
521  void SetRecordingPriority(int priority) { m_recpriority = priority; }
522  void SetRecordingPriority2(int priority) { m_recpriority2 = priority; }
523  void SetRecordingRuleID(uint id) { m_recordid = id; }
524  void SetSourceID(uint id) { m_sourceid = id; }
525  void SetInputID(uint id) { m_inputid = id; }
526  void SetReactivated(bool reactivate)
527  {
528  m_programflags &= ~FL_REACTIVATE;
529  m_programflags |= (reactivate) ? FL_REACTIVATE : 0;
530  }
531  void SetEditing(bool editing)
532  {
533  m_programflags &= ~FL_EDITING;
534  m_programflags |= (editing) ? FL_EDITING : 0;
535  }
536  void SetFlagging(bool flagging)
537  {
538  m_programflags &= ~FL_COMMFLAG;
539  m_programflags |= (flagging) ? FL_COMMFLAG : 0;
540  }
543  void SetIgnoreBookmark(bool ignore)
544  {
545  m_programflags &= ~FL_IGNOREBOOKMARK;
546  m_programflags |= (ignore) ? FL_IGNOREBOOKMARK : 0;
547  }
550  void SetIgnoreProgStart(bool ignore)
551  {
552  m_programflags &= ~FL_IGNOREPROGSTART;
553  m_programflags |= (ignore) ? FL_IGNOREPROGSTART : 0;
554  }
558  void SetAllowLastPlayPos(bool allow)
559  {
560  m_programflags &= ~FL_ALLOWLASTPLAYPOS;
561  m_programflags |= (allow) ? FL_ALLOWLASTPLAYPOS : 0;
562  }
563  virtual void SetRecordingID(uint _recordedid)
564  { m_recordedid = _recordedid; }
565  void SetRecordingStatus(RecStatus::Type status) { m_recstatus = status; }
568  { m_positionMapDBReplacement = pmap; }
569 
570  // Slow DB gets
571  QString QueryBasename(void) const;
572 // uint64_t QueryFilesize(void) const; // TODO Remove
573  uint QueryMplexID(void) const;
574  QDateTime QueryBookmarkTimeStamp(void) const;
575  uint64_t QueryBookmark(void) const;
576  uint64_t QueryProgStart(void) const;
577  uint64_t QueryLastPlayPos(void) const;
578  CategoryType QueryCategoryType(void) const;
579  QStringList QueryDVDBookmark(const QString &serialid) const;
580  QStringList QueryBDBookmark(const QString &serialid) const;
581  bool QueryIsEditing(void) const;
582  bool QueryIsInUse(QStringList &byWho) const;
583  bool QueryIsInUse(QString &byWho) const;
584  bool QueryIsDeleteCandidate(bool one_playback_allowed = false) const;
585  AutoExpireType QueryAutoExpire(void) const;
586  TranscodingStatus QueryTranscodeStatus(void) const;
587  bool QueryTuningInfo(QString &channum, QString &input) const;
588  QString QueryInputDisplayName(void) const;
589  uint QueryAverageWidth(void) const;
590  uint QueryAverageHeight(void) const;
591  uint QueryAverageFrameRate(void) const;
592  MarkTypes QueryAverageAspectRatio(void) const;
593  uint32_t QueryTotalDuration(void) const;
594  int64_t QueryTotalFrames(void) const;
595  QString QueryRecordingGroup(void) const;
596  bool QueryMarkupFlag(MarkTypes type) const;
597  uint QueryTranscoderID(void) const;
598  uint64_t QueryLastFrameInPosMap(void) const;
599  bool Reload(void);
600 
601  // Slow DB sets
602  virtual void SaveFilesize(uint64_t fsize);
603  void SaveBookmark(uint64_t frame);
604  static void SaveDVDBookmark(const QStringList &fields) ;
605  static void SaveBDBookmark(const QStringList &fields) ;
606  void SaveEditing(bool edit);
607  void SaveTranscodeStatus(TranscodingStatus trans);
608  void SaveWatched(bool watchedFlag);
609  void SaveDeletePendingFlag(bool deleteFlag);
610  void SaveCommFlagged(CommFlagStatus flag); // 1 = flagged, 2 = processing
611  void SaveAutoExpire(AutoExpireType autoExpire, bool updateDelete = false);
612  void SavePreserve(bool preserveEpisode);
613  bool SaveBasename(const QString &basename);
614  void SaveAspect(uint64_t frame, MarkTypes type, uint customAspect);
615  void SaveResolution(uint64_t frame, uint width, uint height);
616  void SaveFrameRate(uint64_t frame, uint framerate);
617  void SaveTotalDuration(int64_t duration);
618  void SaveTotalFrames(int64_t frames);
619  void SaveVideoProperties(uint mask, uint video_property_flags);
620  void SaveMarkupFlag(MarkTypes type) const;
621  void ClearMarkupFlag(MarkTypes type) const { ClearMarkupMap(type); }
622  void UpdateLastDelete(bool setTime) const;
623  void MarkAsInUse(bool inuse, const QString& usedFor = "");
624  void UpdateInUseMark(bool force = false);
625  void SaveSeasonEpisode(uint seas, uint ep);
626  void SaveInetRef(const QString &inet);
627 
628  // Extremely slow functions that cannot be called from the UI thread.
629  QString DiscoverRecordingDirectory(void);
630  QString GetPlaybackURL(bool checkMaster = false,
631  bool forceCheckLocal = false);
632  ProgramInfoType DiscoverProgramInfoType(void) const;
633 
634  // Edit flagging map
635  bool QueryCutList(frm_dir_map_t &, bool loadAutosave=false) const;
636  void SaveCutList(frm_dir_map_t &, bool isAutoSave=false) const;
637 
638  // Commercial flagging map
639  void QueryCommBreakList(frm_dir_map_t &) const;
640  void SaveCommBreakList(frm_dir_map_t &) const;
641 
642  // Keyframe positions map
643  void QueryPositionMap(frm_pos_map_t &, MarkTypes type) const;
644  void ClearPositionMap(MarkTypes type) const;
645  void SavePositionMap(frm_pos_map_t &, MarkTypes type,
646  int64_t min_frame = -1, int64_t max_frame = -1) const;
647  void SavePositionMapDelta(frm_pos_map_t &, MarkTypes type) const;
648 
649  // Get position/duration for keyframe and vice versa
650  bool QueryKeyFrameInfo(uint64_t *, uint64_t position_or_keyframe,
651  bool backwards,
652  MarkTypes type, const char *from_filemarkup_asc,
653  const char *from_filemarkup_desc,
654  const char *from_recordedseek_asc,
655  const char *from_recordedseek_desc) const;
656  bool QueryKeyFramePosition(uint64_t *, uint64_t keyframe,
657  bool backwards) const;
658  bool QueryPositionKeyFrame(uint64_t *, uint64_t position,
659  bool backwards) const;
660  bool QueryKeyFrameDuration(uint64_t *, uint64_t keyframe,
661  bool backwards) const;
662  bool QueryDurationKeyFrame(uint64_t *, uint64_t duration,
663  bool backwards) const;
664 
665  // Get/set all markup
666  struct MarkupEntry
667  {
668  int type; // MarkTypes
669  uint64_t frame;
670  uint64_t data;
672  MarkupEntry(int t, uint64_t f, uint64_t d, bool n)
673  : type(t), frame(f), data(d), isDataNull(n) {}
675  : type(-1), frame(0), data(0), isDataNull(true) {}
676  };
677  void QueryMarkup(QVector<MarkupEntry> &mapMark,
678  QVector<MarkupEntry> &mapSeek) const;
679  void SaveMarkup(const QVector<MarkupEntry> &mapMark,
680  const QVector<MarkupEntry> &mapSeek) const;
681 
683  void SendUpdateEvent(void);
685  void SendAddedEvent(void) const;
687  void SendDeletedEvent(void) const;
688 
690  static QString i18n(const QString&);
691 
692  static QString MakeUniqueKey(uint chanid, const QDateTime &recstartts);
693  static bool ExtractKey(const QString &uniquekey,
694  uint &chanid, QDateTime &recstartts);
695  static bool ExtractKeyFromPathname(
696  const QString &pathname, uint &chanid, QDateTime &recstartts);
697  static bool QueryKeyFromPathname(
698  const QString &pathname, uint &chanid, QDateTime &recstartts);
699  static bool QueryRecordedIdFromPathname(const QString &pathname,
700  uint &recordedid);
701 
702  static QString QueryRecordingGroupPassword(const QString &group);
703  static uint64_t QueryBookmark(uint chanid, const QDateTime &recstartts);
704  static QMap<QString,uint32_t> QueryInUseMap(void);
705  static QMap<QString,bool> QueryJobsRunning(int type);
706  static QStringList LoadFromScheduler(const QString &tmptable, int recordid);
707 
708  // Flagging map support methods
709  void QueryMarkupMap(frm_dir_map_t&, MarkTypes type,
710  bool merge = false) const;
711  void SaveMarkupMap(const frm_dir_map_t &, MarkTypes type = MARK_ALL,
712  int64_t min_frame = -1, int64_t max_frame = -1) const;
713  void ClearMarkupMap(MarkTypes type = MARK_ALL,
714  int64_t min_frame = -1, int64_t max_frame = -1) const;
715 
716  protected:
717  // Creates a basename from the start and end times
718  QString CreateRecordBasename(const QString &ext) const;
719 
720  bool LoadProgramFromRecorded(
721  const uint chanid, const QDateTime &recstartts);
722 
723  bool FromStringList(QStringList::const_iterator &it,
724  const QStringList::const_iterator& end);
725 
726  static void QueryMarkupMap(
727  const QString &video_pathname,
728  frm_dir_map_t&, MarkTypes type, bool merge = false);
729  static void QueryMarkupMap(
730  uint chanid, const QDateTime &recstartts,
731  frm_dir_map_t&, MarkTypes type, bool merge = false);
732 
733  static int InitStatics(void);
734 
735  protected:
736  QString m_title;
737  QString m_sortTitle;
738  QString m_subtitle;
739  QString m_sortSubtitle;
740  QString m_description;
741  uint m_season {0};
742  uint m_episode {0};
743  uint m_totalepisodes {0};
745  QString m_category;
746  QString m_director;
747 
748  int32_t m_recpriority {0};
749 
750  uint32_t m_chanid {0};
751  QString m_chanstr; // Channum
752  QString m_chansign; // Callsign
753  QString m_channame;
755 
756  QString m_recgroup {"Default"};
757  QString m_playgroup {"Default"};
758 
759  mutable QString m_pathname;
760 
761  QString m_hostname;
762  QString m_storagegroup {"Default"};
763 
764  QString m_seriesid;
765  QString m_programid;
766  QString m_inetref;
767  CategoryType m_catType {kCategoryNone};
768 
769  uint64_t m_filesize {0ULL};
770 
771  QDateTime m_startts {MythDate::current(true)};
772  QDateTime m_endts {m_startts};
773  QDateTime m_recstartts {m_startts};
774  QDateTime m_recendts {m_startts};
775 
776  float m_stars {0.0F};
778  QDateTime m_lastmodified {m_startts};
779  QDateTime m_lastInUseTime {m_startts.addSecs(-4 * 60 * 60)};
780 
781  int32_t m_recpriority2 {0};
782 
783  uint32_t m_recordid {0};
784  uint32_t m_parentid {0};
785 
786  uint32_t m_sourceid {0};
787  uint32_t m_inputid {0};
788  uint32_t m_findid {0};
789 
790  uint32_t m_programflags {FL_NONE};
791  uint16_t m_properties {0};
793  uint16_t m_year {0};
794  uint16_t m_partnumber {0};
795  uint16_t m_parttotal {0};
796 
797  int8_t m_recstatus {RecStatus::Unknown};
798  uint8_t m_rectype {kNotRecording};
799  uint8_t m_dupin {kDupsInAll};
800  uint8_t m_dupmethod {kDupCheckSubThenDesc};
801 
802  uint m_recordedid {0};
803  QString m_inputname;
804  QDateTime m_bookmarkupdate;
805 
806 // everything below this line is not serialized
807  uint8_t m_availableStatus {asAvailable}; // only used for playbackbox.cpp
808  public:
809  void SetAvailableStatus(AvailableStatusType status, const QString &where);
811  { return (AvailableStatusType) m_availableStatus; }
812  int8_t m_spread {-1}; // only used in guidegrid.cpp
813  int8_t m_startCol {-1}; // only used in guidegrid.cpp
814 
815  static const QString kFromRecordedQuery;
816 
817  protected:
818  QString m_inUseForWhat;
819  PMapDBReplacement *m_positionMapDBReplacement {nullptr};
820 
821  static QMutex s_staticDataLock;
823  static bool s_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)
RecordingDupInType
void SetStorageGroup(const QString &group)
Definition: programinfo.h:515
float GetStars(void) const
Definition: programinfo.h:434
#define kAudioPropertyMask
Definition: programtypes.h:179
QString m_channame
Definition: programinfo.h:753
ProgramInfoType GetProgramInfoType(void) const
Definition: programinfo.h:465
QString m_syndicatedepisode
Definition: programinfo.h:744
QString m_sortTitle
Definition: programinfo.h:737
bool IsPreserved(void) const
Definition: programinfo.h:475
uint GetInputID(void) const
Definition: programinfo.h:455
QString m_inputname
Definition: programinfo.h:803
VERBOSE_PREAMBLE Most true
Definition: verbosedefs.h:91
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:558
RecordingDupMethodType GetDuplicateCheckMethod(void) const
What should be compared to determine if two programs are the same?
Definition: programinfo.h:451
QDateTime GetBookmarkUpdate(void) const
Definition: programinfo.h:467
QString GetChannelName(void) const
This is the channel name in the local market, i.e.
Definition: programinfo.h:378
AutoExpireType
Definition: programtypes.h:230
void SetEditing(bool editing)
Definition: programinfo.h:531
QMap< MarkTypes, frm_pos_map_t > map
Definition: programinfo.h:934
#define MPUBLIC
Definition: mythexp.h:10
bool IsVideo(void) const
Definition: programinfo.h:476
QString m_description
Definition: programinfo.h:740
bool IsReactivated(void) const
Definition: programinfo.h:480
void SetScheduledStartTime(const QDateTime &dt)
Definition: programinfo.h:508
QString toString(MarkTypes type)
void SetProgramInfoType(ProgramInfoType t)
Definition: programinfo.h:504
void SetCategoryType(const CategoryType type)
Definition: programinfo.h:520
QString m_chansign
Definition: programinfo.h:752
void SetIgnoreBookmark(bool ignore)
If "ignore" is true GetBookmark() will return 0, otherwise GetBookmark() will return the bookmark pos...
Definition: programinfo.h:543
QDate m_originalAirDate
Definition: programinfo.h:777
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:454
void SetRecordingPriority2(int priority)
Definition: programinfo.h:522
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:339
uint GetParentRecordingRuleID(void) const
Definition: programinfo.h:442
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:407
QString GetTitle(void) const
Definition: programinfo.h:353
TranscodingStatus
Definition: programtypes.h:120
CommFlagStatus
Definition: programtypes.h:83
void SetRecordingRuleID(uint id)
Definition: programinfo.h:523
void SetSourceID(uint id)
Definition: programinfo.h:524
QDateTime m_recstartts
Definition: programinfo.h:773
uint32_t m_chanid
Definition: programinfo.h:750
bool operator==(MusicMetadata &a, MusicMetadata &b)
bool IsCommercialFree(void) const
Definition: programinfo.h:470
size_t size(void) const
ProgramInfo(const QStringList &list)
Definition: programinfo.h:285
void SetReactivated(bool reactivate)
Definition: programinfo.h:526
int GetRecordingPriority(void) const
Definition: programinfo.h:432
#define kAudioPropertyOffset
Definition: programtypes.h:178
void SetFlagging(bool flagging)
Definition: programinfo.h:536
uint GetStars(uint range_max) const
Definition: programinfo.h:435
QString GetChanNum(void) const
This is the channel "number", in the form 1, 1_2, 1-2, 1#1, etc.
Definition: programinfo.h:368
Q_DECLARE_METATYPE(GrabberScript *)
uint GetAudioProperties(void) const
Definition: programinfo.h:488
QString GetChannelPlaybackFilters(void) const
Definition: programinfo.h:379
bool IsBookmarkSet(void) const
Definition: programinfo.h:472
static bool s_usingProgIDAuth
Definition: programinfo.h:823
uint GetVideoProperties(void) const
Definition: programinfo.h:486
static QStringList LoadFromScheduler(const QString &tmptable, int recordid)
QString GetInetRef(void) const
Definition: programinfo.h:429
static QMutex s_staticDataLock
Definition: programinfo.h:821
QDate GetOriginalAirDate(void) const
Definition: programinfo.h:420
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:414
QString m_chanstr
Definition: programinfo.h:751
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:382
QString MakeUniqueKey(void) const
Creates a unique string that can be used to identify an existing recording.
Definition: programinfo.h:331
MarkTypes
Definition: programtypes.h:48
Holds information on recordings and videos.
Definition: programinfo.h:66
MPUBLIC bool GetNextRecordingList(QDateTime &nextRecordingStart, bool *hasConflicts=nullptr, std::vector< ProgramInfo > *list=nullptr)
void SetScheduledEndTime(const QDateTime &dt)
Definition: programinfo.h:509
void ClearMarkupFlag(MarkTypes type) const
Definition: programinfo.h:621
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:739
bool IsWatched(void) const
Definition: programinfo.h:473
void clear(void)
QString GetChannelSchedulingID(void) const
This is the unique programming identifier of a channel.
Definition: programinfo.h:375
uint32_t GetProgramFlags(void) const
Definition: programinfo.h:464
static void clear(SettingsMap &cache, SettingsMap &overrides, const QString &myKey)
Definition: mythdb.cpp:830
bool IsRecording(void) const
Definition: programinfo.h:477
QString GetDescription(void) const
Definition: programinfo.h:357
MPUBLIC ProgramInfo * LoadProgramFromProgram(const uint chanid, const QDateTime &starttime)
QString GetBasename(void) const
Definition: programinfo.h:336
static const uint16_t * d
QString GetScheduledEndTime(MythDate::Format fmt) const
The scheduled end time of the program (with formatting).
Definition: programinfo.h:391
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:10
bool IsVideoBD(void) const
Definition: programinfo.h:341
#define kSubtitlePropertyMask
Definition: programtypes.h:210
QString GetSortSubtitle(void) const
Definition: programinfo.h:356
bool HasCutlist(void) const
Definition: programinfo.h:471
QString GetShortInputName(void) const
Definition: programinfo.h:457
QString GetSubtitle(void) const
Definition: programinfo.h:355
ProgramInfo(void)
Null constructor.
Definition: programinfo.h:74
bool IsLocal(void) const
Definition: programinfo.h:343
bool IsRepeat(void) const
Definition: programinfo.h:478
AvailableStatusType GetAvailableStatus(void) const
Definition: programinfo.h:810
QString GetRecordingStartTime(MythDate::Format fmt) const
Approximate time the recording started (with formatting).
Definition: programinfo.h:398
QString m_programid
Definition: programinfo.h:765
QString GetRecordingGroup(void) const
Definition: programinfo.h:411
QString m_hostname
Definition: programinfo.h:761
bool IsAutoExpirable(void) const
Definition: programinfo.h:474
unsigned short uint16_t
Definition: iso6937tables.h:1
QString m_chanplaybackfilters
Definition: programinfo.h:754
uint GetRecordingID(void) const
Definition: programinfo.h:438
string hostname
Definition: caa.py:17
uint GetSeason(void) const
Definition: programinfo.h:358
static bool UsingProgramIDAuthority(void)
Definition: programinfo.h:316
unsigned int uint
Definition: compat.h:140
void SetRecordingStatus(RecStatus::Type status)
Definition: programinfo.h:565
void SetSeriesID(const QString &id)
TODO Move to RecordingInfo.
Definition: programinfo.h:517
bool IsDeletePending(void) const
Definition: programinfo.h:481
void ClearInputName(void)
Definition: programinfo.h:460
QString GetLastModifiedTime(MythDate::Format fmt) const
Definition: programinfo.h:422
QDateTime GetScheduledEndTime(void) const
The scheduled end time of the program.
Definition: programinfo.h:389
MPUBLIC QString myth_category_type_to_string(ProgramInfo::CategoryType category_type)
MPUBLIC bool LoadFromOldRecorded(ProgramList &destination, const QString &sql, const MSqlBindings &bindings)
AvailableStatusType
Definition: programtypes.h:213
virtual void SetRecordingID(uint _recordedid)
Definition: programinfo.h:563
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
Definition: mythdate.cpp:101
QString GetPlaybackGroup(void) const
Definition: programinfo.h:412
bool IsVideoFile(void) const
Definition: programinfo.h:337
#define kVideoPropertyOffset
Definition: programtypes.h:195
QString GetSeriesID(void) const
Definition: programinfo.h:427
static ProgramInfoUpdater * s_updater
Definition: programinfo.h:822
QString m_inUseForWhat
Definition: programinfo.h:818
void SetCategory(const QString &cat)
Definition: programinfo.h:519
uint GetYearOfInitialRelease(void) const
Definition: programinfo.h:415
void SetChanID(uint _chanid)
Definition: programinfo.h:507
QDateTime m_bookmarkupdate
Definition: programinfo.h:804
void SetInputID(uint id)
Definition: programinfo.h:525
#define kVideoPropertyMask
Definition: programtypes.h:196
uint GetSubtitleType(void) const
Definition: programinfo.h:484
RecStatus::Type GetRecordingStatus(void) const
Definition: programinfo.h:439
bool IsSameRecording(const ProgramInfo &other) const
Definition: programinfo.h:324
uint GetEpisodeTotal(void) const
Definition: programinfo.h:360
int GetRecordingPriority2(void) const
Definition: programinfo.h:433
QString GetSortTitle(void) const
Definition: programinfo.h:354
static const QString kFromRecordedQuery
Definition: programinfo.h:815
void SetPositionMapDBReplacement(PMapDBReplacement *pmap)
Definition: programinfo.h:567
virtual void clear(void)
RecordingType GetRecordingRuleType(void) const
Definition: programinfo.h:443
void SetHostname(const QString &host)
Definition: programinfo.h:514
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
Definition: programinfo.h:364
QString GetPlaybackURL(ProgramInfo *pginfo, bool storePath)
void SetRecordingRuleType(RecordingType type)
Definition: programinfo.h:566
uint GetRecordingRuleID(void) const
Definition: programinfo.h:441
bool LoadFromScheduler(AutoDeleteDeque< TYPE * > &destination, bool &hasConflicts, QString altTable="", int recordid=-1)
Definition: programinfo.h:876
QString GetProgramID(void) const
Definition: programinfo.h:428
uint GetFindID(void) const
Definition: programinfo.h:462
void SetProgramID(const QString &id)
Definition: programinfo.h:518
void SetRecordingStartTime(const QDateTime &dt)
Definition: programinfo.h:510
QDateTime GetRecordingStartTime(void) const
Approximate time the recording started.
Definition: programinfo.h:396
void SetRecordingEndTime(const QDateTime &dt)
Definition: programinfo.h:511
QDateTime GetRecordingEndTime(void) const
Approximate time the recording should have ended, did end, or is intended to end.
Definition: programinfo.h:404
const char * frames[3]
Definition: element.c:46
QString m_subtitle
Definition: programinfo.h:738
QString m_title
Definition: programinfo.h:736
QDateTime GetLastModifiedTime(void) const
Definition: programinfo.h:421
QString m_seriesid
Definition: programinfo.h:764
QString GetHostname(void) const
Definition: programinfo.h:413
QString GetInputName(void) const
Definition: programinfo.h:456
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:672
QString m_inetref
Definition: programinfo.h:766
QString m_pathname
Definition: programinfo.h:759
bool IsMythStream(void) const
Definition: programinfo.h:348
void SetIgnoreProgStart(bool ignore)
If "ignore" is true QueryProgStart() will return 0, otherwise QueryProgStart() will return the progst...
Definition: programinfo.h:550
QString GetCategory(void) const
Definition: programinfo.h:361
RecordingDupInType GetDuplicateCheckSource(void) const
Where should we check for duplicates?
Definition: programinfo.h:447
ProgramInfo(const QString &_title, const QString &_category, const QDateTime &_startts, const QDateTime &_endts)
Constructs a Dummy ProgramInfo (used by GuideGrid)
Definition: programinfo.h:275
#define kSubtitlePropertyOffset
Definition: programtypes.h:209
void SetRecordingGroup(const QString &group)
Definition: programinfo.h:512
void SetRecordingPriority(int priority)
Definition: programinfo.h:521
QString GetScheduledStartTime(MythDate::Format fmt) const
The scheduled start time of program (with formatting).
Definition: programinfo.h:384
QString GetPathname(void) const
Definition: programinfo.h:335
QString m_director
Definition: programinfo.h:746
CategoryType GetCategoryType(void) const
Definition: programinfo.h:430
bool IsInUsePlaying(void) const
Definition: programinfo.h:469
bool HasPathname(void) const
Definition: programinfo.h:350
MPUBLIC ProgramInfo::CategoryType string_to_myth_category_type(const QString &type)
QString m_category
Definition: programinfo.h:745
ProgramInfo(QStringList::const_iterator &it, QStringList::const_iterator end)
Definition: programinfo.h:279
uint GetEpisode(void) const
Definition: programinfo.h:359
bool IsDuplicate(void) const
Definition: programinfo.h:479
bool IsPathSet(void) const
Definition: programinfo.h:349
void SetPlaybackGroup(const QString &group)
Definition: programinfo.h:513
int pginfo_init_statics()
Definition: programinfo.cpp:44