[vlc-commits] decklink: fix compilation with SDK 11.1 (fix #22276)

Francois Cartegnie git at videolan.org
Thu May 9 15:50:36 CEST 2019


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu May  9 10:38:01 2019 +0200| [10d6549f4eb577670cf657768bb0ad82ef6c69c1] | committer: Francois Cartegnie

decklink: fix compilation with SDK 11.1 (fix #22276)

provided deprecated api entries just does not work

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=10d6549f4eb577670cf657768bb0ad82ef6c69c1
---

 modules/access/decklink.cpp             |  9 +++++--
 modules/stream_out/sdi/DBMHelper.cpp    |  4 +--
 modules/stream_out/sdi/DBMHelper.hpp    |  2 +-
 modules/stream_out/sdi/DBMSDIOutput.cpp | 44 ++++++++++++++++++++++-----------
 modules/video_output/decklink.cpp       | 36 +++++++++++++++++++--------
 5 files changed, 66 insertions(+), 29 deletions(-)

diff --git a/modules/access/decklink.cpp b/modules/access/decklink.cpp
index 00faca5c9f..d2ba30e111 100644
--- a/modules/access/decklink.cpp
+++ b/modules/access/decklink.cpp
@@ -36,6 +36,11 @@
 
 #include "vlc_decklink.h"
 #include <DeckLinkAPIDispatch.cpp>
+#include <DeckLinkAPIVersion.h>
+#if BLACKMAGIC_DECKLINK_API_VERSION < 0x0b010000
+ #define IID_IDeckLinkProfileAttributes IID_IDeckLinkAttributes
+ #define IDeckLinkProfileAttributes IDeckLinkAttributes
+#endif
 
 #include "sdi.h"
 
@@ -140,7 +145,7 @@ struct demux_sys_t
     /* We need to hold onto the IDeckLinkConfiguration object, or our settings will not apply.
        See section 2.4.15 of the Blackmagic DeckLink SDK documentation. */
     IDeckLinkConfiguration *config;
-    IDeckLinkAttributes *attributes;
+    IDeckLinkProfileAttributes *attributes;
 
     bool autodetect;
 
@@ -583,7 +588,7 @@ static int Open(vlc_object_t *p_this)
         goto finish;
     }
 
-    if (sys->card->QueryInterface(IID_IDeckLinkAttributes, (void**)&sys->attributes) != S_OK) {
+    if (sys->card->QueryInterface(IID_IDeckLinkProfileAttributes, (void**)&sys->attributes) != S_OK) {
         msg_Err(demux, "Failed to get attributes interface");
         goto finish;
     }
diff --git a/modules/stream_out/sdi/DBMHelper.cpp b/modules/stream_out/sdi/DBMHelper.cpp
index 2a9966ba9b..0ba92863d6 100644
--- a/modules/stream_out/sdi/DBMHelper.cpp
+++ b/modules/stream_out/sdi/DBMHelper.cpp
@@ -83,7 +83,7 @@ IDeckLinkDisplayMode * Helper::MatchDisplayMode(vlc_object_t *p_obj,
                     continue;
                 }
 
-                if(forcedmode != bmdDisplayModeNotSupported && unlikely(!p_selected))
+                if(forcedmode != bmdModeUnknown && unlikely(!p_selected))
                 {
                     BMDDisplayMode modenl = htonl(forcedmode);
                     msg_Dbg(p_obj, "Forced mode '%4.4s'", (char *)&modenl);
@@ -94,7 +94,7 @@ IDeckLinkDisplayMode * Helper::MatchDisplayMode(vlc_object_t *p_obj,
                     continue;
                 }
 
-                if(p_selected == NULL && forcedmode == bmdDisplayModeNotSupported)
+                if(p_selected == NULL && forcedmode == bmdModeUnknown)
                 {
                     if(i_width >> i_div == p_mode->GetWidth() >> i_div &&
                        i_height >> i_div == p_mode->GetHeight() >> i_div)
diff --git a/modules/stream_out/sdi/DBMHelper.hpp b/modules/stream_out/sdi/DBMHelper.hpp
index a2218acb80..2b3fe7fc4c 100644
--- a/modules/stream_out/sdi/DBMHelper.hpp
+++ b/modules/stream_out/sdi/DBMHelper.hpp
@@ -29,7 +29,7 @@ namespace Decklink
             static IDeckLinkDisplayMode * MatchDisplayMode(vlc_object_t *,
                                                            IDeckLinkOutput *,
                                                            const video_format_t *,
-                                                           BMDDisplayMode = bmdDisplayModeNotSupported);
+                                                           BMDDisplayMode = bmdModeUnknown);
             static const char *ErrorToString(long i_code);
     };
 }
diff --git a/modules/stream_out/sdi/DBMSDIOutput.cpp b/modules/stream_out/sdi/DBMSDIOutput.cpp
index 482fe8e24e..87800da48d 100644
--- a/modules/stream_out/sdi/DBMSDIOutput.cpp
+++ b/modules/stream_out/sdi/DBMSDIOutput.cpp
@@ -37,6 +37,11 @@
 #include "V210.hpp"
 
 #include <DeckLinkAPIDispatch.cpp>
+#include <DeckLinkAPIVersion.h>
+#if BLACKMAGIC_DECKLINK_API_VERSION < 0x0b010000
+ #define IID_IDeckLinkProfileAttributes IID_IDeckLinkAttributes
+ #define IDeckLinkProfileAttributes IDeckLinkAttributes
+#endif
 
 #include "sdiout.hpp"
 
@@ -176,7 +181,7 @@ error:
 int DBMSDIOutput::ConfigureAudio(const audio_format_t *)
 {
     HRESULT result;
-    IDeckLinkAttributes *p_attributes = NULL;
+    IDeckLinkProfileAttributes *p_attributes = NULL;
 
     if(FAKE_DRIVER)
         return VLC_SUCCESS;
@@ -191,7 +196,7 @@ int DBMSDIOutput::ConfigureAudio(const audio_format_t *)
     {
         uint8_t maxchannels = audioMultiplex->config.getMultiplexedFramesCount() * 2;
 
-        result = p_card->QueryInterface(IID_IDeckLinkAttributes, (void**)&p_attributes);
+        result = p_card->QueryInterface(IID_IDeckLinkProfileAttributes, (void**)&p_attributes);
         CHECK("Could not get IDeckLinkAttributes");
 
         int64_t i64;
@@ -249,9 +254,9 @@ static BMDVideoConnection getVConn(const char *psz)
 int DBMSDIOutput::ConfigureVideo(const video_format_t *vfmt)
 {
     HRESULT result;
-    BMDDisplayMode wanted_mode_id = bmdDisplayModeNotSupported;
+    BMDDisplayMode wanted_mode_id = bmdModeUnknown;
     IDeckLinkConfiguration *p_config = NULL;
-    IDeckLinkAttributes *p_attributes = NULL;
+    IDeckLinkProfileAttributes *p_attributes = NULL;
     IDeckLinkDisplayMode *p_display_mode = NULL;
     char *psz_string = NULL;
     video_format_t *fmt = &video.configuredfmt.video;
@@ -296,7 +301,7 @@ int DBMSDIOutput::ConfigureVideo(const video_format_t *vfmt)
     }
 
     /* Read attributes */
-    result = p_card->QueryInterface(IID_IDeckLinkAttributes, (void**)&p_attributes);
+    result = p_card->QueryInterface(IID_IDeckLinkProfileAttributes, (void**)&p_attributes);
     CHECK("Could not get IDeckLinkAttributes");
 
     int64_t vconn;
@@ -328,22 +333,33 @@ int DBMSDIOutput::ConfigureVideo(const video_format_t *vfmt)
         BMDDisplayMode modenl = htonl(mode_id);
         msg_Dbg(p_stream, "Selected mode '%4.4s'", (char *) &modenl);
 
+        BMDPixelFormat pixelFormat = video.tenbits ? bmdFormat10BitYUV : bmdFormat8BitYUV;
         BMDVideoOutputFlags flags = bmdVideoOutputVANC;
         if (mode_id == bmdModeNTSC ||
-                mode_id == bmdModeNTSC2398 ||
-                mode_id == bmdModePAL)
+            mode_id == bmdModeNTSC2398 ||
+            mode_id == bmdModePAL)
         {
             flags = bmdVideoOutputVITC;
         }
-
-        BMDDisplayModeSupport support;
-        IDeckLinkDisplayMode *resultMode;
-
+        bool supported;
+#if BLACKMAGIC_DECKLINK_API_VERSION < 0x0b010000
+        BMDDisplayModeSupport support = bmdDisplayModeNotSupported;
         result = p_output->DoesSupportVideoMode(mode_id,
-                                                video.tenbits ? bmdFormat10BitYUV : bmdFormat8BitYUV,
-                                                flags, &support, &resultMode);
+                                                pixelFormat,
+                                                flags,
+                                                &support,
+                                                NULL);
+        supported = (support != bmdDisplayModeNotSupported);
+#else
+        result = p_output->DoesSupportVideoMode(vconn,
+                                                mode_id,
+                                                pixelFormat,
+                                                bmdSupportedVideoModeDefault,
+                                                NULL,
+                                                &supported);
+#endif
         CHECK("Does not support video mode");
-        if (support == bmdDisplayModeNotSupported)
+        if (!supported)
         {
             msg_Err(p_stream, "Video mode not supported");
             goto error;
diff --git a/modules/video_output/decklink.cpp b/modules/video_output/decklink.cpp
index 0490d34476..5499d4dd08 100644
--- a/modules/video_output/decklink.cpp
+++ b/modules/video_output/decklink.cpp
@@ -52,6 +52,11 @@
 #include "../stream_out/sdi/DBMHelper.hpp"
 #include "../stream_out/sdi/SDIGenerator.hpp"
 #include <DeckLinkAPIDispatch.cpp>
+#include <DeckLinkAPIVersion.h>
+#if BLACKMAGIC_DECKLINK_API_VERSION < 0x0b010000
+ #define IID_IDeckLinkProfileAttributes IID_IDeckLinkAttributes
+ #define IDeckLinkProfileAttributes IDeckLinkAttributes
+#endif
 
 #define FRAME_SIZE 1920
 #define CHANNELS_MAX 6
@@ -418,9 +423,9 @@ static int OpenDecklink(vout_display_t *vd, decklink_sys_t *sys)
     IDeckLinkIterator *decklink_iterator = NULL;
     IDeckLinkDisplayMode *p_display_mode = NULL;
     IDeckLinkConfiguration *p_config = NULL;
-    IDeckLinkAttributes *p_attributes = NULL;
+    IDeckLinkProfileAttributes *p_attributes = NULL;
     IDeckLink *p_card = NULL;
-    BMDDisplayMode wanted_mode_id = bmdDisplayModeNotSupported;
+    BMDDisplayMode wanted_mode_id = bmdModeUnknown;
 
     vlc_mutex_lock(&sys->lock);
 
@@ -480,7 +485,7 @@ static int OpenDecklink(vout_display_t *vd, decklink_sys_t *sys)
 
     /* Read attributes */
 
-    result = p_card->QueryInterface(IID_IDeckLinkAttributes, (void**)&p_attributes);
+    result = p_card->QueryInterface(IID_IDeckLinkProfileAttributes, (void**)&p_attributes);
     CHECK("Could not get IDeckLinkAttributes");
 
     int64_t vconn;
@@ -520,6 +525,7 @@ static int OpenDecklink(vout_display_t *vd, decklink_sys_t *sys)
         BMDDisplayMode modenl = htonl(mode_id);
         msg_Dbg(vd, "Selected mode '%4.4s'", (char *) &modenl);
 
+        BMDPixelFormat pixelFormat = sys->video.tenbits ? bmdFormat10BitYUV : bmdFormat8BitYUV;
         BMDVideoOutputFlags flags = bmdVideoOutputVANC;
         if (mode_id == bmdModeNTSC ||
             mode_id == bmdModeNTSC2398 ||
@@ -527,15 +533,25 @@ static int OpenDecklink(vout_display_t *vd, decklink_sys_t *sys)
         {
             flags = bmdVideoOutputVITC;
         }
-
-        BMDDisplayModeSupport support;
-        IDeckLinkDisplayMode *resultMode;
-
+        bool supported;
+#if BLACKMAGIC_DECKLINK_API_VERSION < 0x0b010000
+        BMDDisplayModeSupport support = bmdDisplayModeNotSupported;
         result = sys->p_output->DoesSupportVideoMode(mode_id,
-                                                              sys->video.tenbits ? bmdFormat10BitYUV : bmdFormat8BitYUV,
-                                                              flags, &support, &resultMode);
+                                                pixelFormat,
+                                                flags,
+                                                &support,
+                                                NULL);
+        supported = (support != bmdDisplayModeNotSupported);
+#else
+        result = sys->p_output->DoesSupportVideoMode(vconn,
+                                                mode_id,
+                                                pixelFormat,
+                                                bmdSupportedVideoModeDefault,
+                                                NULL,
+                                                &supported);
+#endif
         CHECK("Does not support video mode");
-        if (support == bmdDisplayModeNotSupported)
+        if (!supported)
         {
             msg_Err(vd, "Video mode not supported");
             goto error;



More information about the vlc-commits mailing list