ProtoBuffer, UDPListener ...

Protocol Buffer reimplemented to receive image data from third-party apps
The status of the component "UDPListener" is now displayed correctly in WebUI
Global signal names for WebUI added
This commit is contained in:
Paulchen-Panther
2019-02-17 15:26:11 +01:00
parent 777caafb24
commit 7ff9d7037b
38 changed files with 990 additions and 64 deletions

View File

@@ -41,13 +41,13 @@ private slots:
/// @brief forward system image
/// @param image The image
///
void handleSystemImage(const Image<ColorRgb>& image);
void handleSystemImage(const QString& name, const Image<ColorRgb>& image);
///
/// @brief forward v4l image
/// @param image The image
///
void handleV4lImage(const Image<ColorRgb> & image);
void handleV4lImage(const QString& name, const Image<ColorRgb> & image);
///
/// @brief Is called from _v4lInactiveTimer to set source after specific time to inactive
@@ -66,10 +66,12 @@ private:
/// Reflect state of System capture and prio
bool _systemCaptEnabled;
quint8 _systemCaptPrio;
QString _systemCaptName;
QTimer* _systemInactiveTimer;
/// Reflect state of v4l capture and prio
bool _v4lCaptEnabled;
quint8 _v4lCaptPrio;
QString _v4lCaptName;
QTimer* _v4lInactiveTimer;
};

View File

@@ -54,7 +54,7 @@ public:
int ret = grabber.grabFrame(_image);
if (ret >= 0)
{
emit systemImage(_image);
emit systemImage(_grabberName, _image);
return true;
}
return false;
@@ -92,7 +92,7 @@ signals:
///
/// @brief Emit the final processed image
///
void systemImage(const Image<ColorRgb>& image);
void systemImage(const QString& name, const Image<ColorRgb>& image);
protected:

View File

@@ -411,7 +411,7 @@ signals:
void forwardJsonMessage(QJsonObject);
/// Signal which is emitted, when a new proto image should be forwarded
void forwardProtoMessage(Image<ColorRgb>);
void forwardProtoMessage(const QString, const Image<ColorRgb>);
///
/// @brief Is emitted from clients who request a videoMode change

View File

@@ -70,7 +70,7 @@ private slots:
/// @brief Forward image to all proto slaves
/// @param image The PROTO image to send
///
void forwardProtoMessage(const Image<ColorRgb> &image);
void forwardProtoMessage(const QString& name, const Image<ColorRgb> &image);
///
/// @brief Forward message to a single json slave

View File

@@ -0,0 +1,67 @@
#pragma once
// util
#include <utils/Logger.h>
#include <utils/settings.h>
// qt
#include <QVector>
class QTcpServer;
class ProtoClientConnection;
///
/// @brief This class creates a TCP server which accepts connections wich can then send
/// in Protocol Buffer encoded commands. This interface to Hyperion is used by various
/// third-party applications
///
class ProtoServer : public QObject
{
Q_OBJECT
public:
ProtoServer(const QJsonDocument& config, QObject* parent = nullptr);
~ProtoServer();
public slots:
///
/// @brief Handle settings update
/// @param type The type from enum
/// @param config The configuration
///
void handleSettingsUpdate(const settings::type& type, const QJsonDocument& config);
void initServer();
private slots:
///
/// @brief Is called whenever a new socket wants to connect
///
void newConnection();
///
/// @brief is called whenever a client disconnected
///
void clientDisconnected();
private:
///
/// @brief Start the server with current _port
///
void startServer();
///
/// @brief Stop server
///
void stopServer();
private:
QTcpServer* _server;
Logger* _log;
int _timeout;
quint16 _port;
const QJsonDocument _config;
QVector<ProtoClientConnection*> _openConnections;
};

View File

@@ -84,7 +84,6 @@ private slots:
void processTheDatagram(const QByteArray * datagram, const QHostAddress * sender);
private:
/// The UDP server object
QUdpSocket * _server;

View File

@@ -22,7 +22,8 @@ enum Components
COMP_IMAGE,
COMP_EFFECT,
COMP_LEDDEVICE,
COMP_FLATBUFSERVER
COMP_FLATBUFSERVER,
COMP_PROTOSERVER
};
inline const char* componentToString(Components c)
@@ -41,7 +42,8 @@ inline const char* componentToString(Components c)
case COMP_EFFECT: return "Effect";
case COMP_IMAGE: return "Image";
case COMP_LEDDEVICE: return "LED device";
case COMP_FLATBUFSERVER: return "Image Receiver";
case COMP_FLATBUFSERVER: return "Image Receiver";
case COMP_PROTOSERVER: return "Proto Server";
default: return "";
}
}
@@ -63,6 +65,7 @@ inline const char* componentToIdString(Components c)
case COMP_IMAGE: return "IMAGE";
case COMP_LEDDEVICE: return "LEDDEVICE";
case COMP_FLATBUFSERVER: return "FLATBUFSERVER";
case COMP_PROTOSERVER: return "PROTOSERVER";
default: return "";
}
}
@@ -83,6 +86,7 @@ inline Components stringToComponent(QString component)
if (component == "IMAGE") return COMP_IMAGE;
if (component == "LEDDEVICE") return COMP_LEDDEVICE;
if (component == "FLATBUFSERVER") return COMP_FLATBUFSERVER;
if (component == "PROTOSERVER") return COMP_PROTOSERVER;
return COMP_INVALID;
}

View File

@@ -29,13 +29,15 @@ public:
signals:
///
/// @brief PIPE SystemCapture images from GrabberWrapper to Hyperion class
/// @param name The name of the platform capture that is currently active
/// @param image The prepared image
///
void setSystemImage(const Image<ColorRgb>& image);
void setSystemImage(const QString& name, const Image<ColorRgb>& image);
///
/// @brief PIPE v4lCapture images from v4lCapture over HyperionDaemon to Hyperion class
/// @param name The name of the v4l capture (path) that is currently active
/// @param image The prepared image
///
void setV4lImage(const Image<ColorRgb> & image);
void setV4lImage(const QString& name, const Image<ColorRgb> & image);
};

View File

@@ -29,6 +29,7 @@ enum type {
INSTCAPTURE,
NETWORK,
FLATBUFSERVER,
PROTOSERVER,
INVALID
};
@@ -62,6 +63,7 @@ inline QString typeToString(const type& type)
case INSTCAPTURE: return "instCapture";
case NETWORK: return "network";
case FLATBUFSERVER: return "flatbufServer";
case PROTOSERVER: return "protoServer";
default: return "invalid";
}
}
@@ -73,7 +75,7 @@ inline QString typeToString(const type& type)
///
inline type stringToType(const QString& type)
{
if (type == "backgroundEffect") return BGEFFECT;
if (type == "backgroundEffect") return BGEFFECT;
else if (type == "foregroundEffect") return FGEFFECT;
else if (type == "blackborderdetector") return BLACKBORDER;
else if (type == "boblightServer") return BOBLSERVER;
@@ -94,6 +96,7 @@ inline type stringToType(const QString& type)
else if (type == "instCapture") return INSTCAPTURE;
else if (type == "network") return NETWORK;
else if (type == "flatbufServer") return FLATBUFSERVER;
else return INVALID;
else if (type == "protoServer") return PROTOSERVER;
else return INVALID;
}
};