MythTV  master
livetvchain.h
Go to the documentation of this file.
1 #ifndef _LIVETVCHAIN_H_
2 #define _LIVETVCHAIN_H_
3 
4 #include <climits>
5 
6 #include <QString>
7 #include <QStringList>
8 #include <QDateTime>
9 #include <QMutex>
10 #include <QList>
11 
12 #include "mythtvexp.h"
13 #include "referencecounter.h"
14 
15 
16 class ProgramInfo;
17 class MythSocket;
18 
20 {
22  QDateTime starttime;
23  QDateTime endtime;
24  bool discontinuity; // if true, can't play smooth from last entry
25  QString hostprefix;
26  QString inputtype;
27  QString channum;
28  QString inputname;
29 };
30 
32 {
33  public:
34  LiveTVChain();
35  ~LiveTVChain();
36 
37  QString InitializeNewChain(const QString &seed);
38  void LoadFromExistingChain(const QString &id);
39 
40  void SetHostPrefix(const QString &prefix);
41  void SetInputType(const QString &type);
42 
43  void DestroyChain(void);
44 
45  void AppendNewProgram(ProgramInfo *pginfo, const QString& channum,
46  const QString& inputname, bool discont);
47  void FinishedRecording(ProgramInfo *pginfo);
48  void DeleteProgram(ProgramInfo *pginfo);
49 
50  void ReloadAll(const QStringList &data = QStringList());
51 
52  // const gets
53  QString GetID(void) const { return m_id; }
54  int GetCurPos(void) const { return m_curpos; }
55  int ProgramIsAt(uint chanid, const QDateTime &starttime) const;
56  int ProgramIsAt(const ProgramInfo &pginfo) const;
57  int GetLengthAtCurPos(void);
58  int GetLengthAtPos(int pos);
59  int TotalSize(void) const;
60  bool HasNext(void) const;
61  bool HasPrev(void) const { return (m_curpos > 0); }
62  ProgramInfo *GetProgramAt(int at) const;
65  bool NeedsToSwitch(void) const
66  { return (m_switchid >= 0 && m_jumppos == INT_MAX); }
68  bool NeedsToJump(void) const
69  { return (m_switchid >= 0 && m_jumppos != INT_MAX); }
70  QString GetChannelName(int pos = -1) const;
71  QString GetInputName(int pos = -1) const;
72  QString GetInputType(int pos = -1) const;
73 
74  // sets/gets program to switch to
75  void SetProgram(const ProgramInfo &pginfo);
76  void SwitchTo(int num);
77  void SwitchToNext(bool up);
78  void ClearSwitch(void);
79  ProgramInfo *GetSwitchProgram(bool &discont, bool &newtype, int &newid);
80 
81  // sets/gets program to jump to
82  void JumpTo(int num, int pos);
83  void JumpToNext(bool up, int pos);
84  int GetJumpPos(void);
85 
86  // socket stuff
87  void SetHostSocket(MythSocket *sock);
88  bool IsHostSocket(MythSocket *sock);
89  uint HostSocketCount(void) const;
90  void DelHostSocket(MythSocket *sock);
91 
92  QString toString() const;
93 
94  // serialize m_maxpos and m_chain to a stringlist
95  QStringList entriesToStringList() const;
96  // deserialize m_maxpos and m_chain from a stringlist
97  bool entriesFromStringList(const QStringList &items);
98 
99  private:
100  void BroadcastUpdate();
101  void GetEntryAt(int at, LiveTVChainEntry &entry) const;
102  static ProgramInfo *EntryToProgram(const LiveTVChainEntry &entry);
103  ProgramInfo *DoGetNextProgram(bool up, int curpos, int &newid,
104  bool &discont, bool &newtype);
105 
106  QString m_id;
107  QList<LiveTVChainEntry> m_chain;
108  int m_maxpos {0};
109  mutable QMutex m_lock {QMutex::Recursive};
110 
111  QString m_hostprefix;
112  QString m_inputtype;
113 
114  int m_curpos {0};
115  uint m_cur_chanid {0};
116  QDateTime m_cur_startts;
117 
118  int m_switchid {-1};
120 
121  int m_jumppos {INT_MAX};
122 
123  mutable QMutex m_sockLock;
124  QList<MythSocket*> m_inUseSocks;
125 };
126 
127 #endif
128 
QString GetID(void) const
Definition: livetvchain.h:53
bool NeedsToJump(void) const
Returns true iff a switch and jump are required.
Definition: livetvchain.h:68
QString toString(MarkTypes type)
QDateTime endtime
Definition: livetvchain.h:23
General purpose reference counter.
QString m_id
Definition: livetvchain.h:106
QString m_hostprefix
Definition: livetvchain.h:111
QDateTime starttime
Definition: livetvchain.h:22
QString inputtype
Definition: livetvchain.h:26
Holds information on recordings and videos.
Definition: programinfo.h:66
QDateTime m_cur_startts
Definition: livetvchain.h:116
QString m_inputtype
Definition: livetvchain.h:112
#define MTV_PUBLIC
Definition: mythtvexp.h:15
bool NeedsToSwitch(void) const
Returns true iff a switch is required but no jump is required m_jumppos sets to INT_MAX means not set...
Definition: livetvchain.h:65
QMutex m_sockLock
Definition: livetvchain.h:123
QList< LiveTVChainEntry > m_chain
Definition: livetvchain.h:107
QString hostprefix
Definition: livetvchain.h:25
QList< MythSocket * > m_inUseSocks
Definition: livetvchain.h:124
LiveTVChainEntry m_switchentry
Definition: livetvchain.h:119
unsigned int uint
Definition: compat.h:140
bool HasPrev(void) const
Definition: livetvchain.h:61
Class for communcating between myth backends and frontends.
Definition: mythsocket.h:26
int GetCurPos(void) const
Definition: livetvchain.h:54
Keeps track of recordings in a current LiveTV instance.
Definition: livetvchain.h:31
QString inputname
Definition: livetvchain.h:28