2023-02-22 15:49:14 +01:00
|
|
|
boot_timestamp = string_of(gettimeofday())
|
2011-01-17 16:30:45 +01:00
|
|
|
|
2023-02-20 17:53:37 +01:00
|
|
|
web_stream_enabled = ref false
|
|
|
|
web_stream_id = ref '-1'
|
2012-07-17 22:00:13 +02:00
|
|
|
|
2023-02-20 22:01:24 +01:00
|
|
|
show_name = interactive.string("show_name", "")
|
2011-01-17 16:30:45 +01:00
|
|
|
|
2020-12-24 23:18:15 +01:00
|
|
|
dynamic_metadata_callback = ref fun (~new_track=false, s) -> begin () end
|
2013-06-12 18:43:27 +02:00
|
|
|
|
2012-04-13 19:25:40 +02:00
|
|
|
just_switched = ref false
|
2011-12-24 16:59:09 +01:00
|
|
|
|
2011-03-07 20:04:47 +01:00
|
|
|
%include "ls_lib.liq"
|
2011-01-17 16:30:45 +01:00
|
|
|
|
2013-03-14 21:50:55 +01:00
|
|
|
sources = ref []
|
|
|
|
source_id = ref 0
|
|
|
|
|
|
|
|
def create_source()
|
2023-02-25 14:36:49 +01:00
|
|
|
this_source_id = !source_id
|
|
|
|
|
|
|
|
l = request.equeue(id="s#{this_source_id}", length=0.5)
|
2013-05-23 00:07:12 +02:00
|
|
|
|
|
|
|
l = audio_to_stereo(id="queue_src", l)
|
2013-07-10 16:35:24 +02:00
|
|
|
l = cue_cut(l)
|
2013-05-23 00:07:12 +02:00
|
|
|
l = amplify(1., override="replay_gain", l)
|
|
|
|
|
2023-03-02 20:20:09 +01:00
|
|
|
# Fade the tracks to avoid hard cuts in between two tracks and at the end of the shows.
|
|
|
|
# Liquidsoap reads the fade in/out durations from the annotation "liq_fade_in/out" which
|
|
|
|
# value can be set via Libretime settings.
|
|
|
|
l = fade.in(l)
|
|
|
|
l = fade.out(l)
|
2013-05-23 00:07:12 +02:00
|
|
|
|
2013-06-12 18:43:27 +02:00
|
|
|
l = on_metadata(notify_queue, l)
|
2013-06-26 07:25:26 +02:00
|
|
|
|
2013-03-15 17:50:23 +01:00
|
|
|
sources := list.append([l], !sources)
|
|
|
|
server.register(namespace="queues",
|
2023-02-25 14:36:49 +01:00
|
|
|
"s#{this_source_id}_skip",
|
|
|
|
fun (s) -> begin log("queues.s#{this_source_id}_skip")
|
2020-12-24 23:18:15 +01:00
|
|
|
clear_queue(l)
|
|
|
|
"Done"
|
2013-03-15 17:50:23 +01:00
|
|
|
end)
|
2013-03-14 21:50:55 +01:00
|
|
|
source_id := !source_id + 1
|
|
|
|
end
|
|
|
|
|
|
|
|
create_source()
|
|
|
|
create_source()
|
|
|
|
create_source()
|
|
|
|
create_source()
|
|
|
|
|
2013-05-11 05:19:54 +02:00
|
|
|
queue = add(!sources, normalize=false)
|
2013-06-12 20:04:52 +02:00
|
|
|
pair = insert_metadata(queue)
|
2013-06-12 22:04:57 +02:00
|
|
|
dynamic_metadata_callback := fst(pair)
|
2013-06-12 20:04:52 +02:00
|
|
|
queue = snd(pair)
|
2013-03-14 21:50:55 +01:00
|
|
|
|
2012-09-18 21:23:26 +02:00
|
|
|
output.dummy(fallible=true, queue)
|
2012-03-08 23:42:38 +01:00
|
|
|
|
2012-12-03 17:06:56 +01:00
|
|
|
http = input.http_restart(id="http")
|
|
|
|
http = cross_http(http_input_id="http",http)
|
2013-01-10 16:29:57 +01:00
|
|
|
output.dummy(fallible=true, http)
|
|
|
|
stream_queue = http_fallback(http_input_id="http", http=http, default=queue)
|
2023-02-24 15:07:23 +01:00
|
|
|
stream_queue = map_metadata(id="map_metadata:schedule", update=false, append_title, stream_queue)
|
2012-08-17 05:50:32 +02:00
|
|
|
|
|
|
|
ignore(output.dummy(stream_queue, fallible=true))
|
2012-07-17 22:00:13 +02:00
|
|
|
|
2023-02-25 14:24:14 +01:00
|
|
|
def web_stream_set_id(value)
|
|
|
|
web_stream_id := value
|
|
|
|
string_of(!web_stream_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def web_stream_get_id()
|
|
|
|
string_of(!web_stream_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
server.register(namespace="sources",
|
|
|
|
description="Start webstream source",
|
|
|
|
"start_web_stream",
|
|
|
|
fun (s) -> begin log("sources.start_web_stream")
|
2023-02-20 17:53:37 +01:00
|
|
|
notify([("schedule_table_id", !web_stream_id)])
|
|
|
|
web_stream_enabled := true "enabled" end)
|
2023-02-25 14:24:14 +01:00
|
|
|
server.register(namespace="sources",
|
|
|
|
description="Stop webstream source",
|
|
|
|
"stop_web_stream",
|
|
|
|
fun (s) -> begin log("sources.stop_web_stream") web_stream_enabled := false "disabled" end)
|
2012-08-15 22:43:01 +02:00
|
|
|
|
2023-02-22 15:47:05 +01:00
|
|
|
server.register(namespace="web_stream",
|
2023-02-25 14:24:14 +01:00
|
|
|
description="Set the web stream id",
|
|
|
|
"set_id",
|
|
|
|
fun (s) -> begin log("web_stream.set_id") web_stream_set_id(s) end)
|
2012-10-19 22:29:31 +02:00
|
|
|
|
2023-02-22 15:47:05 +01:00
|
|
|
server.register(namespace="web_stream",
|
2023-02-25 14:24:14 +01:00
|
|
|
description="Get the web stream id",
|
2012-10-19 22:29:31 +02:00
|
|
|
"get_id",
|
2023-02-25 14:24:14 +01:00
|
|
|
fun (s) -> begin log("web_stream.get_id") web_stream_get_id() end)
|
2012-10-19 22:29:31 +02:00
|
|
|
|
2012-03-08 23:42:38 +01:00
|
|
|
default = amplify(id="silence_src", 0.00001, noise())
|
2023-02-20 22:01:24 +01:00
|
|
|
|
|
|
|
def map_message_offline(m) =
|
|
|
|
[("title", message_offline())]
|
2020-12-24 23:18:15 +01:00
|
|
|
end
|
2023-02-20 22:01:24 +01:00
|
|
|
|
2023-02-24 15:07:23 +01:00
|
|
|
default = map_metadata(id="map_metadata:offline", map_message_offline, default)
|
2012-03-08 23:42:38 +01:00
|
|
|
ignore(output.dummy(default, fallible=true))
|
2011-02-18 01:46:43 +01:00
|
|
|
|
2023-02-22 15:11:20 +01:00
|
|
|
input_main_streaming = ref false
|
|
|
|
input_show_streaming = ref false
|
|
|
|
schedule_streaming = ref false
|
2012-03-05 23:04:13 +01:00
|
|
|
|
2023-02-22 17:03:12 +01:00
|
|
|
def start_input_main() input_main_streaming := true end
|
|
|
|
def stop_input_main() input_main_streaming := false end
|
|
|
|
def start_input_show() input_show_streaming := true end
|
|
|
|
def stop_input_show() input_show_streaming := false end
|
|
|
|
def start_schedule() schedule_streaming := true; just_switched := true end
|
|
|
|
def stop_schedule() schedule_streaming := false end
|
2012-03-13 19:34:48 +01:00
|
|
|
|
2012-03-12 20:23:06 +01:00
|
|
|
def update_source_status(sourcename, status) =
|
2022-01-17 10:51:32 +01:00
|
|
|
gateway("live '#{sourcename}' '#{status}'")
|
2012-03-12 20:23:06 +01:00
|
|
|
end
|
|
|
|
|
2023-02-22 17:19:07 +01:00
|
|
|
def input_main_on_connect(header) update_source_status("master_dj", true) end
|
|
|
|
def input_main_on_disconnect() update_source_status("master_dj", false) end
|
|
|
|
def input_show_on_connect(header) update_source_status("live_dj", true) end
|
|
|
|
def input_show_on_disconnect() update_source_status("live_dj", false) end
|
2012-03-12 20:23:06 +01:00
|
|
|
|
2023-03-30 20:39:02 +02:00
|
|
|
def make_input_func(secure)
|
|
|
|
if secure then
|
|
|
|
input.harbor.ssl
|
|
|
|
else
|
|
|
|
input.harbor
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-03-01 16:35:08 +01:00
|
|
|
def make_input_auth_handler(input_name)
|
|
|
|
def auth_handler(user, password)
|
|
|
|
log("user '#{user}' connected", label="#{input_name}_input")
|
|
|
|
|
|
|
|
# Check auth based on return value from auth script
|
2023-03-21 14:50:44 +01:00
|
|
|
ret = test_process("libretime-playout-notify live-auth '#{input_name}' '#{user}' '#{password}'")
|
2023-03-01 16:35:08 +01:00
|
|
|
if ret then
|
|
|
|
log("user '#{user}' authenticated", label="#{input_name}_input")
|
|
|
|
else
|
|
|
|
log("user '#{user}' auth failed", label="#{input_name}_input",level=2)
|
|
|
|
end
|
|
|
|
|
|
|
|
ret
|
2023-02-22 17:25:59 +01:00
|
|
|
end
|
|
|
|
auth_handler
|
2012-03-02 22:55:11 +01:00
|
|
|
end
|
|
|
|
|
2023-02-24 15:07:23 +01:00
|
|
|
s = switch(id="switch:blank+schedule",
|
2013-03-01 18:48:32 +01:00
|
|
|
track_sensitive=false,
|
|
|
|
transitions=[transition_default, transition],
|
2023-02-22 15:11:20 +01:00
|
|
|
[({!schedule_streaming}, stream_queue), ({true}, default)]
|
2013-03-01 18:48:32 +01:00
|
|
|
)
|
|
|
|
|
2023-02-22 15:21:39 +01:00
|
|
|
s = if input_show_port != 0 and input_show_mount != "" then
|
2023-03-30 20:39:02 +02:00
|
|
|
input_show_func = make_input_func(input_show_secure)
|
2023-02-22 17:21:15 +01:00
|
|
|
input_show_source =
|
2013-03-01 18:48:32 +01:00
|
|
|
audio_to_stereo(
|
2023-03-30 20:39:02 +02:00
|
|
|
input_show_func(id="harbor:input_show",
|
2023-02-22 15:21:39 +01:00
|
|
|
input_show_mount,
|
|
|
|
port=input_show_port,
|
2023-03-01 16:35:08 +01:00
|
|
|
auth=make_input_auth_handler("show"),
|
2013-03-01 18:48:32 +01:00
|
|
|
max=40.,
|
2023-02-22 17:19:07 +01:00
|
|
|
on_connect=input_show_on_connect,
|
|
|
|
on_disconnect=input_show_on_disconnect))
|
2013-03-01 18:48:32 +01:00
|
|
|
|
2023-02-22 17:21:15 +01:00
|
|
|
ignore(output.dummy(input_show_source, fallible=true))
|
2013-03-01 18:48:32 +01:00
|
|
|
|
2023-02-24 15:07:23 +01:00
|
|
|
switch(id="switch:blank+schedule+show",
|
2013-03-01 18:48:32 +01:00
|
|
|
track_sensitive=false,
|
|
|
|
transitions=[transition, transition],
|
2023-02-22 17:21:15 +01:00
|
|
|
[({!input_show_streaming}, input_show_source), ({true}, s)]
|
2013-03-01 18:48:32 +01:00
|
|
|
)
|
|
|
|
else
|
|
|
|
s
|
2012-02-23 17:51:20 +01:00
|
|
|
end
|
2011-02-18 01:46:43 +01:00
|
|
|
|
2023-02-22 15:21:39 +01:00
|
|
|
s = if input_main_port != 0 and input_main_mount != "" then
|
2023-03-30 20:39:02 +02:00
|
|
|
input_main_func = make_input_func(input_main_secure)
|
2023-02-22 17:21:15 +01:00
|
|
|
input_main_source =
|
2013-05-13 23:52:43 +02:00
|
|
|
audio_to_stereo(
|
2023-03-30 20:39:02 +02:00
|
|
|
input_main_func(id="harbor:input_main",
|
2023-02-22 15:21:39 +01:00
|
|
|
input_main_mount,
|
|
|
|
port=input_main_port,
|
2023-03-01 16:35:08 +01:00
|
|
|
auth=make_input_auth_handler("main"),
|
2013-05-13 23:52:43 +02:00
|
|
|
max=40.,
|
2023-02-22 17:19:07 +01:00
|
|
|
on_connect=input_main_on_connect,
|
|
|
|
on_disconnect=input_main_on_disconnect))
|
2013-03-01 18:48:32 +01:00
|
|
|
|
2023-02-22 17:21:15 +01:00
|
|
|
ignore(output.dummy(input_main_source, fallible=true))
|
2013-03-01 18:48:32 +01:00
|
|
|
|
2023-02-24 15:07:23 +01:00
|
|
|
switch(id="switch:blank+schedule+show+main",
|
2013-03-01 18:48:32 +01:00
|
|
|
track_sensitive=false,
|
|
|
|
transitions=[transition, transition],
|
2023-02-22 17:21:15 +01:00
|
|
|
[({!input_main_streaming}, input_main_source), ({true}, s)]
|
2013-03-01 18:48:32 +01:00
|
|
|
)
|
|
|
|
else
|
|
|
|
s
|
|
|
|
end
|
2012-12-03 17:06:56 +01:00
|
|
|
|
2023-02-22 17:03:12 +01:00
|
|
|
server.register(namespace="sources",
|
|
|
|
description="Stop main input source.",
|
|
|
|
usage="stop_input_main",
|
|
|
|
"stop_input_main",
|
|
|
|
fun (s) -> begin log("sources.stop_input_main") stop_input_main() "Done." end)
|
|
|
|
server.register(namespace="sources",
|
|
|
|
description="Start main input source.",
|
|
|
|
usage="start_input_main",
|
|
|
|
"start_input_main",
|
|
|
|
fun (s) -> begin log("sources.start_input_main") start_input_main() "Done." end)
|
|
|
|
server.register(namespace="sources",
|
|
|
|
description="Stop show input source.",
|
|
|
|
usage="stop_input_show",
|
|
|
|
"stop_input_show",
|
|
|
|
fun (s) -> begin log("sources.stop_input_show") stop_input_show() "Done." end)
|
|
|
|
server.register(namespace="sources",
|
|
|
|
description="Start show input source.",
|
|
|
|
usage="start_input_show",
|
|
|
|
"start_input_show",
|
|
|
|
fun (s) -> begin log("sources.start_input_show") start_input_show() "Done." end)
|
|
|
|
server.register(namespace="sources",
|
|
|
|
description="Stop schedule source.",
|
|
|
|
usage="stop_schedule",
|
|
|
|
"stop_schedule",
|
|
|
|
fun (s) -> begin log("sources.stop_schedule") stop_schedule() "Done." end)
|
|
|
|
server.register(namespace="sources",
|
|
|
|
description="Start schedule source.",
|
|
|
|
usage="start_schedule",
|
|
|
|
"start_schedule",
|
|
|
|
fun (s) -> begin log("sources.start_schedule") start_schedule() "Done." end)
|