MythTV  master
playbacksock.h
Go to the documentation of this file.
1 #ifndef PLAYBACKSOCK_H_
2 #define PLAYBACKSOCK_H_
3 
4 #include <vector>
5 using namespace std;
6 
7 #include <QStringList>
8 #include <QDateTime>
9 #include <QMutex>
10 #include <QSize>
11 
12 #include "referencecounter.h"
13 #include "programinfo.h" // ProgramInfo
14 #include "programtypes.h" // RecStatus::Type
15 #include "inputinfo.h"
16 
17 class MythSocket;
18 class MainServer;
19 class ProgramInfo;
20 
21 typedef enum {
27 
29 {
30  public:
31  PlaybackSock(MainServer *parent, MythSocket *lsock,
32  QString lhostname, PlaybackSockEventsMode eventsMode);
33 
34  void SetDisconnected(void) { m_disconnected = true; }
35  bool IsDisconnected(void) const { return m_disconnected; }
36 
37  MythSocket *getSocket(void) const { return m_sock; }
38  QString getHostname(void) const { return m_hostname; }
39 
40  bool isLocal(void) const { return m_local; }
41  bool wantsEvents(void) const;
42  bool wantsNonSystemEvents(void) const;
43  bool wantsSystemEvents(void) const;
44  bool wantsOnlySystemEvents(void) const;
45  PlaybackSockEventsMode eventsMode(void) const;
46 
47  bool getBlockShutdown(void) const { return m_blockshutdown; }
48  void setBlockShutdown(bool value) { m_blockshutdown = value; }
49 
50  bool IsFrontend(void) const { return m_frontend; }
51  void SetAsFrontend(void) { m_frontend = true; }
52 
53  // all backend<->backend stuff below here
54  bool isSlaveBackend(void) const { return m_backend; }
55  void setAsSlaveBackend(void) { m_backend = true; m_mediaserver = true; }
56 
57  bool isMediaServer(void) const { return m_mediaserver; }
58  void setAsMediaServer(void) { m_mediaserver = true; }
59 
60  void setIP(QString &lip) { m_ip = lip; }
61  QString getIP(void) const { return m_ip; }
62 
63  bool GoToSleep(void);
64  void GetDiskSpace(QStringList &o_strlist);
65  int DeleteFile(const QString &filename, const QString &sgroup);
66  int StopRecording(const ProgramInfo *pginfo);
67  int CheckRecordingActive(const ProgramInfo *pginfo);
68  int DeleteRecording(const ProgramInfo *pginfo, bool forceMetadataDelete = false);
69  bool FillProgramInfo(ProgramInfo &pginfo, const QString &playbackhost);
70  QStringList GetSGFileList(QString &host, QString &groupname,
71  QString &directory, bool fileNamesOnly);
72  QStringList GetSGFileQuery(QString &host, QString &groupname,
73  QString &filename);
74  QString GetFileHash(const QString& filename, const QString& storageGroup);
75  QStringList GetFindFile(const QString &host, const QString &filename,
76  const QString &storageGroup, bool useRegex);
77 
78  QStringList GenPreviewPixmap(const QString &token,
79  const ProgramInfo *pginfo);
80  QStringList GenPreviewPixmap(const QString &token,
81  const ProgramInfo *pginfo,
82  bool time_fmt_sec,
83  long long time,
84  const QString &outputFile,
85  const QSize &outputSize);
86  QDateTime PixmapLastModified(const ProgramInfo *pginfo);
87  bool CheckFile(ProgramInfo *pginfo);
88 
89  bool IsBusy(int capturecardnum,
90  InputInfo *busy_input = nullptr,
91  int time_buffer = 5);
92  int GetEncoderState(int capturecardnum);
93  long long GetMaxBitrate(int capturecardnum);
94  ProgramInfo *GetRecording(uint cardid);
95  bool EncoderIsRecording(int capturecardnum, const ProgramInfo *pginfo);
96  RecStatus::Type StartRecording(int capturecardnum,
97  ProgramInfo *pginfo);
98  RecStatus::Type GetRecordingStatus(int capturecardnum);
99  void RecordPending(int capturecardnum, const ProgramInfo *pginfo,
100  int secsleft, bool hasLater);
101  int SetSignalMonitoringRate(int capturecardnum, int rate, int notifyFrontend);
102  void SetNextLiveTVDir(int capturecardnum, const QString& dir);
103  void CancelNextRecording(int capturecardnum, bool cancel);
104 
105  QStringList ForwardRequest(const QStringList&);
106 
107  bool ReadStringList(QStringList &list);
108 
109  bool AddChildInput(uint childid);
110 
111  // Enforce reference counting
112  protected:
113  virtual ~PlaybackSock();
114 
115  private:
116  bool SendReceiveStringList(QStringList &strlist, uint min_reply_length = 0);
117 
118  MythSocket *m_sock {nullptr};
119  QString m_hostname;
120  QString m_ip;
121 
122  bool m_local {true};
124  bool m_blockshutdown {true};
125  bool m_backend {false};
126  bool m_mediaserver {false};
127  bool m_frontend {false};
128 
129  QMutex m_sockLock;
130 
131  bool m_disconnected {false};
132 
133  MainServer *m_parent {nullptr};
134 };
135 
136 #endif
137 
138 /* vim: set expandtab tabstop=4 shiftwidth=4: */
QString getIP(void) const
Definition: playbacksock.h:61
void setAsSlaveBackend(void)
Definition: playbacksock.h:55
bool IsDisconnected(void) const
Definition: playbacksock.h:35
void FillProgramInfo(DTC::Program *pProgram, ProgramInfo *pInfo, bool bIncChannel, bool bDetails, bool bIncCast)
Definition: serviceUtil.cpp:44
QString getHostname(void) const
Definition: playbacksock.h:38
General purpose reference counter.
void setIP(QString &lip)
Definition: playbacksock.h:60
void setAsMediaServer(void)
Definition: playbacksock.h:58
QString m_ip
Definition: playbacksock.h:120
unsigned int uint
Definition: compat.h:140
PlaybackSockEventsMode m_eventsMode
Definition: playbacksock.h:123
bool IsFrontend(void) const
Definition: playbacksock.h:50
PlaybackSockEventsMode
Definition: playbacksock.h:21
QString m_hostname
Definition: playbacksock.h:119
Holds information on recordings and videos.
Definition: programinfo.h:66
void SetDisconnected(void)
Definition: playbacksock.h:34
bool getBlockShutdown(void) const
Definition: playbacksock.h:47
MythSocket * getSocket(void) const
Definition: playbacksock.h:37
bool isSlaveBackend(void) const
Definition: playbacksock.h:54
void setBlockShutdown(bool value)
Definition: playbacksock.h:48
void SetAsFrontend(void)
Definition: playbacksock.h:51
bool isLocal(void) const
Definition: playbacksock.h:40
QMutex m_sockLock
Definition: playbacksock.h:129
Class for communcating between myth backends and frontends.
Definition: mythsocket.h:26
bool isMediaServer(void) const
Definition: playbacksock.h:57