web-servicesrestaudio-streamingplaylistliquidsoap

On-demand audio streaming


Has anyone come across a software that can dynamically stream an arbitrary source identified by an HTTP URL.

I am looking for a server based software that can expose a RESTful interface to take in the definition of the playlist and respond back with a stream URL, that would playback the playlist. The sound files in the playlist are located on a different system accessible via HTTP.

I did take a look at liquidsoap project, but couldnt figure out how to wrap that into a RESTful webservice.


Solution

  • It would be quite a hassle to implement a RESTful server in liquidsoap. I would build the RESTful webservice in whatever "ordinary" web programming language, like PHP, and then let liquidsoap call the same service to get the tracks/files. In this example, a GET request to http://127.0.0.1/next should return one http url to a mp3/ogg/whatever.

    (Example code for liquidsoap version 1.0 - this example will not run on earlier 0.x-something versions)

    def autopilot() =
      def result()
        result =
          list.hd(
            get_process_lines('curl http://127.0.0.1/next')
          )
        request.create(result)
      end
      audio_to_stereo(request.dynamic(result))
    end
    
    radio =
      mksafe(
        autopilot()
      );
    
    output.icecast(%mp3(samplerate=44100, stereo=true, bitrate=128),
      host="127.0.0.1",
      port=8000,
      password="secretpassword",
      mount="radio.mp3",
      radio
    );
    

    In this example, you would need an icecast2 server to send the stream to.