mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-24 16:00:02 +01:00
libavdevice/decklink: add support for DeckLink SDK 14.3
This patch adds support for DeckLink SDK 14.3 and newer by using the legacy interfaces in the header <DeckLinkAPI_v14_2_1.h>. The missing QueryInterface implementations are also provided.
This commit is contained in:
committed by
Marton Balint
parent
1e90047fe6
commit
27e94281d1
@@ -31,7 +31,11 @@ extern "C" {
|
||||
#include "libavformat/internal.h"
|
||||
}
|
||||
|
||||
#include <DeckLinkAPIVersion.h>
|
||||
#include <DeckLinkAPI.h>
|
||||
#if BLACKMAGIC_DECKLINK_API_VERSION >= 0x0e030000
|
||||
#include <DeckLinkAPI_v14_2_1.h>
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
#include "config.h"
|
||||
@@ -105,7 +109,7 @@ 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) { }
|
||||
@@ -129,7 +133,21 @@ public:
|
||||
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 riid, LPVOID *ppv)
|
||||
{
|
||||
if (DECKLINK_IsEqualIID(riid, IID_IUnknown)) {
|
||||
*ppv = static_cast<IUnknown*>(this);
|
||||
} else if (DECKLINK_IsEqualIID(riid, IID_IDeckLinkMemoryAllocator_v14_2_1)) {
|
||||
*ppv = static_cast<IDeckLinkMemoryAllocator_v14_2_1*>(this);
|
||||
} else {
|
||||
*ppv = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
virtual ULONG STDMETHODCALLTYPE AddRef(void) { return ++_refs; }
|
||||
virtual ULONG STDMETHODCALLTYPE Release(void)
|
||||
{
|
||||
@@ -472,7 +490,7 @@ skip_packet:
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
@@ -574,17 +592,30 @@ 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 riid, LPVOID *ppv)
|
||||
{
|
||||
if (DECKLINK_IsEqualIID(riid, IID_IUnknown)) {
|
||||
*ppv = static_cast<IUnknown*>(this);
|
||||
} else if (DECKLINK_IsEqualIID(riid, IID_IDeckLinkInputCallback_v14_2_1)) {
|
||||
*ppv = static_cast<IDeckLinkInputCallback_v14_2_1*>(this);
|
||||
} else {
|
||||
*ppv = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
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;
|
||||
@@ -593,7 +624,7 @@ private:
|
||||
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)
|
||||
@@ -625,7 +656,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,
|
||||
@@ -679,7 +710,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);
|
||||
@@ -701,7 +732,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;
|
||||
@@ -726,7 +757,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;
|
||||
@@ -1141,7 +1172,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);
|
||||
|
||||
Reference in New Issue
Block a user