views:

38

answers:

1

Hi all, I have to implement a little software that sends an audio stream between two pc in the same WiFi network..

In little words, I get audio from device like a mic and then I have to transmit this audio in real time.. maybe I'll use Java..

To transmit data trough UDP something like this:

//create UDP socket
DatagramSocket socket = new DatagramSocket();

//data to be sent
byte[] buf = (data).getBytes();

//create UDP packet
DatagramPacket packet = new DatagramPacket(buf, buf.length, address, port);

//send the packet
socket.send(packet);

...

Well, my question is, how can I split the audio source in packets that I'll store in buf?

how can I receive the packets in another pc and then "reassembly" or play directly?

It's the right way? Thanks very much. Hi!

+1  A: 

Why don't you use TCP instead of UDP? With TCP sockets, you'll have stream functionality implemented with no extra hassle.

If you stick with UDP, you'll have to implement some kind of packet numbering, then reassembly, then play only when you have them all, and so on. Try to avoid it.

Daniel Mošmondor