2011-01-17 16:30:45 +01:00
|
|
|
%include "library/pervasives.liq"
|
2011-03-30 02:44:04 +02:00
|
|
|
%include "/etc/airtime/liquidsoap.cfg"
|
2011-01-17 16:30:45 +01:00
|
|
|
|
2011-01-17 19:14:59 +01:00
|
|
|
set("log.file.path", log_file)
|
|
|
|
set("log.stdout", true)
|
2011-01-17 16:30:45 +01:00
|
|
|
set("server.telnet", true)
|
2011-03-10 22:41:41 +01:00
|
|
|
set("server.telnet.port", 1234)
|
2011-01-17 16:30:45 +01:00
|
|
|
|
2011-12-24 16:59:09 +01:00
|
|
|
time = ref string_of(gettimeofday())
|
2011-11-30 02:15:38 +01:00
|
|
|
|
2012-03-08 23:42:38 +01:00
|
|
|
queue = audio_to_stereo(id="queue_src", request.queue(id="queue", length=0.5))
|
2011-06-16 00:23:12 +02:00
|
|
|
queue = cue_cut(queue)
|
2011-01-17 16:30:45 +01:00
|
|
|
|
|
|
|
pypo_data = ref '0'
|
2011-03-01 05:51:42 +01:00
|
|
|
web_stream_enabled = ref false
|
2011-03-04 02:13:55 +01:00
|
|
|
stream_metadata_type = ref 0
|
|
|
|
station_name = ref ''
|
|
|
|
show_name = ref ''
|
2011-01-17 16:30:45 +01:00
|
|
|
|
2011-12-24 16:59:09 +01:00
|
|
|
s1_connected = ref ''
|
|
|
|
s2_connected = ref ''
|
|
|
|
s3_connected = ref ''
|
|
|
|
s1_namespace = ref ''
|
|
|
|
s2_namespace = ref ''
|
|
|
|
s3_namespace = ref ''
|
|
|
|
|
2011-03-07 20:04:47 +01:00
|
|
|
%include "ls_lib.liq"
|
2011-01-17 16:30:45 +01:00
|
|
|
|
2012-03-08 23:42:38 +01:00
|
|
|
queue = on_metadata(notify, queue)
|
|
|
|
queue = map_metadata(append_title, queue)
|
|
|
|
ignore(output.dummy(queue, fallible=true))
|
|
|
|
|
2011-03-04 02:13:55 +01:00
|
|
|
server.register(namespace="vars", "pypo_data", fun (s) -> begin pypo_data := s "Done" end)
|
|
|
|
server.register(namespace="vars", "web_stream_enabled", fun (s) -> begin web_stream_enabled := (s == "true") string_of(!web_stream_enabled) end)
|
|
|
|
server.register(namespace="vars", "stream_metadata_type", fun (s) -> begin stream_metadata_type := int_of_string(s) s end)
|
|
|
|
server.register(namespace="vars", "show_name", fun (s) -> begin show_name := s s end)
|
|
|
|
server.register(namespace="vars", "station_name", fun (s) -> begin station_name := s s end)
|
2011-12-24 16:59:09 +01:00
|
|
|
server.register(namespace="vars", "bootup_time", fun (s) -> begin time := s s end)
|
|
|
|
server.register(namespace="streams", "connection_status", fun (s) -> begin "1:#{!s1_connected},2:#{!s2_connected},3:#{!s3_connected}" end)
|
2011-01-26 23:08:30 +01:00
|
|
|
|
2011-01-17 16:30:45 +01:00
|
|
|
|
2012-03-08 23:42:38 +01:00
|
|
|
default = amplify(id="silence_src", 0.00001, noise())
|
2011-02-18 01:46:43 +01:00
|
|
|
default = rewrite_metadata([("artist","Airtime"), ("title", "offline")],default)
|
2012-03-08 23:42:38 +01:00
|
|
|
ignore(output.dummy(default, fallible=true))
|
2011-02-18 01:46:43 +01:00
|
|
|
|
2012-03-05 23:04:13 +01:00
|
|
|
master_dj_enabled = ref false;
|
|
|
|
live_dj_enabled = ref false;
|
|
|
|
|
|
|
|
def make_master_dj_available()
|
|
|
|
master_dj_enabled := true
|
|
|
|
end
|
|
|
|
|
|
|
|
def make_master_dj_unavailable()
|
|
|
|
master_dj_enabled := false
|
|
|
|
end
|
|
|
|
|
|
|
|
def make_live_dj_available()
|
|
|
|
live_dj_enabled := true
|
|
|
|
end
|
|
|
|
|
|
|
|
def make_live_dj_unavailable()
|
|
|
|
live_dj_enabled := false
|
|
|
|
end
|
|
|
|
|
2012-02-06 23:51:02 +01:00
|
|
|
#live stream setup
|
|
|
|
set("harbor.bind_addr", "0.0.0.0")
|
2012-03-02 22:55:11 +01:00
|
|
|
|
2012-03-12 20:23:06 +01:00
|
|
|
def update_source_status(sourcename, status) =
|
|
|
|
system("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --source-name=#{sourcename} --source-status=#{status}")
|
|
|
|
log("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --source-name=#{sourcename} --source-status=#{status}")
|
|
|
|
end
|
|
|
|
|
|
|
|
def live_dj_connect() =
|
|
|
|
update_source_status("live_dj", true)
|
|
|
|
end
|
|
|
|
|
|
|
|
def live_dj_disconnect() =
|
|
|
|
update_source_status("live_dj", false)
|
|
|
|
end
|
|
|
|
|
|
|
|
def master_dj_connect() =
|
|
|
|
update_source_status("master_dj", true)
|
|
|
|
end
|
|
|
|
|
|
|
|
def master_dj_disconnect() =
|
|
|
|
update_source_status("master_dj", false)
|
|
|
|
end
|
|
|
|
|
2012-02-06 23:51:02 +01:00
|
|
|
#auth function for live stream
|
2012-03-02 22:55:11 +01:00
|
|
|
def check_master_dj_client(user,password) =
|
2012-02-21 23:58:05 +01:00
|
|
|
#get the output of the php script
|
2012-03-02 22:55:11 +01:00
|
|
|
ret = get_process_lines("python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_auth.py --master #{user} #{password}")
|
2012-02-21 23:58:05 +01:00
|
|
|
#ret has now the value of the live client (dj1,dj2, or djx), or "ERROR"/"unknown" ...
|
|
|
|
ret = list.hd(ret)
|
|
|
|
#return true to let the client transmit data, or false to tell harbor to decline
|
|
|
|
if (ret == "True") then
|
2012-03-12 20:23:06 +01:00
|
|
|
master_dj_connect()
|
2012-02-21 23:58:05 +01:00
|
|
|
true
|
|
|
|
else
|
|
|
|
false
|
|
|
|
end
|
2012-02-06 23:51:02 +01:00
|
|
|
end
|
|
|
|
|
2012-03-02 22:55:11 +01:00
|
|
|
def check_dj_client(user,password) =
|
|
|
|
#get the output of the php script
|
|
|
|
ret = get_process_lines("python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_auth.py --dj #{user} #{password}")
|
|
|
|
#ret has now the value of the live client (dj1,dj2, or djx), or "ERROR"/"unknown" ...
|
|
|
|
ret = list.hd(ret)
|
|
|
|
#return true to let the client transmit data, or false to tell harbor to decline
|
|
|
|
if (ret == "True") then
|
2012-03-12 20:23:06 +01:00
|
|
|
live_dj_connect()
|
2012-03-02 22:55:11 +01:00
|
|
|
true
|
|
|
|
else
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-03-08 23:42:38 +01:00
|
|
|
def append_dj_inputs(master_harbor_input_port, master_harbor_input_mount_point, dj_harbor_input_port, dj_harbor_input_mount_point, s) =
|
|
|
|
if master_harbor_input_port != 0 and master_harbor_input_mount_point != "" and dj_harbor_input_port != 0 and dj_harbor_input_mount_point != "" then
|
|
|
|
master_dj = input.harbor(id="master_harbor", master_harbor_input_mount_point, port=master_harbor_input_port, auth=check_master_dj_client,
|
2012-03-12 20:23:06 +01:00
|
|
|
max=40., on_disconnect=master_dj_disconnect)
|
2012-03-08 23:42:38 +01:00
|
|
|
dj_live = input.harbor(id="live_dj_harbor", dj_harbor_input_mount_point, port=dj_harbor_input_port, auth=check_dj_client,
|
2012-03-12 20:23:06 +01:00
|
|
|
max=40., on_disconnect=live_dj_disconnect)
|
2012-03-08 23:42:38 +01:00
|
|
|
ignore(output.dummy(master_dj, fallible=true))
|
|
|
|
ignore(output.dummy(dj_live, fallible=true))
|
|
|
|
switch(id="master_dj_switch", track_sensitive=false, transitions=[transition, transition, transition], [({!master_dj_enabled},master_dj), ({!live_dj_enabled},dj_live), ({true}, s)])
|
|
|
|
elsif master_harbor_input_port != 0 and master_harbor_input_mount_point != "" then
|
|
|
|
master_dj = input.harbor(id="master_harbor", master_harbor_input_mount_point, port=master_harbor_input_port, auth=check_master_dj_client,
|
2012-03-12 20:23:06 +01:00
|
|
|
max=40., on_disconnect=master_dj_disconnect)
|
2012-03-08 23:42:38 +01:00
|
|
|
ignore(output.dummy(master_dj, fallible=true))
|
|
|
|
switch(id="master_dj_switch", track_sensitive=false, transitions=[transition, transition], [({!master_dj_enabled},master_dj), ({true}, s)])
|
|
|
|
elsif dj_harbor_input_port != 0 and dj_harbor_input_mount_point != "" then
|
|
|
|
dj_live = input.harbor(id="live_dj_harbor", dj_harbor_input_mount_point, port=dj_harbor_input_port, auth=check_dj_client,
|
2012-03-12 20:23:06 +01:00
|
|
|
max=40., on_disconnect=live_dj_disconnect)
|
2012-03-05 19:51:59 +01:00
|
|
|
ignore(output.dummy(dj_live, fallible=true))
|
2012-03-08 23:42:38 +01:00
|
|
|
switch(id="live_dj_switch", track_sensitive=false, transitions=[transition, transition], [({!live_dj_enabled},dj_live), ({true}, s)])
|
2012-02-23 17:51:20 +01:00
|
|
|
else
|
2012-03-02 22:55:11 +01:00
|
|
|
s
|
2012-02-23 17:51:20 +01:00
|
|
|
end
|
|
|
|
end
|
2011-02-18 01:46:43 +01:00
|
|
|
|
2012-03-08 23:42:38 +01:00
|
|
|
s = fallback(id="default_fallback", track_sensitive=false, [queue, default])
|
|
|
|
s = append_dj_inputs(master_live_stream_port, master_live_stream_mp, dj_live_stream_port, dj_live_stream_mp, s)
|
2012-03-02 22:55:11 +01:00
|
|
|
|
2011-02-18 01:46:43 +01:00
|
|
|
s = crossfade(s)
|
2012-03-12 20:23:06 +01:00
|
|
|
|
2011-02-24 21:16:27 +01:00
|
|
|
# Attach a skip command to the source s:
|
|
|
|
|
2011-03-10 22:41:41 +01:00
|
|
|
#web_stream_source = input.http(id="web_stream", autostart = false, buffer=0.5, max=20., "")
|
2011-03-02 22:43:46 +01:00
|
|
|
|
|
|
|
#once the stream is started, give it a sink so that liquidsoap doesn't
|
|
|
|
#create buffer overflow warnings in the log file.
|
2011-03-10 22:41:41 +01:00
|
|
|
#output.dummy(fallible=true, web_stream_source)
|
2011-03-01 05:51:42 +01:00
|
|
|
|
2011-03-10 22:41:41 +01:00
|
|
|
#s = switch(track_sensitive = false,
|
|
|
|
# transitions=[to_live,to_live],
|
|
|
|
# [
|
|
|
|
# ({ !web_stream_enabled }, web_stream_source),
|
|
|
|
# ({ true }, s)
|
|
|
|
# ]
|
|
|
|
#)
|
2011-02-24 21:16:27 +01:00
|
|
|
|
2011-03-10 22:41:41 +01:00
|
|
|
add_skip_command(s)
|
2011-03-04 02:13:55 +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 make_master_dj_unavailable() "Done." end)
|
|
|
|
server.register(namespace="streams",
|
|
|
|
description="Start Master DJ source.",
|
|
|
|
usage="master_dj_start",
|
|
|
|
"master_dj_start",
|
|
|
|
fun (s) -> begin make_master_dj_available() "Done." end)
|
|
|
|
server.register(namespace="streams",
|
|
|
|
description="Stop Live DJ source.",
|
|
|
|
usage="live_dj_stop",
|
|
|
|
"live_dj_stop",
|
|
|
|
fun (s) -> begin make_live_dj_unavailable() "Done." end)
|
|
|
|
server.register(namespace="streams",
|
|
|
|
description="Start Live DJ source.",
|
|
|
|
usage="live_dj_start",
|
|
|
|
"live_dj_start",
|
|
|
|
fun (s) -> begin make_live_dj_available() "Done." end)
|
|
|
|
|
2011-02-18 01:46:43 +01:00
|
|
|
if output_sound_device then
|
2011-12-02 19:36:59 +01:00
|
|
|
|
|
|
|
success = ref false
|
|
|
|
|
|
|
|
log(output_sound_device_type)
|
|
|
|
|
|
|
|
%ifdef output.alsa
|
2011-12-01 01:01:40 +01:00
|
|
|
if output_sound_device_type == "ALSA" then
|
2011-12-02 19:36:59 +01:00
|
|
|
ignore(output.alsa(s))
|
|
|
|
success := true
|
2011-12-01 01:01:40 +01:00
|
|
|
end
|
|
|
|
%endif
|
2011-12-02 19:36:59 +01:00
|
|
|
|
2011-12-01 01:01:40 +01:00
|
|
|
%ifdef output.ao
|
|
|
|
if output_sound_device_type == "AO" then
|
2011-12-02 19:36:59 +01:00
|
|
|
ignore(output.ao(s))
|
|
|
|
success := true
|
2011-12-01 01:01:40 +01:00
|
|
|
end
|
|
|
|
%endif
|
2011-12-02 19:36:59 +01:00
|
|
|
|
2011-12-01 01:01:40 +01:00
|
|
|
%ifdef output.oss
|
|
|
|
if output_sound_device_type == "OSS" then
|
2011-12-02 19:36:59 +01:00
|
|
|
ignore(output.oss(s))
|
|
|
|
success := true
|
2011-12-01 01:01:40 +01:00
|
|
|
end
|
|
|
|
%endif
|
2011-12-02 19:36:59 +01:00
|
|
|
|
2011-12-01 01:01:40 +01:00
|
|
|
%ifdef output.portaudio
|
|
|
|
if output_sound_device_type == "Portaudio" then
|
2011-12-02 19:36:59 +01:00
|
|
|
ignore(output.portaudio(s))
|
|
|
|
success := true
|
2011-12-01 01:01:40 +01:00
|
|
|
end
|
|
|
|
%endif
|
2011-12-02 19:36:59 +01:00
|
|
|
|
2011-12-01 01:01:40 +01:00
|
|
|
%ifdef output.pulseaudio
|
|
|
|
if output_sound_device_type == "Pulseaudio" then
|
2011-12-02 19:36:59 +01:00
|
|
|
ignore(output.pulseaudio(s))
|
|
|
|
success := true
|
2011-12-01 01:01:40 +01:00
|
|
|
end
|
|
|
|
%endif
|
2011-12-02 19:36:59 +01:00
|
|
|
|
|
|
|
if (!success == false) then
|
|
|
|
ignore(output.prefered(s))
|
|
|
|
end
|
|
|
|
|
2011-02-18 01:46:43 +01:00
|
|
|
end
|
2011-01-17 19:14:59 +01:00
|
|
|
|
2011-11-29 22:25:30 +01:00
|
|
|
if s1_enable == true then
|
2011-12-24 16:59:09 +01:00
|
|
|
if s1_output == 'shoutcast' then
|
|
|
|
s1_namespace := "shoutcast_stream_1"
|
|
|
|
else
|
|
|
|
s1_namespace := s1_mount
|
|
|
|
end
|
|
|
|
server.register(namespace=!s1_namespace, "connected", fun (s) -> begin !s1_connected end)
|
|
|
|
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_connected)
|
2011-02-18 01:46:43 +01:00
|
|
|
end
|
2011-01-26 23:08:30 +01:00
|
|
|
|
2011-11-29 22:25:30 +01:00
|
|
|
if s2_enable == true then
|
2011-12-24 16:59:09 +01:00
|
|
|
if s2_output == 'shoutcast' then
|
|
|
|
s2_namespace := "shoutcast_stream_2"
|
|
|
|
else
|
|
|
|
s2_namespace := s2_mount
|
|
|
|
end
|
|
|
|
server.register(namespace=!s2_namespace, "connected", fun (s) -> begin !s2_connected end)
|
|
|
|
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_connected)
|
2011-10-11 02:14:27 +02:00
|
|
|
|
2011-06-20 23:34:16 +02:00
|
|
|
end
|
2011-05-25 19:58:50 +02:00
|
|
|
|
2011-11-29 22:25:30 +01:00
|
|
|
if s3_enable == true then
|
2011-12-24 16:59:09 +01:00
|
|
|
if s3_output == 'shoutcast' then
|
|
|
|
s3_namespace := "shoutcast_stream_3"
|
|
|
|
else
|
|
|
|
s3_namespace := s3_mount
|
|
|
|
end
|
|
|
|
server.register(namespace=!s3_namespace, "connected", fun (s) -> begin !s3_connected end)
|
|
|
|
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_connected)
|
2011-02-18 01:46:43 +01:00
|
|
|
end
|
2011-06-20 23:34:16 +02:00
|
|
|
|
2011-09-28 19:53:11 +02:00
|
|
|
ignore(output.dummy(blank()))
|