clean split
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "../telemetry/CadenceTelemetryJson.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -21,9 +22,10 @@ struct RuntimeStateJsonInput
|
||||
unsigned short serverPort = 0;
|
||||
bool videoOutputEnabled = false;
|
||||
std::string videoOutputStatus;
|
||||
const SupportedShaderCatalog& shaderCatalog;
|
||||
const RuntimeLayerModelSnapshot& runtimeLayers;
|
||||
const OscControlServerState* osc = nullptr;
|
||||
std::function<void(JsonWriter&)> writeRuntimeJson;
|
||||
std::function<void(JsonWriter&)> writeCatalogJson;
|
||||
std::function<void(JsonWriter&)> writeLayersJson;
|
||||
};
|
||||
|
||||
inline void WriteVideoIoStatusJson(JsonWriter& writer, const RuntimeStateJsonInput& input)
|
||||
@@ -244,12 +246,56 @@ inline void WriteParameterDefinitionJson(JsonWriter& writer, const ShaderParamet
|
||||
writer.EndObject();
|
||||
}
|
||||
|
||||
inline void WriteLayersJson(JsonWriter& writer, const RuntimeStateJsonInput& input)
|
||||
inline void WriteShaderRuntimeJson(JsonWriter& writer, const RuntimeLayerModelSnapshot& runtimeLayers)
|
||||
{
|
||||
writer.BeginObject();
|
||||
writer.KeyUInt("layerCount", static_cast<uint64_t>(runtimeLayers.displayLayers.size()));
|
||||
writer.KeyBool("compileSucceeded", runtimeLayers.compileSucceeded);
|
||||
writer.KeyString("compileMessage", runtimeLayers.compileMessage);
|
||||
writer.EndObject();
|
||||
}
|
||||
|
||||
inline void WriteEmptyRuntimeJson(JsonWriter& writer)
|
||||
{
|
||||
writer.BeginObject();
|
||||
writer.KeyUInt("layerCount", 0);
|
||||
writer.KeyBool("compileSucceeded", true);
|
||||
writer.KeyString("compileMessage", "No runtime content controller is active.");
|
||||
writer.EndObject();
|
||||
}
|
||||
|
||||
inline void WriteShaderCatalogJson(JsonWriter& writer, const SupportedShaderCatalog& shaderCatalog)
|
||||
{
|
||||
writer.BeginArray();
|
||||
for (const RuntimeLayerReadModel& layer : input.runtimeLayers.displayLayers)
|
||||
for (const SupportedShaderSummary& shader : shaderCatalog.Shaders())
|
||||
{
|
||||
const ShaderPackage* shaderPackage = input.shaderCatalog.FindPackage(layer.shaderId);
|
||||
writer.BeginObject();
|
||||
writer.KeyString("id", shader.id);
|
||||
writer.KeyString("name", shader.name);
|
||||
writer.KeyString("description", shader.description);
|
||||
writer.KeyString("category", shader.category);
|
||||
writer.KeyBool("available", true);
|
||||
writer.KeyNull("error");
|
||||
writer.EndObject();
|
||||
}
|
||||
writer.EndArray();
|
||||
}
|
||||
|
||||
inline void WriteEmptyCatalogJson(JsonWriter& writer)
|
||||
{
|
||||
writer.BeginArray();
|
||||
writer.EndArray();
|
||||
}
|
||||
|
||||
inline void WriteRuntimeShaderLayersJson(
|
||||
JsonWriter& writer,
|
||||
const SupportedShaderCatalog& shaderCatalog,
|
||||
const RuntimeLayerModelSnapshot& runtimeLayers)
|
||||
{
|
||||
writer.BeginArray();
|
||||
for (const RuntimeLayerReadModel& layer : runtimeLayers.displayLayers)
|
||||
{
|
||||
const ShaderPackage* shaderPackage = shaderCatalog.FindPackage(layer.shaderId);
|
||||
writer.BeginObject();
|
||||
writer.KeyString("id", layer.id);
|
||||
writer.KeyString("shaderId", layer.shaderId);
|
||||
@@ -281,6 +327,12 @@ inline void WriteLayersJson(JsonWriter& writer, const RuntimeStateJsonInput& inp
|
||||
writer.EndArray();
|
||||
}
|
||||
|
||||
inline void WriteEmptyLayersJson(JsonWriter& writer)
|
||||
{
|
||||
writer.BeginArray();
|
||||
writer.EndArray();
|
||||
}
|
||||
|
||||
inline void WriteOscJson(JsonWriter& writer, const RuntimeStateJsonInput& input)
|
||||
{
|
||||
const bool configured = input.osc ? input.osc->configured : input.config.oscPort != 0;
|
||||
@@ -343,11 +395,10 @@ inline std::string RuntimeStateToJson(const RuntimeStateJsonInput& input)
|
||||
writer.EndObject();
|
||||
|
||||
writer.Key("runtime");
|
||||
writer.BeginObject();
|
||||
writer.KeyUInt("layerCount", static_cast<uint64_t>(input.runtimeLayers.displayLayers.size()));
|
||||
writer.KeyBool("compileSucceeded", input.runtimeLayers.compileSucceeded);
|
||||
writer.KeyString("compileMessage", input.runtimeLayers.compileMessage);
|
||||
writer.EndObject();
|
||||
if (input.writeRuntimeJson)
|
||||
input.writeRuntimeJson(writer);
|
||||
else
|
||||
WriteEmptyRuntimeJson(writer);
|
||||
|
||||
writer.Key("video");
|
||||
writer.BeginObject();
|
||||
@@ -386,24 +437,18 @@ inline std::string RuntimeStateToJson(const RuntimeStateJsonInput& input)
|
||||
writer.KeyNull("backendPlayout");
|
||||
writer.KeyNull("runtimeEvents");
|
||||
writer.Key("shaders");
|
||||
writer.BeginArray();
|
||||
for (const SupportedShaderSummary& shader : input.shaderCatalog.Shaders())
|
||||
{
|
||||
writer.BeginObject();
|
||||
writer.KeyString("id", shader.id);
|
||||
writer.KeyString("name", shader.name);
|
||||
writer.KeyString("description", shader.description);
|
||||
writer.KeyString("category", shader.category);
|
||||
writer.KeyBool("available", true);
|
||||
writer.KeyNull("error");
|
||||
writer.EndObject();
|
||||
}
|
||||
writer.EndArray();
|
||||
if (input.writeCatalogJson)
|
||||
input.writeCatalogJson(writer);
|
||||
else
|
||||
WriteEmptyCatalogJson(writer);
|
||||
writer.Key("stackPresets");
|
||||
writer.BeginArray();
|
||||
writer.EndArray();
|
||||
writer.Key("layers");
|
||||
WriteLayersJson(writer, input);
|
||||
if (input.writeLayersJson)
|
||||
input.writeLayersJson(writer);
|
||||
else
|
||||
WriteEmptyLayersJson(writer);
|
||||
|
||||
writer.EndObject();
|
||||
return writer.StringValue();
|
||||
|
||||
Reference in New Issue
Block a user