mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Flatbuffer, Forwarder
- Flatbuffer now only sends data if priority registration was successful - Forwarder no longer needs to worry about registering the priority
This commit is contained in:
parent
657fe00211
commit
5cc353468d
@ -512,7 +512,7 @@
|
||||
"edt_conf_fw_json_expl": "Jeden z cílů na jeden řádek. Obsahuje IP:PORT (Příklad: 127.0.0.1:19446)",
|
||||
"edt_conf_fw_json_itemtitle": "Json cíl",
|
||||
"edt_conf_fw_proto_title": "Seznam proto klientů",
|
||||
"edt_conf_fw_proto_expl": "Jeden cíl na každý řádek. Obsahuje IP:PORT (Příklad: 127.0.0.1:19447)",
|
||||
"edt_conf_fw_proto_expl": "Jeden cíl na každý řádek. Obsahuje IP:PORT (Příklad: 127.0.0.1:19401)",
|
||||
"edt_conf_fw_proto_itemtitle": "Proto cíl",
|
||||
"edt_conf_js_heading_title": "JSON Server",
|
||||
"edt_conf_ps_heading_title": "PROTO Server",
|
||||
@ -753,4 +753,4 @@
|
||||
"edt_conf_enum_SECAM": "SECAM",
|
||||
"general_speech_it": "Italština",
|
||||
"general_speech_cs": "Czech"
|
||||
}
|
||||
}
|
||||
|
@ -561,7 +561,7 @@
|
||||
"edt_conf_fw_json_expl" : "Ein Json Ziel pro Zeile. Bestehend aus IP:PORT (Beispiel: 127.0.0.1:19446)",
|
||||
"edt_conf_fw_json_itemtitle" : "Json Ziel",
|
||||
"edt_conf_fw_proto_title" : "Liste von Proto zielen",
|
||||
"edt_conf_fw_proto_expl" : "Ein Proto Ziel pro Zeile. Bestehend aus IP:PORT (Beispiel: 127.0.0.1:19447)",
|
||||
"edt_conf_fw_proto_expl" : "Ein Proto Ziel pro Zeile. Bestehend aus IP:PORT (Beispiel: 127.0.0.1:19401)",
|
||||
"edt_conf_fw_proto_itemtitle" : "Proto Ziel",
|
||||
"edt_conf_js_heading_title" : "JSON Server",
|
||||
"edt_conf_fbs_heading_title" : "Flatbuffers Server",
|
||||
|
@ -562,7 +562,7 @@
|
||||
"edt_conf_fw_json_expl" : "One json target per line. Contains IP:PORT (Example: 127.0.0.1:19446)",
|
||||
"edt_conf_fw_json_itemtitle" : "Json target",
|
||||
"edt_conf_fw_proto_title" : "List of proto clients",
|
||||
"edt_conf_fw_proto_expl" : "One proto target per line. Contains IP:PORT (Example: 127.0.0.1:19447)",
|
||||
"edt_conf_fw_proto_expl" : "One proto target per line. Contains IP:PORT (Example: 127.0.0.1:19401)",
|
||||
"edt_conf_fw_proto_itemtitle" : "Proto target",
|
||||
"edt_conf_js_heading_title" : "JSON Server",
|
||||
"edt_conf_fbs_heading_title" : "Flatbuffers Server",
|
||||
|
@ -512,7 +512,7 @@
|
||||
"edt_conf_fw_json_expl": "Una destinazione json per riga. Contiene IP:PORTA:(Esempio: 127.0.0.1:19446)",
|
||||
"edt_conf_fw_json_itemtitle": "Destinatario json",
|
||||
"edt_conf_fw_proto_title": "Lista dei client proto",
|
||||
"edt_conf_fw_proto_expl": "Una destinazione proto per riga. Contiene IP:PORTA:(Esempio: 127.0.0.1:19447)",
|
||||
"edt_conf_fw_proto_expl": "Una destinazione proto per riga. Contiene IP:PORTA:(Esempio: 127.0.0.1:19401)",
|
||||
"edt_conf_fw_proto_itemtitle": "Destinatario proto",
|
||||
"edt_conf_js_heading_title": "Server JSON",
|
||||
"edt_conf_ps_heading_title": "Server PROTO",
|
||||
@ -753,4 +753,4 @@
|
||||
"edt_conf_enum_SECAM": "SECAM",
|
||||
"general_speech_it": "Italiano",
|
||||
"general_speech_cs": "Czech"
|
||||
}
|
||||
}
|
||||
|
@ -216,14 +216,14 @@
|
||||
/// The configuration of the Json/Proto forwarder. Forward messages to multiple instances of Hyperion on same and/or other hosts
|
||||
/// 'proto' is mostly used for video streams and 'json' for effects
|
||||
/// * enable : Enable or disable the forwarder (true/false)
|
||||
/// * proto : Proto server adress and port of your target. Syntax:[IP:PORT] -> ["127.0.0.1:19447"] or more instances to forward ["127.0.0.1:19447","192.168.0.24:19449"]
|
||||
/// * proto : Proto server adress and port of your target. Syntax:[IP:PORT] -> ["127.0.0.1:19401"] or more instances to forward ["127.0.0.1:19401","192.168.0.24:19403"]
|
||||
/// * json : Json server adress and port of your target. Syntax:[IP:PORT] -> ["127.0.0.1:19446"] or more instances to forward ["127.0.0.1:19446","192.168.0.24:19448"]
|
||||
/// HINT:If you redirect to "127.0.0.1" (localhost) you could start a second hyperion with another device/led config!
|
||||
/// Be sure your client(s) is/are listening on the configured ports. The second Hyperion (if used) also needs to be configured! (HyperCon -> External -> Json Server/Proto Server)
|
||||
/// Be sure your client(s) is/are listening on the configured ports. The second Hyperion (if used) also needs to be configured! (WebUI -> Settings Level (Expert) -> Configuration -> Network Services -> Forwarder)
|
||||
"forwarder" :
|
||||
{
|
||||
"enable" : false,
|
||||
"proto" : ["127.0.0.1:19447"],
|
||||
"proto" : ["127.0.0.1:19401"],
|
||||
"json" : ["127.0.0.1:19446"]
|
||||
},
|
||||
|
||||
|
@ -123,7 +123,7 @@
|
||||
{
|
||||
"enable" : false,
|
||||
"json" : ["127.0.0.1:19446"],
|
||||
"proto" : ["127.0.0.1:19447"]
|
||||
"proto" : ["127.0.0.1:19401"]
|
||||
},
|
||||
|
||||
"jsonServer" :
|
||||
|
@ -111,6 +111,12 @@ void FlatBufferClient::handleRegisterCommand(const hyperionnet::Register *regReq
|
||||
{
|
||||
_priority = regReq->priority();
|
||||
_hyperion->registerInput(_priority, hyperion::COMP_FLATBUFSERVER, regReq->origin()->c_str()+_clientAddress);
|
||||
|
||||
auto reply = hyperionnet::CreateReplyDirect(_builder, nullptr, -1, (_priority ? _priority : -1));
|
||||
_builder.Finish(reply);
|
||||
|
||||
// send reply
|
||||
sendMessage();
|
||||
}
|
||||
|
||||
void FlatBufferClient::handleImageCommand(const hyperionnet::Image *image)
|
||||
|
@ -95,7 +95,19 @@ void FlatBufferConnection::setRegister(const QString& origin, int priority)
|
||||
auto req = hyperionnet::CreateRequest(_builder, hyperionnet::Command_Register, registerReq.Union());
|
||||
|
||||
_builder.Finish(req);
|
||||
sendMessage(_builder.GetBufferPointer(), _builder.GetSize());
|
||||
uint32_t size = _builder.GetSize();
|
||||
const uint8_t header[] = {
|
||||
uint8_t((size >> 24) & 0xFF),
|
||||
uint8_t((size >> 16) & 0xFF),
|
||||
uint8_t((size >> 8) & 0xFF),
|
||||
uint8_t((size ) & 0xFF)};
|
||||
|
||||
// write message
|
||||
int count = 0;
|
||||
count += _socket.write(reinterpret_cast<const char *>(header), 4);
|
||||
count += _socket.write(reinterpret_cast<const char *>(_builder.GetBufferPointer()), size);
|
||||
_socket.flush();
|
||||
_builder.Clear();
|
||||
}
|
||||
|
||||
void FlatBufferConnection::setColor(const ColorRgb & color, int priority, int duration)
|
||||
@ -136,10 +148,7 @@ void FlatBufferConnection::connectToHost()
|
||||
{
|
||||
// try connection only when
|
||||
if (_socket.state() == QAbstractSocket::UnconnectedState)
|
||||
{
|
||||
_socket.connectToHost(_host, _port);
|
||||
//_socket.waitForConnected(1000);
|
||||
}
|
||||
}
|
||||
|
||||
void FlatBufferConnection::sendMessage(const uint8_t* buffer, uint32_t size)
|
||||
@ -147,19 +156,17 @@ void FlatBufferConnection::sendMessage(const uint8_t* buffer, uint32_t size)
|
||||
// print out connection message only when state is changed
|
||||
if (_socket.state() != _prevSocketState )
|
||||
{
|
||||
_registered = false;
|
||||
switch (_socket.state() )
|
||||
{
|
||||
case QAbstractSocket::UnconnectedState:
|
||||
Info(_log, "No connection to Hyperion: %s:%d", _host.toStdString().c_str(), _port);
|
||||
_registered = false;
|
||||
break;
|
||||
case QAbstractSocket::ConnectedState:
|
||||
Info(_log, "Connected to Hyperion: %s:%d", _host.toStdString().c_str(), _port);
|
||||
_registered = false;
|
||||
break;
|
||||
default:
|
||||
Debug(_log, "Connecting to Hyperion: %s:%d", _host.toStdString().c_str(), _port);
|
||||
_registered = false;
|
||||
break;
|
||||
}
|
||||
_prevSocketState = _socket.state();
|
||||
@ -171,7 +178,6 @@ void FlatBufferConnection::sendMessage(const uint8_t* buffer, uint32_t size)
|
||||
|
||||
if(!_registered)
|
||||
{
|
||||
_registered = true;
|
||||
setRegister(_origin, _priority);
|
||||
return;
|
||||
}
|
||||
@ -194,14 +200,22 @@ bool FlatBufferConnection::parseReply(const hyperionnet::Reply *reply)
|
||||
{
|
||||
if (!reply->error())
|
||||
{
|
||||
// no error set must be a success or video
|
||||
// no error set must be a success or registered or video
|
||||
const auto videoMode = reply->video();
|
||||
const auto registered = reply->registered();
|
||||
if (videoMode != -1) {
|
||||
// We got a video reply.
|
||||
emit setVideoMode(static_cast<VideoMode>(videoMode));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// We got a registered reply.
|
||||
if (registered != -1 && registered != _priority)
|
||||
_registered = false;
|
||||
else
|
||||
_registered = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ namespace hyperionnet;
|
||||
table Reply {
|
||||
error:string;
|
||||
video:int = -1;
|
||||
registered:int = -1;
|
||||
}
|
||||
|
||||
root_type Reply;
|
||||
|
@ -98,7 +98,7 @@ void MessageForwarder::componentStateChanged(const hyperion::Components componen
|
||||
{
|
||||
_forwarder_enabled = enable;
|
||||
handleSettingsUpdate(settings::NETFORWARD, _hyperion->getSetting(settings::NETFORWARD));
|
||||
Info(_log, "Message Forwarder change state to %s", (_forwarder_enabled ? "enabled" : "disabled"));
|
||||
Info(_log, "Forwarder change state to %s", (_forwarder_enabled ? "enabled" : "disabled"));
|
||||
_hyperion->getComponentRegister().componentStateChanged(component, _forwarder_enabled);
|
||||
}
|
||||
}
|
||||
@ -187,7 +187,7 @@ void MessageForwarder::addProtoSlave(QString slave)
|
||||
if (_forwarder_enabled)
|
||||
{
|
||||
_protoSlaves << slave;
|
||||
FlatBufferConnection* flatbuf = new FlatBufferConnection("Message Forwarder", slave.toLocal8Bit().constData(), _priority, true);
|
||||
FlatBufferConnection* flatbuf = new FlatBufferConnection("Forwarder", slave.toLocal8Bit().constData(), _priority, false);
|
||||
_forwardClients << flatbuf;
|
||||
}
|
||||
}
|
||||
@ -215,10 +215,7 @@ void MessageForwarder::forwardProtoMessage(const Image<ColorRgb> &image)
|
||||
if (_forwarder_enabled)
|
||||
{
|
||||
for (int i=0; i < _forwardClients.size(); i++)
|
||||
{
|
||||
_forwardClients.at(i)->setRegister("Message Forwarder", _priority);
|
||||
_forwardClients.at(i)->setImage(image);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ int main(int argc, char ** argv)
|
||||
IntOption & argWidth = parser.add<IntOption> (0x0, "width", "Width of the captured image [default: %1]", "160", 160, 4096);
|
||||
IntOption & argHeight = parser.add<IntOption> (0x0, "height", "Height of the captured image [default: %1]", "160", 160, 4096);
|
||||
BooleanOption & argScreenshot = parser.add<BooleanOption>(0x0, "screenshot", "Take a single screenshot, save it to file and quit");
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19445");
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
|
||||
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
|
||||
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
|
||||
BooleanOption & argHelp = parser.add<BooleanOption>('h', "help", "Show this help message and exit");
|
||||
|
@ -41,7 +41,7 @@ int main(int argc, char ** argv)
|
||||
IntOption & argHeight = parser.add<IntOption> (0x0, "height", "Height of the captured image [default: %1]", "64", 64);
|
||||
|
||||
BooleanOption & argScreenshot = parser.add<BooleanOption>(0x0, "screenshot", "Take a single screenshot, save it to file and quit");
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19445");
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
|
||||
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
|
||||
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
|
||||
BooleanOption & argHelp = parser.add<BooleanOption>('h', "help", "Show this help message and exit");
|
||||
|
@ -33,7 +33,7 @@ int main(int argc, char ** argv)
|
||||
IntOption & argWidth = parser.add<IntOption> (0x0, "width", "Width of the captured image [default: %1]", "160", 160);
|
||||
IntOption & argHeight = parser.add<IntOption> (0x0, "height", "Height of the captured image [default: %1]", "160", 160);
|
||||
BooleanOption & argScreenshot = parser.add<BooleanOption>(0x0, "screenshot", "Take a single screenshot, save it to file and quit");
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19445");
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
|
||||
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
|
||||
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
|
||||
BooleanOption & argHelp = parser.add<BooleanOption>('h', "help", "Show this help message and exit");
|
||||
|
@ -35,7 +35,7 @@ int main(int argc, char ** argv)
|
||||
IntOption & argWidth = parser.add<IntOption> (0x0, "width", "Width of the captured image [default: %1]", "160", 160);
|
||||
IntOption & argHeight = parser.add<IntOption> (0x0, "height", "Height of the captured image [default: %1]", "160", 160);
|
||||
BooleanOption & argScreenshot = parser.add<BooleanOption>(0x0, "screenshot", "Take a single screenshot, save it to file and quit");
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19445");
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
|
||||
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
|
||||
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
|
||||
BooleanOption & argHelp = parser.add<BooleanOption>('h', "help", "Show this help message and exit");
|
||||
|
@ -42,7 +42,7 @@ int main(int argc, char ** argv)
|
||||
IntOption & argCropBottom = parser.add<IntOption> (0x0, "crop-bottom", "Number of pixels to crop from the bottom of the picture before decimation (overrides --crop-height)");
|
||||
IntOption & argSizeDecimation = parser.add<IntOption> ('s', "size-decimator", "Decimation factor for the output image size [default=%1]", "8", 1);
|
||||
BooleanOption & argScreenshot = parser.add<BooleanOption>(0x0, "screenshot", "Take a single screenshot, save it to file and quit");
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19445");
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
|
||||
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
|
||||
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
|
||||
BooleanOption & argHelp = parser.add<BooleanOption>('h', "help", "Show this help message and exit");
|
||||
|
@ -83,7 +83,7 @@ int main(int argc, char** argv)
|
||||
|
||||
BooleanOption & arg3DSBS = parser.add<BooleanOption>(0x0, "3DSBS", "Interpret the incoming video stream as 3D side-by-side");
|
||||
BooleanOption & arg3DTAB = parser.add<BooleanOption>(0x0, "3DTAB", "Interpret the incoming video stream as 3D top-and-bottom");
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19445");
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
|
||||
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
|
||||
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
|
||||
BooleanOption & argHelp = parser.add<BooleanOption>('h', "help", "Show this help message and exit");
|
||||
|
@ -44,7 +44,7 @@ int main(int argc, char ** argv)
|
||||
IntOption & argCropBottom = parser.add<IntOption> (0x0, "crop-bottom", "Number of pixels to crop from the bottom of the picture before decimation (overrides --crop-height)");
|
||||
IntOption & argSizeDecimation = parser.add<IntOption> ('s', "size-decimator", "Decimation factor for the output size [default=%1]", "8", 1);
|
||||
BooleanOption & argScreenshot = parser.add<BooleanOption>(0x0, "screenshot", "Take a single screenshot, save it to file and quit");
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19445");
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
|
||||
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
|
||||
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
|
||||
BooleanOption & argHelp = parser.add<BooleanOption>('h', "help", "Show this help message and exit");
|
||||
|
Loading…
Reference in New Issue
Block a user