implement proto forwarding for hyperiond internal v4l2 grabber

cleanup


Former-commit-id: 669f139386633e3435cdc33639134819464afd4d
This commit is contained in:
redpanther 2016-02-16 15:41:40 +01:00
parent 738bafee99
commit 629461b944
8 changed files with 62 additions and 40 deletions

View File

@ -44,6 +44,7 @@ public slots:
signals:
void emitColors(int priority, const std::vector<ColorRgb> &ledColors, const int timeout_ms);
void emitImage(int priority, const Image<ColorRgb> & image, const int timeout_ms);
private slots:
void newFrame(const Image<ColorRgb> & image);

View File

@ -27,7 +27,6 @@ public:
void addJsonSlave(std::string slave);
void addProtoSlave(std::string slave);
void sendMessage();
QStringList getProtoSlaves();
QList<MessageForwarder::JsonSlaveAddress> getJsonSlaves();

View File

@ -12,6 +12,10 @@
// Hyperion includes
#include <hyperion/Hyperion.h>
// hyperion includes
#include <utils/Image.h>
#include <utils/ColorRgb.h>
// forward decl
class ProtoClientConnection;
class ProtoConnection;
@ -43,6 +47,9 @@ public:
///
uint16_t getPort() const;
public slots:
void sendImageToProtoSlaves(int priority, const Image<ColorRgb> & image, int duration_ms);
private slots:
///
/// Slot which is called when a client tries to create a new connection

View File

@ -94,6 +94,9 @@ void V4L2Wrapper::newFrame(const Image<ColorRgb> &image)
// process the new image
_processor->process(image, _ledColors);
// forward to other hyperions
emit emitImage(_priority, image, _timeout_ms);
// send colors to Hyperion
emit emitColors(_priority, _ledColors, _timeout_ms);
}

View File

@ -6,7 +6,6 @@ SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/hyperion)
# Group the headers that go through the MOC compiler
SET(Hyperion_QT_HEADERS
${CURRENT_HEADER_DIR}/Hyperion.h
${CURRENT_HEADER_DIR}/MessageForwarder.h
${CURRENT_SOURCE_DIR}/LinearColorSmoothing.h
)
@ -19,6 +18,7 @@ SET(Hyperion_HEADERS
${CURRENT_HEADER_DIR}/PriorityMuxer.h
${CURRENT_SOURCE_DIR}/MultiColorTransform.h
${CURRENT_HEADER_DIR}/MessageForwarder.h
)
SET(Hyperion_SOURCES

View File

@ -35,10 +35,6 @@ void MessageForwarder::addProtoSlave(std::string slave)
_protoSlaves << QString(slave.c_str());
}
void MessageForwarder::sendMessage()
{
}
QStringList MessageForwarder::getProtoSlaves()
{
return _protoSlaves;

View File

@ -70,6 +70,12 @@ void ProtoServer::newMessage(const proto::HyperionRequest * message)
_proxy_connections.at(i)->sendMessage(*message);
}
void ProtoServer::sendImageToProtoSlaves(int priority, const Image<ColorRgb> & image, int duration_ms)
{
for (int i = 0; i < _proxy_connections.size(); ++i)
_proxy_connections.at(i)->setImage(image, priority, duration_ms);
}
void ProtoServer::closedConnection(ProtoClientConnection *connection)
{
std::cout << "Proto connection closed" << std::endl;

View File

@ -189,6 +189,39 @@ int main(int argc, char** argv)
std::cout << "XBMC video checker created and started" << std::endl;
}
// ---- network services -----
// Create Json server if configuration is present
JsonServer * jsonServer = nullptr;
if (config.isMember("jsonServer"))
{
const Json::Value & jsonServerConfig = config["jsonServer"];
jsonServer = new JsonServer(&hyperion, jsonServerConfig["port"].asUInt());
std::cout << "Json server created and started on port " << jsonServer->getPort() << std::endl;
}
#ifdef ENABLE_PROTOBUF
// Create Proto server if configuration is present
ProtoServer * protoServer = nullptr;
if (config.isMember("protoServer"))
{
const Json::Value & protoServerConfig = config["protoServer"];
protoServer = new ProtoServer(&hyperion, protoServerConfig["port"].asUInt() );
std::cout << "Proto server created and started on port " << protoServer->getPort() << std::endl;
}
#endif
// Create Boblight server if configuration is present
BoblightServer * boblightServer = nullptr;
if (config.isMember("boblightServer"))
{
const Json::Value & boblightServerConfig = config["boblightServer"];
boblightServer = new BoblightServer(&hyperion, boblightServerConfig["port"].asUInt());
std::cout << "Boblight server created and started on port " << boblightServer->getPort() << std::endl;
}
// ---- grabber -----
#ifdef ENABLE_DISPMANX
// Construct and start the frame-grabber if the configuration is present
DispmanxWrapper * dispmanx = nullptr;
@ -214,7 +247,7 @@ int main(int argc, char** argv)
#if !defined(ENABLE_OSX) && !defined(ENABLE_FB)
if (config.isMember("framegrabber"))
{
std::cerr << "The dispmanx framegrabber can not be instantiated, becuse it has been left out from the build" << std::endl;
std::cerr << "The dispmanx framegrabber can not be instantiated, because it has been left out from the build" << std::endl;
}
#endif
#endif
@ -246,14 +279,19 @@ int main(int argc, char** argv)
grabberConfig.get("cropTop", 0).asInt(),
grabberConfig.get("cropBottom", 0).asInt());
#ifdef ENABLE_PROTOBUF
QObject::connect(v4l2Grabber, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) );
#endif
v4l2Grabber->start();
std::cout << "V4l2 grabber created and started" << std::endl;
}
#else
if (config.isMember("grabber-v4l2"))
{
std::cerr << "The v4l2 grabber can not be instantiated, becuse it has been left out from the build" << std::endl;
std::cerr << "The v4l2 grabber can not be instantiated, because it has been left out from the build" << std::endl;
}
#endif
#ifdef ENABLE_AMLOGIC
@ -309,12 +347,12 @@ int main(int argc, char** argv)
#else
if (config.isMember("framebuffergrabber"))
{
std::cerr << "The framebuffer grabber can not be instantiated, becuse it has been left out from the build" << std::endl;
std::cerr << "The framebuffer grabber can not be instantiated, because it has been left out from the build" << std::endl;
}
#if !defined(ENABLE_DISPMANX) && !defined(ENABLE_OSX)
else if (config.isMember("framegrabber"))
{
std::cerr << "The framebuffer grabber can not be instantiated, becuse it has been left out from the build" << std::endl;
std::cerr << "The framebuffer grabber can not be instantiated, because it has been left out from the build" << std::endl;
}
#endif
#endif
@ -344,44 +382,16 @@ int main(int argc, char** argv)
#else
if (config.isMember("osxgrabber"))
{
std::cerr << "The osx grabber can not be instantiated, becuse it has been left out from the build" << std::endl;
std::cerr << "The osx grabber can not be instantiated, because it has been left out from the build" << std::endl;
}
#if !defined(ENABLE_DISPMANX) && !defined(ENABLE_FB)
else if (config.isMember("framegrabber"))
{
std::cerr << "The osx grabber can not be instantiated, becuse it has been left out from the build" << std::endl;
std::cerr << "The osx grabber can not be instantiated, because it has been left out from the build" << std::endl;
}
#endif
#endif
// Create Json server if configuration is present
JsonServer * jsonServer = nullptr;
if (config.isMember("jsonServer"))
{
const Json::Value & jsonServerConfig = config["jsonServer"];
jsonServer = new JsonServer(&hyperion, jsonServerConfig["port"].asUInt());
std::cout << "Json server created and started on port " << jsonServer->getPort() << std::endl;
}
#ifdef ENABLE_PROTOBUF
// Create Proto server if configuration is present
ProtoServer * protoServer = nullptr;
if (config.isMember("protoServer"))
{
const Json::Value & protoServerConfig = config["protoServer"];
protoServer = new ProtoServer(&hyperion, protoServerConfig["port"].asUInt() );
std::cout << "Proto server created and started on port " << protoServer->getPort() << std::endl;
}
#endif
// Create Boblight server if configuration is present
BoblightServer * boblightServer = nullptr;
if (config.isMember("boblightServer"))
{
const Json::Value & boblightServerConfig = config["boblightServer"];
boblightServer = new BoblightServer(&hyperion, boblightServerConfig["port"].asUInt());
std::cout << "Boblight server created and started on port " << boblightServer->getPort() << std::endl;
}
// run the application
int rc = app.exec();