summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorrern2022-07-03 15:59:30 +0700
committerrern2022-07-03 15:59:30 +0700
commit5436a4a83fa51cb0c6e610ad4814f7c9cceaf92b (patch)
treef4c46b2095f023685a912c689d78f35fbdf14ef7
parent9411f0a38819a8367fece5323bf64613980c7aa3 (diff)
downloadaur-5436a4a83fa51cb0c6e610ad4814f7c9cceaf92b.tar.gz
Initial
-rwxr-xr-xdab-skeleton.sh60
-rwxr-xr-xdablogo-thumb.jpgbin0 -> 3904 bytes
-rwxr-xr-xdablogo.jpgbin0 -> 28242 bytes
-rwxr-xr-xdabstart.sh24
-rwxr-xr-xrtsp-simple-server.yml162
5 files changed, 246 insertions, 0 deletions
diff --git a/dab-skeleton.sh b/dab-skeleton.sh
new file mode 100755
index 000000000000..7a5da8aab18b
--- /dev/null
+++ b/dab-skeleton.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+BASE_YML="/srv/http/bash/dab/rtsp-simple-server.yml"
+NEW_YML="/etc/rtsp-simple-server/rtsp-simple-server.yml"
+MYNAME=$(hostname -f)
+
+#Create DAB subdir if not existing
+if [ ! -d /srv/http/data/webradios/DAB ];
+ then
+ mkdir /srv/http/data/webradios/DAB
+fi
+
+#this is needed to consider the lowercase accented chars outside of "alnum"
+LC_CTYPE=C
+
+trim() {
+ local var="$*"
+ var="${var%"${var##*[![:space:]]}"}"
+ printf '%s' "$var"
+}
+
+cp $BASE_YML $NEW_YML
+rm -f /srv/http/data/webradios/DAB/rtsp\:\|\|$MYNAME\:8554*
+rm -f /srv/http/data/webradiosimg/rtsp\:\|\|$MYNAME\:8554*
+
+readarray -t services < $( dab-scanner-rtlsdr )
+for service in "${services[@]}"; do
+ if grep -q "^audioservice" <<< $service; then
+ readarray -d ';' -t field <<< $service
+ service_name=$(trim "${field[1]}")
+ service_chan=$(trim "${field[2]}")
+ service_id=$(trim "${field[3]}")
+ legal_nameU=${service_name//[^[:alnum:]]/_}
+#rtsp simple server does not like all uppercase service names neither all numbers names
+ legal_name=${legal_nameU,,}
+ if [ "$legal_name" -eq "$legal_name" ] 2>/dev/null; then
+ legal_name=R${legal_name}
+ fi
+ #echo "$service_name" legale $legal_name su canale "$service_chan"
+ #add services to rtsp daemon config file
+# "runOnDemand: dab-rtlsdr-3 -P \""$service_name"\" -C "$service_chan'|ffmpeg -re -ar 48000 -ac 2 -f s16le -i - -vn -c:a mp3 -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH'
+# runOnDemand: dab-rtlsdr-3 -P "$service_name" -C $service_chan|ffmpeg -re -ar 48000 -ac 2 -f s16le -i - -vn -c:a aac -b:a 160k -f rtsp rtsp://localhost:\$RTSP_PORT/\$RTSP_PATH
+
+cat <<EOT >>$NEW_YML
+ $legal_name:
+ runOnDemand: /srv/http/bash/dab/dabstart.sh $service_id $service_chan \$RTSP_PORT \$RTSP_PATH
+ runOnDemandRestart: yes
+ runOnDemandStartTimeout: 15s
+ runOnDemandCloseAfter: 3s
+EOT
+echo "$service_name" >/srv/http/data/webradios/DAB/rtsp\:\|\|${MYNAME}\:8554\|$legal_name
+ln -s /srv/http/data/webradiosimg/dablogo.jpg /srv/http/data/webradiosimg/rtsp\:\|\|$MYNAME\:8554\|${legal_name}.jpg
+ln -s /srv/http/data/webradiosimg/dablogo-thumb.jpg /srv/http/data/webradiosimg/rtsp\:\|\|$MYNAME\:8554\|${legal_name}-thumb.jpg
+
+echo fatto per $legal_name
+ fi
+done
+#updates webradios count
+chown -R http:http /srv/http/data/webradios*
+count=$( find -L /srv/http/data/webradios -type f | wc -l )
+sed -i 's/\("webradio": \).*/\1'$count'/' /srv/http/data/mpd/counts
diff --git a/dablogo-thumb.jpg b/dablogo-thumb.jpg
new file mode 100755
index 000000000000..492ce1f1f5c6
--- /dev/null
+++ b/dablogo-thumb.jpg
Binary files differ
diff --git a/dablogo.jpg b/dablogo.jpg
new file mode 100755
index 000000000000..5d8a81fb572b
--- /dev/null
+++ b/dablogo.jpg
Binary files differ
diff --git a/dabstart.sh b/dabstart.sh
new file mode 100755
index 000000000000..17c3a0d74050
--- /dev/null
+++ b/dabstart.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+trap killsubs SIGINT
+
+MYPIPE=$(mktemp -u)
+mkfifo $MYPIPE
+
+killsubs() {
+ echo killing $DABPID and $FFMPID
+ kill $DABPID
+ kill $FFMPID
+ rm $MYPIPE
+ cp /srv/http/data/webradiosimg/dablogo.jpg /srv/http/data/shm/webradio/DABslide.jpg
+ echo NO INFO >/srv/http/data/shm/webradio/DABlabel.txt
+}
+
+# check if another radio is playing, in case give time to the rtsp server to stop it
+if pidof -q dab-rtlsdr-3 ;then sleep 4;fi
+dab-rtlsdr-3 -S $1 -C $2 -i /srv/http/data/shm/webradio > $MYPIPE &
+DABPID=$!
+ffmpeg -re -stream_loop -1 -ar 48000 -ac 2 -f s16le -i $MYPIPE -vn -c:a aac -b:a 160k -metadata title="Dab radio" -f rtsp rtsp://localhost:$3/$4 >/dev/null 2>&1 &
+#ffmpeg -re -stream_loop -1 -ar 48000 -ac 2 -f s16le -i $MYPIPE -vn -c:a mp3 -f rtsp rtsp://localhost:$3/$4 >/dev/null 2>&1 &
+FFMPID=$!
+echo starting DAB for service $1 with PID $DABPID and ffmpeg with PID $FFMPID to file $MYPIPE
+wait $FFMPID
diff --git a/rtsp-simple-server.yml b/rtsp-simple-server.yml
new file mode 100755
index 000000000000..51cbb976215a
--- /dev/null
+++ b/rtsp-simple-server.yml
@@ -0,0 +1,162 @@
+
+###############################################
+# General parameters
+
+# Sets the verbosity of the program; available values are "error", "warn", "info", "debug".
+logLevel: info
+# Destinations of log messages; available values are "stdout", "file" and "syslog".
+logDestinations: [stdout]
+# If "file" is in logDestinations, this is the file which will receive the logs.
+logFile: rtsp-simple-server.log
+
+# Timeout of read operations.
+readTimeout: 10s
+# Timeout of write operations.
+writeTimeout: 10s
+# Number of read buffers.
+# A higher number allows a wider throughput, a lower number allows to save RAM.
+readBufferCount: 512
+
+# HTTP URL to perform external authentication.
+# Every time a user wants to authenticate, the server calls this URL
+# with the POST method and a body containing:
+# {
+# "ip": "ip",
+# "user": "user",
+# "password": "password",
+# "path": "path",
+# "action": "read|publish"
+# "query": "url's raw query"
+# }
+# If the response code is 20x, authentication is accepted, otherwise
+# it is discarded.
+externalAuthenticationURL:
+
+# Enable the HTTP API.
+api: yes
+# Address of the API listener.
+apiAddress: 127.0.0.1:9997
+
+# Enable Prometheus-compatible metrics.
+metrics: no
+# Address of the metrics listener.
+metricsAddress: 127.0.0.1:9998
+
+# Enable pprof-compatible endpoint to monitor performances.
+pprof: no
+# Address of the pprof listener.
+pprofAddress: 127.0.0.1:9999
+
+# Command to run when a client connects to the server.
+# This is terminated with SIGINT when a client disconnects from the server.
+# The following environment variables are available:
+# * RTSP_PORT: server port
+runOnConnect:
+# Restart the command if it exits suddenly.
+runOnConnectRestart: no
+
+###############################################
+# RTSP parameters
+
+# Disable support for the RTSP protocol.
+rtspDisable: no
+# List of enabled RTSP transport protocols.
+# UDP is the most performant, but doesn't work when there's a NAT/firewall between
+# server and clients, and doesn't support encryption.
+# UDP-multicast allows to save bandwidth when clients are all in the same LAN.
+# TCP is the most versatile, and does support encryption.
+# The handshake is always performed with TCP.
+protocols: [udp, multicast, tcp]
+# Encrypt handshake and TCP streams with TLS (RTSPS).
+# Available values are "no", "strict", "optional".
+encryption: "no"
+# Address of the TCP/RTSP listener. This is needed only when encryption is "no" or "optional".
+rtspAddress: :8554
+# Address of the TCP/TLS/RTSPS listener. This is needed only when encryption is "strict" or "optional".
+rtspsAddress: :8322
+# Address of the UDP/RTP listener. This is needed only when "udp" is in protocols.
+rtpAddress: :8000
+# Address of the UDP/RTCP listener. This is needed only when "udp" is in protocols.
+rtcpAddress: :8001
+# IP range of all UDP-multicast listeners. This is needed only when "multicast" is in protocols.
+multicastIPRange: 224.1.0.0/16
+# Port of all UDP-multicast/RTP listeners. This is needed only when "multicast" is in protocols.
+multicastRTPPort: 8002
+# Port of all UDP-multicast/RTCP listeners. This is needed only when "multicast" is in protocols.
+multicastRTCPPort: 8003
+# Path to the server key. This is needed only when encryption is "strict" or "optional".
+# This can be generated with:
+# openssl genrsa -out server.key 2048
+# openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650
+serverKey: server.key
+# Path to the server certificate. This is needed only when encryption is "strict" or "optional".
+serverCert: server.crt
+# Authentication methods.
+authMethods: [basic, digest]
+
+###############################################
+# RTMP parameters
+
+# Disable support for the RTMP protocol.
+rtmpDisable: no
+# Address of the RTMP listener.
+rtmpAddress: :1935
+
+###############################################
+# HLS parameters
+
+# Disable support for the HLS protocol.
+hlsDisable: no
+# Address of the HLS listener.
+hlsAddress: :8888
+# By default, HLS is generated only when requested by a user.
+# This option allows to generate it always, avoiding the delay between request and generation.
+hlsAlwaysRemux: no
+# Variant of the HLS protocol to use. Available options are:
+# * mpegts - uses MPEG-TS segments, for maximum compatibility.
+# * fmp4 - uses fragmented MP4 segments, more efficient.
+# * lowLatency - uses Low-Latency HLS.
+hlsVariant: mpegts
+# Number of HLS segments to keep on the server.
+# Segments allow to seek through the stream.
+# Their number doesn't influence latency.
+hlsSegmentCount: 7
+# Minimum duration of each segment.
+# A player usually puts 3 segments in a buffer before reproducing the stream.
+# The final segment duration is also influenced by the interval between IDR frames,
+# since the server changes the duration in order to include at least one IDR frame
+# in each segment.
+hlsSegmentDuration: 1s
+# Minimum duration of each part.
+# A player usually puts 3 parts in a buffer before reproducing the stream.
+# Parts are used in Low-Latency HLS in place of segments.
+# Part duration is influenced by the distance between video/audio samples
+# and is adjusted in order to produce segments with a similar duration.
+hlsPartDuration: 200ms
+# Maximum size of each segment.
+# This prevents RAM exhaustion.
+hlsSegmentMaxSize: 50M
+# Value of the Access-Control-Allow-Origin header provided in every HTTP response.
+# This allows to play the HLS stream from an external website.
+hlsAllowOrigin: '*'
+# Enable TLS/HTTPS on the HLS server.
+# This is required for Low-Latency HLS.
+hlsEncryption: no
+# Path to the server key. This is needed only when encryption is yes.
+# This can be generated with:
+# openssl genrsa -out server.key 2048
+# openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650
+hlsServerKey: server.key
+# Path to the server certificate.
+hlsServerCert: server.crt
+
+###############################################
+# Path parameters
+
+# These settings are path-dependent, and the map key is the name of the path.
+# It's possible to use regular expressions by using a tilde as prefix.
+# For example, "~^(test1|test2)$" will match both "test1" and "test2".
+# For example, "~^prefix" will match all paths that start with "prefix".
+# The settings under the path "all" are applied to all paths that do not match
+# another entry.
+paths: