-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(streamer): backport autofallback from transcoder
- Loading branch information
Showing
5 changed files
with
105 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,27 @@ | ||
streamer_name = "mystreamer" | ||
streamer_name = "mystreamersurround" | ||
|
||
# Radio settings | ||
formats_picker = fun (formats) -> formats.flac.surround | ||
harbor_http_port = 7030 | ||
prometheus_server_port = 9031 | ||
liquidsoap_log_level = 3 | ||
livesource_state_path = "/state/#{streamer_name}.livesourcestate" | ||
|
||
# Inputs configuration | ||
input_playlist_file = "/audio/lib/#{streamer_name}.m3u" | ||
input_list = | ||
[ | ||
{ | ||
name="localPlaylist", | ||
kind="playlist", | ||
playlist_file="/audio/lib/#{streamer_name}.m3u", | ||
is_autofallback=true | ||
} | ||
] | ||
|
||
# SRT output configuration | ||
srt_host = "liquidsoap-myradiosurround" | ||
|
||
# voieA_caller1 | ||
srt_port = 10010 | ||
output_list = | ||
[ | ||
{ | ||
name="transcoder1", | ||
kind="srtcaller", | ||
output_host="liquidsoap-myradiosurround", | ||
output_port=10010, | ||
output_preset=fun (presets) -> presets.flac.surround | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
#!/usr/bin/liquidsoap | ||
|
||
%include "10-settings.liq" | ||
%include "20-prometheus.liq" | ||
|
||
%include "inputs/playlist.liq" | ||
# We define the default preferred_live_source (for the switch "live" defined | ||
# later on) as being the first input in the input_list. We need to do that here, | ||
# so we can define update_source_metrics callback in 20-prometheus.liq | ||
preferred_live_source = ref(list.nth(input_list, 0).name) | ||
|
||
%include "20-prometheus.liq" | ||
%include "50-inputs.liq" | ||
%include "80-outputs.liq" | ||
%include "90-http.liq" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Inputs | ||
|
||
input_sources = [] | ||
|
||
%include "inputs/playlist.liq" | ||
|
||
def is_playing(n) = | ||
fun () -> n == preferred_live_source() | ||
end | ||
|
||
def mk_switch_source(s) = | ||
(is_playing(s.name), s.source) | ||
end | ||
|
||
def mk_fallback_source(result, s) = | ||
if | ||
s.is_autofallback | ||
then | ||
[...result, (s.source : source(audio=pcm))] | ||
else | ||
result | ||
end | ||
end | ||
|
||
# get the livesourcestate on disk if it exist | ||
if | ||
file.exists(livesource_state_path) | ||
then | ||
content = file.contents(livesource_state_path) | ||
|
||
# check that the livesource exist in input list | ||
if | ||
list.exists(fun (s) -> s.name == content, input_sources) | ||
then | ||
preferred_live_source := content | ||
end | ||
end | ||
|
||
real_live_source = ref("") | ||
|
||
live = | ||
switch( | ||
id="switch_live", | ||
track_sensitive=false, | ||
list.map(mk_switch_source, input_sources) | ||
) | ||
|
||
radio = | ||
fallback( | ||
id="fallback_prod", | ||
track_sensitive=false, | ||
[ | ||
(live : source(audio=pcm)), | ||
...list.fold(mk_fallback_source, [], input_sources) | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
# Build the playlist | ||
radio = playlist(input_playlist_file) | ||
radio = mksafe(id="playlist", radio) | ||
radio = crossfade(fade_out=3., fade_in=3., duration=5., radio) | ||
# Build inputs of kind playlist | ||
|
||
def mk_playlist_source(s) = | ||
let {name, playlist_file} = s | ||
radio = playlist(playlist_file) | ||
radio = mksafe(id="#{name}", radio) | ||
radio = crossfade(fade_out=3., fade_in=3., duration=5., radio) | ||
radio | ||
end | ||
|
||
input_list_playlists = list.filter(fun (i) -> i.kind == "playlist", input_list) | ||
|
||
list.append(input_sources, list.map(mk_playlist_source, input_list_playlists)) |