mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Implemented a method to receive and store a snapshot of the current image via JSON.
This commit is contained in:
parent
dd81a23dfc
commit
b9a72c8b49
@ -285,6 +285,11 @@ private:
|
|||||||
///
|
///
|
||||||
void handleSystemCommand(const QJsonObject &message, const JsonApiCommand& cmd);
|
void handleSystemCommand(const QJsonObject &message, const JsonApiCommand& cmd);
|
||||||
|
|
||||||
|
/// @brief Handle an incoming JSON message for actions related to the current image
|
||||||
|
/// @param message the incoming message
|
||||||
|
///
|
||||||
|
void handleGetCurrentImageCommand(const QJsonObject &message, const JsonApiCommand& cmd);
|
||||||
|
|
||||||
void applyColorAdjustments(const QJsonObject &adjustment, ColorAdjustment *colorAdjustment);
|
void applyColorAdjustments(const QJsonObject &adjustment, ColorAdjustment *colorAdjustment);
|
||||||
void applyColorAdjustment(const QString &colorName, const QJsonObject &adjustment, RgbChannelAdjustment &rgbAdjustment);
|
void applyColorAdjustment(const QString &colorName, const QJsonObject &adjustment, RgbChannelAdjustment &rgbAdjustment);
|
||||||
void applyGammaTransform(const QString &transformName, const QJsonObject &adjustment, RgbTransform &rgbTransform, char channel);
|
void applyGammaTransform(const QString &transformName, const QJsonObject &adjustment, RgbTransform &rgbTransform, char channel);
|
||||||
@ -403,5 +408,4 @@ private:
|
|||||||
|
|
||||||
// The JsonCallbacks instance which handles data subscription/notifications
|
// The JsonCallbacks instance which handles data subscription/notifications
|
||||||
QSharedPointer<JsonCallbacks> _jsonCB;
|
QSharedPointer<JsonCallbacks> _jsonCB;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -34,7 +34,8 @@ public:
|
|||||||
System,
|
System,
|
||||||
Temperature,
|
Temperature,
|
||||||
Transform,
|
Transform,
|
||||||
VideoMode
|
VideoMode,
|
||||||
|
GetCurrentImage
|
||||||
};
|
};
|
||||||
|
|
||||||
static QString toString(Type type) {
|
static QString toString(Type type) {
|
||||||
@ -65,6 +66,7 @@ public:
|
|||||||
case Transform: return "transform";
|
case Transform: return "transform";
|
||||||
case VideoMode: return "videomode";
|
case VideoMode: return "videomode";
|
||||||
case Service: return "service";
|
case Service: return "service";
|
||||||
|
case GetCurrentImage: return "getcurrentimage";
|
||||||
default: return "unknown";
|
default: return "unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +324,8 @@ public:
|
|||||||
{ {"system", "toggleIdle"}, { Command::System, SubCommand::ToggleIdle, Authorization::Yes, InstanceCmd::No, NoListenerCmd::Yes} },
|
{ {"system", "toggleIdle"}, { Command::System, SubCommand::ToggleIdle, Authorization::Yes, InstanceCmd::No, NoListenerCmd::Yes} },
|
||||||
{ {"temperature", ""}, { Command::Temperature, SubCommand::Empty, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} },
|
{ {"temperature", ""}, { Command::Temperature, SubCommand::Empty, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} },
|
||||||
{ {"transform", ""}, { Command::Transform, SubCommand::Empty, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} },
|
{ {"transform", ""}, { Command::Transform, SubCommand::Empty, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} },
|
||||||
{ {"videomode", ""}, { Command::VideoMode, SubCommand::Empty, Authorization::Yes, InstanceCmd::No, NoListenerCmd::Yes} }
|
{ {"videomode", ""}, { Command::VideoMode, SubCommand::Empty, Authorization::Yes, InstanceCmd::No, NoListenerCmd::Yes} },
|
||||||
|
{ {"getcurrentimage", ""}, { Command::GetCurrentImage, SubCommand::Empty, Authorization::Yes, InstanceCmd::No, NoListenerCmd::Yes} }
|
||||||
};
|
};
|
||||||
return commandLookup;
|
return commandLookup;
|
||||||
}
|
}
|
||||||
|
19
libsrc/api/JSONRPC_schema/schema-getcurrentimage.json
Normal file
19
libsrc/api/JSONRPC_schema/schema-getcurrentimage.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"type":"object",
|
||||||
|
"required":true,
|
||||||
|
"properties":{
|
||||||
|
"command": {
|
||||||
|
"type" : "string",
|
||||||
|
"required" : true,
|
||||||
|
"enum" : ["getcurrentimage"]
|
||||||
|
},
|
||||||
|
"tan" : {
|
||||||
|
"type" : "integer"
|
||||||
|
},
|
||||||
|
"path": {
|
||||||
|
"type": "string",
|
||||||
|
"required": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
@ -5,7 +5,7 @@
|
|||||||
"command": {
|
"command": {
|
||||||
"type" : "string",
|
"type" : "string",
|
||||||
"required" : true,
|
"required" : true,
|
||||||
"enum": [ "color", "image", "effect", "create-effect", "delete-effect", "serverinfo", "clear", "clearall", "adjustment", "sourceselect", "config", "componentstate", "ledcolors", "logging", "processing", "sysinfo", "videomode", "authorize", "instance", "leddevice", "inputsource", "service", "system", "transform", "correction", "temperature" ]
|
"enum": [ "color", "image", "effect", "create-effect", "delete-effect", "serverinfo", "clear", "clearall", "adjustment", "sourceselect", "config", "componentstate", "ledcolors", "logging", "processing", "sysinfo", "videomode", "authorize", "instance", "leddevice", "inputsource", "service", "system", "transform", "correction", "temperature", "getcurrentimage" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
<file alias="schema-color">JSONRPC_schema/schema-color.json</file>
|
<file alias="schema-color">JSONRPC_schema/schema-color.json</file>
|
||||||
<file alias="schema-image">JSONRPC_schema/schema-image.json</file>
|
<file alias="schema-image">JSONRPC_schema/schema-image.json</file>
|
||||||
<file alias="schema-serverinfo">JSONRPC_schema/schema-serverinfo.json</file>
|
<file alias="schema-serverinfo">JSONRPC_schema/schema-serverinfo.json</file>
|
||||||
|
<file alias="schema-getcurrentimage">JSONRPC_schema/schema-getcurrentimage.json</file>
|
||||||
<file alias="schema-sysinfo">JSONRPC_schema/schema-sysinfo.json</file>
|
<file alias="schema-sysinfo">JSONRPC_schema/schema-sysinfo.json</file>
|
||||||
<file alias="schema-clear">JSONRPC_schema/schema-clear.json</file>
|
<file alias="schema-clear">JSONRPC_schema/schema-clear.json</file>
|
||||||
<file alias="schema-clearall">JSONRPC_schema/schema-clearall.json</file>
|
<file alias="schema-clearall">JSONRPC_schema/schema-clearall.json</file>
|
||||||
|
@ -393,11 +393,53 @@ void JsonAPI::handleCommand(const JsonApiCommand& cmd, const QJsonObject &messag
|
|||||||
sendErrorReply("The command is deprecated, please use the Hyperion Web Interface to configure", cmd);
|
sendErrorReply("The command is deprecated, please use the Hyperion Web Interface to configure", cmd);
|
||||||
break;
|
break;
|
||||||
// END
|
// END
|
||||||
|
case Command::GetCurrentImage:
|
||||||
|
handleGetCurrentImageCommand(message, cmd);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JsonAPI::handleGetCurrentImageCommand(const QJsonObject &message, const JsonApiCommand& cmd)
|
||||||
|
{
|
||||||
|
QString replyMsg;
|
||||||
|
|
||||||
|
Debug(_log, "Get image command received");
|
||||||
|
QString savePath = message["path"].toString();
|
||||||
|
|
||||||
|
Debug(_log,"Save path: %s", QSTRING_CSTR(savePath));
|
||||||
|
|
||||||
|
int priority = _hyperion->getCurrentPriority();
|
||||||
|
const PriorityMuxer::InputInfo priorityInfo = _hyperion->getPriorityInfo(priority);
|
||||||
|
Image<ColorRgb> image = priorityInfo.image;
|
||||||
|
|
||||||
|
QImage jpgImage(reinterpret_cast<const uchar*>(image.memptr()), image.width(), image.height(), qsizetype(3) * image.width(), QImage::Format_RGB888);
|
||||||
|
QByteArray byteArray;
|
||||||
|
QBuffer buffer(&byteArray);
|
||||||
|
buffer.open(QIODevice::WriteOnly);
|
||||||
|
jpgImage.save(&buffer, "JPG");
|
||||||
|
QString base64Image = QString::fromLatin1(byteArray.toBase64().data());
|
||||||
|
if (!savePath.isEmpty())
|
||||||
|
{
|
||||||
|
if (!jpgImage.save(savePath, "JPG"))
|
||||||
|
{
|
||||||
|
replyMsg = "Failed to save image to: " + savePath;
|
||||||
|
sendErrorReply(replyMsg, cmd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject info;
|
||||||
|
info["path"] = savePath;
|
||||||
|
info["format"] = "JPG";
|
||||||
|
info["width"] = image.width();
|
||||||
|
info["height"] = image.height();
|
||||||
|
info["size"] = image.width() * image.height() * 3;
|
||||||
|
info["data"] = base64Image;
|
||||||
|
sendSuccessDataReply(info, cmd);
|
||||||
|
}
|
||||||
|
|
||||||
void JsonAPI::handleColorCommand(const QJsonObject &message, const JsonApiCommand& cmd)
|
void JsonAPI::handleColorCommand(const QJsonObject &message, const JsonApiCommand& cmd)
|
||||||
{
|
{
|
||||||
emit forwardJsonMessage(message);
|
emit forwardJsonMessage(message);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user