Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Broadcast to Icecast / SHOUTcast with Objective-C, C, or C++

I want to provide audio data into SHOUTcast or Icecast servers without using their own broadcaster, since i will be using this on various platforms including mobile.

I need protocol descriptions, open source projects, or samples to be able to send audio data (from mic or file) using Objective-C, C or C++ to SHOUTcast and Icecast servers.

Where can I find the information needed to build a proper SHOUTcast/Icecast source client?

like image 322
Ray Frand Avatar asked Feb 11 '12 09:02

Ray Frand


2 Answers

Comment: It's about time someone makes a SHOUTcast source client for mobile. I've been needing this for a while, but don't have time to build it, so kudos to you. Please make an Android version at some point.

The first thing you should do is download Wireshark.

Start the packet capture, fire up a SHOUTcast server, then fire up a source client, and connect it to the server. Be prepared for the horrifying simplicity of this protocol.

Primary Audio Protocol

  1. Source client connects to SHOUTcast with TCP. Use the port one up from the base port. For instance, if your base port is 8000, your listeners connect on 8000 and you will connect on 8001.
  2. Once connected, the SHOUTcast server won't say anything. Just send the broadcast password, followed by a new CrLf (or \r\n).
  3. If the password is wrong, it will say invalid password or something like that. If it is correct, you're going to get something like this:

    OK2

    icy-caps:11

    Note that each line has CrLf after it, and after these two headers are sent, there are a pair of CrLf.

  4. Now, it is up to the source client to send a bunch of headers: icy-name, icy-genre, icy-pub, icy-br, icy-url, icy-irc, icy-icq, icy-aim, content-type. Send them like this:

    icy-name:My Awesome Station

    Each line should be followed by CrLf, and after you're done sending all of the headers, send a pair of CrLf.

  5. Once this is all done, start sending your stream data! No need to start in any particular spot, just send data. It is up to the clients on the receiving end to sync to the frame. The SHOUTcast server is completely "dumb" to the traffic flowing through it. You can connect with a Telnet client and send a bunch of text if you wanted to.

Updating Metadata

So, you're probably wondering how you send information for the next track and what not. The funny thing is, this is completely out-of-band from the connection where you send audio data.

All you have to do is make a web request to the port base (8000 in our example):

http://yourserver:8000/admin.cgi?pass=yourpassword&mode=updinfo&song=your%20song&url=some_url_goes_here_but_hardly_any_clients_use_it

In case that is difficult to read, these are the parameters:

  • pass
  • mode
  • song
  • url

You'll note that these same parameters, and others, can all be found in the SHOUTcast admin panel.

like image 188
Brad Avatar answered Oct 20 '22 03:10

Brad


I developed shoutcast wrapper native C files along with a sample android app that you can stream from device microphone -> android-icecast-broadcast.

It is captures, encodes pcm audio from mic. and broadcasts ice server.

like image 41
Fatih S. Avatar answered Oct 20 '22 02:10

Fatih S.