History

avdevice/decklink: fix MSVC build issues

Purpose: Made minor changes to get the decklink avdevice code to build using Visual C++. Notes: Made changes to configure per Hendrik Leppkes's review of first and second versions of patch. Also made slight alterations per Marton Balint's reviews. Comments: -- configure: Added if enabled decklink section and setting decklink_indev_extralibs and decklink_outdev_extralibs here for both mingw and Windows. Also eliminated the setting of these variables in the mingw section earlier in the file. -- libavdevice/decklink_common.cpp: Switched the order of the include of libavformat/internal.h to workaround build issues with Visual C++. See comment in file for more details. -- libavdevice/decklink_dec.cpp: a) Rearranged the include of libavformat/internal.h (for reasons as described above). b) Made slight alteration to an argument for call to av_rescale_q() to workaround a compiler error with Visual C++. This appears to only be an issue when building C++ files with Visual C++. See comment in code for more details. -- libavdevice/decklink_enc.cpp: Rearranged the include of libavformat/internal.h (for reasons as described above).

Aaron Levinson committed 9 years ago

Commit 7f7ee861 parent f089e024 files · +35 −6Browse files

Unified · Split

4 files
  1. configure +9 −2
  2. libavdevice/decklink_common.cpp +6 −1
  3. libavdevice/decklink_dec.cpp +14 −2
  4. libavdevice/decklink_enc.cpp +6 −1
configure+9−2
@@ -4853,8 +4853,6 @@ case $target_os in · 4852 unmodified lines
48534853 else
48544854 target_os=mingw32
48554855 fi
4856− decklink_outdev_extralibs="$decklink_outdev_extralibs -lole32 -loleaut32"
4857− decklink_indev_extralibs="$decklink_indev_extralibs -lole32 -loleaut32"
48584856 LIBTARGET=i386
48594857 if enabled x86_64; then
48604858 LIBTARGET="i386:x86-64"
@@ -5959,6 +5957,15 @@ if ! disabled sdl2; then · 1098 unmodified lines
59595957 fi
59605958 enabled sdl2 && enable sdl && add_cflags $sdl2_cflags && add_extralibs $sdl2_extralibs
59615959
5960+if enabled decklink; then
5961+ case $target_os in
5962+ mingw32*|mingw64*|win32|win64)
5963+ decklink_outdev_extralibs="$decklink_outdev_extralibs -lole32 -loleaut32"
5964+ decklink_indev_extralibs="$decklink_indev_extralibs -lole32 -loleaut32"
5965+ ;;
5966+ esac
5967+fi
5968+
59625969 disabled securetransport || { check_func SecIdentityCreate "-Wl,-framework,CoreFoundation -Wl,-framework,Security" &&
59635970 check_lib securetransport "Security/SecureTransport.h Security/Security.h" "SSLCreateContext SecItemImport" "-Wl,-framework,CoreFoundation -Wl,-framework,Security"; }
59645971
libavdevice/decklink_common.cpp+6−1
@@ -19,6 +19,12 @@ · 18 unmodified lines
1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020 */
2121
22+/* Include internal.h first to avoid conflict between winsock.h (used by
23+ * DeckLink headers) and winsock2.h (used by libavformat) in MSVC++ builds */
24+extern "C" {
25+#include "libavformat/internal.h"
26+}
27+
2228 #include <DeckLinkAPI.h>
2329 #ifdef _WIN32
2430 #include <DeckLinkAPI_i.c>
@@ -28,7 +34,6 @@ · 3 unmodified lines
2834
2935 extern "C" {
3036 #include "libavformat/avformat.h"
31−#include "libavformat/internal.h"
3237 #include "libavutil/imgutils.h"
3338 #include "libavutil/intreadwrite.h"
3439 #include "libavutil/bswap.h"
libavdevice/decklink_dec.cpp+14−2
@@ -19,12 +19,17 @@ · 18 unmodified lines
1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020 */
2121
22+/* Include internal.h first to avoid conflict between winsock.h (used by
23+ * DeckLink headers) and winsock2.h (used by libavformat) in MSVC++ builds */
24+extern "C" {
25+#include "libavformat/internal.h"
26+}
27+
2228 #include <DeckLinkAPI.h>
2329
2430 extern "C" {
2531 #include "config.h"
2632 #include "libavformat/avformat.h"
27−#include "libavformat/internal.h"
2833 #include "libavutil/avutil.h"
2934 #include "libavutil/common.h"
3035 #include "libavutil/imgutils.h"
@@ -262,8 +267,15 @@ static int64_t get_pkt_pts(IDeckLinkVideoInputFrame *videoFrame, · 231 unmodified lines
262267 res = videoFrame->GetHardwareReferenceTimestamp(time_base.den, &bmd_pts, &bmd_duration);
263268 break;
264269 case PTS_SRC_WALLCLOCK:
265− pts = av_rescale_q(wallclock, AV_TIME_BASE_Q, time_base);
270+ {
271+ /* MSVC does not support compound literals like AV_TIME_BASE_Q
272+ * in C++ code (compiler error C4576) */
273+ AVRational timebase;
274+ timebase.num = 1;
275+ timebase.den = AV_TIME_BASE;
276+ pts = av_rescale_q(wallclock, timebase, time_base);
266277 break;
278+ }
267279 }
268280 if (res == S_OK)
269281 pts = bmd_pts / time_base.num;
libavdevice/decklink_enc.cpp+6−1
@@ -22,11 +22,16 @@ · 21 unmodified lines
2222 #include <atomic>
2323 using std::atomic;
2424
25+/* Include internal.h first to avoid conflict between winsock.h (used by
26+ * DeckLink headers) and winsock2.h (used by libavformat) in MSVC++ builds */
27+extern "C" {
28+#include "libavformat/internal.h"
29+}
30+
2531 #include <DeckLinkAPI.h>
2632
2733 extern "C" {
2834 #include "libavformat/avformat.h"
29−#include "libavformat/internal.h"
3035 #include "libavutil/imgutils.h"
3136 }
3237

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t