Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
638 views
in Technique[技术] by (71.8m points)

audio - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 ).
  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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...