22 #include <DeckLinkAPI.h>
25 #include <semaphore.h>
49 for (pkt = q->
first_pkt; pkt != NULL; pkt = pkt1) {
70 unsigned long long size;
156 virtual HRESULT STDMETHODCALLTYPE
VideoInputFormatChanged(BMDVideoInputFormatChangedEvents, IDeckLinkDisplayMode*, BMDDetectedVideoInputFormatFlags);
207 IDeckLinkVideoInputFrame *videoFrame, IDeckLinkAudioInputPacket *audioFrame)
210 void *audioFrameBytes;
211 BMDTimeValue frameTime;
212 BMDTimeValue frameDuration;
225 "Frame received (#%lu) - Valid (%liB) - QSize %fMB\n",
227 videoFrame->GetRowBytes() * videoFrame->GetHeight(),
228 (double)qsize / 1024 / 1024);
231 videoFrame->GetBytes(&frameBytes);
232 videoFrame->GetStreamTime(&frameTime, &frameDuration,
235 if (videoFrame->GetFlags() & bmdFrameHasNoInputSource) {
237 0xEA80EA80, 0xD292D210, 0xA910A9A5, 0x90229035,
238 0x6ADD6ACA, 0x51EF515A, 0x286D28EF, 0x10801080 };
239 int width = videoFrame->GetWidth();
240 int height = videoFrame->GetHeight();
241 unsigned *p = (
unsigned *)frameBytes;
244 for (
int x = 0; x <
width; x += 2)
245 *p++ = bars[(x * 8) /
width];
275 pkt.
size = videoFrame->GetRowBytes() *
276 videoFrame->GetHeight();
288 BMDTimeValue audio_pts;
294 audioFrame->GetBytes(&audioFrameBytes);
320 BMDVideoInputFormatChangedEvents events, IDeckLinkDisplayMode *
mode,
321 BMDDetectedVideoInputFormatFlags)
332 ctx->dli->SetCallback(
ctx->input_callback);
333 return ctx->dli->StartStreams();
343 if (
ctx->capture_started) {
344 ctx->dli->StopStreams();
345 ctx->dli->DisableVideoInput();
346 ctx->dli->DisableAudioInput();
365 IDeckLinkDisplayModeIterator *itermode;
366 IDeckLinkIterator *iter;
367 IDeckLink *dl = NULL;
382 iter = CreateDeckLinkIteratorInstance();
389 if (
ctx->list_devices) {
395 tmp=strchr (fname,
'@');
397 mode_num = atoi (tmp+1);
402 while (iter->Next(&dl) ==
S_OK) {
403 const char *displayName;
405 if (!strcmp(fname, displayName)) {
420 if (
ctx->dl->QueryInterface(IID_IDeckLinkInput, (
void **) &
ctx->dli) !=
S_OK) {
428 if (
ctx->list_formats) {
435 if (
ctx->dli->GetDisplayModeIterator(&itermode) !=
S_OK) {
458 st->codec->sample_rate = bmdAudioSampleRate48kHz;
459 st->codec->channels = 2;
470 st->codec->width =
ctx->bmd_width;
471 st->codec->height =
ctx->bmd_height;
474 st->codec->time_base.den =
ctx->bmd_tb_den;
475 st->codec->time_base.num =
ctx->bmd_tb_num;
477 st->codec->codec_tag =
MKTAG(
'U',
'Y',
'V',
'Y');
483 result =
ctx->dli->EnableAudioInput(bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger, 2);
485 if (result !=
S_OK) {
490 result =
ctx->dli->EnableVideoInput(
ctx->bmd_mode, bmdFormat8BitYUV, bmdVideoInputFlagDefault);
492 if (result !=
S_OK) {
521 if (frame && (
ctx->bmd_field_dominance == bmdUpperFieldFirst ||
ctx->bmd_field_dominance == bmdLowerFieldFirst)) {
523 if (
ctx->bmd_field_dominance == bmdUpperFieldFirst) {