CPPMyth
Library to interoperate with MythTV server
mythtypes.h
1 /*
2  * Copyright (C) 2014 Jean-Luc Barriere
3  *
4  * This Program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2, or (at your option)
7  * any later version.
8  *
9  * This Program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; see the file COPYING. If not, write to
16  * the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
17  * MA 02110-1301 USA
18  * http://www.gnu.org/copyleft/gpl.html
19  *
20  */
21 
22 #ifndef MYTHTYPES_H
23 #define MYTHTYPES_H
24 
25 #include "mythsharedptr.h"
26 #define MYTH_SHARED_PTR Myth::shared_ptr
27 
28 #include <string>
29 #include <stdint.h>
30 #include <vector>
31 #include <map>
32 #include <ctime>
33 
38 namespace Myth
39 {
40  uint32_t StringToId(const std::string& str);
41  std::string IdToString(uint32_t id);
42  time_t StringToTime(const std::string& isotime);
43  std::string TimeToString(time_t time, bool utc = false);
44  int StringToInt(const std::string& str);
45  std::string IntToString(int i);
46 
47  typedef enum
48  {
49  RT_NotRecording = 0, // (0x00)
50  RT_SingleRecord = 1, // (0x01)
51  RT_DailyRecord, // (0x02)
52  RT_ChannelRecord, // (0x03) obsolete since 76
53  RT_AllRecord, // (0x04)
54  RT_WeeklyRecord, // (0x05)
55  RT_OneRecord, // (0x06)
56  RT_OverrideRecord, // (0x07)
57  RT_DontRecord, // (0x08)
58  RT_FindDailyRecord, // (0x09) obsolete since 76
59  RT_FindWeeklyRecord, // (0x0a) obsolete since 76
60  RT_TemplateRecord, // (0x0b)
61  RT_UNKNOWN // Keep at last
62  } RT_t;
63 
64  RT_t RuleTypeFromString(unsigned proto, const std::string& type);
65  RT_t RuleTypeFromNum(unsigned proto, int type);
66  const char *RuleTypeToString(unsigned proto, RT_t type);
67  int RuleTypeToNum(unsigned proto, RT_t type);
68 
69  typedef enum
70  {
71  DI_InRecorded = 0, // (0x01)
72  DI_InOldRecorded = 1, // (0x02)
73  DI_InAll, // (0x0F)
74  DI_NewEpi, // (0x10)
75  DI_UNKNOWN // Keep at last
76  } DI_t;
77 
78  DI_t DupInFromString(unsigned proto, const std::string& type);
79  DI_t DupInFromNum(unsigned proto, int type);
80  const char *DupInToString(unsigned proto, DI_t type);
81  int DupInToNum(unsigned proto, DI_t type);
82 
83  typedef enum
84  {
85  DM_CheckNone = 0, // (0x01)
86  DM_CheckSubtitle = 1, // (0x02)
87  DM_CheckDescription, // (0x04)
88  DM_CheckSubtitleAndDescription, // (0x06)
89  DM_CheckSubtitleThenDescription, // (0x08)
90  DM_UNKNOWN // Keep at last
91  } DM_t;
92 
93  DM_t DupMethodFromString(unsigned proto, const std::string& type);
94  DM_t DupMethodFromNum(unsigned proto, int type);
95  const char *DupMethodToString(unsigned proto, DM_t type);
96  int DupMethodToNum(unsigned proto, DM_t type);
97 
98  typedef enum
99  {
100  ST_NoSearch = 0, // (0x00)
101  ST_PowerSearch = 1, // (0x01)
102  ST_TitleSearch, // (0x02)
103  ST_KeywordSearch, // (0x03)
104  ST_PeopleSearch, // (0x04)
105  ST_ManualSearch, // (0x05)
106  ST_UNKNOWN // Keep at last
107  } ST_t;
108 
109  ST_t SearchTypeFromString(unsigned proto, const std::string& type);
110  ST_t SearchTypeFromNum(unsigned proto, int type);
111  const char *SearchTypeToString(unsigned proto, ST_t type);
112  int SearchTypeToNum(unsigned proto, ST_t type);
113 
114  typedef enum
115  {
116  CATT_CategoryNone = 0,
117  CATT_CategoryMovie,
118  CATT_CategorySeries,
119  CATT_CategorySports,
120  CATT_CategoryTVShow,
121  CATT_UNKNOWN // Keep at last
122  } CATT_t;
123 
124  CATT_t CategoryTypeFromString(unsigned proto, const std::string& type);
125  CATT_t CategoryTypeFromNum(unsigned proto, int type);
126  const char *CategoryTypeToString(unsigned proto, CATT_t type);
127  int CategoryTypeToNum(unsigned proto, CATT_t type);
128 
129  typedef enum
130  {
131  FM_NewEpisode = 0x001,
132  FM_IdentifiableEpisode = 0x002,
133  FM_FirstShowing = 0x004,
134  FM_PrimeTime = 0x008,
135  FM_CommercialFree = 0x010,
136  FM_HighDefinition = 0x020,
137  FM_ThisEpisode = 0x040,
138  FM_ThisSeries = 0x080,
139  FM_ThisTime = 0x100,
140  FM_ThisDayAndTime = 0x200,
141  FM_ThisChannel = 0x400
142  } FM_t;
143 
144  typedef enum
145  {
146  EVENT_HANDLER_STATUS = 0, // Internal event: Backend status change
147  EVENT_HANDLER_TIMER, // Internal event: Every cycle without event
148  EVENT_UNKNOWN,
149  EVENT_UPDATE_FILE_SIZE,
150  EVENT_LIVETV_WATCH,
151  EVENT_LIVETV_CHAIN,
152  EVENT_DONE_RECORDING,
153  EVENT_QUIT_LIVETV,
154  EVENT_RECORDING_LIST_CHANGE,
155  EVENT_SCHEDULE_CHANGE,
156  EVENT_SIGNAL,
157  EVENT_ASK_RECORDING,
158  EVENT_CLEAR_SETTINGS_CACHE,
159  EVENT_GENERATED_PIXMAP,
160  EVENT_SYSTEM_EVENT,
161  } EVENT_t;
162 
163  typedef enum
164  {
165  WHENCE_SET = 0,
166  WHENCE_CUR = 1,
167  WHENCE_END = 2,
168  } WHENCE_t;
169 
170  typedef enum
171  {
172  RS_TUNING = -10,
173  RS_FAILED = -9,
174  RS_TUNER_BUSY = -8,
175  RS_LOW_DISKSPACE = -7,
176  RS_CANCELLED = -6,
177  RS_MISSED = -5,
178  RS_ABORTED = -4,
179  RS_RECORDED = -3,
180  RS_RECORDING = -2,
181  RS_WILL_RECORD = -1,
182  RS_UNKNOWN = 0,
183  RS_DONT_RECORD = 1,
184  RS_PREVIOUS_RECORDING = 2,
185  RS_CURRENT_RECORDING = 3,
186  RS_EARLIER_RECORDING = 4,
187  RS_TOO_MANY_RECORDINGS = 5,
188  RS_NOT_LISTED = 6,
189  RS_CONFLICT = 7,
190  RS_LATER_SHOWING = 8,
191  RS_REPEAT = 9,
192  RS_INACTIVE = 10,
193  RS_NEVER_RECORD = 11,
194  RS_OFFLINE = 12,
195  RS_OTHER_SHOWING = 13,
196  } RS_t;
197 
198  RS_t RecStatusFromString(unsigned proto, const std::string& type);
199  RS_t RecStatusFromNum(unsigned proto, int type);
200  const char *RecStatusToString(unsigned proto, RS_t type);
201  int RecStatusToNum(unsigned proto, RS_t type);
202 
203  struct ItemList
204  {
205  uint32_t count;
206  uint32_t protoVer;
207 
208  ItemList()
209  : count(0)
210  , protoVer(0)
211  {}
212  };
213 
214  typedef std::vector<std::string> StringList;
215  typedef MYTH_SHARED_PTR<StringList> StringListPtr;
216 
217  struct Version
218  {
219  std::string version;
220  uint32_t protocol;
221  uint32_t schema;
222 
223  Version()
224  : protocol(0)
225  , schema(0)
226  {}
227  };
228 
229  typedef MYTH_SHARED_PTR<Version> VersionPtr;
230 
231  struct Setting
232  {
233  std::string key;
234  std::string value;
235  };
236 
237  typedef MYTH_SHARED_PTR<Setting> SettingPtr;
238  typedef std::map<std::string, SettingPtr> SettingMap;
239  typedef MYTH_SHARED_PTR<SettingMap> SettingMapPtr;
240 
241  struct Artwork
242  {
243  std::string url;
244  std::string fileName;
245  std::string storageGroup;
246  std::string type;
247  };
248 
249  typedef MYTH_SHARED_PTR<Artwork> ArtworkPtr;
250  typedef std::vector<ArtworkPtr> ArtworkList;
251  typedef MYTH_SHARED_PTR<ArtworkList> ArtworkListPtr;
252 
253  struct Channel
254  {
255  uint32_t chanId;
256  std::string chanNum;
257  std::string callSign;
258  std::string iconURL;
259  std::string channelName;
260  uint32_t mplexId;
261  std::string commFree;
262  std::string chanFilters;
263  uint32_t sourceId;
264  uint32_t inputId;
265  bool visible;
266 
267  Channel()
268  : chanId(0)
269  , mplexId(0)
270  , sourceId(0)
271  , inputId(0)
272  , visible(true)
273  {}
274  };
275 
276  typedef MYTH_SHARED_PTR<Channel> ChannelPtr;
277  typedef std::vector<ChannelPtr> ChannelList;
278  typedef MYTH_SHARED_PTR<ChannelList> ChannelListPtr;
279 
280  struct Recording
281  {
282  uint32_t recordId;
283  int32_t priority;
284  int8_t status;
285  uint32_t encoderId;
286  uint8_t recType;
287  uint8_t dupInType;
288  uint8_t dupMethod;
289  time_t startTs;
290  time_t endTs;
291  std::string profile;
292  std::string recGroup;
293  std::string storageGroup;
294  std::string playGroup;
295  uint32_t recordedId; // Since proto 82
296 
297  Recording()
298  : recordId(0)
299  , priority(0)
300  , status(0)
301  , encoderId(0)
302  , recType(0)
303  , dupInType(DI_InRecorded)
304  , dupMethod(DM_CheckNone)
305  , startTs(0)
306  , endTs(0)
307  , recordedId(0)
308  {}
309  };
310 
311  typedef MYTH_SHARED_PTR<Recording> RecordingPtr;
312  typedef std::vector<RecordingPtr> RecordingList;
313  typedef MYTH_SHARED_PTR<RecordingList> RecordingListPtr;
314 
315  struct Program
316  {
317  time_t startTime;
318  time_t endTime;
319  std::string title;
320  std::string subTitle;
321  std::string description;
322  uint16_t season;
323  uint16_t episode;
324  std::string category;
325  std::string catType;
326  std::string hostName;
327  std::string fileName;
328  int64_t fileSize;
329  bool repeat;
330  uint32_t programFlags;
331  std::string seriesId;
332  std::string programId;
333  std::string inetref;
334  time_t lastModified;
335  std::string stars;
336  time_t airdate;
337  uint16_t audioProps;
338  uint16_t videoProps;
339  uint16_t subProps;
340  Channel channel;
341  Recording recording;
342  std::vector<Artwork> artwork;
343 
344  Program()
345  : startTime(0)
346  , endTime(0)
347  , season(0)
348  , episode(0)
349  , fileSize(0)
350  , repeat(false)
351  , programFlags(0)
352  , lastModified(0)
353  , airdate(0)
354  , audioProps(0)
355  , videoProps(0)
356  , subProps(0)
357  {}
358  };
359 
360  typedef MYTH_SHARED_PTR<Program> ProgramPtr;
361  typedef std::vector<ProgramPtr> ProgramList;
362  typedef MYTH_SHARED_PTR<ProgramList> ProgramListPtr;
363  typedef std::map<time_t, ProgramPtr> ProgramMap;
364  typedef MYTH_SHARED_PTR<ProgramMap> ProgramMapPtr;
365 
366  struct CaptureCard
367  {
368  uint32_t cardId;
369  std::string cardType;
370  std::string hostName;
371 
372  CaptureCard()
373  : cardId(0)
374  {}
375  };
376 
377  typedef MYTH_SHARED_PTR<CaptureCard> CaptureCardPtr;
378  typedef std::vector<CaptureCardPtr> CaptureCardList;
379  typedef MYTH_SHARED_PTR<CaptureCardList> CaptureCardListPtr;
380 
381  struct CardInput
382  {
383  uint32_t inputId;
384  uint32_t cardId;
385  uint32_t sourceId;
386  uint32_t mplexId;
387  std::string inputName;
388  uint8_t liveTVOrder;
389 
390  CardInput()
391  : inputId(0)
392  , cardId(0)
393  , sourceId(0)
394  , mplexId(0)
395  , liveTVOrder(0)
396  {}
397  };
398 
399  typedef MYTH_SHARED_PTR<CardInput> CardInputPtr;
400  typedef std::vector<CardInputPtr> CardInputList;
401  typedef MYTH_SHARED_PTR<CardInputList> CardInputListPtr;
402 
403  struct VideoSource
404  {
405  uint32_t sourceId;
406  std::string sourceName;
407 
408  VideoSource()
409  : sourceId(0)
410  {}
411  };
412 
413  typedef MYTH_SHARED_PTR<VideoSource> VideoSourcePtr;
414  typedef std::vector<VideoSourcePtr> VideoSourceList;
415  typedef MYTH_SHARED_PTR<VideoSourceList> VideoSourceListPtr;
416 
418  {
419  uint32_t recordId;
420  std::string title;
421  std::string subtitle;
422  std::string description;
423  std::string category;
424  time_t startTime;
425  time_t endTime;
426  std::string seriesId;
427  std::string programId;
428  uint32_t chanId;
429  std::string callSign;
430  int8_t findDay;
431  std::string findTime;
432  uint32_t parentId;
433  bool inactive;
434  uint16_t season;
435  uint16_t episode;
436  std::string inetref;
437  std::string type;
438  RT_t type_t;
439  std::string searchType;
440  ST_t searchType_t;
441  int8_t recPriority;
442  uint32_t preferredInput;
443  uint8_t startOffset;
444  uint8_t endOffset;
445  std::string dupMethod;
446  DM_t dupMethod_t;
447  std::string dupIn;
448  DI_t dupIn_t;
449  uint32_t filter;
450  std::string recProfile;
451  std::string recGroup;
452  std::string storageGroup;
453  std::string playGroup;
454  bool autoExpire;
455  uint32_t maxEpisodes;
456  bool maxNewest;
457  bool autoCommflag;
458  bool autoTranscode;
459  bool autoMetaLookup;
460  bool autoUserJob1;
461  bool autoUserJob2;
462  bool autoUserJob3;
463  bool autoUserJob4;
464  uint32_t transcoder;
465  time_t nextRecording;
466  time_t lastRecorded;
467  time_t lastDeleted;
468  uint32_t averageDelay;
469 
471  : recordId(0)
472  , startTime(0)
473  , endTime(0)
474  , chanId(0)
475  , findDay(0)
476  , parentId(0)
477  , inactive(false)
478  , season(0)
479  , episode(0)
480  , type_t(RT_NotRecording)
481  , searchType_t(ST_NoSearch)
482  , recPriority(0)
483  , preferredInput(0)
484  , startOffset(0)
485  , endOffset(0)
486  , dupMethod_t(DM_CheckNone)
487  , dupIn_t(DI_InRecorded)
488  , filter(0)
489  , autoExpire(false)
490  , maxEpisodes(0)
491  , maxNewest(false)
492  , autoCommflag(false)
493  , autoTranscode(false)
494  , autoMetaLookup(false)
495  , autoUserJob1(false)
496  , autoUserJob2(false)
497  , autoUserJob3(false)
498  , autoUserJob4(false)
499  , transcoder(0)
500  , nextRecording(0)
501  , lastRecorded(0)
502  , lastDeleted(0)
503  , averageDelay(0)
504  {}
505  };
506 
507  typedef MYTH_SHARED_PTR<RecordSchedule> RecordSchedulePtr;
508  typedef std::vector<RecordSchedulePtr> RecordScheduleList;
509  typedef MYTH_SHARED_PTR<RecordScheduleList> RecordScheduleListPtr;
510 
512  {
513  bool lock;
514  int signal;
515  int snr;
516  long ber;
517  long ucb;
518 
519  SignalStatus()
520  : lock(false)
521  , signal(0)
522  , snr(0)
523  , ber(0)
524  , ucb(0)
525  {}
526  };
527 
528  typedef MYTH_SHARED_PTR<SignalStatus> SignalStatusPtr;
529 
531  {
532  EVENT_t event;
533  std::vector<std::string> subject;
534  ProgramPtr program;
535  SignalStatusPtr signal;
536 
537  EventMessage()
538  : event(EVENT_UNKNOWN)
539  {}
540  };
541 
542  typedef MYTH_SHARED_PTR<const EventMessage> EventMessagePtr;
543 
545  {
546  std::string fileName;
547  std::string storageGroup;
548  std::string hostName;
549  time_t lastModified;
550  int64_t size;
551 
553  : lastModified(0)
554  , size(0)
555  {}
556  };
557 
558  typedef MYTH_SHARED_PTR<StorageGroupFile> StorageGroupFilePtr;
559 
560  typedef enum
561  {
562  MARK_CUT_END = 0,
563  MARK_CUT_START = 1,
564  MARK_BOOKMARK = 2,
565  MARK_BLANK_FRAME = 3,
566  MARK_COMM_START = 4,
567  MARK_COMM_END = 5,
568  MARK_GOP_START = 6,
569  MARK_KEYFRAME = 7,
570  MARK_SCENE_CHANGE = 8,
571  MARK_GOP_BYFRAME = 9,
572  MARK_ASPECT_1_1 = 10,
573  MARK_ASPECT_4_3 = 11,
574  MARK_ASPECT_16_9 = 12,
575  MARK_ASPECT_2_21_1 = 13,
576  MARK_ASPECT_CUSTOM = 14,
577  MARK_VIDEO_WIDTH = 30,
578  MARK_VIDEO_HEIGHT = 31,
579  MARK_VIDEO_RATE = 32,
580  MARK_DURATION_MS = 33,
581  MARK_TOTAL_FRAMES = 34,
582  } MARK_t;
583 
584  struct Mark
585  {
586  MARK_t markType;
587  int64_t markValue;
588 
589  Mark()
590  : markType(MARK_CUT_END)
591  , markValue(0)
592  {}
593  };
594 
595  typedef MYTH_SHARED_PTR<Mark> MarkPtr;
596  typedef std::vector<MarkPtr> MarkList;
597  typedef MYTH_SHARED_PTR<MarkList> MarkListPtr;
598 }
599 
600 #endif /* MYTHTYPES_H */
This is the main namespace that encloses all public classes.
Definition: mythcontrol.h:29