• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Shoutcast Broadcaster  RSS feed

 
Jacob Steingart
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, I've been wanting to try and write a basic Shoutcast broadcasting tool, but I don't know if Java can do that. I'm also not sure if this is the correct forum for this question... Anyhow, how could I go about opening up a Shoutcast stream with Java and streaming into it? I don't know very much about Java's control over sound. Also, if Java can't do this, what would be a language that can? Probably Python, because Python can do anything. Anyhow, I'm a bit confused on this, so even small bits of help would be appreciated.
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, Java can do this (as it can do almost anything too---and definitely anything if you're also prepared to write some JNI). You need to look at the Java Sound API, specifically the javax.sound.sampled package which comes with the standard JRE/JDK. Read a few tutorials on the Web as it can be a bit tricky to get to grips with at first.

Otherwise you really only need to know the Shoutcast protocol and how to setup server sockets and you're away...
 
Jacob Steingart
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been looking at javax.sound.sampled, and I've managed to write some fairly good code. Right now I can record off a microphone, and I can play a song from a given directory, and record/play stuff from a microphone. It isn't fully functional, as it is only a day and half old command line app, but I can see how I could easily make a nice, pretty GUI version. The only part that (kind of) scares me is the actual broadcasting. As of right now, server-y and internet type things are my weakest point. Any tips on how I could figure out how to a) familiarize myself with sockets, etc., and b) figure out how to do Shoutcast? Any tips would be greatly appreciated.
 
Jacob Steingart
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whoah... I just found this, which is pretty intense, though what I believe to be very useful information on the SHOUTcast protocol. I'm still having a bit of trouble converting this into something Java could use. If someone could help walk me through how to do some of this, it would be greatly appreciated.

-Jacob
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shoutcast is quite an old TCP-based protocol, in fact a hacked HTTP. There are numerous problems caused by this hacking which make it unreliable, for example, when passing through proxies. Essentially though you need to use the java.net.Socket and ServerSocket classes to create a TCP socket, then pass data over it in the format described in your link. The fact it is HTTP-like doesn't really matter. Try Googling for "Java sockets" and "Java UDP sockets". They will, for example, lead you to the Sun socket tutorial.

More modern protocols (including proprietary ones) work over UDP and use some error recovery mechanism for lost packets. For real time applications, by the time the packet is lost, it's often easier to keep it lost than recover it. Reasonably, some protocols will stretch existing packets out in order to cover the gaps.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!