Decklink: add output support

This commit is contained in:
Colin Edwards
2018-09-25 17:51:32 -05:00
parent f8e628ac36
commit 21b67cff64
23 changed files with 1102 additions and 439 deletions

View File

@@ -10,7 +10,10 @@ DeckLinkDevice::DeckLinkDevice(IDeckLink *device_) : device(device_)
DeckLinkDevice::~DeckLinkDevice(void)
{
for (DeckLinkDeviceMode *mode : modes)
for (DeckLinkDeviceMode *mode : inputModes)
delete mode;
for (DeckLinkDeviceMode *mode : outputModes)
delete mode;
}
@@ -37,35 +40,61 @@ bool DeckLinkDevice::Init()
decklink_bool_t detectable = false;
if (attributes->GetFlag(BMDDeckLinkSupportsInputFormatDetection,
&detectable) == S_OK && !!detectable) {
DeckLinkDeviceMode *mode =
new DeckLinkDeviceMode("Auto", MODE_ID_AUTO);
modes.push_back(mode);
modeIdMap[MODE_ID_AUTO] = mode;
DeckLinkDeviceMode *mode = new DeckLinkDeviceMode(
"Auto",
MODE_ID_AUTO);
inputModes.push_back(mode);
inputModeIdMap[MODE_ID_AUTO] = mode;
}
}
// Find input modes
ComPtr<IDeckLinkInput> input;
if (device->QueryInterface(IID_IDeckLinkInput, (void**)&input) != S_OK)
return false;
if (device->QueryInterface(IID_IDeckLinkInput, (void **) &input) == S_OK) {
IDeckLinkDisplayModeIterator *modeIterator;
if (input->GetDisplayModeIterator(&modeIterator) == S_OK) {
IDeckLinkDisplayMode *displayMode;
long long modeId = 1;
IDeckLinkDisplayModeIterator *modeIterator;
if (input->GetDisplayModeIterator(&modeIterator) == S_OK) {
IDeckLinkDisplayMode *displayMode;
long long modeId = 1;
while (modeIterator->Next(&displayMode) == S_OK) {
if (displayMode == nullptr)
continue;
while (modeIterator->Next(&displayMode) == S_OK) {
if (displayMode == nullptr)
continue;
DeckLinkDeviceMode *mode =
new DeckLinkDeviceMode(displayMode, modeId);
inputModes.push_back(mode);
inputModeIdMap[modeId] = mode;
displayMode->Release();
++modeId;
}
DeckLinkDeviceMode *mode =
new DeckLinkDeviceMode(displayMode, modeId);
modes.push_back(mode);
modeIdMap[modeId] = mode;
displayMode->Release();
++modeId;
modeIterator->Release();
}
}
modeIterator->Release();
// find output modes
ComPtr<IDeckLinkOutput> output;
if (device->QueryInterface(IID_IDeckLinkOutput, (void **) &output) == S_OK) {
IDeckLinkDisplayModeIterator *modeIterator;
if (output->GetDisplayModeIterator(&modeIterator) == S_OK) {
IDeckLinkDisplayMode *displayMode;
long long modeId = 1;
while (modeIterator->Next(&displayMode) == S_OK) {
if (displayMode == nullptr)
continue;
DeckLinkDeviceMode *mode =
new DeckLinkDeviceMode(displayMode, modeId);
outputModes.push_back(mode);
outputModeIdMap[modeId] = mode;
displayMode->Release();
++modeId;
}
modeIterator->Release();
}
}
decklink_string_t decklinkModelName;
@@ -115,9 +144,22 @@ bool DeckLinkDevice::GetInput(IDeckLinkInput **input)
return true;
}
DeckLinkDeviceMode *DeckLinkDevice::FindMode(long long id)
bool DeckLinkDevice::GetOutput(IDeckLinkOutput **output)
{
return modeIdMap[id];
if (device->QueryInterface(IID_IDeckLinkOutput, (void**)output) != S_OK)
return false;
return true;
}
DeckLinkDeviceMode *DeckLinkDevice::FindInputMode(long long id)
{
return inputModeIdMap[id];
}
DeckLinkDeviceMode *DeckLinkDevice::FindOutputMode(long long id)
{
return outputModeIdMap[id];
}
const std::string& DeckLinkDevice::GetDisplayName(void)
@@ -130,9 +172,14 @@ const std::string& DeckLinkDevice::GetHash(void) const
return hash;
}
const std::vector<DeckLinkDeviceMode *>& DeckLinkDevice::GetModes(void) const
const std::vector<DeckLinkDeviceMode *>& DeckLinkDevice::GetInputModes(void) const
{
return modes;
return inputModes;
}
const std::vector<DeckLinkDeviceMode *>& DeckLinkDevice::GetOutputModes(void) const
{
return outputModes;
}
const std::string& DeckLinkDevice::GetName(void) const