From febd8d99cfc1108a6a36ddf151475448af9478a3 Mon Sep 17 00:00:00 2001
From: j1nx
Date: Wed, 11 Jan 2023 12:24:07 +0100
Subject: [PATCH] Add roc-toolkit package and dependencies for Real Time
network audio.
---
buildroot-external/Config.in | 2 +
.../configs/rpi3_64-gui_defconfig | 2 +-
.../configs/rpi4_64-gui_defconfig | 2 +-
.../openfec/0001-CMake-improvements.patch | 193 ++++++++++++++++++
buildroot-external/package/openfec/Config.in | 7 +
buildroot-external/package/openfec/openfec.mk | 18 ++
buildroot-external/package/ragel/ragel.hash | 3 +
buildroot-external/package/ragel/ragel.mk | 16 ++
.../package/roc-toolkit/Config.in | 11 +
.../package/roc-toolkit/roc-toolkit.mk | 42 ++++
10 files changed, 294 insertions(+), 2 deletions(-)
create mode 100644 buildroot-external/package/openfec/0001-CMake-improvements.patch
create mode 100644 buildroot-external/package/openfec/Config.in
create mode 100644 buildroot-external/package/openfec/openfec.mk
create mode 100644 buildroot-external/package/ragel/ragel.hash
create mode 100644 buildroot-external/package/ragel/ragel.mk
create mode 100644 buildroot-external/package/roc-toolkit/Config.in
create mode 100644 buildroot-external/package/roc-toolkit/roc-toolkit.mk
diff --git a/buildroot-external/Config.in b/buildroot-external/Config.in
index d1cd5269..89c729d1 100644
--- a/buildroot-external/Config.in
+++ b/buildroot-external/Config.in
@@ -98,6 +98,7 @@ endmenu
source "$BR2_EXTERNAL_OPENVOICEOS_PATH/package/lottie-qml/Config.in"
source "$BR2_EXTERNAL_OPENVOICEOS_PATH/package/ncpamixer/Config.in"
source "$BR2_EXTERNAL_OPENVOICEOS_PATH/package/neon2sse/Config.in"
+ source "$BR2_EXTERNAL_OPENVOICEOS_PATH/package/openfec/Config.in"
source "$BR2_EXTERNAL_OPENVOICEOS_PATH/package/openfst/Config.in"
source "$BR2_EXTERNAL_OPENVOICEOS_PATH/package/ovos-bus-server/Config.in"
source "$BR2_EXTERNAL_OPENVOICEOS_PATH/package/ovos-dashboard/Config.in"
@@ -109,6 +110,7 @@ endmenu
source "$BR2_EXTERNAL_OPENVOICEOS_PATH/package/qt5ct/Config.in"
source "$BR2_EXTERNAL_OPENVOICEOS_PATH/package/respeaker/Config.in"
source "$BR2_EXTERNAL_OPENVOICEOS_PATH/package/rnnnoise-ladspa/Config.in"
+ source "$BR2_EXTERNAL_OPENVOICEOS_PATH/package/roc-toolkit/Config.in"
source "$BR2_EXTERNAL_OPENVOICEOS_PATH/package/rpi-eeprom/Config.in"
source "$BR2_EXTERNAL_OPENVOICEOS_PATH/package/ruy/Config.in"
source "$BR2_EXTERNAL_OPENVOICEOS_PATH/package/snapcast/Config.in"
diff --git a/buildroot-external/configs/rpi3_64-gui_defconfig b/buildroot-external/configs/rpi3_64-gui_defconfig
index 90c3abbb..1678f9ad 100644
--- a/buildroot-external/configs/rpi3_64-gui_defconfig
+++ b/buildroot-external/configs/rpi3_64-gui_defconfig
@@ -238,7 +238,6 @@ BR2_PACKAGE_GST1_PLUGINS_UGLY_PLUGIN_MPEG2DEC=y
BR2_PACKAGE_GST1_PLUGINS_UGLY_PLUGIN_X264=y
BR2_PACKAGE_GST1_DEVTOOLS=y
BR2_PACKAGE_GST1_INTERPIPE=y
-BR2_PACKAGE_GST1_LIBAV=y
BR2_PACKAGE_GST1_PYTHON=y
BR2_PACKAGE_MIMIC=y
BR2_PACKAGE_MIMIC_AUDIO_BACKEND_PULSEAUDIO=y
@@ -594,6 +593,7 @@ BR2_PACKAGE_PICOTTS=y
BR2_PACKAGE_QT5CT=y
BR2_PACKAGE_RESPEAKER=y
BR2_PACKAGE_RNNNOISE_LADSPA=y
+BR2_PACKAGE_ROC_TOOLKIT=y
BR2_PACKAGE_SNAPCAST=y
BR2_PACKAGE_SNAPCAST_SERVER=y
BR2_PACKAGE_SPOTIFYD=y
diff --git a/buildroot-external/configs/rpi4_64-gui_defconfig b/buildroot-external/configs/rpi4_64-gui_defconfig
index e3179737..d6288be5 100644
--- a/buildroot-external/configs/rpi4_64-gui_defconfig
+++ b/buildroot-external/configs/rpi4_64-gui_defconfig
@@ -239,7 +239,6 @@ BR2_PACKAGE_GST1_PLUGINS_UGLY_PLUGIN_MPEG2DEC=y
BR2_PACKAGE_GST1_PLUGINS_UGLY_PLUGIN_X264=y
BR2_PACKAGE_GST1_DEVTOOLS=y
BR2_PACKAGE_GST1_INTERPIPE=y
-BR2_PACKAGE_GST1_LIBAV=y
BR2_PACKAGE_GST1_PYTHON=y
BR2_PACKAGE_MIMIC=y
BR2_PACKAGE_MIMIC_AUDIO_BACKEND_PULSEAUDIO=y
@@ -594,6 +593,7 @@ BR2_PACKAGE_PICOTTS=y
BR2_PACKAGE_QT5CT=y
BR2_PACKAGE_RESPEAKER=y
BR2_PACKAGE_RNNNOISE_LADSPA=y
+BR2_PACKAGE_ROC_TOOLKIT=y
BR2_PACKAGE_SNAPCAST=y
BR2_PACKAGE_SNAPCAST_SERVER=y
BR2_PACKAGE_SPOTIFYD=y
diff --git a/buildroot-external/package/openfec/0001-CMake-improvements.patch b/buildroot-external/package/openfec/0001-CMake-improvements.patch
new file mode 100644
index 00000000..bcc64d9d
--- /dev/null
+++ b/buildroot-external/package/openfec/0001-CMake-improvements.patch
@@ -0,0 +1,193 @@
+From 57c62db33ed51b7e263d18996ea8656dc31722bb Mon Sep 17 00:00:00 2001
+From: Victor Gaydov
+Date: Fri, 2 Dec 2022 16:30:58 +0400
+Subject: [PATCH] CMake improvements
+
+---
+ .github/workflows/{build-openfec.yml => build.yml} | 5 +++++
+ CMakeLists.txt | 14 +++++++++++---
+ applis/eperftool/CMakeLists.txt | 8 ++++++--
+ .../simple_client_server/CMakeLists.txt | 10 +++++++---
+ pc/CMakeLists.txt | 6 +++++-
+ src/CMakeLists.txt | 5 +++++
+ tests/CMakeLists.txt | 6 +++---
+ tools/descr_stats_v1.2/CMakeLists.txt | 2 --
+ 8 files changed, 42 insertions(+), 14 deletions(-)
+ rename .github/workflows/{build-openfec.yml => build.yml} (94%)
+
+diff --git a/.github/workflows/build-openfec.yml b/.github/workflows/build.yml
+similarity index 94%
+rename from .github/workflows/build-openfec.yml
+rename to .github/workflows/build.yml
+index 730aa60..b36ef6d 100644
+--- a/.github/workflows/build-openfec.yml
++++ b/.github/workflows/build.yml
+@@ -43,6 +43,11 @@ jobs:
+ cd build
+ make -j2
+
++ - name: Run tests
++ run: |
++ cd build
++ make test
++
+ release:
+ runs-on: ubuntu-latest
+ if: startsWith(github.ref, 'refs/tags/v')
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index c1629d2..b3f46e3 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -1,4 +1,8 @@
+-cmake_minimum_required(VERSION 3.0.2)
++if(CMAKE_MAJOR_VERSION LESS 3)
++ cmake_minimum_required(VERSION 2.6)
++else()
++ cmake_minimum_required(VERSION 2.8.12)
++endif()
+
+ ##project
+ project(openfec C)
+@@ -39,13 +43,17 @@ message(STATUS "Optimization level ${OPTIMIZE}")
+
+ endif (DEBUG STREQUAL "ON")
+
+-set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE})
+-set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE})
++set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}
++ CACHE STRING "output path for libraries")
++set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}
++ CACHE STRING "output path for executables")
+ MARK_AS_ADVANCED(
+ LIBRARY_OUTPUT_PATH
+ EXECUTABLE_OUTPUT_PATH
+ )
+
++option(INSTALL_DEVTOOLS "install developer tools into the system" OFF)
++
+ link_directories(${LIBRARY_OUTPUT_PATH})
+
+ add_subdirectory(pc)
+diff --git a/applis/eperftool/CMakeLists.txt b/applis/eperftool/CMakeLists.txt
+index ca29521..f7966a1 100644
+--- a/applis/eperftool/CMakeLists.txt
++++ b/applis/eperftool/CMakeLists.txt
+@@ -1,9 +1,13 @@
+ file (GLOB eperftool_sources ./*)
+
+-set(EPERFTOOL_BIN ${PROJECT_BINARY_DIR}/applis/eperftool/eperftool CACHE STRING "eperftool dir")
++set(EPERFTOOL_BIN ${EXECUTABLE_OUTPUT_PATH}/eperftool CACHE STRING "eperftool exe")
+ add_executable( eperftool ${eperftool_sources})
+
+
+ target_link_libraries( eperftool openfec m)
+
+-install(TARGETS eperftool)
++if(INSTALL_DEVTOOLS)
++ install(TARGETS eperftool
++ RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
++ COMPONENT devtools)
++endif()
+diff --git a/applis/howto_examples/simple_client_server/CMakeLists.txt b/applis/howto_examples/simple_client_server/CMakeLists.txt
+index d3eed50..a215699 100644
+--- a/applis/howto_examples/simple_client_server/CMakeLists.txt
++++ b/applis/howto_examples/simple_client_server/CMakeLists.txt
+@@ -1,6 +1,6 @@
+ file (GLOB simple_server_sources ./simple_server.c)
+
+-set(SIMPLE_SERVER_BIN ${PROJECT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}/simple_server CACHE STRING "simple_server dir")
++set(SIMPLE_SERVER_BIN ${EXECUTABLE_OUTPUT_PATH}/simple_server CACHE STRING "simple_server exe")
+ add_executable(simple_server ${simple_server_sources})
+
+ target_link_libraries(simple_server openfec m)
+@@ -8,9 +8,13 @@ target_link_libraries(simple_server openfec m)
+
+ file (GLOB simple_client_sources ./simple_client.c)
+
+-set(SIMPLE_SERVER_BIN ${PROJECT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}/simple_client CACHE STRING "simple_client dir")
++set(SIMPLE_SERVER_BIN ${EXECUTABLE_OUTPUT_PATH}/simple_client CACHE STRING "simple_client exe")
+ add_executable(simple_client ${simple_client_sources})
+
+ target_link_libraries(simple_client openfec m)
+
+-install(TARGETS simple_server simple_client)
+\ No newline at end of file
++if(INSTALL_DEVTOOLS)
++ install(TARGETS simple_server simple_client
++ RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
++ COMPONENT applis)
++endif()
+diff --git a/pc/CMakeLists.txt b/pc/CMakeLists.txt
+index e9e2baf..589b91a 100644
+--- a/pc/CMakeLists.txt
++++ b/pc/CMakeLists.txt
+@@ -5,7 +5,7 @@ SET(PKG_CONFIG_LIBS
+ "-L\${libdir} -l${PROJECT_NAME}"
+ )
+ SET(PKG_CONFIG_CFLAGS
+- "-I\${includedir}/lib_common -I\${includedir}/lib_stable"
++ "-I\${includedir}/lib_common -I\${includedir}/lib_stable -I\${includedir}/lib_advanced"
+ )
+
+ message(STATUS "Configuring \"${CMAKE_SOURCE_BINARY_DIR}/${PROJECT_NAME}.pc\"")
+@@ -15,3 +15,7 @@ CONFIGURE_FILE(
+ "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc"
+ @ONLY
+ )
++
++install(
++ FILES "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc"
++ DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/pkgconfig)
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index f92e095..0a547a0 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -37,6 +37,11 @@ target_link_libraries(openfec m)
+
+ install(TARGETS openfec DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
+
++install(
++ DIRECTORY ${PROJECT_SOURCE_DIR}/src/
++ DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}/openfec
++ FILES_MATCHING PATTERN "*.h*")
++
+ include(TestBigEndian)
+ test_big_endian(BIG_ENDIAN)
+ if(BIG_ENDIAN)
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index ac25678..630d950 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -1,19 +1,19 @@
+ # list of dedicated binary tests
+ add_executable(test_create_instance create_instance_test.c)
+ target_link_libraries(test_create_instance openfec m)
+-add_test("create_instance" ${PROJECT_BINARY_DIR}/tests/test_create_instance)
++add_test("create_instance" ${EXECUTABLE_OUTPUT_PATH}/test_create_instance)
+ set_tests_properties ("create_instance"
+ PROPERTIES FAIL_REGULAR_EXPRESSION "ERROR;FAILURE")
+
+ add_executable(test_encoder_instance encoder_instance_test.c)
+ target_link_libraries(test_encoder_instance openfec m)
+-add_test("encoder_instance" ${PROJECT_BINARY_DIR}/tests/test_encoder_instance)
++add_test("encoder_instance" ${EXECUTABLE_OUTPUT_PATH}/test_encoder_instance)
+ set_tests_properties ("encoder_instance"
+ PROPERTIES FAIL_REGULAR_EXPRESSION "ERROR;FAILURE")
+
+ add_executable(test_code_params code_params_test.c)
+ target_link_libraries(test_code_params openfec m)
+-add_test("code_params" ${PROJECT_BINARY_DIR}/tests/test_code_params)
++add_test("code_params" ${EXECUTABLE_OUTPUT_PATH}/test_code_params)
+ set_tests_properties ("code_params"
+ PROPERTIES FAIL_REGULAR_EXPRESSION "ERROR;FAILURE")
+
+diff --git a/tools/descr_stats_v1.2/CMakeLists.txt b/tools/descr_stats_v1.2/CMakeLists.txt
+index 471d732..b3732e9 100644
+--- a/tools/descr_stats_v1.2/CMakeLists.txt
++++ b/tools/descr_stats_v1.2/CMakeLists.txt
+@@ -4,5 +4,3 @@ set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/perf_eval)
+ add_executable(descr_stats ${descr_stat_sources})
+
+ target_link_libraries( descr_stats m)
+-
+-install(TARGETS descr_stats)
diff --git a/buildroot-external/package/openfec/Config.in b/buildroot-external/package/openfec/Config.in
new file mode 100644
index 00000000..550bcf3d
--- /dev/null
+++ b/buildroot-external/package/openfec/Config.in
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_OPENFEC
+ bool "openfec"
+ help
+ Unofficial OpenFEC fork with various bugfixes.
+
+ https://github.com/roc-streaming/openfec
+
diff --git a/buildroot-external/package/openfec/openfec.mk b/buildroot-external/package/openfec/openfec.mk
new file mode 100644
index 00000000..df2c385b
--- /dev/null
+++ b/buildroot-external/package/openfec/openfec.mk
@@ -0,0 +1,18 @@
+################################################################################
+#
+# openfec
+#
+################################################################################
+
+OPENFEC_VERSION = b452e08e5bb135c9fac541ce7553b7b60ceb8119
+OPENFEC_SITE = $(call github,roc-streaming,openfec,$(OPENFEC_VERSION))
+OPENFEC_LICENSE = MIT
+
+OPENFEC_INSTALL_STAGING = YES
+OPENFEC_DEPENDENCIES = host-pkgconf
+OPENFEC_SUPPORTS_IN_SOURCE_BUILD = NO
+
+OPENFEC_CONF_OPTS = \
+ -DOPTIMIZE=DEFAULT
+
+$(eval $(cmake-package))
diff --git a/buildroot-external/package/ragel/ragel.hash b/buildroot-external/package/ragel/ragel.hash
new file mode 100644
index 00000000..332f5874
--- /dev/null
+++ b/buildroot-external/package/ragel/ragel.hash
@@ -0,0 +1,3 @@
+# Locally computed:
+sha256 5f156edb65d20b856d638dd9ee2dfb43285914d9aa2b6ec779dac0270cd56c3f ragel-6.10.tar.gz
+sha256 05a87975accb539399d0c8a4f4402ac27a6762fb1e4f31d04d455a8bee3e3693 COPYING
diff --git a/buildroot-external/package/ragel/ragel.mk b/buildroot-external/package/ragel/ragel.mk
new file mode 100644
index 00000000..56afcd72
--- /dev/null
+++ b/buildroot-external/package/ragel/ragel.mk
@@ -0,0 +1,16 @@
+################################################################################
+#
+# ragel
+#
+################################################################################
+
+RAGEL_VERSION = 6.10
+RAGEL_SITE = https://www.colm.net/files/ragel/
+RAGEL_LICENSE = GPL-2.0
+RAGEL_LICENSE_FILES = COPYING
+RAGEL_CONF_OPTS = \
+ --disable-silent-rules \
+ --disable-manual \
+ --disable-dependency-tracking
+
+$(eval $(host-autotools-package))
diff --git a/buildroot-external/package/roc-toolkit/Config.in b/buildroot-external/package/roc-toolkit/Config.in
new file mode 100644
index 00000000..2cd13955
--- /dev/null
+++ b/buildroot-external/package/roc-toolkit/Config.in
@@ -0,0 +1,11 @@
+config BR2_PACKAGE_ROC_TOOLKIT
+ bool "roc-toolkit"
+ select BR2_PACKAGE_GST1_LIBAV
+ select BR2_PACKAGE_LIBUNWIND
+ select BR2_PACKAGE_OPENFEC
+ select BR2_PACKAGE_SPEEXDSP
+ help
+ Roc is a toolkit for real-time audio streaming over the network.
+
+ https://github.com/roc-streaming/roc-toolkit
+
diff --git a/buildroot-external/package/roc-toolkit/roc-toolkit.mk b/buildroot-external/package/roc-toolkit/roc-toolkit.mk
new file mode 100644
index 00000000..7b76aac1
--- /dev/null
+++ b/buildroot-external/package/roc-toolkit/roc-toolkit.mk
@@ -0,0 +1,42 @@
+################################################################################
+#
+# roc-toolkit
+#
+################################################################################
+
+ROC_TOOLKIT_VERSION = 127cfc645d0a807a33506001367b6d9a9d46f23e
+ROC_TOOLKIT_SITE = $(call github,roc-streaming,roc-toolkit,$(ROC_TOOLKIT_VERSION))
+ROC_TOOLKIT_LICENSE = MPL-2.0
+ROC_TOOLKIT_LICENSE_FILES = LICENSE
+ROC_TOOLKIT_INSTALL_STAGING = YES
+
+ROC_TOOLKIT_DEPENDENCIES = \
+ host-scons \
+ host-pkgconf \
+ host-ragel \
+ gst1-libav \
+ libunwind \
+ openfec \
+ speexdsp \
+ sox \
+ pulseaudio
+
+define ROC_TOOLKIT_BUILD_CMDS
+ (cd $(@D); \
+ $(TARGET_CONFIGURE_OPTS) CROSS=$(TARGET_CROSS) \
+ $(SCONS) $(ROCTOOLKIT__SCONS_OPTS))
+endef
+
+define ROC_TOOLKIT_INSTALL_STAGING_CMDS
+ (cd $(@D); \
+ $(TARGET_CONFIGURE_OPTS) CROSS=$(TARGET_CROSS) \
+ $(SCONS) --prefix="$(STAGING_DIR)/usr" install)
+endef
+
+define ROC_TOOLKIT_INSTALL_TARGET_CMDS
+ (cd $(@D); \
+ $(TARGET_CONFIGURE_OPTS) CROSS=$(TARGET_CROSS) \
+ $(SCONS) --prefix="$(TARGET_DIR)/usr" install)
+endef
+
+$(eval $(generic-package))