22 #include <DeckLinkAPI.h>
24 #include <DeckLinkAPI_i.c>
26 #include <DeckLinkAPIDispatch.cpp>
30 #include <semaphore.h>
41 IDeckLinkIterator *CreateDeckLinkIteratorInstance(
void)
43 IDeckLinkIterator *iter;
45 if (CoInitialize(NULL) < 0) {
50 if (CoCreateInstance(CLSID_CDeckLinkIterator, NULL, CLSCTX_ALL,
51 IID_IDeckLinkIterator, (
void**) &iter) !=
S_OK) {
64 int l = WideCharToMultiByte(CP_UTF8, 0, w, -1, 0, 0, 0, 0);
67 WideCharToMultiByte(CP_UTF8, 0, w, -1, s, l, 0, 0);
70 #define DECKLINK_STR OLECHAR *
71 #define DECKLINK_STRDUP dup_wchar_to_utf8
72 #define DECKLINK_FREE(s) SysFreeString(s)
74 #define DECKLINK_STR const char *
75 #define DECKLINK_STRDUP av_strdup
77 #define DECKLINK_FREE(s) free((void *) s)
83 HRESULT hr = This->GetDisplayName(&tmpDisplayName);
93 int tb_num,
int tb_den,
98 BMDDisplayModeSupport support;
99 IDeckLinkDisplayModeIterator *itermode;
100 IDeckLinkDisplayMode *
mode;
105 res =
ctx->dli->GetDisplayModeIterator (&itermode);
107 res =
ctx->dlo->GetDisplayModeIterator (&itermode);
120 ctx->bmd_mode = bmdModeUnknown;
121 while ((
ctx->bmd_mode == bmdModeUnknown) && itermode->Next(&mode) ==
S_OK) {
122 BMDTimeValue bmd_tb_num, bmd_tb_den;
123 int bmd_width = mode->GetWidth();
124 int bmd_height = mode->GetHeight();
126 mode->GetFrameRate(&bmd_tb_num, &bmd_tb_den);
128 if ((bmd_width == width && bmd_height == height &&
129 bmd_tb_num == tb_num && bmd_tb_den == tb_den) || i == num) {
130 ctx->bmd_mode = mode->GetDisplayMode();
131 ctx->bmd_width = bmd_width;
132 ctx->bmd_height = bmd_height;
133 ctx->bmd_tb_den = bmd_tb_den;
134 ctx->bmd_tb_num = bmd_tb_num;
135 ctx->bmd_field_dominance = mode->GetFieldDominance();
137 bmd_width, bmd_height, (
float)bmd_tb_den/(
float)bmd_tb_num,
138 (
ctx->bmd_field_dominance==bmdLowerFieldFirst ||
ctx->bmd_field_dominance==bmdUpperFieldFirst)?
"(i)":
"");
147 if (
ctx->bmd_mode == bmdModeUnknown)
150 if (
ctx->dli->DoesSupportVideoMode(
ctx->bmd_mode, bmdFormat8BitYUV,
151 bmdVideoOutputFlagDefault,
152 &support, NULL) !=
S_OK)
155 if (
ctx->dlo->DoesSupportVideoMode(
ctx->bmd_mode, bmdFormat8BitYUV,
156 bmdVideoOutputFlagDefault,
157 &support, NULL) !=
S_OK)
160 if (support == bmdDisplayModeSupported)
172 IDeckLink *dl = NULL;
173 IDeckLinkIterator *iter = CreateDeckLinkIteratorInstance();
179 while (iter->Next(&dl) ==
S_OK) {
180 const char *displayName;
194 IDeckLinkDisplayModeIterator *itermode;
195 IDeckLinkDisplayMode *
mode;
200 res =
ctx->dli->GetDisplayModeIterator (&itermode);
202 res =
ctx->dlo->GetDisplayModeIterator (&itermode);
212 while (itermode->Next(&mode) ==
S_OK) {
213 BMDTimeValue tb_num, tb_den;
214 mode->GetFrameRate(&tb_num, &tb_den);
216 ++i,mode->GetWidth(), mode->GetHeight(),
217 (int) tb_den, (
int) tb_num);
218 switch (mode->GetFieldDominance()) {
219 case bmdLowerFieldFirst:
221 case bmdUpperFieldFirst: