Skip to content
Snippets Groups Projects
Verified Commit dd48d6d3 authored by Ole Binder's avatar Ole Binder
Browse files

Chore: add and improve tests

parent 877a283b
No related branches found
No related tags found
1 merge request!17Yaml configuration file
#!/usr/bin/env liquidsoap
#
# Aura Engine (https://gitlab.servus.at/aura/engine)
#
# Copyright (C) 2017-now() - The Aura Engine Team.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
%include "base_config.liq"
settings.log.level.set(3)
##################################################################################################
# Setup sources
settings.server.telnet.set(true)
settings.server.telnet.bind_addr.set("0.0.0.0")
settings.server.telnet.port.set(1234)
# Create fallback playlist
fallback_folder =
......@@ -30,42 +10,10 @@ fallback_folder = mksafe(fallback_folder)
# Create mixer with one queue
in_queue = request.queue(id="in_queue")
input_queue_0 =
amplify(id="in_queue_amplify", 1., override="replay_gain", in_queue)
mixer = mix(id="mixer", [input_queue_0.{id="in_queue_mixer"}])
input_queue_0 = amplify(id="in_queue", 1., override="replay_gain", in_queue)
mixer = mix(id="mixer", [input_queue_0.{id="in_queue"}])
stripped_mixer = blank.strip(max_blank=5., mixer)
# Output
main_out = fallback(track_sensitive=false, [stripped_mixer, fallback_folder])
output.jack(id="pcm.aura_engine", mksafe(main_out))
##################################################################################################
# Test case (Liquidsoap 2.1, DEB or Docker version)
# 1. Add requests
r1 = request.create("assets/audio.mp3")
r2 = request.create("assets/audio.mp3")
r3 = request.create("assets/audio.mp3")
in_queue.push(r1)
in_queue.push(r2)
in_queue.push(r3)
# 2. Fallback is playing
print(
"Fallback playing"
)
# 3. Wait 5 seconds and activate queue via server commands
def show_mixer() =
print(
"Show mixer.inputs"
)
r = server.execute("mixer.inputs")
print(r)
print(
"Show all functions::"
)
r = server.execute("help")
print(r)
end
thread.run(delay=5., {show_mixer()})
%include "base_config.liq"
# 1.) Metadata handler to be called when track starts
def on_metadata_notification(meta) =
print(
"TITLE: #{meta['title']}"
)
print(
"ON AIR: #{meta['on_air']}"
)
end
# 2.) Invalid source to test fallback
empty_source =
blank.strip(
id="invalid_source",
track_sensitive=false,
max_blank=15.,
min_noise=0.,
threshold=-80.,
blank()
)
# 3.) Fallback
fallback_source =
playlist(
id="fallback_folder",
"/var/audio/fallback",
mode="randomize",
reload=300,
reload_mode="seconds"
)
fallback_source =
source.on_track(
id="fallback_folder", fallback_source, on_metadata_notification
)
fallback_source = mksafe(fallback_source)
current_show_id = ref("-1")
def reopen_on_new_show(meta) =
print(
"reopen recording..."
)
print(meta)
if
current_show_id() == meta["show_id"]
then
print(
"same show, do nothing"
)
false
else
current_show_id := meta["show_id"]
print(
"new show, reopen.."
)
true
end
end
def reopen_on_track(metadata) =
print(
"reopen on track"
)
print(metadata)
end
# 4.) Mix and output
main_source =
fallback(
id="fallback-source",
track_sensitive=false,
replay_metadata=true,
[empty_source, fallback_source]
)
recording =
output.file(
id="recorder_test",
fallible=true,
%mp3,
reopen_on_metadata=reopen_on_new_show,
'/var/audio/recording/show/test_%H%M%S.mp3',
main_source
)
output.jack(id="lineout", main_source)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment