mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Allow forwarding of flat-/proto buffer input (#1471)
* Typo * Address compiler Warnings * Allow forwarding of flat-/proto buffer input
This commit is contained in:
@@ -182,6 +182,7 @@ void FlatBufferClient::handleImageCommand(const hyperionnet::Image *image)
|
||||
}
|
||||
|
||||
emit setGlobalInputImage(_priority, imageRGB, duration);
|
||||
emit setBufferImage("FlatBuffer", imageRGB);
|
||||
}
|
||||
|
||||
// send reply
|
||||
|
@@ -54,6 +54,11 @@ signals:
|
||||
///
|
||||
void setGlobalInputColor(int priority, const std::vector<ColorRgb> &ledColor, int timeout_ms, const QString& origin = "FlatBuffer" ,bool clearEffects = true);
|
||||
|
||||
///
|
||||
/// @brief Emit the final processed image
|
||||
///
|
||||
void setBufferImage(const QString& name, const Image<ColorRgb>& image);
|
||||
|
||||
///
|
||||
/// @brief Emits whenever the client disconnected
|
||||
///
|
||||
|
@@ -81,6 +81,7 @@ void FlatBufferServer::newConnection()
|
||||
connect(client, &FlatBufferClient::clearGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::clearGlobalInput);
|
||||
connect(client, &FlatBufferClient::setGlobalInputImage, GlobalSignals::getInstance(), &GlobalSignals::setGlobalImage);
|
||||
connect(client, &FlatBufferClient::setGlobalInputColor, GlobalSignals::getInstance(), &GlobalSignals::setGlobalColor);
|
||||
connect(client, &FlatBufferClient::setBufferImage, GlobalSignals::getInstance(), &GlobalSignals::setBufferImage);
|
||||
connect(GlobalSignals::getInstance(), &GlobalSignals::globalRegRequired, client, &FlatBufferClient::registationRequired);
|
||||
_openConnections.append(client);
|
||||
}
|
||||
|
@@ -107,13 +107,27 @@ void MessageForwarder::enableTargets(bool enable, const QJsonObject& config)
|
||||
if (flatbufTargetNum > 0)
|
||||
{
|
||||
hyperion::Components activeCompId = _hyperion->getPriorityInfo(_hyperion->getCurrentPriority()).componentId;
|
||||
if (activeCompId == hyperion::COMP_GRABBER)
|
||||
{
|
||||
|
||||
switch (activeCompId) {
|
||||
case hyperion::COMP_GRABBER:
|
||||
connect(_hyperion, &Hyperion::forwardSystemProtoMessage, this, &MessageForwarder::forwardFlatbufferMessage, Qt::UniqueConnection);
|
||||
}
|
||||
else if (activeCompId == hyperion::COMP_V4L)
|
||||
{
|
||||
break;
|
||||
case hyperion::COMP_V4L:
|
||||
connect(_hyperion, &Hyperion::forwardV4lProtoMessage, this, &MessageForwarder::forwardFlatbufferMessage, Qt::UniqueConnection);
|
||||
break;
|
||||
#if defined(ENABLE_FLATBUF_SERVER)
|
||||
case hyperion::COMP_FLATBUFSERVER:
|
||||
#endif
|
||||
#if defined(ENABLE_PROTOBUF_SERVER)
|
||||
case hyperion::COMP_PROTOSERVER:
|
||||
#endif
|
||||
#if defined(ENABLE_FLATBUF_SERVER) || defined(ENABLE_PROTOBUF_SERVER)
|
||||
|
||||
connect(_hyperion, &Hyperion::forwardBufferMessage, this, &MessageForwarder::forwardFlatbufferMessage, Qt::UniqueConnection);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,33 +149,41 @@ void MessageForwarder::handlePriorityChanges(int priority)
|
||||
if (priority != 0 && _forwarder_enabled)
|
||||
{
|
||||
hyperion::Components activeCompId = _hyperion->getPriorityInfo(priority).componentId;
|
||||
if (activeCompId == hyperion::COMP_GRABBER || activeCompId == hyperion::COMP_V4L)
|
||||
{
|
||||
switch (activeCompId)
|
||||
{
|
||||
case hyperion::COMP_GRABBER:
|
||||
{
|
||||
disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, nullptr, nullptr);
|
||||
connect(_hyperion, &Hyperion::forwardSystemProtoMessage, this, &MessageForwarder::forwardFlatbufferMessage, Qt::UniqueConnection);
|
||||
}
|
||||
|
||||
switch (activeCompId) {
|
||||
case hyperion::COMP_GRABBER:
|
||||
disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, nullptr, nullptr);
|
||||
#if defined(ENABLE_FLATBUF_SERVER) || defined(ENABLE_PROTOBUF_SERVER)
|
||||
disconnect(_hyperion, &Hyperion::forwardBufferMessage, nullptr, nullptr);
|
||||
#endif
|
||||
connect(_hyperion, &Hyperion::forwardSystemProtoMessage, this, &MessageForwarder::forwardFlatbufferMessage, Qt::UniqueConnection);
|
||||
break;
|
||||
case hyperion::COMP_V4L:
|
||||
{
|
||||
disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, nullptr, nullptr);
|
||||
connect(_hyperion, &Hyperion::forwardV4lProtoMessage, this, &MessageForwarder::forwardFlatbufferMessage, Qt::UniqueConnection);
|
||||
}
|
||||
case hyperion::COMP_V4L:
|
||||
disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, nullptr, nullptr);
|
||||
#if defined(ENABLE_FLATBUF_SERVER) || defined(ENABLE_PROTOBUF_SERVER)
|
||||
disconnect(_hyperion, &Hyperion::forwardBufferMessage, nullptr, nullptr);
|
||||
#endif
|
||||
connect(_hyperion, &Hyperion::forwardV4lProtoMessage, this, &MessageForwarder::forwardFlatbufferMessage, Qt::UniqueConnection);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, nullptr, nullptr);
|
||||
disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(ENABLE_FLATBUF_SERVER)
|
||||
case hyperion::COMP_FLATBUFSERVER:
|
||||
#endif
|
||||
#if defined(ENABLE_PROTOBUF_SERVER)
|
||||
case hyperion::COMP_PROTOSERVER:
|
||||
#endif
|
||||
#if defined(ENABLE_FLATBUF_SERVER) || defined(ENABLE_PROTOBUF_SERVER)
|
||||
disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, nullptr, nullptr);
|
||||
disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, nullptr, nullptr);
|
||||
connect(_hyperion, &Hyperion::forwardBufferMessage, this, &MessageForwarder::forwardFlatbufferMessage, Qt::UniqueConnection);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, nullptr, nullptr);
|
||||
disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, nullptr, nullptr);
|
||||
#if defined(ENABLE_FLATBUF_SERVER) || defined(ENABLE_PROTOBUF_SERVER)
|
||||
disconnect(_hyperion, &Hyperion::forwardBufferMessage, nullptr, nullptr);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -351,6 +373,9 @@ void MessageForwarder::stopFlatbufferTargets()
|
||||
{
|
||||
disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, nullptr, nullptr);
|
||||
disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, nullptr, nullptr);
|
||||
#if defined(ENABLE_FLATBUF_SERVER) || defined(ENABLE_PROTOBUF_SERVER)
|
||||
disconnect(_hyperion, &Hyperion::forwardBufferMessage, nullptr, nullptr);
|
||||
#endif
|
||||
|
||||
if (_messageForwarderFlatBufHelper != nullptr)
|
||||
{
|
||||
|
@@ -150,6 +150,9 @@ void Hyperion::start()
|
||||
{
|
||||
_messageForwarder = new MessageForwarder(this);
|
||||
_messageForwarder->handleSettingsUpdate(settings::NETFORWARD, getSetting(settings::NETFORWARD));
|
||||
#if defined(ENABLE_FLATBUF_SERVER) || defined(ENABLE_PROTOBUF_SERVER)
|
||||
connect(GlobalSignals::getInstance(), &GlobalSignals::setBufferImage, this, &Hyperion::forwardBufferMessage);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -279,7 +279,7 @@ int LedDeviceRazer::write(const std::vector<ColorRgb>& ledValues)
|
||||
for (int col = 0; col < _maxColumn; col++) {
|
||||
int pos = row * _maxColumn + col;
|
||||
int bgrColor;
|
||||
if (pos < ledValues.size())
|
||||
if (pos < static_cast<int>(ledValues.size()))
|
||||
{
|
||||
bgrColor = (ledValues[pos].red * 65536) + (ledValues[pos].green * 256) + ledValues[pos].blue;
|
||||
}
|
||||
|
@@ -14,8 +14,6 @@
|
||||
// Constants
|
||||
namespace {
|
||||
|
||||
bool verbose = false;
|
||||
|
||||
const QChar ONE_SLASH = '/';
|
||||
|
||||
const int HTTP_STATUS_NO_CONTENT = 204;
|
||||
|
@@ -198,6 +198,7 @@ void ProtoClientConnection::handleImageCommand(const proto::ImageRequest &messag
|
||||
}
|
||||
|
||||
emit setGlobalInputImage(_priority, imageRGB, duration);
|
||||
emit setBufferImage("ProtoBuffer", imageRGB);
|
||||
|
||||
// send reply
|
||||
sendSuccessReply();
|
||||
|
@@ -56,6 +56,11 @@ signals:
|
||||
///
|
||||
void setGlobalInputColor(int priority, const std::vector<ColorRgb> &ledColor, int timeout_ms, const QString& origin = "ProtoBuffer" ,bool clearEffects = true);
|
||||
|
||||
///
|
||||
/// @brief Emit the final processed image
|
||||
///
|
||||
void setBufferImage(const QString& name, const Image<ColorRgb>& image);
|
||||
|
||||
///
|
||||
/// @brief Emits whenever the client disconnected
|
||||
///
|
||||
|
@@ -80,6 +80,7 @@ void ProtoServer::newConnection()
|
||||
connect(client, &ProtoClientConnection::clearGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::clearGlobalInput);
|
||||
connect(client, &ProtoClientConnection::setGlobalInputImage, GlobalSignals::getInstance(), &GlobalSignals::setGlobalImage);
|
||||
connect(client, &ProtoClientConnection::setGlobalInputColor, GlobalSignals::getInstance(), &GlobalSignals::setGlobalColor);
|
||||
connect(client, &ProtoClientConnection::setBufferImage, GlobalSignals::getInstance(), &GlobalSignals::setBufferImage);
|
||||
connect(GlobalSignals::getInstance(), &GlobalSignals::globalRegRequired, client, &ProtoClientConnection::registationRequired);
|
||||
_openConnections.append(client);
|
||||
}
|
||||
|
Reference in New Issue
Block a user