109 lines
3.5 KiB
C++
109 lines
3.5 KiB
C++
#pragma once
|
|
|
|
#include "../app/AppConfig.h"
|
|
#include "../app/AppConfigProvider.h"
|
|
#include "../json/JsonWriter.h"
|
|
#include "../telemetry/CadenceTelemetryJson.h"
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
namespace RenderCadenceCompositor
|
|
{
|
|
struct RuntimeStateJsonInput
|
|
{
|
|
const AppConfig& config;
|
|
const CadenceTelemetrySnapshot& telemetry;
|
|
unsigned short serverPort = 0;
|
|
bool videoOutputEnabled = false;
|
|
std::string videoOutputStatus;
|
|
};
|
|
|
|
inline void WriteVideoIoStatusJson(JsonWriter& writer, const RuntimeStateJsonInput& input)
|
|
{
|
|
writer.BeginObject();
|
|
writer.KeyString("backend", "decklink");
|
|
writer.KeyNull("modelName");
|
|
writer.KeyBool("supportsInternalKeying", false);
|
|
writer.KeyBool("supportsExternalKeying", false);
|
|
writer.KeyBool("keyerInterfaceAvailable", false);
|
|
writer.KeyBool("externalKeyingRequested", input.config.deckLink.externalKeyingEnabled);
|
|
writer.KeyBool("externalKeyingActive", input.videoOutputEnabled && input.config.deckLink.externalKeyingEnabled);
|
|
writer.KeyString("statusMessage", input.videoOutputStatus);
|
|
writer.EndObject();
|
|
}
|
|
|
|
inline std::string RuntimeStateToJson(const RuntimeStateJsonInput& input)
|
|
{
|
|
JsonWriter writer;
|
|
writer.BeginObject();
|
|
|
|
writer.Key("app");
|
|
writer.BeginObject();
|
|
writer.KeyUInt("serverPort", input.serverPort);
|
|
writer.KeyUInt("oscPort", input.config.oscPort);
|
|
writer.KeyString("oscBindAddress", input.config.oscBindAddress);
|
|
writer.KeyDouble("oscSmoothing", input.config.oscSmoothing);
|
|
writer.KeyBool("autoReload", input.config.autoReload);
|
|
writer.KeyUInt("maxTemporalHistoryFrames", static_cast<uint64_t>(input.config.maxTemporalHistoryFrames));
|
|
writer.KeyDouble("previewFps", input.config.previewFps);
|
|
writer.KeyBool("enableExternalKeying", input.config.deckLink.externalKeyingEnabled);
|
|
writer.KeyString("inputVideoFormat", input.config.inputVideoFormat);
|
|
writer.KeyString("inputFrameRate", input.config.inputFrameRate);
|
|
writer.KeyString("outputVideoFormat", input.config.outputVideoFormat);
|
|
writer.KeyString("outputFrameRate", input.config.outputFrameRate);
|
|
writer.EndObject();
|
|
|
|
writer.Key("runtime");
|
|
writer.BeginObject();
|
|
writer.KeyUInt("layerCount", 0);
|
|
writer.KeyBool("compileSucceeded", true);
|
|
writer.KeyString("compileMessage", "Runtime state is not ported into RenderCadenceCompositor yet.");
|
|
writer.EndObject();
|
|
|
|
writer.Key("video");
|
|
writer.BeginObject();
|
|
writer.KeyBool("hasSignal", false);
|
|
writer.KeyNull("width");
|
|
writer.KeyNull("height");
|
|
writer.KeyString("modeName", "output-only");
|
|
writer.EndObject();
|
|
|
|
writer.Key("decklink");
|
|
WriteVideoIoStatusJson(writer, input);
|
|
writer.Key("videoIO");
|
|
WriteVideoIoStatusJson(writer, input);
|
|
|
|
writer.Key("performance");
|
|
writer.BeginObject();
|
|
writer.KeyDouble("frameBudgetMs", FrameDurationMillisecondsFromRateString(input.config.outputFrameRate));
|
|
writer.KeyNull("renderMs");
|
|
writer.KeyNull("smoothedRenderMs");
|
|
writer.KeyNull("budgetUsedPercent");
|
|
writer.KeyNull("completionIntervalMs");
|
|
writer.KeyNull("smoothedCompletionIntervalMs");
|
|
writer.KeyNull("maxCompletionIntervalMs");
|
|
writer.KeyUInt("lateFrameCount", input.telemetry.displayedLate);
|
|
writer.KeyUInt("droppedFrameCount", input.telemetry.dropped);
|
|
writer.KeyNull("flushedFrameCount");
|
|
writer.Key("cadence");
|
|
WriteCadenceTelemetryJson(writer, input.telemetry);
|
|
writer.EndObject();
|
|
|
|
writer.KeyNull("backendPlayout");
|
|
writer.KeyNull("runtimeEvents");
|
|
writer.Key("shaders");
|
|
writer.BeginArray();
|
|
writer.EndArray();
|
|
writer.Key("stackPresets");
|
|
writer.BeginArray();
|
|
writer.EndArray();
|
|
writer.Key("layers");
|
|
writer.BeginArray();
|
|
writer.EndArray();
|
|
|
|
writer.EndObject();
|
|
return writer.StringValue();
|
|
}
|
|
}
|