Skip to content
Snippets Groups Projects
library.liq 4.77 KiB
#
# Aura Engine (https://gitlab.servus.at/aura/engine)
#
# Copyright (C) 2017-2020 - The Aura Engine Team.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.




#####################################
#         CLEAR SOURCE              #
#####################################

def clear_items(ns) =
    ret = server.execute("#{source.id(ns)}.primary_queue")
    ret = list.hd(default="", ret)
    if ret == "" then
        log("Queue cleared.")
        (-1.)
    else
        log("There are still items in the queue, trying skip ...")
        source.skip(ns)
        (0.1)
    end
end

def clear_queue(ns) =
    add_timeout(fast=false, 0.5, {clear_items(ns)})
end


#####################################
#         DYNAMIC SOURCES           #
#####################################

def create_dynamic_source(~skip=true, name)
    log("Creating dynamic source '#{name}'")
    track = get_process_lines("cat "^string.quote("next-track.txt"))
    track = list.hd(default="", track)
    dyn_source = request.dynamic.list(
      { [request.create(track)] })
    dyn_source
end


#####################
# stream to icecast #
#####################

def stream_to_icecast(id, 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()