refactor(playout): rename liquidsoap switch functions

This commit is contained in:
jo 2023-02-22 17:03:12 +01:00 committed by Kyle Robbertze
parent d36fc56f51
commit 9a815d68ff
2 changed files with 43 additions and 56 deletions

View File

@ -99,30 +99,12 @@ input_main_streaming = ref false
input_show_streaming = ref false input_show_streaming = ref false
schedule_streaming = ref false schedule_streaming = ref false
def make_master_dj_available() def start_input_main() input_main_streaming := true end
input_main_streaming := true def stop_input_main() input_main_streaming := false end
end def start_input_show() input_show_streaming := true end
def stop_input_show() input_show_streaming := false end
def make_master_dj_unavailable() def start_schedule() schedule_streaming := true; just_switched := true end
input_main_streaming := false def stop_schedule() schedule_streaming := false end
end
def make_live_dj_available()
input_show_streaming := true
end
def make_live_dj_unavailable()
input_show_streaming := false
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) = def update_source_status(sourcename, status) =
gateway("live '#{sourcename}' '#{status}'") gateway("live '#{sourcename}' '#{status}'")
@ -230,36 +212,36 @@ else
s s
end end
server.register(namespace="streams", server.register(namespace="sources",
description="Stop Master DJ source.", description="Stop main input source.",
usage="master_dj_stop", usage="stop_input_main",
"master_dj_stop", "stop_input_main",
fun (s) -> begin log("streams.master_dj_stop") make_master_dj_unavailable() "Done." end) fun (s) -> begin log("sources.stop_input_main") stop_input_main() "Done." end)
server.register(namespace="streams", server.register(namespace="sources",
description="Start Master DJ source.", description="Start main input source.",
usage="master_dj_start", usage="start_input_main",
"master_dj_start", "start_input_main",
fun (s) -> begin log("streams.master_dj_start") make_master_dj_available() "Done." end) fun (s) -> begin log("sources.start_input_main") start_input_main() "Done." end)
server.register(namespace="streams", server.register(namespace="sources",
description="Stop Live DJ source.", description="Stop show input source.",
usage="live_dj_stop", usage="stop_input_show",
"live_dj_stop", "stop_input_show",
fun (s) -> begin log("streams.live_dj_stop") make_live_dj_unavailable() "Done." end) fun (s) -> begin log("sources.stop_input_show") stop_input_show() "Done." end)
server.register(namespace="streams", server.register(namespace="sources",
description="Start Live DJ source.", description="Start show input source.",
usage="live_dj_start", usage="start_input_show",
"live_dj_start", "start_input_show",
fun (s) -> begin log("streams.live_dj_start") make_live_dj_available() "Done." end) fun (s) -> begin log("sources.start_input_show") start_input_show() "Done." end)
server.register(namespace="streams", server.register(namespace="sources",
description="Stop Scheduled Play source.", description="Stop schedule source.",
usage="scheduled_play_stop", usage="stop_schedule",
"scheduled_play_stop", "stop_schedule",
fun (s) -> begin log("streams.scheduled_play_stop") make_scheduled_play_unavailable() "Done." end) fun (s) -> begin log("sources.stop_schedule") stop_schedule() "Done." end)
server.register(namespace="streams", server.register(namespace="sources",
description="Start Scheduled Play source.", description="Start schedule source.",
usage="scheduled_play_start", usage="start_schedule",
"scheduled_play_start", "start_schedule",
fun (s) -> begin log("streams.scheduled_play_start") make_scheduled_play_available() "Done." end) fun (s) -> begin log("sources.start_schedule") start_schedule() "Done." end)
if output_sound_device then if output_sound_device then
success = ref false success = ref false

View File

@ -82,7 +82,7 @@ class LiquidsoapClient:
def web_stream_start(self) -> None: def web_stream_start(self) -> None:
with self.conn: with self.conn:
self.conn.write("streams.scheduled_play_start") self.conn.write("sources.start_schedule")
self.conn.write("web_stream.output_start") self.conn.write("web_stream.output_start")
def web_stream_start_buffer(self, schedule_id: int, uri: str) -> None: def web_stream_start_buffer(self, schedule_id: int, uri: str) -> None:
@ -112,9 +112,14 @@ class LiquidsoapClient:
name: Literal["master_dj", "live_dj", "scheduled_play"], name: Literal["master_dj", "live_dj", "scheduled_play"],
streaming: bool, streaming: bool,
) -> None: ) -> None:
name_map = {
"master_dj": "input_main",
"live_dj": "input_show",
"scheduled_play": "schedule",
}
action = "start" if streaming else "stop" action = "start" if streaming else "stop"
with self.conn: with self.conn:
self.conn.write(f"streams.{name}_{action}") self.conn.write(f"sources.{action}_{name_map[name]}")
def settings_update( def settings_update(
self, self,