CC-3367: Display in Now Playing whether Live DJ stream and Live Master stream
are connected and give user the ability to block those streams - added stream source switch interface - backend code
This commit is contained in:
parent
d4a387e113
commit
f193047a1c
19 changed files with 383 additions and 38 deletions
|
@ -15,6 +15,31 @@ def append_title(m) =
|
|||
end
|
||||
end
|
||||
|
||||
default_dj_fade_in = ref 5.
|
||||
default_dj_fade_out = ref 5.
|
||||
|
||||
def transition(a,b) =
|
||||
log("transition called...")
|
||||
add(normalize=false,
|
||||
[ sequence([ blank(duration=2.),
|
||||
fade.initial(duration=!default_dj_fade_in, b) ]),
|
||||
fade.final(duration=!default_dj_fade_out, a) ])
|
||||
end
|
||||
|
||||
def transition_to_live(a,b) =
|
||||
log("transition called...")
|
||||
#add(normalize=false,
|
||||
# [fade.initial(duration=5.,type="log", b),fade.final(duration=5.,type="log",a)])
|
||||
smooth_add(delay=10., normal=a, special=b)
|
||||
end
|
||||
|
||||
def transition_from_live(a,b) =
|
||||
log("transition called...")
|
||||
#add(normalize=false,
|
||||
# [fade.initial(duration=5.,type="log", b),fade.final(duration=5.,type="log",a)])
|
||||
smooth_add(delay=10., normal=b, special=a)
|
||||
end
|
||||
|
||||
def crossfade(s)
|
||||
#duration is automatically overwritten by metadata fields passed in
|
||||
#with audio
|
||||
|
|
|
@ -8,7 +8,7 @@ set("server.telnet.port", 1234)
|
|||
|
||||
time = ref string_of(gettimeofday())
|
||||
|
||||
queue = audio_to_stereo(request.queue(id="queue", length=0.5))
|
||||
queue = audio_to_stereo(id="queue_src", request.queue(id="queue", length=0.5))
|
||||
queue = cue_cut(queue)
|
||||
|
||||
pypo_data = ref '0'
|
||||
|
@ -26,6 +26,10 @@ s3_namespace = ref ''
|
|||
|
||||
%include "ls_lib.liq"
|
||||
|
||||
queue = on_metadata(notify, queue)
|
||||
queue = map_metadata(append_title, queue)
|
||||
ignore(output.dummy(queue, fallible=true))
|
||||
|
||||
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)
|
||||
|
@ -35,8 +39,9 @@ server.register(namespace="vars", "bootup_time", fun (s) -> begin time := s s en
|
|||
server.register(namespace="streams", "connection_status", fun (s) -> begin "1:#{!s1_connected},2:#{!s2_connected},3:#{!s3_connected}" end)
|
||||
|
||||
|
||||
default = amplify(0.00001, noise())
|
||||
default = amplify(id="silence_src", 0.00001, noise())
|
||||
default = rewrite_metadata([("artist","Airtime"), ("title", "offline")],default)
|
||||
ignore(output.dummy(default, fallible=true))
|
||||
|
||||
master_dj_enabled = ref false;
|
||||
live_dj_enabled = ref false;
|
||||
|
@ -87,33 +92,53 @@ def check_dj_client(user,password) =
|
|||
end
|
||||
end
|
||||
|
||||
def append_master_dj_input(master_harbor_input_port, master_harbor_input_mount_point, s) =
|
||||
if master_harbor_input_port != 0 and master_harbor_input_mount_point != "" then
|
||||
master_dj = input.harbor(master_harbor_input_mount_point, port=master_harbor_input_port, auth=check_master_dj_client, buffer=0.5,max=15.)
|
||||
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(header) =
|
||||
update_source_status("live_dj", true)
|
||||
end
|
||||
|
||||
def live_dj_disconnect() =
|
||||
update_source_status("live_dj", false)
|
||||
end
|
||||
|
||||
def master_dj_connect(header) =
|
||||
update_source_status("master_dj", true)
|
||||
end
|
||||
|
||||
def master_dj_disconnect() =
|
||||
update_source_status("master_dj", false)
|
||||
end
|
||||
|
||||
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,
|
||||
max=40., on_connect=master_dj_connect, on_disconnect=master_dj_disconnect)
|
||||
dj_live = input.harbor(id="live_dj_harbor", dj_harbor_input_mount_point, port=dj_harbor_input_port, auth=check_dj_client,
|
||||
max=40., on_connect=live_dj_connect, on_disconnect=live_dj_disconnect)
|
||||
ignore(output.dummy(master_dj, fallible=true))
|
||||
stopable_master_dj = switch(track_sensitive=false, [({!master_dj_enabled},master_dj)])
|
||||
fallback(track_sensitive=false, [stopable_master_dj, s])
|
||||
else
|
||||
s
|
||||
end
|
||||
end
|
||||
|
||||
def append_dj_input(dj_harbor_input_port, dj_harbor_input_mount_point, s) =
|
||||
if dj_harbor_input_port != 0 and dj_harbor_input_mount_point != "" then
|
||||
dj_live = input.harbor(dj_harbor_input_mount_point, port=dj_harbor_input_port, auth=check_dj_client, buffer=0.5,max=15.)
|
||||
ignore(output.dummy(dj_live, fallible=true))
|
||||
stopable_live_dj = switch(track_sensitive=false, [({!live_dj_enabled},dj_live)])
|
||||
fallback(track_sensitive=false, [stopable_live_dj, s])
|
||||
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,
|
||||
max=40., on_connect=master_dj_connect, on_disconnect=master_dj_disconnect)
|
||||
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,
|
||||
max=40., on_connect=live_dj_connect, on_disconnect=live_dj_disconnect)
|
||||
ignore(output.dummy(dj_live, fallible=true))
|
||||
switch(id="live_dj_switch", track_sensitive=false, transitions=[transition, transition], [({!live_dj_enabled},dj_live), ({true}, s)])
|
||||
else
|
||||
s
|
||||
end
|
||||
end
|
||||
|
||||
s = fallback(track_sensitive=false, [queue, default])
|
||||
s = on_metadata(notify, s)
|
||||
s = map_metadata(append_title, s)
|
||||
s = append_dj_input(dj_live_stream_port, dj_live_stream_mp, s)
|
||||
s = append_master_dj_input(master_live_stream_port, master_live_stream_mp, s)
|
||||
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)
|
||||
|
||||
|
||||
s = crossfade(s)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue