2015-02-18 15:15:38 -08:00
|
|
|
#include "decklink-device-mode.hpp"
|
|
|
|
|
|
|
|
DeckLinkDeviceMode::DeckLinkDeviceMode(IDeckLinkDisplayMode *mode, long long id)
|
|
|
|
: id(id), mode(mode)
|
|
|
|
{
|
|
|
|
if (mode == nullptr)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mode->AddRef();
|
|
|
|
|
|
|
|
decklink_string_t decklinkStringName;
|
|
|
|
if (mode->GetName(&decklinkStringName) == S_OK)
|
|
|
|
DeckLinkStringToStdString(decklinkStringName, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
DeckLinkDeviceMode::DeckLinkDeviceMode(const std::string &name, long long id)
|
|
|
|
: id(id), mode(nullptr), name(name)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DeckLinkDeviceMode::~DeckLinkDeviceMode(void)
|
|
|
|
{
|
|
|
|
if (mode != nullptr)
|
|
|
|
mode->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
BMDDisplayMode DeckLinkDeviceMode::GetDisplayMode(void) const
|
|
|
|
{
|
|
|
|
if (mode != nullptr)
|
|
|
|
return mode->GetDisplayMode();
|
|
|
|
|
|
|
|
return bmdModeUnknown;
|
|
|
|
}
|
|
|
|
|
2018-09-25 17:51:32 -05:00
|
|
|
int DeckLinkDeviceMode::GetWidth()
|
|
|
|
{
|
|
|
|
if (mode != nullptr)
|
|
|
|
return mode->GetWidth();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int DeckLinkDeviceMode::GetHeight()
|
|
|
|
{
|
|
|
|
if (mode != nullptr)
|
|
|
|
return mode->GetHeight();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-05-05 21:55:06 +09:00
|
|
|
BMDDisplayModeFlags DeckLinkDeviceMode::GetDisplayModeFlags(void) const
|
|
|
|
{
|
|
|
|
if (mode != nullptr)
|
|
|
|
return mode->GetFlags();
|
|
|
|
|
|
|
|
return (BMDDisplayModeFlags)0;
|
|
|
|
}
|
|
|
|
|
2015-02-18 15:15:38 -08:00
|
|
|
long long DeckLinkDeviceMode::GetId(void) const
|
|
|
|
{
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string &DeckLinkDeviceMode::GetName(void) const
|
|
|
|
{
|
|
|
|
return name;
|
|
|
|
}
|
2017-05-05 21:55:06 +09:00
|
|
|
|
2021-04-20 22:24:33 -07:00
|
|
|
bool DeckLinkDeviceMode::IsEqualFrameRate(int64_t num, int64_t den)
|
|
|
|
{
|
2021-07-23 20:32:53 -07:00
|
|
|
bool equal = false;
|
2021-04-20 22:24:33 -07:00
|
|
|
|
2021-07-23 20:32:53 -07:00
|
|
|
if (mode) {
|
|
|
|
BMDTimeValue frameDuration;
|
|
|
|
BMDTimeScale timeScale;
|
|
|
|
if (SUCCEEDED(mode->GetFrameRate(&frameDuration, &timeScale)))
|
|
|
|
equal = timeScale * den == frameDuration * num;
|
|
|
|
}
|
2021-04-20 22:24:33 -07:00
|
|
|
|
2021-07-23 20:32:53 -07:00
|
|
|
return equal;
|
2021-04-20 22:24:33 -07:00
|
|
|
}
|
|
|
|
|
2017-05-05 21:55:06 +09:00
|
|
|
void DeckLinkDeviceMode::SetMode(IDeckLinkDisplayMode *mode_)
|
|
|
|
{
|
|
|
|
IDeckLinkDisplayMode *old = mode;
|
|
|
|
if (old != nullptr)
|
|
|
|
old->Release();
|
|
|
|
|
|
|
|
mode = mode_;
|
|
|
|
if (mode != nullptr)
|
|
|
|
mode->AddRef();
|
|
|
|
}
|