PDA

View Full Version : Internet radio information display



mortod
2007-09-07, 03:22
It might seem like a trivial question, but why is that some internet radio stations display things like artist and trackname, and others don't? I'm specifically thinking about Virgin Radio UK (Slim picks -> Most Popular) - they must broadcast the information as there is 'now playing' detail updated on their webpage. Or would it require someone to write an add-in to parse that webpage assuming that the information is not included in the radio data stream?

gerph
2007-09-09, 03:24
It might seem like a trivial question, but why is that some internet radio stations display things like artist and trackname, and others don't? I'm specifically thinking about Virgin Radio UK (Slim picks -> Most Popular) - they must broadcast the information as there is 'now playing' detail updated on their webpage. Or would it require someone to write an add-in to parse that webpage assuming that the information is not included in the radio data stream?

Those which use MP3 streaming use the 'shoutcast' protocol which interleaves metadata within the stream. The shoutcast protocol wasn't - when I looked at it a few years ago - very well documented but, off the top of my head you send a request in the header when you start fetching the data, something like 'ICY-Metadata: 1' or something, and you get back a similar response in the server headers. As well as the response you get a interleave interval value in one of the fields.

Every 'interleave interval' bytes in the stream there is a variable amount of metadata inserted - this metadata is only inserted if you already requested the shoutcast protocol, so you must interpret it. It's a relatively lightweight format IIRC, and off the top of my head it's a tag string followed by a nul, followed by a value up to a nul, and the metadata is terminated by a lone nul (ie an empty tag string).

Ah; seems I'm slightly wrong... http://www.smackfu.com/stuff/programming/shoutcast.html has a little description of the protocol. My memory clearly isn't good :-)

Anyhow, that's how the metadata is embedded in the stream, in general.

The data could also be embedded in other ways, in particular ID3v2 is capable of being embedded within the stream 'safely' (ie without the need for any protocol negotiation).

As for why only some stations give the information... it's really up to them whether they insert the data.

Technically the shoutcast method is costly. The metadata must be inserted into the stream of every client's data at its own intervals, therefore you can't just stream the same data to every client - it has to be modified before transmission. That's relatively costly. This can be helped by using constant bitrate frames, never using padding (or always using padding if you're perverse) and contriving the interleave interval to be an exact multiple of the frame size. In this way the server can stream the same data to all clients so long as it only ever starts sending to new clients at the end of a metadata interveave interval.

It might not matter to smaller stations that this processing is performed, but when the number of listeners increases the processing required for inserting the metadata becomes significant.

mortod
2007-12-12, 07:15
I see now that Virgin UK metadata is being displayed by my SB3 - it seems Virgin have started broadcasting it. But it does take a while before the SB displays the new track detail (about 1.5 minutes after the track starts). Not sure whether that is a SB issue, or a delay in what is being broadcast. But I also see a similar delay on LastFM. Any thoughts?