how to ice restart?

人走茶凉 提交于 2021-01-27 05:22:43

问题


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:

  1. Put additional constraint: cons.mandatory.add(new MediaConstraints.KeyValuePair("IceRestart", "true"));
  2. Generate sdp file: pc.createOffer(new WebRtcObserver(callbacks), cons);
  3. Set resulted sdp to PeerConnection: pc.setLocalDescription(new WebRtcObserver(callbacks), sdp);
  4. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!