Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Icecast 2: protocol description, streaming to it using C#

Tags:

c#

.net

icecast

I need to write an Icecast 2 client that will be able to stream audio from the computer (mp3-files, soundcard recording and so forth) to the server. I decided to write such a client on C#.

Two questions:

1) It will be very useful to know common guidelines (best practices, maybe tricks) I may/should/must use to seamlessly work with streamed audio (streamed over network, of course) in C#. Some general technical documentation about streaming over TCP/IP in common and ICY in particular, advices and notes on the overall architecture of the application will be very appreciated.

2) Is there any good documentation regarding the Icecast 2 streaming protocol? I couldn't find those docs on the official site of Icecast. I don't want to extract the protocol description directly from the source code of it. If the protocol is really simple and neat, could anybody provide a summary of it right here?

like image 224
Daniel O'Hara Avatar asked Mar 07 '11 01:03

Daniel O'Hara


People also ask

What protocol does Icecast use?

The Icecast server is capable of streaming audio content as Opus or Vorbis over standard HTTP, video as WebM or Theora over HTTP, and MP3, AAC, and NSV over the SHOUTcast protocol. Theora, AAC, and NSV are only supported in version 2.2. 0 and newer.

How do I stream Icecast?

Just navigate your web browser to host/port the Icecast server is listening on. If you are a Windows user, make sure you started the Icecast server and then click on the shortcut in the Startmenu, it will open the Icecast status page in your browser.

Can Icecast stream video?

About Icecast 2 Icecast is a streaming media (audio/video) server which currently supports Ogg (Vorbis and Theora), Opus, WebM and MP3 streams.

How do you know if Icecast is running?

To verify that icecast is running go to http://localhost:8000/ or check the status of icecast. service .


4 Answers

As far as I know, there is no protocol spec anywhere, outside of the Icecast source code. Here's what I've found from packet sniffing:

Audio Stream

The protocol is similar to HTTP. The source client will connect to the server make a request with the mountpoint, and pass some headers with information about the stream:

SOURCE /mp3test ICE/1.0
content-type: audio/mpeg
Authorization: Basic c291cmNlOmhhY2ttZQ==
ice-name: This is my server name
ice-url: http://www.google.com
ice-genre: Rock
ice-bitrate: 128
ice-private: 0
ice-public: 1
ice-description: This is my server description
ice-audio-info: ice-samplerate=44100;ice-bitrate=128;ice-channels=2

If all is good, the server responds with:

HTTP/1.0 200 OK

The source client then proceeds to send the binary stream data. Note that it seems some encoders don't even wait for the server to respond with 200 OK before they start sending stream data. Just headers, an empty line, and then stream data.

Meta Data

Meta data is sent using an out-of-band HTTP request. The source client sends:

GET /admin/metadata?pass=hackme&mode=updinfo&mount=/mp3test&song=Even%20more%20meta%21%21 HTTP/1.0
Authorization: Basic c291cmNlOmhhY2ttZQ==
User-Agent: (Mozilla Compatible)

The server responds with:

HTTP/1.0 200 OK
Content-Type: text/xml
Content-Length: 113

<?xml version="1.0"?>
<iceresponse><message>Metadata update successful</message><return>1</return></iceresponse>

Also note that both the audio stream and meta data requests are sent on the same port. Unlike SHOUTcast, this is the base port that the server is running on.

like image 188
Brad Avatar answered Oct 05 '22 22:10

Brad


I'm going to comment here despite this question being quite old.

Icecast is HTTP compliant. This was always the case for the listener side (plain and simple HTTP1.0, RFC 1945), starting with 2.4.0 it's also true for the source client side.

To implement a source client it's a PUT request in compliance with HTTP 1.1 aka RFC2616. Some options can be set through HTTP headers, for details please refer to the current Icecast documentation.

If you send one of the supported container formats: Ogg or WebM (technically EBML), then this is all you need to know. To make it clear this covers at leastOpus, Vorbis, Theora and VP8 codecs.

Please note that while generally working fine, other formats are technically not supported. Icecast only passes through the stream without any processing in such a case.

If you need help or have further questions, then the official mailing lists and the IRC channel are the right place to go.

like image 32
TBR Avatar answered Oct 06 '22 00:10

TBR


Looked at Icecast2 a good long while ago: best reference I could find was at http://forums.radiotoolbox.com/viewtopic.php?t=74 link (I should print that out, took me forever to figure out the proper Google spell to cast to surface that again). It appears to cover source to server and server to client.

Questions remain about just how accurate it is: I got about halfway through an Android implementation before other things consumed me, and I can't quite remember what was wrong with the communication between my implementation of that and VLC/Winamp, but honestly it was the closest thing I could find to a spec.

like image 41
Femi Avatar answered Oct 06 '22 00:10

Femi


The best description I know is here: https://gist.github.com/ePirat/adc3b8ba00d85b7e3870

@ePirat is xpiph/icecast core committer.

like image 44
Niko Avatar answered Oct 06 '22 00:10

Niko