Reputation: 1
I want to create a voice chat application in pure java socket programming. I used UDP protocol to transfer recorded voice from one client to another but when i test it over the internet voice is not comming continuously. As i am new to this voice chat application, someone may suggest what should i do for getting continuous voice.
The Scenario is like this.
Client1------------------------------>> Server ------------------------------------>>Client2
Client1: Reading 1KB voice buffer from TargateDataLine then create a voice packet and sent to server.
Server: Receive from client1 and then send to client2.
Client2: Receive the UDP packet and get voice data then play.
Also facing the bandwidth up and down problem. What should be the minimum bandwidth to use voice chat. Ex- skype required 30KBPS udloading/downloading speed.
Thanks in advance.
Upvotes: 0
Views: 3416
Reputation: 24
The Answer is pretty simple you should use tcp protocol. Coz udp sends the packet but doesn't ensure that the packet was received by the target. but tcp protocol ensures it and you will get a stable connection with cost of some speed reduced in transfer of data.tcp vs udp
Upvotes: 0
Reputation: 136
In order to establish a connection between two or more users for peer-to-peer communication you need a signaling server as well as STUN/TURN servers.
You can code your own ones or use a ready backend solutions like ConnectyCube and concentrate on client-side implementation. Here are some WebRTC video chat code samples for your reference as well.
Upvotes: 1
Reputation: 1670
You should send the packets directly between the clients. The relaying of packets through the server is adding more delay to it. Simply send it from client1 to client2.
Upvotes: 0