Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Developing the client for the icecast server

I am developing the client for the icecast server (www.icecast.org). Can anybody tell me, what is the format they are using for streaming the content?

I was looking on their pages, but there is no information about the stream format at all.

I have then checked the Wireshark trace and due to my understanding the format of the audio data I am receiving within the 200 OK response to the GET request it is just a plain binary audio data without any metadata included, so comparing to the SHOUTcast or HTTP Live Streaming (HLS) it is relative simple approach.

Is that right? Any experience with it?

Wireshark trace snippet:

GET /bonton-128.mp3 HTTP/1.1
Host: icecast3.play.cz
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-US
Accept-Encoding: gzip, deflate
Connection: keep-alive


HTTP/1.0 200 OK
Content-Type: audio/mpeg
icy-br:128
ice-audio-info: ice-samplerate=44100;ice-bitrate=128;ice-channels=2
icy-br:128
icy-description:Radio Bonton
icy-genre:Pop / Rock
icy-name:Radio Bonton
icy-pub:0
icy-url:http://www.radiobonton.cz
Server: Icecast 2.3.2
Cache-Control: no-cache

Here are then aac or MPEG data

Thanks and regards,

STeN

like image 837
STeN Avatar asked May 19 '11 15:05

STeN


1 Answers

For your purposes, Icecast and SHOUTcast are equivalent.

They both use a bastardized version of HTTP. In fact, you can make a simple HTTP request and use standard HTTP client libraries, and it will almost always work just fine. The only thing different is that SHOUTcast will return ICY 200 OK instead of HTTP 200 OK in its response.

Now if you make the request, as you have done above, you get a standard audio stream that you can play directly. As you have pointed out, MP3 and AAC are used almost exclusively, but other formats can be used.

If you want metadata, you have to tell the server you are prepared to receive it. You have to put this header in your request:

Icy-MetaData:1

Once you do that, you will see another header come back to you in the response, such as icy-metaint:8192, which means that every 8192 bytes, you will receive a chunk of metadata.

I won't go into further details because this is already well documented. No need to re-type the wheel:

Pulling Track Info From an Audio Stream Using PHP

http://www.smackfu.com/stuff/programming/shoutcast.html

However, if you do have questions as you go, please post them on StackOverflow and tag them as icecast or shoutcast, and I will be happy to assist you.

like image 129
Brad Avatar answered Sep 22 '22 00:09

Brad