00001 #ifndef PROGRAMINFO_H_
00002 #define PROGRAMINFO_H_
00003
00004 #include "recordingtypes.h"
00005 #include "mythdbcon.h"
00006
00007 #include <qstring.h>
00008 #include <qdatetime.h>
00009 #include <qmap.h>
00010 #include <qregexp.h>
00011 #include <vector>
00012
00013 using namespace std;
00014 typedef QMap<long long, long long> frm_pos_map_t;
00015 typedef QMap<long long, int> frm_dir_map_t;
00016
00017
00018
00019
00020
00021
00022
00023
00024 #define NUMPROGRAMLINES 46
00025
00026 typedef enum {
00027 MARK_UNSET = -10,
00028 MARK_UPDATED_CUT = -3,
00029 MARK_EDIT_MODE = -2,
00030 MARK_CUT_END = 0,
00031 MARK_CUT_START = 1,
00032 MARK_BOOKMARK = 2,
00033 MARK_BLANK_FRAME = 3,
00034 MARK_COMM_START = 4,
00035 MARK_COMM_END = 5,
00036 MARK_GOP_START = 6,
00037 MARK_KEYFRAME = 7,
00038 MARK_SCENE_CHANGE = 8,
00039 MARK_GOP_BYFRAME = 9
00040 } MarkTypes;
00041
00042 enum CommFlagStatuses {
00043 COMM_FLAG_NOT_FLAGGED = 0,
00044 COMM_FLAG_DONE = 1,
00045 COMM_FLAG_PROCESSING = 2,
00046 COMM_FLAG_COMMFREE = 3
00047 };
00048
00049 enum TranscodingStatuses {
00050 TRANSCODING_NOT_TRANSCODED = 0,
00051 TRANSCODING_COMPLETE = 1,
00052 TRANSCODING_RUNNING = 2
00053 };
00054
00055 enum FlagMask {
00056 FL_COMMFLAG = 0x0001,
00057 FL_CUTLIST = 0x0002,
00058 FL_AUTOEXP = 0x0004,
00059 FL_EDITING = 0x0008,
00060 FL_BOOKMARK = 0x0010,
00061 FL_INUSERECORDING = 0x0020,
00062 FL_INUSEPLAYING = 0x0040,
00063 FL_TRANSCODED = 0x0400,
00064 FL_WATCHED = 0x0800,
00065 FL_PRESERVED = 0x1000,
00066 };
00067
00068
00069
00070 enum AudioProps {
00071 AUD_UNKNOWN = 0x00,
00072 AUD_STEREO = 0x01,
00073 AUD_MONO = 0x02,
00074 AUD_SURROUND = 0x04,
00075 AUD_DOLBY = 0x08,
00076 AUD_HARDHEAR = 0x10,
00077 AUD_VISUALIMPAIR = 0x20,
00078 };
00079
00080
00081
00082 enum VideoProps {
00083 VID_UNKNOWN = 0x00,
00084 VID_HDTV = 0x01,
00085 VID_WIDESCREEN = 0x02,
00086 VID_AVC = 0x04,
00087 };
00088
00089
00090
00091 enum SubtitleTypes {
00092 SUB_UNKNOWN = 0x00,
00093 SUB_HARDHEAR = 0x01,
00094 SUB_NORMAL = 0x02,
00095 SUB_ONSCREEN = 0x04,
00096 SUB_SIGNED = 0x08
00097 };
00098
00099 enum RecStatusType {
00100 rsFailed = -9,
00101 rsTunerBusy = -8,
00102 rsLowDiskSpace = -7,
00103 rsCancelled = -6,
00104 rsMissed = -5,
00105 rsAborted = -4,
00106 rsRecorded = -3,
00107 rsRecording = -2,
00108 rsWillRecord = -1,
00109 rsUnknown = 0,
00110 rsDontRecord = 1,
00111 rsPreviousRecording = 2,
00112 rsCurrentRecording = 3,
00113 rsEarlierShowing = 4,
00114 rsTooManyRecordings = 5,
00115 rsNotListed = 6,
00116 rsConflict = 7,
00117 rsLaterShowing = 8,
00118 rsRepeat = 9,
00119 rsInactive = 10,
00120 rsNeverRecord = 11,
00121 rsOffLine = 12,
00122 rsOtherShowing = 13
00123 };
00124
00125 enum AvailableStatusType {
00126 asAvailable = 0,
00127 asNotYetAvailable,
00128 asPendingDelete,
00129 asFileNotFound,
00130 asZeroByte,
00131 asDeleted
00132 };
00133
00134 enum WatchListStatus {
00135 wlDeleted = -4,
00136 wlEarlier = -3,
00137 wlWatched = -2,
00138 wlExpireOff = -1
00139 };
00140
00141 enum AutoExpireType {
00142 kDisableAutoExpire = 0,
00143 kNormalAutoExpire = 1,
00144 kDeletedAutoExpire = 9999,
00145 kLiveTVAutoExpire = 10000
00146 };
00147
00148 class ScheduledRecording;
00149 class QGridLayout;
00150
00151 class MPUBLIC ProgramInfo
00152 {
00153 public:
00154
00155 ProgramInfo(void);
00156 ProgramInfo(const ProgramInfo &other);
00157 static ProgramInfo *GetProgramAtDateTime(const QString &channel,
00158 const QDateTime &dtime,
00159 bool genUnknown = false,
00160 int clampHoursMax = 0);
00161 static ProgramInfo *GetProgramFromBasename(const QString filename);
00162 static ProgramInfo *GetProgramFromRecorded(const QString &channel,
00163 const QString &starttime);
00164 static ProgramInfo *GetProgramFromRecorded(const QString &channel,
00165 const QDateTime &dtime);
00166
00167 ProgramInfo& operator=(const ProgramInfo &other);
00168 ProgramInfo& clone(const ProgramInfo &other);
00169 bool FromStringList(QStringList::const_iterator &it,
00170 QStringList::const_iterator end);
00171 bool FromStringList(const QStringList &list, uint offset);
00172
00173 bool FillInRecordInfo(const vector<ProgramInfo *> &reclist);
00174
00175
00176 ~ProgramInfo();
00177
00178
00179 void Save() const;
00180 void ToStringList(QStringList &list) const;
00181 void ToMap(QMap<QString, QString> &progMap,
00182 bool showrerecord = false) const;
00183
00184
00185 int IsProgramRecurring(void) const;
00186 bool IsSameProgram(const ProgramInfo& other) const;
00187 bool IsSameTimeslot(const ProgramInfo& other) const;
00188 bool IsSameProgramTimeslot(const ProgramInfo& other) const;
00189 static int GetChannelRecPriority(const QString &channel);
00190 static int GetRecordingTypeRecPriority(RecordingType type);
00191
00192
00193 ScheduledRecording* GetScheduledRecording(void);
00194 int getRecordID(void);
00195 int GetAutoRunJobs(void) const;
00196 RecordingType GetProgramRecordingStatus(void);
00197 QString GetProgramRecordingProfile(void);
00198 void ApplyRecordStateChange(RecordingType newstate);
00199 void ApplyRecordRecPriorityChange(int);
00200 void ToggleRecord(void);
00201 void ReactivateRecording(void);
00202 void AddHistory(bool resched = true, bool forcedup = false);
00203 void DeleteHistory(void);
00204 void ForgetHistory(void);
00205 void SetDupHistory(void);
00206
00207
00208 void StartedRecording(QString ext);
00209 void FinishedRecording(bool prematurestop);
00210 void UpdateRecordingEnd(void);
00211 void ApplyRecordRecID(void);
00212 void ApplyRecordRecGroupChange(const QString &newrecgroup);
00213 void ApplyRecordPlayGroupChange(const QString &newrecgroup);
00214 void ApplyRecordRecTitleChange(const QString &newTitle,
00215 const QString &newSubtitle);
00216 void ApplyTranscoderProfileChange(QString);
00217
00218
00219 bool SetRecordBasename(QString basename);
00220 QString GetRecordBasename(bool fromDB = false) const;
00221 QString GetPlaybackURL(bool checkMaster = false,
00222 bool forceCheckLocal = false);
00223 QString MakeUniqueKey(void) const;
00224 int CalculateLength(void) const;
00225 int SecsTillStart() const;
00226 QString ChannelText(const QString&) const;
00227 QString RecTypeChar(void) const;
00228 QString RecTypeText(void) const;
00229 QString RecStatusChar(void) const;
00230 QString RecStatusText(void) const;
00231 QString RecStatusDesc(void) const;
00232 void UpdateInUseMark(bool force = false);
00233 bool PathnameExists(void);
00234
00235
00238 void setIgnoreBookmark(bool ignore) { ignoreBookmark = ignore; }
00239
00240
00241 long long GetFilesize(void);
00242 int GetMplexID(void) const;
00243 long long GetBookmark(void) const;
00244 QStringList GetDVDBookmark(QString serialid, bool delbookmark) const;
00245 bool IsEditing(void) const;
00246 bool IsCommFlagged(void) const;
00247 bool IsInUse(QString &byWho) const;
00248 int GetAutoExpireFromRecorded(void) const;
00249 int GetTranscodedStatus(void) const;
00250 bool GetPreserveEpisodeFromRecorded(void) const;
00251 bool UsesMaxEpisodes(void) const;
00252 int getProgramFlags(void) const;
00253 void getProgramProperties(void);
00254 bool GetChannel(QString &channum, QString &input) const;
00255 QString GetFileName(void) const { return pathname; }
00256 QString toString(void) const;
00257
00258
00259 void SetFilesize(long long fsize);
00260 void SetBookmark(long long pos) const;
00261 void SetDVDBookmark(QStringList fields) const;
00262 void SetEditing(bool edit) const;
00263 void SetTranscoded(int transFlag) const;
00264 void SetWatchedFlag(bool watchedFlag) const;
00265 void SetDeleteFlag(bool deleteFlag) const;
00266 void SetCommFlagged(int flag) const;
00267 void SetAutoExpire(int autoExpire, bool updateDelete = false) const;
00268 void SetPreserveEpisode(bool preserveEpisode) const;
00269 void UpdateLastDelete(bool setTime) const;
00270
00271
00272 void GetCutList(frm_dir_map_t &) const;
00273 void GetCommBreakList(frm_dir_map_t &) const;
00274
00275 void SetCutList(frm_dir_map_t &) const;
00276 void SetCommBreakList(frm_dir_map_t &) const;
00277
00278
00279 bool CheckMarkupFlag(int type) const;
00280 void GetMarkupMap(frm_dir_map_t&, int type, bool merge = false) const;
00281 void SetMarkupFlag(int type, bool processing) const;
00282 void SetMarkupMap(frm_dir_map_t &, int type = -100,
00283 long long min_frm = -1, long long max_frm = -1) const;
00284 void ClearMarkupMap(int type = -100,
00285 long long min_frm = -1, long long max_frm = -1) const;
00286
00287
00288 void GetPositionMap(frm_pos_map_t &, int type) const;
00289 void ClearPositionMap(int type) const;
00290 void SetPositionMap(frm_pos_map_t &, int type,
00291 long long min_frm = -1, long long max_frm = -1) const;
00292 void SetPositionMapDelta(frm_pos_map_t &, int type) const;
00293
00294
00295
00296 void showDetails(void) const;
00297 void EditRecording(void);
00298 void EditScheduled(void);
00299
00300
00301 void MarkAsInUse(bool inuse, QString usedFor = "");
00302
00303
00304 static QString GetRecGroupPassword(QString group);
00305 void UpdateRecGroup(void);
00306
00307 private:
00308
00309 bool IsFindApplicable(void) const;
00310 void ShowRecordingDialog(void);
00311 void ShowNotRecordingDialog(void);
00312
00313
00314 QString CreateRecordBasename(const QString &ext) const;
00315
00316 public:
00317
00318 QString title;
00319 QString subtitle;
00320 QString description;
00321 QString category;
00322
00323 QString chanid;
00324 QString chanstr;
00325 QString chansign;
00326 QString channame;
00327
00328
00329 int recpriority;
00330 QString recgroup;
00331 QString playgroup;
00332 int chancommfree;
00333
00334 QString pathname;
00335 long long filesize;
00336 QString hostname;
00337 QString storagegroup;
00338
00339 QDateTime startts;
00340 QDateTime endts;
00341 QDateTime recstartts;
00342 QDateTime recendts;
00343
00344 AvailableStatusType availableStatus;
00345
00346 bool isVideo;
00347 int lenMins;
00348
00349 QString year;
00350 float stars;
00351
00352 QDate originalAirDate;
00353 QDateTime lastmodified;
00354 QDateTime lastInUseTime;
00355
00356 bool hasAirDate;
00357 bool repeat;
00358
00359 int spread;
00360 int startCol;
00361
00362 RecStatusType recstatus;
00363 RecStatusType oldrecstatus;
00364 RecStatusType savedrecstatus;
00365 int prefinput;
00366 int recpriority2;
00367 int reactivate;
00368
00369 int recordid;
00370 int parentid;
00371 RecordingType rectype;
00372 RecordingDupInType dupin;
00373 RecordingDupMethodType dupmethod;
00374
00375 int sourceid;
00376 int inputid;
00377 int cardid;
00378 bool shareable;
00379 bool duplicate;
00380
00381 QString schedulerid;
00382 int findid;
00383
00384 int programflags;
00385 int subtitleType;
00386 int videoproperties;
00387 int audioproperties;
00388 int transcoder;
00389 QString chanOutputFilters;
00390
00391 QString seriesid;
00392 QString programid;
00393 QString catType;
00394
00395 QString sortTitle;
00396
00397 private:
00398 bool ignoreBookmark;
00399 mutable class ScheduledRecording* record;
00400 mutable QMutex regExpLock;
00401 QRegExp regExpSeries;
00402
00403 QString inUseForWhat;
00404 };
00405
00409 class MPUBLIC ProgramList: public QPtrList<ProgramInfo> {
00410 public:
00411 ProgramList(bool autoDelete = true) {
00412 setAutoDelete(autoDelete);
00413 compareFunc = NULL;
00414 };
00415 ~ProgramList(void) { };
00416
00417 ProgramInfo * operator[](uint index) {
00418 return at(index);
00419 };
00420
00421 bool FromScheduler(bool &hasConflicts, QString altTable = "", int recordid=-1);
00422 bool FromScheduler(void) {
00423 bool dummyConflicts;
00424 return FromScheduler(dummyConflicts);
00425 };
00426
00427 bool FromProgram(const QString &sql, MSqlBindings &bindings,
00428 ProgramList &schedList, bool oneChanid = false);
00429 bool FromProgram(const QString &sql, MSqlBindings &bindings) {
00430 ProgramList dummySched;
00431 return FromProgram(sql, bindings, dummySched);
00432 }
00433
00434 bool FromRecorded( bool bDescending, ProgramList *pSchedList );
00435
00436 bool FromOldRecorded(const QString &sql, MSqlBindings &bindings);
00437
00438 typedef int (*CompareFunc)(ProgramInfo *p1, ProgramInfo *p2);
00439 void Sort(CompareFunc func) {
00440 compareFunc = func;
00441 sort();
00442 };
00443
00444 protected:
00445 virtual int compareItems(QPtrCollection::Item item1,
00446 QPtrCollection::Item item2);
00447
00448 private:
00449 CompareFunc compareFunc;
00450 };
00451
00452 #endif
00453
00454