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 void customEvent(QEvent *event) override; // QObject
35
36 // Used to actually connect to an ZM server
37 bool connectToHost(const QString &hostname, unsigned int port);
38 bool connected(void) const { return m_bConnected; }
39
40 bool checkProtoVersion(void);
41
42 // If you want to be pleasant, call shutdown() before deleting your ZMClient
43 // device
44 void shutdown();
45
46 void getServerStatus(QString &status, QString &cpuStat, QString &diskStat);
47 void updateMonitorStatus(void);
48 void getEventList(const QString &monitorName, bool oldestFirst,
49 const QString &date, bool includeContinuous, std::vector<Event*> *eventList);
50 void getEventFrame(Event *event, int frameNo, MythImage **image);
51 void getAnalyseFrame(Event *event, int frameNo, QImage &image);
52 int getLiveFrame(int monitorID, QString &status, FrameData& buffer);
53 void getFrameList(int eventID, std::vector<Frame*> *frameList);
54 void deleteEvent(int eventID);
55 void deleteEventList(std::vector<Event*> *eventList);
56
57 int getMonitorCount(void);
58 Monitor* getMonitorAt(int pos);
59 Monitor* getMonitorByID(int monID);
60
61 void getCameraList(QStringList &cameraList);
62 void getEventDates(const QString &monitorName, bool oldestFirst,
63 QStringList &dateList);
64 void setMonitorFunction(int monitorID, const QString &function, bool enabled);
65 bool updateAlarmStates(void);
66
67 bool isMiniPlayerEnabled(void) const { return m_isMiniPlayerEnabled; }
68 void setIsMiniPlayerEnabled(bool enabled) { m_isMiniPlayerEnabled = enabled; }
69
70 void saveNotificationMonitors(void);
71 void showMiniPlayer(int monitorID) const;
72
73 private slots:
74 void restartConnection(void); // Try to re-establish the connection to
75 // ZMServer every 10 seconds
76 private:
77 void doGetMonitorList(void);
78 bool readData(unsigned char *data, int dataSize);
79 bool sendReceiveStringList(QStringList &strList);
80
81 QRecursiveMutex m_listLock;
82 QRecursiveMutex m_commandLock;
83 QList<Monitor*> m_monitorList;
84 QMap<int, Monitor*> m_monitorMap;
85
86 MythSocket *m_socket {nullptr};
87 QRecursiveMutex m_socketLock;
88 QString m_hostname {"localhost"};
89 uint m_port {6548};
90 bool m_bConnected {false};
91 QTimer *m_retryTimer {nullptr};
92 bool m_zmclientReady {false};
93 bool m_isMiniPlayerEnabled {true};
94};
95
96#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:67
QMap< int, Monitor * > m_monitorMap
Definition: zmclient.h:84
QRecursiveMutex m_listLock
Definition: zmclient.h:81
QList< Monitor * > m_monitorList
Definition: zmclient.h:83
QRecursiveMutex m_commandLock
Definition: zmclient.h:82
void setIsMiniPlayerEnabled(bool enabled)
Definition: zmclient.h:68
QRecursiveMutex m_socketLock
Definition: zmclient.h:87
static ZMClient * m_zmclient
Definition: zmclient.h:26
bool connected(void) const
Definition: zmclient.h:38
unsigned int uint
Definition: freesurround.h:24
static void showMiniPlayer(void)
Definition: mythmusic.cpp:439
#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