Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions libavdevice/decklink_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,8 @@ int ff_decklink_list_devices(AVFormatContext *avctx,
return AVERROR(EIO);

while (ret == 0 && iter->Next(&dl) == S_OK) {
IDeckLinkOutput *output_config;
IDeckLinkInput *input_config;
IDeckLinkOutput_v14_2_1 *output_config;
IDeckLinkInput_v14_2_1 *input_config;
const char *display_name = NULL;
const char *unique_name = NULL;
AVDeviceInfo *new_device = NULL;
Expand All @@ -527,14 +527,14 @@ int ff_decklink_list_devices(AVFormatContext *avctx,
goto next;

if (show_outputs) {
if (dl->QueryInterface(IID_IDeckLinkOutput, (void **)&output_config) == S_OK) {
if (dl->QueryInterface(IID_IDeckLinkOutput_v14_2_1, (void **)&output_config) == S_OK) {
output_config->Release();
add = 1;
}
}

if (show_inputs) {
if (dl->QueryInterface(IID_IDeckLinkInput, (void **)&input_config) == S_OK) {
if (dl->QueryInterface(IID_IDeckLinkInput_v14_2_1, (void **)&input_config) == S_OK) {
input_config->Release();
add = 1;
}
Expand Down
4 changes: 2 additions & 2 deletions libavdevice/decklink_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ typedef struct DecklinkPacketQueue {
struct decklink_ctx {
/* DeckLink SDK interfaces */
IDeckLink *dl;
IDeckLinkOutput *dlo;
IDeckLinkInput *dli;
IDeckLinkOutput_v14_2_1 *dlo;
IDeckLinkInput_v14_2_1 *dli;
IDeckLinkConfiguration *cfg;
IDeckLinkProfileAttributes *attr;
decklink_output_callback *output_callback;
Expand Down
42 changes: 29 additions & 13 deletions libavdevice/decklink_dec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ static VANCLineNumber vanc_line_numbers[] = {
{bmdModeUnknown, 0, -1, -1, -1}
};

class decklink_allocator : public IDeckLinkMemoryAllocator
class decklink_allocator : public IDeckLinkMemoryAllocator_v14_2_1
{
public:
decklink_allocator(): _refs(1) { }
virtual ~decklink_allocator() { }

// IDeckLinkMemoryAllocator methods
// IDeckLinkMemoryAllocator_v14_2_1 methods
virtual HRESULT STDMETHODCALLTYPE AllocateBuffer(unsigned int bufferSize, void* *allocatedBuffer)
{
void *buf = av_malloc(bufferSize + AV_INPUT_BUFFER_PADDING_SIZE);
Expand All @@ -129,7 +129,15 @@ class decklink_allocator : public IDeckLinkMemoryAllocator
virtual HRESULT STDMETHODCALLTYPE Decommit() { return S_OK; }

// IUnknown methods
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv) { return E_NOINTERFACE; }
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv)
{
if (iid == IID_IDeckLinkMemoryAllocator_v14_2_1) {
*ppv = (IDeckLinkMemoryAllocator_v14_2_1*)this;
AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
virtual ULONG STDMETHODCALLTYPE AddRef(void) { return ++_refs; }
virtual ULONG STDMETHODCALLTYPE Release(void)
{
Expand Down Expand Up @@ -472,7 +480,7 @@ static uint8_t *get_metadata(AVFormatContext *avctx, uint16_t *buf, size_t width
}


static void handle_klv(AVFormatContext *avctx, decklink_ctx *ctx, IDeckLinkVideoInputFrame *videoFrame, int64_t pts)
static void handle_klv(AVFormatContext *avctx, decklink_ctx *ctx, IDeckLinkVideoInputFrame_v14_2_1 *videoFrame, int64_t pts)
{
const uint8_t KLV_DID = 0x44;
const uint8_t KLV_IN_VANC_SDID = 0x04;
Expand Down Expand Up @@ -574,17 +582,25 @@ static void handle_klv(AVFormatContext *avctx, decklink_ctx *ctx, IDeckLinkVideo
}
}

class decklink_input_callback : public IDeckLinkInputCallback
class decklink_input_callback : public IDeckLinkInputCallback_v14_2_1
{
public:
explicit decklink_input_callback(AVFormatContext *_avctx);
~decklink_input_callback();

virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv) { return E_NOINTERFACE; }
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv)
{
if (iid == IID_IDeckLinkInputCallback_v14_2_1) {
*ppv = (IDeckLinkInputCallback_v14_2_1*)this;
AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
virtual ULONG STDMETHODCALLTYPE AddRef(void);
virtual ULONG STDMETHODCALLTYPE Release(void);
virtual HRESULT STDMETHODCALLTYPE VideoInputFormatChanged(BMDVideoInputFormatChangedEvents, IDeckLinkDisplayMode*, BMDDetectedVideoInputFormatFlags);
virtual HRESULT STDMETHODCALLTYPE VideoInputFrameArrived(IDeckLinkVideoInputFrame*, IDeckLinkAudioInputPacket*);
virtual HRESULT STDMETHODCALLTYPE VideoInputFrameArrived(IDeckLinkVideoInputFrame_v14_2_1*, IDeckLinkAudioInputPacket*);

private:
std::atomic<int> _refs;
Expand All @@ -593,7 +609,7 @@ class decklink_input_callback : public IDeckLinkInputCallback
int no_video;
int64_t initial_video_pts;
int64_t initial_audio_pts;
IDeckLinkVideoInputFrame* last_video_frame;
IDeckLinkVideoInputFrame_v14_2_1* last_video_frame;
};

decklink_input_callback::decklink_input_callback(AVFormatContext *_avctx) : _refs(1)
Expand Down Expand Up @@ -625,7 +641,7 @@ ULONG decklink_input_callback::Release(void)
return ret;
}

static int64_t get_pkt_pts(IDeckLinkVideoInputFrame *videoFrame,
static int64_t get_pkt_pts(IDeckLinkVideoInputFrame_v14_2_1 *videoFrame,
IDeckLinkAudioInputPacket *audioFrame,
int64_t wallclock,
int64_t abs_wallclock,
Expand Down Expand Up @@ -679,7 +695,7 @@ static int64_t get_pkt_pts(IDeckLinkVideoInputFrame *videoFrame,
return pts;
}

static int get_bmd_timecode(AVFormatContext *avctx, AVTimecode *tc, AVRational frame_rate, BMDTimecodeFormat tc_format, IDeckLinkVideoInputFrame *videoFrame)
static int get_bmd_timecode(AVFormatContext *avctx, AVTimecode *tc, AVRational frame_rate, BMDTimecodeFormat tc_format, IDeckLinkVideoInputFrame_v14_2_1 *videoFrame)
{
IDeckLinkTimecode *timecode;
int ret = AVERROR(ENOENT);
Expand All @@ -701,7 +717,7 @@ static int get_bmd_timecode(AVFormatContext *avctx, AVTimecode *tc, AVRational f
return ret;
}

static int get_frame_timecode(AVFormatContext *avctx, decklink_ctx *ctx, AVTimecode *tc, IDeckLinkVideoInputFrame *videoFrame)
static int get_frame_timecode(AVFormatContext *avctx, decklink_ctx *ctx, AVTimecode *tc, IDeckLinkVideoInputFrame_v14_2_1 *videoFrame)
{
AVRational frame_rate = ctx->video_st->r_frame_rate;
int ret;
Expand All @@ -726,7 +742,7 @@ static int get_frame_timecode(AVFormatContext *avctx, decklink_ctx *ctx, AVTimec
}

HRESULT decklink_input_callback::VideoInputFrameArrived(
IDeckLinkVideoInputFrame *videoFrame, IDeckLinkAudioInputPacket *audioFrame)
IDeckLinkVideoInputFrame_v14_2_1 *videoFrame, IDeckLinkAudioInputPacket *audioFrame)
{
void *frameBytes;
void *audioFrameBytes;
Expand Down Expand Up @@ -1141,7 +1157,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
goto error;

/* Get input device. */
if (ctx->dl->QueryInterface(IID_IDeckLinkInput, (void **) &ctx->dli) != S_OK) {
if (ctx->dl->QueryInterface(IID_IDeckLinkInput_v14_2_1, (void **) &ctx->dli) != S_OK) {
av_log(avctx, AV_LOG_ERROR, "Could not open input device from '%s'\n",
avctx->url);
ret = AVERROR(EIO);
Expand Down
32 changes: 25 additions & 7 deletions libavdevice/decklink_enc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extern "C" {
#endif

/* DeckLink callback class declaration */
class decklink_frame : public IDeckLinkVideoFrame
class decklink_frame : public IDeckLinkVideoFrame_v14_2_1
{
public:
decklink_frame(struct decklink_ctx *ctx, AVFrame *avframe, AVCodecID codec_id, int height, int width) :
Expand Down Expand Up @@ -111,7 +111,16 @@ class decklink_frame : public IDeckLinkVideoFrame
_ancillary->AddRef();
return S_OK;
}
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv) { return E_NOINTERFACE; }
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv)
{
if (iid == IID_IDeckLinkVideoFrame_v14_2_1)
{
*ppv = (IDeckLinkVideoFrame_v14_2_1*)this;
AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
virtual ULONG STDMETHODCALLTYPE AddRef(void) { return ++_refs; }
virtual ULONG STDMETHODCALLTYPE Release(void)
{
Expand All @@ -138,10 +147,10 @@ class decklink_frame : public IDeckLinkVideoFrame
std::atomic<int> _refs;
};

class decklink_output_callback : public IDeckLinkVideoOutputCallback
class decklink_output_callback : public IDeckLinkVideoOutputCallback_v14_2_1
{
public:
virtual HRESULT STDMETHODCALLTYPE ScheduledFrameCompleted(IDeckLinkVideoFrame *_frame, BMDOutputFrameCompletionResult result)
virtual HRESULT STDMETHODCALLTYPE ScheduledFrameCompleted(IDeckLinkVideoFrame_v14_2_1 *_frame, BMDOutputFrameCompletionResult result)
{
decklink_frame *frame = static_cast<decklink_frame *>(_frame);
struct decklink_ctx *ctx = frame->_ctx;
Expand All @@ -159,7 +168,16 @@ class decklink_output_callback : public IDeckLinkVideoOutputCallback
return S_OK;
}
virtual HRESULT STDMETHODCALLTYPE ScheduledPlaybackHasStopped(void) { return S_OK; }
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv) { return E_NOINTERFACE; }
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv)
{
if (iid == IID_IDeckLinkVideoOutputCallback_v14_2_1)
{
*ppv = (IDeckLinkVideoOutputCallback_v14_2_1*)this;
AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
virtual ULONG STDMETHODCALLTYPE AddRef(void) { return 1; }
virtual ULONG STDMETHODCALLTYPE Release(void) { return 1; }
};
Expand Down Expand Up @@ -739,7 +757,7 @@ static int decklink_write_video_packet(AVFormatContext *avctx, AVPacket *pkt)
ctx->first_pts = pkt->pts;

/* Schedule frame for playback. */
hr = ctx->dlo->ScheduleVideoFrame((class IDeckLinkVideoFrame *) frame,
hr = ctx->dlo->ScheduleVideoFrame((class IDeckLinkVideoFrame_v14_2_1 *) frame,
pkt->pts * ctx->bmd_tb_num,
ctx->bmd_tb_num, ctx->bmd_tb_den);
/* Pass ownership to DeckLink, or release on failure */
Expand Down Expand Up @@ -874,7 +892,7 @@ av_cold int ff_decklink_write_header(AVFormatContext *avctx)
return ret;

/* Get output device. */
if (ctx->dl->QueryInterface(IID_IDeckLinkOutput, (void **) &ctx->dlo) != S_OK) {
if (ctx->dl->QueryInterface(IID_IDeckLinkOutput_v14_2_1, (void **) &ctx->dlo) != S_OK) {
av_log(avctx, AV_LOG_ERROR, "Could not open output device from '%s'\n",
avctx->url);
ret = AVERROR(EIO);
Expand Down