MythTV  master
playbacksock.h
Go to the documentation of this file.
1 #ifndef PLAYBACKSOCK_H_
2 #define PLAYBACKSOCK_H_
3 
4 #include <vector>
5 
6 #include <QStringList>
7 #include <QDateTime>
8 #include <QMutex>
9 #include <QSize>
10 
11 #include "referencecounter.h"
12 #include "programinfo.h" // ProgramInfo
13 #include "programtypes.h" // RecStatus::Type
14 #include "inputinfo.h"
15 
16 class MythSocket;
17 class MainServer;
18 class ProgramInfo;
19 
25 };
26 
28 {
29  public:
30  PlaybackSock(MainServer *parent, MythSocket *lsock,
31  QString lhostname, PlaybackSockEventsMode eventsMode);
32 
33  void SetDisconnected(void) { m_disconnected = true; }
34  bool IsDisconnected(void) const { return m_disconnected; }
35 
36  MythSocket *getSocket(void) const { return m_sock; }
37  QString getHostname(void) const { return m_hostname; }
38 
39  bool isLocal(void) const { return m_local; }
40  bool wantsEvents(void) const;
41  bool wantsNonSystemEvents(void) const;
42  bool wantsSystemEvents(void) const;
43  bool wantsOnlySystemEvents(void) const;
45 
46  bool getBlockShutdown(void) const { return m_blockshutdown; }
47  void setBlockShutdown(bool value) { m_blockshutdown = value; }
48 
49  bool IsFrontend(void) const { return m_frontend; }
50  void SetAsFrontend(void) { m_frontend = true; }
51 
52  // all backend<->backend stuff below here
53  bool isSlaveBackend(void) const { return m_backend; }
54  void setAsSlaveBackend(void) { m_backend = true; m_mediaserver = true; }
55 
56  bool isMediaServer(void) const { return m_mediaserver; }
57  void setAsMediaServer(void) { m_mediaserver = true; }
58 
59  void setIP(const QString &lip) { m_ip = lip; }
60  QString getIP(void) const { return m_ip; }
61 
62  bool GoToSleep(void);
63  void GetDiskSpace(QStringList &o_strlist);
64  int DeleteFile(const QString &filename, const QString &sgroup);
65  int StopRecording(const ProgramInfo *pginfo);
66  int CheckRecordingActive(const ProgramInfo *pginfo);
67  int DeleteRecording(const ProgramInfo *pginfo, bool forceMetadataDelete = false);
68  bool FillProgramInfo(ProgramInfo &pginfo, const QString &playbackhost);
69  QStringList GetSGFileList(const QString &host, const QString &groupname,
70  const QString &directory, bool fileNamesOnly);
71  QStringList GetSGFileQuery(const QString &host, const QString &groupname,
72  const QString &filename);
73  QString GetFileHash(const QString& filename, const QString& storageGroup);
74  QStringList GetFindFile(const QString &host, const QString &filename,
75  const QString &storageGroup, bool useRegex);
76 
77  QStringList GenPreviewPixmap(const QString &token,
78  const ProgramInfo *pginfo);
79  QStringList GenPreviewPixmap(const QString &token,
80  const ProgramInfo *pginfo,
81  bool time_fmt_sec,
82  long long time,
83  const QString &outputFile,
84  QSize outputSize);
85  QDateTime PixmapLastModified(const ProgramInfo *pginfo);
86  bool CheckFile(ProgramInfo *pginfo);
87 
88  bool IsBusy(int capturecardnum,
89  InputInfo *busy_input = nullptr,
90  int time_buffer = 5);
91  int GetEncoderState(int capturecardnum);
92  long long GetMaxBitrate(int capturecardnum);
93  ProgramInfo *GetRecording(uint cardid);
94  bool EncoderIsRecording(int capturecardnum, const ProgramInfo *pginfo);
95  RecStatus::Type StartRecording(int capturecardnum,
96  ProgramInfo *pginfo);
97  RecStatus::Type GetRecordingStatus(int capturecardnum);
98  void RecordPending(int capturecardnum, const ProgramInfo *pginfo,
99  int secsleft, bool hasLater);
100  int SetSignalMonitoringRate(int capturecardnum, int rate, int notifyFrontend);
101  void SetNextLiveTVDir(int capturecardnum, const QString& dir);
102  void CancelNextRecording(int capturecardnum, bool cancel);
103 
104  QStringList ForwardRequest(const QStringList &slist);
105 
106  bool ReadStringList(QStringList &list);
107 
108  bool AddChildInput(uint childid);
109 
110  // Enforce reference counting
111  protected:
112  ~PlaybackSock() override;
113 
114  private:
115  bool SendReceiveStringList(QStringList &strlist, uint min_reply_length = 0);
116 
117  MythSocket *m_sock {nullptr};
118  QString m_hostname;
119  QString m_ip;
120 
121  bool m_local {true};
123  bool m_blockshutdown {true};
124  bool m_backend {false};
125  bool m_mediaserver {false};
126  bool m_frontend {false};
127 
128  QMutex m_sockLock;
129 
130  bool m_disconnected {false};
131 
132  MainServer *m_parent {nullptr};
133 };
134 
135 #endif
136 
137 /* vim: set expandtab tabstop=4 shiftwidth=4: */
RecStatus::Type
Type
Definition: recStatus.h:16
PlaybackSock::IsFrontend
bool IsFrontend(void) const
Definition: playbacksock.h:49
kPBSEvents_SystemOnly
@ kPBSEvents_SystemOnly
Definition: playbacksock.h:24
kPBSEvents_None
@ kPBSEvents_None
Definition: playbacksock.h:21
PlaybackSock::SetDisconnected
void SetDisconnected(void)
Definition: playbacksock.h:33
PlaybackSock::GetDiskSpace
void GetDiskSpace(QStringList &o_strlist)
Appends host's dir's total and used space in kilobytes.
Definition: playbacksock.cpp:140
PlaybackSock::wantsOnlySystemEvents
bool wantsOnlySystemEvents(void) const
Definition: playbacksock.cpp:56
PlaybackSock::m_hostname
QString m_hostname
Definition: playbacksock.h:118
PlaybackSock::m_sock
MythSocket * m_sock
Definition: playbacksock.h:117
PlaybackSock::EncoderIsRecording
bool EncoderIsRecording(int capturecardnum, const ProgramInfo *pginfo)
Definition: playbacksock.cpp:429
PlaybackSock::wantsSystemEvents
bool wantsSystemEvents(void) const
Definition: playbacksock.cpp:50
PlaybackSock::~PlaybackSock
~PlaybackSock() override
Definition: playbacksock.cpp:33
PlaybackSock::PlaybackSock
PlaybackSock(MainServer *parent, MythSocket *lsock, QString lhostname, PlaybackSockEventsMode eventsMode)
Definition: playbacksock.cpp:17
PlaybackSock::m_eventsMode
PlaybackSockEventsMode m_eventsMode
Definition: playbacksock.h:122
PlaybackSock::setAsSlaveBackend
void setAsSlaveBackend(void)
Definition: playbacksock.h:54
kPBSEvents_Normal
@ kPBSEvents_Normal
Definition: playbacksock.h:22
PlaybackSock::m_ip
QString m_ip
Definition: playbacksock.h:119
PlaybackSock::FillProgramInfo
bool FillProgramInfo(ProgramInfo &pginfo, const QString &playbackhost)
Definition: playbacksock.cpp:202
MainServer
Definition: mainserver.h:114
kPBSEvents_NonSystem
@ kPBSEvents_NonSystem
Definition: playbacksock.h:23
PlaybackSock::eventsMode
PlaybackSockEventsMode eventsMode(void) const
Definition: playbacksock.cpp:61
PlaybackSock::m_sockLock
QMutex m_sockLock
Definition: playbacksock.h:128
PlaybackSock::GenPreviewPixmap
QStringList GenPreviewPixmap(const QString &token, const ProgramInfo *pginfo)
Definition: playbacksock.cpp:273
PlaybackSock::DeleteFile
int DeleteFile(const QString &filename, const QString &sgroup)
Definition: playbacksock.cpp:161
programtypes.h
MythSocket
Class for communcating between myth backends and frontends.
Definition: mythsocket.h:27
PlaybackSock::setAsMediaServer
void setAsMediaServer(void)
Definition: playbacksock.h:57
PlaybackSock::StopRecording
int StopRecording(const ProgramInfo *pginfo)
Definition: playbacksock.cpp:173
PlaybackSock::m_disconnected
bool m_disconnected
Definition: playbacksock.h:130
PlaybackSock::isSlaveBackend
bool isSlaveBackend(void) const
Definition: playbacksock.h:53
programinfo.h
PlaybackSock::IsBusy
bool IsBusy(int capturecardnum, InputInfo *busy_input=nullptr, int time_buffer=5)
Definition: playbacksock.cpp:336
PlaybackSock::SendReceiveStringList
bool SendReceiveStringList(QStringList &strlist, uint min_reply_length=0)
Definition: playbacksock.cpp:80
PlaybackSock::IsDisconnected
bool IsDisconnected(void) const
Definition: playbacksock.h:34
PlaybackSock::m_frontend
bool m_frontend
Definition: playbacksock.h:126
PlaybackSock::m_backend
bool m_backend
Definition: playbacksock.h:124
PlaybackSock::m_local
bool m_local
Definition: playbacksock.h:121
PlaybackSock::isLocal
bool isLocal(void) const
Definition: playbacksock.h:39
PlaybackSock::getHostname
QString getHostname(void) const
Definition: playbacksock.h:37
PlaybackSock::AddChildInput
bool AddChildInput(uint childid)
Tells a slave to add a child input.
Definition: playbacksock.cpp:535
PlaybackSock::GetRecordingStatus
RecStatus::Type GetRecordingStatus(int capturecardnum)
Definition: playbacksock.cpp:460
PlaybackSock::CancelNextRecording
void CancelNextRecording(int capturecardnum, bool cancel)
Definition: playbacksock.cpp:512
PlaybackSock::GetFileHash
QString GetFileHash(const QString &filename, const QString &storageGroup)
Definition: playbacksock.cpp:249
PlaybackSock::CheckFile
bool CheckFile(ProgramInfo *pginfo)
Definition: playbacksock.cpp:321
PlaybackSock::wantsNonSystemEvents
bool wantsNonSystemEvents(void) const
Definition: playbacksock.cpp:44
filename
QString filename
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:637
PlaybackSock::SetSignalMonitoringRate
int SetSignalMonitoringRate(int capturecardnum, int rate, int notifyFrontend)
Definition: playbacksock.cpp:489
PlaybackSock::RecordPending
void RecordPending(int capturecardnum, const ProgramInfo *pginfo, int secsleft, bool hasLater)
Definition: playbacksock.cpp:477
PlaybackSock::SetNextLiveTVDir
void SetNextLiveTVDir(int capturecardnum, const QString &dir)
Definition: playbacksock.cpp:503
PlaybackSock::SetAsFrontend
void SetAsFrontend(void)
Definition: playbacksock.h:50
uint
unsigned int uint
Definition: compat.h:141
PlaybackSock::GetEncoderState
int GetEncoderState(int capturecardnum)
Returns the maximum bits per second the recorder can produce.
Definition: playbacksock.cpp:379
token
return token
Definition: musicutils.cpp:74
PlaybackSock::StartRecording
RecStatus::Type StartRecording(int capturecardnum, ProgramInfo *pginfo)
Definition: playbacksock.cpp:442
PlaybackSock::GoToSleep
bool GoToSleep(void)
Tells a slave to go to sleep.
Definition: playbacksock.cpp:130
PlaybackSock
Definition: playbacksock.h:28
referencecounter.h
PlaybackSock::wantsEvents
bool wantsEvents(void) const
Definition: playbacksock.cpp:39
PlaybackSock::m_blockshutdown
bool m_blockshutdown
Definition: playbacksock.h:123
PlaybackSock::GetSGFileQuery
QStringList GetSGFileQuery(const QString &host, const QString &groupname, const QString &filename)
Definition: playbacksock.cpp:236
PlaybackSock::GetRecording
ProgramInfo * GetRecording(uint cardid)
Returns the ProgramInfo being used by any current recording.
Definition: playbacksock.cpp:411
ProgramInfo
Holds information on recordings and videos.
Definition: programinfo.h:68
PlaybackSock::CheckRecordingActive
int CheckRecordingActive(const ProgramInfo *pginfo)
Definition: playbacksock.cpp:150
dir
QDir dir
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1174
PlaybackSock::GetSGFileList
QStringList GetSGFileList(const QString &host, const QString &groupname, const QString &directory, bool fileNamesOnly)
Definition: playbacksock.cpp:222
inputinfo.h
PlaybackSock::setBlockShutdown
void setBlockShutdown(bool value)
Definition: playbacksock.h:47
InputInfo
Definition: inputinfo.h:15
PlaybackSock::m_mediaserver
bool m_mediaserver
Definition: playbacksock.h:125
PlaybackSock::getSocket
MythSocket * getSocket(void) const
Definition: playbacksock.h:36
PlaybackSock::GetFindFile
QStringList GetFindFile(const QString &host, const QString &filename, const QString &storageGroup, bool useRegex)
Definition: playbacksock.cpp:259
PlaybackSock::isMediaServer
bool isMediaServer(void) const
Definition: playbacksock.h:56
PlaybackSock::getIP
QString getIP(void) const
Definition: playbacksock.h:60
PlaybackSock::DeleteRecording
int DeleteRecording(const ProgramInfo *pginfo, bool forceMetadataDelete=false)
Definition: playbacksock.cpp:184
PlaybackSock::ForwardRequest
QStringList ForwardRequest(const QStringList &slist)
Definition: playbacksock.cpp:523
PlaybackSock::ReadStringList
bool ReadStringList(QStringList &list)
Definition: playbacksock.cpp:66
PlaybackSockEventsMode
PlaybackSockEventsMode
Definition: playbacksock.h:20
PlaybackSock::getBlockShutdown
bool getBlockShutdown(void) const
Definition: playbacksock.h:46
PlaybackSock::m_parent
MainServer * m_parent
Definition: playbacksock.h:132
PlaybackSock::setIP
void setIP(const QString &lip)
Definition: playbacksock.h:59
ReferenceCounter
General purpose reference counter.
Definition: referencecounter.h:27
PlaybackSock::GetMaxBitrate
long long GetMaxBitrate(int capturecardnum)
Definition: playbacksock.cpp:396
PlaybackSock::PixmapLastModified
QDateTime PixmapLastModified(const ProgramInfo *pginfo)
Definition: playbacksock.cpp:306