Commit 9cbbd83f authored by Mehdi Sabwat's avatar Mehdi Sabwat
Browse files

vlc.js: update $TESTED_HASH with patchset

parent 2df77145
......@@ -19,7 +19,7 @@ checkfail()
SLOW_MODE=${SLOW_MODE:=1}
WORK_DIR=$PWD
EMSDK_VERSION="2.0.17"
EMSDK_VERSION="2.0.25"
# Download the portable SDK and uncompress it
if [ ! -d emsdk ]; then
diagnostic "emsdk not found. Fetching it"
......@@ -29,7 +29,7 @@ if [ ! -d emsdk ]; then
fi
cd $WORK_DIR
TESTED_HASH="ae406f9e6be4eb0b7d6b8db6edd51005d5af546f"
TESTED_HASH="721cf129"
# Go go go vlc
if [ ! -d vlc ]; then
diagnostic "VLC source not found, cloning"
......@@ -40,7 +40,14 @@ if [ ! -d vlc ]; then
# patching vlc
if [ -d ../vlc_patches ] && [ "$(ls -A ../vlc_patches)" ]; then
# core patches
git am -3 ../vlc_patches/upstream-core/*.patch
git am -3 ../vlc_patches/0001-configure-improve-testing-unsupported-GL-functions-f.patch
git am -3 ../vlc_patches/0001-contrib-set-RANLIB-for-toolchain.cmake.patch
git am -3 ../vlc_patches/0001-modules-disable-libvlc_json-and-ytbdl-vlc.js-17.patch
git am -3 ../vlc_patches/nacl-wasm/00*.patch
git am -3 ../vlc_patches/audio_output/00*.patch
git am -3 ../vlc_patches/video_output/00*.patch
git am -3 ../vlc_patches/logger/00*.patch
# git am -3 ../vlc_patches/filesystem/*.patch
fi
checkfail "vlc source: git clone failed"
fi
......
From f6824c1e0834913d796fc661a444902dcb806b7d Mon Sep 17 00:00:00 2001
From b848ce9dd721810e11a1566d9dfdea3c34c13ace Mon Sep 17 00:00:00 2001
From: Mehdi Sabwat <mehdi@videolabs.io>
Date: Tue, 27 Apr 2021 15:34:23 +0200
Subject: [PATCH 05/16] configure: improve testing unsupported GL functions for
Subject: [PATCH 1/1] configure: improve testing unsupported GL functions for
emscripten
The build system assumes OpenGL functions are implemented if the headers are defined.
......@@ -14,10 +14,10 @@ in wasm-emscripten this function will appear supported even if it is not.
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
index 08e3f849d8..dbdd5dc3e8 100644
index 374ce00cc7..81abc3fcf0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3329,13 +3329,16 @@ PKG_CHECK_MODULES([GL], [gl], [
@@ -3311,13 +3311,16 @@ PKG_CHECK_MODULES([GL], [gl], [
have_gl="yes"
], [
AC_MSG_CHECKING([for OpenGL])
......@@ -38,5 +38,5 @@ index 08e3f849d8..dbdd5dc3e8 100644
GL_CFLAGS=""
have_gl="yes"
--
2.31.1
2.32.0
From 89483da629c05701ac2ff8a157a67e031e5e471f Mon Sep 17 00:00:00 2001
From: Mehdi Sabwat <mehdisabwat@gmail.com>
Date: Mon, 30 Dec 2019 13:55:23 +0100
Subject: [PATCH 1/1] contrib: add emscripten target
set toolchain variables in bootstrap and main.mak
Co-Author: Etienne Brateau <etienne.brateau@gmail.com>
---
contrib/bootstrap | 3 +++
contrib/src/main.mak | 9 +++++++++
2 files changed, 12 insertions(+)
diff --git a/contrib/bootstrap b/contrib/bootstrap
index 01a234e55c..b6224bae9d 100755
--- a/contrib/bootstrap
+++ b/contrib/bootstrap
@@ -348,6 +348,9 @@ case "${OS}" in
*nacl*)
add_make_enabled "HAVE_NACL"
;;
+ *emscripten*)
+ add_make_enabled "HAVE_EMSCRIPTEN"
+ ;;
esac
#
diff --git a/contrib/src/main.mak b/contrib/src/main.mak
index 5e5846de97..897020517e 100644
--- a/contrib/src/main.mak
+++ b/contrib/src/main.mak
@@ -133,6 +133,15 @@ EXTRA_CFLAGS += -fno-stack-check
XCODE_FLAGS += OTHER_CFLAGS=-fno-stack-check
endif
+ifdef HAVE_EMSCRIPTEN
+CC := emcc
+CXX := em++
+LD := emcc
+AR := emar
+RANLIB := emranlib
+CFLAGS="-pthread"
+endif
+
ifdef HAVE_MACOSX
EXTRA_CXXFLAGS += -stdlib=libc++
ifeq ($(ARCH),x86_64)
--
2.24.1
From 982c6ce6720bca35524a1f06d0c1a64afd77e918 Mon Sep 17 00:00:00 2001
From: Mehdi Sabwat <mehdi@videolabs.io>
Date: Thu, 3 Jun 2021 22:50:44 +0200
Subject: [PATCH 1/1] contrib: set RANLIB for toolchain.cmake
This commit will allow taking into account $RANLIB when we are cross compiling contribs that use cmake.
When cross compiling Openjpeg with emscripten sdk, for example, the build system
won't be able to use emranlib (ranlib targetting the $HOST).
cf: https://emscripten.org/docs/compiling/Building-Projects.html#troubleshooting
---
contrib/src/main.mak | 1 +
1 file changed, 1 insertion(+)
diff --git a/contrib/src/main.mak b/contrib/src/main.mak
index fb71479d68..2d4bce03ee 100644
--- a/contrib/src/main.mak
+++ b/contrib/src/main.mak
@@ -597,6 +597,7 @@ else
endif
endif
echo "set(CMAKE_AR $(AR) CACHE FILEPATH \"Archiver\")" >> $@
+ echo "set(CMAKE_RANLIB $(RANLIB) CACHE FILEPATH \"Add index to Archive\")" >> $@
ifdef HAVE_CROSS_COMPILE
echo "set(_CMAKE_TOOLCHAIN_PREFIX $(HOST)-)" >> $@
ifdef HAVE_ANDROID
--
2.32.0
From 38d4ef121b5ba92278b7e269c312506c8e3a9fb7 Mon Sep 17 00:00:00 2001
From b67a4befac19e46f48e7955b5475dca89e8c9d52 Mon Sep 17 00:00:00 2001
From: Mehdi Sabwat <mehdi@videolabs.io>
Date: Fri, 16 Apr 2021 11:32:33 +0200
Subject: [PATCH 09/16] modules: disable libvlc_json and ytbdl vlc.js#17
Subject: [PATCH 1/1] modules: disable libvlc_json and ytbdl vlc.js#17
The libjson library is not linkable with emsdk v2.0.17,
this commit should be reverted when the ticket is resolved.
......@@ -33,5 +33,5 @@ index 48f5d7a97d..dbfe923650 100644
noinst_LTLIBRARIES += libvlc_json.la
+endif
--
2.31.1
2.32.0
From 4a82c06361880c86123934b6dfb54263e0154051 Mon Sep 17 00:00:00 2001
From: Mehdi Sabwat <mehdisabwat@gmail.com>
Date: Wed, 4 Sep 2019 19:35:17 +0200
Subject: [PATCH 01/15] contrib: add ffmpeg configuration options for
wasm-emscripten
We need to specify the pthread flag for compilation and linking, otherwise tests will fail.
---
...001-configure-add-emscripten-support.patch | 33 +++++++++++++++++++
contrib/src/ffmpeg/rules.mak | 6 ++++
2 files changed, 39 insertions(+)
create mode 100644 contrib/src/ffmpeg/0001-configure-add-emscripten-support.patch
diff --git a/contrib/src/ffmpeg/0001-configure-add-emscripten-support.patch b/contrib/src/ffmpeg/0001-configure-add-emscripten-support.patch
new file mode 100644
index 0000000000..cb8471c90e
--- /dev/null
+++ b/contrib/src/ffmpeg/0001-configure-add-emscripten-support.patch
@@ -0,0 +1,33 @@
+From da7782c47f1f3d84eefb4ccce1c95e40d3b65fde Mon Sep 17 00:00:00 2001
+From: Mehdi Sabwat <mehdisabwat@gmail.com>
+Date: Tue, 13 Aug 2019 21:14:56 +0200
+Subject: [PATCH 1/1] configure: add emscripten support
+
+---
+ configure | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/configure b/configure
+index 7cea9d4d73..bafcbc87fc 100755
+--- a/configure
++++ b/configure
+@@ -4239,6 +4239,7 @@ fi
+ exesuf() {
+ case $1 in
+ mingw32*|mingw64*|win32|win64|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;;
++ emscripten) echo .js ;;
+ esac
+ }
+
+@@ -5428,6 +5429,8 @@ case $target_os in
+ ;;
+ minix)
+ ;;
++ emscripten)
++ ;;
+ none)
+ ;;
+ *)
+--
+2.23.0
+
diff --git a/contrib/src/ffmpeg/rules.mak b/contrib/src/ffmpeg/rules.mak
index 1ba04616e5..e2ec5f3cd3 100644
--- a/contrib/src/ffmpeg/rules.mak
+++ b/contrib/src/ffmpeg/rules.mak
@@ -221,6 +221,11 @@ ifdef HAVE_NACL
FFMPEGCONF+=--disable-inline-asm --disable-asm --target-os=linux
endif
+ifdef HAVE_EMSCRIPTEN
+FFMPEGCONF+=--target-os=emscripten --arch=wasm32 --ranlib=emranlib \
+ --extra-ldflags="-pthread" --extra-ldexeflags="-pthread"
+endif
+
# Build
PKGS += ffmpeg
ifeq ($(call need_pkg,"libavcodec >= $(FFMPEG_LAVC_MIN) libavformat >= 53.21.0 libswscale"),)
@@ -248,6 +253,7 @@ endif
ifdef USE_LIBAV
$(APPLY) $(SRC)/ffmpeg/libav_gsm.patch
endif
+ $(APPLY) $(SRC)/ffmpeg/0001-configure-add-emscripten-support.patch
$(MOVE)
.ffmpeg: ffmpeg
--
2.23.0
From ba9735f71e72cd3c7b57b1558a69c9f111316f65 Mon Sep 17 00:00:00 2001
From: Mehdi Sabwat <mehdisabwat@gmail.com>
Date: Tue, 31 Dec 2019 12:02:20 +0100
Subject: [PATCH 1/1] contrib: delete empty variable
As a fwp on c29409d1a742e65b6b2f3c95702196ff9ab1570c this commit fixes an issue
on platforms that are not listed.
---
contrib/src/main.mak | 1 -
1 file changed, 1 deletion(-)
diff --git a/contrib/src/main.mak b/contrib/src/main.mak
index 897020517e..a0469fb3e0 100644
--- a/contrib/src/main.mak
+++ b/contrib/src/main.mak
@@ -646,7 +646,6 @@ ifdef HAVE_CROSS_COMPILE
echo "set(PKG_CONFIG_EXECUTABLE $(PKG_CONFIG))" >> $@
endif
-MESON_SYSTEM_NAME =
ifdef HAVE_WIN32
MESON_SYSTEM_NAME = windows
else
--
2.24.1
From 747c6207acf654665d23625537b962152922c8c5 Mon Sep 17 00:00:00 2001
From: Mehdi Sabwat <mehdisabwat@gmail.com>
Date: Mon, 24 Feb 2020 14:08:02 +0100
Subject: [PATCH 1/1] core: initial core build for emscripten, based on POSIX
posix/sort.c won't be added because qsort_r is not supported.
---
src/Makefile.am | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/src/Makefile.am b/src/Makefile.am
index bf91159fcc..474ddcdd63 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -437,6 +437,17 @@ libvlccore_la_SOURCES += \
posix/timer.c
endif
+if HAVE_EMSCRIPTEN
+libvlccore_la_SOURCES += \
+ posix/thread.c \
+ posix/getaddrinfo.c \
+ posix/error.c \
+ posix/dirs.c \
+ posix/filesystem.c \
+ posix/specific.c \
+ posix/timer.c
+endif
+
if HAVE_DARWIN
libvlccore_la_SOURCES += \
darwin/error.c \
@@ -481,6 +492,7 @@ if !HAVE_LINUX
libvlccore_la_SOURCES += posix/wait.c
endif
if !HAVE_ANDROID
+if !HAVE_EMSCRIPTEN
libvlccore_la_SOURCES += posix/sort.c
if !HAVE_DARWIN
libvlccore_la_SOURCES += \
@@ -503,6 +515,7 @@ endif
endif
endif
endif
+endif
if ENABLE_SOUT
libvlccore_la_SOURCES += \
--
2.25.0
From e06b3ac370e84480e7d3c6d9e8184c27fc2d0bf5 Mon Sep 17 00:00:00 2001
From: Mehdi Sabwat <mehdisabwat@gmail.com>
Date: Tue, 17 Sep 2019 18:59:43 +0200
Subject: [PATCH 08/15] compat: add sigwait support for emscripten
---
compat/sigwait.c | 4 ++--
configure.ac | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/compat/sigwait.c b/compat/sigwait.c
index e5a082d2d6..950579cc8b 100644
--- a/compat/sigwait.c
+++ b/compat/sigwait.c
@@ -24,8 +24,8 @@
# include <config.h>
#endif
-#ifdef __native_client__
-/* NaCl has no working sigwait, but SIGPIPE, for which vlc uses sigwait
+#if defined(__native_client__) || defined(__EMSCRIPTEN__)
+/* NaCl and Emscripten have no working sigwait, but SIGPIPE, for which vlc uses sigwait
* currently, is never generated in NaCl. So for SIGPIPE it's safe to instantly
* return, for all others run into an assertion. */
diff --git a/configure.ac b/configure.ac
index c9d04253cd..e5298e6f7a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -324,6 +324,7 @@ case "${host_os}" in
;;
*emscripten*)
SYS=emscripten
+ AC_LIBOBJ([sigwait])
CC=emcc
LD=emcc
LDSHARED=emcc
--
2.23.0
From 39c77bd0970d509bd47df2d0c1e58b09281067e2 Mon Sep 17 00:00:00 2001
From: Mehdi Sabwat <mehdisabwat@gmail.com>
Date: Thu, 5 Sep 2019 23:54:30 +0200
Subject: [PATCH 09/15] compat: add clock_nanosleep support
clock_nanosleep() is not supported in emscripten
Implementation from : https://code.woboq.org/userspace/glibc/sysdeps/unix/clock_nanosleep.c.html
---
compat/clock_nanosleep.c | 91 ++++++++++++++++++++++++++++++++++++++++
configure.ac | 1 +
2 files changed, 92 insertions(+)
create mode 100644 compat/clock_nanosleep.c
diff --git a/compat/clock_nanosleep.c b/compat/clock_nanosleep.c
new file mode 100644
index 0000000000..d4cfee70e6
--- /dev/null
+++ b/compat/clock_nanosleep.c
@@ -0,0 +1,91 @@
+/*****************************************************************************
+ * clock_nanosleep.c:
+ High-resolution sleep with the specified clock for emscripten.
+ *****************************************************************************
+ * Copyright © 2019 VLC authors, VideoLAN
+ * and Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <assert.h>
+#include <errno.h>
+#include <time.h>
+// #include <sysdep-cancel.h>
+
+/* This implementation assumes that these is only a `nanosleep' system
+ call. So we have to remap all other activities. */
+int
+//__clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
+// struct timespec *rem)
+clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
+ struct timespec *rem)
+{
+ struct timespec now;
+
+ if (__builtin_expect (req->tv_nsec, 0) < 0
+ || __builtin_expect (req->tv_nsec, 0) >= 1000000000)
+ return EINVAL;
+
+ if (clock_id == CLOCK_THREAD_CPUTIME_ID)
+ return EINVAL; /* POSIX specifies EINVAL for this case. */
+
+ if (clock_id < CLOCK_REALTIME || clock_id > CLOCK_THREAD_CPUTIME_ID)
+ return EINVAL;
+
+ /* If we got an absolute time, remap it. */
+ if (flags == TIMER_ABSTIME)
+ {
+ long int nsec;
+ long int sec;
+
+ /* Make sure we use safe data types. */
+ assert (sizeof (sec) >= sizeof (now.tv_sec));
+
+ /* Get the current time for this clock. */
+ //if (__clock_gettime (clock_id, &now) != 0)
+ if (clock_gettime (clock_id, &now) != 0)
+ return errno;
+
+ /* Compute the difference. */
+ nsec = req->tv_nsec - now.tv_nsec;
+ sec = req->tv_sec - now.tv_sec - (nsec < 0);
+ if (sec < 0)
+ /* The time has already elapsed. */
+ return 0;
+
+ now.tv_sec = sec;
+ now.tv_nsec = nsec + (nsec < 0 ? 1000000000 : 0);
+
+ /* From now on this is our time. */
+ req = &now;
+
+ /* Make sure we are not modifying the struct pointed to by REM. */
+ rem = NULL;
+ }
+ else if (flags != 0)
+ return EINVAL;
+
+ else if (clock_id != CLOCK_REALTIME)
+ /* Not supported. */
+ return ENOTSUP;
+ // return __nanosleep (req, rem), 0 ? errno : 0;
+ return nanosleep (req, rem), 0 ? errno : 0;
+}
+//weak_alias (__clock_nanosleep, clock_nanosleep)
diff --git a/configure.ac b/configure.ac
index e5298e6f7a..5f24ab5945 100644
--- a/configure.ac
+++ b/configure.ac
@@ -325,6 +325,7 @@ case "${host_os}" in
*emscripten*)
SYS=emscripten
AC_LIBOBJ([sigwait])
+ AC_LIBOBJ([clock_nanosleep])
CC=emcc
LD=emcc
LDSHARED=emcc
--
2.23.0
From 1f14176411e65c0d12fe167e62a8f7f10f233216 Mon Sep 17 00:00:00 2001
From: Mehdi Sabwat <mehdisabwat@gmail.com>
Date: Mon, 24 Feb 2020 14:15:56 +0100
Subject: [PATCH 1/1] emscripten: add vlc_getProxyUrl stub.
---
src/Makefile.am | 3 ++-
src/emscripten/netconf.c | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 1 deletion(-)
create mode 100644 src/emscripten/netconf.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 474ddcdd63..64d28e12c4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -445,7 +445,8 @@ libvlccore_la_SOURCES += \
posix/dirs.c \
posix/filesystem.c \
posix/specific.c \
- posix/timer.c
+ posix/timer.c \
+ emscripten/netconf.c
endif
if HAVE_DARWIN
diff --git a/src/emscripten/netconf.c b/src/emscripten/netconf.c
new file mode 100644
index 0000000000..b972bf4976
--- /dev/null
+++ b/src/emscripten/netconf.c
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * netconf.c : Network configuration
+ *****************************************************************************
+ * Copyright (C) 2019
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <string.h>
+
+char *vlc_getProxyUrl(const char *url);
+
+/**
+ * Determines the network proxy server to use (if any).
+ * @param url absolute URL for which to get the proxy server
+ * @return proxy URL, NULL if no proxy or error
+ */
+char *vlc_getProxyUrl(const char *url)
+{
+ char *proxy = strdup(url);
+
+ return proxy;
+}
--
2.25.0
From a2a2372eb588474073873cd745164e22ef076328 Mon Sep 17 00:00:00 2001
From: Mehdi Sabwat <mehdisabwat@gmail.com>
Date: Mon, 9 Sep 2019 19:07:49 +0200
Subject: [PATCH 11/15] configure: disable deprecated GL functions for
emscripten
The build system assumes OpenGL functions are implemented if the headers are defined.
Which is wrong, so we need to disable the HAVE_GL marker.
---
configure.ac | 1 +
1 file changed, 1 insertion(+)
diff --git a/configure.ac b/configure.ac
index 5f24ab5945..66a69a91d7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3231,6 +3231,7 @@ PKG_CHECK_MODULES([GL], [gl], [
])
AC_MSG_RESULT([${have_gl}])
])
+AS_IF([test "${SYS}" = "emscripten"], [have_gl="no"], [have_gl="yes"])
AM_CONDITIONAL([HAVE_GL], [test "${have_gl}" = "yes"])
AS_IF([test "${have_gl}" = "yes"], [
AC_DEFINE([HAVE_GL], 1, [Defined if having OpenGL])
--
2.23.0
From bde1b91e748fa7b2a97041605628ab7c96bd6a61 Mon Sep 17 00:00:00 2001
From: Mehdi Sabwat <mehdisabwat@gmail.com>
Date: Mon, 9 Sep 2019 19:18:36 +0200
Subject: [PATCH 12/15] logger: add emscripten module
---
modules/logger/Makefile.am | 7 ++++
modules/logger/emscripten.c | 82 +++++++++++++++++++++++++++++++++++++
2 files changed, 89 insertions(+)
create mode 100644 modules/logger/emscripten.c
diff --git a/modules/logger/Makefile.am b/modules/logger/Makefile.am
index 4addf6dcfd..9b26a68afd 100644
--- a/modules/logger/Makefile.am
+++ b/modules/logger/Makefile.am
@@ -22,3 +22,10 @@ libandroid_logger_plugin_la_LIBADD = -llog