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

style: consolidate channel names engine#65

parent 87438dfc
No related branches found
No related tags found
No related merge requests found
Pipeline #2264 passed
...@@ -83,9 +83,9 @@ Set the volume of mixer `input 0` to `100%` ...@@ -83,9 +83,9 @@ Set the volume of mixer `input 0` to `100%`
`mixer.volume 0 100` `mixer.volume 0 100`
Push some audio file to the filesystem `in_filesystem_0` Push some audio file to the filesystem `in_queue_0`
`in_filesystem_0.push /path/to/your/file.mp3` `in_queue_0.push /path/to/your/file.mp3`
## Read More ## Read More
......
...@@ -63,10 +63,10 @@ engine_state = { ...@@ -63,10 +63,10 @@ engine_state = {
mixer = mix(id="mixer", mixer = mix(id="mixer",
list.append( list.append(
[ [
input_filesystem_0, input_queue_0,
input_filesystem_1, input_queue_1,
input_http_0, input_stream_0,
input_http_1 input_stream_1
], ],
!inputs !inputs
) )
......
...@@ -178,15 +178,15 @@ def eval_source_type(source_id) = ...@@ -178,15 +178,15 @@ def eval_source_type(source_id) =
type_mapping = [ type_mapping = [
("fallback_folder", "fallback"), ("fallback_folder", "fallback"),
("fallback_playlist", "fallback"), ("fallback_playlist", "fallback"),
("in_filesystem_0", "queue"), ("in_queue_0", "queue"),
("in_filesystem_0", "queue"), ("in_queue_1", "queue"),
("in_http_0", "stream"), ("in_stream_0", "stream"),
("in_http_1", "stream"), ("in_stream_1", "stream"),
("linein_0", "analog_in"), ("in_line_0", "analog_in"),
("linein_1", "analog_in"), ("in_line_1", "analog_in"),
("linein_2", "analog_in"), ("in_line_2", "analog_in"),
("linein_3", "analog_in"), ("in_line_3", "analog_in"),
("linein_4", "analog_in") ("in_line_4", "analog_in")
] ]
let source_type = list.assoc( let source_type = list.assoc(
default="unknown_source", default="unknown_source",
...@@ -209,15 +209,15 @@ def eval_track_type(meta_track_type, meta_source) = ...@@ -209,15 +209,15 @@ def eval_track_type(meta_track_type, meta_source) =
type_mapping = [ type_mapping = [
("fallback_folder", "0"), ("fallback_folder", "0"),
("fallback_playlist", "3"), ("fallback_playlist", "3"),
("in_filesystem_0", "0"), ("in_queue_0", "0"),
("in_filesystem_0", "0"), ("in_queue_1", "0"),
("in_http_0", "1"), ("in_stream_0", "1"),
("in_http_1", "1"), ("in_stream_1", "1"),
("linein_0", "2"), ("in_line_0", "2"),
("linein_1", "2"), ("in_line_1", "2"),
("linein_2", "2"), ("in_line_2", "2"),
("linein_3", "2"), ("in_line_3", "2"),
("linein_4", "2") ("in_line_4", "2")
] ]
track_type = list.assoc( track_type = list.assoc(
......
...@@ -36,26 +36,26 @@ end ...@@ -36,26 +36,26 @@ end
##################################### #####################################
# Create Sources # Create Sources
input_filesystem_raw_0 = request.queue(id="in_filesystem_0") input_queue_raw_0 = request.queue(id="in_queue_0")
input_filesystem_raw_1 = request.queue(id="in_filesystem_1") input_queue_raw_1 = request.queue(id="in_queue_1")
# Apply ReplayGain normalization, if metadata available # Apply ReplayGain normalization, if metadata available
input_filesystem_0 = amplify(id="in_filesystem_0", 1., override="replay_gain", input_filesystem_raw_0) input_queue_0 = amplify(id="in_queue_0", 1., override="replay_gain", input_queue_raw_0)
input_filesystem_1 = amplify(id="in_filesystem_1", 1., override="replay_gain", input_filesystem_raw_1) input_queue_1 = amplify(id="in_queue_1", 1., override="replay_gain", input_queue_raw_1)
# See https://github.com/savonet/liquidsoap/discussions/2537 # See https://github.com/savonet/liquidsoap/discussions/2537
# input_filesystem_0 = replaygain(input_filesystem_0) # input_queue_0 = replaygain(input_queue_0)
# input_filesystem_1 = replaygain(input_filesystem_1) # input_queue_1 = replaygain(input_queue_1)
# Add Event Handlers # Add Event Handlers
input_filesystem_0.on_metadata(on_metadata_notification) input_queue_0.on_metadata(on_metadata_notification)
input_filesystem_1.on_metadata(on_metadata_notification) input_queue_1.on_metadata(on_metadata_notification)
##################################### #####################################
# SERVER FUNCTIONS # # SERVER FUNCTIONS #
##################################### #####################################
# Clear Default Queue A # Clear Default Queue A
server.register(namespace=source.id(input_filesystem_0), server.register(namespace=source.id(input_queue_0),
description="Skip & clear all items from queue A.", description="Skip & clear all items from queue A.",
usage="clear", usage="clear",
"clear", "clear",
...@@ -63,13 +63,13 @@ server.register(namespace=source.id(input_filesystem_0), ...@@ -63,13 +63,13 @@ server.register(namespace=source.id(input_filesystem_0),
fun (s) -> fun (s) ->
begin begin
ignore(s) ignore(s)
clear_queue(input_filesystem_raw_0) clear_queue(input_queue_raw_0)
"OK" "OK"
end end
) )
# Clear Default Queue B # Clear Default Queue B
server.register(namespace=source.id(input_filesystem_1), server.register(namespace=source.id(input_queue_1),
description="Skip & clear all items from queue B.", description="Skip & clear all items from queue B.",
usage="clear", usage="clear",
"clear", "clear",
...@@ -77,37 +77,37 @@ server.register(namespace=source.id(input_filesystem_1), ...@@ -77,37 +77,37 @@ server.register(namespace=source.id(input_filesystem_1),
fun (s) -> fun (s) ->
begin begin
ignore(s) ignore(s)
clear_queue(input_filesystem_raw_1) clear_queue(input_queue_raw_1)
"OK" "OK"
end end
) )
# Seek Filesystem Queue A # Seek Filesystem Queue A
server.register(namespace = source.id(input_filesystem_0), server.register(namespace = source.id(input_queue_0),
description="Seek to relative position in #{source.id(input_filesystem_0)}", description="FFWD given amount of seconds",
usage = "seek <duration in seconds>", usage = "roll <duration in seconds>",
"seek", "roll",
fun (t) -> fun (t) ->
begin begin
log("Seeking #{t} sec") log("Rolling #{t} seconds")
t = float_of_string(default=0.,t) t = float_of_string(default=0.,t)
ret = source.seek(input_filesystem_0, t) ret = source.seek(input_queue_0, t)
"Seeked #{ret} seconds." "OK"
end end
) )
# Seek Filesystem Queue B # Seek Filesystem Queue B
server.register(namespace = source.id(input_filesystem_1), server.register(namespace = source.id(input_queue_1),
description="Seek to relative position in #{source.id(input_filesystem_1)}", description="FFWD given amount of seconds",
usage = "seek <duration in seconds>", usage = "roll <duration in seconds>",
"seek", "roll",
fun (t) -> fun (t) ->
begin begin
log("Seeking #{t} sec") log("Rolling #{t} seconds")
t = float_of_string(default=0.,t) t = float_of_string(default=0.,t)
ret = source.seek(input_filesystem_1, t) ret = source.seek(input_queue_1, t)
"Seeked #{ret} seconds." "OK"
end end
) )
...@@ -70,7 +70,7 @@ def create_input_line(source_id, device) = ...@@ -70,7 +70,7 @@ def create_input_line(source_id, device) =
fun (json_string) -> begin fun (json_string) -> begin
log("Received JSON to set track metadata on channel \ log("Received JSON to set track metadata on channel \
'linein_0' to:\n #{json_string}") 'in_line_0' to:\n #{json_string}")
metadata = build_metadata(json_string) metadata = build_metadata(json_string)
insert_callback = list.assoc(source_id, !in_line_insert_callbacks) insert_callback = list.assoc(source_id, !in_line_insert_callbacks)
insert_callback(metadata) insert_callback(metadata)
...@@ -85,21 +85,21 @@ end ...@@ -85,21 +85,21 @@ end
##################################### #####################################
if a0_in != "" then if a0_in != "" then
create_input_line("linein_0", a0_in) create_input_line("in_line_0", a0_in)
end end
if a1_in != "" then if a1_in != "" then
create_input_line("linein_1", a1_in) create_input_line("in_line_1", a1_in)
end end
if a2_in != "" then if a2_in != "" then
create_input_line("linein_2", a2_in) create_input_line("in_line_2", a2_in)
end end
if a3_in != "" then if a3_in != "" then
create_input_line("linein_3", a3_in) create_input_line("in_line_3", a3_in)
end end
if a4_in != "" then if a4_in != "" then
create_input_line("linein_4", a4_in) create_input_line("in_line_4", a4_in)
end end
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
##################################### #####################################
# STREAM 1 # STREAM 1
input_http_0 = input.http( input_stream_0 = input.http(
id="in_http_0", id="in_stream_0",
max_buffer=input_stream_max_buffer, max_buffer=input_stream_max_buffer,
timeout=input_stream_timeout, timeout=input_stream_timeout,
start=false, start=false,
...@@ -37,29 +37,29 @@ input_http_0 = input.http( ...@@ -37,29 +37,29 @@ input_http_0 = input.http(
) )
# Enable metadata insertion and store callbacks # Enable metadata insertion and store callbacks
input_http_0 = insert_metadata(id="in_http_0", input_http_0) input_stream_0 = insert_metadata(id="in_stream_0", input_stream_0)
in_stream_insert_meta_0 = input_http_0.insert_metadata in_stream_insert_meta_0 = input_stream_0.insert_metadata
in_stream_last_meta_0 = input_http_0.last_metadata in_stream_last_meta_0 = input_stream_0.last_metadata
# Map metadata # Map metadata
def on_stream_meta_0(meta) = def on_stream_meta_0(meta) =
lm = (in_stream_last_meta_0() ?? []) lm = (in_stream_last_meta_0() ?? [])
merge_meta(lm, meta) merge_meta(lm, meta)
end end
input_http_0 = metadata.map(id="in_http_0", on_stream_meta_0, input_http_0) input_stream_0 = metadata.map(id="in_stream_0", on_stream_meta_0, input_stream_0)
# Old Liquidsoap approach: # Old Liquidsoap approach:
# input_http_0.on_metadata(on_metadata_notification) # input_stream_0.on_metadata(on_metadata_notification)
# New Liquidsoap 2.1 approach, which should not trigger when inactive, # New Liquidsoap 2.1 approach, which should not trigger when inactive,
# but actually does trigger before stream is ready: # but actually does trigger before stream is ready:
input_http_0 = source.on_metadata(id="in_http_0", input_http_0, on_metadata_notification) input_stream_0 = source.on_metadata(id="in_stream_0", input_stream_0, on_metadata_notification)
##################################### #####################################
# STREAM 2 # STREAM 2
input_http_1 = input.http( input_stream_1 = input.http(
id="in_http_1", id="in_stream_1",
max_buffer=input_stream_max_buffer, max_buffer=input_stream_max_buffer,
timeout=input_stream_timeout, timeout=input_stream_timeout,
start=false, start=false,
...@@ -67,16 +67,16 @@ input_http_1 = input.http( ...@@ -67,16 +67,16 @@ input_http_1 = input.http(
) )
# Enable metadata insertion and store callbacks # Enable metadata insertion and store callbacks
input_http_1 = insert_metadata(id="in_http_1", input_http_1) input_stream_1 = insert_metadata(id="in_stream_1", input_stream_1)
in_stream_insert_meta_1 = input_http_1.insert_metadata in_stream_insert_meta_1 = input_stream_1.insert_metadata
in_stream_last_meta_1 = input_http_1.last_metadata in_stream_last_meta_1 = input_stream_1.last_metadata
# Old approach: # Old approach:
# input_http_1.on_metadata(on_metadata_notification) # input_stream_1.on_metadata(on_metadata_notification)
# New Liquidsoap 2.1 approach, which should not trigger when inactive, # New Liquidsoap 2.1 approach, which should not trigger when inactive,
# but actually does trigger before stream is ready: # but actually does trigger before stream is ready:
input_http_1 = source.on_metadata(id="in_http_1", input_http_1, on_metadata_notification) input_stream_1 = source.on_metadata(id="in_stream_1", input_stream_1, on_metadata_notification)
##################################### #####################################
...@@ -97,30 +97,30 @@ usage_set_track_metadata = "set_track_metadata { \ ...@@ -97,30 +97,30 @@ usage_set_track_metadata = "set_track_metadata { \
\"track_artist\": \"Foo\" \ \"track_artist\": \"Foo\" \
}" }"
# Set current track metadata for "input_http_0" # Set current track metadata for "input_stream_0"
server.register(namespace=source.id(input_http_0), server.register(namespace=source.id(input_stream_0),
description="Sets the current track metadata for a channel", description="Sets the current track metadata for a channel",
usage=usage_set_track_metadata, usage=usage_set_track_metadata,
"set_track_metadata", "set_track_metadata",
fun (json_string) -> begin fun (json_string) -> begin
log("Received JSON to set track metadata on channel \ log("Received JSON to set track metadata on channel \
'#{source.id(input_http_0)}' to:\n #{json_string}") '#{source.id(input_stream_0)}' to:\n #{json_string}")
metadata = build_metadata(json_string) metadata = build_metadata(json_string)
do_meta_insert(in_stream_last_meta_0, in_stream_insert_meta_0, metadata) do_meta_insert(in_stream_last_meta_0, in_stream_insert_meta_0, metadata)
"OK" "OK"
end end
) )
# Set current track metadata for "input_http_1" # Set current track metadata for "input_stream_1"
server.register(namespace=source.id(input_http_1), server.register(namespace=source.id(input_stream_1),
description="Sets the current track metadata for a channel", description="Sets the current track metadata for a channel",
usage=usage_set_track_metadata, usage=usage_set_track_metadata,
"set_track_metadata", "set_track_metadata",
fun (json_string) -> begin fun (json_string) -> begin
log("Received JSON to set track metadata on channel \ log("Received JSON to set track metadata on channel \
'#{source.id(input_http_1)}' to:\n #{json_string}") '#{source.id(input_stream_1)}' to:\n #{json_string}")
metadata = build_metadata(json_string) metadata = build_metadata(json_string)
do_meta_insert(in_stream_last_meta_1, in_stream_insert_meta_1, metadata) do_meta_insert(in_stream_last_meta_1, in_stream_insert_meta_1, metadata)
"OK" "OK"
......
...@@ -38,11 +38,11 @@ type = eval_source_type("fallback_playlist") ...@@ -38,11 +38,11 @@ type = eval_source_type("fallback_playlist")
assertEquals(type, "fallback") assertEquals(type, "fallback")
# Case 3: Stream # Case 3: Stream
type = eval_source_type("in_http_0") type = eval_source_type("in_stream_0")
assertEquals(type, "stream") assertEquals(type, "stream")
# Case 4: Analog In # Case 4: Analog In
type = eval_source_type("linein_0") type = eval_source_type("in_line_0")
assertEquals(type, "analog_in") assertEquals(type, "analog_in")
# Case 5: Unknown Source # Case 5: Unknown Source
......
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