clean split
All checks were successful
CI / React UI Build (push) Successful in 12s
CI / Native Windows Build And Tests (push) Successful in 2m14s
CI / Windows Release Package (push) Has been skipped

This commit is contained in:
Aiden
2026-05-30 21:22:03 +10:00
parent fbc2851ccb
commit 56883439a6
10 changed files with 269 additions and 63 deletions

View File

@@ -5,7 +5,7 @@
#include "AppConfigProvider.h"
#include "AppRestart.h"
#include "RenderCadenceHttpRoutes.h"
#include "RuntimeLayerController.h"
#include "RuntimeContentController.h"
#include "../logging/Logger.h"
#include "../control/RuntimeStateJson.h"
#include "../control/osc/OscControlServer.h"
@@ -65,20 +65,19 @@ public:
SystemFrameExchange& frameExchange,
AppConfig config,
std::unique_ptr<IVideoOutputEdge> output,
std::unique_ptr<IRuntimeContentController> runtimeContent,
std::filesystem::path configPath = std::filesystem::path()) :
mRenderThread(renderThread),
mFrameExchange(frameExchange),
mConfig(config),
mConfigPath(std::move(configPath)),
mOutput(std::move(output)),
mRuntimeContent(std::move(runtimeContent)),
mOutputThread(*mOutput, mFrameExchange, VideoOutputThreadConfig{
mConfig.outputThread.targetBufferedFrames,
mConfig.outputThread.idleSleep
}),
mTelemetryHealth(mConfig.telemetry),
mRuntimeLayers([this](const std::vector<RuntimeRenderLayerModel>& layers) {
mRenderThread.SubmitRuntimeRenderLayers(layers);
})
mTelemetryHealth(mConfig.telemetry)
{
}
@@ -92,10 +91,8 @@ public:
bool Start(std::string& error)
{
mRuntimeLayers.Initialize(
mConfig.shaderLibrary,
static_cast<unsigned>(mConfig.maxTemporalHistoryFrames),
mConfig.runtimeShaderId);
if (mRuntimeContent)
mRuntimeContent->Initialize(mConfig);
Log("app", "Starting render thread.");
if (!detail::StartRenderThread(mRenderThread, error, 0))
@@ -104,7 +101,8 @@ public:
Stop();
return false;
}
mRuntimeLayers.StartStartupBuild(mConfig.runtimeShaderId);
if (mRuntimeContent)
mRuntimeContent->Start();
if (!BuildSettledOutputReserve(error))
{
@@ -131,7 +129,8 @@ public:
mPreviewWindow.Stop();
mOutputThread.Stop();
mOutput->Stop();
mRuntimeLayers.Stop();
if (mRuntimeContent)
mRuntimeContent->Stop();
mRenderThread.Stop();
mOutput->ReleaseResources();
if (mStarted)
@@ -260,23 +259,15 @@ private:
routeCallbacks.getNdiSourcesJson = [this]() {
return BuildNdiSourcesJson();
};
routeCallbacks.addLayer = [this](const std::string& body) {
return mRuntimeLayers.HandleAddLayer(body);
};
routeCallbacks.removeLayer = [this](const std::string& body) {
return mRuntimeLayers.HandleRemoveLayer(body);
};
routeCallbacks.executePost = [this](const std::string& path, const std::string& body) {
if (path == "/api/config/save")
return HandleConfigSave(body);
if (path == "/api/app/restart")
return HandleAppRestart();
RuntimeControlCommand command;
std::string error;
if (!ParseRuntimeControlCommand(path, body, command, error))
return ControlActionResult{ false, error };
return mRuntimeLayers.HandleControlCommand(command);
if (mRuntimeContent)
return mRuntimeContent->HandlePost(path, body);
return ControlActionResult{ false, "No runtime content controller is active." };
};
HttpControlServerCallbacks callbacks;
@@ -320,17 +311,27 @@ private:
{
CadenceTelemetrySnapshot telemetry = mHttpTelemetry.Sample(mFrameExchange, *mOutput, mOutputThread, mRenderThread);
ApplyVideoInputMetrics(telemetry);
RuntimeLayerModelSnapshot layerSnapshot = mRuntimeLayers.Snapshot(telemetry);
return RuntimeStateToJson(RuntimeStateJsonInput{
RuntimeStateJsonInput stateInput{
mConfig,
telemetry,
mHttpServer.Port(),
mVideoOutputEnabled,
mVideoOutputStatus,
mRuntimeLayers.ShaderCatalog(),
layerSnapshot,
&mOscServer.State()
});
};
if (mRuntimeContent)
{
stateInput.writeRuntimeJson = [this, telemetry](JsonWriter& writer) {
mRuntimeContent->WriteRuntimeJson(writer, telemetry);
};
stateInput.writeCatalogJson = [this](JsonWriter& writer) {
mRuntimeContent->WriteCatalogJson(writer);
};
stateInput.writeLayersJson = [this, telemetry](JsonWriter& writer) {
mRuntimeContent->WriteLayersJson(writer, telemetry);
};
}
return RuntimeStateToJson(stateInput);
}
void StartOscServer()
@@ -460,13 +461,13 @@ private:
AppConfig mConfig;
std::filesystem::path mConfigPath;
std::unique_ptr<IVideoOutputEdge> mOutput;
std::unique_ptr<IRuntimeContentController> mRuntimeContent;
VideoOutputThread<SystemFrameExchange> mOutputThread;
TelemetryHealthMonitor mTelemetryHealth;
CadenceTelemetry mHttpTelemetry;
HttpControlServer mHttpServer;
OscControlServer mOscServer;
PreviewWindowThread mPreviewWindow;
RuntimeLayerController mRuntimeLayers;
std::function<VideoInputEdgeMetrics()> mVideoInputMetricsProvider;
uint64_t mLastInputCapturedFrames = 0;
std::atomic<bool> mRestartRequired{ false };