22 #include <DeckLinkAPI.h>
24 #include <DeckLinkAPI_i.c>
26 #include <DeckLinkAPIDispatch.cpp>
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)
73 #elif defined(__APPLE__)
74 static char *dup_cfstring_to_utf8(CFStringRef w)
77 CFStringGetCString(w, s, 255, kCFStringEncodingUTF8);
80 #define DECKLINK_STR const __CFString *
81 #define DECKLINK_STRDUP dup_cfstring_to_utf8
82 #define DECKLINK_FREE(s) free((void *) s)
84 #define DECKLINK_STR const char *
85 #define DECKLINK_STRDUP av_strdup
87 #define DECKLINK_FREE(s) free((void *) s)
93 HRESULT hr = This->GetDisplayName(&tmpDisplayName);
103 int tb_num,
int tb_den,
108 BMDDisplayModeSupport support;
109 IDeckLinkDisplayModeIterator *itermode;
110 IDeckLinkDisplayMode *
mode;
115 res =
ctx->dli->GetDisplayModeIterator (&itermode);
117 res =
ctx->dlo->GetDisplayModeIterator (&itermode);
130 ctx->bmd_mode = bmdModeUnknown;
131 while ((
ctx->bmd_mode == bmdModeUnknown) && itermode->Next(&mode) ==
S_OK) {
132 BMDTimeValue bmd_tb_num, bmd_tb_den;
133 int bmd_width = mode->GetWidth();
134 int bmd_height = mode->GetHeight();
136 mode->GetFrameRate(&bmd_tb_num, &bmd_tb_den);
138 if ((bmd_width == width && bmd_height == height &&
139 bmd_tb_num == tb_num && bmd_tb_den == tb_den) || i == num) {
140 ctx->bmd_mode = mode->GetDisplayMode();
141 ctx->bmd_width = bmd_width;
142 ctx->bmd_height = bmd_height;
143 ctx->bmd_tb_den = bmd_tb_den;
144 ctx->bmd_tb_num = bmd_tb_num;
145 ctx->bmd_field_dominance = mode->GetFieldDominance();
147 bmd_width, bmd_height, (
float)bmd_tb_den/(
float)bmd_tb_num,
148 (
ctx->bmd_field_dominance==bmdLowerFieldFirst ||
ctx->bmd_field_dominance==bmdUpperFieldFirst)?
"(i)":
"");
157 if (
ctx->bmd_mode == bmdModeUnknown)
160 if (
ctx->dli->DoesSupportVideoMode(
ctx->bmd_mode, bmdFormat8BitYUV,
161 bmdVideoOutputFlagDefault,
165 if (
ctx->dlo->DoesSupportVideoMode(
ctx->bmd_mode, bmdFormat8BitYUV,
166 bmdVideoOutputFlagDefault,
170 if (support == bmdDisplayModeSupported)
182 IDeckLink *dl =
NULL;
183 IDeckLinkIterator *iter = CreateDeckLinkIteratorInstance();
189 while (iter->Next(&dl) ==
S_OK) {
190 const char *displayName;
204 IDeckLinkDisplayModeIterator *itermode;
205 IDeckLinkDisplayMode *
mode;
210 res =
ctx->dli->GetDisplayModeIterator (&itermode);
212 res =
ctx->dlo->GetDisplayModeIterator (&itermode);
222 while (itermode->Next(&mode) ==
S_OK) {
223 BMDTimeValue tb_num, tb_den;
224 mode->GetFrameRate(&tb_num, &tb_den);
226 ++i,mode->GetWidth(), mode->GetHeight(),
227 (int) tb_den, (
int) tb_num);
228 switch (mode->GetFieldDominance()) {
229 case bmdLowerFieldFirst:
231 case bmdUpperFieldFirst:
int ff_decklink_set_format(AVFormatContext *avctx, int width, int height, int tb_num, int tb_den, decklink_direction_t direction, int num)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static char * dup_wchar_to_utf8(wchar_t *w)
char filename[1024]
input or output filename
int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direction)
#define AV_LOG_INFO
Standard information.
char * av_strdup(const char *s)
Duplicate the string s.
int ff_decklink_list_devices(AVFormatContext *avctx)
HRESULT ff_decklink_get_display_name(IDeckLink *This, const char **displayName)
void * priv_data
Format private data.