# CONFIGS
set("log.file", true)
set("log.stdout", true)
set("log.level", 4)
set("server.telnet", true)
set("server.telnet.port", 5000)
set("log.file.path", "/tmp/broadcast.log")
set("audio.converter.samplerate.libsamplerate.quality","best")
set("buffering.path","/tmp")
set("decoding.buffer_length",10.)


# FUNCTIONS
dodsorfas_out = output.icecast(description="Dodsorfas Radio", genre="Misc", url="https://radio.dodsorf.as/")
output_docker_env.icecast = dodsorfas_out(
    host=getenv("ICECAST_PORT_8000_TCP_ADDR"),
    port=int_of_string(getenv("ICECAST_PORT_8000_TCP_PORT")),
    password=getenv("ICECAST_SOURCE_PASSWORD")
)
def outputs(encoder, ~mount, input)
    output_docker_env.icecast(encoder, mount=mount, input)
end

input = mksafe(input.harbor("dodsorfas.main", port=5001, password=getenv("HARBOR_PASSWORD")))

# OUTPUTS
outputs(%mp3(bitrate=64), mount="/dodsorfas-radio-64.mp3", input)
outputs(%mp3(bitrate=128), mount="/dodsorfas-radio-128.mp3", input)
outputs(%mp3(bitrate=160), mount="/dodsorfas-radio-160.mp3", input)
outputs(%mp3(bitrate=192), mount="/dodsorfas-radio-192.mp3", input)
outputs(%vorbis, mount="/dodsorfas-radio.vorbis.ogg", input)
outputs(%opus, mount="/dodsorfas-radio.opus.ogg", input)
