]> git.sesse.net Git - ffmpeg/blobdiff - libavdevice/decklink_common.cpp
avdevice/pulse_audio_dec: do not read undersized frames
[ffmpeg] / libavdevice / decklink_common.cpp
index 53b57ffe4e256bbd904a5dee81505f51e9124a63..24aa9b1d1350e028c1848f2cf38e1c172c6065a9 100644 (file)
@@ -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;
 }
@@ -272,7 +293,7 @@ int ff_decklink_set_format(AVFormatContext *avctx,
 #if BLACKMAGIC_DECKLINK_API_VERSION >= 0x0b050000
     if (direction == DIRECTION_IN) {
         BMDDisplayMode actualMode = ctx->bmd_mode;
-        if (ctx->dli->DoesSupportVideoMode(ctx->video_input, ctx->bmd_mode, (BMDPixelFormat) cctx->raw_format,
+        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;
@@ -286,7 +307,7 @@ int ff_decklink_set_format(AVFormatContext *avctx,
     return 0;
 #elif BLACKMAGIC_DECKLINK_API_VERSION >= 0x0b000000
     if (direction == DIRECTION_IN) {
-        if (ctx->dli->DoesSupportVideoMode(ctx->video_input, ctx->bmd_mode, (BMDPixelFormat) cctx->raw_format,
+        if (ctx->dli->DoesSupportVideoMode(ctx->video_input, ctx->bmd_mode, ctx->raw_format,
                                            bmdSupportedVideoModeDefault,
                                            &support) != S_OK)
             return -1;
@@ -303,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;