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

Refact: Liquidsoap 2.1 compatiblity

parent a67ba8b1
No related branches found
No related tags found
1 merge request!3Liquidsoap 2 migration
...@@ -72,47 +72,29 @@ def stream_to_icecast(id, encoding, bitrate, host, port, pass, mount_point, url, ...@@ -72,47 +72,29 @@ def stream_to_icecast(id, encoding, bitrate, host, port, pass, mount_point, url,
log("Successfully connected to stream_#{streamnumber}") log("Successfully connected to stream_#{streamnumber}")
end end
stereo = (int_of_string(channels) >= 2)
user_ref = ref (user) user_ref = ref (user)
if user == "" then if user == "" then
user_ref := "source" user_ref := "source"
end end
# Liquidsoap cannot handle one output definition for mono and stereo # TODO Refactor all outgoing stream formats this way
output_icecast_mono = output.icecast(id = id, 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, icy_metadata = "true") let stereo = (int_of_string(channels) >= 2)
output_icecast_stereo = output.icecast(id = id, 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, icy_metadata = "true") let format = %mp3(bitrate = 128, stereo = true)
# %ifencoder %aac
# if encoding == "aac" then
# log("ENABLING AAC to ICECAST")
# %include "outgoing_streams/aac.liq"
# end
# %endif
#
# %ifencoder %flac
# if encoding == "flac" then
# log("ENABLING FLAC to ICECAST")
# %include "outgoing_streams/flac.liq"
# end
# %endif
if encoding == "mp3" then if encoding == "mp3" then
log("ENABLING MP3 to ICECAST")
%include "outgoing_streams/mp3.liq" %include "outgoing_streams/mp3.liq"
end end
if encoding == "ogg" then if encoding == "ogg" then
log("ENABLING OGG to ICECAST")
%include "outgoing_streams/ogg.liq" %include "outgoing_streams/ogg.liq"
end end
# %ifencoder %opus log("Icecast output format: #{encoding} #{bitrate}")
# if encoding == "opus" then # Liquidsoap cannot handle one output definition for mono and stereo
# log("ENABLING OPUS to ICECAST") # FIXME should be working since Liquidsoap 2
# %include "outgoing_streams/opus.liq" output_icecast_mono = output.icecast(id = id, 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, icy_metadata = "true", format, !source)
# end output_icecast_stereo = output.icecast(id = id, 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, icy_metadata = "true", format, !source)
# %endif ignore(output_icecast_mono)
ignore(output_icecast_stereo)
end end
########### ###########
......
...@@ -19,69 +19,91 @@ ...@@ -19,69 +19,91 @@
if bitrate == 24 then if bitrate == 24 then
if stereo then if stereo then
ignore(output_icecast_stereo(%mp3(bitrate = 24, stereo = true), !source)) format = %mp3(bitrate = 24, stereo = true)
ignore(format)
else else
ignore(output_icecast_mono(%mp3(bitrate = 24, stereo = false), mean(!source))) format = %mp3(bitrate = 24, stereo = false)
ignore(format)
end end
elsif bitrate == 32 then elsif bitrate == 32 then
if stereo then if stereo then
ignore(output_icecast_stereo(%mp3(bitrate = 32, stereo = true), !source)) format = %mp3(bitrate = 32, stereo = true)
ignore(format)
else else
ignore(output_icecast_mono(%mp3(bitrate = 32, stereo = false), mean(!source))) format = %mp3(bitrate = 32, stereo = false)
ignore(format)
end end
elsif bitrate == 48 then elsif bitrate == 48 then
if stereo then if stereo then
ignore(output_icecast_stereo(%mp3(bitrate = 48, stereo = true), !source)) format = %mp3(bitrate = 48, stereo = true)
ignore(format)
else else
ignore(output_icecast_mono(%mp3(bitrate = 48, stereo = false), mean(!source))) format = %mp3(bitrate = 48, stereo = false)
ignore(format)
end end
elsif bitrate == 64 then elsif bitrate == 64 then
if stereo then if stereo then
ignore(output_icecast_stereo(%mp3(bitrate = 64, stereo = true), !source)) format = %mp3(bitrate = 64, stereo = true)
ignore(format)
else else
ignore(output_icecast_mono(%mp3(bitrate = 64, stereo = false), mean(!source))) format = %mp3(bitrate = 64, stereo = false)
ignore(format)
end end
elsif bitrate == 96 then elsif bitrate == 96 then
if stereo then if stereo then
ignore(output_icecast_stereo(%mp3(bitrate = 96, stereo = true), !source)) format = %mp3(bitrate = 96, stereo = true)
ignore(format)
else else
ignore(output_icecast_mono(%mp3(bitrate = 96, stereo = false), mean(!source))) format = %mp3(bitrate = 96, stereo = false)
ignore(format)
end end
elsif bitrate == 128 then elsif bitrate == 128 then
if stereo then if stereo then
ignore(output_icecast_stereo(%mp3(bitrate = 128, stereo = true), !source)) format = %mp3(bitrate = 128, stereo = true)
ignore(format)
else else
ignore(output_icecast_mono(%mp3(bitrate = 128, stereo = false), mean(!source))) format = %mp3(bitrate = 128, stereo = false)
ignore(format)
end end
elsif bitrate == 160 then elsif bitrate == 160 then
if stereo then if stereo then
ignore(output_icecast_stereo(%mp3(bitrate = 160, stereo = true), !source)) format = %mp3(bitrate = 160, stereo = true)
ignore(format)
else else
ignore(output_icecast_mono(%mp3(bitrate = 160, stereo = false), mean(!source))) format = %mp3(bitrate = 160, stereo = false)
ignore(format)
end end
elsif bitrate == 192 then elsif bitrate == 192 then
if stereo then if stereo then
ignore(output_icecast_stereo(%mp3(bitrate = 192, stereo = true), !source)) format = %mp3(bitrate = 192, stereo = true)
ignore(format)
else else
ignore(output_icecast_mono(%mp3(bitrate = 192, stereo = false), mean(!source))) format = %mp3(bitrate = 192, stereo = false)
ignore(format)
end end
elsif bitrate == 224 then elsif bitrate == 224 then
if stereo then if stereo then
ignore(output_icecast_stereo(%mp3(bitrate = 224, stereo = true), !source)) format = %mp3(bitrate = 224, stereo = true)
ignore(format)
else else
ignore(output_icecast_mono(%mp3(bitrate = 224, stereo = false), mean(!source))) format = %mp3(bitrate = 224, stereo = false)
ignore(format)
end end
elsif bitrate == 256 then elsif bitrate == 256 then
if stereo then if stereo then
ignore(output_icecast_stereo(%mp3(bitrate = 256, stereo = true), !source)) format = %mp3(bitrate = 256, stereo = true)
ignore(format)
else else
ignore(output_icecast_mono(%mp3(bitrate = 256, stereo = false), mean(!source))) format = %mp3(bitrate = 256, stereo = false)
ignore(format)
end end
elsif bitrate == 320 then elsif bitrate == 320 then
if stereo then if stereo then
ignore(output_icecast_stereo(%mp3(bitrate = 320, stereo = true), !source)) format = %mp3(bitrate = 320, stereo = true)
ignore(format)
else else
ignore(output_icecast_mono(%mp3(bitrate = 320, stereo = false), mean(!source))) format = %mp3(bitrate = 320, stereo = false)
ignore(format)
end end
end end
...@@ -23,57 +23,75 @@ end ...@@ -23,57 +23,75 @@ end
if bitrate == 24 or bitrate == 32 or bitrate == 48 then if bitrate == 24 or bitrate == 32 or bitrate == 48 then
if stereo then if stereo then
ignore(output_icecast_stereo(%vorbis(quality=-0.1, channels = 2), !source)) format = %vorbis(quality=-0.1, channels = 2)
ignore(format)
else else
ignore(output_icecast_mono(%vorbis(quality=-0.1, channels = 1), mean(!source))) format = %vorbis(quality=-0.1, channels = 1)
ignore(format)
end end
elsif bitrate == 64 then elsif bitrate == 64 then
if stereo then if stereo then
ignore(output_icecast_stereo(%vorbis(quality=0, channels = 2), !source)) format = %vorbis(quality=0, channels = 2)
ignore(format)
else else
ignore(output_icecast_mono(%vorbis(quality=0, channels = 1), mean(!source))) format = %vorbis(quality=0, channels = 1)
ignore(format)
end end
elsif bitrate == 96 then elsif bitrate == 96 then
if stereo then if stereo then
ignore(output_icecast_stereo(%vorbis(quality=0.2, channels = 2), !source)) format = %vorbis(quality=0.2, channels = 2)
ignore(format)
else else
ignore(output_icecast_mono(%vorbis(quality=0.2, channels = 1), mean(!source))) format = %vorbis(quality=0.2, channels = 1)
ignore(format)
end end
elsif bitrate == 128 then elsif bitrate == 128 then
if stereo then if stereo then
ignore(output_icecast_stereo(%vorbis(quality=0.4, channels = 2), !source)) format = %vorbis(quality=0.4, channels = 2)
ignore(format)
else else
ignore(output_icecast_mono(%vorbis(quality=0.4, channels = 1), mean(!source))) format = %vorbis(quality=0.4, channels = 1)
ignore(format)
end end
elsif bitrate == 160 then elsif bitrate == 160 then
if stereo then if stereo then
ignore(output_icecast_stereo(%vorbis(quality=0.5, channels = 2), !source)) format = %vorbis(quality=0.5, channels = 2)
ignore(format)
else else
ignore(output_icecast_mono(%vorbis(quality=0.5, channels = 1), mean(!source))) format = %vorbis(quality=0.5, channels = 1)
ignore(format)
end end
elsif bitrate == 192 then elsif bitrate == 192 then
if stereo then if stereo then
ignore(output_icecast_stereo(%vorbis(quality=0.6, channels = 2), !source)) format = %vorbis(quality=0.6, channels = 2)
ignore(format)
else else
ignore(output_icecast_mono(%vorbis(quality=0.6, channels = 1), mean(!source))) format = %vorbis(quality=0.6, channels = 1)
ignore(format)
end end
elsif bitrate == 224 then elsif bitrate == 224 then
if stereo then if stereo then
ignore(output_icecast_stereo(%vorbis(quality=0.7, channels = 2), !source)) format = %vorbis(quality=0.7, channels = 2)
ignore(format)
else else
ignore(output_icecast_mono(%vorbis(quality=0.7, channels = 1), mean(!source))) format = %vorbis(quality=0.7, channels = 1)
ignore(format)
end end
elsif bitrate == 256 then elsif bitrate == 256 then
if stereo then if stereo then
ignore(output_icecast_stereo(%vorbis(quality=0.8, channels = 2), !source)) format = %vorbis(quality=0.8, channels = 2)
ignore(format)
else else
ignore(output_icecast_mono(%vorbis(quality=0.8, channels = 1), mean(!source))) format = %vorbis(quality=0.8, channels = 1)
ignore(format)
end end
elsif bitrate == 320 then elsif bitrate == 320 then
if stereo then if stereo then
ignore(output_icecast_stereo(%vorbis(quality=0.9, channels = 2), !source)) format = %vorbis(quality=0.9, channels = 2)
ignore(format)
else else
ignore(output_icecast_mono(%vorbis(quality=0.9, channels = 1), mean(!source))) format = %vorbis(quality=0.9, channels = 1)
ignore(format)
end end
end end
...@@ -28,7 +28,14 @@ def read_ini(file) ...@@ -28,7 +28,14 @@ def read_ini(file)
# read ini file # read ini file
settings_file_content = process.read.lines("cat "^file ) settings_file_content = process.read.lines("cat "^file )
# one entry stored as ["setting_name", "setting"] # one entry stored as ["setting_name", "setting"]
settings_map = list.map(string.split(separator="="), settings_file_content) # settings_map = list.map(string.split(separator="="), settings_file_content)
def split_line(line)
string.split(line, separator="=")
end
settings_map = list.map(split_line, settings_file_content)
# settings_map = list.map(string.split("#{settings_file_content}", separator="="))
def filter_pair(setting_pair) = def filter_pair(setting_pair) =
if !debug then if !debug then
......
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