From patchwork Tue Apr 9 19:28:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 12666 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 7D8104495D4 for ; Tue, 9 Apr 2019 22:29:23 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6AD5E68ADC5; Tue, 9 Apr 2019 22:29:23 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1185368AD1C for ; Tue, 9 Apr 2019 22:29:17 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id F1DA6E1883; Tue, 9 Apr 2019 21:29:16 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TqjCRg-_LhOF; Tue, 9 Apr 2019 21:29:16 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 0EC46E2105; Tue, 9 Apr 2019 21:29:16 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Tue, 9 Apr 2019 21:28:56 +0200 Message-Id: <20190409192856.5401-3-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190409192856.5401-1-cus@passwd.hu> References: <20190409192856.5401-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 3/3] avdevice/decklink_common: add support for DeckLink SDK 11 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fixes ticket #7789. Signed-off-by: Marton Balint --- libavdevice/decklink_common.cpp | 53 ++++++++++++++++++++++++++++++++++++++--- libavdevice/decklink_common.h | 6 ++++- 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp index 3902311edd..c3a1d5588c 100644 --- a/libavdevice/decklink_common.cpp +++ b/libavdevice/decklink_common.cpp @@ -81,9 +81,9 @@ static int decklink_get_attr_string(IDeckLink *dl, BMDDeckLinkAttributeID cfg_id { DECKLINK_STR tmp; HRESULT hr; - IDeckLinkAttributes *attr; + IDeckLinkProfileAttributes *attr; *s = NULL; - if (dl->QueryInterface(IID_IDeckLinkAttributes, (void **)&attr) != S_OK) + if (dl->QueryInterface(IID_IDeckLinkProfileAttributes, (void **)&attr) != S_OK) return AVERROR_EXTERNAL; hr = attr->GetString(cfg_id, &tmp); attr->Release(); @@ -149,11 +149,28 @@ int ff_decklink_set_configs(AVFormatContext *avctx, if (ctx->duplex_mode) { DECKLINK_BOOL duplex_supported = false; +#if BLACKMAGIC_DECKLINK_API_VERSION >= 0x0b000000 + IDeckLinkProfileManager *manager = NULL; + if (ctx->dl->QueryInterface(IID_IDeckLinkProfileManager, (void **)&manager) == S_OK) + duplex_supported = true; +#else if (ctx->attr->GetFlag(BMDDeckLinkSupportsDuplexModeConfiguration, &duplex_supported) != S_OK) duplex_supported = false; +#endif if (duplex_supported) { +#if BLACKMAGIC_DECKLINK_API_VERSION >= 0x0b000000 + IDeckLinkProfile *profile = NULL; + BMDProfileID bmd_profile_id = ctx->duplex_mode == 2 ? bmdProfileOneSubDeviceFullDuplex : bmdProfileTwoSubDevicesHalfDuplex; + res = manager->GetProfile(bmd_profile_id, &profile); + if (res == S_OK) { + res = profile->SetActive(); + profile->Release(); + } + manager->Release(); +#else res = ctx->cfg->SetInt(bmdDeckLinkConfigDuplexMode, ctx->duplex_mode == 2 ? bmdDuplexModeFull : bmdDuplexModeHalf); +#endif if (res != S_OK) av_log(avctx, AV_LOG_WARNING, "Setting duplex mode failed.\n"); else @@ -187,7 +204,11 @@ int ff_decklink_set_format(AVFormatContext *avctx, { struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data; struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx; +#if BLACKMAGIC_DECKLINK_API_VERSION >= 0x0b000000 + DECKLINK_BOOL support; +#else BMDDisplayModeSupport support; +#endif IDeckLinkDisplayModeIterator *itermode; IDeckLinkDisplayMode *mode; int i = 1; @@ -248,6 +269,31 @@ int ff_decklink_set_format(AVFormatContext *avctx, if (ctx->bmd_mode == bmdModeUnknown) return -1; + +#if BLACKMAGIC_DECKLINK_API_VERSION >= 0x0b000000 + if (direction == DIRECTION_IN) { + if (ctx->dli->DoesSupportVideoMode(ctx->video_input, ctx->bmd_mode, (BMDPixelFormat) cctx->raw_format, + bmdVideoInputFlagDefault, + &support) != S_OK) + return -1; + } else { + BMDDisplayMode actualMode = ctx->bmd_mode; + if (!ctx->supports_vanc || ctx->dlo->DoesSupportVideoMode(bmdVideoConnectionUnspecified, ctx->bmd_mode, ctx->raw_format, + bmdVideoOutputVANC, + &actualMode, &support) != S_OK || !support || ctx->bmd_mode != actualMode) { + /* Try without VANC enabled */ + if (ctx->dlo->DoesSupportVideoMode(bmdVideoConnectionUnspecified, ctx->bmd_mode, ctx->raw_format, + bmdVideoOutputFlagDefault, + &actualMode, &support) != S_OK || !support || ctx->bmd_mode != actualMode) { + return -1; + } + ctx->supports_vanc = 0; + } + + } + if (support) + return 0; +#else if (direction == DIRECTION_IN) { if (ctx->dli->DoesSupportVideoMode(ctx->bmd_mode, (BMDPixelFormat) cctx->raw_format, bmdVideoOutputFlagDefault, @@ -269,6 +315,7 @@ int ff_decklink_set_format(AVFormatContext *avctx, } if (support == bmdDisplayModeSupported) return 0; +#endif return -1; } @@ -473,7 +520,7 @@ int ff_decklink_init_device(AVFormatContext *avctx, const char* name) return AVERROR_EXTERNAL; } - if (ctx->dl->QueryInterface(IID_IDeckLinkAttributes, (void **)&ctx->attr) != S_OK) { + if (ctx->dl->QueryInterface(IID_IDeckLinkProfileAttributes, (void **)&ctx->attr) != S_OK) { av_log(avctx, AV_LOG_ERROR, "Could not get attributes interface for '%s'\n", name); ff_decklink_cleanup(avctx); return AVERROR_EXTERNAL; diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h index d2fc3f79d5..921818ba41 100644 --- a/libavdevice/decklink_common.h +++ b/libavdevice/decklink_common.h @@ -24,6 +24,10 @@ #define AVDEVICE_DECKLINK_COMMON_H #include +#if BLACKMAGIC_DECKLINK_API_VERSION < 0x0b000000 +#define IID_IDeckLinkProfileAttributes IID_IDeckLinkAttributes +#define IDeckLinkProfileAttributes IDeckLinkAttributes +#endif #include "libavutil/thread.h" #include "decklink_common_c.h" @@ -87,7 +91,7 @@ struct decklink_ctx { IDeckLinkOutput *dlo; IDeckLinkInput *dli; IDeckLinkConfiguration *cfg; - IDeckLinkAttributes *attr; + IDeckLinkProfileAttributes *attr; decklink_output_callback *output_callback; /* DeckLink mode information */