Simplify ownership/lifetime
Some checks failed
CI / Native Windows Build And Tests (push) Has been cancelled
CI / React UI Build (push) Has been cancelled
CI / Windows Release Package (push) Has been cancelled

This commit is contained in:
2026-05-06 10:57:59 +10:00
parent 1b67777c4a
commit bbbc678c83
4 changed files with 109 additions and 52 deletions

View File

@@ -139,7 +139,7 @@ bool OpenGLComposite::InitDeckLink()
initFailureReason = "OpenGL extension checks failed.";
goto error;
}
if (mDeckLink->inputFrameWidth != mDeckLink->outputFrameWidth || mDeckLink->inputFrameHeight != mDeckLink->outputFrameHeight)
if (mDeckLink->InputOutputDimensionsDiffer())
{
mRenderer->SetFastTransferAvailable(false);
OutputDebugStringA("Input/output dimensions differ; using regular OpenGL transfer fallback instead of fast transfer.\n");
@@ -151,20 +151,20 @@ bool OpenGLComposite::InitDeckLink()
goto error;
}
PublishDeckLinkOutputStatus(mDeckLink->outputModelName.empty()
PublishDeckLinkOutputStatus(mDeckLink->OutputModelName().empty()
? "DeckLink output device selected."
: ("Selected output device: " + mDeckLink->outputModelName));
: ("Selected output device: " + mDeckLink->OutputModelName()));
// Resize window to match output video frame, but scale large formats down by half for viewing.
if (mDeckLink->outputFrameWidth < 1920)
resizeWindow(mDeckLink->outputFrameWidth, mDeckLink->outputFrameHeight);
if (mDeckLink->OutputFrameWidth() < 1920)
resizeWindow(mDeckLink->OutputFrameWidth(), mDeckLink->OutputFrameHeight());
else
resizeWindow(mDeckLink->outputFrameWidth / 2, mDeckLink->outputFrameHeight / 2);
resizeWindow(mDeckLink->OutputFrameWidth() / 2, mDeckLink->OutputFrameHeight() / 2);
if (mRenderer->FastTransferAvailable())
{
// Initialize fast video frame transfers
if (! VideoFrameTransfer::initialize(mDeckLink->inputFrameWidth, mDeckLink->inputFrameHeight, mRenderer->CaptureTexture(), mRenderer->OutputTexture()))
if (! VideoFrameTransfer::initialize(mDeckLink->InputFrameWidth(), mDeckLink->InputFrameHeight(), mRenderer->CaptureTexture(), mRenderer->OutputTexture()))
{
MessageBox(NULL, _T("Cannot initialize video transfers."), _T("VideoFrameTransfer error."), MB_OK);
goto error;
@@ -175,9 +175,9 @@ bool OpenGLComposite::InitDeckLink()
{
goto error;
}
if (!mDeckLink->input && mRuntimeHost)
if (!mDeckLink->HasInputDevice() && mRuntimeHost)
{
mRuntimeHost->SetSignalStatus(false, mDeckLink->inputFrameWidth, mDeckLink->inputFrameHeight, mDeckLink->inputDisplayModeName);
mRuntimeHost->SetSignalStatus(false, mDeckLink->InputFrameWidth(), mDeckLink->InputFrameHeight(), mDeckLink->InputDisplayModeName());
}
if (!mDeckLink->ConfigureOutput(this, hGLDC, hGLRC, outputDisplayMode, mRuntimeHost && mRuntimeHost->ExternalKeyingEnabled(), initFailureReason))
@@ -185,7 +185,7 @@ bool OpenGLComposite::InitDeckLink()
goto error;
}
PublishDeckLinkOutputStatus(mDeckLink->statusMessage);
PublishDeckLinkOutputStatus(mDeckLink->StatusMessage());
return true;
@@ -204,7 +204,7 @@ void OpenGLComposite::paintGL()
return;
}
mRenderer->PresentToWindow(hGLDC, mDeckLink->outputFrameWidth, mDeckLink->outputFrameHeight);
mRenderer->PresentToWindow(hGLDC, mDeckLink->OutputFrameWidth(), mDeckLink->OutputFrameHeight());
ValidateRect(hGLWnd, NULL);
LeaveCriticalSection(&pMutex);
}
@@ -231,16 +231,16 @@ void OpenGLComposite::PublishDeckLinkOutputStatus(const std::string& statusMessa
return;
if (!statusMessage.empty())
mDeckLink->statusMessage = statusMessage;
mDeckLink->SetStatusMessage(statusMessage);
mRuntimeHost->SetDeckLinkOutputStatus(
mDeckLink->outputModelName,
mDeckLink->supportsInternalKeying,
mDeckLink->supportsExternalKeying,
mDeckLink->keyerInterfaceAvailable,
mDeckLink->OutputModelName(),
mDeckLink->SupportsInternalKeying(),
mDeckLink->SupportsExternalKeying(),
mDeckLink->KeyerInterfaceAvailable(),
mRuntimeHost->ExternalKeyingEnabled(),
mDeckLink->externalKeyingActive,
mDeckLink->statusMessage);
mDeckLink->ExternalKeyingActive(),
mDeckLink->StatusMessage());
}
bool OpenGLComposite::InitOpenGLState()
@@ -269,7 +269,7 @@ bool OpenGLComposite::InitOpenGLState()
return false;
}
if (!mShaderPrograms->CompileLayerPrograms(mDeckLink->inputFrameWidth, mDeckLink->inputFrameHeight, sizeof(compilerErrorMessage), compilerErrorMessage))
if (!mShaderPrograms->CompileLayerPrograms(mDeckLink->InputFrameWidth(), mDeckLink->InputFrameHeight(), sizeof(compilerErrorMessage), compilerErrorMessage))
{
MessageBoxA(NULL, compilerErrorMessage, "OpenGL shader failed to load or compile", MB_OK);
return false;
@@ -277,7 +277,7 @@ bool OpenGLComposite::InitOpenGLState()
mShaderPrograms->ResetTemporalHistoryState();
std::string rendererError;
if (!mRenderer->InitializeResources(mDeckLink->inputFrameWidth, mDeckLink->inputFrameHeight, mDeckLink->outputFrameWidth, mDeckLink->outputFrameHeight, rendererError))
if (!mRenderer->InitializeResources(mDeckLink->InputFrameWidth(), mDeckLink->InputFrameHeight(), mDeckLink->OutputFrameWidth(), mDeckLink->OutputFrameHeight(), rendererError))
{
MessageBoxA(NULL, rendererError.c_str(), "OpenGL initialization error.", MB_OK);
return false;
@@ -300,7 +300,7 @@ void OpenGLComposite::PlayoutFrameCompleted(IDeckLinkVideoFrame* completedFrame,
bool OpenGLComposite::Start()
{
return mDeckLink->Start(mDeckLink->outputFrameHeight);
return mDeckLink->Start();
}
bool OpenGLComposite::Stop()
@@ -311,7 +311,7 @@ bool OpenGLComposite::Stop()
if (mControlServer)
mControlServer->Stop();
const bool wasExternalKeyingActive = mDeckLink->externalKeyingActive;
const bool wasExternalKeyingActive = mDeckLink->ExternalKeyingActive();
mDeckLink->Stop();
if (wasExternalKeyingActive)
PublishDeckLinkOutputStatus("External keying has been disabled.");
@@ -326,7 +326,7 @@ bool OpenGLComposite::ReloadShader()
EnterCriticalSection(&pMutex);
wglMakeCurrent(hGLDC, hGLRC);
bool success = mShaderPrograms->CompileLayerPrograms(mDeckLink->inputFrameWidth, mDeckLink->inputFrameHeight, sizeof(compilerErrorMessage), compilerErrorMessage);
bool success = mShaderPrograms->CompileLayerPrograms(mDeckLink->InputFrameWidth(), mDeckLink->InputFrameHeight(), sizeof(compilerErrorMessage), compilerErrorMessage);
if (mRuntimeHost)
mRuntimeHost->ClearReloadRequest();
@@ -353,14 +353,14 @@ void OpenGLComposite::renderEffect()
{
PollRuntimeChanges();
const bool hasInputSource = !mDeckLink->hasNoInputSource;
const std::vector<RuntimeRenderState> layerStates = mRuntimeHost ? mRuntimeHost->GetLayerRenderStates(mDeckLink->inputFrameWidth, mDeckLink->inputFrameHeight) : std::vector<RuntimeRenderState>();
const bool hasInputSource = mDeckLink->HasInputSource();
const std::vector<RuntimeRenderState> layerStates = mRuntimeHost ? mRuntimeHost->GetLayerRenderStates(mDeckLink->InputFrameWidth(), mDeckLink->InputFrameHeight()) : std::vector<RuntimeRenderState>();
const unsigned historyCap = mRuntimeHost ? mRuntimeHost->GetMaxTemporalHistoryFrames() : 0;
mRenderPass->Render(
hasInputSource,
layerStates,
mDeckLink->inputFrameWidth,
mDeckLink->inputFrameHeight,
mDeckLink->InputFrameWidth(),
mDeckLink->InputFrameHeight(),
historyCap,
[this](const RuntimeRenderState& state, LayerProgram::TextBinding& textBinding, std::string& error) {
return mShaderPrograms->UpdateTextBindingTexture(state, textBinding, error);
@@ -392,7 +392,7 @@ bool OpenGLComposite::PollRuntimeChanges()
return true;
char compilerErrorMessage[1024] = {};
if (!mShaderPrograms->CompileLayerPrograms(mDeckLink->inputFrameWidth, mDeckLink->inputFrameHeight, sizeof(compilerErrorMessage), compilerErrorMessage))
if (!mShaderPrograms->CompileLayerPrograms(mDeckLink->InputFrameWidth(), mDeckLink->InputFrameHeight(), sizeof(compilerErrorMessage), compilerErrorMessage))
{
mRuntimeHost->SetCompileStatus(false, compilerErrorMessage);
mRuntimeHost->ClearReloadRequest();