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:
		@@ -575,7 +575,7 @@
 | 
			
		||||
    "edt_dev_spec_intervall_title": "Interval",
 | 
			
		||||
    "edt_dev_spec_invert_title": "Invert signal",
 | 
			
		||||
    "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_ledType_title": "LED Type",
 | 
			
		||||
    "edt_dev_spec_lightid_itemtitle": "ID",
 | 
			
		||||
 
 | 
			
		||||
@@ -78,11 +78,14 @@ private slots:
 | 
			
		||||
	///
 | 
			
		||||
	void forwardJsonMessage(const QJsonObject &message);
 | 
			
		||||
 | 
			
		||||
#if defined(ENABLE_FLATBUF_SERVER) || defined(ENABLE_PROTOBUF_SERVER)
 | 
			
		||||
	///
 | 
			
		||||
	/// @brief Forward image to all flatbuffer target hosts
 | 
			
		||||
	/// @param image The flatbuffer image to send
 | 
			
		||||
	///
 | 
			
		||||
	///
 | 
			
		||||
	void forwardFlatbufferMessage(const QString& name, const Image<ColorRgb> &image);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	///
 | 
			
		||||
	/// @brief Forward message to a single json target host
 | 
			
		||||
 
 | 
			
		||||
@@ -428,6 +428,11 @@ signals:
 | 
			
		||||
	/// Signal which is emitted, when a new V4l proto image should be forwarded
 | 
			
		||||
	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
 | 
			
		||||
	///
 | 
			
		||||
 
 | 
			
		||||
@@ -47,6 +47,15 @@ signals:
 | 
			
		||||
	///
 | 
			
		||||
	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
 | 
			
		||||
	/// @param[in] priority    The priority of the channel
 | 
			
		||||
 
 | 
			
		||||
@@ -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