Day 15 - Streaming mp3s with Catalyst
A very short article about a very simple streaming server.
Just a short entry for today, briefly describing one of the examples in the Catalyst subversion repository.
In December 2005 Andy Grundman wrote a very short streaming server for Catalyst which you can obtain by issuing the command:
$ svn co http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Streaming
In simple terms, a streaming server is a web server that dynamically throttles the delivery of large media blobs on a per-user basis. The server in this example is really a proof of concept which shows you the basic technique to get started with.
Because this example is relatively old (by Catalyst standards) there is
Controller::Root, which is now the recommended practice - the root
controller is in
After you've gotten the example, copy an mp3 file into the application
root and call it
$ mplayer http://localhost:3000/mp3
You can see the mp3 controller dealing with the request in the debug output - telling you how many bytes it spits out at each time. If you can pause mplayer before the file has finished downloading, you can see that the server stops responding as well. I have been unable to get the range request output for this server, but would be interested to hear how.
In any case, the code is available to download, and as with all things Catalyst, it's easy and simple to adapt this code to suit your own purposes.
Kieren Diment, <email@example.com> (article) Andy Grundman, <firstname.lastname@example.org> (streaming server)
Copyright 2006 Kieren Diment. This document can be freely redistributed and can be modified and re-distributed under the same conditions as Perl itself.