I would like to have some advices because I've got conflict between clients sending RTSP messages to the server. First at all I apologize to you all for my English.
Well, what I'm doing is a java streaming video application.
clients set
TCP
connection with the server for exchangingRTSP
messagesserver sends over
UDP
, to the client requesting, frames inRTP
packets using JPEG Payload Type because my video is in MotionJPEG format.
To be more specific:
- Server uses Threads to handle clients TCP connection on the same port
- Every client connected sent to the server the port wants to use for UDP transmission.
The problem is that the server receive and analize RTSP messages on tcp communication but when a client more connect to server, RTPS messages confuse orders and my server want to convert to integer where are just string, take session number from "unicast" written and so on...
This is what I do to handle different clients:
ServerSocket socket = new ServerSocket(7777);
while(true) {
System.out.println("\nAspettando una connessione...");
Socket incoming = socket.accept();
Server server = new Server(incoming);
Thread t = new Thread(server);
t.start();
}
My class Server implements Runnable to handle the timer to play, pause and stop the streaming.
Well it works providing video streaming to one client, but the server confuses RTSP on TCP requestes from clients that freeze. If I close those and open a third one it starts to work again because server understands what is receiving.
To be more specific the exceptions in server depend on the RTSP message clients are sending. For example
$Server (should receive Cseq) receives from (/192.168.0.4): Session: 12345678
$Server (should receive Cseq) from (/127.0.0.1): Cseq: 4
So exceptions could be:
Exception in thread "Thread-3" java.lang.NullPointerException
at java.util.StringTokenizer.<init>(StringTokenizer.java:182)
at java.util.StringTokenizer.<init>(StringTokenizer.java:219)
at progetto2.Server.run(Server.java:91)
at java.lang.Thread.run(Thread.java:619)
or
when is found Transport: RTP/UDP;unicast;client_port=8888\r\n something like (I apologize I've lost the exception in thread line)
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:449)
at java.lang.Integer.parseInt(Integer.java:499)
at progetto2.Server.run(Server.java:108)
at java.lang.Thread.run(Thread.java:619)
So I should I handle different clients, should I use different TCP ports? I'm sorry but I remember for multiclient chat I didn't have these problems. I hope to have explained my problem in the best way.
Thank you to everyone for helping and advicing me!
Kind regards!