diff --git a/modules/liquidsoap/aac.liq b/modules/liquidsoap/aac.liq new file mode 100644 index 0000000000000000000000000000000000000000..6990ea89dfe5eb778ba530ff09495e256b8f1549 --- /dev/null +++ b/modules/liquidsoap/aac.liq @@ -0,0 +1,68 @@ + if bitrate == 24 then + if stereo then + ignore(output_stereo(%aac(bitrate = 24, channels = 2), !source)) + else + ignore(output_mono(%aac(bitrate = 24, channels = 1), mean(!source))) + end + elsif bitrate == 32 then + if stereo then + ignore(output_stereo(%aac(bitrate = 32, channels = 2), !source)) + else + ignore(output_mono(%aac(bitrate = 32, channels = 1), mean(!source))) + end + elsif bitrate == 48 then + if stereo then + ignore(output_stereo(%aac(bitrate = 48, channels = 2), !source)) + else + ignore(output_mono(%aac(bitrate = 48, channels = 1), mean(!source))) + end + elsif bitrate == 64 then + if stereo then + ignore(output_stereo(%aac(bitrate = 64, channels = 2), !source)) + else + ignore(output_mono(%aac(bitrate = 64, channels = 1), mean(!source))) + end + elsif bitrate == 96 then + if stereo then + ignore(output_stereo(%aac(bitrate = 96, channels = 2), !source)) + else + ignore(output_mono(%aac(bitrate = 96, channels = 1), mean(!source))) + end + elsif bitrate == 128 then + if stereo then + ignore(output_stereo(%aac(bitrate = 128, channels = 2), !source)) + else + ignore(output_mono(%aac(bitrate = 128, channels = 1), mean(!source))) + end + elsif bitrate == 160 then + if stereo then + ignore(output_stereo(%aac(bitrate = 160, channels = 2), !source)) + else + ignore(output_mono(%aac(bitrate = 160, channels = 1), mean(!source))) + end + elsif bitrate == 192 then + if stereo then + ignore(output_stereo(%aac(bitrate = 192, channels = 2), !source)) + else + ignore(output_mono(%aac(bitrate = 192, channels = 1), mean(!source))) + end + elsif bitrate == 224 then + if stereo then + ignore(output_stereo(%aac(bitrate = 224, channels = 2), !source)) + else + ignore(output_mono(%aac(bitrate = 224, channels = 1), mean(!source))) + end + elsif bitrate == 256 then + if stereo then + ignore(output_stereo(%aac(bitrate = 256, channels = 2), !source)) + else + ignore(output_mono(%aac(bitrate = 256, channels = 1), mean(!source))) + end + elsif bitrate == 320 then + if stereo then + ignore(output_stereo(%aac(bitrate = 320, channels = 2), !source)) + else + ignore(output_mono(%aac(bitrate = 320, channels = 1), mean(!source))) + end + end + diff --git a/modules/liquidsoap/aacplus.liq b/modules/liquidsoap/aacplus.liq new file mode 100644 index 0000000000000000000000000000000000000000..6cd2545d754274b1de830557c7bf55f284f9c48a --- /dev/null +++ b/modules/liquidsoap/aacplus.liq @@ -0,0 +1,68 @@ + if bitrate == 24 then + if stereo then + ignore(output_stereo(%aacplus(bitrate = 24, channels = 2), !source)) + else + ignore(output_mono(%aacplus(bitrate = 24, channels = 1), mean(!source))) + end + elsif bitrate == 32 then + if stereo then + ignore(output_stereo(%aacplus(bitrate = 32, channels = 2), !source)) + else + ignore(output_mono(%aacplus(bitrate = 32, channels = 1), mean(!source))) + end + elsif bitrate == 48 then + if stereo then + ignore(output_stereo(%aacplus(bitrate = 48, channels = 2), !source)) + else + ignore(output_mono(%aacplus(bitrate = 48, channels = 1), mean(!source))) + end + elsif bitrate == 64 then + if stereo then + ignore(output_stereo(%aacplus(bitrate = 64, channels = 2), !source)) + else + ignore(output_mono(%aacplus(bitrate = 64, channels = 1), mean(!source))) + end + elsif bitrate == 96 then + if stereo then + ignore(output_stereo(%aacplus(bitrate = 96, channels = 2), !source)) + else + ignore(output_mono(%aacplus(bitrate = 96, channels = 1), mean(!source))) + end + elsif bitrate == 128 then + if stereo then + ignore(output_stereo(%aacplus(bitrate = 128, channels = 2), !source)) + else + ignore(output_mono(%aacplus(bitrate = 128, channels = 1), mean(!source))) + end + elsif bitrate == 160 then + if stereo then + ignore(output_stereo(%aacplus(bitrate = 160, channels = 2), !source)) + else + ignore(output_mono(%aacplus(bitrate = 160, channels = 1), mean(!source))) + end + elsif bitrate == 192 then + if stereo then + ignore(output_stereo(%aacplus(bitrate = 192, channels = 2), !source)) + else + ignore(output_mono(%aacplus(bitrate = 192, channels = 1), mean(!source))) + end + elsif bitrate == 224 then + if stereo then + ignore(output_stereo(%aacplus(bitrate = 224, channels = 2), !source)) + else + ignore(output_mono(%aacplus(bitrate = 224, channels = 1), mean(!source))) + end + elsif bitrate == 256 then + if stereo then + ignore(output_stereo(%aacplus(bitrate = 256, channels = 2), !source)) + else + ignore(output_mono(%aacplus(bitrate = 256, channels = 1), mean(!source))) + end + elsif bitrate == 320 then + if stereo then + ignore(output_stereo(%aacplus(bitrate = 320, channels = 2), !source)) + else + ignore(output_mono(%aacplus(bitrate = 320, channels = 1), mean(!source))) + end + end + diff --git a/modules/liquidsoap/engine.liq b/modules/liquidsoap/engine.liq index ddbfbfe20acf27a7473d6bb1f98164b9fd7a3b11..e6e396ec43e6083ee1abed889c5a991e65b2827f 100644 --- a/modules/liquidsoap/engine.liq +++ b/modules/liquidsoap/engine.liq @@ -5,11 +5,17 @@ set("server.telnet", true) set("server.telnet.bind_addr", "0.0.0.0") set("server.telnet.port", 1234) +icecast_vorbis_metadata = false +%include "library.liq" + %include "settings.liq" %include "fallback.liq" -%include "serverfunctions.liq" + +################# # create sources +################# + #input_fs = single(id="fs", "/var/audio/fallback/output.flac") input_fs = request.queue(id="fs") input_http = input.http(id="http", "http://stream.fro.at/fro-128.ogg") @@ -21,14 +27,26 @@ mixer = mix(id="mixer", [input_fs, input_http, input_alsa]) # output source with station_fallback output_source = fallback(track_sensitive=false, [mixer, timeslot_fallback, show_fallback, station_fallback]) -clock.unify([output_source, mixer, show_fallback, timeslot_fallback, station_fallback]) +################# +# create outputs +################# -# create output +# alsa output output.alsa(id="lineout", device="hw:0", bufferize = false, output_source) +clock.unify([output_source, mixer, show_fallback, timeslot_fallback, station_fallback]) + +# recording output %include "recorder.liq" -recorder = get_recorder_output() +set_recorder_output() + +# stream output +%include "stream2.liq" + +%include "serverfunctions.liq" system('#{list.assoc("install_dir", ini)}/guru.py --init-player -q') + + diff --git a/modules/liquidsoap/fdkaac.liq b/modules/liquidsoap/fdkaac.liq new file mode 100644 index 0000000000000000000000000000000000000000..0c6945221c2fca707572a6c41988c8c17ea97f60 --- /dev/null +++ b/modules/liquidsoap/fdkaac.liq @@ -0,0 +1,24 @@ + if bitrate == 24 then + ignore(output_stereo(%fdkaac(bitrate = 24, aot="mpeg4_he_aac_v2"), !source)) + elsif bitrate == 32 then + ignore(output_stereo(%fdkaac(bitrate = 32, aot="mpeg4_he_aac_v2"), !source)) + elsif bitrate == 48 then + ignore(output_stereo(%fdkaac(bitrate = 48, aot="mpeg4_he_aac_v2"), !source)) + elsif bitrate == 64 then + ignore(output_stereo(%fdkaac(bitrate = 64, aot="mpeg4_he_aac_v2"), !source)) + elsif bitrate == 96 then + ignore(output_stereo(%fdkaac(bitrate = 96, aot="mpeg4_he_aac_v2"), !source)) + elsif bitrate == 128 then + ignore(output_stereo(%fdkaac(bitrate = 128, aot="mpeg4_he_aac_v2"), !source)) + elsif bitrate == 160 then + ignore(output_stereo(%fdkaac(bitrate = 160, aot="mpeg4_he_aac_v2"), !source)) + elsif bitrate == 192 then + ignore(output_stereo(%fdkaac(bitrate = 192, aot="mpeg4_he_aac_v2"), !source)) + elsif bitrate == 224 then + ignore(output_stereo(%fdkaac(bitrate = 224, aot="mpeg4_he_aac_v2"), !source)) + elsif bitrate == 256 then + ignore(output_stereo(%fdkaac(bitrate = 256, aot="mpeg4_he_aac_v2"), !source)) + elsif bitrate == 320 then + ignore(output_stereo(%fdkaac(bitrate = 320, aot="mpeg4_he_aac_v2"), !source)) + end + diff --git a/modules/liquidsoap/flac.liq b/modules/liquidsoap/flac.liq new file mode 100644 index 0000000000000000000000000000000000000000..2d9e68f8b27455bcabdc73a8cd2aa02f69b95c40 --- /dev/null +++ b/modules/liquidsoap/flac.liq @@ -0,0 +1,60 @@ + 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(%flac(samplerate=44100, channels = 2, compression = 7, bits_per_sample=8), !source)) + else + ignore(output_mono(%flac(samplerate=44100, channels = 1, compression = 7, bits_per_sample=8), mean(!source))) + end + elsif bitrate == 64 then + if stereo then + ignore(output_stereo(%flac(samplerate=44100, channels = 2, compression = 7, bits_per_sample=8), !source)) + else + ignore(output_mono(%flac(samplerate=44100, channels = 1, compression = 7, bits_per_sample=8), mean(!source))) + end + elsif bitrate == 96 then + if stereo then + ignore(output_stereo(%flac(samplerate=44100, channels = 2, compression = 7, bits_per_sample=8), !source)) + else + ignore(output_mono(%flac(samplerate=44100, channels = 1, compression = 7, bits_per_sample=8), mean(!source))) + end + elsif bitrate == 128 then + if stereo then + ignore(output_stereo(%flac(samplerate=44100, channels = 2, compression = 6, bits_per_sample=16), !source)) + else + ignore(output_mono(%flac(samplerate=44100, channels = 1, compression = 6, bits_per_sample=16), mean(!source))) + end + elsif bitrate == 160 then + if stereo then + ignore(output_stereo(%flac(samplerate=44100, channels = 2, compression = 5, bits_per_sample=16), !source)) + else + ignore(output_mono(%flac(samplerate=44100, channels = 1, compression = 5, bits_per_sample=16), mean(!source))) + end + elsif bitrate == 192 then + if stereo then + ignore(output_stereo(%flac(samplerate=44100, channels = 2, compression = 4, bits_per_sample=16), !source)) + else + ignore(output_mono(%flac(samplerate=44100, channels = 1, compression = 4, bits_per_sample=16), mean(!source))) + end + elsif bitrate == 224 then + if stereo then + ignore(output_stereo(%flac(samplerate=44100, channels = 2, compression = 3, bits_per_sample=32), !source)) + else + ignore(output_mono(%flac(samplerate=44100, channels = 1, compression = 3, bits_per_sample=32), mean(!source))) + end + elsif bitrate == 256 then + if stereo then + ignore(output_stereo(%flac(samplerate=44100, channels = 2, compression = 2, bits_per_sample=32), !source)) + else + ignore(output_mono(%flac(samplerate=44100, channels = 1, compression = 2, bits_per_sample=32), mean(!source))) + end + elsif bitrate == 320 then + if stereo then + ignore(output_stereo(%flac(samplerate=44100, channels = 2, compression = 1, bits_per_sample=32), !source)) + else + ignore(output_mono(%flac(samplerate=44100, channels = 1, compression = 1, bits_per_sample=32), mean(!source))) + end + end + diff --git a/modules/liquidsoap/library.liq b/modules/liquidsoap/library.liq new file mode 100644 index 0000000000000000000000000000000000000000..12baa1649ed029a71428dba7d21ba2d0fad6669a --- /dev/null +++ b/modules/liquidsoap/library.liq @@ -0,0 +1,77 @@ +# time = ref string_of(gettimeofday()) + +def stream_to_icecast(encoding, bitrate, host, port, pass, mount_point, url, description, genre, user, stream, streamnumber, connected, name, channels) = + source = ref stream + def on_error(msg) + connected := "false" + log(msg) + 5. + end + def on_connect() + connected := "true" + log("Successfully connected to stream_#{streamnumber}") + end + + stereo = (channels == "stereo") + + user_ref = ref user + if user == "" then + user_ref := "source" + end + output_mono = output.icecast(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(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 encoding == "mp3" then + %include "mp3.liq" + end + if encoding == "ogg" then + %include "ogg.liq" + end + %ifencoder %opus + if encoding == "opus" then + %include "opus.liq" + end + %endif + %ifencoder %aac + if encoding == "aac" then + %include "aac.liq" + end + %endif + %ifencoder %aacplus + if encoding == "aacplus" then + %include "aacplus.liq" + end + %endif + %ifencoder %fdkaac + if encoding == "fdkaac" then + %include "fdkaac.liq" + end + %endif + %ifencoder %flac + if encoding == "flac" then + %include "flac.liq" + end + %endif +end \ No newline at end of file diff --git a/modules/liquidsoap/lqstest.liq b/modules/liquidsoap/lqstest.liq new file mode 100644 index 0000000000000000000000000000000000000000..04c9a0da82f3e5bf2eb9ca6ae6d0e753a7c48d32 --- /dev/null +++ b/modules/liquidsoap/lqstest.liq @@ -0,0 +1,24 @@ +set("log.file.path", "./<script>.log") + +#%include "readini.liq" +#ini = read_ini("/etc/aura/engine.ini") + +# output_source = mksafe(blank()) + +# %include "stream.liq" + +# stream = get_stream(0) + +# output_stream = input.external("arecord -f S16_LE -c2 -r44100 -t raw -D dsnoop:1,0 -") + +output.icecast( + %vorbis(quality = 0.5), + mount="aura-test.ogg", + host="develop.servus.at", + port=8000, + name="LQSTest", + user="source", + password="A7E7tst1", + fallible=true, + input.alsa(device="pcm.plugj") +) diff --git a/modules/liquidsoap/mp3.liq b/modules/liquidsoap/mp3.liq new file mode 100644 index 0000000000000000000000000000000000000000..0d96632be93a76105f60dcc1e3f8d14423197659 --- /dev/null +++ b/modules/liquidsoap/mp3.liq @@ -0,0 +1,68 @@ + 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/modules/liquidsoap/ogg.liq b/modules/liquidsoap/ogg.liq new file mode 100644 index 0000000000000000000000000000000000000000..089e777b8ce15b3e3803bde34ccce12b4411b529 --- /dev/null +++ b/modules/liquidsoap/ogg.liq @@ -0,0 +1,60 @@ + 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/modules/liquidsoap/opus.liq b/modules/liquidsoap/opus.liq new file mode 100644 index 0000000000000000000000000000000000000000..3ad6f6c550e1e63341f6db68be70fc5489ae2abc --- /dev/null +++ b/modules/liquidsoap/opus.liq @@ -0,0 +1,68 @@ + 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/modules/liquidsoap/recorder.liq b/modules/liquidsoap/recorder.liq index ce2939555c5affda21fee3d7ac6d8f57e4759103..414ec5a516f15dfe8fafc689f621f51c57b31e54 100644 --- a/modules/liquidsoap/recorder.liq +++ b/modules/liquidsoap/recorder.liq @@ -84,7 +84,7 @@ def enable_stop_function(record) end end -def get_recorder_output() +def set_recorder_output() # flac output if rec_filetype == 'flac' then log("output file type is FLAC") @@ -104,6 +104,7 @@ def get_recorder_output() end end +# shows current file and how many bytes were written so far def currecording() curfile = !recordingfile if curfile != "" then @@ -114,6 +115,7 @@ def currecording() end end +# register socket server command server.register(namespace="record", description="Show current file.", usage="curfile", diff --git a/modules/liquidsoap/serverfunctions.liq b/modules/liquidsoap/serverfunctions.liq index 772b4a0d98153bdf0fcf17483ee07e01973bf936..b2aa3fa5518219d52fed484dda026ecd99061add 100644 --- a/modules/liquidsoap/serverfunctions.liq +++ b/modules/liquidsoap/serverfunctions.liq @@ -3,4 +3,16 @@ # description="shutdown server", # usage="stop", # "stop", -# fun(x,y) -> shutdown ) \ No newline at end of file +# fun(x,y) -> shutdown ) + +def toggle_stream_connection(_) = + "" +end + +#server.register(namespace="streams", +# "connection_status", +# fun (s) -> begin +# log("streams.connection_status") +# "1:#{!s0_connected}, 2:#{!s1_connected}, 3:#{!s2_connected}, 4:#{!s3_connected}, 5:#{!s4_connected}" +# end +# ) \ No newline at end of file diff --git a/modules/liquidsoap/settings.liq b/modules/liquidsoap/settings.liq index 5fca0550da4a68e511480b37fd53d16c2c7457ef..ec5158cc350e25e5b0a2a7669bdb6ac81addf7c6 100644 --- a/modules/liquidsoap/settings.liq +++ b/modules/liquidsoap/settings.liq @@ -47,4 +47,5 @@ if use_alsa then print("setting alsa.periods to #{alsa_periods}") set("alsa.periods", alsa_periods) # assertion error when setting periods other than 0 => alsa default end -end \ No newline at end of file +end + diff --git a/modules/liquidsoap/stream.liq b/modules/liquidsoap/stream.liq new file mode 100644 index 0000000000000000000000000000000000000000..c743156a8b40696fd1dca91c075d7c7de6d10fca --- /dev/null +++ b/modules/liquidsoap/stream.liq @@ -0,0 +1,125 @@ + +def get_icecast_mp3_stream(number) + stream_bitrate = int_of_string(list.assoc("stream_#{number}_bitrate", ini)) + stream_mountpoint = list.assoc("stream_#{number}_mountpoint", ini) + stream_host = list.assoc("stream_#{number}_host", ini) + stream_port = int_of_string(list.assoc("stream_#{number}_port", ini)) + stream_name = list.assoc("stream_#{number}_name", ini) + stream_url = list.assoc("stream_#{number}_url", ini) + stream_genre = list.assoc("stream_#{number}_genre", ini) + stream_description = list.assoc("stream_#{number}_description", ini) + stream_user = list.assoc("stream_#{number}_user", ini) + stream_password = list.assoc("stream_#{number}_password", ini) + + + + if stream_bitrate == 24 then + icecast_stream = output.icecast(%mp3(bitrate = 24, samplerate = 22050), mount=stream_mountpoint, host=stream_host, port=stream_port, name=stream_name, url=stream_url, genre=stream_genre, description=stream_description, user=stream_user, password=stream_password, icy_metadata="true", fallible=true, buffer(output_source)) + clock.assign_new(id="stream_#{number}", + [icecast_stream] + ) + icecast_stream + else + icecast_stream = output.icecast(%mp3(samplerate = 44100), mount=stream_mountpoint, host=stream_host, port=stream_port, name=stream_name, url=stream_url, genre=stream_genre, description=stream_description, user=stream_user, password=stream_password, icy_metadata="true", fallible=true, buffer(output_source)) + clock.assign_new(id="stream_#{number}", + [icecast_stream] + ) + icecast_stream + end +end + +def get_icecast_ogg_stream(number) + stream_quality = float_of_string(list.assoc("stream_#{number}_quality", ini)) + + stream_mountpoint = list.assoc("stream_#{number}_mountpoint", ini) + stream_host = list.assoc("stream_#{number}_host", ini) + stream_port = int_of_string(list.assoc("stream_#{number}_port", ini)) + stream_name = list.assoc("stream_#{number}_name", ini) + stream_url = list.assoc("stream_#{number}_url", ini) + stream_genre = list.assoc("stream_#{number}_genre", ini) + stream_description = list.assoc("stream_#{number}_description", ini) + stream_user = list.assoc("stream_#{number}_user", ini) + stream_password = list.assoc("stream_#{number}_password", ini) + + if stream_quality >= 0.5 then + icecast_stream = output.icecast(%vorbis(quality = 1.0), mount=stream_mountpoint, host=stream_host, port=stream_port, name=stream_name, url=stream_url, genre=stream_genre, description=stream_description, user=stream_user, password=stream_password, icy_metadata="true", fallible=true, buffer(output_source)) + clock.assign_new(id="stream_#{number}", + [icecast_stream] + ) + icecast_stream + else + icecast_stream = output.icecast(%vorbis(quality = 0.1), mount=stream_mountpoint, host=stream_host, port=stream_port, name=stream_name, url=stream_url, genre=stream_genre, description=stream_description, user=stream_user, password=stream_password, icy_metadata="true", fallible=true, buffer(output_source)) + clock.assign_new(id="stream_#{number}", + [icecast_stream] + ) + icecast_stream + end +end + +def get_harbour_mp3_stream(number) + + stream_bitrate = int_of_string(list.assoc("stream_#{number}_bitrate", ini)) + stream_user = list.assoc("stream_#{number}_user", ini) + stream_password = list.assoc("stream_#{number}_password", ini) + stream_port = int_of_string(list.assoc("stream_#{number}_port", ini)) + stream_url = list.assoc("stream_#{number}_url", ini) + stream_mountpoint = list.assoc("stream_#{number}_mountpoint", ini) + + if stream_bitrate == 24 then + harbourstream = output.harbor(%mp3(bitrate = 24, samplerate = 22050), user=stream_user, password=stream_password, id="stream", port=stream_port, url=stream_url, mount=stream_mountpoint, icy_metadata="true", fallible=true, buffer(output_source)) + clock.assign_new(id="stream_#{number}", + [harbourstream] + ) + harbourstream + else + harbourstream = output.harbor(%mp3, user=stream_user, password=stream_password, id="stream", port=stream_port, url=stream_url, mount=stream_mountpoint, icy_metadata="true", fallible=true, buffer(output_source)) + clock.assign_new(id="stream_#{number}", + [harbourstream] + ) + harbourstream + end +end + +def get_stream(number) + stream = list.assoc("stream_#{number}", ini) + stream_type = list.assoc("stream_#{number}_type", ini) + stream_format = list.assoc("stream_#{number}_format", ini) + + # is stream enabled? + if stream == "y" then + log("activating stream #{number}") + if stream_type == "icecast" then + log("its an icecast stream") + if stream_format == "mp3" then + log("filled with mp3") + get_icecast_mp3_stream(number) + elsif stream_format == "vorbis" then + log("filled with ogg") + get_icecast_ogg_stream(number) + else + output.dummy(blank()) + end + + elsif stream_type == "harbor" then + log("its an harbor stream") + if stream_format == "mp3" then + get_harbour_mp3_stream(number) + else + output.dummy(blank()) + end + else + output.dummy(blank()) + end + else + output.dummy(blank()) + end +end + +def set_streams() + stream_0 = get_stream(0) + #stream_1 = get_stream(1) + #stream_2 = get_stream(2) + #stream_3 = get_stream(3) + #stream_4 = get_stream(4) +end + diff --git a/modules/liquidsoap/stream2.liq b/modules/liquidsoap/stream2.liq new file mode 100644 index 0000000000000000000000000000000000000000..ffe08aaeaa2497482bf96f49d55638eb9fad4dd8 --- /dev/null +++ b/modules/liquidsoap/stream2.liq @@ -0,0 +1,111 @@ + +# Output streaming settings +# What a mess... +s0_enable = list.assoc("stream_0", ini) == "y" +s1_enable = list.assoc("stream_1", ini) == "y" +s2_enable = list.assoc("stream_2", ini) == "y" +s3_enable = list.assoc("stream_3", ini) == "y" +s4_enable = list.assoc("stream_4", ini) == "y" + +s0_encoding = list.assoc("stream_0_encoding", ini) +s0_bitrate = int_of_string(list.assoc("stream_0_bitrate", ini)) +s0_host = list.assoc("stream_0_host", ini) +s0_port = int_of_string(list.assoc("stream_0_port", ini)) +s0_user = list.assoc("stream_0_user", ini) +s0_pass = list.assoc("stream_0_pass", ini) +s0_mount = list.assoc("stream_0_mountpoint", ini) +s0_url = list.assoc("stream_0_displayurl", ini) +s0_desc = list.assoc("stream_0_description", ini) +s0_genre = list.assoc("stream_0_genre", ini) +s0_name = list.assoc("stream_0_name", ini) +s0_channels = list.assoc("stream_0_channels", ini) + +s1_encoding = list.assoc("stream_1_encoding", ini) +s1_bitrate = int_of_string(list.assoc("stream_1_bitrate", ini)) +s1_host = list.assoc("stream_1_host", ini) +s1_port = int_of_string(list.assoc("stream_1_port", ini)) +s1_user = list.assoc("stream_1_user", ini) +s1_pass = list.assoc("stream_1_pass", ini) +s1_mount = list.assoc("stream_1_mountpoint", ini) +s1_url = list.assoc("stream_1_displayurl", ini) +s1_desc = list.assoc("stream_1_description", ini) +s1_genre = list.assoc("stream_1_genre", ini) +s1_name = list.assoc("stream_1_name", ini) +s1_channels = list.assoc("stream_1_channels", ini) + +s2_encoding = list.assoc("stream_2_encoding", ini) +s2_bitrate = int_of_string(list.assoc("stream_2_bitrate", ini)) +s2_host = list.assoc("stream_2_host", ini) +s2_port = int_of_string(list.assoc("stream_2_port", ini)) +s2_user = list.assoc("stream_2_user", ini) +s2_pass = list.assoc("stream_2_pass", ini) +s2_mount = list.assoc("stream_2_mountpoint", ini) +s2_url = list.assoc("stream_2_displayurl", ini) +s2_desc = list.assoc("stream_2_description", ini) +s2_genre = list.assoc("stream_2_genre", ini) +s2_name = list.assoc("stream_2_name", ini) +s2_channels = list.assoc("stream_2_channels", ini) + +s3_encoding = list.assoc("stream_3_encoding", ini) +s3_bitrate = int_of_string(list.assoc("stream_3_bitrate", ini)) +s3_host = list.assoc("stream_3_host", ini) +s3_port = int_of_string(list.assoc("stream_3_port", ini)) +s3_user = list.assoc("stream_3_user", ini) +s3_pass = list.assoc("stream_3_pass", ini) +s3_mount = list.assoc("stream_3_mountpoint", ini) +s3_url = list.assoc("stream_3_displayurl", ini) +s3_desc = list.assoc("stream_3_description", ini) +s3_genre = list.assoc("stream_3_genre", ini) +s3_name = list.assoc("stream_3_name", ini) +s3_channels = list.assoc("stream_3_channels", ini) + +s4_encoding = list.assoc("stream_4_encoding", ini) +s4_bitrate = int_of_string(list.assoc("stream_4_bitrate", ini)) +s4_host = list.assoc("stream_4_host", ini) +s4_port = int_of_string(list.assoc("stream_4_port", ini)) +s4_user = list.assoc("stream_4_user", ini) +s4_pass = list.assoc("stream_4_pass", ini) +s4_mount = list.assoc("stream_4_mountpoint", ini) +s4_url = list.assoc("stream_4_displayurl", ini) +s4_desc = list.assoc("stream_4_description", ini) +s4_genre = list.assoc("stream_4_genre", ini) +s4_name = list.assoc("stream_4_name", ini) +s4_channels = list.assoc("stream_4_channels", ini) + +s0_connected = ref '' +s1_connected = ref '' +s2_connected = ref '' +s3_connected = ref '' +s4_connected = ref '' + +# s1_namespace := "icecast" +# s0_output = list.assoc("stream_0_type", ini) + + +if s0_enable == true then + # enable connection status for that stream + server.register(namespace="stream_0", "connected", fun (s) -> begin !s0_connected end) + + # aaand stream + stream_to_icecast(s0_encoding, s0_bitrate, s0_host, s0_port, s0_pass, s0_mount, s0_url, s0_desc, s0_genre, s0_user, output_source, "0", s0_connected, s0_name, s0_channels) +end + +if s1_enable == true then + server.register(namespace="stream_1", "connected", fun (s) -> begin !s1_connected end) + stream_to_icecast(s1_encoding, s1_bitrate, s1_host, s1_port, s1_pass, s1_mount, s1_url, s1_desc, s1_genre, s1_user, output_source, "1", s1_connected, s1_name, s1_channels) +end + +if s2_enable == true then + server.register(namespace="stream_2", "connected", fun (s) -> begin !s2_connected end) + stream_to_icecast(s2_encoding, s2_bitrate, s2_host, s2_port, s2_pass, s2_mount, s2_url, s2_desc, s2_genre, s2_user, output_source, "2", s2_connected, s2_name, s2_channels) +end + +if s3_enable == true then + server.register(namespace="stream_3", "connected", fun (s) -> begin !s3_connected end) + stream_to_icecast(s3_encoding, s3_bitrate, s3_host, s3_port, s3_pass, s3_mount, s3_url, s3_desc, s3_genre, s3_user, output_source, "3", s3_connected, s3_name, s3_channels) +end + +if s4_enable == true then + server.register(namespace="stream_4", "connected", fun (s) -> begin !s4_connected end) + stream_to_icecast(s4_encoding, s4_bitrate, s4_host, s4_port, s4_pass, s4_mount, s4_url, s4_desc, s4_genre, s4_user, output_source, "4", s4_connected, s4_name, s4_channels) +end