[vlc-devel] [PATCH v4 3/3] contrib: srt: Enabled for Win32

Justin Kim justin.kim at collabora.com
Mon Mar 26 09:52:08 CEST 2018


Signed-off-by: Justin Kim <justin.kim at collabora.com>
---
 ...001-CMakeLists.txt-let-cmake-find-pthread.patch | 39 +++++++++++++
 ...0001-Clean-.pc-to-provide-the-dependecies.patch | 46 ++++++++++++++++
 .../srt/0001-Fix-include-path-for-wintime.h.patch  | 64 ++++++++++++++++++++++
 .../0001-channel.cpp-add-mswsock.h-for-Win32.patch | 28 ++++++++++
 ...h-Enable-localtime_s-only-if-MSC_VER-1500.patch | 34 ++++++++++++
 ...ore-api.h-change-inet_ntop-to-getnameinfo.patch | 43 +++++++++++++++
 contrib/src/srt/rules.mak                          | 13 ++++-
 7 files changed, 265 insertions(+), 2 deletions(-)
 create mode 100644 contrib/src/srt/0001-CMakeLists.txt-let-cmake-find-pthread.patch
 create mode 100644 contrib/src/srt/0001-Clean-.pc-to-provide-the-dependecies.patch
 create mode 100644 contrib/src/srt/0001-Fix-include-path-for-wintime.h.patch
 create mode 100644 contrib/src/srt/0001-channel.cpp-add-mswsock.h-for-Win32.patch
 create mode 100644 contrib/src/srt/0001-srt_compat.h-Enable-localtime_s-only-if-MSC_VER-1500.patch
 create mode 100644 contrib/src/srt/0001-srtcore-api.h-change-inet_ntop-to-getnameinfo.patch

diff --git a/contrib/src/srt/0001-CMakeLists.txt-let-cmake-find-pthread.patch b/contrib/src/srt/0001-CMakeLists.txt-let-cmake-find-pthread.patch
new file mode 100644
index 0000000000..d798d05f63
--- /dev/null
+++ b/contrib/src/srt/0001-CMakeLists.txt-let-cmake-find-pthread.patch
@@ -0,0 +1,39 @@
+From 85b1aba00a1ffe9cce6821de5f1676bf014ae535 Mon Sep 17 00:00:00 2001
+From: Justin Kim <justin.kim at collabora.com>
+Date: Fri, 23 Mar 2018 13:05:29 +0900
+Subject: [PATCH] CMakeLists.txt: let cmake find pthread
+
+---
+ CMakeLists.txt | 16 +++-------------
+ 1 file changed, 3 insertions(+), 13 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 8e02b58..39ab8ab 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -212,19 +212,9 @@ endif()
+ 
+ 
+ # find pthread
+-find_path(PTHREAD_INCLUDE_DIR pthread.h HINTS C:/pthread-win32/include)
+-if (PTHREAD_INCLUDE_DIR)
+-	message(STATUS "Pthread include dir: ${PTHREAD_INCLUDE_DIR}")
+-else()
+-	message(FATAL_ERROR "Failed to find pthread.h. Specify PTHREAD_INCLUDE_DIR.")
+-endif()
+-
+-find_library(PTHREAD_LIBRARY NAMES pthread pthread_dll pthread_lib HINTS C:/pthread-win32/lib)
+-if (PTHREAD_LIBRARY)
+-	message(STATUS "Pthread library: ${PTHREAD_LIBRARY}")
+-else()
+-	message(FATAL_ERROR "Failed to find pthread library. Specify PTHREAD_LIBRARY.")
+-endif()
++set (THREADS_PTHREAD_ARG "2" CACHE STRING "Forcibly set by CMakeLists.txt." FORCE)
++set (THREADS_PREFER_PTHREAD_FLAG ON)
++find_package (Threads REQUIRED)
+ 
+ # This is required in some projects that add some other sources
+ # to the SRT library to be compiled together (aka "virtual library").
+-- 
+2.7.4
+
diff --git a/contrib/src/srt/0001-Clean-.pc-to-provide-the-dependecies.patch b/contrib/src/srt/0001-Clean-.pc-to-provide-the-dependecies.patch
new file mode 100644
index 0000000000..3e57dec08f
--- /dev/null
+++ b/contrib/src/srt/0001-Clean-.pc-to-provide-the-dependecies.patch
@@ -0,0 +1,46 @@
+From 02a6fcd2668a0f19ebeb77b02a0f5e9befda317c Mon Sep 17 00:00:00 2001
+From: Justin Kim <justin.kim at collabora.com>
+Date: Fri, 8 Dec 2017 18:32:55 +0900
+Subject: [PATCH] Clean .pc to provide the dependecies
+
+SRT will provide the dependencies by `Requires:` field.
+
+Signed-off-by: Justin Kim <justin.kim at collabora.com>
+---
+ CMakeLists.txt       | 5 ++---
+ scripts/haisrt.pc.in | 2 +-
+ 2 files changed, 3 insertions(+), 4 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 1db73d4..3bf4fe9 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -106,6 +106,7 @@ if ( USE_GNUTLS )
+ 		${SSL_LIBRARY_DIRS}
+ 	)
+ else()
++	set (SSL_REQUIRED_MODULES "openssl libcrypto zlib")
+ 	find_package(OpenSSL REQUIRED)
+ 	set (SSL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
+ 	set (SSL_LIBRARIES ${OPENSSL_LIBRARIES})
+@@ -115,7 +116,6 @@ else()
+ 		-DHAICRYPT_USE_OPENSSL_AES
+ 	)
+ endif()
+-
+ message (STATUS "SSL libraries: ${SSL_LIBRARIES}")
+ 
+ # Detect if the compiler is GNU compatable for flags
+diff --git a/scripts/haisrt.pc.in b/scripts/haisrt.pc.in
+index 3b1c49f..beb103b 100644
+--- a/scripts/haisrt.pc.in
++++ b/scripts/haisrt.pc.in
+@@ -9,4 +9,4 @@ Version: @SRT_VERSION@
+ Libs: -L${libdir} -l at TARGET_srt@ @IFNEEDED_LINK_HAICRYPT@ @IFNEEDED_SRTBASE@ @IFNEEDED_SRT_LDFLAGS@
+ Libs.private: @SRT_LIBS_PRIVATE@
+ Cflags: -I${includedir}
+-
++Requires.private: @SSL_REQUIRED_MODULES@
+-- 
+2.7.4
+
diff --git a/contrib/src/srt/0001-Fix-include-path-for-wintime.h.patch b/contrib/src/srt/0001-Fix-include-path-for-wintime.h.patch
new file mode 100644
index 0000000000..3cb011c921
--- /dev/null
+++ b/contrib/src/srt/0001-Fix-include-path-for-wintime.h.patch
@@ -0,0 +1,64 @@
+From f9497cbb465453d5c8f895f7b70c19f7b0d0d23c Mon Sep 17 00:00:00 2001
+From: Justin Kim <justin.kim at collabora.com>
+Date: Tue, 2 Jan 2018 20:17:46 +0900
+Subject: [PATCH] Fix #include path for wintime.h
+
+`wintime.h` is installed `${includedir}/srt/win`
+so `platform_sys.h` shouldn't use an absolute path
+for this header.
+
+Signed-off-by: Justin Kim <justin.kim at collabora.com>
+---
+ common/win/wintime.h   | 3 +--
+ scripts/haisrt.pc.in   | 2 +-
+ srtcore/platform_sys.h | 2 +-
+ 3 files changed, 3 insertions(+), 4 deletions(-)
+
+diff --git a/common/win/wintime.h b/common/win/wintime.h
+index af810b6..cc37b52 100644
+--- a/common/win/wintime.h
++++ b/common/win/wintime.h
+@@ -4,7 +4,6 @@
+ #include <winsock2.h>
+ #include <windows.h>
+ #include <time.h>
+-#include "haicrypt.h"
+ 
+ #ifdef __cplusplus
+ extern "C" {
+@@ -34,7 +33,7 @@ struct timezone
+ 
+ void timeradd(struct timeval *a, struct timeval *b, struct timeval *result);
+ 
+-HAICRYPT_API int gettimeofday(struct timeval* tp, struct timezone* tz);
++int gettimeofday(struct timeval* tp, struct timezone* tz);
+ 
+ #ifdef __cplusplus
+ }
+diff --git a/scripts/haisrt.pc.in b/scripts/haisrt.pc.in
+index beb103b..9009f9b 100644
+--- a/scripts/haisrt.pc.in
++++ b/scripts/haisrt.pc.in
+@@ -8,5 +8,5 @@ Description: SRT library set
+ Version: @SRT_VERSION@
+ Libs: -L${libdir} -l at TARGET_srt@ @IFNEEDED_LINK_HAICRYPT@ @IFNEEDED_SRTBASE@ @IFNEEDED_SRT_LDFLAGS@
+ Libs.private: @SRT_LIBS_PRIVATE@
+-Cflags: -I${includedir}
++Cflags: -I${includedir} -I${includedir}/srt
+ Requires.private: @SSL_REQUIRED_MODULES@
+diff --git a/srtcore/platform_sys.h b/srtcore/platform_sys.h
+index 5ffa374..f2cb09b 100644
+--- a/srtcore/platform_sys.h
++++ b/srtcore/platform_sys.h
+@@ -8,7 +8,7 @@
+    #include <windows.h>
+    #include <inttypes.h>
+    #include <stdint.h>
+-   #include <win/wintime.h>
++   #include "win/wintime.h"
+    #if defined(_MSC_VER)
+       #pragma warning(disable:4251)
+    #endif
+-- 
+2.7.4
+
diff --git a/contrib/src/srt/0001-channel.cpp-add-mswsock.h-for-Win32.patch b/contrib/src/srt/0001-channel.cpp-add-mswsock.h-for-Win32.patch
new file mode 100644
index 0000000000..507311fbbb
--- /dev/null
+++ b/contrib/src/srt/0001-channel.cpp-add-mswsock.h-for-Win32.patch
@@ -0,0 +1,28 @@
+From a3f76dccdef8b2968a1c9d6961585ae9162e9eb3 Mon Sep 17 00:00:00 2001
+From: Justin Kim <justin.kim at collabora.com>
+Date: Thu, 23 Nov 2017 20:03:57 +0900
+Subject: [PATCH] channel.cpp: add mswsock.h for Win32
+
+For cross-compiling, 'mswsock.h' is required to use
+MSG_TRUNC flag.
+
+Signed-off-by: Justin Kim <justin.kim at collabora.com>
+---
+ srtcore/channel.cpp | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/srtcore/channel.cpp b/srtcore/channel.cpp
+index a15179b..07b0b96 100644
+--- a/srtcore/channel.cpp
++++ b/srtcore/channel.cpp
+@@ -75,6 +75,7 @@ modified by
+ #else
+    #include <winsock2.h>
+    #include <ws2tcpip.h>
++   #include <mswsock.h>
+ #endif
+ 
+ #include <iostream>
+-- 
+2.7.4
+
diff --git a/contrib/src/srt/0001-srt_compat.h-Enable-localtime_s-only-if-MSC_VER-1500.patch b/contrib/src/srt/0001-srt_compat.h-Enable-localtime_s-only-if-MSC_VER-1500.patch
new file mode 100644
index 0000000000..2bf50ffdcb
--- /dev/null
+++ b/contrib/src/srt/0001-srt_compat.h-Enable-localtime_s-only-if-MSC_VER-1500.patch
@@ -0,0 +1,34 @@
+From 32917c2f3c942b7ac25bc461f5984441bcb1fd21 Mon Sep 17 00:00:00 2001
+From: Justin Kim <justin.kim at collabora.com>
+Date: Tue, 2 Jan 2018 16:20:44 +0900
+Subject: [PATCH] srt_compat.h: Enable localtime_s only if MSC_VER >= 1500
+
+Signed-off-by: Justin Kim <justin.kim at collabora.com>
+---
+ common/srt_compat.h | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/common/srt_compat.h b/common/srt_compat.h
+index d73e193..bddf5f8 100644
+--- a/common/srt_compat.h
++++ b/common/srt_compat.h
+@@ -177,10 +177,16 @@ inline struct tm LocalTime(time_t tt)
+ {
+ 	struct tm tm;
+ #ifdef WIN32
++#if defined(_MSC_VER) && (_MSC_VER>=1500)
+ 	errno_t rr = localtime_s(&tm, &tt);
+ 	if (rr)
+ 		return tm;
++
+ #else
++	tm = *localtime(&tt);
++#endif // _MSC_VER
++
++#else // WIN32
+ 	tm = *localtime_r(&tt, &tm);
+ #endif
+ 
+-- 
+2.7.4
+
diff --git a/contrib/src/srt/0001-srtcore-api.h-change-inet_ntop-to-getnameinfo.patch b/contrib/src/srt/0001-srtcore-api.h-change-inet_ntop-to-getnameinfo.patch
new file mode 100644
index 0000000000..3b982cdf7f
--- /dev/null
+++ b/contrib/src/srt/0001-srtcore-api.h-change-inet_ntop-to-getnameinfo.patch
@@ -0,0 +1,43 @@
+From 9f9ac2b05be359e68b849d9e2948b0a0ac82b35d Mon Sep 17 00:00:00 2001
+From: Justin Kim <justin.kim at collabora.com>
+Date: Fri, 24 Nov 2017 11:09:36 +0900
+Subject: [PATCH] srtcore/api.h: change inet_ntop to getnameinfo
+
+Missing a header `arpa/inet.h` causes compilation warings.
+However, rather than the header for `inet_ntop` function, it would
+be better to use a protocol-independent address to name translator.
+
+Signed-off-by: Justin Kim <justin.kim at collabora.com>
+---
+ srtcore/api.h          | 2 +-
+ srtcore/platform_sys.h | 1 +
+ 2 files changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/srtcore/api.h b/srtcore/api.h
+index cd62531..7045da4 100644
+--- a/srtcore/api.h
++++ b/srtcore/api.h
+@@ -282,7 +282,7 @@ inline std::string SockaddrToString(const sockaddr* sadr)
+ 
+ 	std::ostringstream output;
+ 	char hostbuf[1024];
+-	if (inet_ntop(sadr->sa_family, addr, hostbuf, 1024))
++	if (!getnameinfo(sadr, sizeof(*sadr), hostbuf, 1024, NULL, 0, NI_NAMEREQD))
+ 	{
+ 		output << hostbuf;
+ 	}
+diff --git a/srtcore/platform_sys.h b/srtcore/platform_sys.h
+index 5a1d65c..5ffa374 100644
+--- a/srtcore/platform_sys.h
++++ b/srtcore/platform_sys.h
+@@ -16,6 +16,7 @@
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ #include <sys/time.h>
++#include <netdb.h>
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
+ #include <unistd.h>
+-- 
+2.7.4
+
diff --git a/contrib/src/srt/rules.mak b/contrib/src/srt/rules.mak
index 3ffdfb4d55..2c5c556836 100644
--- a/contrib/src/srt/rules.mak
+++ b/contrib/src/srt/rules.mak
@@ -3,11 +3,10 @@
 SRT_VERSION := 1.2.2
 SRT_URL := $(GITHUB)/Haivision/srt/archive/v$(SRT_VERSION).tar.gz
 
-ifndef HAVE_WIN32
 ifdef BUILD_NETWORK
 PKGS += srt
 endif
-endif
+
 ifeq ($(call need_pkg,"srt >= 1.2.2"),)
 PKGS_FOUND += srt
 endif
@@ -16,6 +15,10 @@ ifdef HAVE_DARWIN_OS
 SRT_DARWIN=CFLAGS="$(CFLAGS) -Wno-error=partial-availability" CXXFLAGS="$(CXXFLAGS) -Wno-error=partial-availability"
 endif
 
+ifdef HAVE_WIN32
+DEPS_srt += pthreads $(DEPS_pthreads)
+endif
+
 $(TARBALLS)/srt-$(SRT_VERSION).tar.gz:
 	$(call download_pkg,$(SRT_URL),srt)
 
@@ -25,6 +28,12 @@ srt: srt-$(SRT_VERSION).tar.gz .sum-srt
 	$(UNPACK)
 	$(APPLY) $(SRC)/srt/fix-pc.patch
 	$(APPLY) $(SRC)/srt/add-implicit-link-libraries.patch
+	$(APPLY) $(SRC)/srt/0001-srtcore-api.h-change-inet_ntop-to-getnameinfo.patch
+	$(APPLY) $(SRC)/srt/0001-Clean-.pc-to-provide-the-dependecies.patch
+	$(APPLY) $(SRC)/srt/0001-srt_compat.h-Enable-localtime_s-only-if-MSC_VER-1500.patch
+	$(APPLY) $(SRC)/srt/0001-channel.cpp-add-mswsock.h-for-Win32.patch
+	$(APPLY) $(SRC)/srt/0001-Fix-include-path-for-wintime.h.patch
+	$(APPLY) $(SRC)/srt/0001-CMakeLists.txt-let-cmake-find-pthread.patch
 	$(call pkg_static,"scripts/haisrt.pc.in")
 	mv srt-$(SRT_VERSION) $@ && touch $@
 
-- 
2.16.2



More information about the vlc-devel mailing list