Skip to content

Commit

Permalink
Merge pull request #5 from radiofrance/surround-conf
Browse files Browse the repository at this point in the history
Add surround conf.
  • Loading branch information
uZer authored Nov 2, 2023
2 parents aa040b3 + d7ae2fa commit 4be6f0a
Show file tree
Hide file tree
Showing 19 changed files with 303 additions and 112 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
example/audio/*
.*.sw*
.res/.$*
43 changes: 28 additions & 15 deletions .res/info.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
Useful URLs and exposed services with default configuration.

# Liquidsoap container (liquidsoap-myradio)
http://127.0.0.1:6001/metrics # Liquidsoap Prometheus Metrics
http://127.0.0.1:7000/livesource # Liquidsoap HTTP API
srt://127.0.0.1:10000 # Liquidsoap SRT input port voieA_caller1
srt://127.0.0.1:10001 # Liquidsoap SRT input port voieA_caller2
srt://127.0.0.1:10002 # Liquidsoap SRT input port voieB_caller1
srt://127.0.0.1:10003 # Liquidsoap SRT input port voieB_caller2
srt://127.0.0.1:10004 # Liquidsoap SRT input port override_caller1
srt://127.0.0.1:10005 # Liquidsoap SRT input port override_caller2
srt://127.0.0.1:10006 # Liquidsoap SRT input port sat_sat1
http://127.0.0.1:6001/metrics # Liquidsoap (myradio) Prometheus Metrics
http://127.0.0.1:7000/livesource # Liquidsoap (myradio) HTTP API
srt://127.0.0.1:10000 # Liquidsoap (myradio) SRT input port voieA_caller1
srt://127.0.0.1:10001 # Liquidsoap (myradio) SRT input port voieA_caller2
srt://127.0.0.1:10002 # Liquidsoap (myradio) SRT input port voieB_caller1
srt://127.0.0.1:10003 # Liquidsoap (myradio) SRT input port voieB_caller2
srt://127.0.0.1:10004 # Liquidsoap (myradio) SRT input port override_caller1
srt://127.0.0.1:10005 # Liquidsoap (myradio) SRT input port override_caller2
srt://127.0.0.1:10006 # Liquidsoap (myradio) SRT input port sat_sat1

# Liquidsoap container (liquidsoap-myradiosurround)
http://127.0.0.1:6011/metrics # Liquidsoap (myradiosurround) Prometheus Metrics
http://127.0.0.1:7010/livesource # Liquidsoap (myradiosurround) HTTP API
srt://127.0.0.1:10010 # Liquidsoap (myradiosurround) SRT input port voieA_caller1
srt://127.0.0.1:10011 # Liquidsoap (myradiosurround) SRT input port voieA_caller2
srt://127.0.0.1:10012 # Liquidsoap (myradiosurround) SRT input port voieB_caller1
srt://127.0.0.1:10013 # Liquidsoap (myradiosurround) SRT input port voieB_caller2
srt://127.0.0.1:10014 # Liquidsoap (myradiosurround) SRT input port override_caller1
srt://127.0.0.1:10015 # Liquidsoap (myradiosurround) SRT input port override_caller2
srt://127.0.0.1:10016 # Liquidsoap (myradiosurround) SRT input port sat_sat1

# Icecast2
http://127.0.0.1:8000 # Icecast status and mountpoints
http://127.0.0.1:8000/myradio-hifi.aac # Icecast mountpoint (AAC hifi)
http://127.0.0.1:8000/myradio-midfi.aac # Icecast mountpoint (AAC midfi)
http://127.0.0.1:8000/myradio-lofi.aac # Icecast mountpoint (AAC lofi)
http://127.0.0.1:8000/myradio-midfi.mp3 # Icecast mountpoint (MP3 midfi)
http://127.0.0.1:8000/myradio-lofi.mp3 # Icecast mountpoint (MP3 lofi)
http://127.0.0.1:8000 # Icecast status and mountpoints
http://127.0.0.1:8000/myradio-hifi.aac # Icecast mountpoint (AAC hifi)
http://127.0.0.1:8000/myradio-midfi.aac # Icecast mountpoint (AAC midfi)
http://127.0.0.1:8000/myradio-lofi.aac # Icecast mountpoint (AAC lofi)
http://127.0.0.1:8000/myradio-midfi.mp3 # Icecast mountpoint (MP3 midfi)
http://127.0.0.1:8000/myradio-lofi.mp3 # Icecast mountpoint (MP3 lofi)
http://127.0.0.1:8000/myradiosurround-hifi.aac # Icecast mountpoint (AAC hifi surround)

# NGINX (HLS, only AAC audio)
http://127.0.0.1:8080 # Browse HLS files
http://127.0.0.1:8080/myradio/myradio.m3u8 # HLS playlist
http://127.0.0.1:8080/myradio/myradio_hifi.m3u8 # HLS playlist (enforce hifi)
http://127.0.0.1:8080/myradio/myradio_midfi.m3u8 # HLS playlist (enforce midfi)
http://127.0.0.1:8080/myradio/myradio_lofi.m3u8 # HLS playlist (enforce lofi)
http://127.0.0.1:8080/myradiosurround/myradiosurround_hifi.m3u8 # HLS playlist (enforce lofi)

# Prometheus
http://127.0.0.1:9090 # Prometheus web interface
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test: ## Run test on the liquidsoap configuration

reload: ## Update containers if needed and restart liquidsoap
@docker compose up -d
@docker compose restart liquidsoap-test liquidsoap-myradio
@docker compose restart liquidsoap-test liquidsoap-myradio liquidsoap-myradiosurround
@docker compose ps
@docker compose logs -f

Expand Down
61 changes: 55 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
- /conf/test.liq
- /scripts/00-live.liq
container_name: liquidsoap-test
image: savonet/liquidsoap:v2.2.1
image: savonet/liquidsoap:rolling-release-v2.2.x
networks:
- default
volumes:
Expand All @@ -20,7 +20,7 @@ services:
- /conf/myradio.liq
- /scripts/00-live.liq
container_name: liquidsoap-myradio
image: savonet/liquidsoap:v2.2.1
image: savonet/liquidsoap:rolling-release-v2.2.x
networks:
- default
restart: unless-stopped
Expand All @@ -40,6 +40,31 @@ services:
- data_hls:/tmp/
- data_liquidsoap:/state/

liquidsoap-myradiosurround:
command:
- /conf/myradiosurround.liq
- /scripts/00-live.liq
container_name: liquidsoap-myradiosurround
image: savonet/liquidsoap:rolling-release-v2.2.x
networks:
- default
restart: unless-stopped
ports:
- 6011:6011/tcp
- 7010:7010/tcp
- 10010:10010/tcp
- 10011:10011/tcp
- 10012:10012/tcp
- 10013:10013/tcp
- 10014:10014/tcp
- 10015:10015/tcp
- 10016:10016/tcp
volumes:
- ./example/liquidsoap/:/conf/:ro
- ./scripts/:/scripts/:ro
- data_hls:/tmp/
- data_liquidsoap:/state/

# Feed liquidsoap with an example SRT source (https://modular-station.com/)
source-voieA-caller1:
command:
Expand All @@ -56,7 +81,7 @@ services:
- "srt://liquidsoap-myradio:10000" # voieA_caller1
container_name: source-voieA-caller1
entrypoint: []
image: savonet/liquidsoap:v2.2.1
image: savonet/liquidsoap:rolling-release-v2.2.x
networks:
- default
restart: unless-stopped
Expand All @@ -77,7 +102,7 @@ services:
- "srt://liquidsoap-myradio:10002" # voieB_caller1
container_name: source-voieB-caller1
entrypoint: []
image: savonet/liquidsoap:v2.2.1
image: savonet/liquidsoap:rolling-release-v2.2.x
networks:
- default
restart: unless-stopped
Expand All @@ -98,10 +123,33 @@ services:
- "srt://liquidsoap-myradio:10004" # override_caller1
container_name: source-override-caller1
entrypoint: []
image: savonet/liquidsoap:v2.2.1
image: savonet/liquidsoap:rolling-release-v2.2.x
networks:
- default
restart: unless-stopped

# Feed liquidsoap with an example SRT source (https://modular-station.com/)
source-surround:
command:
- /usr/bin/ffmpeg
- -hide_banner
- -re
- -i
- /audio/CHANNEL_ORDER_TEST_MUSIC_MULTI_5.1_-23LUFS.wav
- -vn
- -f
- wav
- -codec:a
- pcm_s24le
- "srt://liquidsoap-myradiosurround:10010" # voieA_caller1
container_name: source-surround
entrypoint: []
image: savonet/liquidsoap:rolling-release-v2.2.x
networks:
- default
restart: unless-stopped
volumes:
- ./example/audio/:/audio/:ro

# Streaming services: icecast
icecast:
Expand All @@ -112,9 +160,10 @@ services:
- ICECAST_PASSWORD=secret
- ICECAST_RELAY_PASSWORD=secret
- ICECAST_HOSTNAME=icecast
- ICECAST_MAX_SOURCES=10
expose:
- 8000
image: moul/icecast
image: libretime/icecast
ports:
- 8000:8000

Expand Down
35 changes: 19 additions & 16 deletions example/liquidsoap/myradio.liq
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
radio_name = "myradio"
hls_segments_http_post_origin = "hostname"

hls_state_path = "/state/#{radio_name}.hlsstate"
livesource_state_path = "/state/#{radio_name}.livesourcestate"
# Radio settings
formats_picker = fun (formats) -> formats.stereo
aac_encoder = "aac"
harbor_http_port = 7000
prometheus_server_port = 6001
liquidsoap_log_level = 3

hls_segments_directory = "/tmp/#{radio_name}"

# SRT inputs configuration
input_list = [
{name="voieA_caller1", is_autofallback=true, port=10000},
{name="voieA_caller2", is_autofallback=true, port=10001},
Expand All @@ -15,17 +18,24 @@ input_list = [
{name="override_caller2", is_autofallback=false, port=10005},
{name="sat_sat1", is_autofallback=true, port=10006},
]
livesource_state_path = "/state/#{radio_name}.livesourcestate"

aac_encoder = "aac"

# HLS output configuration
hls_segments_directory = "/tmp/#{radio_name}"
hls_segments_enable_todo_files = false
hls_state_path = "/state/#{radio_name}.hlsstate"
hls_segments_http_post_enable = false
hls_segments_http_post_origin = "hostname"
hls_segments_http_post_target = "http://segmentforwarder"
hls_formats = [
"lofi", "midfi", "hifi"
]
enable_upload_hls_segments = false
hls_segments_http_post_target = "http://segmentforwarder"

enable_hls_segments_todo_files = false

# ICECAST output configuration
icecast_host = "icecast"
icecast_port = 8000
icecast_password = "secret"
icecast_formats = [
("aac", [
"lofi", "midfi", "hifi"
Expand All @@ -34,10 +44,3 @@ icecast_formats = [
"lofi", "midfi"
])
]

prometheus_server_port = 6001
harbor_http_port = 7000
icecast_host = "icecast"
icecast_port = 8000
icecast_password = "secret"
liquidsoap_log_level = 3
41 changes: 41 additions & 0 deletions example/liquidsoap/myradiosurround.liq
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
radio_name = "myradiosurround"

# Radio settings
formats_picker = fun (formats) -> formats.surround
aac_encoder = "aac"
harbor_http_port = 7010
prometheus_server_port = 6011
liquidsoap_log_level = 3


# SRT inputs configuration
input_list = [
{name="voieA_caller1", is_autofallback=true, port=10010},
{name="voieA_caller2", is_autofallback=true, port=10011},
{name="voieB_caller1", is_autofallback=true, port=10012},
{name="voieB_caller2", is_autofallback=true, port=10013},
{name="override_caller1", is_autofallback=false, port=10014},
{name="override_caller2", is_autofallback=false, port=10015},
{name="sat_sat1", is_autofallback=true, port=10016},
]
livesource_state_path = "/state/#{radio_name}.livesourcestate"


# HLS output configuration
hls_segments_directory = "/tmp/#{radio_name}"
hls_segments_enable_todo_files = false
hls_state_path = "/state/#{radio_name}.hlsstate"
hls_segments_http_post_enable = false
hls_segments_http_post_origin = "hostname"
hls_segments_http_post_target = "http://segmentforwarder"
hls_formats = [
"hifi"
]

# ICECAST output configuration
icecast_host = "icecast"
icecast_port = 8000
icecast_password = "secret"
icecast_formats = [
("aac", ["hifi"])
]
5 changes: 4 additions & 1 deletion example/prometheus/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ scrape_configs:
- job_name: 'liquidsoap'
scrape_interval: 5s
static_configs:
- targets: ['liquidsoap-myradio:6001']
- targets: [
'liquidsoap-myradio:6001',
'liquidsoap-myradiosurround:6001',
]

- job_name: 'prometheus'
scrape_interval: 10s
Expand Down
13 changes: 1 addition & 12 deletions scripts/00-live.liq
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
%include "10-settings.liq"
%include "20-prometheus.liq"
%include "30-formats.liq"
%include "40-icecast.liq"
%include "50-hls.liq"
%include "60-core.liq"

#############################
Expand Down Expand Up @@ -155,14 +153,5 @@ thread.run(
{set_metric_audio_lufs(radio_prod.lufs())}
)

radio_prod = ffmpeg.raw.encode.audio(%ffmpeg(%audio.raw), radio_prod)

# Outputs

# HLS Output
mk_hls_output(hls_formats, radio_prod)

# Icecast Output
mk_icecast_outputs(icecast_formats, radio_prod)

%include "80-outputs.liq"
%include "90-http.liq"
28 changes: 0 additions & 28 deletions scripts/20-prometheus.liq
Original file line number Diff line number Diff line change
Expand Up @@ -95,34 +95,6 @@ audit_lufs_metric_create =
"liquidsoap_output_lufs_5s"
)

# "hlsssegment_sent" is an output-only metric counting the number of
# HLS segments sent for each status code.
# As we don't know all the status codes beforehand we use a assoc list
# (aka map or dict) named increase_hlssegment_metrics to map status
# code to time serie and create_hlsssegment_metric as a helper
# function to dynamically create the time serie if it is not already
# in the list.
# These metrics are updated at on_file_change hook of HLS output.
hlssegment_sent_create =
prometheus.counter(
labels=["radio","code"],
help="Number of HLS segment send to segment-forwarder","liquidsoap_hlssegment_sent"
)

increase_hlssegment_metrics = ref([])
def create_hlssegment_metrics(code, increment) =
increase_metric = hlssegment_sent_create(label_values=[radio_name,"#{code}"])
increase_hlssegment_metrics := list.add((code, increase_metric), increase_hlssegment_metrics())
increase_metric(increment)
end
def increase_hlssegment_sent_metric(code, increment) =
def default(increment) =
create_hlssegment_metrics(code, increment)
end
increase_metric = list.assoc(default=default, code, increase_hlssegment_metrics())
increase_metric(increment)
end

# SRT metrics per source (input queues and buffers)
# SRT sourceA (network) -> input.srt -> buffered_input ---------> radio_live
# ^ ^
Expand Down
12 changes: 10 additions & 2 deletions scripts/30-formats.liq
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
let formats = {
icecast = (),
hls = ()
surround = {
icecast = (),
hls = ()
},
stereo = {
icecast = (),
hls = ()
}
}

%include "formats/hls-aac.liq"
%include "formats/hls-libfdk-aac.liq"
%include "formats/icecast-aac.liq"
%include "formats/icecast-libfdk-aac.liq"
%include "formats/icecast-mp3.liq"

formats = formats_picker(formats)
13 changes: 13 additions & 0 deletions scripts/80-outputs.liq
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Outputs

# HLS Output
if hls_formats != [] then
%include "outputs/hls.liq"
mk_hls_output(hls_formats, radio_prod)
end

# Icecast Output
if icecast_formats != [] then
%include "outputs/icecast.liq"
mk_icecast_outputs(icecast_formats, radio_prod)
end
Loading

0 comments on commit 4be6f0a

Please sign in to comment.