From 2d60bc467eeccd9781e88081694165e2b68ac717 Mon Sep 17 00:00:00 2001 From: jayfan0 <34886607+jayfan0@users.noreply.github.com> Date: Fri, 16 Aug 2024 22:10:10 +0100 Subject: [PATCH 1/9] NEetwork Audio --- package/ingenic-audiodaemon/files/S96iad | 14 ++ .../thingino-webui/files/var/www/x/audio.cgi | 121 ++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100755 package/thingino-webui/files/var/www/x/audio.cgi diff --git a/package/ingenic-audiodaemon/files/S96iad b/package/ingenic-audiodaemon/files/S96iad index c4030f3ea..05e430a12 100755 --- a/package/ingenic-audiodaemon/files/S96iad +++ b/package/ingenic-audiodaemon/files/S96iad @@ -4,13 +4,27 @@ DAEMON_ARGS="-r -c /etc/iad.json" +audiostreamer_enable="$(get audiolistener)" +audiostreamer_port="$(get audiolistenerport)" + start() { starting start_daemon + + # Run listener in background for playing audio over the network + if [ "$audiostreamer_enable" = "true" ]; then + nc -ll -p $audiostreamer_port -e iac -s & + echo $! > /run/network_audio.pid + check_result + fi } stop() { stopping + is_streamer_disabled && quit "Streamer disabled" + + kill "$(cat /run/network_audio.pid)" + stop_daemon } diff --git a/package/thingino-webui/files/var/www/x/audio.cgi b/package/thingino-webui/files/var/www/x/audio.cgi new file mode 100755 index 000000000..11c530d71 --- /dev/null +++ b/package/thingino-webui/files/var/www/x/audio.cgi @@ -0,0 +1,121 @@ +#!/usr/bin/haserl + +<%in p/common.cgi %> + +<% + plugin="audio" + plugin_name="Audio" + page_title="Audio" + params="debug iad_net_audio_enabled iad_net_audio_port" + + tmp_file=/tmp/$plugin + + config_file="${ui_config_dir}/${plugin}.conf" + [ ! -f "$config_file" ] && touch $config_file + + audio_control=/etc/init.d/S96iad + + if [ "POST" = "$REQUEST_METHOD" ]; then + # parse values from parameters + for p in $params; do + eval ${plugin}_${p}=\$POST_${plugin}_${p} + sanitize "${plugin}_${p}" + done; unset p + + # validation + + if [ -z "$error" ]; then + # Check if record path starts and ends with "/" + if [ -z $record_path ]; then + echo "Record path cannot be empty. Disabling." >> /tmp/webui.log + record_enable=false + record_path="/mnt/mmcblk0p1/" + else + if [[ $record_path != "/mnt/*" ]]; then + echo "Record path does not seem to be in sd card location. Disabling" >> /tmp/webui.log + record_enable=false + record_path="/mnt/mmcblk0p1/" + fi + if [[ $record_path != "/mnt/*/" ]]; then + echo "record path does not end with "/". Adding" >> /tmp/webui.log + record_path="$record_path/" + fi + fi + + # Checking if LED GPIO is defined, otherwise disable + if [ -z "$record_led_gpio" ]; then + record_led_enabled=false + echo "LED GPIO PIN not defined. Disabling blink" >> /tmp/webui.log + fi + + # Check if max disk usage is defined, otherwise default to 85% + if [ -z "$record_diskusage" ]; then + record_diskusage=85 + echo "Max Disk Usage not defined. Defaulting to 85%" >> /tmp/webui.log + fi + + :>$tmp_file + for p in $params; do + echo "${plugin}_${p}=\"$(eval echo \$${plugin}_${p})\"" >>$tmp_file + done; unset p + mv $tmp_file $config_file + + # Check if record path exists + if [ ! -d "$record_path" ]; then + echo "Record path $record_path does not exist. Creating" >> /tmp/webui.log + mkdir -p "$record_path" >> /tmp/webui.log + fi + + if [ -f "$record_control" ]; then + $record_control restart >> /tmp/webui.log + else + echo "$record_control not found" >> /tmp/webui.log + fi + + update_caminfo + redirect_to "$SCRIPT_NAME" + fi + else + include $config_file + + # default values + [ -z "$record_debug" ] && record_debug=true + [ -z "$record_enabled" ] && record_enabled=false + [ -z "$record_prefix" ] && record_prefix="thingino-" + [ -z "$record_path" ] && record_path="/mnt/mmcblk0p1/" + [ -z "$record_format" ] && record_format="avi" + [ -z "$record_interval" ] && record_interval=60 + [ -z "$record_loop" ] && record_loop=true + [ -z "$record_diskusage" ] && record_diskusage=85 + [ -z "$record_led_enabled" ] && record_led_enabled=false + [ -z "$record_led_gpio" ] && record_led_gpio=$(get gpio_led_r) + [ -z "$record_led_interval" ] && record_led_interval=1 + fi +%> + +<%in p/header.cgi %> + +
+ +<% fi %> +<%in p/footer.cgi %> From ff0da58791d43abd2df1cd7f5674bf94e410d67f Mon Sep 17 00:00:00 2001 From: jayfan0 <34886607+jayfan0@users.noreply.github.com> Date: Fri, 16 Aug 2024 22:27:47 +0100 Subject: [PATCH 2/9] Allow network audio streaming --- package/ingenic-audiodaemon/files/S96iad | 29 +++++++-- .../thingino-webui/files/var/www/x/audio.cgi | 65 ++++--------------- 2 files changed, 36 insertions(+), 58 deletions(-) diff --git a/package/ingenic-audiodaemon/files/S96iad b/package/ingenic-audiodaemon/files/S96iad index 05e430a12..111e39b7b 100755 --- a/package/ingenic-audiodaemon/files/S96iad +++ b/package/ingenic-audiodaemon/files/S96iad @@ -4,16 +4,37 @@ DAEMON_ARGS="-r -c /etc/iad.json" -audiostreamer_enable="$(get audiolistener)" -audiostreamer_port="$(get audiolistenerport)" +# read web config, create if missing +AUDIO_WEBUI_CONF=/etc/webui/audio.conf +[ ! -d $(dirname $AUDIO_WEBUI_CONF) ] && mkdir -p $(dirname $AUDIO_WEBUI_CONF) +[ ! -f $AUDIO_WEBUI_CONF ] && touch $AUDIO_WEBUI_CONF +. $AUDIO_WEBUI_CONF + +# default debugging on +if [ -z "$audio_debug" ]; then + audio_debug="false" + echo "audio_debug=$audio_debug" >> $AUDIO_WEBUI_CONF +fi + +# default to "disabled" and update config +if [ -z "$net_enable" ]; then + net_enable="false" + echo "net_enable=$net_enable" >> $AUDIO_WEBUI_CONF +fi + +# set default port and update config +if [ -z "$net_port" ]; then + net_port=8081 + echo "net_port=$net_port" >> $AUDIO_WEBUI_CONF +fi start() { starting start_daemon # Run listener in background for playing audio over the network - if [ "$audiostreamer_enable" = "true" ]; then - nc -ll -p $audiostreamer_port -e iac -s & + if [ "$net_enable" = "true" ]; then + nc -ll -p $net_port -e iac -s & echo $! > /run/network_audio.pid check_result fi diff --git a/package/thingino-webui/files/var/www/x/audio.cgi b/package/thingino-webui/files/var/www/x/audio.cgi index 11c530d71..fe1cb34f0 100755 --- a/package/thingino-webui/files/var/www/x/audio.cgi +++ b/package/thingino-webui/files/var/www/x/audio.cgi @@ -6,7 +6,7 @@ plugin="audio" plugin_name="Audio" page_title="Audio" - params="debug iad_net_audio_enabled iad_net_audio_port" + params="debug net_enabled net_port" tmp_file=/tmp/$plugin @@ -25,51 +25,16 @@ # validation if [ -z "$error" ]; then - # Check if record path starts and ends with "/" - if [ -z $record_path ]; then - echo "Record path cannot be empty. Disabling." >> /tmp/webui.log - record_enable=false - record_path="/mnt/mmcblk0p1/" - else - if [[ $record_path != "/mnt/*" ]]; then - echo "Record path does not seem to be in sd card location. Disabling" >> /tmp/webui.log - record_enable=false - record_path="/mnt/mmcblk0p1/" - fi - if [[ $record_path != "/mnt/*/" ]]; then - echo "record path does not end with "/". Adding" >> /tmp/webui.log - record_path="$record_path/" - fi - fi - - # Checking if LED GPIO is defined, otherwise disable - if [ -z "$record_led_gpio" ]; then - record_led_enabled=false - echo "LED GPIO PIN not defined. Disabling blink" >> /tmp/webui.log - fi - - # Check if max disk usage is defined, otherwise default to 85% - if [ -z "$record_diskusage" ]; then - record_diskusage=85 - echo "Max Disk Usage not defined. Defaulting to 85%" >> /tmp/webui.log - fi - :>$tmp_file for p in $params; do echo "${plugin}_${p}=\"$(eval echo \$${plugin}_${p})\"" >>$tmp_file done; unset p mv $tmp_file $config_file - # Check if record path exists - if [ ! -d "$record_path" ]; then - echo "Record path $record_path does not exist. Creating" >> /tmp/webui.log - mkdir -p "$record_path" >> /tmp/webui.log - fi - - if [ -f "$record_control" ]; then - $record_control restart >> /tmp/webui.log + if [ -f "$audio_control" ]; then + $audio_control restart >> /tmp/webui.log else - echo "$record_control not found" >> /tmp/webui.log + echo "$audio_control not found" >> /tmp/webui.log fi update_caminfo @@ -79,17 +44,9 @@ include $config_file # default values - [ -z "$record_debug" ] && record_debug=true - [ -z "$record_enabled" ] && record_enabled=false - [ -z "$record_prefix" ] && record_prefix="thingino-" - [ -z "$record_path" ] && record_path="/mnt/mmcblk0p1/" - [ -z "$record_format" ] && record_format="avi" - [ -z "$record_interval" ] && record_interval=60 - [ -z "$record_loop" ] && record_loop=true - [ -z "$record_diskusage" ] && record_diskusage=85 - [ -z "$record_led_enabled" ] && record_led_enabled=false - [ -z "$record_led_gpio" ] && record_led_gpio=$(get gpio_led_r) - [ -z "$record_led_interval" ] && record_led_interval=1 + [ -z "$audio_debug" ] && audio_debug=false + [ -z "$net_enabled" ] && net_enabled=false + [ -z "$net_port" ] && net_port=8081 fi %> @@ -98,9 +55,9 @@ - <% fi %> <%in _footer.cgi %> From 6b7613eb1c094f1fa5c12a36b9703e7c46347914 Mon Sep 17 00:00:00 2001 From: jayfan0 <34886607+jayfan0@users.noreply.github.com> Date: Fri, 16 Aug 2024 23:54:40 +0100 Subject: [PATCH 8/9] remoe stray `fi` --- package/thingino-webui/files/var/www/x/config-audio.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/thingino-webui/files/var/www/x/config-audio.cgi b/package/thingino-webui/files/var/www/x/config-audio.cgi index c561d0bcd..eeba91bcf 100755 --- a/package/thingino-webui/files/var/www/x/config-audio.cgi +++ b/package/thingino-webui/files/var/www/x/config-audio.cgi @@ -65,5 +65,5 @@ fi -<% fi %> + <%in _footer.cgi %> From 2b397d2709361237906dd04bc79c9e416a219bde Mon Sep 17 00:00:00 2001 From: jayfan0 <34886607+jayfan0@users.noreply.github.com> Date: Thu, 22 Aug 2024 09:14:42 +0100 Subject: [PATCH 9/9] Rename to Audio Backchannel. Add WIP column for audio output settings --- package/thingino-webui/files/var/www/x/config-audio.cgi | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/package/thingino-webui/files/var/www/x/config-audio.cgi b/package/thingino-webui/files/var/www/x/config-audio.cgi index eeba91bcf..470c95552 100755 --- a/package/thingino-webui/files/var/www/x/config-audio.cgi +++ b/package/thingino-webui/files/var/www/x/config-audio.cgi @@ -50,13 +50,15 @@ fi