# Liquidsoap

## Audio Stream Generation

### icecast_proxy.liq

    # Serve all files other
    # than /admin.* by fetching data
    # from Icecast, located at localhost:8000
    def proxy_icecast(~method,~protocol,~data,~headers,uri) =
      def f(x) =
        # Replace Host
        if string.capitalize(fst(x)) == "HOST" then
          "Host: localhost:8000"
        else
          "#{fst(x)}: #{snd(x)}"
        end
      end
      headers = list.map(f,headers)
      headers = string.concat(separator="\r\n",headers)
      request =
        "#{method} #{uri} #{protocol}\r\n\
         #{headers}\r\n\r\n"
      get_process_output("echo #{quote(request)} | \
                          nc localhost 8000")
    end

    # Register this handler at port 8005
    # (provided harbor sources are also served
    #  from this port).
    harbor.http.register(port=8005,"^/(?!admin)",
                         proxy_icecast)

Download