22 #include <DeckLinkAPI.h>
25 #include <semaphore.h>
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) {
236 if (videoFrame->GetPixelFormat() == bmdFormat8BitYUV) {
238 0xEA80EA80, 0xD292D210, 0xA910A9A5, 0x90229035,
239 0x6ADD6ACA, 0x51EF515A, 0x286D28EF, 0x10801080 };
240 int width = videoFrame->GetWidth();
241 int height = videoFrame->GetHeight();
242 unsigned *p = (
unsigned *)frameBytes;
245 for (
int x = 0; x <
width; x += 2)
246 *p++ = bars[(x * 8) /
width];
277 pkt.
size = videoFrame->GetRowBytes() *
278 videoFrame->GetHeight();
290 BMDTimeValue audio_pts;
296 audioFrame->GetBytes(&audioFrameBytes);
322 BMDVideoInputFormatChangedEvents events, IDeckLinkDisplayMode *
mode,
323 BMDDetectedVideoInputFormatFlags)
334 ctx->dli->SetCallback(
ctx->input_callback);
335 return ctx->dli->StartStreams();
345 if (
ctx->capture_started) {
346 ctx->dli->StopStreams();
347 ctx->dli->DisableVideoInput();
348 ctx->dli->DisableAudioInput();
367 IDeckLinkDisplayModeIterator *itermode;
368 IDeckLinkIterator *iter;
369 IDeckLink *dl =
NULL;
384 iter = CreateDeckLinkIteratorInstance();
391 if (
ctx->list_devices) {
397 tmp=strchr (fname,
'@');
399 mode_num = atoi (tmp+1);
404 while (iter->Next(&dl) ==
S_OK) {
405 const char *displayName;
407 if (!strcmp(fname, displayName)) {
422 if (
ctx->dl->QueryInterface(IID_IDeckLinkInput, (
void **) &
ctx->dli) !=
S_OK) {
430 if (
ctx->list_formats) {
437 if (
ctx->dli->GetDisplayModeIterator(&itermode) !=
S_OK) {
460 st->codec->sample_rate = bmdAudioSampleRate48kHz;
461 st->codec->channels = 2;
471 st->codec->width =
ctx->bmd_width;
472 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;
480 st->codec->codec_tag =
MKTAG(
'V',
'2',
'1',
'0');
484 st->codec->codec_tag =
MKTAG(
'U',
'Y',
'V',
'Y');
491 result =
ctx->dli->EnableAudioInput(bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger, 2);
493 if (result !=
S_OK) {
498 result =
ctx->dli->EnableVideoInput(
ctx->bmd_mode,
499 cctx->
v210 ? bmdFormat10BitYUV : bmdFormat8BitYUV,
500 bmdVideoInputFlagDefault);
502 if (result !=
S_OK) {
531 if (frame && (
ctx->bmd_field_dominance == bmdUpperFieldFirst ||
ctx->bmd_field_dominance == bmdLowerFieldFirst)) {
533 if (
ctx->bmd_field_dominance == bmdUpperFieldFirst) {