From 1c55cd9b5c4872f5750fb1b91fea86706a974527 Mon Sep 17 00:00:00 2001 From: prlanzarin <4529051+prlanzarin@users.noreply.github.com> Date: Thu, 22 Dec 2022 18:07:17 -0300 Subject: [PATCH] build(freeswitch): add mod_audio_fork and libwebsockets Add mod_audio_fork to FreeSWITCH's build alongside libwebsockets (which mod_audio_fork depends on). mod_audio_fork is used by the built in transcription feature as a way to extract L16 streams from FreeSWITCH via WebSockets for further processing by arbitrary transcription servers. For full details on mod_audio_fork itself, please check drachtio's source repo: github.com/drachtio/drachtio-freeswitch-modules.git A few cautionary tales about this one: - The new patch (mod_audio_fork_build.patch) guarantees libwebsockets is properly linked to FreeSWITCH and that mod_audio_fork is built as well. That's because mod_audio_fork is not an upstream module. - The patch _may_ introduce conflicts on FreeSWITCH bumps more easily than the other patches we have. They shouldn't be too hard to adapt, though. - There's fine tuning to be done to FreeSWITCH's unit file regarding mod_audio_fork's capabilities. Again: check drachtio's repo. --- .../bbb-freeswitch-core/build.sh | 39 +++++++++- .../mod_audio_fork_build.patch | 72 +++++++++++++++++++ .../bbb-freeswitch-core/modules.conf | 1 + 3 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 build/packages-template/bbb-freeswitch-core/mod_audio_fork_build.patch diff --git a/build/packages-template/bbb-freeswitch-core/build.sh b/build/packages-template/bbb-freeswitch-core/build.sh index cb89bc8233..fd85abda5c 100755 --- a/build/packages-template/bbb-freeswitch-core/build.sh +++ b/build/packages-template/bbb-freeswitch-core/build.sh @@ -73,18 +73,51 @@ cd .. ldconfig +# libwebsockets start +# mod_audio_fork needs it (used in built-in speech transcription) +if [ ! -d libwebsockets ]; then + git clone https://github.com/warmcat/libwebsockets.git +fi +cd libwebsockets/ +git checkout v3.2.3 + +mkdir -p build +cd build + +cmake .. +make -j $(nproc) +make install +cd ../../ + +ldconfig +# libwebsockets end + +# mod_audio_fork start +# copy mod_audio_fork into place (used in built-in speech transcription) +if [ ! -d drachtio-freeswitch-modules ]; then + git clone https://github.com/drachtio/drachtio-freeswitch-modules.git +fi + +cd drachtio-freeswitch-modules +git checkout 4198b1c114268829627069afeea7eb40c86a81af +cp -r modules/mod_audio_fork $BUILDDIR/freeswitch/src/mod/applications/mod_audio_fork +cd .. +# mod_audio_fork end + # we already cloned the FS repo in freeswitch.placeholder.sh and selected tag/branch cd $BUILDDIR/freeswitch patch -p0 < $BUILDDIR/floor.patch patch -p0 --ignore-whitespace < $BUILDDIR/audio.patch # Provisional patch for https://github.com/signalwire/freeswitch/pull/1531 +# Enables mod_audio_fork in the build process (used in built-in speech transcription) +patch -p1 < $BUILDDIR/mod_audio_fork_build.patch -./bootstrap.sh +./bootstrap.sh ./configure --disable-core-odbc-support --disable-core-pgsql-support \ - --without-python --without-erlang --without-java \ - --prefix=/opt/freeswitch + --without-python --without-erlang --without-java --with-lws=yes \ + --prefix=/opt/freeswitch # Overrides for generating debug version # --prefix=/opt/freeswitch CFLAGS="-Wno-error -Og -ggdb" CXXFLAGS="-Wno-error -Og -ggdb" diff --git a/build/packages-template/bbb-freeswitch-core/mod_audio_fork_build.patch b/build/packages-template/bbb-freeswitch-core/mod_audio_fork_build.patch new file mode 100644 index 0000000000..3b4b5a3415 --- /dev/null +++ b/build/packages-template/bbb-freeswitch-core/mod_audio_fork_build.patch @@ -0,0 +1,72 @@ +diff --git a/Makefile.am b/Makefile.am +index f869072ff7..b31807a6f8 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -166,6 +166,14 @@ if HAVE_FVAD + CORE_CFLAGS += -DSWITCH_HAVE_FVAD $(LIBFVAD_CFLAGS) + endif + ++## ++## libwebsockets ++## ++if HAVE_LWS ++CORE_CFLAGS += -DSWITCH_HAVE_LWS $(LWS_CFLAGS) ++LWS_LIBS += -lwebsockets ++endif ++ + ## + ## libfreeswitch + ## +@@ -233,7 +241,7 @@ endif + lib_LTLIBRARIES = libfreeswitch.la + libfreeswitch_la_CFLAGS = $(CORE_CFLAGS) $(SQLITE_CFLAGS) $(GUMBO_CFLAGS) $(FVAD_CFLAGS) $(FREETYPE_CFLAGS) $(CURL_CFLAGS) $(PCRE_CFLAGS) $(SPEEX_CFLAGS) $(LIBEDIT_CFLAGS) $(openssl_CFLAGS) $(SOFIA_SIP_CFLAGS) $(AM_CFLAGS) $(TPL_CFLAGS) + libfreeswitch_la_LDFLAGS = -version-info 1:0:0 $(AM_LDFLAGS) $(PLATFORM_CORE_LDFLAGS) -no-undefined +-libfreeswitch_la_LIBADD = $(CORE_LIBS) $(APR_LIBS) $(SQLITE_LIBS) $(GUMBO_LIBS) $(FVAD_LIBS) $(FREETYPE_LIBS) $(CURL_LIBS) $(PCRE_LIBS) $(SPEEX_LIBS) $(LIBEDIT_LIBS) $(SYSTEMD_LIBS) $(openssl_LIBS) $(PLATFORM_CORE_LIBS) $(TPL_LIBS) $(SPANDSP_LIBS) $(SOFIA_SIP_LIBS) ++libfreeswitch_la_LIBADD = $(CORE_LIBS) $(APR_LIBS) $(SQLITE_LIBS) $(GUMBO_LIBS) $(FVAD_LIBS) $(FREETYPE_LIBS) $(CURL_LIBS) $(PCRE_LIBS) $(SPEEX_LIBS) $(LIBEDIT_LIBS) $(SYSTEMD_LIBS) $(openssl_LIBS) $(PLATFORM_CORE_LIBS) $(TPL_LIBS) $(SPANDSP_LIBS) $(SOFIA_SIP_LIBS) $(LWS_LIBS) + libfreeswitch_la_DEPENDENCIES = $(BUILT_SOURCES) + + if HAVE_PNG +diff --git a/build/modules.conf.in b/build/modules.conf.in +index 7bf59e2acc..9cab2f6fdb 100644 +--- a/build/modules.conf.in ++++ b/build/modules.conf.in +@@ -1,3 +1,4 @@ ++applications/mod_audio_fork + #applications/mod_abstraction + applications/mod_av + #applications/mod_avmd +diff --git a/configure.ac b/configure.ac +index f09196bdfd..fba7b9d676 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1590,6 +1590,22 @@ AS_IF([test "x$enable_core_libedit_support" != "xno"],[ + AC_MSG_ERROR([You need to either install libedit-dev (>= 2.11) or configure with --disable-core-libedit-support]) + ])])]) + ++dnl --------------------------------------------------------------------------- ++dnl - libwebsockets ++dnl --------------------------------------------------------------------------- ++AC_ARG_WITH(lws, ++ [AS_HELP_STRING([--with-lws], ++ [enable support for libwebsockets])], ++ [with_lws="$withval"], ++ [with_lws="no"]) ++if test "$with_lws" = "yes"; then ++ PKG_CHECK_MODULES([LWS], [libwebsockets], [ ++ AM_CONDITIONAL([HAVE_LWS],[true])], [ ++ AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_LWS],[false])]) ++else ++ AM_CONDITIONAL([HAVE_LWS],[false]) ++fi ++ + AC_ARG_ENABLE(systemd, + [AS_HELP_STRING([--enable-systemd], [Compile with systemd notify support])]) + +@@ -2081,6 +2097,7 @@ AC_CONFIG_FILES([Makefile + tests/unit/Makefile + src/Makefile + src/mod/Makefile ++ src/mod/applications/mod_audio_fork/Makefile + src/mod/applications/mod_abstraction/Makefile + src/mod/applications/mod_avmd/Makefile + src/mod/applications/mod_bert/Makefile diff --git a/build/packages-template/bbb-freeswitch-core/modules.conf b/build/packages-template/bbb-freeswitch-core/modules.conf index 7df3f615a9..199817fcfe 100644 --- a/build/packages-template/bbb-freeswitch-core/modules.conf +++ b/build/packages-template/bbb-freeswitch-core/modules.conf @@ -52,6 +52,7 @@ applications/mod_valet_parking #applications/mod_vmd applications/mod_voicemail #applications/mod_voicemail_ivr +applications/mod_audio_fork #asr_tts/mod_cepstral #asr_tts/mod_flite #asr_tts/mod_pocketsphinx