1

I am working on an Android app including client and server that client app sends camera captured data to server for processing, and server sent the result back to client to display. The current version of it uses TCP for transmitting data, so the code includes something like:

Client side:

send(){
  Socket socket = new Socket();
  DataOutputStream outputStream = new DataoutputStream(socket.getOutPutStream());
  outputStream.writeUTF(...)
  ...
  outputStream.write(data);
  outputSteram.flush();
  ...
}

receive(){
   DataInputStream dataInputStream = new DataInputStream(...);
   ...
   dataInputStream.readFully(data, 0, length);
   ...
}

Server side:

...
serverDataInputStream.readFully(data,0,length);
//process data
...

serverDataOutputStream.write(reply)
...

I tried to change this to use UDP, but the data sent from client to server is much larger than the maximum size of a UDP packet, so have to fragment the data in client and reassemble it on server manually. It turns out to be too much troublesome.

I know RTP takes care of data fragmentation, so now I want to change this into RTP. After Googleing for a while, I found the following information: http://sourceforge.net/projects/jlibrtp/ http://code.google.com/p/sipdroid/source/browse/trunk/src/org/sipdroid/sipua/ui/VideoCamera.java

And these two posts are very similar to what I am doing: Android Camera RTSP/RTP Stream? Creating RTP Packets from Android Camera to Send

But the posts just include limited sample code. Can anyone post more details and sample code here? I don't have much experience of Java and Android programming. So detailed examples or step by step instruction will be extremely appreciated!

Thank you!

Community
  • 1
  • 1
edwinzhang
  • 146
  • 1
  • 6

0 Answers0