@@ -83,7 +83,6 @@ bool OpenGLComposite::InitializeVideoIO()
|
|||||||
}
|
}
|
||||||
|
|
||||||
const VideoIOConfiguration videoIOConfig = mRuntimeHost->GetVideoIOConfiguration();
|
const VideoIOConfiguration videoIOConfig = mRuntimeHost->GetVideoIOConfiguration();
|
||||||
const VideoIOBackendDescriptor* backendDescriptor = GetVideoIOBackendDescriptor(videoIOConfig.backendId);
|
|
||||||
mVideoIO = CreateVideoIODevice(videoIOConfig.backendId, initFailureReason);
|
mVideoIO = CreateVideoIODevice(videoIOConfig.backendId, initFailureReason);
|
||||||
if (!mVideoIO)
|
if (!mVideoIO)
|
||||||
{
|
{
|
||||||
@@ -94,8 +93,8 @@ bool OpenGLComposite::InitializeVideoIO()
|
|||||||
|
|
||||||
if (!mVideoIO->DiscoverDevicesAndModes(videoIOConfig, initFailureReason))
|
if (!mVideoIO->DiscoverDevicesAndModes(videoIOConfig, initFailureReason))
|
||||||
{
|
{
|
||||||
const char* title = IsVideoIOBackendUnavailableError(videoIOConfig.backendId, initFailureReason) && backendDescriptor != nullptr
|
const char* title = initFailureReason == "Please install the Blackmagic DeckLink drivers to use the features of this application."
|
||||||
? backendDescriptor->unavailableTitle
|
? "This application requires the selected video I/O drivers installed."
|
||||||
: "Video I/O initialization failed";
|
: "Video I/O initialization failed";
|
||||||
MessageBoxA(NULL, initFailureReason.c_str(), title, MB_OK | MB_ICONERROR);
|
MessageBoxA(NULL, initFailureReason.c_str(), title, MB_OK | MB_ICONERROR);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -3,73 +3,14 @@
|
|||||||
#include "DeckLinkSession.h"
|
#include "DeckLinkSession.h"
|
||||||
#include "VideoIOTypes.h"
|
#include "VideoIOTypes.h"
|
||||||
|
|
||||||
#include <array>
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
struct VideoIOBackendRegistration
|
|
||||||
{
|
|
||||||
VideoIOBackendDescriptor descriptor;
|
|
||||||
VideoIODeviceFactory factory;
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::array<VideoIOBackendRegistration, 1>& RegisteredBackends()
|
|
||||||
{
|
|
||||||
static const std::array<VideoIOBackendRegistration, 1> 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<DeckLinkSession>(); }
|
|
||||||
}
|
|
||||||
} };
|
|
||||||
return backends;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const VideoIOBackendDescriptor* GetVideoIOBackendDescriptor(VideoIOBackendId backendId)
|
|
||||||
{
|
|
||||||
for (const VideoIOBackendRegistration& registration : RegisteredBackends())
|
|
||||||
{
|
|
||||||
if (registration.descriptor.backendId == backendId)
|
|
||||||
return ®istration.descriptor;
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<VideoIOBackendDescriptor> ListVideoIOBackendDescriptors()
|
|
||||||
{
|
|
||||||
std::vector<VideoIOBackendDescriptor> descriptors;
|
|
||||||
descriptors.reserve(RegisteredBackends().size());
|
|
||||||
for (const VideoIOBackendRegistration& registration : RegisteredBackends())
|
|
||||||
descriptors.push_back(registration.descriptor);
|
|
||||||
return descriptors;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<VideoIODevice> CreateVideoIODevice(VideoIOBackendId backendId, std::string& error)
|
std::unique_ptr<VideoIODevice> CreateVideoIODevice(VideoIOBackendId backendId, std::string& error)
|
||||||
{
|
{
|
||||||
for (const VideoIOBackendRegistration& registration : RegisteredBackends())
|
switch (backendId)
|
||||||
{
|
{
|
||||||
if (registration.descriptor.backendId != backendId)
|
case VideoIOBackendId::DeckLink:
|
||||||
continue;
|
return std::make_unique<DeckLinkSession>();
|
||||||
|
|
||||||
error.clear();
|
|
||||||
return registration.factory ? registration.factory() : nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
error = "Unsupported video I/O backend.";
|
error = "Unsupported video I/O backend.";
|
||||||
return nullptr;
|
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;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,25 +2,9 @@
|
|||||||
|
|
||||||
#include "VideoIOConfig.h"
|
#include "VideoIOConfig.h"
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
class VideoIODevice;
|
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<std::unique_ptr<VideoIODevice>()>;
|
|
||||||
|
|
||||||
const VideoIOBackendDescriptor* GetVideoIOBackendDescriptor(VideoIOBackendId backendId);
|
|
||||||
std::vector<VideoIOBackendDescriptor> ListVideoIOBackendDescriptors();
|
|
||||||
std::unique_ptr<VideoIODevice> CreateVideoIODevice(VideoIOBackendId backendId, std::string& error);
|
std::unique_ptr<VideoIODevice> CreateVideoIODevice(VideoIOBackendId backendId, std::string& error);
|
||||||
bool IsVideoIOBackendUnavailableError(VideoIOBackendId backendId, const std::string& error);
|
|
||||||
|
|||||||
@@ -19,18 +19,6 @@ void Expect(bool condition, const char* message)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
const std::vector<VideoIOBackendDescriptor> 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::string error;
|
||||||
std::unique_ptr<VideoIODevice> device = CreateVideoIODevice(VideoIOBackendId::DeckLink, error);
|
std::unique_ptr<VideoIODevice> device = CreateVideoIODevice(VideoIOBackendId::DeckLink, error);
|
||||||
Expect(device != nullptr, "decklink backend factory returns a device");
|
Expect(device != nullptr, "decklink backend factory returns a device");
|
||||||
|
|||||||
Reference in New Issue
Block a user