Skip to content
Snippets Groups Projects
Commit 364a136b authored by David Trattnig's avatar David Trattnig
Browse files

Feat: Ability to return fallback state engine#107

parent c2a7090c
No related branches found
No related tags found
1 merge request!3Liquidsoap 2 migration
......@@ -20,9 +20,12 @@
# Initialize
icecast_vorbis_metadata = false
inputs = ref ([])
engine_state = {
is_fallback = ref(false)
}
# Load settings from ini file
%include "settings.liq"
......@@ -37,9 +40,23 @@ inputs = ref ([])
# EVENTS #
#####################################
# Updates the playout state
def on_playout_state_change(source_type) =
if source_type == "fallback" then
engine_state.is_fallback := true
else
engine_state.is_fallback := false
end
end
# Called when some new metadata info is available
def on_metadata_notification(meta) =
log(level=5, label="metadata", "Raw metadata before POST:\n\n #{meta}\n\n")
# FIXME For some reason stream channels do not pass the `source` property in meta
channel_name = meta["source"]
source_type = eval_source_type(channel_name)
on_playout_state_change(source_type)
log(level=3, label="metadata", "Raw metadata before POST:\n\n #{meta}\n\n")
show_name = ref(list.assoc(default="", "show_name", meta))
show_id = ref(list.assoc(default="", "show_id", meta))
......@@ -53,15 +70,11 @@ def on_metadata_notification(meta) =
track_album = list.assoc(default=meta["track_album"], "album", meta)
track_title = list.assoc(default=meta["track_title"], "title", meta)
source_type = eval_source_type(meta["source"])
if source_type == "fallback" then
log(level=3, label="metadata", "Detected FALLBACK playing \
log(level=3, label="metadata", "Detected FALLBACK channel `#{channel_name}` playing \
(Show ID: #{!fallback_show_id})")
show_name := !fallback_show_name
show_id := !fallback_show_id
elsif source_type == "queue" then
log(level=3, label="metadata", "ERROR in metadata handling: \
Invalid source type #{source_type}")
end
playlog = [
......
......@@ -17,55 +17,29 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Namespace: aura_engine
#
# Get state of the inputs/outputs as JSON
server.register(namespace = "aura_engine",
description="Returns enabled line-in, line-out and connected outgoing streams",
description="Get status info (uptime and fallback state)",
usage="status",
"status",
fun(s) -> begin
ignore(s)
log("executing: aura_engine.status")
json_streams = {
stream_0 = { enabled = "#{s0_enable}", connected = "#{!s0_connected}" },
stream_1 = { enabled = "#{s1_enable}", connected = "#{!s1_connected}" },
stream_2 = { enabled = "#{s2_enable}", connected = "#{!s2_connected}" },
stream_3 = { enabled = "#{s3_enable}", connected = "#{!s3_connected}" },
stream_4 = { enabled = "#{s4_enable}", connected = "#{!s4_connected}" }
}
json_linein = {
linein_0 = { enabled = "#{a0_in != ''}" },
linein_1 = { enabled = "#{a1_in != ''}" },
linein_2 = { enabled = "#{a2_in != ''}" },
linein_3 = { enabled = "#{a3_in != ''}" },
linein_4 = { enabled = "#{a4_in != ''}" }
}
json_lineout = {
lineout_0 = { enabled = "#{a0_out != ''}" },
lineout_1 = { enabled = "#{a1_out != ''}" },
lineout_2 = { enabled = "#{a2_out != ''}" },
lineout_3 = { enabled = "#{a3_out != ''}" },
lineout_4 = { enabled = "#{a4_out != ''}" }
}
uptime = list.nth(server.execute("uptime"), 0)
json_data = json()
json_data.add("streams", json_streams)
json_data.add("linein", json_linein)
json_data.add("lineout", json_lineout)
json_data.add("uptime", uptime)
json_data.add("is_fallback", !engine_state.is_fallback)
json.stringify(json_data)
end
)
# Updates engine config
server.register(namespace="aura_engine",
description="Updates the engine configuration",
description="Update the engine configuration",
usage="update_config { \
\"fallback_show_id\": \"-1\", \
\"fallback_show_name\": \"Station Fallback\" \
......@@ -87,10 +61,9 @@ server.register(namespace="aura_engine",
end
)
# Get version
server.register(namespace="aura_engine",
description="Returns the version of Engine Core",
description="Return the version of Engine Core",
usage="version",
"version",
fun (s) -> begin
......@@ -112,14 +85,13 @@ server.register(namespace="aura_engine",
)
#
# Namespace: mixer
#
# Get connection state of outgoing streams #TODO refactor
server.register(namespace="mixer",
description="Returns all active outputs",
description="Return all active outputs",
usage="outputs",
"outputs",
fun (s) -> begin
......@@ -172,7 +144,7 @@ server.register(namespace = "mixer",
r = server.execute("mixer.select #{source_number} false")
print(r)
end
"Done!"
"OK"
end
end
)
......@@ -182,7 +154,6 @@ server.register(namespace = "mixer",
# Namespace: misc #TODO: refactor
#
def fadeTo(source_number) =
if source_number == "" then
print(source_number)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment