1

Thanks to all of you in advance :)

I want to make it clear before you start reading that I want to develop an android based app to use android device as a broadcaster, which records sound using its mic and sent it to shoutcast server something like this:

Android Device with internet connection -> Shoutcast Server -> listeners.

So please do not get confused with playing shoutcast streams on android, because I do not want to develop a player to play an stream. If you are looking for developing a player then download source code from given link, it worked fine for me. Click to download Source code.

Now back to my question, I googled a lot in last two weeks and found This article, which helped me to use builtin mic of android device and stream over a local network. One can listen the stream using VLC.

But I want to send up-stream to my shoutcast server same as one can use winamp with DSP plugin and the problems are:

  1. If I use the code from above This link, it works fine on local n/w but when I try to configure it with my shoutcast server, it gives error : ![UnknownHostException] in log of eclipse.

  2. Is there any url based system on shoutcast server, to which if I will send a stream then it will get the stream and broadcast to my listeners? e.g. if I want to listen stream (down streaming), i can use http://xx.example.com:1234;stream.mp3 and I am asking for up-streaming.

  3. How I can establish a connection to server by login/password. I want to do similar to DSP Plugin as shown in image attached.

    Shoutcast DSP Plugin

Community
  • 1
  • 1
SJSSoft
  • 723
  • 2
  • 10
  • 28
  • Hey Aman, did you ever complete you application? I'm looking for an application just like this one but can't seem to find one. – Nick Caballero Sep 18 '14 at 12:00

2 Answers2

1

The code you linked to is not appropriate in this case. It appears to be for sending raw audio data over UDP, which is not at all what SHOUTcast uses.

SHOUTcast servers do not have an HTTP interface to stream to. They use a completely separate protocol which you must use if you need to use SHOUTcast servers. (I should note that Icecast just added HTTP PUT support within the last year or so.)

Fortunately, the SHOUTcast source protocol is quite simple. All you need to do is send your password, followed by a line break. If you get a favorable response from the server, then send your icy-* headers followed by two line breaks, and followed by your encoded audio data. I have outlined this in detail when this question was asked for iOS a couple years ago: https://stackoverflow.com/a/9241620/362536 You can see the protocol yourself by using a packet sniffer like Wireshark and running it while you connect the Winamp SHOUTcast DSP (or other SHOUTcast source client) to your server.

Finally, don't forget to use an appropriate codec. With SHOUTcast, it's best to use either MP3 (as-is), or an AAC stream wrapped in ADTS. When I tried this project awhile back, I had a hard time figuring out how to get the audio encoded properly, as at least Android 2.1 didn't seem to have a way to encode to a stream and not to a file. I'm no Android dev though, so maybe you will find a better way!

Community
  • 1
  • 1
Brad
  • 159,648
  • 54
  • 349
  • 530
  • I hope it is a relevant answer. That is what I was looking for. I know a little about icy but not sure about it. Let me try. Thanks :) – SJSSoft Jul 13 '14 at 03:00
0

Change the code from

UnknownHostException ()    

to

 UnknownHostException(hostname)    

where hostname is the name of the server on the internet. Probably a dns or routing issue. Pass the hostname to

 getByName    

or better yet

getAllByName    

, log it, and verify it is the expected IP address (es).

This should add more info to the eclipse log.

rjt
  • 1,042
  • 10
  • 16
  • I have used catch(UnknownHostException e) { Log.e("VS", "UnknownHostException"+ e.getMessage()); } Can you please provide exact code for it. I am a fresher. – SJSSoft Jul 12 '14 at 07:27
  • That is about right as long as it dumps the hostname variable. Want to make sure it is not NULL. Depending on the context of the failure, there may be a more specific message such as wrong format - a space in the host name. You may want to catch other exceptions such as NoRouteToHost. – rjt Jul 12 '14 at 12:24