[vlc-devel] [PATCH] Live555: could not play streams on devices with Linux kernel lower than 3.9

Mirco Pazzaglia mirco.pazzaglia at inim.biz
Mon Dec 23 14:26:28 CET 2019


Live555 makes use of socket option SO_REUSEPORT (introduced as of Linux kernel version 3.9 https://mirrors.edge.kernel.org/pub/linux/kernel/projects/backports/stable/v3.9-rc1/ChangeLog-3.9-rc1-3 ) without ensuring the OS actually supports it. This patch would be a fix for this ticket https://trac.videolan.org/vlc/ticket/23201 (Cannot play RTSP streams on "older" Android devices). As far as I know it requires the creation of a new .patch file to fix the Live555 source file as follows.

---

    Live555: setsockopt for SO_REUSEPORT was issued resulting in 'Protocol not available' errno ENOPROTOOPT in Linux (thus Android) OSes with kernel version < 3.9 .
    
    Check for SO_REUSEPORT availability was added using getsockopt before trying to set the socket option.

diff --git a/contrib/src/live555/check-so_reuseport-avail.patch b/contrib/src/live555/check-so_reuseport-avail.patch
new file mode 100644
index 0000000000..c3062f4f17
--- /dev/null
+++ b/contrib/src/live555/check-so_reuseport-avail.patch
@@ -0,0 +1,24 @@
+diff --git a/groupsock/GroupsockHelper.cpp b/groupsock/GroupsockHelper.cpp
+--- a/groupsock/GroupsockHelper.cpp
++++ b/groupsock/GroupsockHelper.cpp
+@@ -121,11 +121,16 @@
+   // Windoze doesn't properly handle SO_REUSEPORT or IP_MULTICAST_LOOP
+ #else
+ #ifdef SO_REUSEPORT
+-  if (setsockopt(newSocket, SOL_SOCKET, SO_REUSEPORT,
+-		 (const char*)&reuseFlag, sizeof reuseFlag) < 0) {
+-    socketErr(env, "setsockopt(SO_REUSEPORT) error: ");
+-    closeSocket(newSocket);
+-    return -1;
++  int checkReuseFlag;
++  int checkReuseFlagLen = sizeof checkReuseFlag;
++  if (getsockopt(newSocket, SOL_SOCKET, SO_REUSEPORT,
++     &checkReuseFlag, &checkReuseFlagLen) == 0) {
++    if (setsockopt(newSocket, SOL_SOCKET, SO_REUSEPORT,
++       (const char*)&reuseFlag, sizeof reuseFlag) < 0) {
++      socketErr(env, "setsockopt(SO_REUSEPORT) error: ");
++      closeSocket(newSocket);
++      return -1;
++    }
+   }
+ #endif
\ No newline at end of file
diff --git a/contrib/src/live555/rules.mak b/contrib/src/live555/rules.mak
index bb1d5655c7..f08d836f35 100644
--- a/contrib/src/live555/rules.mak
+++ b/contrib/src/live555/rules.mak
@@ -82,6 +82,8 @@ ifneq ($(LEGACY_NDK), 1)
 	$(APPLY) $(SRC)/live555/in_addr-s_addr-field.patch
 	# Don't use unavailable off64_t functions
 	$(APPLY) $(SRC)/live555/file-offset-bits-64.patch
+	# Check against ENOPROTOOPT for sockopt SO_REUSEPORT (not available in Linux kernel < 3.9)
+	$(APPLY) $(SRC)/live555/check-so_reuseport-avail.patch
 endif
 endif
 	# Fix creating static libs on mingw




More information about the vlc-devel mailing list