问题
I am developing a voice chatting app
based on webRTC
using android libjingle
.I want to reconnect users by using ice restart when they change their network from wifi
to 4g or vice versa, or are disconnected. I have a question about implementing it by using libjingle
. I will write down how to implement ice restart function based on what I understood so let me know there is anything wrong.
Q: As I understand, at first I need to set ice start option to be true in the MediaConstraints
option without removing peer connection 객체 used for the first connection like below:
mediaConstraints.optional.add(new MediaConstraints.KeyValuePair("IceRestart", "true"));
Secondly, I need to update MediaConstrants
using the peer connection 객체(used for the first connection)'s updateIce method like below:
peerConnection.updateIce(iceServers, mediaConstraints);
And finally is it right to send an offer, which is the same with basic webrtc
network?
- I want to double check whether I understand well. And if there is something wrong in what I've written, please let me know!!
回答1:
For doing ice restart, sender should send SDP file with different ice-pwd or ice-ufrag. IceRestart option forces PeerConnection to update those values.
Steps should be:
- Put additional constraint:
cons.mandatory.add(new MediaConstraints.KeyValuePair("IceRestart", "true"));
- Generate sdp file:
pc.createOffer(new WebRtcObserver(callbacks), cons);
- Set resulted sdp to PeerConnection:
pc.setLocalDescription(new WebRtcObserver(callbacks), sdp);
- Send it to remote peer.
So steps 2-4 are the same as for regular offer.
来源:https://stackoverflow.com/questions/47175624/how-to-ice-restart