diff --git a/playout/libretime_playout/liquidsoap/1.4/fdkaac.liq b/playout/libretime_playout/liquidsoap/1.4/fdkaac.liq deleted file mode 100644 index 6ac835ef5..000000000 --- a/playout/libretime_playout/liquidsoap/1.4/fdkaac.liq +++ /dev/null @@ -1,23 +0,0 @@ - if bitrate == 24 then - ignore(output_stereo(%fdkaac(bitrate = 24, aot="mpeg4_he_aac_v2", afterburner=false, sbr_mode=true), !source)) - elsif bitrate == 32 then - ignore(output_stereo(%fdkaac(bitrate = 32, aot="mpeg4_he_aac_v2", afterburner=false, sbr_mode=true), !source)) - elsif bitrate == 48 then - ignore(output_stereo(%fdkaac(bitrate = 48, aot="mpeg4_he_aac_v2", afterburner=false, sbr_mode=true), !source)) - elsif bitrate == 64 then - ignore(output_stereo(%fdkaac(bitrate = 64, aot="mpeg4_he_aac_v2", afterburner=false, sbr_mode=true), !source)) - elsif bitrate == 96 then - ignore(output_stereo(%fdkaac(bitrate = 96, aot="mpeg4_aac_lc", afterburner=false, sbr_mode=true), !source)) - elsif bitrate == 128 then - ignore(output_stereo(%fdkaac(bitrate = 128, aot="mpeg4_aac_lc", afterburner=false, sbr_mode=true), !source)) - elsif bitrate == 160 then - ignore(output_stereo(%fdkaac(bitrate = 160, aot="mpeg4_aac_lc", afterburner=true, sbr_mode=true), !source)) - elsif bitrate == 192 then - ignore(output_stereo(%fdkaac(bitrate = 192, aot="mpeg4_aac_lc", afterburner=true, sbr_mode=true), !source)) - elsif bitrate == 224 then - ignore(output_stereo(%fdkaac(bitrate = 224, aot="mpeg4_aac_lc", afterburner=true, sbr_mode=true), !source)) - elsif bitrate == 256 then - ignore(output_stereo(%fdkaac(bitrate = 256, aot="mpeg4_aac_lc", afterburner=true, sbr_mode=true), !source)) - elsif bitrate == 320 then - ignore(output_stereo(%fdkaac(bitrate = 320, aot="mpeg4_aac_lc", afterburner=true, sbr_mode=true), !source)) - end diff --git a/playout/libretime_playout/liquidsoap/1.4/ls_lib.liq b/playout/libretime_playout/liquidsoap/1.4/ls_lib.liq index d0278a33f..563008e19 100644 --- a/playout/libretime_playout/liquidsoap/1.4/ls_lib.liq +++ b/playout/libretime_playout/liquidsoap/1.4/ls_lib.liq @@ -95,112 +95,19 @@ def to_live(old,new) = end -def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, description, genre, user, s, stream, name, channels) = - source = ref s - def on_error(msg) - gateway("stream '#{stream}' '#{boot_timestamp}' --error='#{msg}'") - 5. - end - def on_connect() - gateway("stream '#{stream}' '#{boot_timestamp}'") - end +def make_ouput_on_connect_handler(stream) + def on_connect() + gateway("stream '#{stream}' '#{boot_timestamp}'") + end + on_connect +end - stereo = (channels == "stereo") - - if output_type == "icecast" then - user_ref = ref user - if user == "" then - user_ref := "source" - end - output_mono = output.icecast( - id = "icecast:stream_#{stream}", - host = host, - port = port, - password = pass, - mount = mount_point, - fallible = true, - url = url, - description = description, - name = name, - genre = genre, - user = !user_ref, - on_error = on_error, - on_connect = on_connect) - - output_stereo = output.icecast( - id = "icecast:stream_#{stream}", - host = host, - port = port, - password = pass, - mount = mount_point, - fallible = true, - url = url, - description = description, - name = name, - genre = genre, - user = !user_ref, - on_error = on_error, - on_connect = on_connect) - if type == "mp3" then - %include "mp3.liq" - end - if type == "ogg" then - %include "ogg.liq" - end - - %ifencoder %opus - if type == "opus" then - %include "opus.liq" - end - %endif - - %ifencoder %fdkaac - if type == "aac" then - %include "fdkaac.liq" - end - %endif - else - user_ref = ref user - if user == "" then - user_ref := "source" - end - - output_mono = output.shoutcast( - id = "shoutcast:stream_#{stream}", - host = host, - port = port, - password = pass, - fallible = true, - url = url, - genre = genre, - name = description, - user = !user_ref, - on_error = on_error, - on_connect = on_connect) - - output_stereo = output.shoutcast( - id = "shoutcast:stream_#{stream}", - host = host, - port = port, - password = pass, - fallible = true, - url = url, - genre = genre, - name = description, - user = !user_ref, - on_error = on_error, - on_connect = on_connect) - - if type == "mp3" then - %include "mp3.liq" - end - - %ifencoder %fdkaac - if type == "aac" then - %include "fdkaac.liq" - end - %endif - end +def make_ouput_on_error_handler(stream) + def on_error(msg) + gateway("stream '#{stream}' '#{boot_timestamp}' --error='#{msg}'") + 5. + end + on_error end def clear_queue(s) diff --git a/playout/libretime_playout/liquidsoap/1.4/ls_script.liq b/playout/libretime_playout/liquidsoap/1.4/ls_script.liq index cecf7db5a..c4708a9f8 100644 --- a/playout/libretime_playout/liquidsoap/1.4/ls_script.liq +++ b/playout/libretime_playout/liquidsoap/1.4/ls_script.liq @@ -224,78 +224,3 @@ server.register(namespace="sources", usage="start_schedule", "start_schedule", fun (s) -> begin log("sources.start_schedule") start_schedule() "Done." end) - -if output_sound_device then - success = ref false - - log(output_sound_device_type) - - %ifdef output.alsa - if output_sound_device_type == "ALSA" then - ignore(output.alsa(s)) - success := true - end - %endif - - %ifdef output.ao - if output_sound_device_type == "AO" then - ignore(output.ao(s)) - success := true - end - %endif - - %ifdef output.oss - if output_sound_device_type == "OSS" then - ignore(output.oss(s)) - success := true - end - %endif - - %ifdef output.portaudio - if output_sound_device_type == "Portaudio" then - ignore(output.portaudio(s)) - success := true - end - %endif - - %ifdef output.pulseaudio - if output_sound_device_type == "Pulseaudio" then - ignore(output.pulseaudio(s)) - success := true - end - %endif - - if (!success == false) then - ignore(output.prefered(s)) - end - -end - -if s1_enable == true then - output_to(s1_output, s1_type, s1_bitrate, s1_host, s1_port, s1_pass, - s1_mount, s1_url, s1_description, s1_genre, s1_user, s, "1", - s1_name, s1_channels) -end - -if s2_enable == true then - output_to(s2_output, s2_type, s2_bitrate, s2_host, s2_port, s2_pass, - s2_mount, s2_url, s2_description, s2_genre, s2_user, s, "2", - s2_name, s2_channels) - -end - -if s3_enable == true then - output_to(s3_output, s3_type, s3_bitrate, s3_host, s3_port, s3_pass, - s3_mount, s3_url, s3_description, s3_genre, s3_user, s, "3", - s3_name, s3_channels) -end - -if s4_enable == true then - log("Stream 4 Enabled") - output_to(s4_output, s4_type, s4_bitrate, s4_host, s4_port, s4_pass, - s4_mount, s4_url, s4_name, s4_genre, s4_user, s, "4", - s4_description, s4_channels) -end - - -gateway("started") diff --git a/playout/libretime_playout/liquidsoap/1.4/mp3.liq b/playout/libretime_playout/liquidsoap/1.4/mp3.liq deleted file mode 100644 index 25b551f9d..000000000 --- a/playout/libretime_playout/liquidsoap/1.4/mp3.liq +++ /dev/null @@ -1,67 +0,0 @@ - if bitrate == 24 then - if stereo then - ignore(output_stereo(%mp3(bitrate = 24, stereo = true), !source)) - else - ignore(output_mono(%mp3(bitrate = 24, stereo = false), mean(!source))) - end - elsif bitrate == 32 then - if stereo then - ignore(output_stereo(%mp3(bitrate = 32, stereo = true), !source)) - else - ignore(output_mono(%mp3(bitrate = 32, stereo = false), mean(!source))) - end - elsif bitrate == 48 then - if stereo then - ignore(output_stereo(%mp3(bitrate = 48, stereo = true), !source)) - else - ignore(output_mono(%mp3(bitrate = 48, stereo = false), mean(!source))) - end - elsif bitrate == 64 then - if stereo then - ignore(output_stereo(%mp3(bitrate = 64, stereo = true), !source)) - else - ignore(output_mono(%mp3(bitrate = 64, stereo = false), mean(!source))) - end - elsif bitrate == 96 then - if stereo then - ignore(output_stereo(%mp3(bitrate = 96, stereo = true), !source)) - else - ignore(output_mono(%mp3(bitrate = 96, stereo = false), mean(!source))) - end - elsif bitrate == 128 then - if stereo then - ignore(output_stereo(%mp3(bitrate = 128, stereo = true), !source)) - else - ignore(output_mono(%mp3(bitrate = 128, stereo = false), mean(!source))) - end - elsif bitrate == 160 then - if stereo then - ignore(output_stereo(%mp3(bitrate = 160, stereo = true), !source)) - else - ignore(output_mono(%mp3(bitrate = 160, stereo = false), mean(!source))) - end - elsif bitrate == 192 then - if stereo then - ignore(output_stereo(%mp3(bitrate = 192, stereo = true), !source)) - else - ignore(output_mono(%mp3(bitrate = 192, stereo = false), mean(!source))) - end - elsif bitrate == 224 then - if stereo then - ignore(output_stereo(%mp3(bitrate = 224, stereo = true), !source)) - else - ignore(output_mono(%mp3(bitrate = 224, stereo = false), mean(!source))) - end - elsif bitrate == 256 then - if stereo then - ignore(output_stereo(%mp3(bitrate = 256, stereo = true), !source)) - else - ignore(output_mono(%mp3(bitrate = 256, stereo = false), mean(!source))) - end - elsif bitrate == 320 then - if stereo then - ignore(output_stereo(%mp3(bitrate = 320, stereo = true), !source)) - else - ignore(output_mono(%mp3(bitrate = 320, stereo = false), mean(!source))) - end - end diff --git a/playout/libretime_playout/liquidsoap/1.4/ogg.liq b/playout/libretime_playout/liquidsoap/1.4/ogg.liq deleted file mode 100644 index 9bcf852bc..000000000 --- a/playout/libretime_playout/liquidsoap/1.4/ogg.liq +++ /dev/null @@ -1,59 +0,0 @@ - if not icecast_vorbis_metadata then - source := add(normalize=false, [amplify(0.00001, noise()), !source]) - end - - if bitrate == 24 or bitrate == 32 or bitrate == 48 then - if stereo then - ignore(output_stereo(%vorbis(quality=-0.1, channels = 2), !source)) - else - ignore(output_mono(%vorbis(quality=-0.1, channels = 1), mean(!source))) - end - elsif bitrate == 64 then - if stereo then - ignore(output_stereo(%vorbis(quality=0, channels = 2), !source)) - else - ignore(output_mono(%vorbis(quality=0, channels = 1), mean(!source))) - end - elsif bitrate == 96 then - if stereo then - ignore(output_stereo(%vorbis(quality=0.2, channels = 2), !source)) - else - ignore(output_mono(%vorbis(quality=0.2, channels = 1), mean(!source))) - end - elsif bitrate == 128 then - if stereo then - ignore(output_stereo(%vorbis(quality=0.4, channels = 2), !source)) - else - ignore(output_mono(%vorbis(quality=0.4, channels = 1), mean(!source))) - end - elsif bitrate == 160 then - if stereo then - ignore(output_stereo(%vorbis(quality=0.5, channels = 2), !source)) - else - ignore(output_mono(%vorbis(quality=0.5, channels = 1), mean(!source))) - end - elsif bitrate == 192 then - if stereo then - ignore(output_stereo(%vorbis(quality=0.6, channels = 2), !source)) - else - ignore(output_mono(%vorbis(quality=0.6, channels = 1), mean(!source))) - end - elsif bitrate == 224 then - if stereo then - ignore(output_stereo(%vorbis(quality=0.7, channels = 2), !source)) - else - ignore(output_mono(%vorbis(quality=0.7, channels = 1), mean(!source))) - end - elsif bitrate == 256 then - if stereo then - ignore(output_stereo(%vorbis(quality=0.8, channels = 2), !source)) - else - ignore(output_mono(%vorbis(quality=0.8, channels = 1), mean(!source))) - end - elsif bitrate == 320 then - if stereo then - ignore(output_stereo(%vorbis(quality=0.9, channels = 2), !source)) - else - ignore(output_mono(%vorbis(quality=0.9, channels = 1), mean(!source))) - end - end diff --git a/playout/libretime_playout/liquidsoap/1.4/opus.liq b/playout/libretime_playout/liquidsoap/1.4/opus.liq deleted file mode 100644 index 7219aac03..000000000 --- a/playout/libretime_playout/liquidsoap/1.4/opus.liq +++ /dev/null @@ -1,67 +0,0 @@ - if bitrate == 24 then - if stereo then - ignore(output_stereo(%opus(bitrate = 24, channels = 2, signal="music", application="audio", complexity=10, vbr="constrained"), !source)) - else - ignore(output_mono(%opus(bitrate = 24, channels = 1, signal="music", application="audio", complexity=10, vbr="constrained"), mean(!source))) - end - elsif bitrate == 32 then - if stereo then - ignore(output_stereo(%opus(bitrate = 32, channels = 2, signal="music", application="audio", complexity=10, vbr="constrained"), !source)) - else - ignore(output_mono(%opus(bitrate = 32, channels = 1, signal="music", application="audio", complexity=10, vbr="constrained"), mean(!source))) - end - elsif bitrate == 48 then - if stereo then - ignore(output_stereo(%opus(bitrate = 48, channels = 2, signal="music", application="audio", complexity=10, vbr="constrained"), !source)) - else - ignore(output_mono(%opus(bitrate = 48, channels = 1, signal="music", application="audio", complexity=10, vbr="constrained"), mean(!source))) - end - elsif bitrate == 64 then - if stereo then - ignore(output_stereo(%opus(bitrate = 64, channels = 2, signal="music", application="audio", complexity=10, vbr="constrained"), !source)) - else - ignore(output_mono(%opus(bitrate = 64, channels = 1, signal="music", application="audio", complexity=10, vbr="constrained"), mean(!source))) - end - elsif bitrate == 96 then - if stereo then - ignore(output_stereo(%opus(bitrate = 96, channels = 2, signal="music", application="audio", complexity=10, vbr="constrained"), !source)) - else - ignore(output_mono(%opus(bitrate = 96, channels = 1, signal="music", application="audio", complexity=10, vbr="constrained"), mean(!source))) - end - elsif bitrate == 128 then - if stereo then - ignore(output_stereo(%opus(bitrate = 128, channels = 2, signal="music", application="audio", complexity=10, vbr="constrained"), !source)) - else - ignore(output_mono(%opus(bitrate = 128, channels = 1, signal="music", application="audio", complexity=10, vbr="constrained"), mean(!source))) - end - elsif bitrate == 160 then - if stereo then - ignore(output_stereo(%opus(bitrate = 160, channels = 2, signal="music", application="audio", complexity=10, vbr="constrained"), !source)) - else - ignore(output_mono(%opus(bitrate = 160, channels = 1, signal="music", application="audio", complexity=10, vbr="constrained"), mean(!source))) - end - elsif bitrate == 192 then - if stereo then - ignore(output_stereo(%opus(bitrate = 192, channels = 2, signal="music", application="audio", complexity=10, vbr="constrained"), !source)) - else - ignore(output_mono(%opus(bitrate = 192, channels = 1, signal="music", application="audio", complexity=10, vbr="constrained"), mean(!source))) - end - elsif bitrate == 224 then - if stereo then - ignore(output_stereo(%opus(bitrate = 224, channels = 2, signal="music", application="audio", complexity=10, vbr="constrained"), !source)) - else - ignore(output_mono(%opus(bitrate = 224, channels = 1, signal="music", application="audio", complexity=10, vbr="constrained"), mean(!source))) - end - elsif bitrate == 256 then - if stereo then - ignore(output_stereo(%opus(bitrate = 256, channels = 2, signal="music", application="audio", complexity=10, vbr="constrained"), !source)) - else - ignore(output_mono(%opus(bitrate = 256, channels = 1, signal="music", application="audio", complexity=10, vbr="constrained"), mean(!source))) - end - elsif bitrate == 320 then - if stereo then - ignore(output_stereo(%opus(bitrate = 320, channels = 2, signal="music", application="audio", complexity=10, vbr="constrained"), !source)) - else - ignore(output_mono(%opus(bitrate = 320, channels = 1, signal="music", application="audio", complexity=10, vbr="constrained"), mean(!source))) - end - end diff --git a/playout/libretime_playout/liquidsoap/entrypoint.py b/playout/libretime_playout/liquidsoap/entrypoint.py index 31fb05600..c8869cbd7 100644 --- a/playout/libretime_playout/liquidsoap/entrypoint.py +++ b/playout/libretime_playout/liquidsoap/entrypoint.py @@ -2,7 +2,7 @@ from pathlib import Path from typing import Optional, Tuple from jinja2 import Environment, PackageLoader -from libretime_shared.config import AudioFormat, IcecastOutput, SystemOutput +from libretime_shared.config import AudioFormat from ..config import Config from .models import Info, StreamPreferences @@ -17,18 +17,6 @@ templates = Environment( # nosec ) templates.filters["quote"] = quote -# Liquidsoap has 4 hardcoded output stream set of variables, so we need to -# fill the missing stream outputs with placeholders so Liquidsoap does -# not fail with missing variables in the entrypoint. -_icecast_placeholder = IcecastOutput( - enabled=False, - mount="", - source_password="", - audio=dict(format="ogg", bitrate=256), -) - -_system_placeholder = SystemOutput() - def generate_entrypoint( entrypoint_filepath: Path, @@ -46,11 +34,6 @@ def generate_entrypoint( paths["log_filepath"] = log_filepath.resolve() config = config.copy() - missing_outputs = [_icecast_placeholder] * (4 - len(config.stream.outputs.merged)) - config.stream.outputs.icecast.extend(missing_outputs) - - if not config.stream.outputs.system: - config.stream.outputs.system.append(_system_placeholder) # Global icecast_vorbis_metadata until it is # handled per output diff --git a/playout/libretime_playout/liquidsoap/templates/entrypoint.liq.j2 b/playout/libretime_playout/liquidsoap/templates/entrypoint.liq.j2 index d756cf931..20d7fc089 100644 --- a/playout/libretime_playout/liquidsoap/templates/entrypoint.liq.j2 +++ b/playout/libretime_playout/liquidsoap/templates/entrypoint.liq.j2 @@ -8,32 +8,9 @@ input_main_port = {{ config.stream.inputs.main.port }} input_show_mount = {{ config.stream.inputs.show.mount | quote }} input_show_port = {{ config.stream.inputs.show.port }} -{% for output in config.stream.outputs.merged -%} -# Output s{{ loop.index }} -s{{ loop.index }}_enable = {{ output.enabled | lower }} -s{{ loop.index }}_output = {{ output.kind | quote }} -s{{ loop.index }}_host = {{ output.host | quote }} -s{{ loop.index }}_port = {{ output.port }} -s{{ loop.index }}_mount = {{ output.mount | quote }} -s{{ loop.index }}_user = {{ output.source_user | quote }} -s{{ loop.index }}_pass = {{ output.source_password | quote }} - -s{{ loop.index }}_channels = {{ output.audio.channels.value | quote }} -s{{ loop.index }}_type = {{ output.audio.format.value | quote }} -s{{ loop.index }}_bitrate = {{ output.audio.bitrate }} - -s{{ loop.index }}_name = {{ (output.name or '') | quote }} -s{{ loop.index }}_description = {{ (output.description or '') | quote }} -s{{ loop.index }}_genre = {{ (output.genre or '') | quote }} -s{{ loop.index }}_url = {{ (output.website or '') | quote }} - -{% endfor -%} +# Outputs icecast_vorbis_metadata = {{ icecast_vorbis_metadata | lower }} -# System output -output_sound_device = {{ config.stream.outputs.system[0].enabled | lower }} -output_sound_device_type = {{ config.stream.outputs.system[0].kind.value | quote }} - # Settings auth_path = {{ paths.auth_filepath | quote }} @@ -56,3 +33,7 @@ message_format = interactive.string("message_format", {{ preferences.message_for input_fade_transition = interactive.float("input_fade_transition", {{ preferences.input_fade_transition }}) %include "{{ paths.lib_filepath }}" + +{% include "outputs.liq.j2" %} + +gateway("started") diff --git a/playout/libretime_playout/liquidsoap/templates/outputs.liq.j2 b/playout/libretime_playout/liquidsoap/templates/outputs.liq.j2 new file mode 100644 index 000000000..c17d15824 --- /dev/null +++ b/playout/libretime_playout/liquidsoap/templates/outputs.liq.j2 @@ -0,0 +1,142 @@ +{#- + Build an audio encoder usable by the icecast or shoutcast output functions, + using the output audio configuration +#} +{%- macro icecast_encoder(audio) -%} + +{%- if audio.format == "ogg" -%} +{%- set quality_mapping = { + 32: "-0.1", 48: "-0.1", 64: "0", 96: "0.2", 128: "0.4", + 160: "0.5", 192: "0.6", 224: "0.7", 256: "0.8", 320: "0.9", +} -%} +%vorbis( + quality={{ quality_mapping[audio.bitrate] }}, + channels={{ 2 if audio.channels == "stereo" else 1 }} +) + +{%- elif audio.format == "mp3" -%} +%mp3( + bitrate={{ audio.bitrate }}, + stereo={{ "true" if audio.channels == "stereo" else "false" }} +) + +{%- elif audio.format == "opus" -%} +%opus( + bitrate={{ audio.bitrate }}, + channels={{ 2 if audio.channels == "stereo" else 1 }}, + signal="music", + application="audio", + complexity=10, + vbr="constrained" +) + +{%- elif audio.format == "aac" -%} +%fdkaac( + bitrate=bitrate={{ audio.bitrate }}, + aot={{ "mpeg4_he_aac_v2" if audio.bitrate <= 64 else "mpeg4_aac_lc" }}, + afterburner={{ "false" if audio.bitrate <= 128 else "true" }}, + sbr_mode=true +) + +{%- endif -%} +{%- endmacro -%} + +{#- + Build an icecast output the output configuration. +#} +{%- macro output_icecast(output_id, output) -%} +# icecast:{{ output_id }} +{#- Handle stereo or mono output #} +{% if output.audio.channels == "stereo" -%} +output_icecast_{{ output_id }}_source = s +{% else -%} +output_icecast_{{ output_id }}_source = mean(s) +{% endif -%} + +output.icecast( + id="icecast:{{ output_id }}", + host={{ output.host | quote }}, + port={{ output.port }}, + mount={{ output.mount | quote }}, + user={{ output.source_user | quote }}, + password={{ output.source_password | quote }}, + fallible = true, + name={{ (output.name or '') | quote }}, + description={{ (output.description or '') | quote }}, + genre={{ (output.genre or '') | quote }}, + url={{ (output.website or '') | quote }}, + on_connect=make_ouput_on_connect_handler("{{ output_id }}"), + on_error=make_ouput_on_error_handler("{{ output_id }}"), + {{ icecast_encoder(output.audio) | indent(width=2) }}, + output_icecast_{{ output_id }}_source, +) +{%- endmacro -%} + +{#- + Build a shoutcast output the output configuration. +#} +{%- macro output_shoutcast(output_id, output) -%} +# shoutcast:{{ output_id }} +{#- Handle stereo or mono output #} +{% if output.audio.channels == "stereo" -%} +output_shoutcast_{{ output_id }}_source = s +{% else -%} +output_shoutcast_{{ output_id }}_source = mean(s) +{% endif -%} + +output.shoutcast( + id="shoutcast:{{ output_id }}", + host={{ output.host | quote }}, + port={{ output.port }}, +{#- Shoutcast does not have any mount + mount={{ output.mount | quote }}, +#} + user={{ output.source_user | quote }}, + password={{ output.source_password | quote }}, + fallible = true, +{#- Pass output.description to name and ignore output.name + name={{ (output.name or '') | quote }}, + description={{ (output.description or '') | quote }}, +#} + name={{ (output.description or '') | quote }}, + genre={{ (output.genre or '') | quote }}, + url={{ (output.website or '') | quote }}, + on_connect=make_ouput_on_connect_handler("{{ output_id }}"), + on_error=make_ouput_on_error_handler("{{ output_id }}"), +{#- + The config validation will prevent from using incompatible audio encoders +#} + {{ icecast_encoder(output.audio) | indent(width=2) }}, + output_shoutcast_{{ output_id }}_source, +) +{%- endmacro -%} + +{% for output in config.stream.outputs.system -%} +{% if output.enabled -%} +# {{ output.kind.value }}:{{ loop.index }} +%ifdef output.{{ output.kind.value }} +output.{{ output.kind.value }}(id="{{ output.kind.value }}:{{ loop.index }}", s) +%else +log("output.{{ output.kind.value }} is not defined!") +%endif + +{% endif -%} +{% endfor -%} + +{% for output in config.stream.outputs.icecast -%} +{% if output.enabled -%} +{{ output_icecast(loop.index, output) }} + +{% endif -%} +{% endfor -%} + +{% for output in config.stream.outputs.shoutcast -%} +{% if output.enabled -%} +{# + Icecast and Shoutcast streams are merged in legacy, so we need to use a custom index + as stream id. +-#} +{{ output_shoutcast((config.stream.outputs.icecast | length) + loop.index, output) }} + +{% endif -%} +{% endfor -%} diff --git a/playout/tests/liquidsoap/__snapshots__/entrypoint_test.ambr b/playout/tests/liquidsoap/__snapshots__/entrypoint_test.ambr index 1287a53f7..f1b057bd1 100644 --- a/playout/tests/liquidsoap/__snapshots__/entrypoint_test.ambr +++ b/playout/tests/liquidsoap/__snapshots__/entrypoint_test.ambr @@ -11,84 +11,9 @@ input_show_mount = "show" input_show_port = 8002 - # Output s1 - s1_enable = false - s1_output = "icecast" - s1_host = "localhost" - s1_port = 8000 - s1_mount = "" - s1_user = "source" - s1_pass = "" - - s1_channels = "stereo" - s1_type = "ogg" - s1_bitrate = 256 - - s1_name = "" - s1_description = "" - s1_genre = "" - s1_url = "" - - # Output s2 - s2_enable = false - s2_output = "icecast" - s2_host = "localhost" - s2_port = 8000 - s2_mount = "" - s2_user = "source" - s2_pass = "" - - s2_channels = "stereo" - s2_type = "ogg" - s2_bitrate = 256 - - s2_name = "" - s2_description = "" - s2_genre = "" - s2_url = "" - - # Output s3 - s3_enable = false - s3_output = "icecast" - s3_host = "localhost" - s3_port = 8000 - s3_mount = "" - s3_user = "source" - s3_pass = "" - - s3_channels = "stereo" - s3_type = "ogg" - s3_bitrate = 256 - - s3_name = "" - s3_description = "" - s3_genre = "" - s3_url = "" - - # Output s4 - s4_enable = false - s4_output = "icecast" - s4_host = "localhost" - s4_port = 8000 - s4_mount = "" - s4_user = "source" - s4_pass = "" - - s4_channels = "stereo" - s4_type = "ogg" - s4_bitrate = 256 - - s4_name = "" - s4_description = "" - s4_genre = "" - s4_url = "" - + # Outputs icecast_vorbis_metadata = false - # System output - output_sound_device = false - output_sound_device_type = "alsa" - # Settings auth_path = "/fake/liquidsoap_auth.py" @@ -108,6 +33,10 @@ %include "/fake/1.4/ls_script.liq" + + + gateway("started") + ''' # --- # name: test_generate_entrypoint[stream_config1-1.4] @@ -122,84 +51,9 @@ input_show_mount = "show" input_show_port = 8002 - # Output s1 - s1_enable = true - s1_output = "icecast" - s1_host = "localhost" - s1_port = 8000 - s1_mount = "main" - s1_user = "source" - s1_pass = "hackme" - - s1_channels = "stereo" - s1_type = "ogg" - s1_bitrate = 256 - - s1_name = "LibreTime!" - s1_description = "LibreTime Radio! Stream #1" - s1_genre = "various" - s1_url = "https://libretime.org" - - # Output s2 - s2_enable = false - s2_output = "icecast" - s2_host = "localhost" - s2_port = 8000 - s2_mount = "second" - s2_user = "source" - s2_pass = "hackme" - - s2_channels = "stereo" - s2_type = "mp3" - s2_bitrate = 256 - - s2_name = "" - s2_description = "" - s2_genre = "" - s2_url = "" - - # Output s3 - s3_enable = false - s3_output = "icecast" - s3_host = "localhost" - s3_port = 8000 - s3_mount = "" - s3_user = "source" - s3_pass = "" - - s3_channels = "stereo" - s3_type = "ogg" - s3_bitrate = 256 - - s3_name = "" - s3_description = "" - s3_genre = "" - s3_url = "" - - # Output s4 - s4_enable = false - s4_output = "icecast" - s4_host = "localhost" - s4_port = 8000 - s4_mount = "" - s4_user = "source" - s4_pass = "" - - s4_channels = "stereo" - s4_type = "ogg" - s4_bitrate = 256 - - s4_name = "" - s4_description = "" - s4_genre = "" - s4_url = "" - + # Outputs icecast_vorbis_metadata = false - # System output - output_sound_device = false - output_sound_device_type = "alsa" - # Settings auth_path = "/fake/liquidsoap_auth.py" @@ -219,6 +73,33 @@ %include "/fake/1.4/ls_script.liq" + # icecast:1 + output_icecast_1_source = s + output.icecast( + id="icecast:1", + host="localhost", + port=8000, + mount="main", + user="source", + password="hackme", + fallible = true, + name="LibreTime!", + description="LibreTime Radio! Stream #1", + genre="various", + url="https://libretime.org", + on_connect=make_ouput_on_connect_handler("1"), + on_error=make_ouput_on_error_handler("1"), + %vorbis( + quality=0.8, + channels=2 + ), + output_icecast_1_source, + ) + + + + gateway("started") + ''' # --- # name: test_generate_entrypoint[stream_config2-1.4] @@ -233,84 +114,9 @@ input_show_mount = "show" input_show_port = 8002 - # Output s1 - s1_enable = false - s1_output = "icecast" - s1_host = "localhost" - s1_port = 8000 - s1_mount = "" - s1_user = "source" - s1_pass = "" - - s1_channels = "stereo" - s1_type = "ogg" - s1_bitrate = 256 - - s1_name = "" - s1_description = "" - s1_genre = "" - s1_url = "" - - # Output s2 - s2_enable = false - s2_output = "icecast" - s2_host = "localhost" - s2_port = 8000 - s2_mount = "" - s2_user = "source" - s2_pass = "" - - s2_channels = "stereo" - s2_type = "ogg" - s2_bitrate = 256 - - s2_name = "" - s2_description = "" - s2_genre = "" - s2_url = "" - - # Output s3 - s3_enable = false - s3_output = "icecast" - s3_host = "localhost" - s3_port = 8000 - s3_mount = "" - s3_user = "source" - s3_pass = "" - - s3_channels = "stereo" - s3_type = "ogg" - s3_bitrate = 256 - - s3_name = "" - s3_description = "" - s3_genre = "" - s3_url = "" - - # Output s4 - s4_enable = true - s4_output = "shoutcast" - s4_host = "localhost" - s4_port = 8000 - s4_mount = "" - s4_user = "source" - s4_pass = "hackme" - - s4_channels = "stereo" - s4_type = "mp3" - s4_bitrate = 256 - - s4_name = "LibreTime!" - s4_description = "" - s4_genre = "various" - s4_url = "https://libretime.org" - + # Outputs icecast_vorbis_metadata = false - # System output - output_sound_device = false - output_sound_device_type = "alsa" - # Settings auth_path = "/fake/liquidsoap_auth.py" @@ -330,6 +136,31 @@ %include "/fake/1.4/ls_script.liq" + # shoutcast:1 + output_shoutcast_1_source = s + output.shoutcast( + id="shoutcast:1", + host="localhost", + port=8000, + user="source", + password="hackme", + fallible = true, + name="", + genre="various", + url="https://libretime.org", + on_connect=make_ouput_on_connect_handler("1"), + on_error=make_ouput_on_error_handler("1"), + %mp3( + bitrate=256, + stereo=true + ), + output_shoutcast_1_source, + ) + + + + gateway("started") + ''' # --- # name: test_generate_entrypoint[stream_config3-1.4] @@ -344,84 +175,9 @@ input_show_mount = "show" input_show_port = 8002 - # Output s1 - s1_enable = true - s1_output = "icecast" - s1_host = "localhost" - s1_port = 8000 - s1_mount = "main" - s1_user = "source" - s1_pass = "hackme" - - s1_channels = "stereo" - s1_type = "ogg" - s1_bitrate = 256 - - s1_name = "" - s1_description = "" - s1_genre = "" - s1_url = "" - - # Output s2 - s2_enable = false - s2_output = "icecast" - s2_host = "localhost" - s2_port = 8000 - s2_mount = "" - s2_user = "source" - s2_pass = "" - - s2_channels = "stereo" - s2_type = "ogg" - s2_bitrate = 256 - - s2_name = "" - s2_description = "" - s2_genre = "" - s2_url = "" - - # Output s3 - s3_enable = false - s3_output = "icecast" - s3_host = "localhost" - s3_port = 8000 - s3_mount = "" - s3_user = "source" - s3_pass = "" - - s3_channels = "stereo" - s3_type = "ogg" - s3_bitrate = 256 - - s3_name = "" - s3_description = "" - s3_genre = "" - s3_url = "" - - # Output s4 - s4_enable = true - s4_output = "shoutcast" - s4_host = "localhost" - s4_port = 8000 - s4_mount = "" - s4_user = "source" - s4_pass = "hackme" - - s4_channels = "stereo" - s4_type = "mp3" - s4_bitrate = 256 - - s4_name = "" - s4_description = "" - s4_genre = "" - s4_url = "" - + # Outputs icecast_vorbis_metadata = false - # System output - output_sound_device = false - output_sound_device_type = "alsa" - # Settings auth_path = "/fake/liquidsoap_auth.py" @@ -441,6 +197,54 @@ %include "/fake/1.4/ls_script.liq" + # icecast:1 + output_icecast_1_source = s + output.icecast( + id="icecast:1", + host="localhost", + port=8000, + mount="main", + user="source", + password="hackme", + fallible = true, + name="", + description="", + genre="", + url="", + on_connect=make_ouput_on_connect_handler("1"), + on_error=make_ouput_on_error_handler("1"), + %vorbis( + quality=0.8, + channels=2 + ), + output_icecast_1_source, + ) + + # shoutcast:2 + output_shoutcast_2_source = s + output.shoutcast( + id="shoutcast:2", + host="localhost", + port=8000, + user="source", + password="hackme", + fallible = true, + name="", + genre="", + url="", + on_connect=make_ouput_on_connect_handler("2"), + on_error=make_ouput_on_error_handler("2"), + %mp3( + bitrate=256, + stereo=true + ), + output_shoutcast_2_source, + ) + + + + gateway("started") + ''' # --- # name: test_generate_entrypoint[stream_config4-1.4] @@ -455,84 +259,9 @@ input_show_mount = "show" input_show_port = 8002 - # Output s1 - s1_enable = false - s1_output = "icecast" - s1_host = "localhost" - s1_port = 8000 - s1_mount = "" - s1_user = "source" - s1_pass = "" - - s1_channels = "stereo" - s1_type = "ogg" - s1_bitrate = 256 - - s1_name = "" - s1_description = "" - s1_genre = "" - s1_url = "" - - # Output s2 - s2_enable = false - s2_output = "icecast" - s2_host = "localhost" - s2_port = 8000 - s2_mount = "" - s2_user = "source" - s2_pass = "" - - s2_channels = "stereo" - s2_type = "ogg" - s2_bitrate = 256 - - s2_name = "" - s2_description = "" - s2_genre = "" - s2_url = "" - - # Output s3 - s3_enable = false - s3_output = "icecast" - s3_host = "localhost" - s3_port = 8000 - s3_mount = "" - s3_user = "source" - s3_pass = "" - - s3_channels = "stereo" - s3_type = "ogg" - s3_bitrate = 256 - - s3_name = "" - s3_description = "" - s3_genre = "" - s3_url = "" - - # Output s4 - s4_enable = false - s4_output = "icecast" - s4_host = "localhost" - s4_port = 8000 - s4_mount = "" - s4_user = "source" - s4_pass = "" - - s4_channels = "stereo" - s4_type = "ogg" - s4_bitrate = 256 - - s4_name = "" - s4_description = "" - s4_genre = "" - s4_url = "" - + # Outputs icecast_vorbis_metadata = false - # System output - output_sound_device = true - output_sound_device_type = "pulseaudio" - # Settings auth_path = "/fake/liquidsoap_auth.py" @@ -552,6 +281,17 @@ %include "/fake/1.4/ls_script.liq" + # pulseaudio:1 + %ifdef output.pulseaudio + output.pulseaudio(id="pulseaudio:1", s) + %else + log("output.pulseaudio is not defined!") + %endif + + + + gateway("started") + ''' # --- # name: test_generate_entrypoint[stream_config5-1.4] @@ -566,84 +306,9 @@ input_show_mount = "show" input_show_port = 8002 - # Output s1 - s1_enable = false - s1_output = "icecast" - s1_host = "localhost" - s1_port = 8000 - s1_mount = "" - s1_user = "source" - s1_pass = "" - - s1_channels = "stereo" - s1_type = "ogg" - s1_bitrate = 256 - - s1_name = "" - s1_description = "" - s1_genre = "" - s1_url = "" - - # Output s2 - s2_enable = false - s2_output = "icecast" - s2_host = "localhost" - s2_port = 8000 - s2_mount = "" - s2_user = "source" - s2_pass = "" - - s2_channels = "stereo" - s2_type = "ogg" - s2_bitrate = 256 - - s2_name = "" - s2_description = "" - s2_genre = "" - s2_url = "" - - # Output s3 - s3_enable = false - s3_output = "icecast" - s3_host = "localhost" - s3_port = 8000 - s3_mount = "" - s3_user = "source" - s3_pass = "" - - s3_channels = "stereo" - s3_type = "ogg" - s3_bitrate = 256 - - s3_name = "" - s3_description = "" - s3_genre = "" - s3_url = "" - - # Output s4 - s4_enable = false - s4_output = "icecast" - s4_host = "localhost" - s4_port = 8000 - s4_mount = "" - s4_user = "source" - s4_pass = "" - - s4_channels = "stereo" - s4_type = "ogg" - s4_bitrate = 256 - - s4_name = "" - s4_description = "" - s4_genre = "" - s4_url = "" - + # Outputs icecast_vorbis_metadata = false - # System output - output_sound_device = false - output_sound_device_type = "alsa" - # Settings auth_path = "/fake/liquidsoap_auth.py" @@ -663,5 +328,9 @@ %include "/fake/1.4/ls_script.liq" + + + gateway("started") + ''' # ---