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