A few people have looked at the source of my Indie 103.1 iPhone App and asked about reading SHOUTcast metadata (artist and track information) from the audio stream. The Indie App code won’t read metadata for SHOUTcast streams – but it does work for Icecast streams. Turns out that SHOUTcast and Icecast (two of the most popular server applications for streaming radio) are supposed to be compatible, but the response message from each server is slightly different.
SmackFu has a great page that documents the ShoutCAST metatdata protocol. They don’t mention the difference in the server response, but you’ll find references to it on Google.
When you send an HTTP GET request to an Icecast server (like Indie 103.1) it replies with HTTP 200 OK. This is what we’d expect, and you can use CFHTTPMessageCopyHeaderFieldValue to read the response header where you get the Icy-MetaInt value. SHOUTcast responds to an HTTP GET request with ICY 200 OK. When this happens CFHTTPMessageCopyHeaderFieldValue returns null.
One solution is to look for the ICY 200 OK response and parse the headers manually. I’ve created another Google Code project called audiostreamer-meta and used Matt Gallagher’s execelent AudioStreamer example as a sample project. The sample application will parse the metadata from both server streams. Check the debug window in Xcode to see the metadata. The code needs some clean up, and it would be nice to display the artist, tract, and other metadata on the view itself. Feel free to join the project and help make the code better.