diff --git a/include/flatbufserver/FlatBufferServer.h b/include/flatbufserver/FlatBufferServer.h index 0be8d32f4..b34b7094e 100644 --- a/include/flatbufserver/FlatBufferServer.h +++ b/include/flatbufserver/FlatBufferServer.h @@ -31,6 +31,7 @@ class FlatBufferServer : public QObject signals: void hdrToneMappingChanged(int mode, uint8_t* lutBuffer); + void HdrChanged(int mode); public slots: /// @@ -44,6 +45,8 @@ public slots: void setHdrToneMappingEnabled(int mode); + int getHdrToneMappingEnabled(); + private slots: /// /// @brief Is called whenever a new socket wants to connect @@ -94,8 +97,9 @@ private slots: QVector _openConnections; // tone mapping - int _hdrToneMappingMode; - uint8_t* _lutBuffer; - bool _lutBufferInit; - QString _configurationPath; + int _hdrToneMappingMode; + int _realHdrToneMappingMode; + uint8_t* _lutBuffer; + bool _lutBufferInit; + QString _configurationPath; }; diff --git a/sources/api/JsonAPI.cpp b/sources/api/JsonAPI.cpp index 3b576cbe6..f8b923f35 100644 --- a/sources/api/JsonAPI.cpp +++ b/sources/api/JsonAPI.cpp @@ -46,6 +46,8 @@ // auth manager #include +#include + using namespace hyperhdr; JsonAPI::JsonAPI(QString peerAddress, Logger* log, bool localConnection, QObject* parent, bool noListener) @@ -562,7 +564,10 @@ void JsonAPI::handleServerInfoCommand(const QJsonObject& message, const QString& } else { - info["videomodehdr"] = 0; + if (FlatBufferServer::getInstance() != nullptr) + info["videomodehdr"] = FlatBufferServer::getInstance()->getHdrToneMappingEnabled(); + else + info["videomodehdr"] = 0; } // get available components diff --git a/sources/api/JsonCB.cpp b/sources/api/JsonCB.cpp index 428300d94..c095366b7 100644 --- a/sources/api/JsonCB.cpp +++ b/sources/api/JsonCB.cpp @@ -32,6 +32,8 @@ // Image to led map helper #include +#include + using namespace hyperhdr; JsonCB::JsonCB(QObject* parent) @@ -126,6 +128,14 @@ bool JsonCB::subscribeFor(const QString& type, bool unsubscribe) connect(GrabberWrapper::instance, &GrabberWrapper::HdrChanged, this, &JsonCB::handleVideoModeHdrChange, Qt::UniqueConnection); } + if (type == "videomodehdr-update" && GrabberWrapper::instance == nullptr && FlatBufferServer::instance != nullptr) + { + if (unsubscribe) + disconnect(FlatBufferServer::instance, &FlatBufferServer::HdrChanged, this, &JsonCB::handleVideoModeHdrChange); + else + connect(FlatBufferServer::instance, &FlatBufferServer::HdrChanged, this, &JsonCB::handleVideoModeHdrChange, Qt::UniqueConnection); + } + if (type == "effects-update") { if (unsubscribe) diff --git a/sources/flatbufserver/FlatBufferServer.cpp b/sources/flatbufserver/FlatBufferServer.cpp index cf8c66247..5b8b668be 100644 --- a/sources/flatbufserver/FlatBufferServer.cpp +++ b/sources/flatbufserver/FlatBufferServer.cpp @@ -32,7 +32,8 @@ FlatBufferServer::FlatBufferServer(const QJsonDocument& config, const QString& c , _log(Logger::getInstance("FLATBUFSERVER")) , _timeout(5000) , _config(config) - , _hdrToneMappingMode(false) + , _hdrToneMappingMode(0) + , _realHdrToneMappingMode(0) , _lutBuffer(nullptr) , _lutBufferInit(false) , _configurationPath(configurationPath) @@ -71,13 +72,27 @@ void FlatBufferServer::initServer() void FlatBufferServer::setHdrToneMappingEnabled(int mode) { - bool status = _hdrToneMappingMode && mode; + bool status = (_hdrToneMappingMode != 0) && (mode != 0); if (status) loadLutFile(); + _realHdrToneMappingMode = (_lutBufferInit && status) ? mode : 0; + // inform clients - emit hdrToneMappingChanged((_lutBufferInit && status)?mode :0, _lutBuffer); + emit hdrToneMappingChanged(_realHdrToneMappingMode, _lutBuffer); + + +#if !defined(ENABLE_MF) && !defined(ENABLE_AVF) && !defined(ENABLE_V4L2) + emit HdrChanged(_realHdrToneMappingMode); + emit HyperHdrIManager::getInstance()->setNewComponentStateToAllInstances(hyperhdr::Components::COMP_HDR, (_realHdrToneMappingMode != 0)); +#endif + +} + +int FlatBufferServer::getHdrToneMappingEnabled() +{ + return _realHdrToneMappingMode; } void FlatBufferServer::handleSettingsUpdate(settings::type type, const QJsonDocument& config) @@ -100,10 +115,6 @@ void FlatBufferServer::handleSettingsUpdate(settings::type type, const QJsonDocu setHdrToneMappingEnabled(_hdrToneMappingMode); -#if !defined(ENABLE_MF) && !defined(ENABLE_AVF) && !defined(ENABLE_V4L2) - emit HyperHdrIManager::getInstance()->setNewComponentStateToAllInstances(hyperhdr::Components::COMP_HDR, (_hdrToneMappingMode != 0)); -#endif - // new timeout just for new connections _timeout = obj["timeout"].toInt(5000); // enable check