|
|
|
|
@@ -45,6 +45,7 @@
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <cstring>
|
|
|
|
|
#include <cctype>
|
|
|
|
|
#include <wincodec.h>
|
|
|
|
|
#include <set>
|
|
|
|
|
#include <sstream>
|
|
|
|
|
@@ -61,7 +62,6 @@ constexpr GLuint kDecodedVideoTextureUnit = 1;
|
|
|
|
|
constexpr GLuint kSourceHistoryTextureUnitBase = 2;
|
|
|
|
|
constexpr GLuint kPackedVideoTextureUnit = 2;
|
|
|
|
|
constexpr GLuint kGlobalParamsBindingPoint = 0;
|
|
|
|
|
const char* kDisplayModeName = "1080p59.94";
|
|
|
|
|
const char* kVertexShaderSource =
|
|
|
|
|
"#version 430 core\n"
|
|
|
|
|
"out vec2 vTexCoord;\n"
|
|
|
|
|
@@ -106,6 +106,91 @@ void CopyErrorMessage(const std::string& message, int errorMessageSize, char* er
|
|
|
|
|
strncpy_s(errorMessage, errorMessageSize, message.c_str(), _TRUNCATE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string NormalizeModeToken(const std::string& value)
|
|
|
|
|
{
|
|
|
|
|
std::string normalized;
|
|
|
|
|
for (unsigned char ch : value)
|
|
|
|
|
{
|
|
|
|
|
if (std::isalnum(ch))
|
|
|
|
|
normalized.push_back(static_cast<char>(std::tolower(ch)));
|
|
|
|
|
}
|
|
|
|
|
return normalized;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ResolveConfiguredDisplayMode(const std::string& videoFormat, const std::string& frameRate, BMDDisplayMode& displayMode, std::string& displayModeName)
|
|
|
|
|
{
|
|
|
|
|
const std::string formatToken = NormalizeModeToken(videoFormat);
|
|
|
|
|
const std::string frameToken = NormalizeModeToken(frameRate);
|
|
|
|
|
const std::string combinedToken = formatToken + frameToken;
|
|
|
|
|
|
|
|
|
|
struct ModeOption
|
|
|
|
|
{
|
|
|
|
|
const char* token;
|
|
|
|
|
BMDDisplayMode mode;
|
|
|
|
|
const char* displayName;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const ModeOption options[] =
|
|
|
|
|
{
|
|
|
|
|
{ "720p50", bmdModeHD720p50, "720p50" },
|
|
|
|
|
{ "hd720p50", bmdModeHD720p50, "720p50" },
|
|
|
|
|
{ "720p5994", bmdModeHD720p5994, "720p59.94" },
|
|
|
|
|
{ "hd720p5994", bmdModeHD720p5994, "720p59.94" },
|
|
|
|
|
{ "720p60", bmdModeHD720p60, "720p60" },
|
|
|
|
|
{ "hd720p60", bmdModeHD720p60, "720p60" },
|
|
|
|
|
{ "1080i50", bmdModeHD1080i50, "1080i50" },
|
|
|
|
|
{ "hd1080i50", bmdModeHD1080i50, "1080i50" },
|
|
|
|
|
{ "1080i5994", bmdModeHD1080i5994, "1080i59.94" },
|
|
|
|
|
{ "hd1080i5994", bmdModeHD1080i5994, "1080i59.94" },
|
|
|
|
|
{ "1080i60", bmdModeHD1080i6000, "1080i60" },
|
|
|
|
|
{ "hd1080i60", bmdModeHD1080i6000, "1080i60" },
|
|
|
|
|
{ "1080p2398", bmdModeHD1080p2398, "1080p23.98" },
|
|
|
|
|
{ "hd1080p2398", bmdModeHD1080p2398, "1080p23.98" },
|
|
|
|
|
{ "1080p24", bmdModeHD1080p24, "1080p24" },
|
|
|
|
|
{ "hd1080p24", bmdModeHD1080p24, "1080p24" },
|
|
|
|
|
{ "1080p25", bmdModeHD1080p25, "1080p25" },
|
|
|
|
|
{ "hd1080p25", bmdModeHD1080p25, "1080p25" },
|
|
|
|
|
{ "1080p2997", bmdModeHD1080p2997, "1080p29.97" },
|
|
|
|
|
{ "hd1080p2997", bmdModeHD1080p2997, "1080p29.97" },
|
|
|
|
|
{ "1080p30", bmdModeHD1080p30, "1080p30" },
|
|
|
|
|
{ "hd1080p30", bmdModeHD1080p30, "1080p30" },
|
|
|
|
|
{ "1080p50", bmdModeHD1080p50, "1080p50" },
|
|
|
|
|
{ "hd1080p50", bmdModeHD1080p50, "1080p50" },
|
|
|
|
|
{ "1080p5994", bmdModeHD1080p5994, "1080p59.94" },
|
|
|
|
|
{ "hd1080p5994", bmdModeHD1080p5994, "1080p59.94" },
|
|
|
|
|
{ "1080p60", bmdModeHD1080p6000, "1080p60" },
|
|
|
|
|
{ "hd1080p60", bmdModeHD1080p6000, "1080p60" },
|
|
|
|
|
{ "2160p2398", bmdMode4K2160p2398, "2160p23.98" },
|
|
|
|
|
{ "4k2160p2398", bmdMode4K2160p2398, "2160p23.98" },
|
|
|
|
|
{ "2160p24", bmdMode4K2160p24, "2160p24" },
|
|
|
|
|
{ "4k2160p24", bmdMode4K2160p24, "2160p24" },
|
|
|
|
|
{ "2160p25", bmdMode4K2160p25, "2160p25" },
|
|
|
|
|
{ "4k2160p25", bmdMode4K2160p25, "2160p25" },
|
|
|
|
|
{ "2160p2997", bmdMode4K2160p2997, "2160p29.97" },
|
|
|
|
|
{ "4k2160p2997", bmdMode4K2160p2997, "2160p29.97" },
|
|
|
|
|
{ "2160p30", bmdMode4K2160p30, "2160p30" },
|
|
|
|
|
{ "4k2160p30", bmdMode4K2160p30, "2160p30" },
|
|
|
|
|
{ "2160p50", bmdMode4K2160p50, "2160p50" },
|
|
|
|
|
{ "4k2160p50", bmdMode4K2160p50, "2160p50" },
|
|
|
|
|
{ "2160p5994", bmdMode4K2160p5994, "2160p59.94" },
|
|
|
|
|
{ "4k2160p5994", bmdMode4K2160p5994, "2160p59.94" },
|
|
|
|
|
{ "2160p60", bmdMode4K2160p60, "2160p60" },
|
|
|
|
|
{ "4k2160p60", bmdMode4K2160p60, "2160p60" }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (const ModeOption& option : options)
|
|
|
|
|
{
|
|
|
|
|
if (combinedToken == option.token || (frameToken.empty() && formatToken == option.token))
|
|
|
|
|
{
|
|
|
|
|
displayMode = option.mode;
|
|
|
|
|
displayModeName = option.displayName;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ScopedGlShader
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
@@ -210,6 +295,7 @@ OpenGLComposite::OpenGLComposite(HWND hWnd, HDC hDC, HGLRC hRC) :
|
|
|
|
|
mDLInput(NULL), mDLOutput(NULL), mDLKeyer(NULL),
|
|
|
|
|
mPlayoutAllocator(NULL),
|
|
|
|
|
mFrameWidth(0), mFrameHeight(0),
|
|
|
|
|
mDisplayModeName("1080p59.94"),
|
|
|
|
|
mHasNoInputSource(true),
|
|
|
|
|
mDeckLinkSupportsInternalKeying(false),
|
|
|
|
|
mDeckLinkSupportsExternalKeying(false),
|
|
|
|
|
@@ -340,9 +426,32 @@ bool OpenGLComposite::InitDeckLink()
|
|
|
|
|
IDeckLinkDisplayModeIterator* pDLDisplayModeIterator = NULL;
|
|
|
|
|
IDeckLinkDisplayMode* pDLDisplayMode = NULL;
|
|
|
|
|
BMDDisplayMode displayMode = bmdModeHD1080p5994; // mode to use for capture and playout
|
|
|
|
|
std::string displayModeName = "1080p59.94";
|
|
|
|
|
int outputFrameRowBytes;
|
|
|
|
|
HRESULT result;
|
|
|
|
|
|
|
|
|
|
if (mRuntimeHost && mRuntimeHost->GetRepoRoot().empty())
|
|
|
|
|
{
|
|
|
|
|
std::string runtimeError;
|
|
|
|
|
if (!mRuntimeHost->Initialize(runtimeError))
|
|
|
|
|
{
|
|
|
|
|
MessageBoxA(NULL, runtimeError.c_str(), "Runtime host failed to initialize", MB_OK);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mRuntimeHost)
|
|
|
|
|
{
|
|
|
|
|
if (!ResolveConfiguredDisplayMode(mRuntimeHost->GetVideoFormat(), mRuntimeHost->GetFrameRate(), displayMode, displayModeName))
|
|
|
|
|
{
|
|
|
|
|
const std::string error = "Unsupported DeckLink video format/frameRate in config/runtime-host.json: " +
|
|
|
|
|
mRuntimeHost->GetVideoFormat() + " / " + mRuntimeHost->GetFrameRate();
|
|
|
|
|
MessageBoxA(NULL, error.c_str(), "DeckLink mode configuration error", MB_OK);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mDisplayModeName = displayModeName;
|
|
|
|
|
|
|
|
|
|
result = CoCreateInstance(CLSID_CDeckLinkIterator, NULL, CLSCTX_ALL, IID_IDeckLinkIterator, (void**)&pDLIterator);
|
|
|
|
|
if (FAILED(result))
|
|
|
|
|
{
|
|
|
|
|
@@ -444,7 +553,8 @@ bool OpenGLComposite::InitDeckLink()
|
|
|
|
|
|
|
|
|
|
if (pDLDisplayMode == NULL)
|
|
|
|
|
{
|
|
|
|
|
MessageBox(NULL, _T("Cannot get specified BMDDisplayMode."), _T("DeckLink error."), MB_OK);
|
|
|
|
|
const std::string error = "Cannot get specified BMDDisplayMode for configured mode: " + displayModeName;
|
|
|
|
|
MessageBoxA(NULL, error.c_str(), "DeckLink error.", MB_OK);
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -697,7 +807,7 @@ bool OpenGLComposite::InitOpenGLState()
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
std::string runtimeError;
|
|
|
|
|
if (!mRuntimeHost->Initialize(runtimeError))
|
|
|
|
|
if (mRuntimeHost->GetRepoRoot().empty() && !mRuntimeHost->Initialize(runtimeError))
|
|
|
|
|
{
|
|
|
|
|
MessageBoxA(NULL, runtimeError.c_str(), "Runtime host failed to initialize", MB_OK);
|
|
|
|
|
return false;
|
|
|
|
|
@@ -867,7 +977,7 @@ void OpenGLComposite::VideoFrameArrived(IDeckLinkVideoInputFrame* inputFrame, bo
|
|
|
|
|
{
|
|
|
|
|
mHasNoInputSource = hasNoInputSource;
|
|
|
|
|
if (mRuntimeHost)
|
|
|
|
|
mRuntimeHost->SetSignalStatus(!hasNoInputSource, mFrameWidth, mFrameHeight, kDisplayModeName);
|
|
|
|
|
mRuntimeHost->SetSignalStatus(!hasNoInputSource, mFrameWidth, mFrameHeight, mDisplayModeName);
|
|
|
|
|
|
|
|
|
|
if (mHasNoInputSource)
|
|
|
|
|
return; // don't transfer texture when there's no input
|
|
|
|
|
|