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

Justin Kim justin.kim at collabora.com
Fri Mar 23 07:59:34 CET 2018


Signed-off-by: Justin Kim <justin.kim at collabora.com>
---
 ...001-CMakeLists.txt-let-cmake-find-pthread.patch | 39 ++++++++++++++++++++
 .../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                          | 11 +++++-
 5 files changed, 153 insertions(+), 2 deletions(-)
 create mode 100644 contrib/src/srt/0001-CMakeLists.txt-let-cmake-find-pthread.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-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..6d099cccc8 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,10 @@ 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-CMakeLists.txt-let-cmake-find-pthread.patch
+	$(APPLY) $(SRC)/srt/0001-srtcore-api.h-change-inet_ntop-to-getnameinfo.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
 	$(call pkg_static,"scripts/haisrt.pc.in")
 	mv srt-$(SRT_VERSION) $@ && touch $@
 
-- 
2.16.2



More information about the vlc-devel mailing list