Icecast 2: Protocol Description, Streaming to It Using C#

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

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.

Creating an Audio broadcasting via shoutcast or icecast winforms app

There are two possible approaches that I can think of right now for C#:

  • In an earlier answer I recommended to wrap the C library libShout:
    https://stackoverflow.com/a/29745771/2648865
  • Someone seems to have done something like this:
    https://github.com/Zerpico/libShout-csharp
    Please note that the repository seems to contain DLL binaries, I strongly recommend against using random DLLs. Please consider compiling from sources.

How to create an Icecast client like Butt

To solve my problem I used Edcast.
This is the url https://code.google.com/p/edcast-reborn/

Basically I used two instances of edcast, each one pointing a different audio input and they were connecting to the Icecast server.

With this configuration you can see the two edcast instances and listen the different audio inputs by accessing the Icecast server.

Thank you all for your help.

Open socket connection with Icecast server on iOS

My solution is as follows:

I am using the AsyncSocket library like this:

[socket connectToHost:@"myicecastserver.com" onPort:8000 error:&err];

the trick was to remove 'http://' (yes, I am that silly) then on connect I can send the right headers.

Make iOS device as source client using Icecast

I was on wrong path finally I found iOS-Icecast-Client on github. It helps me to make a connection with icecast-server and send the recorder audio to server in chunks. As I have already mentioned that I was able to setup the icecast-server on localhost.

After downloading the above library in AudioProcessor.m file there is a line

ShoutOutputStream_Init("192.x.x.x", 8000, "/stream", "source", "hackme", 0);

Where 192.x.x.x is your wifi ip as you can not use localhost in device to connect it. Also make sure your system and device should be on same wifi connection to reach the network.

8000 is your port defined in icecast.xml.

/stream is mount point name defined in icecast.xml.

And here comes where I spent few hours to get the username and password these are also defined in authentication tag in icecast.xml. I used the default one source and hackme.

0 is whether it is vorbis (0) or a .mp3 (1) file.

Finally I got it working. And Many thanks to gstream79 to provide us such a wonderful library.



Related Topics



Leave a reply



Submit