Reputation: 2066
This might sound silly, but I have been searching for a very long time on how to do that, and all what I get is only being more confused :/ I have made a webRTC video chat application and it is working just fine, what I need now is how to ring one android-device from another when that other wants to call first one, I mean until now I must enter the same room name on both devices to be able to make a video call and that's not practical cuz in real life how will the other peer or device user know that someone wants to call him, I have read about SIP, but it seems not what I am looking for, please help.
Upvotes: 2
Views: 2666
Reputation: 2066
Just Use Socket.io which consists of two parts: 1. Frontend SDK (IOS, Android, Web, ...etc) 2. Backend -> very well documented
Here is the link: https://socket.io/
Upvotes: 0
Reputation: 21033
WebRTC
is responsible for PeerConnection
Not ring the device and handle the Users . Its your own data you need to Handle it yourself .
Thats where SignalingServer
Comes to the party . Once youcreateOffer()
from a userId(lets say id is 2)
and send it to your Singnalling server with the destination userSocketId(Here i am mapping userId to SocketId you can also map some other field).
If destination Socket has registered it will immediately get the incoming call request with caller info which you have put in the packet
. Then you can Ring the device .
See i can not explain the whole functions here but one thing you should understand You will have to utilize Signalling server
for textual data sharing beetween two devices.
Basically you need to have the ID
to which you want to call then only signalling server will emit the Particular data on receiver end. So you need a cloud database in which all user info is saved .
You can follow Sample mentioned here. The signalling server
in this sample uses NODE.JS
which is easy to understand and modify if you are familiar with java.
Edit:- If you are looking for the point where you should start RING
. Well it should ring whenever you receive an Offer
and you open your calling UI(Activity).
Keep one thing in Mind ICECandiates
should not get lost so Use proper handshake bettween both party before sending ICECandiates
lists cause this is the base of setting up PeerConnection
.
public void startCallNotification() {
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
ringtone = RingtoneManager.getRingtone(this, notification);
ringtone.play();
vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
long[] vibrationCycle = {0, 1000, 1000};
if (vibrator.hasVibrator()) {
vibrator.vibrate(vibrationCycle, 1);
}
}
Just call the method above whenever you get an offer. Obviously you need to handle some other cases like internet lost on caller end and connection reset, Wait for ICECandidates.
Things will bread and butter if you understand WebRTC
architecture first. SO i humbly recommend to read the structure first. You can start with This and This or similar blogs on WEBRTC
.
Upvotes: 5