LinuxDevCenter.com
oreilly.comSafari Books Online.Conferences.

advertisement


Streaming Media With Linux, Part 2
Pages: 1, 2, 3

Now fire up XMMS and point it to http://127.0.0.1:8000 to hear the stream. When you're ready for the network, simply change the loopback references in your Icecast and shout configuration files to your actual IP address, just as we did with RealServer, and you're set to rock the net. Of course, you want to make it easy for people to connect to your MP3 stream, so you might want to add a link like this one to a Web page:



<a href=http://connection.m3u>My Streaming MP3 Show</a>

where the connection.m3u file contains a single line redirecting the request to the actual mount point:

http://64.108.112.104:8000

Make sure that you place the connection.m3u file on the same web site as the page in which the link appears. Web surfers can then simply click on the link to listen to the sounds of your personal MP3 stream.

This introduction touches only the basic points of getting Icecast up and running. The system also handles live broadcasts, and you can reflect your broadcasts to a larger audience using the public server at yp.icecast.org. There's much more to Icecast, but I'll leave that exploration to the industrious student. Let's move further on and take a look at Icecast 2, the next generation. ...

Related Articles:

Streaming Media With Linux Resources Page

Streaming Media With Linux (Part 1)

Creating Great Audio for the Web

Could Ogg Vorbis Replace MP3?

Linux Audio Plug-Ins: A Look Into LADSPA

Server-Side Considerations for Video Streaming

Shooting Digital Video PDA Style

Streaming Vorbis with Icecast 2

Icecast 2 is currently available only in a BitKeeper repository, which means you'll have to obtain and install the BitKeeper software. It is available in source code, but I recommend using the easy-to-install pre-compiled binary. Follow the download directions on the BitKeeper page to obtain your user ID and instructions. Log on to the download site, then retrieve the correct binary for your system (glibc 2.0 or glibc 2.1) and move it to a temporary directory ($HOME/tmp is good). Go into the holding directory, become the root user (su root) and run sh x86-glibc21-linux.bin to install the BitKeeper software.

You must also have the OggVorbis libraries correctly installed on your system. If you ran the OggVorbis examples earlier in this article, then you've already installed the necessary libraries. If not, head over to the OggVorbis nightly CVS, download the package, and install the software (as described in this article). Now you're ready to compile and install Icecast.

Note: You must use OggVorbis 1.0 beta 4 or higher to build and run the following examples.

Icecast developer Jack Moffit has placed online a set of instructions for downloading and compiling Icecast 2. The process of retrieving files from a BitKeeper repository is simple, but be sure to strictly follow the instructions on that page. Download the sources for Icecast and libshout, then follow Jack's directions for compiling them (./autogen.sh; make; make install should do it).

Before running the server we need to have some content to stream, so let's create a playlist of pieces in OGG format.

Open your favorite text editor and create a new file named "ogglist." This text file lists the locations of the OGG files you wish to play, as in this example:

/home/dlphilp/soundfiles/oggfiles/4_LPC_Studies.ogg
/home/dlphilp/soundfiles/oggfiles/moanmix.ogg
/home/dlphilp/soundfiles/oggfiles/odimix.ogg

Now go to your Icecast home directory and edit (as root) the conf/icecast.xml file to reflect your location, server name, connection port, and so forth. While still in the Icecast home top directory, start the server with this command line:

icecast -c conf/icecast.xml

You will see the XML file displayed, along with some debugging messages; then your Icecast2 server is ready to work.

Icecast will eventually use the ices utility to send Vorbis streams out to the server, but the current BitKeeper libshout package includes a prototype streamer (appropriately named "example") in the examples directory. Open the example.c program in a text editor and edit the following lines to reflect your build configuration:

conn.ip = "127.0.0.1";
conn.password = "itsme";
conn.mount = "/shouter.ogg";

These settings will set up the example binary to stream content to a virtual mount point named shouter.ogg at the loopback address. You can name the mount point anything you like, as long as it ends with .ogg. The password must match the password in the icecast.xml configuration file.

Run make to compile the example, then pass your Ogg playlist to the streamer with this command string:

cat ogglist | xargs cat | example 8000

The pipes route the file names from ogglist to xargs, which parses and cats each file to the example streamer at port number 8000. The server window will report on the connection from the streamer:

connection added....
DEBUG: someone signaled us!
DEBUG: header read succeeded...

What kind of headers do we have?
req_type = source
protocol = ice
version = 1.0
uri = /shouter.ogg
DEBUG: source logging in
DEBUG: source logged in!

Now bring up XMMS (the CVS version described above) or ogg123 and point it to this address:

xmms http://127.0.0.1:8000/shouter.ogg

If you use ogg123 make sure you indicate an output device:

ogg123 -d oss http://127.0.0.1:8000/shouter.ogg

FreeAmp is another excellent open source streaming audio player. As of release candidate 2.1, Freeamp includes built-in support for streaming Vorbis; unfortunately, I did not have time to test it, but developer Robert Kaye kindly sent a screenshot of FreeAmp rendering a Vorbis stream (Figure 11). With the addition of FreeAmp, Linux users now have their choice of three streaming Vorbis players, and more are certainly on the way. But let's get back to your server ...

Screen shot.
Figure 11. FreeAmp playing a Vorbis stream.

The server streams the OGG files from your playlist to the mount point, where the requesting client will receive the stream. Again, the server will report on the client connection:

connection added....
DEBUG: someone signaled us!
DEBUG: header read succeeded...

What kind of headers do we have?
req_type = get
protocol = http
version = 1.0
uri = /shouter.ogg
DEBUG: client coming in...
DEBUG: sending ice-bitrate: 0
DEBUG: sending ice-name: no name
DEBUG: sending ice-public: 0
Client added
Printing client tree:
id = 1

Printing pending tree:
Done.

Meanwhile, your player should note the connection, pre-buffer some of the stream (you can set the pre-buffering value in XMMS by configuring the Ogg-Vorbis input plug-in), and start playing. Behold the wonder of streaming Vorbis! (Sorry, I couldn't contain my awe... :)

Acknowledgements

The author thanks Jack Moffitt for his extensive and invaluable assistance with this article, particularly regarding the material on Icecast 1 and 2. Thanks also to my broadband neighbors Jack Paxton and Josh Flechtner and to the members of the Icecast and Vorbis mail-lists for their help with my real-world tests of RealServer and Icecast.

The developers of Icecast 2 are working hard to put the finishing touches on the public distribution package. Much of what I have presented here will likely change (i.e., get easier), but the example presented here delivers the proof of concept. High-quality streaming audio with Vorbis is a reality, and that is great news for anyone involved with network broadcasting.

Final thoughts

The pace of development is fast and furious in the world of streaming audio. Access to broadband is becoming more common, content creation is booming, and viable alternatives to patented and licensed streaming formats have begun to appear. Whether on the client side or the server side, Linux is poised to become the platform of choice for listeners and producers of streaming audio. The major streaming formats are already supported by Linux players, utilities, and servers, and even better things are coming our way fast. As we have seen in this article, the future of streaming audio is in good company with Linux: It's just a natural match.

Dave Phillips maintains the Linux Music & Sound Applications Web site and has been a performing musician for more than 30 years.


Return to the Linux DevCenter.




Linux Online Certification

Linux/Unix System Administration Certificate Series
Linux/Unix System Administration Certificate Series — This course series targets both beginning and intermediate Linux/Unix users who want to acquire advanced system administration skills, and to back those skills up with a Certificate from the University of Illinois Office of Continuing Education.

Enroll today!


Linux Resources
  • Linux Online
  • The Linux FAQ
  • linux.java.net
  • Linux Kernel Archives
  • Kernel Traffic
  • DistroWatch.com


  • Sponsored by: