Skip to content

Commit 3488738

Browse files
committed
Flatbuffers: custom LUT files
1 parent ba42c26 commit 3488738

File tree

9 files changed

+58
-12
lines changed

9 files changed

+58
-12
lines changed

Diff for: assets/webconfig/content/json_api.html

+8-4
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,14 @@ <h4 class="bs-main-text" data-i18n="conf_helptable_expl">Explanation</h4>
369369
<input class="form-check-input" type="radio" name="hdrModeState" id="hdr_on_mode" value="1">
370370
<label class="form-check-label" for="hdr_on_mode" data-i18n="general_btn_on"></label>
371371
</div>
372-
<div class="form-check">
373-
<input class="form-check-input" type="radio" name="hdrModeState" id="hdr_border_mode" value="2">
374-
<label class="form-check-label" for="hdr_border_mode" data-i18n="general_mode_border"></label>
375-
</div>
372+
</div>
373+
</div>
374+
<div class="row mt-1">
375+
<div class="col-8 text-start">
376+
<div class="input-group">
377+
<span class="input-group-text mb-1" data-i18n="json_api_flatbuffers_user_lut"></span>
378+
<input class="form-control mb-1" type="text" id="flatbuffersUserLut">
379+
</div>
376380
</div>
377381
</div>
378382
</div>

Diff for: assets/webconfig/i18n/en.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1120,8 +1120,7 @@
11201120
"json_api_effect_color_expl" : "Set desired color or effect for the active instance.",
11211121
"json_api_clear" : "Clear a priority",
11221122
"json_api_clear_expl" : "Clear priority from effects and preset colors.",
1123-
"json_api_hdr" : "HDR mode",
1124-
"json_api_hdr_expl" : "Turn on/off HDR tone mapping for USB grabber. 'Border mode' works only for MJPEG stream.",
1123+
"json_api_hdr" : "HDR mode",
11251124
"json_api_components_expl_multi":"You can run multiple commands with just one link. Maximum lenght is 2048 chars. They all will be executed but you will receive only one response (check out logs for all the output). Just put your links' <code>request</code> content into the format (note first '?' char and next '&' chars):<br><code>http://IP:PORT/json-rpc?request=request1&request=request2&request=request3...</code>",
11261125
"edt_conf_stream_autoResume_title" : "Auto resume",
11271126
"edt_conf_stream_autoResume_expl" : "Try restarting video capture if the video stream stops. Use with caution as it is not a cure for hardware problems of the grabber.",
@@ -1176,5 +1175,7 @@
11761175
"edt_conf_mqtt_is_ssl_title" : "SSL",
11771176
"edt_conf_mqtt_is_ssl_expl" : "Use SSL protocol",
11781177
"edt_conf_mqtt_ssl_ignore_errors_title" : "Ignore SSL errors",
1179-
"edt_conf_mqtt_ssl_ignore_errors_expl" : "Ignore all SSL errors such as self-signed certificates etc. Use with caution."
1178+
"edt_conf_mqtt_ssl_ignore_errors_expl" : "Ignore all SSL errors such as self-signed certificates etc. Use with caution.",
1179+
"json_api_flatbuffers_user_lut" : "Flatbuffers LUT filename",
1180+
"json_api_hdr_expl" : "Turn on/off HDR tone mapping. You can also pass the name of the user LUT file in the user HyperHDR home folder to be used for Flatbuffers tone mapping."
11801181
}

Diff for: assets/webconfig/js/json_api.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -515,26 +515,28 @@ function BuildClearJson()
515515
var componentHdr =
516516
`{
517517
"command":"videomodehdr",
518-
"HDR":{0}
518+
"HDR":{0},
519+
"flatbuffers_user_lut_filename":"{1}"
519520
}`;
520521

521-
$('input[name="hdrModeState"]').change(
522+
$('input[name="hdrModeState"], #flatbuffersUserLut').change(
522523
function(){
523524
if ($("input[name='hdrModeState']:checked").val())
524525
{
525526
BuildHdrJson();
526527
}
527528
});
528-
529529

530530
function BuildHdrJson()
531531
{
532532
$('button[name="hdrModeButtons"]').each(function(i, obj) {
533533
$(this).removeClass('disabled');
534534
});
535535

536-
var state = $('input[name="hdrModeState"]:checked').val();
537-
var finJson = componentHdr.replace("{0}", state);
536+
var state = $('input[name="hdrModeState"]:checked').val();
537+
var flatbufferUserLut = $('#flatbuffersUserLut').val();
538+
var finJson = componentHdr.replace("{0}", state).replace("{1}", flatbufferUserLut);
539+
538540
$("#hdrMode_json").html(finJson);
539541
}
540542
////////////////////////////////////////////////////////////////////////////////

Diff for: include/api/API.h

+6
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ class API : public QObject
124124
///
125125
void setVideoModeHdr(int hdr, hyperhdr::Components callerComp = hyperhdr::COMP_INVALID);
126126

127+
///
128+
/// @brief Set user LUT filename for flatbuffers tone mapping
129+
/// @param userLUTfile user LUT filename
130+
///
131+
void setFlatbufferUserLUT(QString userLUTfile);
132+
127133
///
128134
/// @brief Set an effect
129135
/// @param dat The effect data

Diff for: include/flatbufserver/FlatBufferServer.h

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public slots:
4444

4545
void initServer();
4646

47+
void setUserLut(QString filename);
48+
4749
void setHdrToneMappingEnabled(int mode);
4850

4951
int getHdrToneMappingEnabled();
@@ -105,4 +107,5 @@ private slots:
105107
uint8_t* _lutBuffer;
106108
bool _lutBufferInit;
107109
QString _configurationPath;
110+
QString _userLutFile;
108111
};

Diff for: sources/api/API.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,12 @@ void API::setVideoModeHdr(int hdr, hyperhdr::Components callerComp)
245245
QMetaObject::invokeMethod(FlatBufferServer::getInstance(), "setHdrToneMappingEnabled", Qt::QueuedConnection, Q_ARG(int, hdr));
246246
}
247247

248+
void API::setFlatbufferUserLUT(QString userLUTfile)
249+
{
250+
if (FlatBufferServer::getInstance() != nullptr)
251+
QMetaObject::invokeMethod(FlatBufferServer::getInstance(), "setUserLut", Qt::QueuedConnection, Q_ARG(QString, userLUTfile));
252+
}
253+
248254
bool API::setEffect(const EffectCmdData& dat, hyperhdr::Components callerComp)
249255
{
250256
int res;

Diff for: sources/api/JSONRPC_schema/schema-videomodehdr.json

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
"minimum" : 0,
1616
"maximum" : 2,
1717
"required": true
18+
},
19+
"flatbuffers_user_lut_filename": {
20+
"type" : "string",
21+
"required": false
1822
}
1923
},
2024
"additionalProperties": false

Diff for: sources/api/JsonAPI.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,11 @@ void JsonAPI::handleProcessingCommand(const QJsonObject& message, const QString&
12881288

12891289
void JsonAPI::handleVideoModeHdrCommand(const QJsonObject& message, const QString& command, int tan)
12901290
{
1291+
if (message.contains("flatbuffers_user_lut_filename"))
1292+
{
1293+
API::setFlatbufferUserLUT(message["flatbuffers_user_lut_filename"].toString(""));
1294+
}
1295+
12911296
API::setVideoModeHdr(message["HDR"].toInt());
12921297
sendSuccessReply(command, tan);
12931298
}

Diff for: sources/flatbufserver/FlatBufferServer.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ FlatBufferServer::FlatBufferServer(const QJsonDocument& config, const QString& c
3535
, _lutBuffer(nullptr)
3636
, _lutBufferInit(false)
3737
, _configurationPath(configurationPath)
38+
, _userLutFile("")
3839
{
3940
FlatBufferServer::instance = this;
4041
}
@@ -240,6 +241,13 @@ void FlatBufferServer::loadLutFile()
240241
files.append(fileName3);
241242
#endif
242243

244+
if (!_userLutFile.isEmpty())
245+
{
246+
QString userFile = QString("%1/%2").arg(_configurationPath).arg(_userLutFile);
247+
files.prepend(userFile);
248+
Debug(_log, "Adding user LUT file for searching: %s", QSTRING_CSTR(userFile));
249+
}
250+
243251
_lutBufferInit = false;
244252

245253
if (_hdrToneMappingMode)
@@ -295,3 +303,10 @@ void FlatBufferServer::importFromProtoHandler(int priority, int duration, const
295303

296304
emit GlobalSignals::getInstance()->setGlobalImage(priority, image, duration);
297305
}
306+
307+
void FlatBufferServer::setUserLut(QString filename)
308+
{
309+
_userLutFile = filename.replace("~", "").replace("/","").replace("..", "");
310+
311+
Info(_log, "Setting user LUT filename to: '%s'", QSTRING_CSTR(_userLutFile));
312+
}

0 commit comments

Comments
 (0)