MythTV  master
zmclient.h
Go to the documentation of this file.
1 #ifndef ZMCLIENT_H_
2 #define ZMCLIENT_H_
3 
4 #include <iostream>
5 #include <vector>
6 
7 // myth
8 #include <mythsocket.h>
9 #include <mythexp.h>
10 #include <mythimage.h>
11 
12 // zm
13 #include "zmdefines.h"
14 #define MAX_IMAGE_SIZE (2048*1536*3)
15 using FrameData = std::array<uint8_t,MAX_IMAGE_SIZE>;
16 
17 class MPUBLIC ZMClient : public QObject
18 {
19  Q_OBJECT
20 
21  protected:
22  ZMClient();
23 
25 
26  public:
27  ~ZMClient() override;
28 
29  static ZMClient *get(void);
30  static bool setupZMClient (void);
31 
32  void customEvent(QEvent *event) override; // QObject
33 
34  // Used to actually connect to an ZM server
35  bool connectToHost(const QString &hostname, unsigned int port);
36  bool connected(void) const { return m_bConnected; }
37 
38  bool checkProtoVersion(void);
39 
40  // If you want to be pleasant, call shutdown() before deleting your ZMClient
41  // device
42  void shutdown();
43 
44  void getServerStatus(QString &status, QString &cpuStat, QString &diskStat);
45  void updateMonitorStatus(void);
46  void getEventList(const QString &monitorName, bool oldestFirst,
47  const QString &date, bool includeContinuous, std::vector<Event*> *eventList);
48  void getEventFrame(Event *event, int frameNo, MythImage **image);
49  void getAnalyseFrame(Event *event, int frameNo, QImage &image);
50  int getLiveFrame(int monitorID, QString &status, FrameData& buffer);
51  void getFrameList(int eventID, std::vector<Frame*> *frameList);
52  void deleteEvent(int eventID);
53  void deleteEventList(std::vector<Event*> *eventList);
54 
55  int getMonitorCount(void);
56  Monitor* getMonitorAt(int pos);
57  Monitor* getMonitorByID(int monID);
58 
59  void getCameraList(QStringList &cameraList);
60  void getEventDates(const QString &monitorName, bool oldestFirst,
61  QStringList &dateList);
62  void setMonitorFunction(int monitorID, const QString &function, bool enabled);
63  bool updateAlarmStates(void);
64 
65  bool isMiniPlayerEnabled(void) const { return m_isMiniPlayerEnabled; }
66  void setIsMiniPlayerEnabled(bool enabled) { m_isMiniPlayerEnabled = enabled; }
67 
68  void saveNotificationMonitors(void);
69  void showMiniPlayer(int monitorID) const;
70 
71  private slots:
72  void restartConnection(void); // Try to re-establish the connection to
73  // ZMServer every 10 seconds
74  private:
75  void doGetMonitorList(void);
76  bool readData(unsigned char *data, int dataSize);
77  bool sendReceiveStringList(QStringList &strList);
78 
79  QMutex m_listLock {QMutex::Recursive};
80  QMutex m_commandLock {QMutex::Recursive};
81  QList<Monitor*> m_monitorList;
82  QMap<int, Monitor*> m_monitorMap;
83 
84  MythSocket *m_socket {nullptr};
85  QMutex m_socketLock {QMutex::Recursive};
86  QString m_hostname {"localhost"};
87  uint m_port {6548};
88  bool m_bConnected {false};
89  QTimer *m_retryTimer {nullptr};
90  bool m_zmclientReady {false};
91  bool m_isMiniPlayerEnabled {true};
92 };
93 
94 #endif
MPUBLIC
#define MPUBLIC
Definition: mythexp.h:10
ZMClient::connected
bool connected(void) const
Definition: zmclient.h:36
ZMClient::m_monitorList
QList< Monitor * > m_monitorList
Definition: zmclient.h:81
zmdefines.h
mythexp.h
ZMClient::isMiniPlayerEnabled
bool isMiniPlayerEnabled(void) const
Definition: zmclient.h:65
MythSocket
Class for communcating between myth backends and frontends.
Definition: mythsocket.h:27
Event
Event details.
Definition: zmdefines.h:27
uint
unsigned int uint
Definition: compat.h:141
shutdown
static int shutdown()
Definition: mythtv/programs/mythshutdown/main.cpp:454
deleteEvent
static QKeyEvent deleteEvent(QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier,"DELETE"))
mythimage.h
ZMClient::m_zmclient
static ZMClient * m_zmclient
Definition: zmclient.h:24
MythImage
Definition: mythimage.h:37
ZMClient::setIsMiniPlayerEnabled
void setIsMiniPlayerEnabled(bool enabled)
Definition: zmclient.h:66
hardwareprofile.distros.all.get
def get()
Definition: all.py:22
ZMClient::m_monitorMap
QMap< int, Monitor * > m_monitorMap
Definition: zmclient.h:82
FrameData
std::array< uint8_t, MAX_IMAGE_SIZE > FrameData
Definition: zmserver.h:29
Monitor
Definition: zmdefines.h:100
musicbrainzngs.caa.hostname
string hostname
Definition: caa.py:17
showMiniPlayer
static void showMiniPlayer(void)
Definition: mythplugins/mythmusic/mythmusic/main.cpp:437
mythsocket.h
ZMClient
Definition: zmclient.h:18