MythTV  master
encoderlink.h
Go to the documentation of this file.
1 #ifndef ENCODERLINK_H_
2 #define ENCODERLINK_H_
3 
4 #include <QDateTime> // for QDateTime
5 #include <QMutex> // for QMutex
6 #include <QString> // for QString
7 
8 #include <vector> // for vector
9 
10 #include "enums/recStatus.h"
11 #include "tv.h" // for SleepStatus, etc
12 #include "videoouttypes.h" // for PictureAttribute
13 
14 class TVRec;
15 class PlaybackSock;
16 class LiveTVChain;
17 class InputInfo;
18 class ProgramInfo;
19 class QStringList;
20 
22 {
23  public:
24  EncoderLink(int inputid, PlaybackSock *lsock, QString lhostname);
25  EncoderLink(int inputid, TVRec *ltv);
26 
27  ~EncoderLink();
28 
30  void SetSocket(PlaybackSock *lsock);
32  PlaybackSock *GetSocket(void) { return m_sock; }
33 
35  void SetSleepStatus(SleepStatus newStatus);
37  QDateTime GetSleepStatusTime(void) const { return m_sleepStatusTime; }
39  QDateTime GetLastSleepTime(void) const { return m_lastSleepTime; }
41  void SetLastWakeTime(QDateTime newTime) { m_lastWakeTime = newTime; }
43  QDateTime GetLastWakeTime(void) const { return m_lastWakeTime; }
44 
46  QString GetHostName(void) const { return m_hostname; }
48  bool IsLocal(void) const { return m_local; }
50  bool IsConnected(void) const { return (IsLocal() || m_sock!=nullptr); }
52  bool IsAwake(void) const { return (m_sleepStatus == sStatus_Awake); }
54  bool IsAsleep(void) const { return (m_sleepStatus & sStatus_Asleep); }
56  bool IsWaking(void) const { return (m_sleepStatus == sStatus_Waking); }
58  bool IsFallingAsleep(void) const
59  { return (m_sleepStatus == sStatus_FallingAsleep); }
61  bool CanSleep(void) const { return (m_sleepStatus != sStatus_Undefined); }
62 
64  SleepStatus GetSleepStatus(void) const { return (m_sleepStatus); }
65 
67  int GetInputID(void) const { return m_inputid; }
69  TVRec *GetTVRec(void) { return m_tv; }
70 
72  bool GoToSleep(void);
73  int LockTuner(void);
76  void FreeTuner(void) { m_locked = false; }
79  bool IsTunerLocked(void) const { return m_locked; }
80 
81  bool CheckFile(ProgramInfo *pginfo);
82  void GetDiskSpace(QStringList &o_strlist);
83  long long GetMaxBitrate(void);
84  int SetSignalMonitoringRate(int rate, int notifyFrontend);
85 
86  bool IsBusy(InputInfo *busy_input = nullptr, int time_buffer = 5);
87  bool IsBusyRecording(void);
88 
89  TVState GetState();
90  uint GetFlags(void);
91  bool IsRecording(const ProgramInfo *rec); // scheduler call only.
92 
93  bool MatchesRecording(const ProgramInfo *rec);
94  void RecordPending(const ProgramInfo *rec, int secsleft, bool hasLater);
97  void StopRecording(bool killFile = false);
98  void FinishRecording(void);
99  void FrontendReady(void);
100  void CancelNextRecording(bool);
101  bool WouldConflict(const ProgramInfo *rec);
102 
103  bool IsReallyRecording(void);
104  ProgramInfo *GetRecording(void);
105  float GetFramerate(void);
106  long long GetFramesWritten(void);
107  long long GetFilePosition(void);
108  int64_t GetKeyframePosition(uint64_t desired);
109  bool GetKeyframePositions(int64_t start, int64_t end, frm_pos_map_t&);
110  bool GetKeyframeDurations(int64_t start, int64_t end, frm_pos_map_t&);
111  void SpawnLiveTV(LiveTVChain *chain, bool pip, QString startchan);
112  QString GetChainID(void);
113  void StopLiveTV(void);
114  void PauseRecorder(void);
115  void SetLiveRecording(int);
116  void SetNextLiveTVDir(const QString& dir);
117  QString GetInput(void) const;
118  QString SetInput(QString);
119  void ToggleChannelFavorite(QString);
120  void ChangeChannel(ChannelChangeDirection channeldirection);
121  void SetChannel(const QString &name);
124  PictureAttribute attr,
125  bool direction);
126  bool CheckChannel(const QString &name);
127  bool ShouldSwitchToAnotherInput(const QString &channelid);
128  bool CheckChannelPrefix(const QString&,uint&,bool&,QString&);
129  void GetNextProgram(BrowseDirection direction,
130  QString &title, QString &subtitle, QString &desc,
131  QString &category, QString &starttime,
132  QString &endtime, QString &callsign, QString &iconpath,
133  QString &channelname, uint &chanid,
134  QString &seriesid, QString &programid);
135  bool GetChannelInfo(uint &chanid, uint &sourceid,
136  QString &callsign, QString &channum,
137  QString &channame, QString &xmltv) const;
138  bool SetChannelInfo(uint chanid, uint sourceid,
139  QString oldchannum,
140  QString callsign, QString channum,
141  QString channame, QString xmltv);
142 
143  bool AddChildInput(uint childid);
144 
145  private:
146  bool HasSockAndIncrRef();
147  bool HasSockAndDecrRef();
148 
150 
151  PlaybackSock *m_sock {nullptr};
152  QMutex m_sockLock;
153  QString m_hostname;
154 
155  TVRec *m_tv {nullptr};
156 
157  bool m_local {false};
158  bool m_locked {false};
159 
161  QDateTime m_sleepStatusTime;
162  QDateTime m_lastSleepTime;
163  QDateTime m_lastWakeTime;
164 
168 };
169 
170 #endif
ChannelChangeDirection
ChannelChangeDirection is an enumeration of possible channel changing directions.
Definition: tv.h:28
unsigned int uint
Definition: compat.h:140
TVState
TVState is an enumeration of the states used by TV and TVRec.
Definition: tv.h:50
enum BrowseDirections BrowseDirection
Used to request ProgramInfo for channel browsing.
Holds information on recordings and videos.
Definition: programinfo.h:66
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:150
A slave is awake when it is connected to the master.
Definition: tv.h:100
SleepStatus
SleepStatus is an enumeration of the awake/sleep status of a slave.
Definition: tv.h:97
PictureAttribute
Definition: videoouttypes.h:89
const char * name
Definition: ParseText.cpp:328
A slave is considered asleep when it is not awake and not undefined.
Definition: tv.h:104
PictureAdjustType
Definition: tv.h:120
A slave's sleep status is undefined when it has never connected to the master backend or is not able ...
Definition: tv.h:117
QMap< long long, long long > frm_pos_map_t
Frame # -> File offset map.
Definition: programtypes.h:46
A slave is marked as falling asleep when told to shutdown by the master.
Definition: tv.h:108
Keeps track of recordings in a current LiveTV instance.
Definition: livetvchain.h:31
A slave is marked as waking when the master runs the slave's wakeup command.
Definition: tv.h:112