Stream from Android device to shoutcast (upstreaming)

限于喜欢 提交于 2019-12-07 01:13:29
Brad

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!

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!