diff options
author | Yoann QUERET <yoann@queret.net> | 2016-02-09 16:29:25 +0100 |
---|---|---|
committer | Yoann QUERET <yoann@queret.net> | 2016-02-09 16:29:25 +0100 |
commit | a153cb1e281357300ae43454cba593b9cf0c3bde (patch) | |
tree | 4430d0a1019e0f6cbe0e7935f3faaf613ffe343b | |
parent | bcd51f68047854efc73f53463e0091bae14b7ad9 (diff) | |
download | dab-scripts-a153cb1e281357300ae43454cba593b9cf0c3bde.tar.gz dab-scripts-a153cb1e281357300ae43454cba593b9cf0c3bde.tar.bz2 dab-scripts-a153cb1e281357300ae43454cba593b9cf0c3bde.zip |
Bye bye old script, welcome supervisor
-rwxr-xr-x | encode-gst.sh | 48 | ||||
-rw-r--r-- | encode-jack-dls-jamin.sh | 354 | ||||
-rwxr-xr-x | encode-jack-dls.sh | 293 | ||||
-rwxr-xr-x | encode-jack.sh | 238 | ||||
-rwxr-xr-x | encode-libvlc.sh | 116 | ||||
-rw-r--r-- | encode-mot.sh | 92 | ||||
-rwxr-xr-x | encode-mpg123.sh | 45 | ||||
-rw-r--r-- | examplesite/configuration.sh | 23 | ||||
-rw-r--r-- | examplesite/dls/radio1-default.dls | 1 | ||||
-rw-r--r-- | examplesite/filtertaps.txt | 46 | ||||
-rw-r--r-- | examplesite/mail-warning.txt | 0 | ||||
-rw-r--r-- | examplesite/mod.ini | 46 | ||||
-rw-r--r-- | examplesite/multiplex.mux | 76 | ||||
-rwxr-xr-x | icy-info.py | 93 | ||||
-rwxr-xr-x | kill-all-encoders.sh | 6 | ||||
-rwxr-xr-x | launch-all-encoders.sh | 28 | ||||
-rw-r--r-- | mot.sh | 51 | ||||
-rwxr-xr-x | radio.sh | 52 | ||||
-rwxr-xr-x | start-mux-mod.sh | 34 |
19 files changed, 0 insertions, 1642 deletions
diff --git a/encode-gst.sh b/encode-gst.sh deleted file mode 100755 index 255b4be..0000000 --- a/encode-gst.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# -# Encode one programme using gstreamer. -# -# Status: Experimental - -URL=$1 -ID=$2 -DST=$3 - -QUEUEDELAY=400000 #400ms - -BITRATE=80 -RATE=32000 - -if [[ "$DST" == "" ]] -then - echo "Usage $0 url id destination" - exit 1 -fi - -while true -do - - gst-launch -q \ - uridecodebin uri=$URL ! \ - queue "max-size-time=$QUEUEDELAY" ! \ - audioresample quality=8 ! \ - audioconvert ! \ - audio/x-raw-int, "rate=$RATE,format=S16LE,channels=2" ! \ - filesink location="/dev/stdout" | \ - dabplus-enc -i /dev/stdin -b $BITRATE -r $RATE -f raw -a -o $DST - - R=$? - - NOW=$(date) - - mail -s "Encoder $ID restart $URL" matthias+odrge1@mpb.li << EOF -The encoder id:$ID -encoding $URL -> $DST with gstreamer was restarted at -$NOW - -The return code was $R - -EOF - - sleep 5 -done diff --git a/encode-jack-dls-jamin.sh b/encode-jack-dls-jamin.sh deleted file mode 100644 index 32d4557..0000000 --- a/encode-jack-dls-jamin.sh +++ /dev/null @@ -1,354 +0,0 @@ -#!/bin/bash -# -# Encode programme using mplayer, connect through JACK -# to jamin, which connects to dabplus-enc or toolame -# -# Read webstream from URL using mplayer -# Launch dabplus-enc or toolame encoder -# Launch jamin -# connect all through JACK -# monitor processes, and restart if necessary -# Optionally send an email when restart happens -# -# Extract ICY Text from stream and use it for DLS - -printerr() { - echo -e "\033[01;31m$1\033[0m" - logger -p local0.error -t "$ID" "$1" -} - -printmsg() { - echo -e "\033[01;32m$1\033[0m" - logger -p local0.notice -t "$ID" "$1" -} - -set -u - -# check number of arguments -if [[ "$#" -lt 3 ]] ; then - echo "Usage $0 url jack-id destination [volume] [encoder]" - echo "The volume setting is optional" - exit 1 -fi - -if [[ "$#" -gt 2 ]] ; then - URL=$1 - ID=$2 - DST=$3 -fi - -if [[ "$#" == 4 ]] ; then - VOL=$4 - ENC="dabplus-enc" -elif [[ "$#" == 5 ]] ; then - VOL=$4 - ENC=$5 -else - VOL="0" - ENC="dabplus-enc" -fi - - -BITRATE=96 -RATE=48 - -if [[ "$ENC" == "toolame" && "$RATE" == "32" ]] ; then - echo "32kHz not supported for toolame" - exit 1 -fi - -DLSDIR=site/dls -SLIDEDIR=site/slide -JAMIN=site/jamin - - -mplayerpid=0 -encoderpid=0 -motencoderpid=0 -jaminpid=0 -running=1 - -mplayer_ok=0 -encoder_ok=0 -jamin_ok=0 - -# The trap for Ctrl-C -sigint_trap() { - printerr "Got Ctrl-C, killing mplayer and encoder" - running=0 - - if [[ "$mplayerpid" != "0" ]] ; then - kill -TERM $mplayerpid - sleep 2 - kill -KILL $mplayerpid - fi - - if [[ "$encoderpid" != "0" ]] ; then - kill -TERM $encoderpid - sleep 2 - kill -KILL $encoderpid - fi - - if [[ "$motencoderpid" != "0" ]] ; then - kill -TERM $motencoderpid - sleep 2 - kill -KILL $motencoderpid - fi - if [[ "$jaminpid" != "0" ]] ; then - kill -TERM $jaminpid - sleep 2 - kill -KILL $jaminpid - fi - - printmsg "Goodbye" - exit -} - -trap sigint_trap SIGTERM -trap sigint_trap SIGINT - -while [[ "$running" == "1" ]] -do - if [[ "$mplayerpid" == "0" ]] ; then - if [[ "$VOL" == "0" ]] ; then - mplayer -quiet -af resample=${RATE}000:0:2 -ao jack:name=$ID "$URL" | \ - ./icy-info.py $DLSDIR/${ID}.dls $DLSDIR/${ID}-default.dls & - mplayerpid=$! - else - mplayer -quiet -af resample=${RATE}000:0:2 -af volume=$VOL -ao jack:name=$ID "$URL" | \ - ./icy-info.py $DLSDIR/${ID}.dls $DLSDIR/${ID}-default.dls & - mplayerpid=$! - fi - - printmsg "Started mplayer with pid $mplayerpid" - - # give some time to mplayer to set up and - # wait until port becomes visible - timeout=10 - - while [[ "$mplayer_ok" == "0" ]] - do - printmsg "Waiting for mplayer to connect to jack ($timeout)" - sleep 1 - mplayer_ok=$(jack_lsp $ID:out_0 | wc -l) - - timeout=$(( $timeout - 1 )) - - if [[ "$timeout" == "0" ]] ; then - printerr "mplayer doesn't connect to jack !" - kill $mplayerpid - break - fi - done - else - printmsg "No need to start mplayer: $mplayerpid" - fi - - if [[ "$mplayer_ok" == "1" && "$encoder_ok" == "0" ]] ; then - if [[ "$ENC" == "dabplus-enc" ]] ; then - dabplus-enc -j ${ID}enc -l \ - -p 34 -P $DLSDIR/${ID}.pad \ - -b $BITRATE -r ${RATE}000 -f raw -o $DST & - encoderpid=$! - elif [[ "$ENC" == "toolame" ]] ; then - toolame -b $BITRATE -s $RATE \ - -p 34 -P $DLSDIR/${ID}.pad \ - -j ${ID}enc $DST & - encoderpid=$! - fi - - #jasmin - - if [[ "$jaminpid" == "0" ]] ; then - jamin -g -f $JAMIN/$ID.jam $ID:out_0 $ID:out_1 ${ID}enc:input0 ${ID}enc:input1 & - jaminpid=$! - fi - - printmsg "Started jamin with pid $jaminpid" - - # give some time to the encoder to set up and - # wait until port becomes visible - timeout=10 - - encoder_connected=0 - - while [[ "$encoder_connected" == "0" ]] - do - printmsg "Waiting for encoder to connect to jack ($timeout)" - sleep 1 - encoder_connected=$(jack_lsp ${ID}enc:input0 | wc -l) - - timeout=$(( $timeout - 1)) - - if [[ "$timeout" == "0" ]] ; then - printerr "encoder doesn't connect to jack !" - kill $encoderpid - break - fi - done - -# if [[ "$encoder_connected" == "1" ]] ; then -# jack_connect ${ID}:out_0 ${ID}enc:input0 && \ -# jack_connect ${ID}:out_1 ${ID}enc:input1 #&& \ -# jack_connect ${ID}:out_0 ${ID}enc:input0 && \ -# jack_connect ${ID}:out_0 ${ID}enc:input1 -# connect_ret=$? -# -# if [[ "$connect_ret" == "0" ]] ; then -# encoder_ok=1 -# else -# encoder_ok=0 -# fi - -encoder_ok=1 -# -# if [[ "$encoder_ok" == "1" ]] ; then -# printmsg "Started encoder with pid $encoderpid" -# else -# if [[ "$encoderpid" != "0" ]] ; then -# kill -TERM $encoderpid -# fi -# fi -# fi - fi - - if [[ "$encoder_ok" == "1" && "$motencoderpid" == "0" ]] ; then - # Check if the slides folder exists, and start mot-encoder accordingly - if [[ -d "$SLIDEDIR/$ID" ]] ; then - mot-encoder -o $DLSDIR/${ID}.pad -t $DLSDIR/${ID}.dls -p 34 -v \ - -e -d $SLIDEDIR/${ID} & - motencoderpid=$! - else - mot-encoder -o $DLSDIR/${ID}.pad -t $DLSDIR/${ID}.dls -p 34 -v & - motencoderpid=$! - fi - - printmsg "Started mot-encoder with pid $encoderpid" - fi - - - sleep 8 - - checkloop=1 - while [[ "$checkloop" == "1" ]] - do - sleep 2 - - kill -s 0 $mplayerpid - if [[ "$?" != "0" ]] ; then - # mplayer died - # we must kill jack-stdout, because we cannot reconnect it - # to a new mplayer, since we do not know the jack-stdout name. - # And it has no cmdline option to set one, Rrrrongntudtjuuu! - - if [[ "$encoderpid" != "0" ]] ; then - kill -TERM $encoderpid - fi - - if [[ "$motencoderpid" != "0" ]] ; then - kill -TERM $motencoderpid - fi - - if [[ "$jaminpid" != "0" ]] ; then - kill -TERM $jaminpid - fi - - # mark as dead - mplayerpid=0 - mplayer_ok=0 - encoderpid=0 - encoder_ok=0 - jaminpid=0 - jamin_ok=0 - motencoderpid=0 - - checkloop=0 - - printerr "Mplayer died" - fi - - if [[ "$encoderpid" != "0" ]] ; then - kill -s 0 $encoderpid - if [[ "$?" != "0" ]] ; then - # the encoder died, - # no need to kill the mplayer, we can reconnect to it - - if [[ "$motencoderpid" != "0" ]] ; then - kill -TERM $motencoderpid - fi - - if [[ "$jaminpid" != "0" ]] ; then - kill -TERM $jaminpid - fi - - encoderpid=0 - encoder_ok=0 - jaminpid=0 - jamin_ok=0 - motencoderpid=0 - - checkloop=0 - - printerr "Encoder died" - fi - fi - - if [[ "$jaminpid" != "0" ]] ; then - kill -s 0 $jaminpid - if [[ "$?" != "0" ]] ; then - # the jamin died, - - if [[ "$motencoderpid" != "0" ]] ; then - kill -TERM $motencoderpid - fi - - if [[ "$encoderpid" != "0" ]] ; then - kill -TERM $encoderpid - fi - - encoderpid=0 - encoder_ok=0 - jaminpid=0 - motencoderpid=0 - - checkloop=0 - - printerr "Jamin died" - fi - - fi - - if [[ "$motencoderpid" != "0" ]] ; then - kill -s 0 $motencoderpid - if [[ "$?" != "0" ]] ; then - # mot-encoder died - # let's try restarting it - - motencoderpid=0 - - checkloop=0 - - printerr "mot-encoder died" - fi - fi - done - - MAILTO=$(cat site/mail-warning.txt) - - if [[ "$MAILTO" != "" ]] ; then - NOW=$(date) - - mail -s "Encoder $ID restart $URL" "$MAILTO" << EOF -The encoder id:$ID -encoding $URL -> $DST using encode-jack-dls-jamin was restarted at -$NOW - -mplayer ok? $mplayer_ok - -EOF - - fi - sleep 5 - -done - diff --git a/encode-jack-dls.sh b/encode-jack-dls.sh deleted file mode 100755 index 042fc2f..0000000 --- a/encode-jack-dls.sh +++ /dev/null @@ -1,293 +0,0 @@ -#!/bin/bash -# -# Encode programme using mplayer, connect through JACK -# to dabplus-enc or toolame -# -# Read webstream from URL using mplayer -# Launch dabplus-enc or toolame encoder -# connect both through JACK -# monitor processes, and restart if necessary -# Optionally send an email when restart happens -# -# Extract ICY Text from stream and use it for DLS - -printerr() { - echo -e "\033[01;31m$1\033[0m" - logger -p local0.error -t "$ID" "$1" -} - -printmsg() { - echo -e "\033[01;32m$1\033[0m" - logger -p local0.notice -t "$ID" "$1" -} - -set -u - -# check number of arguments -if [[ "$#" -lt 3 ]] ; then - echo "Usage $0 url jack-id destination [volume] [encoder]" - echo "The volume setting is optional" - exit 1 -fi - -if [[ "$#" -gt 2 ]] ; then - URL=$1 - ID=$2 - DST=$3 -fi - -if [[ "$#" == 4 ]] ; then - VOL=$4 - ENC="dabplus-enc" -elif [[ "$#" == 5 ]] ; then - VOL=$4 - ENC=$5 -else - VOL="0" - ENC="dabplus-enc" -fi - - -BITRATE=80 -RATE=32 #kHz - -if [[ "$ENC" == "toolame" && "$RATE" == "32" ]] ; then - echo "32kHz not supported for toolame" - exit 1 -fi - -DLSDIR=site/dls -SLIDEDIR=site/slide - -mplayerpid=0 -encoderpid=0 -motencoderpid=0 -running=1 - -mplayer_ok=0 -encoder_ok=0 - -# The trap for Ctrl-C -sigint_trap() { - printerr "Got Ctrl-C, killing mplayer and encoder" - running=0 - - if [[ "$mplayerpid" != "0" ]] ; then - kill -TERM $mplayerpid - sleep 2 - kill -KILL $mplayerpid - fi - - if [[ "$encoderpid" != "0" ]] ; then - kill -TERM $encoderpid - sleep 2 - kill -KILL $encoderpid - fi - - if [[ "$motencoderpid" != "0" ]] ; then - kill -TERM $motencoderpid - sleep 2 - kill -KILL $motencoderpid - fi - - printmsg "Goodbye" - exit -} - -trap sigint_trap SIGTERM -trap sigint_trap SIGINT - -while [[ "$running" == "1" ]] -do - if [[ "$mplayerpid" == "0" ]] ; then - if [[ "$VOL" == "0" ]] ; then - mplayer -quiet -af resample=${RATE}000:0:2 -ao jack:name=$ID "$URL" | \ - ./icy-info.py $DLSDIR/${ID}.dls $DLSDIR/${ID}-default.dls & - mplayerpid=$! - else - mplayer -quiet -af resample=${RATE}000:0:2 -af volume=$VOL -ao jack:name=$ID "$URL" | \ - ./icy-info.py $DLSDIR/${ID}.dls $DLSDIR/${ID}-default.dls & - mplayerpid=$! - fi - - printmsg "Started mplayer with pid $mplayerpid" - - # give some time to mplayer to set up and - # wait until port becomes visible - timeout=10 - - while [[ "$mplayer_ok" == "0" ]] - do - printmsg "Waiting for mplayer to connect to jack ($timeout)" - sleep 1 - mplayer_ok=$(jack_lsp $ID:out_0 | wc -l) - - timeout=$(( $timeout - 1 )) - - if [[ "$timeout" == "0" ]] ; then - printerr "mplayer doesn't connect to jack !" - kill $mplayerpid - break - fi - done - else - printmsg "No need to start mplayer: $mplayerpid" - fi - - if [[ "$mplayer_ok" == "1" && "$encoder_ok" == "0" ]] ; then - if [[ "$ENC" == "dabplus-enc" ]] ; then - dabplus-enc -j ${ID}enc -l \ - -p 34 -P $DLSDIR/${ID}.pad \ - -b $BITRATE -r ${RATE}000 -f raw -o $DST & - encoderpid=$! - elif [[ "$ENC" == "toolame" ]] ; then - toolame -b $BITRATE -s $RATE \ - -p 34 -P $DLSDIR/${ID}.pad \ - -j ${ID}enc $DST & - encoderpid=$! - fi - - # give some time to the encoder to set up and - # wait until port becomes visible - timeout=10 - - encoder_connected=0 - - while [[ "$encoder_connected" == "0" ]] - do - printmsg "Waiting for encoder to connect to jack ($timeout)" - sleep 1 - encoder_connected=$(jack_lsp ${ID}enc:input0 | wc -l) - - timeout=$(( $timeout - 1)) - - if [[ "$timeout" == "0" ]] ; then - printerr "encoder doesn't connect to jack !" - kill $encoderpid - break - fi - done - - if [[ "$encoder_connected" == "1" ]] ; then - jack_connect ${ID}:out_0 ${ID}enc:input0 && \ - jack_connect ${ID}:out_1 ${ID}enc:input1 - connect_ret=$? - - if [[ "$connect_ret" == "0" ]] ; then - encoder_ok=1 - else - encoder_ok=0 - fi - - if [[ "$encoder_ok" == "1" ]] ; then - printmsg "Started encoder with pid $encoderpid" - else - if [[ "$encoderpid" != "0" ]] ; then - kill -TERM $encoderpid - fi - fi - fi - fi - - if [[ "$encoder_ok" == "1" && "$motencoderpid" == "0" ]] ; then - # Check if the slides folder exists, and start mot-encoder accordingly - if [[ -d "$SLIDEDIR/$ID" ]] ; then - mot-encoder -o $DLSDIR/${ID}.pad -t $DLSDIR/${ID}.dls -p 34 -v \ - -e -d $SLIDEDIR/${ID} & - motencoderpid=$! - else - mot-encoder -o $DLSDIR/${ID}.pad -t $DLSDIR/${ID}.dls -p 34 -v & - motencoderpid=$! - fi - - printmsg "Started mot-encoder with pid $encoderpid" - fi - - - sleep 5 - - checkloop=1 - while [[ "$checkloop" == "1" ]] - do - sleep 2 - - kill -s 0 $mplayerpid - if [[ "$?" != "0" ]] ; then - # mplayer died - # we must kill jack-stdout, because we cannot reconnect it - # to a new mplayer, since we do not know the jack-stdout name. - # And it has no cmdline option to set one, Rrrrongntudtjuuu! - if [[ "$encoderpid" != "0" ]] ; then - kill -TERM $encoderpid - fi - - if [[ "$motencoderpid" != "0" ]] ; then - kill -TERM $motencoderpid - fi - - # mark as dead - mplayerpid=0 - mplayer_ok=0 - encoderpid=0 - encoder_ok=0 - motencoderpid=0 - - checkloop=0 - - printerr "Mplayer died" - fi - - if [[ "$encoderpid" != "0" ]] ; then - kill -s 0 $encoderpid - if [[ "$?" != "0" ]] ; then - # the encoder died, - # no need to kill the mplayer, we can reconnect to it - - if [[ "$motencoderpid" != "0" ]] ; then - kill -TERM $motencoderpid - fi - - motencoderpid=0 - encoderpid=0 - encoder_ok=0 - - checkloop=0 - - printerr "Encoder died" - fi - fi - - if [[ "$motencoderpid" != "0" ]] ; then - kill -s 0 $motencoderpid - if [[ "$?" != "0" ]] ; then - # mot-encoder died - # let's try restarting it - - motencoderpid=0 - - checkloop=0 - - printerr "mot-encoder died" - fi - fi - done - - MAILTO=$(cat site/mail-warning.txt) - - if [[ "$MAILTO" != "" ]] ; then - NOW=$(date) - - mail -s "Encoder $ID restart $URL" "$MAILTO" << EOF -The encoder id:$ID -encoding $URL -> $DST using encode-jack-dls was restarted at -$NOW - -mplayer ok? $mplayer_ok - -EOF - - fi - sleep 5 - -done - diff --git a/encode-jack.sh b/encode-jack.sh deleted file mode 100755 index bb28dee..0000000 --- a/encode-jack.sh +++ /dev/null @@ -1,238 +0,0 @@ -#!/bin/bash -# -# Encode programme using mplayer, connect through JACK -# to dabplus-enc or toolame -# -# Read webstream from URL using mplayer -# Launch dabplus-enc or toolame encoder -# connect both through JACK -# monitor processes, and restart if necessary -# Optionally send an email when restart happens - -printerr() { - echo -e "\033[01;31m$1\033[0m" - logger -p local0.error -t "$ID" "$1" -} - -printmsg() { - echo -e "\033[01;32m$1\033[0m" - logger -p local0.notice -t "$ID" "$1" -} - -set -u - -# check number of arguments -if [[ "$#" -lt 3 ]] ; then - echo "Usage $0 url jack-id destination [volume] [encoder]" - echo "The volume setting is optional" - exit 1 -fi - -if [[ "$#" -gt 2 ]] ; then - URL=$1 - ID=$2 - DST=$3 -fi - -if [[ "$#" == 4 ]] ; then - VOL=$4 - ENC="dabplus-enc" -elif [[ "$#" == 5 ]] ; then - VOL=$4 - ENC=$5 -else - VOL="0" - ENC="dabplus-enc" -fi - - -BITRATE=80 -RATE=32 #kHz - -if [[ "$ENC" == "toolame" && "$RATE" == "32" ]] ; then - echo "32kHz not supported for toolame" - exit 1 -fi - -mplayerpid=0 -encoderpid=0 -running=1 - -mplayer_ok=0 -encoder_ok=0 - -# The trap for Ctrl-C -sigint_trap() { - printerr "Got Ctrl-C, killing mplayer and encoder" - running=0 - - if [[ "$mplayerpid" != "0" ]] ; then - kill -TERM $mplayerpid - sleep 2 - kill -KILL $mplayerpid - fi - - if [[ "$encoderpid" != "0" ]] ; then - kill -TERM $encoderpid - sleep 2 - kill -KILL $encoderpid - fi - - printmsg "quitting" - exit -} - -trap sigint_trap SIGTERM -trap sigint_trap SIGINT - -while [[ "$running" == "1" ]] -do - if [[ "$mplayerpid" == "0" ]] ; then - if [[ "$VOL" == "0" ]] ; then - mplayer -quiet -af resample=${RATE}000:0:2 -ao jack:name=$ID "$URL" & - mplayerpid=$! - else - mplayer -quiet -af resample=${RATE}000:0:2 -af volume=$VOL -ao jack:name=$ID "$URL" & - mplayerpid=$! - fi - - printmsg "Started mplayer with pid $mplayerpid" - - # give some time to mplayer to set up and - # wait until port becomes visible - timeout=10 - - while [[ "$mplayer_ok" == "0" ]] - do - printmsg "Waiting for mplayer to connect to jack ($timeout)" - sleep 1 - mplayer_ok=$(jack_lsp $ID:out_0 | wc -l) - - timeout=$(( $timeout - 1 )) - - if [[ "$timeout" == "0" ]] ; then - printerr "mplayer doesn't connect to jack !" - kill $mplayerpid - break - fi - done - else - printmsg "No need to start mplayer: $mplayerpid" - fi - - if [[ "$mplayer_ok" == "1" && "$encoder_ok" == "0" ]] ; then - if [[ "$ENC" == "dabplus-enc" ]] ; then - dabplus-enc -j ${ID}enc -l \ - -b $BITRATE -r ${RATE}000 -f raw -o $DST & - encoderpid=$! - elif [[ "$ENC" == "toolame" ]] ; then - toolame -b $BITRATE -s $RATE \ - -j ${ID}enc $DST & - encoderpid=$! - fi - - # give some time to the encoder to set up and - # wait until port becomes visible - timeout=10 - - encoder_connected=0 - - while [[ "$encoder_connected" == "0" ]] - do - printmsg "Waiting for encoder to connect to jack ($timeout)" - sleep 1 - encoder_connected=$(jack_lsp ${ID}enc:input0 | wc -l) - - timeout=$(( $timeout - 1)) - - if [[ "$timeout" == "0" ]] ; then - printerr "encoder doesn't connect to jack !" - kill $encoderpid - break - fi - done - - if [[ "$encoder_connected" == "1" ]] ; then - jack_connect ${ID}:out_0 ${ID}enc:input0 && \ - jack_connect ${ID}:out_1 ${ID}enc:input1 - connect_ret=$? - - if [[ "$connect_ret" == "0" ]] ; then - encoder_ok=1 - else - encoder_ok=0 - fi - - if [[ "$encoder_ok" == "1" ]] ; then - printmsg "Started encoder with pid $encoderpid" - else - if [[ "$encoderpid" != "0" ]] ; then - kill -TERM $encoderpid - fi - fi - fi - fi - - sleep 5 - - checkloop=1 - while [[ "$checkloop" == "1" ]] - do - sleep 2 - - kill -s 0 $mplayerpid - if [[ "$?" != "0" ]] ; then - # mplayer died - # we must kill jack-stdout, because we cannot reconnect it - # to a new mplayer, since we do not know the jack-stdout name. - # And it has no cmdline option to set one, Rrrrongntudtjuuu! - if [[ "$encoderpid" != "0" ]] ; then - kill -TERM $encoderpid - fi - - # mark as dead - mplayerpid=0 - mplayer_ok=0 - encoderpid=0 - encoder_ok=0 - - checkloop=0 - - printerr "Mplayer died" - fi - - if [[ "$encoderpid" != "0" ]] ; then - kill -s 0 $encoderpid - if [[ "$?" != "0" ]] ; then - # the encoder died, - # no need to kill the mplayer, we can reconnect to it - - encoderpid=0 - encoder_ok=0 - - checkloop=0 - - printerr "Encoder died" - fi - fi - done - - MAILTO=$(cat site/mail-warning.txt) - - if [[ "$MAILTO" != "" ]] ; then - NOW=$(date) - - mail -s "Encoder $ID restart $URL" "$MAILTO" << EOF -The encoder id:$ID -encoding $URL -> $DST using encode-jack was restarted at -$NOW - -mplayer ok? $mplayer_ok - -EOF - - fi - sleep 5 - -done - diff --git a/encode-libvlc.sh b/encode-libvlc.sh deleted file mode 100755 index 361a743..0000000 --- a/encode-libvlc.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/bash -# -# Encode programme using libVLC input from -# dabplus-enc or toolame -# -# monitor processes, and restart if necessary -# Optionally send an email when restart happens - -printerr() { - echo -e "\033[01;31m$1\033[0m" - logger -p local0.error -t "$ID" "$1" -} - -printmsg() { - echo -e "\033[01;32m$1\033[0m" - logger -p local0.notice -t "$ID" "$1" -} - -set -u - -# check number of arguments -if [[ "$#" -lt 3 ]] ; then - echo "Usage $0 url id destination [encoder]" - echo "Encoder shall be 'dabplus-enc' or 'toolame'" - exit 1 -fi - -URL=$1 -ID=$2 -DST=$3 - -if [[ "$#" -gt 3 ]] ; then - ENC=$4 -else - ENC="dabplus-enc" -fi - -if [[ "$#" -gt 4 ]]; then - shift 4 - OPTIONS=$@ -else - if [[ "$ENC" == "dabplus-enc" ]]; then - OPTIONS="-b 80 -r 32000" - else - OPTIONS="-b 128 -s 48 -L" - fi -fi - -running=1 - -encoderpid=0 - -# The trap for Ctrl-C -sigint_trap() { - printerr "Got Ctrl-C, killing mplayer and encoder" - running=0 - - if [[ "$encoderpid" != "0" ]] ; then - kill -TERM $encoderpid - sleep 2 - kill -KILL $encoderpid - fi - - printmsg "quitting" - exit -} - -trap sigint_trap SIGTERM -trap sigint_trap SIGINT - -while [[ "$running" == "1" ]] -do - - printmsg "Launching encoder" - if [[ "$ENC" == "dabplus-enc" ]] ; then - dabplus-enc -v "$URL" $OPTIONS -o "$DST" -l & - encoderpid=$! - elif [[ "$ENC" == "toolame" ]] ; then - toolame $OPTIONS -V "$URL" "$DST" & - encoderpid=$! - fi - printerr "Detected crash of encoder!" - - sleep 5 - - checkloop=1 - while [[ "$checkloop" == "1" ]] - do - sleep 2 - - kill -s 0 $encoderpid - if [[ "$?" != "0" ]] ; then - printerr "the encoder died" - - encoderpid=0 - checkloop=0 - fi - done - - MAILTO=$(cat site/mail-warning.txt) - - if [[ "$MAILTO" != "" ]] ; then - NOW=$(date) - - mail -s "Encoder $ID restart $URL" "$MAILTO" << EOF -The encoder id:$ID -encoding $URL -> $DST using encode-libvlc was restarted at -$NOW - -EOF - - fi - sleep 5 - -done - diff --git a/encode-mot.sh b/encode-mot.sh deleted file mode 100644 index ad60bad..0000000 --- a/encode-mot.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash -# -# Encode programme using libVLC input from -# dabplus-enc or toolame -# -# monitor processes, and restart if necessary -# Optionally send an email when restart happens - -printerr() { - echo -e "\033[01;31m$1\033[0m" - logger -p local0.error -t "$ID" "$1" -} - -printmsg() { - echo -e "\033[01;32m$1\033[0m" - logger -p local0.notice -t "$ID" "$1" -} - -set -u - -# check number of arguments -if [[ "$#" -lt 3 ]] ; then - echo "Usage $0 id options" - exit 1 -fi - -ID=$1 -shift 2 - -OPTIONS=$@ - -running=1 - -encoderpid=0 - -# The trap for Ctrl-C -sigint_trap() { - printerr "Got Ctrl-C, killing mot-encoder" - running=0 - - if [[ "$encoderpid" != "0" ]] ; then - kill -TERM $encoderpid - fi - - printmsg "quitting" - exit -} - -trap sigint_trap SIGTERM -trap sigint_trap SIGINT - -while [[ "$running" == "1" ]] -do - - printmsg "Launching mot-encoder" - mot-encoder $OPTIONS & - encoderpid=$! - printerr "Detected crash of encoder!" - - sleep 5 - - checkloop=1 - while [[ "$checkloop" == "1" ]] - do - sleep 2 - - kill -s 0 $encoderpid - if [[ "$?" != "0" ]] ; then - printerr "the mot-encoder died" - - encoderpid=0 - checkloop=0 - fi - done - - MAILTO=$(cat ./mail-warning.txt) - - if [[ "$MAILTO" != "" ]] ; then - NOW=$(date) - - mail -s "MOT Encoder $ID restart $URL" "$MAILTO" << EOF -The encoder id:$ID -encoding using mot-encoder was restarted at -$NOW - -EOF - - fi - sleep 5 - -done - diff --git a/encode-mpg123.sh b/encode-mpg123.sh deleted file mode 100755 index 17c4d7f..0000000 --- a/encode-mpg123.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -# -# Encode programme using mpg123 -# -# Status: Experimental - -URL=$1 -ID=$2 -DST=$4 - -BITRATE=80 -RATE=32000 - -if [[ "$DST" == "" ]] -then - echo "Usage $0 url id destination" - exit 1 -fi - -while true -do - - mpg123 -r $RATE -s $URL | \ - dabplus-enc -i /dev/stdin -b $BITRATE -r $RATE -f raw -a -o $DST - - R=$? - - MAILTO=$(cat site/mail-warning.txt) - - if [[ "$MAILTO" != "" ]] ; then - NOW=$(date) - - mail -s "Encoder $ID restart $URL" $MAILTO << EOF -The encoder id:$ID -encoding $URL -> $DST with mpg123 was restarted at -$NOW - -The return code was $R - -EOF - fi - - sleep 5 -done - diff --git a/examplesite/configuration.sh b/examplesite/configuration.sh deleted file mode 100644 index bcbffc0..0000000 --- a/examplesite/configuration.sh +++ /dev/null @@ -1,23 +0,0 @@ -# Configuration file for the encoder scripts - -all_radios=("radio1" "radio2" "radio3") -all_mot=("radio1" "radio3") - -# declare radios to be an associative array, DO NOT REMOVE -declare -A radios -declare -A mot - -# for each radio, write here the full encoder command. -# encode-jack needs: -# URL ID dabmux-URL [amplitude correction] - -# radio1 -radios[radio1]="./encode-libvlc.sh http://radio1.aac Radio1 tcp://localhost:9001 toolame -b 128 -s 48 -m j -y 2 -L -W dls/radio1.txt -p 6 -P dls/radio1.dls" -mot[radio]="./encode-mot.sh Radio1 --pad 6 --remove-dls --dls dls/radio1.txt --output dls/radio1.dls" - -# radio2 -radios[radio2]="./encode-libvlc.sh http://radio2.aac Radio2 tcp://localhost:9002 toolame -b 128 -s 48 -m j -y 2 -L" - -# radio3 -radios[radio3]="./encode-libvlc.sh http://radio3.aac Radio3 tcp://localhost:9003 toolame -b 128 -s 48 -m j -y 2 -L -W dls/radio3.txt -p 6 -P dls/radio3.dls" -mot[radio3]="./encode-mot.sh Radio3 --pad 6 --remove-dls --dls dls/radio3.txt --output dls/radio3.dls" diff --git a/examplesite/dls/radio1-default.dls b/examplesite/dls/radio1-default.dls deleted file mode 100644 index b79382b..0000000 --- a/examplesite/dls/radio1-default.dls +++ /dev/null @@ -1 +0,0 @@ -Radio1 - The Best Example DLS Text Ever diff --git a/examplesite/filtertaps.txt b/examplesite/filtertaps.txt deleted file mode 100644 index cd0b28d..0000000 --- a/examplesite/filtertaps.txt +++ /dev/null @@ -1,46 +0,0 @@ -45 --0.00110450468492 -0.00120703084394 --0.000840645749122 --0.000187368263141 -0.00184351124335 --0.00355578539893 -0.00419321097434 --0.00254214904271 --0.00183473504148 -0.00781436730176 --0.0125957569107 -0.0126200336963 --0.00537294941023 --0.00866683479398 -0.0249746385962 --0.0356550291181 -0.0319730602205 --0.00795613788068 --0.0363943465054 -0.0938014090061 --0.151176810265 -0.193567320704 -0.791776955128 -0.193567320704 --0.151176810265 -0.0938014090061 --0.0363943465054 --0.00795613788068 -0.0319730602205 --0.0356550291181 -0.0249746385962 --0.00866683479398 --0.00537294941023 -0.0126200336963 --0.0125957569107 -0.00781436730176 --0.00183473504148 --0.00254214904271 -0.00419321097434 --0.00355578539893 -0.00184351124335 --0.000187368263141 --0.000840645749122 -0.00120703084394 --0.00110450468492 diff --git a/examplesite/mail-warning.txt b/examplesite/mail-warning.txt deleted file mode 100644 index e69de29..0000000 --- a/examplesite/mail-warning.txt +++ /dev/null diff --git a/examplesite/mod.ini b/examplesite/mod.ini deleted file mode 100644 index 4d20ebc..0000000 --- a/examplesite/mod.ini +++ /dev/null @@ -1,46 +0,0 @@ -[remotecontrol] -telnet=1 -telnetport=2121 - -[log] -syslog=0 -filelog=1 -filename=/dev/stderr - -[input] -transport=file -source=/dev/stdin -loop=0 - -[modulator] -gainmode=2 -mode=1 -dac_clk_rate=0 -digital_gain=0.5 -rate=2048000 - -[firfilter] -enabled=0 -filtertapsfile=site/filtertaps.txt - -[output] -output=uhd - -[fileoutput] -filename=/dev/null - -[uhdoutput] -device= -type=b200 -master_clock_rate=32768000 -channel=10D -txgain=50 -refclk_source=internal -pps_source=none -behaviour_refclk_lock_lost=crash - -[delaymanagement] -synchronous=0 -management=dynamic -fixedoffset=0.000 -dynamicoffsetfile=site/modulatoroffset diff --git a/examplesite/multiplex.mux b/examplesite/multiplex.mux deleted file mode 100644 index 1f1983e..0000000 --- a/examplesite/multiplex.mux +++ /dev/null @@ -1,76 +0,0 @@ -; Example configuration file for site. -; Please see ODR-DabMux repository for more details -; -general { - dabmode 1 - nbframes 0 - syslog 1 - writescca false - tist false - statsserverport 12720 -} - -remotecontrol { - telnetport 12721 -} - -ensemble { - id 0xabcd - ecc 0x01 - label "ODR-mmbTools" - shortlabel "mmbTools" - international-table 1 - local-time-offset auto -} - -services { - srv_radio1 { - label "radio1" - id 0x6543 - } - srv_radio2 { - label "radio2" - id 0x6542 - } -} - -subchannels { - sub_radio1 { - type dabplus - inputfile "tcp://*:9000" - zmq-buffer 80 - zmq-prebuffering 40 - bitrate 80 - id 1 - protection 3 - } - sub_radio2 { - type dabplus - inputfile "tcp://*:9001" - zmq-buffer 80 - zmq-prebuffering 40 - bitrate 80 - id 2 - protection 3 - } -} - -components { - comp_radio1 { - label "radio1" - shortlabel "radio1" - service srv_radio1 - subchannel sub_radio1 - } - comp_radio2 { - label "radio2" - shortlabel "radio2" - service srv_radio2 - subchannel sub_radio2 - } -} - -outputs { - stdout "fifo:///dev/stdout?type=raw" -} - diff --git a/icy-info.py b/icy-info.py deleted file mode 100755 index 14ed558..0000000 --- a/icy-info.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/python2 -# -# This script parses the mplayer standard output and -# extracts ICY info for the mot-encoder. -# -# Usage: -# mplayer <blablabla> | icy-info.py file.dls file-with-default.dls -# -# the file-with-default.dls contains DLS text to be sent when there -# is no ICY info - -import re -import select -import sys -import time - -re_icy = re.compile(r"""ICY Info: StreamTitle='([^']*)'.*""") - -if len(sys.argv) < 3: - print("Please specify dls output file, and file containing default text") - sys.exit(1) - -dls_file = sys.argv[1] - -default_textfile = sys.argv[2] - -def new_dlstext(text): - if text.strip() == "": - try: - fd = open(default_textfile, "r") - text = fd.read().strip() - fd.close() - except Exception as e: - print("Could not read default text from {}: {}".format(default_textfile, e)) - - print("New Text: {}".format(text)) - - fd = open(dls_file, "w") - fd.write(text) - fd.close() - -wait_timeout = 5 -nodls_timeout = 0 - - -while True: - # readline is blocking, therefore we cannot send a default text - # after some timeout - new_data = sys.stdin.readline() - if not new_data: - break - - match = re_icy.match(new_data) - - if match: - artist_title = match.groups()[0] - new_dlstext(artist_title) - else: - print("{}".format(new_data.strip())) - -if False: - # The select call creates a one ICY delay, and it's not clear why... - while True: - rfds, wfds, efds = select.select( [sys.stdin], [], [], wait_timeout) - - if rfds: - # new data available on stdin - print("SELECT !") - new_data = sys.stdin.readline() - print("DATA ! {}".format(new_data)) - - if not new_data: - break - - match = re_icy.match(new_data) - - if match: - artist_title = match.groups()[0] - new_dlstext(artist_title) - else: - print("{}".format(new_data.strip())) - - else: - # timeout reading stdin - nodls_timeout += 1 - - if nodls_timeout == 100: - new_dlstext("") - nodls_timeout = 0 - - time.sleep(.1) - - diff --git a/kill-all-encoders.sh b/kill-all-encoders.sh deleted file mode 100755 index 38a6f34..0000000 --- a/kill-all-encoders.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -# kill all processes - -pkill -INT "radio.sh" -pkill -INT "mot.sh" diff --git a/launch-all-encoders.sh b/launch-all-encoders.sh deleted file mode 100755 index d9da530..0000000 --- a/launch-all-encoders.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -# launch each encoder in its own screen window - -set -e - -if [ -f site/configuration.sh ] -then - - source site/configuration.sh - - for radio in ${all_radios[*]} - do - echo "Launching $radio encoder" - screen -t "Audio Encoder $radio" ./radio.sh "$radio" - sleep 0.4 - done - - for mot in ${all_mot[*]} - do - echo "Launching $mot mot-encoder" - screen -t "MOT Encoder $mot" ./mot.sh "$mot" - sleep 0.4 - done -else - echo "Error: No site configuration available!" - exit 1 -fi - @@ -1,51 +0,0 @@ -#!/bin/bash -# -# Start the mot-encoder for the radio - -set -e - -source site/configuration.sh - -printerr() { - echo -e "\033[01;31m$1\033[0m" -} - -printmsg() { - echo -e "\033[01;32m$1\033[0m" -} - -script_pid=0 -sigint_trap() { - printerr "Got Ctrl-C, killing radio encoder script" - if [[ "$script_pid" != "0" ]] ; then - kill $script_pid - script_pid=0 - wait - fi -} - -set -e - -# check number of arguments -if [[ "$#" -lt 1 ]] ; then - echo "Usage $0 radio-id" - echo "You must specify which radio to start" - exit 1 -fi - -RADIO=$1 - -if [ "${mot[$RADIO]+_}" ] ; then - COMMAND=${mot[$RADIO]} - - trap sigint_trap SIGINT - - # execute script - $COMMAND & - script_pid=$! - wait -else - echo "Radio $RADIO not defined in configuration" - exit 1 -fi - diff --git a/radio.sh b/radio.sh deleted file mode 100755 index 31a5ac1..0000000 --- a/radio.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -# -# Start the encoder for the radio - -set -e - -source site/configuration.sh - -printerr() { - echo -e "\033[01;31m$1\033[0m" -} - -printmsg() { - echo -e "\033[01;32m$1\033[0m" -} - -script_pid=0 -sigint_trap() { - printerr "Got Ctrl-C" - if [[ "$script_pid" != "0" ]] ; then - printmsg "killing radio encoder script $script_pid" - kill -INT $script_pid - script_pid=0 - wait - fi -} - -set -e - -# check number of arguments -if [[ "$#" -lt 1 ]] ; then - echo "Usage $0 radio-id" - echo "You must specify which radio to start" - exit 1 -fi - -RADIO=$1 - -if [ "${radios[$RADIO]+_}" ] ; then - COMMAND=${radios[$RADIO]} - - trap sigint_trap SIGINT - - # execute script - $COMMAND & - script_pid=$! - wait -else - echo "Radio $RADIO not defined in configuration" - exit 1 -fi - diff --git a/start-mux-mod.sh b/start-mux-mod.sh deleted file mode 100755 index 96e05c2..0000000 --- a/start-mux-mod.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# -# Launch the multiplexer and the modulator - -if [[ -e site/multiplex.mux && -e site/mod.ini && -e site/mail-warning.txt ]] -then - - while true - do - odr-dabmux -e site/multiplex.mux | sudo odr-dabmod -C site/mod.ini - R=$? - - MAILTO=$(cat site/mail-warning.txt) - - if [[ "$MAILTO" != "" ]] ; then - NOW=$(date) - mail -s "MUX and MOD restart" "$MAILTO" << EOF -The mux and mod were restarted at -$NOW - -The return code was $R - -EOF - - fi - - sleep 15 - done -else - echo "Incomplete site configuration !" - echo "Check that the site/ folder exists" - exit 1 -fi - |