Allow forwarding of flat-/proto buffer input (#1471)

* Typo

* Address compiler Warnings

* Allow forwarding of flat-/proto buffer input
This commit is contained in:
LordGrey 2022-05-29 17:47:08 +02:00 committed by GitHub
parent 7c76322215
commit ec496ed457
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 792 additions and 735 deletions

View File

@ -575,7 +575,7 @@
"edt_dev_spec_intervall_title": "Interval", "edt_dev_spec_intervall_title": "Interval",
"edt_dev_spec_invert_title": "Invert signal", "edt_dev_spec_invert_title": "Invert signal",
"edt_dev_spec_latchtime_title": "Latch time", "edt_dev_spec_latchtime_title": "Latch time",
"edt_dev_spec_latchtime_title_info": "Latch time is the time-frame a device requires until the next update can be processed. During that time-frame any updates done via ignored.", "edt_dev_spec_latchtime_title_info": "Latch time is the time-frame a device requires until the next update can be processed. During that time-frame any updates done are ignored.",
"edt_dev_spec_ledIndex_title": "LED index", "edt_dev_spec_ledIndex_title": "LED index",
"edt_dev_spec_ledType_title": "LED Type", "edt_dev_spec_ledType_title": "LED Type",
"edt_dev_spec_lightid_itemtitle": "ID", "edt_dev_spec_lightid_itemtitle": "ID",

View File

@ -78,11 +78,14 @@ private slots:
/// ///
void forwardJsonMessage(const QJsonObject &message); void forwardJsonMessage(const QJsonObject &message);
#if defined(ENABLE_FLATBUF_SERVER) || defined(ENABLE_PROTOBUF_SERVER)
/// ///
/// @brief Forward image to all flatbuffer target hosts /// @brief Forward image to all flatbuffer target hosts
/// @param image The flatbuffer image to send /// @param image The flatbuffer image to send
/// ///
///
void forwardFlatbufferMessage(const QString& name, const Image<ColorRgb> &image); void forwardFlatbufferMessage(const QString& name, const Image<ColorRgb> &image);
#endif
/// ///
/// @brief Forward message to a single json target host /// @brief Forward message to a single json target host

View File

@ -428,6 +428,11 @@ signals:
/// Signal which is emitted, when a new V4l proto image should be forwarded /// Signal which is emitted, when a new V4l proto image should be forwarded
void forwardV4lProtoMessage(const QString&, const Image<ColorRgb>&); void forwardV4lProtoMessage(const QString&, const Image<ColorRgb>&);
#if defined(ENABLE_FLATBUF_SERVER) || defined(ENABLE_PROTOBUF_SERVER)
/// Signal which is emitted, when a new Flat-/Proto- Buffer image should be forwarded
void forwardBufferMessage(const QString&, const Image<ColorRgb>&);
#endif
/// ///
/// @brief Is emitted from clients who request a videoMode change /// @brief Is emitted from clients who request a videoMode change
/// ///

View File

@ -47,6 +47,15 @@ signals:
/// ///
void setV4lImage(const QString& name, const Image<ColorRgb>& image); void setV4lImage(const QString& name, const Image<ColorRgb>& image);
#if defined(ENABLE_FLATBUF_SERVER) || defined(ENABLE_PROTOBUF_SERVER)
///
/// @brief PIPE Flat-/Proto- buffer images to Hyperion class
/// @param name The name of the buffer capture that is currently active
/// @param image The prepared image
///
void setBufferImage(const QString& name, const Image<ColorRgb>& image);
#endif
/// ///
/// @brief PIPE the register command for a new global input over HyperionDaemon to Hyperion class /// @brief PIPE the register command for a new global input over HyperionDaemon to Hyperion class
/// @param[in] priority The priority of the channel /// @param[in] priority The priority of the channel

View File

@ -182,6 +182,7 @@ void FlatBufferClient::handleImageCommand(const hyperionnet::Image *image)
} }
emit setGlobalInputImage(_priority, imageRGB, duration); emit setGlobalInputImage(_priority, imageRGB, duration);
emit setBufferImage("FlatBuffer", imageRGB);
} }
// send reply // send reply

View File

@ -54,6 +54,11 @@ signals:
/// ///
void setGlobalInputColor(int priority, const std::vector<ColorRgb> &ledColor, int timeout_ms, const QString& origin = "FlatBuffer" ,bool clearEffects = true); 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 /// @brief Emits whenever the client disconnected
/// ///

View File

@ -81,6 +81,7 @@ void FlatBufferServer::newConnection()
connect(client, &FlatBufferClient::clearGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::clearGlobalInput); connect(client, &FlatBufferClient::clearGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::clearGlobalInput);
connect(client, &FlatBufferClient::setGlobalInputImage, GlobalSignals::getInstance(), &GlobalSignals::setGlobalImage); connect(client, &FlatBufferClient::setGlobalInputImage, GlobalSignals::getInstance(), &GlobalSignals::setGlobalImage);
connect(client, &FlatBufferClient::setGlobalInputColor, GlobalSignals::getInstance(), &GlobalSignals::setGlobalColor); connect(client, &FlatBufferClient::setGlobalInputColor, GlobalSignals::getInstance(), &GlobalSignals::setGlobalColor);
connect(client, &FlatBufferClient::setBufferImage, GlobalSignals::getInstance(), &GlobalSignals::setBufferImage);
connect(GlobalSignals::getInstance(), &GlobalSignals::globalRegRequired, client, &FlatBufferClient::registationRequired); connect(GlobalSignals::getInstance(), &GlobalSignals::globalRegRequired, client, &FlatBufferClient::registationRequired);
_openConnections.append(client); _openConnections.append(client);
} }

View File

@ -107,13 +107,27 @@ void MessageForwarder::enableTargets(bool enable, const QJsonObject& config)
if (flatbufTargetNum > 0) if (flatbufTargetNum > 0)
{ {
hyperion::Components activeCompId = _hyperion->getPriorityInfo(_hyperion->getCurrentPriority()).componentId; 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); connect(_hyperion, &Hyperion::forwardSystemProtoMessage, this, &MessageForwarder::forwardFlatbufferMessage, Qt::UniqueConnection);
} break;
else if (activeCompId == hyperion::COMP_V4L) case hyperion::COMP_V4L:
{
connect(_hyperion, &Hyperion::forwardV4lProtoMessage, this, &MessageForwarder::forwardFlatbufferMessage, Qt::UniqueConnection); 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) if (priority != 0 && _forwarder_enabled)
{ {
hyperion::Components activeCompId = _hyperion->getPriorityInfo(priority).componentId; hyperion::Components activeCompId = _hyperion->getPriorityInfo(priority).componentId;
if (activeCompId == hyperion::COMP_GRABBER || activeCompId == hyperion::COMP_V4L)
{ switch (activeCompId) {
switch (activeCompId) case hyperion::COMP_GRABBER:
{ disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, nullptr, nullptr);
case hyperion::COMP_GRABBER: #if defined(ENABLE_FLATBUF_SERVER) || defined(ENABLE_PROTOBUF_SERVER)
{ disconnect(_hyperion, &Hyperion::forwardBufferMessage, nullptr, nullptr);
disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, nullptr, nullptr); #endif
connect(_hyperion, &Hyperion::forwardSystemProtoMessage, this, &MessageForwarder::forwardFlatbufferMessage, Qt::UniqueConnection); connect(_hyperion, &Hyperion::forwardSystemProtoMessage, this, &MessageForwarder::forwardFlatbufferMessage, Qt::UniqueConnection);
}
break; break;
case hyperion::COMP_V4L: case hyperion::COMP_V4L:
{ disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, nullptr, nullptr);
disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, nullptr, nullptr); #if defined(ENABLE_FLATBUF_SERVER) || defined(ENABLE_PROTOBUF_SERVER)
connect(_hyperion, &Hyperion::forwardV4lProtoMessage, this, &MessageForwarder::forwardFlatbufferMessage, Qt::UniqueConnection); disconnect(_hyperion, &Hyperion::forwardBufferMessage, nullptr, nullptr);
} #endif
connect(_hyperion, &Hyperion::forwardV4lProtoMessage, this, &MessageForwarder::forwardFlatbufferMessage, Qt::UniqueConnection);
break; break;
default: #if defined(ENABLE_FLATBUF_SERVER)
{ case hyperion::COMP_FLATBUFSERVER:
disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, nullptr, nullptr); #endif
disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, nullptr, nullptr); #if defined(ENABLE_PROTOBUF_SERVER)
} case hyperion::COMP_PROTOSERVER:
} #endif
} #if defined(ENABLE_FLATBUF_SERVER) || defined(ENABLE_PROTOBUF_SERVER)
else
{
disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, nullptr, nullptr); disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, nullptr, nullptr);
disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, 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::forwardSystemProtoMessage, nullptr, nullptr);
disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, 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) if (_messageForwarderFlatBufHelper != nullptr)
{ {

View File

@ -150,6 +150,9 @@ void Hyperion::start()
{ {
_messageForwarder = new MessageForwarder(this); _messageForwarder = new MessageForwarder(this);
_messageForwarder->handleSettingsUpdate(settings::NETFORWARD, getSetting(settings::NETFORWARD)); _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 #endif

File diff suppressed because it is too large Load Diff

View File

@ -279,7 +279,7 @@ int LedDeviceRazer::write(const std::vector<ColorRgb>& ledValues)
for (int col = 0; col < _maxColumn; col++) { for (int col = 0; col < _maxColumn; col++) {
int pos = row * _maxColumn + col; int pos = row * _maxColumn + col;
int bgrColor; 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; bgrColor = (ledValues[pos].red * 65536) + (ledValues[pos].green * 256) + ledValues[pos].blue;
} }

View File

@ -14,8 +14,6 @@
// Constants // Constants
namespace { namespace {
bool verbose = false;
const QChar ONE_SLASH = '/'; const QChar ONE_SLASH = '/';
const int HTTP_STATUS_NO_CONTENT = 204; const int HTTP_STATUS_NO_CONTENT = 204;

View File

@ -198,6 +198,7 @@ void ProtoClientConnection::handleImageCommand(const proto::ImageRequest &messag
} }
emit setGlobalInputImage(_priority, imageRGB, duration); emit setGlobalInputImage(_priority, imageRGB, duration);
emit setBufferImage("ProtoBuffer", imageRGB);
// send reply // send reply
sendSuccessReply(); sendSuccessReply();

View File

@ -56,6 +56,11 @@ signals:
/// ///
void setGlobalInputColor(int priority, const std::vector<ColorRgb> &ledColor, int timeout_ms, const QString& origin = "ProtoBuffer" ,bool clearEffects = true); 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 /// @brief Emits whenever the client disconnected
/// ///

View File

@ -80,6 +80,7 @@ void ProtoServer::newConnection()
connect(client, &ProtoClientConnection::clearGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::clearGlobalInput); connect(client, &ProtoClientConnection::clearGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::clearGlobalInput);
connect(client, &ProtoClientConnection::setGlobalInputImage, GlobalSignals::getInstance(), &GlobalSignals::setGlobalImage); connect(client, &ProtoClientConnection::setGlobalInputImage, GlobalSignals::getInstance(), &GlobalSignals::setGlobalImage);
connect(client, &ProtoClientConnection::setGlobalInputColor, GlobalSignals::getInstance(), &GlobalSignals::setGlobalColor); connect(client, &ProtoClientConnection::setGlobalInputColor, GlobalSignals::getInstance(), &GlobalSignals::setGlobalColor);
connect(client, &ProtoClientConnection::setBufferImage, GlobalSignals::getInstance(), &GlobalSignals::setBufferImage);
connect(GlobalSignals::getInstance(), &GlobalSignals::globalRegRequired, client, &ProtoClientConnection::registationRequired); connect(GlobalSignals::getInstance(), &GlobalSignals::globalRegRequired, client, &ProtoClientConnection::registationRequired);
_openConnections.append(client); _openConnections.append(client);
} }