7

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?

Brad
  • 146,404
  • 44
  • 300
  • 476
Ray Frand
  • 81
  • 1
  • 3

2 Answers2

12

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.

Brad
  • 146,404
  • 44
  • 300
  • 476
  • Thank you! Is this protocol same with Icy servers? (Is it a standartized protocol?) I will start implementing this after discovering audio conversion to adts. – Ray Frand Feb 14 '12 at 08:33
  • ICY is SHOUTcast. Yes, it should work with Icecast as well. There is no written standard, but it is standardized in the way that everything uses it. – Brad Feb 14 '12 at 16:20
  • @RayFrand, I should note that with Icecast, while you can use this source protocol, you can only use one per server. If you want to write a pure Icecast source, see this: http://stackoverflow.com/a/9985297/362536 – Brad May 29 '12 at 00:17
  • @Brad thanks! this actually helped me aswell :D , my motive is a web-based shoutcast broadcaster [ so that broadcast off cloud ] – ShrekOverflow Jul 02 '12 at 14:40
  • I was quite wondering what is the frame rate to broadcast to shoutcast ? I mean i can transcode mp3 files [ mine works as an async process this kinda makes it messy ] so i am wondering if there is any defined data rate that is to broadcasted to the server ? or can it handle anything – ShrekOverflow Jul 02 '12 at 14:43
  • @Abhishek, The bitrate is not pre-defined, and varies from station to station, by preference of the owner. If you can afford more bandwidth and wish to provide higher quality audio to your listeners, then go for it. It is very common to provide a variety of bitrates, to accommodate those with slower connections. – Brad Jul 02 '12 at 14:52
  • No no no you got me wrong i was actually confused with how much data to send to shoutcast itself ! now i think i will send it just enough data to make it upto 44100 samples per second. Considering shoutcast is totally dumb with traffic it should just re-broadcast the data to clients ? Or should i actually send more data then this ? – ShrekOverflow Jul 02 '12 at 14:55
  • @Abhishek, The data you send is the data that gets sent to clients. The bitrate you choose to send to SHOUTcast is the bitrate that will be sent to clients. – Brad Jul 02 '12 at 21:24
  • Please note that this is only valid for SHOUTcast, Icecast works not like that, although it uses some of the icy headers. – ePirat Jul 02 '15 at 10:12
  • @ePirat Yes, that's correct. For Icecast see this question: http://stackoverflow.com/questions/5215019/icecast-2-protocol-description-streaming-to-it-using-c-sharp/9985297#9985297 – Brad Jul 02 '15 at 16:11
  • @Brad Please note that even the linked post isn't at the most up to date state and some of the things there are not recommended practice anymore, like out of band metadata. – ePirat Jul 03 '15 at 16:18
  • Here is the source client: https://github.com/fatihsokmen/android-icecast-broadcast – Fatih S. Nov 16 '15 at 20:40
0

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.

Fatih S.
  • 300
  • 2
  • 8
  • Hi Fatih, I just saw your github repo. I want to broadcast mp3 from my android phone to icecast server. I have built my server but could not find any solution for android app. And I am unable to use your repo for this purpose. Can you guide me how to include it in my test project? – Talha Arshad Oct 28 '20 at 13:14