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