replace direct ownership
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
#include "../logging/Logger.h"
|
#include "../logging/Logger.h"
|
||||||
#include "../preview/PreviewConfig.h"
|
#include "../preview/PreviewConfig.h"
|
||||||
#include "../telemetry/TelemetryHealthMonitor.h"
|
#include "../telemetry/TelemetryHealthMonitor.h"
|
||||||
#include "DeckLinkOutput.h"
|
#include "VideoIOEdges.h"
|
||||||
#include "VideoOutputThread.h"
|
#include "VideoOutputThread.h"
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
@@ -15,7 +15,7 @@ namespace RenderCadenceCompositor
|
|||||||
{
|
{
|
||||||
struct AppConfig
|
struct AppConfig
|
||||||
{
|
{
|
||||||
DeckLinkOutputConfig deckLink;
|
VideoOutputEdgeConfig deckLink;
|
||||||
VideoOutputThreadConfig outputThread;
|
VideoOutputThreadConfig outputThread;
|
||||||
TelemetryHealthMonitorConfig telemetry;
|
TelemetryHealthMonitorConfig telemetry;
|
||||||
LoggerConfig logging;
|
LoggerConfig logging;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
@@ -56,7 +57,8 @@ public:
|
|||||||
mRenderThread(renderThread),
|
mRenderThread(renderThread),
|
||||||
mFrameExchange(frameExchange),
|
mFrameExchange(frameExchange),
|
||||||
mConfig(config),
|
mConfig(config),
|
||||||
mOutputThread(mOutput, mFrameExchange, VideoOutputThreadConfig{
|
mOutput(std::make_unique<DeckLinkOutput>()),
|
||||||
|
mOutputThread(*mOutput, mFrameExchange, VideoOutputThreadConfig{
|
||||||
mConfig.outputThread.targetBufferedFrames,
|
mConfig.outputThread.targetBufferedFrames,
|
||||||
mConfig.outputThread.idleSleep
|
mConfig.outputThread.idleSleep
|
||||||
}),
|
}),
|
||||||
@@ -100,7 +102,7 @@ public:
|
|||||||
|
|
||||||
StartPreviewWindow();
|
StartPreviewWindow();
|
||||||
StartOptionalVideoOutput();
|
StartOptionalVideoOutput();
|
||||||
mTelemetryHealth.Start(mFrameExchange, mOutput, mOutputThread, mRenderThread);
|
mTelemetryHealth.Start(mFrameExchange, *mOutput, mOutputThread, mRenderThread);
|
||||||
StartHttpServer();
|
StartHttpServer();
|
||||||
Log("app", "RenderCadenceCompositor started.");
|
Log("app", "RenderCadenceCompositor started.");
|
||||||
mStarted = true;
|
mStarted = true;
|
||||||
@@ -113,17 +115,17 @@ public:
|
|||||||
mTelemetryHealth.Stop();
|
mTelemetryHealth.Stop();
|
||||||
mPreviewWindow.Stop();
|
mPreviewWindow.Stop();
|
||||||
mOutputThread.Stop();
|
mOutputThread.Stop();
|
||||||
mOutput.Stop();
|
mOutput->Stop();
|
||||||
mRuntimeLayers.Stop();
|
mRuntimeLayers.Stop();
|
||||||
mRenderThread.Stop();
|
mRenderThread.Stop();
|
||||||
mOutput.ReleaseResources();
|
mOutput->ReleaseResources();
|
||||||
if (mStarted)
|
if (mStarted)
|
||||||
Log("app", "RenderCadenceCompositor shutdown complete.");
|
Log("app", "RenderCadenceCompositor shutdown complete.");
|
||||||
mStarted = false;
|
mStarted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Started() const { return mStarted; }
|
bool Started() const { return mStarted; }
|
||||||
const IVideoOutputEdge& Output() const { return mOutput; }
|
const IVideoOutputEdge& Output() const { return *mOutput; }
|
||||||
void SetVideoInputMetricsProvider(std::function<VideoInputEdgeMetrics()> provider)
|
void SetVideoInputMetricsProvider(std::function<VideoInputEdgeMetrics()> provider)
|
||||||
{
|
{
|
||||||
mVideoInputMetricsProvider = std::move(provider);
|
mVideoInputMetricsProvider = std::move(provider);
|
||||||
@@ -134,7 +136,7 @@ private:
|
|||||||
{
|
{
|
||||||
std::string outputError;
|
std::string outputError;
|
||||||
Log("app", "Initializing optional DeckLink output.");
|
Log("app", "Initializing optional DeckLink output.");
|
||||||
if (!mOutput.Initialize(
|
if (!mOutput->Initialize(
|
||||||
mConfig.deckLink,
|
mConfig.deckLink,
|
||||||
[this](const VideoIOCompletion& completion) {
|
[this](const VideoIOCompletion& completion) {
|
||||||
mFrameExchange.ReleaseScheduledByBytes(completion.outputFrameBuffer);
|
mFrameExchange.ReleaseScheduledByBytes(completion.outputFrameBuffer);
|
||||||
@@ -160,7 +162,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Log("app", "Starting DeckLink scheduled playback.");
|
Log("app", "Starting DeckLink scheduled playback.");
|
||||||
if (!mOutput.StartScheduledPlayback(outputError))
|
if (!mOutput->StartScheduledPlayback(outputError))
|
||||||
{
|
{
|
||||||
DisableVideoOutput("DeckLink scheduled playback failed: " + outputError);
|
DisableVideoOutput("DeckLink scheduled playback failed: " + outputError);
|
||||||
return;
|
return;
|
||||||
@@ -171,8 +173,8 @@ private:
|
|||||||
Log("app", mVideoOutputStatus);
|
Log("app", mVideoOutputStatus);
|
||||||
Log(
|
Log(
|
||||||
"app",
|
"app",
|
||||||
"DeckLink output mode: " + mOutput.State().outputDisplayModeName +
|
"DeckLink output mode: " + mOutput->State().outputDisplayModeName +
|
||||||
", frame budget " + std::to_string(mOutput.State().frameBudgetMilliseconds) + " ms.");
|
", frame budget " + std::to_string(mOutput->State().frameBudgetMilliseconds) + " ms.");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BuildSettledOutputReserve(std::string& error)
|
bool BuildSettledOutputReserve(std::string& error)
|
||||||
@@ -193,8 +195,8 @@ private:
|
|||||||
void DisableVideoOutput(const std::string& reason)
|
void DisableVideoOutput(const std::string& reason)
|
||||||
{
|
{
|
||||||
mOutputThread.Stop();
|
mOutputThread.Stop();
|
||||||
mOutput.Stop();
|
mOutput->Stop();
|
||||||
mOutput.ReleaseResources();
|
mOutput->ReleaseResources();
|
||||||
mFrameExchange.Clear();
|
mFrameExchange.Clear();
|
||||||
mVideoOutputEnabled = false;
|
mVideoOutputEnabled = false;
|
||||||
mVideoOutputStatus = reason;
|
mVideoOutputStatus = reason;
|
||||||
@@ -254,7 +256,7 @@ private:
|
|||||||
|
|
||||||
std::string BuildStateJson()
|
std::string BuildStateJson()
|
||||||
{
|
{
|
||||||
CadenceTelemetrySnapshot telemetry = mHttpTelemetry.Sample(mFrameExchange, mOutput, mOutputThread, mRenderThread);
|
CadenceTelemetrySnapshot telemetry = mHttpTelemetry.Sample(mFrameExchange, *mOutput, mOutputThread, mRenderThread);
|
||||||
ApplyVideoInputMetrics(telemetry);
|
ApplyVideoInputMetrics(telemetry);
|
||||||
RuntimeLayerModelSnapshot layerSnapshot = mRuntimeLayers.Snapshot(telemetry);
|
RuntimeLayerModelSnapshot layerSnapshot = mRuntimeLayers.Snapshot(telemetry);
|
||||||
return RuntimeStateToJson(RuntimeStateJsonInput{
|
return RuntimeStateToJson(RuntimeStateJsonInput{
|
||||||
@@ -300,7 +302,7 @@ private:
|
|||||||
RenderThread& mRenderThread;
|
RenderThread& mRenderThread;
|
||||||
SystemFrameExchange& mFrameExchange;
|
SystemFrameExchange& mFrameExchange;
|
||||||
AppConfig mConfig;
|
AppConfig mConfig;
|
||||||
DeckLinkOutput mOutput;
|
std::unique_ptr<IVideoOutputEdge> mOutput;
|
||||||
VideoOutputThread<SystemFrameExchange> mOutputThread;
|
VideoOutputThread<SystemFrameExchange> mOutputThread;
|
||||||
TelemetryHealthMonitor mTelemetryHealth;
|
TelemetryHealthMonitor mTelemetryHealth;
|
||||||
CadenceTelemetry mHttpTelemetry;
|
CadenceTelemetry mHttpTelemetry;
|
||||||
|
|||||||
@@ -52,6 +52,13 @@ struct VideoOutputEdgeMetrics
|
|||||||
uint64_t scheduleRealignmentCount = 0;
|
uint64_t scheduleRealignmentCount = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct VideoOutputEdgeConfig
|
||||||
|
{
|
||||||
|
VideoFormat outputVideoMode;
|
||||||
|
bool externalKeyingEnabled = false;
|
||||||
|
bool outputAlphaRequired = false;
|
||||||
|
};
|
||||||
|
|
||||||
class IVideoOutputEdge
|
class IVideoOutputEdge
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -59,6 +66,7 @@ public:
|
|||||||
|
|
||||||
virtual ~IVideoOutputEdge() = default;
|
virtual ~IVideoOutputEdge() = default;
|
||||||
|
|
||||||
|
virtual bool Initialize(const VideoOutputEdgeConfig& config, CompletionCallback completionCallback, std::string& error) = 0;
|
||||||
virtual bool StartScheduledPlayback(std::string& error) = 0;
|
virtual bool StartScheduledPlayback(std::string& error) = 0;
|
||||||
virtual bool ScheduleFrame(const VideoIOOutputFrame& frame) = 0;
|
virtual bool ScheduleFrame(const VideoIOOutputFrame& frame) = 0;
|
||||||
virtual void Stop() = 0;
|
virtual void Stop() = 0;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ DeckLinkOutput::~DeckLinkOutput()
|
|||||||
ReleaseResources();
|
ReleaseResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeckLinkOutput::Initialize(const DeckLinkOutputConfig& config, CompletionCallback completionCallback, std::string& error)
|
bool DeckLinkOutput::Initialize(const VideoOutputEdgeConfig& config, CompletionCallback completionCallback, std::string& error)
|
||||||
{
|
{
|
||||||
mConfig = config;
|
mConfig = config;
|
||||||
mCompletionCallback = completionCallback;
|
mCompletionCallback = completionCallback;
|
||||||
|
|||||||
@@ -12,13 +12,7 @@
|
|||||||
|
|
||||||
namespace RenderCadenceCompositor
|
namespace RenderCadenceCompositor
|
||||||
{
|
{
|
||||||
struct DeckLinkOutputConfig
|
using DeckLinkOutputConfig = VideoOutputEdgeConfig;
|
||||||
{
|
|
||||||
VideoFormat outputVideoMode;
|
|
||||||
bool externalKeyingEnabled = false;
|
|
||||||
bool outputAlphaRequired = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
using DeckLinkOutputMetrics = VideoOutputEdgeMetrics;
|
using DeckLinkOutputMetrics = VideoOutputEdgeMetrics;
|
||||||
|
|
||||||
class DeckLinkOutput : public IVideoOutputEdge
|
class DeckLinkOutput : public IVideoOutputEdge
|
||||||
@@ -31,7 +25,7 @@ public:
|
|||||||
DeckLinkOutput& operator=(const DeckLinkOutput&) = delete;
|
DeckLinkOutput& operator=(const DeckLinkOutput&) = delete;
|
||||||
~DeckLinkOutput();
|
~DeckLinkOutput();
|
||||||
|
|
||||||
bool Initialize(const DeckLinkOutputConfig& config, CompletionCallback completionCallback, std::string& error);
|
bool Initialize(const VideoOutputEdgeConfig& config, CompletionCallback completionCallback, std::string& error) override;
|
||||||
bool StartScheduledPlayback(std::string& error) override;
|
bool StartScheduledPlayback(std::string& error) override;
|
||||||
bool ScheduleFrame(const VideoIOOutputFrame& frame) override;
|
bool ScheduleFrame(const VideoIOOutputFrame& frame) override;
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
@@ -44,7 +38,7 @@ private:
|
|||||||
void HandleCompletion(const VideoIOCompletion& completion);
|
void HandleCompletion(const VideoIOCompletion& completion);
|
||||||
|
|
||||||
DeckLinkSession mSession;
|
DeckLinkSession mSession;
|
||||||
DeckLinkOutputConfig mConfig;
|
VideoOutputEdgeConfig mConfig;
|
||||||
CompletionCallback mCompletionCallback;
|
CompletionCallback mCompletionCallback;
|
||||||
std::atomic<uint64_t> mCompletions{ 0 };
|
std::atomic<uint64_t> mCompletions{ 0 };
|
||||||
std::atomic<uint64_t> mDisplayedLate{ 0 };
|
std::atomic<uint64_t> mDisplayedLate{ 0 };
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ private:
|
|||||||
class FakeOutputEdge final : public RenderCadenceCompositor::IVideoOutputEdge
|
class FakeOutputEdge final : public RenderCadenceCompositor::IVideoOutputEdge
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
bool Initialize(const RenderCadenceCompositor::VideoOutputEdgeConfig&, CompletionCallback, std::string&) override { return true; }
|
||||||
bool StartScheduledPlayback(std::string&) override { return true; }
|
bool StartScheduledPlayback(std::string&) override { return true; }
|
||||||
bool ScheduleFrame(const VideoIOOutputFrame& frame) override
|
bool ScheduleFrame(const VideoIOOutputFrame& frame) override
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user