22 #include <DeckLinkAPI.h>
25 #include <semaphore.h>
49 virtual BMDPixelFormat STDMETHODCALLTYPE
GetPixelFormat(
void) {
return bmdFormat8BitYUV; }
50 virtual BMDFrameFlags STDMETHODCALLTYPE
GetFlags (
void) {
return bmdVideoOutputFlagDefault; }
104 " Only AV_PIX_FMT_UYVY422 is supported.\n");
110 " Check available formats with -list_formats 1.\n");
113 if (
ctx->dlo->EnableVideoOutput(
ctx->bmd_mode,
114 bmdVideoOutputFlagDefault) !=
S_OK) {
121 ctx->dlo->SetScheduledFrameCompletionCallback(
ctx->output_callback);
126 ctx->frames_preroll /= 1000;
129 ctx->frames_buffer =
ctx->frames_preroll * 2;
130 ctx->frames_buffer =
FFMIN(
ctx->frames_buffer, 60);
131 sem_init(&
ctx->semaphore, 0,
ctx->frames_buffer);
153 " Only 48kHz is supported.\n");
158 " Only stereo and 7.1 are supported.\n");
161 if (
ctx->dlo->EnableAudioOutput(bmdAudioSampleRate48kHz,
162 bmdAudioSampleType16bitInteger,
164 bmdAudioOutputStreamTimestamped) !=
S_OK) {
168 if (
ctx->dlo->BeginAudioPreroll() !=
S_OK) {
187 if (
ctx->playback_started) {
189 ctx->dlo->StopScheduledPlayback(
ctx->last_pts *
ctx->bmd_tb_num,
190 &actual,
ctx->bmd_tb_den);
191 ctx->dlo->DisableVideoOutput();
193 ctx->dlo->DisableAudioOutput();
201 if (
ctx->output_callback)
202 delete ctx->output_callback;
204 sem_destroy(&
ctx->semaphore);
228 tmp->width =
ctx->bmd_width;
229 tmp->height =
ctx->bmd_height;
247 (
void *) avframe->
data[0]);
254 sem_wait(&
ctx->semaphore);
257 hr =
ctx->dlo->ScheduleVideoFrame((
struct IDeckLinkVideoFrame *)
frame,
258 pkt->
pts *
ctx->bmd_tb_num,
259 ctx->bmd_tb_num,
ctx->bmd_tb_den);
262 " error %08x.\n", (uint32_t) hr);
267 ctx->dlo->GetBufferedVideoFrameCount(&buffered);
269 if (pkt->
pts > 2 && buffered <= 2)
271 " Video may misbehave!\n");
274 if (!
ctx->playback_started && pkt->
pts >
ctx->frames_preroll) {
276 if (
ctx->audio &&
ctx->dlo->EndAudioPreroll() !=
S_OK) {
281 if (
ctx->dlo->StartScheduledPlayback(0,
ctx->bmd_tb_den, 1.0) !=
S_OK) {
285 ctx->playback_started = 1;
295 int sample_count = pkt->
size / (
ctx->channels << 1);
298 ctx->dlo->GetBufferedAudioSampleFrameCount(&buffered);
299 if (pkt->
pts > 1 && !buffered)
301 " Audio will misbehave!\n");
303 if (
ctx->dlo->ScheduleAudioSamples(pkt->
data, sample_count, pkt->
pts,
304 bmdAudioSampleRate48kHz,
NULL) !=
S_OK) {
318 IDeckLinkDisplayModeIterator *itermode;
319 IDeckLinkIterator *iter;
320 IDeckLink *dl =
NULL;
331 iter = CreateDeckLinkIteratorInstance();
338 if (
ctx->list_devices) {
344 while (iter->Next(&dl) ==
S_OK) {
345 const char *displayName;
347 if (!strcmp(avctx->
filename, displayName)) {
362 if (
ctx->dl->QueryInterface(IID_IDeckLinkOutput, (
void **) &
ctx->dlo) !=
S_OK) {
370 if (
ctx->list_formats) {
377 if (
ctx->dlo->GetDisplayModeIterator(&itermode) !=
S_OK) {