2013-10-11 10:06:24 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// system includes
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
// Qt includes
|
|
|
|
#include <QTcpServer>
|
|
|
|
#include <QSet>
|
2016-02-15 18:25:18 +01:00
|
|
|
#include <QList>
|
2016-02-08 16:56:23 +01:00
|
|
|
#include <QStringList>
|
2013-10-11 10:06:24 +02:00
|
|
|
|
|
|
|
// Hyperion includes
|
|
|
|
#include <hyperion/Hyperion.h>
|
|
|
|
|
2016-02-16 15:41:40 +01:00
|
|
|
// hyperion includes
|
|
|
|
#include <utils/Image.h>
|
|
|
|
#include <utils/ColorRgb.h>
|
2016-06-07 23:12:18 +02:00
|
|
|
#include <utils/GrabbingMode.h>
|
|
|
|
#include <utils/VideoMode.h>
|
2016-07-11 17:08:22 +02:00
|
|
|
#include <utils/Logger.h>
|
2016-02-16 15:41:40 +01:00
|
|
|
|
2016-02-15 18:25:18 +01:00
|
|
|
// forward decl
|
2013-10-11 10:06:24 +02:00
|
|
|
class ProtoClientConnection;
|
2016-02-15 18:25:18 +01:00
|
|
|
class ProtoConnection;
|
|
|
|
|
|
|
|
namespace proto {
|
|
|
|
class HyperionRequest;
|
|
|
|
}
|
2013-10-11 10:06:24 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// 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
|
|
|
|
/// hyperion-remote to control the leds
|
|
|
|
///
|
|
|
|
class ProtoServer : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
/// ProtoServer constructor
|
|
|
|
/// @param hyperion Hyperion instance
|
|
|
|
/// @param port port number on which to start listening for connections
|
|
|
|
///
|
2016-06-19 00:56:47 +02:00
|
|
|
ProtoServer(uint16_t port = 19445);
|
2013-10-11 10:06:24 +02:00
|
|
|
~ProtoServer();
|
|
|
|
|
|
|
|
///
|
|
|
|
/// @return the port number on which this TCP listens for incoming connections
|
|
|
|
///
|
|
|
|
uint16_t getPort() const;
|
|
|
|
|
2016-02-16 15:41:40 +01:00
|
|
|
public slots:
|
|
|
|
void sendImageToProtoSlaves(int priority, const Image<ColorRgb> & image, int duration_ms);
|
2016-08-11 07:13:55 +02:00
|
|
|
void componentStateChanged(const hyperion::Components component, bool enable);
|
2016-02-16 15:41:40 +01:00
|
|
|
|
2016-06-07 23:12:18 +02:00
|
|
|
signals:
|
|
|
|
///
|
2016-07-10 22:04:31 +02:00
|
|
|
/// Forwarding KODI Checker
|
2016-06-07 23:12:18 +02:00
|
|
|
///
|
|
|
|
void grabbingMode(const GrabbingMode mode);
|
|
|
|
void videoMode(const VideoMode VideoMode);
|
|
|
|
|
2013-10-11 10:06:24 +02:00
|
|
|
private slots:
|
|
|
|
///
|
|
|
|
/// Slot which is called when a client tries to create a new connection
|
|
|
|
///
|
|
|
|
void newConnection();
|
|
|
|
|
|
|
|
///
|
|
|
|
/// Slot which is called when a client closes a connection
|
|
|
|
/// @param connection The Connection object which is being closed
|
|
|
|
///
|
|
|
|
void closedConnection(ProtoClientConnection * connection);
|
|
|
|
|
2016-02-15 18:25:18 +01:00
|
|
|
void newMessage(const proto::HyperionRequest * message);
|
|
|
|
|
2013-10-11 10:06:24 +02:00
|
|
|
private:
|
|
|
|
/// Hyperion instance
|
|
|
|
Hyperion * _hyperion;
|
|
|
|
|
|
|
|
/// The TCP server object
|
|
|
|
QTcpServer _server;
|
|
|
|
|
|
|
|
/// List with open connections
|
|
|
|
QSet<ProtoClientConnection *> _openConnections;
|
2016-02-08 16:56:23 +01:00
|
|
|
QStringList _forwardClients;
|
2016-02-15 18:25:18 +01:00
|
|
|
|
|
|
|
/// Hyperion proto connection object for forwarding
|
|
|
|
QList<ProtoConnection*> _proxy_connections;
|
2016-08-11 07:13:55 +02:00
|
|
|
|
|
|
|
/// Logger instance
|
2016-07-11 17:08:22 +02:00
|
|
|
Logger * _log;
|
2016-08-11 07:13:55 +02:00
|
|
|
|
|
|
|
/// flag if forwarder is enabled
|
|
|
|
bool _forwarder_enabled;
|
2013-10-11 10:06:24 +02:00
|
|
|
};
|