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 class QStringList;
23 
25 {
26  public:
27  EncoderLink(int inputid, PlaybackSock *lsock, QString lhostname);
28  EncoderLink(int inputid, TVRec *ltv);
29 
30  ~EncoderLink();
31 
33  void SetSocket(PlaybackSock *lsock);
35  PlaybackSock *GetSocket(void) { return m_sock; }
36 
38  void SetSleepStatus(SleepStatus newStatus);
40  QDateTime GetSleepStatusTime(void) const { return m_sleepStatusTime; }
42  QDateTime GetLastSleepTime(void) const { return m_lastSleepTime; }
44  void SetLastWakeTime(QDateTime newTime) { m_lastWakeTime = std::move(newTime); }
46  QDateTime GetLastWakeTime(void) const { return m_lastWakeTime; }
47 
49  QString GetHostName(void) const { return m_hostname; }
51  bool IsLocal(void) const { return m_local; }
53  bool IsConnected(void) const { return (IsLocal() || m_sock!=nullptr); }
55  bool IsAwake(void) const { return (m_sleepStatus == sStatus_Awake); }
57  bool IsAsleep(void) const { return (m_sleepStatus & sStatus_Asleep) != 0; }
59  bool IsWaking(void) const { return (m_sleepStatus == sStatus_Waking); }
61  bool IsFallingAsleep(void) const
62  { return (m_sleepStatus == sStatus_FallingAsleep); }
64  bool CanSleep(void) const { return (m_sleepStatus != sStatus_Undefined); }
65 
67  SleepStatus GetSleepStatus(void) const { return (m_sleepStatus); }
68 
70  int GetInputID(void) const { return m_inputid; }
72  TVRec *GetTVRec(void) { return m_tv; }
73 
75  bool GoToSleep(void);
76  int LockTuner(void);
79  void FreeTuner(void) { m_locked = false; }
82  bool IsTunerLocked(void) const { return m_locked; }
83 
84  bool CheckFile(ProgramInfo *pginfo);
85  void GetDiskSpace(QStringList &o_strlist);
86  long long GetMaxBitrate(void);
87  int SetSignalMonitoringRate(int rate, int notifyFrontend);
88 
89  bool IsBusy(InputInfo *busy_input = nullptr, int time_buffer = 5);
90  bool IsBusyRecording(void);
91 
92  TVState GetState();
93  uint GetFlags(void);
94  bool IsRecording(const ProgramInfo *rec); // scheduler call only.
95 
96  bool MatchesRecording(const ProgramInfo *rec);
97  void RecordPending(const ProgramInfo *rec, int secsleft, bool hasLater);
100  void StopRecording(bool killFile = false);
101  void FinishRecording(void);
102  void FrontendReady(void);
103  void CancelNextRecording(bool cancel);
104  bool WouldConflict(const ProgramInfo *rec);
105 
106  bool IsReallyRecording(void);
107  ProgramInfo *GetRecording(void);
108  float GetFramerate(void);
109  long long GetFramesWritten(void);
110  long long GetFilePosition(void);
111  int64_t GetKeyframePosition(uint64_t desired);
112  bool GetKeyframePositions(int64_t start, int64_t end, frm_pos_map_t &map);
113  bool GetKeyframeDurations(int64_t start, int64_t end, frm_pos_map_t &map);
114  void SpawnLiveTV(LiveTVChain *chain, bool pip, QString startchan);
115  QString GetChainID(void);
116  void StopLiveTV(void);
117  void PauseRecorder(void);
118  void SetLiveRecording(int recording);
119  void SetNextLiveTVDir(const QString& dir);
120  QString GetInput(void) const;
121  QString SetInput(QString input);
122  void ToggleChannelFavorite(const QString &changroup);
123  void ChangeChannel(ChannelChangeDirection channeldirection);
124  void SetChannel(const QString &name);
127  PictureAttribute attr,
128  bool direction);
129  bool CheckChannel(const QString &name);
130  bool ShouldSwitchToAnotherInput(const QString &channelid);
131  bool CheckChannelPrefix(const QString &prefix, uint &complete_valid_channel_on_rec,
132  bool &is_extra_char_useful, QString &needed_spacer);
133  void GetNextProgram(BrowseDirection direction,
134  QString &title, QString &subtitle, QString &desc,
135  QString &category, QString &starttime,
136  QString &endtime, QString &callsign, QString &iconpath,
137  QString &channelname, uint &chanid,
138  QString &seriesid, QString &programid);
139  bool GetChannelInfo(uint &chanid, uint &sourceid,
140  QString &callsign, QString &channum,
141  QString &channame, QString &xmltv) const;
142  bool SetChannelInfo(uint chanid, uint sourceid,
143  const QString& oldchannum,
144  const QString& callsign, const QString& channum,
145  const QString& channame, const QString& xmltv);
146 
147  bool AddChildInput(uint childid);
148 
149  private:
150  bool HasSockAndIncrRef();
151  bool HasSockAndDecrRef();
152 
154 
155  PlaybackSock *m_sock {nullptr};
156  QMutex m_sockLock;
157  QString m_hostname;
158 
159  TVRec *m_tv {nullptr};
160 
161  bool m_local {false};
162  bool m_locked {false};
163 
165  QDateTime m_sleepStatusTime;
166  QDateTime m_lastSleepTime;
167  QDateTime m_lastWakeTime;
168 
172 };
173 
174 #endif
RecStatus::Type
Type
Definition: recStatus.h:16
tv.h
ChannelChangeDirection
ChannelChangeDirection
ChannelChangeDirection is an enumeration of possible channel changing directions.
Definition: tv.h:29
SleepStatus
SleepStatus
SleepStatus is an enumeration of the awake/sleep status of a slave.
Definition: tv.h:97
PictureAdjustType
PictureAdjustType
Definition: tv.h:121
title
QString title
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:639
category
QString category
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1425
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:140
PlaybackSock
Definition: playbacksock.h:29
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:88
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:68
TVState
TVState
TVState is an enumeration of the states used by TV and TVRec.
Definition: tv.h:51
dir
QDir dir
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1177
TVRec
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:143
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:15
BrowseDirection
BrowseDirection
Used to request ProgramInfo for channel browsing.
Definition: tv.h:38
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:32