mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
UDP listener removed because this class is not multi-instance capable. For a new implementation, image data is needed instead of led colors.
Signed-off-by: Paulchen-Panther <Paulchen-Panter@protonmail.com>
This commit is contained in:
@@ -12,7 +12,6 @@ add_subdirectory(protoserver)
|
||||
add_subdirectory(bonjour)
|
||||
add_subdirectory(ssdp)
|
||||
add_subdirectory(boblightserver)
|
||||
add_subdirectory(udplistener)
|
||||
add_subdirectory(leddevice)
|
||||
add_subdirectory(utils)
|
||||
add_subdirectory(effectengine)
|
||||
|
@@ -21,7 +21,7 @@
|
||||
"component":
|
||||
{
|
||||
"type" : "string",
|
||||
"enum" : ["ALL", "SMOOTHING", "BLACKBORDER", "FORWARDER", "UDPLISTENER", "BOBLIGHTSERVER", "GRABBER", "V4L", "LEDDEVICE"],
|
||||
"enum" : ["ALL", "SMOOTHING", "BLACKBORDER", "FORWARDER", "BOBLIGHTSERVER", "GRABBER", "V4L", "LEDDEVICE"],
|
||||
"required": true
|
||||
},
|
||||
"state":
|
||||
|
@@ -11,7 +11,7 @@ ComponentRegister::ComponentRegister(Hyperion* hyperion)
|
||||
{
|
||||
// init all comps to false
|
||||
QVector<hyperion::Components> vect;
|
||||
vect << COMP_ALL << COMP_SMOOTHING << COMP_BLACKBORDER << COMP_FORWARDER << COMP_UDPLISTENER << COMP_BOBLIGHTSERVER << COMP_GRABBER << COMP_V4L << COMP_LEDDEVICE;
|
||||
vect << COMP_ALL << COMP_SMOOTHING << COMP_BLACKBORDER << COMP_FORWARDER << COMP_BOBLIGHTSERVER << COMP_GRABBER << COMP_V4L << COMP_LEDDEVICE;
|
||||
for(auto e : vect)
|
||||
{
|
||||
_componentStates.emplace(e, ((e == COMP_ALL) ? true : false));
|
||||
|
@@ -156,7 +156,8 @@ bool HyperionIManager::deleteInstance(const quint8& inst)
|
||||
return false;
|
||||
|
||||
// stop it if required as blocking and wait
|
||||
if (stopInstance(inst, true));
|
||||
if (stopInstance(inst, true))
|
||||
;
|
||||
|
||||
if(_instanceTable->deleteInstance(inst))
|
||||
{
|
||||
|
@@ -63,7 +63,7 @@ public:
|
||||
///
|
||||
/// @brief select a smoothing cfg given by cfg index from addConfig()
|
||||
/// @param cfg The index to use
|
||||
/// @param force Overwrite in any case the current values (used for cfg 0 settings udpate)
|
||||
/// @param force Overwrite in any case the current values (used for cfg 0 settings update)
|
||||
///
|
||||
/// @return On success return else false (and falls back to cfg 0)
|
||||
///
|
||||
|
@@ -63,10 +63,6 @@
|
||||
{
|
||||
"$ref": "schema-boblightServer.json"
|
||||
},
|
||||
"udpListener" :
|
||||
{
|
||||
"$ref": "schema-udpListener.json"
|
||||
},
|
||||
"webConfig" :
|
||||
{
|
||||
"$ref": "schema-webConfig.json"
|
||||
|
@@ -17,7 +17,6 @@
|
||||
<file alias="schema-flatbufServer.json">schema/schema-flatbufServer.json</file>
|
||||
<file alias="schema-protoServer.json">schema/schema-protoServer.json</file>
|
||||
<file alias="schema-boblightServer.json">schema/schema-boblightServer.json</file>
|
||||
<file alias="schema-udpListener.json">schema/schema-udpListener.json</file>
|
||||
<file alias="schema-webConfig.json">schema/schema-webConfig.json</file>
|
||||
<file alias="schema-effects.json">schema/schema-effects.json</file>
|
||||
<file alias="schema-ledConfig.json">schema/schema-ledConfig.json</file>
|
||||
|
@@ -1,56 +0,0 @@
|
||||
{
|
||||
"type" : "object",
|
||||
"title" : "edt_conf_udpl_heading_title",
|
||||
"properties" :
|
||||
{
|
||||
"enable" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"title" : "edt_conf_general_enable_title",
|
||||
"default" : false,
|
||||
"propertyOrder" : 1
|
||||
},
|
||||
"address" :
|
||||
{
|
||||
"type" : "string",
|
||||
"title" : "edt_conf_udpl_address_title",
|
||||
"default" : "239.255.28.01",
|
||||
"propertyOrder" : 2
|
||||
},
|
||||
"port" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"title" : "edt_conf_general_port_title",
|
||||
"minimum" : 0,
|
||||
"maximum" : 65535,
|
||||
"default" : 2801,
|
||||
"propertyOrder" : 3
|
||||
},
|
||||
"priority" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"title" : "edt_conf_general_priority_title",
|
||||
"minimum" : 100,
|
||||
"maximum" : 254,
|
||||
"default" : 200,
|
||||
"propertyOrder" : 4
|
||||
},
|
||||
"timeout" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"title" : "edt_conf_udpl_timeout_title",
|
||||
"minimum" : 1000,
|
||||
"default" : 10000,
|
||||
"append" : "edt_append_ms",
|
||||
"propertyOrder" : 5
|
||||
},
|
||||
"shared" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"title" : "edt_conf_udpl_shared_title",
|
||||
"default" : false,
|
||||
"propertyOrder" : 6
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
|
||||
# Define the current source locations
|
||||
set(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/udplistener)
|
||||
set(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/udplistener)
|
||||
|
||||
FILE ( GLOB UDPListener_SOURCES "${CURRENT_HEADER_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" )
|
||||
|
||||
add_library(udplistener ${UDPListener_SOURCES} )
|
||||
|
||||
target_link_libraries(udplistener
|
||||
hyperion
|
||||
hyperion-utils
|
||||
${QT_LIBRARIES}
|
||||
)
|
@@ -1,161 +0,0 @@
|
||||
// project includes
|
||||
#include <udplistener/UDPListener.h>
|
||||
|
||||
// bonjour includes
|
||||
#include <bonjour/bonjourserviceregister.h>
|
||||
|
||||
// hyperion includes
|
||||
#include <hyperion/Hyperion.h>
|
||||
#include <hyperion/HyperionIManager.h>
|
||||
#include "HyperionConfig.h"
|
||||
|
||||
// utils includes
|
||||
#include <utils/NetOrigin.h>
|
||||
|
||||
// qt includes
|
||||
#include <QUdpSocket>
|
||||
#include <QJsonObject>
|
||||
|
||||
using namespace hyperion;
|
||||
|
||||
UDPListener::UDPListener(const QJsonDocument& config)
|
||||
: QObject()
|
||||
, _server(new QUdpSocket(this))
|
||||
, _priority(0)
|
||||
, _timeout(0)
|
||||
, _log(Logger::getInstance("UDPLISTENER"))
|
||||
, _isActive(false)
|
||||
, _listenPort(0)
|
||||
, _netOrigin(NetOrigin::getInstance())
|
||||
{
|
||||
// init
|
||||
handleSettingsUpdate(settings::UDPLISTENER, config);
|
||||
}
|
||||
|
||||
UDPListener::~UDPListener()
|
||||
{
|
||||
// clear the current channel
|
||||
stop();
|
||||
delete _server;
|
||||
}
|
||||
|
||||
void UDPListener::start()
|
||||
{
|
||||
if ( active() )
|
||||
return;
|
||||
|
||||
QHostAddress mcastGroup;
|
||||
if (_listenAddress.isInSubnet(QHostAddress::parseSubnet("224.0.0.0/4")))
|
||||
{
|
||||
mcastGroup = _listenAddress;
|
||||
}
|
||||
|
||||
if (!_server->bind(_listenAddress, _listenPort, _bondage))
|
||||
{
|
||||
Error(_log, "Could not bind to %s:%d", _listenAddress.toString().toStdString().c_str(), _listenPort);
|
||||
}
|
||||
else
|
||||
{
|
||||
Info(_log, "Started, listening on %s:%d", _listenAddress.toString().toStdString().c_str(), _listenPort);
|
||||
if (!mcastGroup.isNull())
|
||||
{
|
||||
bool joinGroupOK = _server->joinMulticastGroup(_listenAddress);
|
||||
InfoIf ( joinGroupOK, _log, "Multicast enabled");
|
||||
WarningIf( ! joinGroupOK, _log, "Multicast failed");
|
||||
}
|
||||
_isActive = true;
|
||||
|
||||
if(_serviceRegister == nullptr)
|
||||
{
|
||||
_serviceRegister = new BonjourServiceRegister(this);
|
||||
_serviceRegister->registerService("_hyperiond-udp._udp", _listenPort);
|
||||
}
|
||||
else if( _serviceRegister->getPort() != _listenPort)
|
||||
{
|
||||
delete _serviceRegister;
|
||||
_serviceRegister = new BonjourServiceRegister(this);
|
||||
_serviceRegister->registerService("_hyperiond-udp._udp", _listenPort);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UDPListener::stop()
|
||||
{
|
||||
if ( ! active() )
|
||||
return;
|
||||
|
||||
_server->close();
|
||||
_isActive = false;
|
||||
Info(_log, "Stopped");
|
||||
}
|
||||
|
||||
void UDPListener::updatedComponentState(const hyperion::Components component, bool enable)
|
||||
{
|
||||
if (component == COMP_UDPLISTENER)
|
||||
{
|
||||
if (_isActive != enable)
|
||||
{
|
||||
if (enable) start();
|
||||
else stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t UDPListener::getPort() const
|
||||
{
|
||||
return _server->localPort();
|
||||
}
|
||||
|
||||
void UDPListener::readPendingDatagrams()
|
||||
{
|
||||
while (_server->hasPendingDatagrams())
|
||||
{
|
||||
QByteArray datagram;
|
||||
datagram.resize(_server->pendingDatagramSize());
|
||||
QHostAddress sender;
|
||||
quint16 senderPort;
|
||||
|
||||
_server->readDatagram(datagram.data(), datagram.size(), &sender, &senderPort);
|
||||
|
||||
if(_netOrigin->accessAllowed(sender, _listenAddress))
|
||||
processTheDatagram(&datagram, &sender);
|
||||
}
|
||||
}
|
||||
|
||||
void UDPListener::processTheDatagram(const QByteArray * datagram, const QHostAddress * sender)
|
||||
{
|
||||
int packetLedCount = datagram->size()/3;
|
||||
//DebugIf( (packetLedCount != hyperionLedCount), _log, "packetLedCount (%d) != hyperionLedCount (%d)", packetLedCount, hyperionLedCount);
|
||||
|
||||
std::vector<ColorRgb> _ledColors(packetLedCount, ColorRgb::BLACK);
|
||||
|
||||
for (int ledIndex=0; ledIndex < packetLedCount; ledIndex++)
|
||||
{
|
||||
ColorRgb & rgb = _ledColors[ledIndex];
|
||||
rgb.red = datagram->at(ledIndex*3+0);
|
||||
rgb.green = datagram->at(ledIndex*3+1);
|
||||
rgb.blue = datagram->at(ledIndex*3+2);
|
||||
}
|
||||
// TODO provide a setInput with origin arg to overwrite senders smarter
|
||||
emit registerGlobalInput(_priority, hyperion::COMP_UDPLISTENER, QString("UDPListener@%1").arg(sender->toString()));
|
||||
emit setGlobalInput(_priority, _ledColors, _timeout);
|
||||
}
|
||||
|
||||
void UDPListener::handleSettingsUpdate(const settings::type& type, const QJsonDocument& config)
|
||||
{
|
||||
if(type == settings::UDPLISTENER)
|
||||
{
|
||||
QJsonObject obj = config.object();
|
||||
// if we change the prio we need to make sure the old one is cleared before we apply the new one!
|
||||
stop();
|
||||
|
||||
QString addr = obj["address"].toString("");
|
||||
_priority = obj["priority"].toInt();
|
||||
_listenPort = obj["port"].toInt();
|
||||
_listenAddress = addr.isEmpty()? QHostAddress::AnyIPv4 : QHostAddress(addr);
|
||||
_bondage = (obj["shared"].toBool(false)) ? QAbstractSocket::ShareAddress : QAbstractSocket::DefaultForPlatform;
|
||||
_timeout = obj["timeout"].toInt(10000);
|
||||
if(obj["enable"].toBool())
|
||||
start();
|
||||
}
|
||||
}
|
@@ -1 +0,0 @@
|
||||
|
Reference in New Issue
Block a user