MythTV master
zmclient.h
Go to the documentation of this file.
1#ifndef ZMCLIENT_H_
2#define ZMCLIENT_H_
3
4// C++
5#include <array>
6#include <iostream>
7#include <vector>
8
9// MythTV
12#include <libmythui/mythimage.h>
13
14// zm
15#include "zmdefines.h"
16static constexpr size_t MAX_IMAGE_SIZE { 2048ULL * 1536 * 3 };
17using FrameData = std::array<uint8_t,MAX_IMAGE_SIZE>;
18
19class MPLUGIN_PUBLIC ZMClient : public QObject
20{
21 Q_OBJECT
22
23 protected:
24 ZMClient();
25
27
28 public:
29 ~ZMClient() override;
30
31 static ZMClient *get(void);
32 static bool setupZMClient (void);
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 protected:
72 void customEvent(QEvent *event) override; // QObject
73
74 private slots:
75 void restartConnection(void); // Try to re-establish the connection to
76 // ZMServer every 10 seconds
77 private:
78 void doGetMonitorList(void);
79 bool readData(unsigned char *data, int dataSize);
80 bool sendReceiveStringList(QStringList &strList);
81
82 QRecursiveMutex m_listLock;
83 QRecursiveMutex m_commandLock;
84 QList<Monitor*> m_monitorList;
85 QMap<int, Monitor*> m_monitorMap;
86
87 MythSocket *m_socket {nullptr};
88 QRecursiveMutex m_socketLock;
89 QString m_hostname {"localhost"};
90 uint m_port {6548};
91 bool m_bConnected {false};
92 QTimer *m_retryTimer {nullptr};
93 bool m_zmclientReady {false};
94 bool m_isMiniPlayerEnabled {true};
95};
96
97#endif
Event details.
Definition: zmdefines.h:28
Class for communcating between myth backends and frontends.
Definition: mythsocket.h:26
bool isMiniPlayerEnabled(void) const
Definition: zmclient.h:65
QMap< int, Monitor * > m_monitorMap
Definition: zmclient.h:85
QRecursiveMutex m_listLock
Definition: zmclient.h:82
QList< Monitor * > m_monitorList
Definition: zmclient.h:84
QRecursiveMutex m_commandLock
Definition: zmclient.h:83
void setIsMiniPlayerEnabled(bool enabled)
Definition: zmclient.h:66
QRecursiveMutex m_socketLock
Definition: zmclient.h:88
static ZMClient * m_zmclient
Definition: zmclient.h:26
bool connected(void) const
Definition: zmclient.h:36
unsigned int uint
Definition: compat.h:60
static void showMiniPlayer(void)
Definition: mythmusic.cpp:451
#define MPLUGIN_PUBLIC
static int shutdown()
bool readData(const QString &filename, float *mean, unsigned char *median, float *stddev, int *frow, int *fcol, int *fwidth, int *fheight, HistogramAnalyzer::Histogram *histogram, unsigned char *monochromatic, long long nframes)
string hostname
Definition: caa.py:17
static QKeyEvent deleteEvent(QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier,"DELETE"))
static constexpr size_t MAX_IMAGE_SIZE
Definition: zmclient.h:16
std::array< uint8_t, MAX_IMAGE_SIZE > FrameData
Definition: zmserver.h:33