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-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-02-15 18:25:18 +01:00
|
|
|
ProtoServer(Hyperion * hyperion, 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-06-07 23:12:18 +02:00
|
|
|
signals:
|
|
|
|
///
|
|
|
|
/// Forwarding XBMC Checker
|
|
|
|
///
|
|
|
|
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;
|
|
|
|
|
2013-10-11 10:06:24 +02:00
|
|
|
};
|