X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavdevice%2Fdecklink_common.cpp;h=24aa9b1d1350e028c1848f2cf38e1c172c6065a9;hb=b2d0826513c5e76f9bad2f1f0c809bc5c8e58b0c;hp=c3a1d5588c44c3b37f9622e7fd9e77edbcdf45c2;hpb=63c2c83f6eb46743e57a16b47dc2f45185391b00;p=ffmpeg diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp index c3a1d5588c4..24aa9b1d135 100644 --- a/libavdevice/decklink_common.cpp +++ b/libavdevice/decklink_common.cpp @@ -70,9 +70,30 @@ static IDeckLinkIterator *decklink_create_iterator(AVFormatContext *avctx) #else iter = CreateDeckLinkIteratorInstance(); #endif - if (!iter) + if (!iter) { av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator. " "Make sure you have DeckLink drivers " BLACKMAGIC_DECKLINK_API_VERSION_STRING " or newer installed.\n"); + } else { + IDeckLinkAPIInformation *api; + int64_t version; +#ifdef _WIN32 + if (CoCreateInstance(CLSID_CDeckLinkAPIInformation, NULL, CLSCTX_ALL, + IID_IDeckLinkAPIInformation, (void**) &api) != S_OK) { + api = NULL; + } +#else + api = CreateDeckLinkAPIInformationInstance(); +#endif + if (api && api->GetInt(BMDDeckLinkAPIVersion, &version) == S_OK) { + if (version < BLACKMAGIC_DECKLINK_API_VERSION) + av_log(avctx, AV_LOG_WARNING, "Installed DeckLink drivers are too old and may be incompatible with the SDK this module was built against. " + "Make sure you have DeckLink drivers " BLACKMAGIC_DECKLINK_API_VERSION_STRING " or newer installed.\n"); + } else { + av_log(avctx, AV_LOG_ERROR, "Failed to check installed DeckLink API version.\n"); + } + if (api) + api->Release(); + } return iter; } @@ -200,7 +221,7 @@ 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) + decklink_direction_t direction) { struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data; struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx; @@ -214,8 +235,8 @@ int ff_decklink_set_format(AVFormatContext *avctx, int i = 1; HRESULT res; - av_log(avctx, AV_LOG_DEBUG, "Trying to find mode for frame size %dx%d, frame timing %d/%d, field order %d, direction %d, mode number %d, format code %s\n", - width, height, tb_num, tb_den, field_order, direction, num, (cctx->format_code) ? cctx->format_code : "(unset)"); + av_log(avctx, AV_LOG_DEBUG, "Trying to find mode for frame size %dx%d, frame timing %d/%d, field order %d, direction %d, format code %s\n", + width, height, tb_num, tb_den, field_order, direction, cctx->format_code ? cctx->format_code : "(unset)"); if (direction == DIRECTION_IN) { res = ctx->dli->GetDisplayModeIterator (&itermode); @@ -248,7 +269,6 @@ int ff_decklink_set_format(AVFormatContext *avctx, bmd_height == height && !av_cmp_q(mode_tb, target_tb) && field_order_eq(field_order, bmd_field_dominance)) - || i == num || target_mode == bmd_mode) { ctx->bmd_mode = bmd_mode; ctx->bmd_width = bmd_width; @@ -270,24 +290,33 @@ int ff_decklink_set_format(AVFormatContext *avctx, if (ctx->bmd_mode == bmdModeUnknown) return -1; -#if BLACKMAGIC_DECKLINK_API_VERSION >= 0x0b000000 +#if BLACKMAGIC_DECKLINK_API_VERSION >= 0x0b050000 if (direction == DIRECTION_IN) { - if (ctx->dli->DoesSupportVideoMode(ctx->video_input, ctx->bmd_mode, (BMDPixelFormat) cctx->raw_format, - bmdVideoInputFlagDefault, + BMDDisplayMode actualMode = ctx->bmd_mode; + if (ctx->dli->DoesSupportVideoMode(ctx->video_input, ctx->bmd_mode, ctx->raw_format, + bmdNoVideoInputConversion, bmdSupportedVideoModeDefault, + &actualMode, &support) != S_OK || !support || ctx->bmd_mode != actualMode) + return -1; + } else { + BMDDisplayMode actualMode = ctx->bmd_mode; + if (ctx->dlo->DoesSupportVideoMode(bmdVideoConnectionUnspecified, ctx->bmd_mode, ctx->raw_format, + bmdNoVideoOutputConversion, bmdSupportedVideoModeDefault, + &actualMode, &support) != S_OK || !support || ctx->bmd_mode != actualMode) + return -1; + } + return 0; +#elif BLACKMAGIC_DECKLINK_API_VERSION >= 0x0b000000 + if (direction == DIRECTION_IN) { + if (ctx->dli->DoesSupportVideoMode(ctx->video_input, ctx->bmd_mode, ctx->raw_format, + bmdSupportedVideoModeDefault, &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 (ctx->dlo->DoesSupportVideoMode(bmdVideoConnectionUnspecified, ctx->bmd_mode, ctx->raw_format, + bmdSupportedVideoModeDefault, + &actualMode, &support) != S_OK || !support || ctx->bmd_mode != actualMode) { + return -1; } } @@ -295,7 +324,7 @@ int ff_decklink_set_format(AVFormatContext *avctx, return 0; #else if (direction == DIRECTION_IN) { - if (ctx->dli->DoesSupportVideoMode(ctx->bmd_mode, (BMDPixelFormat) cctx->raw_format, + if (ctx->dli->DoesSupportVideoMode(ctx->bmd_mode, ctx->raw_format, bmdVideoOutputFlagDefault, &support, NULL) != S_OK) return -1; @@ -320,8 +349,8 @@ int ff_decklink_set_format(AVFormatContext *avctx, return -1; } -int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t direction, int num) { - return ff_decklink_set_format(avctx, 0, 0, 0, 0, AV_FIELD_UNKNOWN, direction, num); +int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t direction) { + return ff_decklink_set_format(avctx, 0, 0, 0, 0, AV_FIELD_UNKNOWN, direction); } int ff_decklink_list_devices(AVFormatContext *avctx,