mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
even more changes
Signed-off-by: Paulchen-Panther <Paulchen--Panter@gmx.net>
This commit is contained in:
254
include/api/JsonAPI.h
Normal file
254
include/api/JsonAPI.h
Normal file
@@ -0,0 +1,254 @@
|
||||
#pragma once
|
||||
|
||||
// hyperion includes
|
||||
#include <utils/Logger.h>
|
||||
#include <utils/jsonschema/QJsonSchemaChecker.h>
|
||||
#include <utils/Components.h>
|
||||
#include <hyperion/Hyperion.h>
|
||||
|
||||
// qt includess
|
||||
#include <QTimer>
|
||||
#include <QJsonObject>
|
||||
#include <QMutex>
|
||||
#include <QString>
|
||||
|
||||
// createEffect helper
|
||||
struct find_schema: std::unary_function<EffectSchema, bool>
|
||||
{
|
||||
QString pyFile;
|
||||
find_schema(QString pyFile):pyFile(pyFile) { }
|
||||
bool operator()(EffectSchema const& schema) const
|
||||
{
|
||||
return schema.pyFile == pyFile;
|
||||
}
|
||||
};
|
||||
|
||||
// deleteEffect helper
|
||||
struct find_effect: std::unary_function<EffectDefinition, bool>
|
||||
{
|
||||
QString effectName;
|
||||
find_effect(QString effectName) :effectName(effectName) { }
|
||||
bool operator()(EffectDefinition const& effectDefinition) const
|
||||
{
|
||||
return effectDefinition.name == effectName;
|
||||
}
|
||||
};
|
||||
|
||||
class JsonCB;
|
||||
|
||||
class JsonAPI : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
/// @param peerAddress provide the Address of the peer
|
||||
/// @param log The Logger class of the creator
|
||||
/// @param parent Parent QObject
|
||||
/// @param noListener if true, this instance won't listen for hyperion push events
|
||||
///
|
||||
JsonAPI(QString peerAddress, Logger* log, QObject* parent, bool noListener = false);
|
||||
|
||||
///
|
||||
/// Handle an incoming JSON message
|
||||
///
|
||||
/// @param message the incoming message as string
|
||||
///
|
||||
void handleMessage(const QString & message, const QString& httpAuthHeader = "");
|
||||
|
||||
public slots:
|
||||
/// _timer_ledcolors requests ledcolor updates (if enabled)
|
||||
void streamLedcolorsUpdate();
|
||||
|
||||
/// push images whenever hyperion emits (if enabled)
|
||||
void setImage(const Image<ColorRgb> & image);
|
||||
|
||||
/// process and push new log messages from logger (if enabled)
|
||||
void incommingLogMessage(Logger::T_LOG_MESSAGE);
|
||||
|
||||
signals:
|
||||
///
|
||||
/// Signal emits with the reply message provided with handleMessage()
|
||||
///
|
||||
void callbackMessage(QJsonObject);
|
||||
|
||||
///
|
||||
/// Signal emits whenever a jsonmessage should be forwarded
|
||||
///
|
||||
void forwardJsonMessage(QJsonObject);
|
||||
|
||||
private:
|
||||
|
||||
// The JsonCB instance which handles data subscription/notifications
|
||||
JsonCB* _jsonCB;
|
||||
// true if further callbacks are forbidden (http)
|
||||
bool _noListener;
|
||||
/// The peer address of the client
|
||||
QString _peerAddress;
|
||||
|
||||
/// Log instance
|
||||
Logger* _log;
|
||||
|
||||
/// Hyperion instance
|
||||
Hyperion* _hyperion;
|
||||
|
||||
/// timer for ledcolors streaming
|
||||
QTimer _timer_ledcolors;
|
||||
|
||||
// streaming buffers
|
||||
QJsonObject _streaming_leds_reply;
|
||||
QJsonObject _streaming_image_reply;
|
||||
QJsonObject _streaming_logging_reply;
|
||||
|
||||
/// flag to determine state of log streaming
|
||||
bool _streaming_logging_activated;
|
||||
|
||||
/// mutex to determine state of image streaming
|
||||
QMutex _image_stream_mutex;
|
||||
|
||||
/// timeout for live video refresh
|
||||
volatile qint64 _image_stream_timeout;
|
||||
|
||||
///
|
||||
/// Handle an incoming JSON Color message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleColorCommand(const QJsonObject & message, const QString &command, const int tan);
|
||||
|
||||
///
|
||||
/// Handle an incoming JSON Image message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleImageCommand(const QJsonObject & message, const QString &command, const int tan);
|
||||
|
||||
///
|
||||
/// Handle an incoming JSON Effect message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleEffectCommand(const QJsonObject & message, const QString &command, const int tan);
|
||||
|
||||
///
|
||||
/// Handle an incoming JSON Effect message (Write JSON Effect)
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleCreateEffectCommand(const QJsonObject & message, const QString &command, const int tan);
|
||||
|
||||
///
|
||||
/// Handle an incoming JSON Effect message (Delete JSON Effect)
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleDeleteEffectCommand(const QJsonObject & message, const QString &command, const int tan);
|
||||
|
||||
///
|
||||
/// Handle an incoming JSON System info message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleSysInfoCommand(const QJsonObject & message, const QString &command, const int tan);
|
||||
|
||||
///
|
||||
/// Handle an incoming JSON Server info message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleServerInfoCommand(const QJsonObject & message, const QString &command, const int tan);
|
||||
|
||||
///
|
||||
/// Handle an incoming JSON Clear message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleClearCommand(const QJsonObject & message, const QString &command, const int tan);
|
||||
|
||||
///
|
||||
/// Handle an incoming JSON Adjustment message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleAdjustmentCommand(const QJsonObject & message, const QString &command, const int tan);
|
||||
|
||||
///
|
||||
/// Handle an incoming JSON SourceSelect message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleSourceSelectCommand(const QJsonObject & message, const QString &command, const int tan);
|
||||
|
||||
/// Handle an incoming JSON GetConfig message and check subcommand
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleConfigCommand(const QJsonObject & message, const QString &command, const int tan);
|
||||
|
||||
/// Handle an incoming JSON GetConfig message from handleConfigCommand()
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleSchemaGetCommand(const QJsonObject & message, const QString &command, const int tan);
|
||||
|
||||
/// Handle an incoming JSON SetConfig message from handleConfigCommand()
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleConfigSetCommand(const QJsonObject & message, const QString &command, const int tan);
|
||||
|
||||
///
|
||||
/// Handle an incoming JSON Component State message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleComponentStateCommand(const QJsonObject & message, const QString &command, const int tan);
|
||||
|
||||
/// Handle an incoming JSON Led Colors message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleLedColorsCommand(const QJsonObject & message, const QString &command, const int tan);
|
||||
|
||||
/// Handle an incoming JSON Logging message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleLoggingCommand(const QJsonObject & message, const QString &command, const int tan);
|
||||
|
||||
/// Handle an incoming JSON Proccessing message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleProcessingCommand(const QJsonObject & message, const QString &command, const int tan);
|
||||
|
||||
/// Handle an incoming JSON VideoMode message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleVideoModeCommand(const QJsonObject & message, const QString &command, const int tan);
|
||||
|
||||
///
|
||||
/// Handle an incoming JSON message of unknown type
|
||||
///
|
||||
void handleNotImplemented();
|
||||
|
||||
///
|
||||
/// Send a standard reply indicating success
|
||||
///
|
||||
void sendSuccessReply(const QString &command="", const int tan=0);
|
||||
|
||||
///
|
||||
/// Send a standard reply indicating success with data
|
||||
///
|
||||
void sendSuccessDataReply(const QJsonDocument &doc, const QString &command="", const int &tan=0);
|
||||
|
||||
///
|
||||
/// Send an error message back to the client
|
||||
///
|
||||
/// @param error String describing the error
|
||||
///
|
||||
void sendErrorReply(const QString & error, const QString &command="", const int tan=0);
|
||||
};
|
112
include/api/JsonCB.h
Normal file
112
include/api/JsonCB.h
Normal file
@@ -0,0 +1,112 @@
|
||||
#pragma once
|
||||
|
||||
// qt incl
|
||||
#include <QObject>
|
||||
#include <QJsonObject>
|
||||
|
||||
// components def
|
||||
#include <utils/Components.h>
|
||||
// bonjour
|
||||
#include <bonjour/bonjourrecord.h>
|
||||
// videModes
|
||||
#include <utils/VideoMode.h>
|
||||
// settings
|
||||
#include <utils/settings.h>
|
||||
|
||||
class Hyperion;
|
||||
class ComponentRegister;
|
||||
class BonjourBrowserWrapper;
|
||||
class PriorityMuxer;
|
||||
|
||||
class JsonCB : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
JsonCB(QObject* parent);
|
||||
|
||||
///
|
||||
/// @brief Subscribe to future data updates given by cmd
|
||||
/// @param cmd The cmd which will be subscribed for
|
||||
/// @return True on success, false if not found
|
||||
///
|
||||
bool subscribeFor(const QString& cmd);
|
||||
|
||||
///
|
||||
/// @brief Get all possible commands to subscribe for
|
||||
/// @return The list of commands
|
||||
///
|
||||
QStringList getCommands() { return _availableCommands; };
|
||||
///
|
||||
/// @brief Get all subscribed commands
|
||||
/// @return The list of commands
|
||||
///
|
||||
QStringList getSubscribedCommands() { return _subscribedCommands; };
|
||||
signals:
|
||||
///
|
||||
/// @brief Emits whenever a new json mesage callback is ready to send
|
||||
/// @param The JsonObject message
|
||||
///
|
||||
void newCallback(QJsonObject);
|
||||
|
||||
private slots:
|
||||
///
|
||||
/// @brief handle component state changes
|
||||
///
|
||||
void handleComponentState(const hyperion::Components comp, const bool state);
|
||||
|
||||
///
|
||||
/// @brief handle emits from bonjour wrapper
|
||||
/// @param bRegisters The full register map
|
||||
///
|
||||
void handleBonjourChange(const QMap<QString,BonjourRecord>& bRegisters);
|
||||
|
||||
///
|
||||
/// @brief handle emits from PriorityMuxer
|
||||
///
|
||||
void handlePriorityUpdate();
|
||||
|
||||
///
|
||||
/// @brief Handle imageToLedsMapping updates
|
||||
///
|
||||
void handleImageToLedsMappingChange(const int& mappingType);
|
||||
|
||||
///
|
||||
/// @brief Handle the adjustment update
|
||||
///
|
||||
void handleAdjustmentChange();
|
||||
|
||||
///
|
||||
/// @brief Handle video mode change
|
||||
/// @param mode The new videoMode
|
||||
///
|
||||
void handleVideoModeChange(const VideoMode& mode);
|
||||
|
||||
///
|
||||
/// @brief Handle effect list change
|
||||
///
|
||||
void handleEffectListChange();
|
||||
|
||||
///
|
||||
/// @brief Handle a config part change. This does NOT include (global) changes from other hyperion instances
|
||||
/// @param type The settings type from enum
|
||||
/// @param data The data as QJsonDocument
|
||||
///
|
||||
void handleSettingsChange(const settings::type& type, const QJsonDocument& data);
|
||||
|
||||
private:
|
||||
/// pointer of Hyperion instance
|
||||
Hyperion* _hyperion;
|
||||
/// pointer of comp register
|
||||
ComponentRegister* _componentRegister;
|
||||
/// Bonjour instance
|
||||
BonjourBrowserWrapper* _bonjour;
|
||||
/// priority muxer instance
|
||||
PriorityMuxer* _prioMuxer;
|
||||
/// contains all available commands
|
||||
QStringList _availableCommands;
|
||||
/// contains active subscriptions
|
||||
QStringList _subscribedCommands;
|
||||
/// construct callback msg
|
||||
void doCallback(const QString& cmd, const QVariant& data);
|
||||
};
|
@@ -31,7 +31,7 @@ public:
|
||||
/// @param hyperion Hyperion instance
|
||||
/// @param port port number on which to start listening for connections
|
||||
///
|
||||
BoblightServer(const QJsonDocument& config);
|
||||
BoblightServer(Hyperion* hyperion, const QJsonDocument& config);
|
||||
~BoblightServer();
|
||||
|
||||
///
|
||||
|
@@ -47,6 +47,8 @@ public:
|
||||
void registerService(const BonjourRecord &record, quint16 servicePort, std::vector<std::pair<std::string, std::string>> txt = std::vector<std::pair<std::string, std::string>>());
|
||||
inline BonjourRecord registeredRecord() const {return finalRecord; }
|
||||
|
||||
const quint16 & getPort() { return _port; };
|
||||
|
||||
signals:
|
||||
void error(DNSServiceErrorType error);
|
||||
void serviceRegistered(const BonjourRecord &record);
|
||||
@@ -62,6 +64,9 @@ private:
|
||||
DNSServiceRef dnssref;
|
||||
QSocketNotifier *bonjourSocket;
|
||||
BonjourRecord finalRecord;
|
||||
|
||||
// current port
|
||||
quint16 _port = 0;
|
||||
};
|
||||
|
||||
#endif // BONJOURSERVICEREGISTER_H
|
||||
|
@@ -19,7 +19,7 @@
|
||||
#include "hyperion_request_generated.h"
|
||||
|
||||
///
|
||||
/// Connection class to setup an connection to the hyperion server and execute commands. Used from standalone capture binaries (x11/dispamnx/...)
|
||||
/// Connection class to setup an connection to the hyperion server and execute commands.
|
||||
///
|
||||
class FlatBufferConnection : public QObject
|
||||
{
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
~FlatBufferConnection();
|
||||
|
||||
/// Do not read reply messages from Hyperion if set to true
|
||||
void setSkipReply(bool skip);
|
||||
void setSkipReply(const bool& skip);
|
||||
|
||||
///
|
||||
/// Set all leds to the specified color
|
||||
@@ -116,8 +116,8 @@ private:
|
||||
/// Host port
|
||||
uint16_t _port;
|
||||
|
||||
/// Skip receiving reply messages from Hyperion if set
|
||||
bool _skipReply;
|
||||
/// buffer for reply
|
||||
QByteArray _receiveBuffer;
|
||||
|
||||
QTimer _timer;
|
||||
QAbstractSocket::SocketState _prevSocketState;
|
||||
|
@@ -9,7 +9,6 @@
|
||||
|
||||
class QTcpServer;
|
||||
class FlatBufferClient;
|
||||
class NetOrigin;
|
||||
|
||||
///
|
||||
/// @brief A TcpServer to receive images of different formats with Google Flatbuffer
|
||||
@@ -57,7 +56,6 @@ private:
|
||||
|
||||
private:
|
||||
QTcpServer* _server;
|
||||
NetOrigin* _netOrigin;
|
||||
Logger* _log;
|
||||
int _timeout;
|
||||
quint16 _port;
|
||||
|
@@ -42,7 +42,7 @@ public:
|
||||
|
||||
///
|
||||
///@brief Set new width and height for dispmanx, overwrite Grabber.h impl
|
||||
virtual void setWidthHeight(int width, int height);
|
||||
virtual bool setWidthHeight(int width, int height);
|
||||
|
||||
private:
|
||||
///
|
||||
|
@@ -14,6 +14,8 @@
|
||||
#include <hyperion/Grabber.h>
|
||||
#include <grabber/VideoStandard.h>
|
||||
|
||||
class QTimer;
|
||||
|
||||
/// Capture class for V4L2 devices
|
||||
///
|
||||
/// @see http://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html
|
||||
@@ -23,7 +25,6 @@ class V4L2Grabber : public Grabber
|
||||
|
||||
public:
|
||||
V4L2Grabber(const QString & device,
|
||||
int input,
|
||||
VideoStandard videoStandard,
|
||||
PixelFormat pixelFormat,
|
||||
int pixelDecimation
|
||||
@@ -71,7 +72,7 @@ public:
|
||||
///
|
||||
/// @brief overwrite Grabber.h implementation
|
||||
///
|
||||
virtual void setInputVideoStandard(int input, VideoStandard videoStandard);
|
||||
virtual void setDeviceVideoStandard(QString device, VideoStandard videoStandard);
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -86,6 +87,11 @@ signals:
|
||||
private slots:
|
||||
int read_frame();
|
||||
|
||||
///
|
||||
/// @brief Is called whenever the _readFrameAdaptTimer emits to unlock read_frame() through _readFrame bool
|
||||
///
|
||||
void unlockReadFrame() { _readFrame = true; };
|
||||
|
||||
private:
|
||||
void getV4Ldevices();
|
||||
|
||||
@@ -161,4 +167,6 @@ private:
|
||||
|
||||
bool _initialized;
|
||||
bool _deviceAutoDiscoverEnabled;
|
||||
QTimer* _readFrameAdaptTimer;
|
||||
bool _readFrame = false;
|
||||
};
|
||||
|
@@ -9,7 +9,6 @@ class V4L2Wrapper : public GrabberWrapper
|
||||
|
||||
public:
|
||||
V4L2Wrapper(const QString & device,
|
||||
int input,
|
||||
VideoStandard videoStandard,
|
||||
PixelFormat pixelFormat,
|
||||
int pixelDecimation );
|
||||
|
@@ -42,7 +42,7 @@ public:
|
||||
///
|
||||
/// @brief Apply new width/height values, overwrite Grabber.h implementation as X11 doesn't use width/height, just pixelDecimation to calc dimensions
|
||||
///
|
||||
virtual void setWidthHeight(int width, int height);
|
||||
virtual bool setWidthHeight(int width, int height) { return true; };
|
||||
|
||||
///
|
||||
/// @brief Apply new pixelDecimation
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#include <utils/Image.h>
|
||||
|
||||
class Hyperion;
|
||||
class QTimer;
|
||||
|
||||
///
|
||||
/// @brief Capture Control class which is a interface to the HyperionDaemon native capture classes.
|
||||
@@ -48,6 +49,11 @@ private slots:
|
||||
///
|
||||
void handleV4lImage(const Image<ColorRgb> & image);
|
||||
|
||||
///
|
||||
/// @brief Is called from _v4lInactiveTimer to set source after specific time to inactive
|
||||
///
|
||||
void setV4lInactive();
|
||||
|
||||
private:
|
||||
/// Hyperion instance
|
||||
Hyperion* _hyperion;
|
||||
@@ -59,4 +65,5 @@ private:
|
||||
/// Reflect state of v4l capture and prio
|
||||
bool _v4lCaptEnabled;
|
||||
quint8 _v4lCaptPrio;
|
||||
QTimer* _v4lInactiveTimer;
|
||||
};
|
||||
|
@@ -33,9 +33,9 @@ public:
|
||||
///
|
||||
/// @brief Check if a component is currently enabled
|
||||
/// @param comp The component from enum
|
||||
/// @return True if component is running else false
|
||||
/// @return True if component is running else false. Not found is -1
|
||||
///
|
||||
bool isComponentEnabled(const hyperion::Components& comp) const;
|
||||
int isComponentEnabled(const hyperion::Components& comp) const;
|
||||
|
||||
/// contains all components and their state
|
||||
std::map<hyperion::Components, bool> getRegister() { return _componentStates; };
|
||||
|
@@ -36,7 +36,7 @@ public:
|
||||
///
|
||||
/// @brief Apply new width/height values, on errors (collide with cropping) reject the values
|
||||
///
|
||||
virtual void setWidthHeight(int width, int height);
|
||||
virtual bool setWidthHeight(int width, int height);
|
||||
|
||||
///
|
||||
/// @brief Apply new pixelDecimation (used from x11)
|
||||
@@ -66,9 +66,9 @@ public:
|
||||
virtual void setSignalDetectionEnable(bool enable) {};
|
||||
|
||||
///
|
||||
/// @brief Apply input and videoStanded (used from v4l)
|
||||
/// @brief Apply device and videoStanded (used from v4l)
|
||||
///
|
||||
virtual void setInputVideoStandard(int input, VideoStandard videoStandard) {};
|
||||
virtual void setDeviceVideoStandard(QString device, VideoStandard videoStandard) {};
|
||||
|
||||
///
|
||||
/// @brief Apply display index (used from x11)
|
||||
|
@@ -1,12 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include <utils/Logger.h>
|
||||
#include <utils/Components.h>
|
||||
#include <hyperion/Hyperion.h>
|
||||
#include <utils/Image.h>
|
||||
#include <utils/ColorRgb.h>
|
||||
#include <utils/VideoMode.h>
|
||||
@@ -98,9 +99,6 @@ protected:
|
||||
|
||||
QString _grabberName;
|
||||
|
||||
/// Pointer to Hyperion for writing led values
|
||||
Hyperion * _hyperion;
|
||||
|
||||
/// The timer for generating events with the specified update rate
|
||||
QTimer* _timer;
|
||||
|
||||
@@ -110,9 +108,6 @@ protected:
|
||||
/// The Logger instance
|
||||
Logger * _log;
|
||||
|
||||
// forwarding enabled
|
||||
bool _forward;
|
||||
|
||||
Grabber *_ggrabber;
|
||||
|
||||
/// The image used for grabbing frames
|
||||
|
@@ -49,6 +49,7 @@ class ColorAdjustment;
|
||||
class SettingsManager;
|
||||
class BGEffectHandler;
|
||||
class CaptureCont;
|
||||
class BoblightServer;
|
||||
|
||||
///
|
||||
/// The main class of Hyperion. This gives other 'users' access to the attached LedDevice through
|
||||
@@ -105,6 +106,8 @@ public:
|
||||
///
|
||||
PriorityMuxer* getMuxerInstance() { return &_muxer; };
|
||||
|
||||
ImageProcessor* getImageProcessor() { return _imageProcessor; };
|
||||
|
||||
///
|
||||
/// @brief Get a setting by settings::type from SettingsManager
|
||||
/// @param type The settingsType from enum
|
||||
@@ -145,7 +148,7 @@ public:
|
||||
bool isCurrentPriority(const int priority) const;
|
||||
|
||||
///
|
||||
/// Returns a list of active priorities
|
||||
/// Returns a list of all registered priorities
|
||||
///
|
||||
/// @return The list with priorities
|
||||
///
|
||||
@@ -279,6 +282,13 @@ public slots:
|
||||
///
|
||||
const bool setInputImage(const int priority, const Image<ColorRgb>& image, int64_t timeout_ms = -1, const bool& clearEffect = true);
|
||||
|
||||
///
|
||||
/// @brief Set the given priority to inactive
|
||||
/// @param priority The priority
|
||||
/// @return True on success false if not found
|
||||
///
|
||||
const bool setInputInactive(const quint8& priority);
|
||||
|
||||
///
|
||||
/// Writes a single color to all the leds for the given time and priority
|
||||
/// Registers comp color or provided type against muxer
|
||||
@@ -540,4 +550,7 @@ private:
|
||||
std::vector<ColorRgb> _ledBuffer;
|
||||
/// buffer for leds (without adjustment)
|
||||
std::vector<ColorRgb> _rawLedBuffer;
|
||||
|
||||
/// Boblight instance
|
||||
BoblightServer* _boblightServer;
|
||||
};
|
||||
|
@@ -162,6 +162,13 @@ public:
|
||||
///
|
||||
const bool setInputImage(const int priority, const Image<ColorRgb>& image, int64_t timeout_ms = -1);
|
||||
|
||||
///
|
||||
/// @brief Set the given priority to inactive
|
||||
/// @param priority The priority
|
||||
/// @return True on success false if not found
|
||||
///
|
||||
const bool setInputInactive(const quint8& priority);
|
||||
|
||||
///
|
||||
/// Clears the specified priority channel and update _currentPriority on success
|
||||
///
|
||||
|
@@ -6,7 +6,6 @@
|
||||
// qt incl
|
||||
#include <QJsonObject>
|
||||
|
||||
class SettingsTable;
|
||||
class Hyperion;
|
||||
|
||||
///
|
||||
@@ -63,8 +62,6 @@ private:
|
||||
Hyperion* _hyperion;
|
||||
/// Logger instance
|
||||
Logger* _log;
|
||||
/// instance of database table interface
|
||||
SettingsTable* _sTable;
|
||||
/// the schema
|
||||
static QJsonObject schemaJson;
|
||||
/// the current config of this instance
|
||||
|
@@ -8,12 +8,10 @@
|
||||
#include <utils/Logger.h>
|
||||
#include <utils/settings.h>
|
||||
|
||||
class Hyperion;
|
||||
class QTcpServer;
|
||||
class QTcpSocket;
|
||||
class JsonClientConnection;
|
||||
class BonjourServiceRegister;
|
||||
class ComponentRegister;
|
||||
class NetOrigin;
|
||||
|
||||
///
|
||||
@@ -50,12 +48,7 @@ private slots:
|
||||
///
|
||||
void closedConnection(void);
|
||||
|
||||
/// forward message to all json slaves
|
||||
void forwardJsonMessage(const QJsonObject &message);
|
||||
|
||||
public slots:
|
||||
/// process current forwarder state
|
||||
void componentStateChanged(const hyperion::Components component, bool enable);
|
||||
|
||||
///
|
||||
/// forward message to a single json slaves
|
||||
@@ -75,18 +68,12 @@ private:
|
||||
/// The TCP server object
|
||||
QTcpServer * _server;
|
||||
|
||||
/// Link to Hyperion to get config state emiter
|
||||
Hyperion * _hyperion;
|
||||
|
||||
/// List with open connections
|
||||
QSet<JsonClientConnection *> _openConnections;
|
||||
|
||||
/// the logger instance
|
||||
Logger * _log;
|
||||
|
||||
/// Component Register pointer
|
||||
ComponentRegister* _componentRegister;
|
||||
|
||||
NetOrigin* _netOrigin;
|
||||
|
||||
/// port
|
||||
|
@@ -25,8 +25,6 @@ class ProtoConnection;
|
||||
class QTcpServer;
|
||||
class Hyperion;
|
||||
class BonjourServiceRegister;
|
||||
class ComponentRegister;
|
||||
class NetOrigin;
|
||||
|
||||
namespace proto {
|
||||
class HyperionRequest;
|
||||
@@ -55,8 +53,6 @@ public:
|
||||
uint16_t getPort() const;
|
||||
|
||||
public slots:
|
||||
void sendImageToProtoSlaves(int priority, const Image<ColorRgb> & image, int duration_ms);
|
||||
void componentStateChanged(const hyperion::Components component, bool enable);
|
||||
|
||||
///
|
||||
/// @brief Handle settings update from Hyperion Settingsmanager emit or this constructor
|
||||
@@ -65,12 +61,6 @@ public slots:
|
||||
///
|
||||
void handleSettingsUpdate(const settings::type& type, const QJsonDocument& config);
|
||||
|
||||
signals:
|
||||
///
|
||||
/// Forwarding videoMode
|
||||
///
|
||||
void videoMode(const VideoMode VideoMode);
|
||||
|
||||
private slots:
|
||||
///
|
||||
/// Slot which is called when a client tries to create a new connection
|
||||
@@ -83,8 +73,6 @@ private slots:
|
||||
///
|
||||
void closedConnection(ProtoClientConnection * connection);
|
||||
|
||||
void newMessage(const proto::HyperionRequest * message);
|
||||
|
||||
private:
|
||||
/// Hyperion instance
|
||||
Hyperion * _hyperion;
|
||||
@@ -94,26 +82,13 @@ private:
|
||||
|
||||
/// List with open connections
|
||||
QSet<ProtoClientConnection *> _openConnections;
|
||||
QStringList _forwardClients;
|
||||
|
||||
/// Hyperion proto connection object for forwarding
|
||||
QList<ProtoConnection*> _proxy_connections;
|
||||
|
||||
/// Logger instance
|
||||
Logger * _log;
|
||||
|
||||
/// Component Register
|
||||
ComponentRegister* _componentRegister;
|
||||
|
||||
/// Network Origin Check
|
||||
NetOrigin* _netOrigin;
|
||||
|
||||
/// Service register
|
||||
BonjourServiceRegister * _serviceRegister = nullptr;
|
||||
|
||||
/// flag if forwarder is enabled
|
||||
bool _forwarder_enabled;
|
||||
|
||||
uint16_t _port = 0;
|
||||
|
||||
/// Start server
|
||||
|
@@ -11,15 +11,13 @@
|
||||
// Hyperion includes
|
||||
#include <utils/Logger.h>
|
||||
#include <utils/Components.h>
|
||||
#include <utils/ColorRgb.h>
|
||||
|
||||
// settings
|
||||
#include <utils/settings.h>
|
||||
|
||||
class Hyperion;
|
||||
class UDPClientConnection;
|
||||
class BonjourServiceRegister;
|
||||
class QUdpSocket;
|
||||
class NetOrigin;
|
||||
|
||||
///
|
||||
/// This class creates a UDP server which accepts connections from boblight clients.
|
||||
@@ -67,6 +65,22 @@ public slots:
|
||||
///
|
||||
void handleSettingsUpdate(const settings::type& type, const QJsonDocument& config);
|
||||
|
||||
signals:
|
||||
///
|
||||
/// @brief forward register data to HyperionDaemon
|
||||
///
|
||||
void registerGlobalInput(const int priority, const hyperion::Components& component, const QString& origin = "System", const QString& owner = "", unsigned smooth_cfg = 0);
|
||||
|
||||
///
|
||||
/// @brief forward led data to HyperionDaemon
|
||||
///
|
||||
const bool setGlobalInput(const int priority, const std::vector<ColorRgb>& ledColors, const int timeout_ms = -1, const bool& clearEffect = true);
|
||||
|
||||
///
|
||||
/// @brief forward clear to HyperionDaemon
|
||||
///
|
||||
void clearGlobalPriority(const int& _priority, const hyperion::Components& component);
|
||||
|
||||
private slots:
|
||||
///
|
||||
/// Slot which is called when a client tries to create a new connection
|
||||
@@ -75,15 +89,10 @@ private slots:
|
||||
void processTheDatagram(const QByteArray * datagram, const QHostAddress * sender);
|
||||
|
||||
private:
|
||||
/// Hyperion instance
|
||||
Hyperion * _hyperion;
|
||||
|
||||
/// The UDP server object
|
||||
QUdpSocket * _server;
|
||||
|
||||
/// List with open connections
|
||||
QSet<UDPClientConnection *> _openConnections;
|
||||
|
||||
/// hyperion priority
|
||||
int _priority;
|
||||
|
||||
@@ -94,7 +103,7 @@ private:
|
||||
Logger * _log;
|
||||
|
||||
/// Bonjour Service Register
|
||||
BonjourServiceRegister* _bonjourService = nullptr;
|
||||
BonjourServiceRegister* _serviceRegister = nullptr;
|
||||
|
||||
/// state of connection
|
||||
bool _isActive;
|
||||
@@ -103,7 +112,4 @@ private:
|
||||
QHostAddress _listenAddress;
|
||||
uint16_t _listenPort;
|
||||
QAbstractSocket::BindFlag _bondage;
|
||||
|
||||
/// Check Network Origin
|
||||
NetOrigin* _netOrigin;
|
||||
};
|
||||
|
@@ -22,7 +22,8 @@ enum Components
|
||||
COMP_IMAGE,
|
||||
COMP_EFFECT,
|
||||
COMP_PROTOSERVER,
|
||||
COMP_LEDDEVICE
|
||||
COMP_LEDDEVICE,
|
||||
COMP_FLATBUFSERVER
|
||||
};
|
||||
|
||||
inline const char* componentToString(Components c)
|
||||
@@ -42,6 +43,7 @@ inline const char* componentToString(Components c)
|
||||
case COMP_IMAGE: return "Image";
|
||||
case COMP_PROTOSERVER: return "Proto Server";
|
||||
case COMP_LEDDEVICE: return "LED device";
|
||||
case COMP_FLATBUFSERVER: return "Image Receiver";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
@@ -63,6 +65,7 @@ inline const char* componentToIdString(Components c)
|
||||
case COMP_IMAGE: return "IMAGE";
|
||||
case COMP_PROTOSERVER: return "PROTOSERVER";
|
||||
case COMP_LEDDEVICE: return "LEDDEVICE";
|
||||
case COMP_FLATBUFSERVER: return "FLATBUFSERVER";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
@@ -83,7 +86,7 @@ inline Components stringToComponent(QString component)
|
||||
if (component == "IMAGE") return COMP_IMAGE;
|
||||
if (component == "PROTOSERVER") return COMP_PROTOSERVER;
|
||||
if (component == "LEDDEVICE") return COMP_LEDDEVICE;
|
||||
|
||||
if (component == "FLATBUFSERVER") return COMP_FLATBUFSERVER;
|
||||
return COMP_INVALID;
|
||||
}
|
||||
|
||||
|
34
include/utils/NetUtils.h
Normal file
34
include/utils/NetUtils.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include <utils/Logger.h>
|
||||
|
||||
#include <QTcpServer>
|
||||
|
||||
namespace NetUtils {
|
||||
///
|
||||
/// @brief Check if the port is available for listening
|
||||
/// @param[in/out] port The port to test, will be incremented if port is in use
|
||||
/// @param log The logger of the caller to print
|
||||
/// @return True on success else false
|
||||
///
|
||||
static const bool portAvailable(quint16& port, Logger* log)
|
||||
{
|
||||
const quint16 prevPort = port;
|
||||
QTcpServer server;
|
||||
bool corrected = false;
|
||||
while (!server.listen(QHostAddress::Any, port))
|
||||
{
|
||||
corrected = true;
|
||||
Warning(log,"Port '%d' is already in use, will increment", port);
|
||||
port ++;
|
||||
}
|
||||
server.close();
|
||||
if(corrected)
|
||||
{
|
||||
Warning(log, "The requested Port '%d' was already in use, will use Port '%d' instead", prevPort, port);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@@ -16,6 +16,14 @@ class Stats : public QObject
|
||||
|
||||
public:
|
||||
Stats();
|
||||
static Stats* getInstance() { return instance; };
|
||||
static Stats* instance;
|
||||
|
||||
void handleDataUpdate(const QJsonObject& config);
|
||||
|
||||
private:
|
||||
friend class HyperionDaemon;
|
||||
Stats(const QJsonObject& config);
|
||||
~Stats();
|
||||
|
||||
private:
|
||||
|
@@ -29,6 +29,7 @@ enum type {
|
||||
WEBSERVER,
|
||||
INSTCAPTURE,
|
||||
NETWORK,
|
||||
FLATBUFSERVER,
|
||||
INVALID
|
||||
};
|
||||
|
||||
@@ -62,6 +63,7 @@ inline QString typeToString(const type& type)
|
||||
case WEBSERVER: return "webConfig";
|
||||
case INSTCAPTURE: return "instCapture";
|
||||
case NETWORK: return "network";
|
||||
case FLATBUFSERVER: return "flatbufServer";
|
||||
default: return "invalid";
|
||||
}
|
||||
}
|
||||
@@ -94,6 +96,7 @@ inline type stringToType(const QString& type)
|
||||
else if (type == "webConfig") return WEBSERVER;
|
||||
else if (type == "instCapture") return INSTCAPTURE;
|
||||
else if (type == "network") return NETWORK;
|
||||
else if (type == "flatbufServer") return FLATBUFSERVER;
|
||||
else return INVALID;
|
||||
}
|
||||
};
|
||||
|
@@ -5,13 +5,13 @@
|
||||
#include <QString>
|
||||
#include <QJsonDocument>
|
||||
|
||||
// hyperion / utils
|
||||
#include <hyperion/Hyperion.h>
|
||||
// utils include
|
||||
#include <utils/Logger.h>
|
||||
|
||||
// settings
|
||||
#include <utils/settings.h>
|
||||
|
||||
class BonjourServiceRegister;
|
||||
class StaticFileServing;
|
||||
class QtHttpServer;
|
||||
|
||||
@@ -42,7 +42,6 @@ public slots:
|
||||
|
||||
private:
|
||||
Logger* _log;
|
||||
Hyperion* _hyperion;
|
||||
QString _baseUrl;
|
||||
quint16 _port;
|
||||
StaticFileServing* _staticFileServing;
|
||||
@@ -50,6 +49,8 @@ private:
|
||||
|
||||
const QString WEBSERVER_DEFAULT_PATH = ":/webconfig";
|
||||
const quint16 WEBSERVER_DEFAULT_PORT = 8090;
|
||||
|
||||
BonjourServiceRegister * _serviceRegister = nullptr;
|
||||
};
|
||||
|
||||
#endif // WEBSERVER_H
|
||||
|
Reference in New Issue
Block a user