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

Merge and insert metadata on stream sources

parent 3872a3be
No related branches found
No related tags found
1 merge request!3Liquidsoap 2 migration
......@@ -27,13 +27,56 @@
# SOURCES #
#####################################
http_starturl = ""
input_http_0 = input.http(id="in_http_0", max_buffer=input_stream_max_buffer, timeout=input_stream_timeout, start=false, http_starturl)
# STREAM 1
input_http_0 = input.http(
id="in_http_0",
max_buffer=input_stream_max_buffer,
timeout=input_stream_timeout,
start=false,
""
)
# Enable metadata insertion and store callbacks
input_http_0 = insert_metadata(id="in_http_0", input_http_0)
input_http_0.on_metadata(on_metadata_notification)
input_http_1 = input.http(id="in_http_1", max_buffer=input_stream_max_buffer, timeout=input_stream_timeout, start=false, http_starturl)
in_stream_insert_meta_0 = input_http_0.insert_metadata
in_stream_last_meta_0 = input_http_0.last_metadata
# Map metadata
def on_stream_meta_0(meta) =
lm = (in_stream_last_meta_0() ?? [])
merge_meta(lm, meta)
end
input_http_0 = metadata.map(id="in_http_0", on_stream_meta_0, input_http_0)
# Old Liquidsoap approach:
# input_http_0.on_metadata(on_metadata_notification)
# New Liquidsoap 2.1 approach, which should not trigger when inactive,
# but actually does trigger before stream is ready:
input_http_0 = source.on_metadata(id="in_http_0", input_http_0, on_metadata_notification)
#####################################
# STREAM 2
input_http_1 = input.http(
id="in_http_1",
max_buffer=input_stream_max_buffer,
timeout=input_stream_timeout,
start=false,
""
)
# Enable metadata insertion and store callbacks
input_http_1 = insert_metadata(id="in_http_1", input_http_1)
input_http_1.on_metadata(on_metadata_notification)
in_stream_insert_meta_1 = input_http_1.insert_metadata
in_stream_last_meta_1 = input_http_1.last_metadata
# Old approach:
# input_http_1.on_metadata(on_metadata_notification)
# New Liquidsoap 2.1 approach, which should not trigger when inactive,
# but actually does trigger before stream is ready:
input_http_1 = source.on_metadata(id="in_http_1", input_http_1, on_metadata_notification)
#####################################
......@@ -42,9 +85,9 @@ input_http_1.on_metadata(on_metadata_notification)
usage_set_track_metadata = "set_track_metadata { \
\"show_name\": \"Laser Music 2000\", \
\"show_id\": -1, \
\"timeslot_id\": -1, \
\"playlist_id\": -1, \
\"show_id\": 123, \
\"timeslot_id\": 123, \
\"playlist_id\": 123, \
\"playlist_item\": \"\", \
\"track_type\": 1, \
\"track_start\": \"2022/02/22 22:02:22\", \
......@@ -64,7 +107,7 @@ server.register(namespace=source.id(input_http_0),
log("Received JSON to set track metadata on channel \
'#{source.id(input_http_0)}' to:\n #{json_string}")
metadata = build_metadata(json_string)
input_http_0.insert_metadata(metadata)
do_meta_insert(in_stream_last_meta_0, in_stream_insert_meta_0, metadata)
"OK"
end
)
......@@ -79,7 +122,7 @@ server.register(namespace=source.id(input_http_1),
log("Received JSON to set track metadata on channel \
'#{source.id(input_http_1)}' to:\n #{json_string}")
metadata = build_metadata(json_string)
input_http_1.insert_metadata(metadata)
do_meta_insert(in_stream_last_meta_1, in_stream_insert_meta_1, metadata)
"OK"
end
)
\ No newline at end of file
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