sintonia/playout/libretime_playout/liquidsoap/1.4/ls_script.liq

338 lines
9.5 KiB
Plaintext
Raw Normal View History

boot_timestamp = interactive.string("boot_timestamp", string_of(gettimeofday()))
2011-01-17 16:30:45 +01:00
web_stream_enabled = ref false
web_stream_id = ref '-1'
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
just_switched = ref false
2011-03-07 20:04:47 +01:00
%include "ls_lib.liq"
2011-01-17 16:30:45 +01:00
sources = ref []
source_id = ref 0
def create_source()
l = request.equeue(id="s#{!source_id}", length=0.5)
l = audio_to_stereo(id="queue_src", l)
l = cue_cut(l)
l = amplify(1., override="replay_gain", l)
# the crossfade function controls fade in/out
2020-12-24 23:18:15 +01:00
l = crossfade(duration=0., smart=true, l)
l = on_metadata(notify_queue, l)
sources := list.append([l], !sources)
server.register(namespace="queues",
"s#{!source_id}_skip",
2020-12-24 23:18:15 +01:00
fun (s) -> begin log("queues.s#{!source_id}_skip")
clear_queue(l)
"Done"
end)
source_id := !source_id + 1
end
create_source()
create_source()
create_source()
create_source()
create_source()
create_source()
create_source()
create_source()
queue = add(!sources, normalize=false)
pair = insert_metadata(queue)
dynamic_metadata_callback := fst(pair)
queue = snd(pair)
output.dummy(fallible=true, queue)
2012-12-03 17:06:56 +01:00
http = input.http_restart(id="http")
http = cross_http(http_input_id="http",http)
output.dummy(fallible=true, http)
stream_queue = http_fallback(http_input_id="http", http=http, default=queue)
stream_queue = map_metadata(update=false, append_title, stream_queue)
ignore(output.dummy(stream_queue, fallible=true))
server.register(namespace="web_stream",
description="Enable webstream output",
usage='start',
"output_start",
fun (s) -> begin log("web_stream.output_start")
notify([("schedule_table_id", !web_stream_id)])
web_stream_enabled := true "enabled" end)
server.register(namespace="web_stream",
description="Enable webstream output",
usage='stop',
"output_stop",
fun (s) -> begin log("web_stream.output_stop") web_stream_enabled := false "disabled" end)
server.register(namespace="web_stream",
description="Set the streams cc_schedule row id",
usage="id <id>",
"id",
fun (s) -> begin log("web_stream.id") set_web_stream_id(s) end)
server.register(namespace="web_stream",
description="Get the streams cc_schedule row id",
usage="get_id",
"get_id",
fun (s) -> begin log("web_stream.get_id") get_web_stream_id() end)
default = amplify(id="silence_src", 0.00001, noise())
def map_message_offline(m) =
[("title", message_offline())]
2020-12-24 23:18:15 +01:00
end
default = map_metadata(map_message_offline, default)
ignore(output.dummy(default, fallible=true))
input_main_streaming = ref false
input_show_streaming = ref false
schedule_streaming = ref false
2012-03-05 23:04:13 +01:00
def make_master_dj_available()
input_main_streaming := true
2012-03-05 23:04:13 +01:00
end
def make_master_dj_unavailable()
input_main_streaming := false
2012-03-05 23:04:13 +01:00
end
def make_live_dj_available()
input_show_streaming := true
2012-03-05 23:04:13 +01:00
end
def make_live_dj_unavailable()
input_show_streaming := false
2012-03-05 23:04:13 +01:00
end
def make_scheduled_play_available()
schedule_streaming := true
just_switched := true
end
def make_scheduled_play_unavailable()
schedule_streaming := false
end
def update_source_status(sourcename, status) =
gateway("live '#{sourcename}' '#{status}'")
end
def live_dj_connect(header) =
update_source_status("live_dj", true)
end
2012-09-18 23:22:14 +02:00
def live_dj_disconnect() =
update_source_status("live_dj", false)
end
def master_dj_connect(header) =
update_source_status("master_dj", true)
end
2012-09-18 23:22:14 +02:00
def master_dj_disconnect() =
update_source_status("master_dj", false)
end
# Auth function for live stream
# @Category LiveStream
# @param user Username to check against LibreTime API
# @param password Password to check against LibreTime API
# @param ~type Type of password to check, "dj" or "master, default: "master"
def check_auth(user="", password="", ~type="master") =
log("#{type} user #{user} connected",label="#{type}_source")
2012-09-18 23:22:14 +02:00
# Check auth based on return value from auth script
2020-12-24 23:18:15 +01:00
ret = test_process("python3 #{auth_path} --#{type} #{user} #{password}")
if ret then
log("#{type} user #{user} authenticated",label="#{type}_source")
else
log("#{type} user #{user} auth failed",label="#{type}_source",level=2)
end
ret
end
# Check master source auth
# @Category LiveStream
# @param user Username to check against LibreTime API
# @param password Password to check against LibreTime API
def check_master_dj_client(user, password) =
check_auth(user, password)
end
# Check dj/show source auth
# @Category LiveStream
# @param user Username to check against LibreTime API
# @param password Password to check against LibreTime API
def check_dj_client(user, password) =
check_auth(user, password, type="dj")
end
2013-03-01 18:48:32 +01:00
s = switch(id="schedule_noise_switch",
track_sensitive=false,
transitions=[transition_default, transition],
[({!schedule_streaming}, stream_queue), ({true}, default)]
2013-03-01 18:48:32 +01:00
)
s = if input_show_port != 0 and input_show_mount != "" then
dj_live =
2013-03-01 18:48:32 +01:00
audio_to_stereo(
input.harbor(id="live_dj_harbor",
input_show_mount,
port=input_show_port,
2013-03-01 18:48:32 +01:00
auth=check_dj_client,
max=40.,
on_connect=live_dj_connect,
on_disconnect=live_dj_disconnect))
2013-03-01 18:48:32 +01:00
ignore(output.dummy(dj_live, fallible=true))
switch(id="show_schedule_noise_switch",
track_sensitive=false,
transitions=[transition, transition],
[({!input_show_streaming}, dj_live), ({true}, s)]
2013-03-01 18:48:32 +01:00
)
else
s
end
s = if input_main_port != 0 and input_main_mount != "" then
master_dj =
audio_to_stereo(
input.harbor(id="master_harbor",
input_main_mount,
port=input_main_port,
auth=check_master_dj_client,
max=40.,
on_connect=master_dj_connect,
on_disconnect=master_dj_disconnect))
2013-03-01 18:48:32 +01:00
ignore(output.dummy(master_dj, fallible=true))
switch(id="master_show_schedule_noise_switch",
track_sensitive=false,
transitions=[transition, transition],
[({!input_main_streaming}, master_dj), ({true}, s)]
2013-03-01 18:48:32 +01:00
)
else
s
end
2012-12-03 17:06:56 +01:00
2012-03-05 23:04:13 +01:00
server.register(namespace="streams",
description="Stop Master DJ source.",
usage="master_dj_stop",
"master_dj_stop",
fun (s) -> begin log("streams.master_dj_stop") make_master_dj_unavailable() "Done." end)
2012-03-05 23:04:13 +01:00
server.register(namespace="streams",
description="Start Master DJ source.",
usage="master_dj_start",
"master_dj_start",
fun (s) -> begin log("streams.master_dj_start") make_master_dj_available() "Done." end)
2012-03-05 23:04:13 +01:00
server.register(namespace="streams",
description="Stop Live DJ source.",
usage="live_dj_stop",
"live_dj_stop",
fun (s) -> begin log("streams.live_dj_stop") make_live_dj_unavailable() "Done." end)
2012-03-05 23:04:13 +01:00
server.register(namespace="streams",
description="Start Live DJ source.",
usage="live_dj_start",
"live_dj_start",
fun (s) -> begin log("streams.live_dj_start") make_live_dj_available() "Done." end)
server.register(namespace="streams",
description="Stop Scheduled Play source.",
usage="scheduled_play_stop",
"scheduled_play_stop",
fun (s) -> begin log("streams.scheduled_play_stop") make_scheduled_play_unavailable() "Done." end)
server.register(namespace="streams",
description="Start Scheduled Play source.",
usage="scheduled_play_start",
"scheduled_play_start",
fun (s) -> begin log("streams.scheduled_play_start") make_scheduled_play_available() "Done." end)
2012-03-05 23:04:13 +01:00
if output_sound_device then
success = ref false
2012-09-18 23:22:14 +02:00
log(output_sound_device_type)
2012-09-18 23:22:14 +02:00
%ifdef output.alsa
if output_sound_device_type == "ALSA" then
ignore(output.alsa(s))
success := true
end
%endif
2012-09-18 23:22:14 +02:00
%ifdef output.ao
if output_sound_device_type == "AO" then
ignore(output.ao(s))
success := true
end
%endif
2012-09-18 23:22:14 +02:00
%ifdef output.oss
if output_sound_device_type == "OSS" then
ignore(output.oss(s))
success := true
end
%endif
2012-09-18 23:22:14 +02:00
%ifdef output.portaudio
if output_sound_device_type == "Portaudio" then
ignore(output.portaudio(s))
success := true
end
%endif
2012-09-18 23:22:14 +02:00
%ifdef output.pulseaudio
if output_sound_device_type == "Pulseaudio" then
ignore(output.pulseaudio(s))
success := true
end
%endif
2012-09-18 23:22:14 +02:00
if (!success == false) then
ignore(output.prefered(s))
end
2012-09-18 23:22:14 +02:00
end
2011-01-17 19:14:59 +01:00
if s1_enable == true then
2012-09-18 23:22:14 +02:00
output_to(s1_output, s1_type, s1_bitrate, s1_host, s1_port, s1_pass,
s1_mount, s1_url, s1_description, s1_genre, s1_user, s, "1",
s1_name, s1_channels)
end
if s2_enable == true then
2012-09-18 23:22:14 +02:00
output_to(s2_output, s2_type, s2_bitrate, s2_host, s2_port, s2_pass,
s2_mount, s2_url, s2_description, s2_genre, s2_user, s, "2",
s2_name, s2_channels)
2012-09-18 23:22:14 +02:00
end
if s3_enable == true then
2012-09-18 23:22:14 +02:00
output_to(s3_output, s3_type, s3_bitrate, s3_host, s3_port, s3_pass,
s3_mount, s3_url, s3_description, s3_genre, s3_user, s, "3",
s3_name, s3_channels)
end
2015-03-03 22:08:53 +01:00
if s4_enable == true then
log("Stream 4 Enabled")
2015-03-03 22:08:53 +01:00
output_to(s4_output, s4_type, s4_bitrate, s4_host, s4_port, s4_pass,
s4_mount, s4_url, s4_name, s4_genre, s4_user, s, "4",
s4_description, s4_channels)
2015-03-03 22:08:53 +01:00
end
2015-03-03 22:08:53 +01:00
gateway("started")