#include "VideoIOBackendFactory.h" #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()) { if (registration.descriptor.backendId != backendId) continue; error.clear(); return registration.factory ? registration.factory() : nullptr; } 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; }