How can I code a server/client video and audio streaming application? How can I code a server/client video and audio streaming application? multithreading multithreading

How can I code a server/client video and audio streaming application?


For streaming and talking to your clients, you need to define a protocol: Search the web for RTP and RTSP. It should give you a pretty good idea of what you need to implement these protocols or even create your own one.

As for implementing, take a look at the red5 project: http://red5.org/

Take a look at Xuggler as well: http://www.xuggle.com/xuggler/ This project will help you saving lots of lines of code. Note that its development has gone stale.

Cheers.


Check out the Java Media Framework (it has tutorials): http://java.sun.com/javase/technologies/desktop/media/jmf/

Does this even work?

     while(true) {        Runnable r = new ThreadedEchoHandler(incoming, i);        Thread t = new Thread(r);        t.start();        i++;     }

I think your code would produce a bunch of threads with incoming socket connections... what you probably want to do is this:

     while(true) {        Runnable r = new ThreadedEchoHandler(incoming.accept(), i);        Thread t = new Thread(r);        t.start();        i++;     }

The ThreadedEchoHandler should take a Socket instead of a ServerSocket. Accept blocks until a client connects, otherwise you'll be spawning an infinite number of threads without a connection... I don't think you have anything that will stop you from doing that at the moment.


Guys thank you very much for your answers and for editing title. I'm new here, new on java, new on networking. Why I'm making my skill on streaming? It's a study case.I'm looking at many tutorial about networking and I saw RTP but I didn't read about 'cause I thought (for reading on forums) it was just for real time streming meant as webcam streaming...but it's that I'm just so confused LOL

Lirik of course what you said, I forgot some lines of coding

while(true) {   Socket incoming = s.accept();   Runnable r = new ThreadedEchoHandler(incoming, i);   ...

or as you said

while(true) {  Runnable r = new ThreadedEchoHandler(s.accept(), i);   ...

Taking a look at what you said guys.Kind regards!