From 0c166656102d130a1877085215efb1159e66634c Mon Sep 17 00:00:00 2001 From: Aiden <68633820+awils27@users.noreply.github.com> Date: Sat, 9 May 2026 16:47:33 +1000 Subject: [PATCH] Revert "Decklink separation" This reverts commit 46f2f1ece5df9b875677df673dabea43f43ac490. --- .../gl/OpenGLComposite.cpp | 5 +- .../videoio/VideoIOBackendFactory.cpp | 65 +------------------ .../videoio/VideoIOBackendFactory.h | 16 ----- tests/VideoIOBackendFactoryTests.cpp | 12 ---- 4 files changed, 5 insertions(+), 93 deletions(-) diff --git a/apps/LoopThroughWithOpenGLCompositing/gl/OpenGLComposite.cpp b/apps/LoopThroughWithOpenGLCompositing/gl/OpenGLComposite.cpp index d0f2514..1efc5db 100644 --- a/apps/LoopThroughWithOpenGLCompositing/gl/OpenGLComposite.cpp +++ b/apps/LoopThroughWithOpenGLCompositing/gl/OpenGLComposite.cpp @@ -83,7 +83,6 @@ bool OpenGLComposite::InitializeVideoIO() } const VideoIOConfiguration videoIOConfig = mRuntimeHost->GetVideoIOConfiguration(); - const VideoIOBackendDescriptor* backendDescriptor = GetVideoIOBackendDescriptor(videoIOConfig.backendId); mVideoIO = CreateVideoIODevice(videoIOConfig.backendId, initFailureReason); if (!mVideoIO) { @@ -94,8 +93,8 @@ bool OpenGLComposite::InitializeVideoIO() if (!mVideoIO->DiscoverDevicesAndModes(videoIOConfig, initFailureReason)) { - const char* title = IsVideoIOBackendUnavailableError(videoIOConfig.backendId, initFailureReason) && backendDescriptor != nullptr - ? backendDescriptor->unavailableTitle + const char* title = initFailureReason == "Please install the Blackmagic DeckLink drivers to use the features of this application." + ? "This application requires the selected video I/O drivers installed." : "Video I/O initialization failed"; MessageBoxA(NULL, initFailureReason.c_str(), title, MB_OK | MB_ICONERROR); return false; diff --git a/apps/LoopThroughWithOpenGLCompositing/videoio/VideoIOBackendFactory.cpp b/apps/LoopThroughWithOpenGLCompositing/videoio/VideoIOBackendFactory.cpp index a12a0a1..7ec5b60 100644 --- a/apps/LoopThroughWithOpenGLCompositing/videoio/VideoIOBackendFactory.cpp +++ b/apps/LoopThroughWithOpenGLCompositing/videoio/VideoIOBackendFactory.cpp @@ -3,73 +3,14 @@ #include "DeckLinkSession.h" #include "VideoIOTypes.h" -#include - -namespace -{ -struct VideoIOBackendRegistration -{ - VideoIOBackendDescriptor descriptor; - VideoIODeviceFactory factory; -}; - -const std::array& RegisteredBackends() -{ - static const std::array backends = { { - { - { - VideoIOBackendId::DeckLink, - "decklink", - "Blackmagic DeckLink", - "Please install the Blackmagic DeckLink drivers to use the features of this application.", - "This application requires the selected video I/O drivers installed." - }, - []() { return std::make_unique(); } - } - } }; - return backends; -} -} - -const VideoIOBackendDescriptor* GetVideoIOBackendDescriptor(VideoIOBackendId backendId) -{ - for (const VideoIOBackendRegistration& registration : RegisteredBackends()) - { - if (registration.descriptor.backendId == backendId) - return ®istration.descriptor; - } - return nullptr; -} - -std::vector ListVideoIOBackendDescriptors() -{ - std::vector descriptors; - descriptors.reserve(RegisteredBackends().size()); - for (const VideoIOBackendRegistration& registration : RegisteredBackends()) - descriptors.push_back(registration.descriptor); - return descriptors; -} - std::unique_ptr CreateVideoIODevice(VideoIOBackendId backendId, std::string& error) { - for (const VideoIOBackendRegistration& registration : RegisteredBackends()) + switch (backendId) { - if (registration.descriptor.backendId != backendId) - continue; - - error.clear(); - return registration.factory ? registration.factory() : nullptr; + case VideoIOBackendId::DeckLink: + return std::make_unique(); } error = "Unsupported video I/O backend."; return nullptr; } - -bool IsVideoIOBackendUnavailableError(VideoIOBackendId backendId, const std::string& error) -{ - const VideoIOBackendDescriptor* descriptor = GetVideoIOBackendDescriptor(backendId); - return descriptor != nullptr && - descriptor->unavailableMessage != nullptr && - *descriptor->unavailableMessage != '\0' && - error == descriptor->unavailableMessage; -} diff --git a/apps/LoopThroughWithOpenGLCompositing/videoio/VideoIOBackendFactory.h b/apps/LoopThroughWithOpenGLCompositing/videoio/VideoIOBackendFactory.h index d85f8f3..be41432 100644 --- a/apps/LoopThroughWithOpenGLCompositing/videoio/VideoIOBackendFactory.h +++ b/apps/LoopThroughWithOpenGLCompositing/videoio/VideoIOBackendFactory.h @@ -2,25 +2,9 @@ #include "VideoIOConfig.h" -#include #include #include -#include class VideoIODevice; -struct VideoIOBackendDescriptor -{ - VideoIOBackendId backendId = VideoIOBackendId::DeckLink; - const char* backendName = "decklink"; - const char* displayName = "Blackmagic DeckLink"; - const char* unavailableMessage = ""; - const char* unavailableTitle = "Video I/O initialization failed"; -}; - -using VideoIODeviceFactory = std::function()>; - -const VideoIOBackendDescriptor* GetVideoIOBackendDescriptor(VideoIOBackendId backendId); -std::vector ListVideoIOBackendDescriptors(); std::unique_ptr CreateVideoIODevice(VideoIOBackendId backendId, std::string& error); -bool IsVideoIOBackendUnavailableError(VideoIOBackendId backendId, const std::string& error); diff --git a/tests/VideoIOBackendFactoryTests.cpp b/tests/VideoIOBackendFactoryTests.cpp index f31800d..3f4b6cd 100644 --- a/tests/VideoIOBackendFactoryTests.cpp +++ b/tests/VideoIOBackendFactoryTests.cpp @@ -19,18 +19,6 @@ void Expect(bool condition, const char* message) int main() { - const std::vector backends = ListVideoIOBackendDescriptors(); - Expect(!backends.empty(), "backend registry is not empty"); - Expect(backends.front().backendId == VideoIOBackendId::DeckLink, "decklink is registered"); - Expect(std::string(backends.front().backendName) == "decklink", "decklink registry name is stable"); - - const VideoIOBackendDescriptor* descriptor = GetVideoIOBackendDescriptor(VideoIOBackendId::DeckLink); - Expect(descriptor != nullptr, "decklink descriptor can be looked up"); - Expect(descriptor != nullptr && std::string(descriptor->displayName) == "Blackmagic DeckLink", "decklink descriptor exposes display name"); - Expect(descriptor != nullptr && std::string(descriptor->unavailableTitle) == "This application requires the selected video I/O drivers installed.", "decklink descriptor exposes unavailable title"); - Expect(IsVideoIOBackendUnavailableError(VideoIOBackendId::DeckLink, "Please install the Blackmagic DeckLink drivers to use the features of this application."), "decklink unavailable message is recognized"); - Expect(!IsVideoIOBackendUnavailableError(VideoIOBackendId::DeckLink, "some other error"), "non-driver errors are not treated as backend unavailable"); - std::string error; std::unique_ptr device = CreateVideoIODevice(VideoIOBackendId::DeckLink, error); Expect(device != nullptr, "decklink backend factory returns a device");