25 #include <DeckLinkAPI.h>
50 virtual BMDPixelFormat STDMETHODCALLTYPE
GetPixelFormat(
void) {
return bmdFormat8BitYUV; }
51 virtual BMDFrameFlags STDMETHODCALLTYPE
GetFlags (
void) {
return _avframe->
linesize[0] < 0 ? bmdFrameFlagFlipVertical : bmdFrameFlagDefault; }
117 " Only AV_PIX_FMT_UYVY422 is supported.\n");
123 " Check available formats with -list_formats 1.\n");
126 if (
ctx->dlo->EnableVideoOutput(
ctx->bmd_mode,
127 bmdVideoOutputFlagDefault) !=
S_OK) {
134 ctx->dlo->SetScheduledFrameCompletionCallback(
ctx->output_callback);
139 ctx->frames_preroll /= 1000;
142 ctx->frames_buffer =
ctx->frames_preroll * 2;
143 ctx->frames_buffer =
FFMIN(
ctx->frames_buffer, 60);
166 " Only 48kHz is supported.\n");
171 " Only stereo and 7.1 are supported.\n");
174 if (
ctx->dlo->EnableAudioOutput(bmdAudioSampleRate48kHz,
175 bmdAudioSampleType16bitInteger,
177 bmdAudioOutputStreamTimestamped) !=
S_OK) {
181 if (
ctx->dlo->BeginAudioPreroll() !=
S_OK) {
200 if (
ctx->playback_started) {
202 ctx->dlo->StopScheduledPlayback(
ctx->last_pts *
ctx->bmd_tb_num,
203 &actual,
ctx->bmd_tb_den);
204 ctx->dlo->DisableVideoOutput();
206 ctx->dlo->DisableAudioOutput();
211 if (
ctx->output_callback)
212 delete ctx->output_callback;
253 hr =
ctx->dlo->ScheduleVideoFrame((
struct IDeckLinkVideoFrame *)
frame,
254 pkt->
pts *
ctx->bmd_tb_num,
255 ctx->bmd_tb_num,
ctx->bmd_tb_den);
260 " error %08x.\n", (uint32_t) hr);
264 ctx->dlo->GetBufferedVideoFrameCount(&buffered);
266 if (pkt->
pts > 2 && buffered <= 2)
268 " Video may misbehave!\n");
271 if (!
ctx->playback_started && pkt->
pts >
ctx->frames_preroll) {
273 if (
ctx->audio &&
ctx->dlo->EndAudioPreroll() !=
S_OK) {
278 if (
ctx->dlo->StartScheduledPlayback(0,
ctx->bmd_tb_den, 1.0) !=
S_OK) {
282 ctx->playback_started = 1;
292 int sample_count = pkt->
size / (
ctx->channels << 1);
295 ctx->dlo->GetBufferedAudioSampleFrameCount(&buffered);
296 if (pkt->
pts > 1 && !buffered)
298 " Audio will misbehave!\n");
300 if (
ctx->dlo->ScheduleAudioSamples(pkt->
data, sample_count, pkt->
pts,
301 bmdAudioSampleRate48kHz,
NULL) !=
S_OK) {
327 if (
ctx->list_devices) {
337 if (
ctx->dl->QueryInterface(IID_IDeckLinkOutput, (
void **) &
ctx->dlo) !=
S_OK) {
345 if (
ctx->list_formats) {
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
enum AVFieldOrder field_order
Video only.
This structure describes decoded (raw) audio or video data.
virtual long STDMETHODCALLTYPE GetWidth(void)
#define AV_LOG_WARNING
Something somehow does not look correct.
static int decklink_setup_video(AVFormatContext *avctx, AVStream *st)
static int decklink_write_audio_packet(AVFormatContext *avctx, AVPacket *pkt)
int ff_decklink_init_device(AVFormatContext *avctx, const char *name)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
This struct describes the properties of an encoded stream.
av_cold int ff_decklink_write_trailer(AVFormatContext *avctx)
static int decklink_write_video_packet(AVFormatContext *avctx, AVPacket *pkt)
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv)
virtual long STDMETHODCALLTYPE GetHeight(void)
AVStream ** streams
A list of all streams in the file.
int ff_decklink_set_format(AVFormatContext *avctx, int width, int height, int tb_num, int tb_den, enum AVFieldOrder field_order, decklink_direction_t direction, int num)
static int decklink_setup_audio(AVFormatContext *avctx, AVStream *st)
virtual ULONG STDMETHODCALLTYPE Release(void)
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
virtual HRESULT STDMETHODCALLTYPE ScheduledPlaybackHasStopped(void)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
enum AVMediaType codec_type
General type of the encoded data.
#define sem_destroy(psem)
virtual BMDPixelFormat STDMETHODCALLTYPE GetPixelFormat(void)
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
char filename[1024]
input or output filename
struct decklink_ctx * _ctx
av_cold int ff_decklink_write_header(AVFormatContext *avctx)
uint32_t buffercount_type
int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direction)
virtual long STDMETHODCALLTYPE GetRowBytes(void)
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
static void error(const char *err)
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
virtual ULONG STDMETHODCALLTYPE AddRef(void)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int ff_decklink_list_devices(AVFormatContext *avctx)
static const char * format
virtual BMDFrameFlags STDMETHODCALLTYPE GetFlags(void)
virtual HRESULT STDMETHODCALLTYPE GetBytes(void **buffer)
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
void ff_decklink_cleanup(AVFormatContext *avctx)
int sample_rate
Audio only.
virtual HRESULT STDMETHODCALLTYPE ScheduledFrameCompleted(IDeckLinkVideoFrame *_frame, BMDOutputFrameCompletionResult result)
virtual HRESULT STDMETHODCALLTYPE GetAncillaryData(IDeckLinkVideoFrameAncillary **ancillary)
virtual ULONG STDMETHODCALLTYPE AddRef(void)
void * priv_data
Format private data.
int ff_decklink_write_packet(AVFormatContext *avctx, AVPacket *pkt)
AVCodecParameters * codecpar
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
virtual HRESULT STDMETHODCALLTYPE GetTimecode(BMDTimecodeFormat format, IDeckLinkTimecode **timecode)
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
decklink_frame(struct decklink_ctx *ctx, AVFrame *avframe)
virtual ULONG STDMETHODCALLTYPE Release(void)