2
votes

During establishing the video call ice candidates gathereing is started after the call to createOffer or createAnswer. I'd like to get all local ice candidates for the local peer before I call createOffer or createAnswer. This way I'll have all of them set in sdp description and there will be no need to send them separately to remote peer as they will go all together in sdp. Is it possible?

UPD: All I want is to gather Ice candidates and keep them. After I want to create offers and asnwers but without of waiting for gathering of candidates will fininsh. Also How to add Ice candidates to description manually? And Is it possible to disabale Ice candidates gathering without recreating RTCPeerConnection?

3

3 Answers

8
votes

Candidate gathering only starts when you call setLocalDescription.

If you want an SDP with all the candidates, wait for the onicecandidate event without a candidate and inspect the peerconnection's localDescription.sdp which contains all candidates gathered so far.

1
votes

You can reduce the delay by setting icecandidatepoolsize - then the browser will try and pre-gather candidates before Offer/Answer.

see: https://github.com/pipe/two/blob/master/index.html#L181

0
votes

According to https://developer.mozilla.org/zh-CN/docs/Web/API/RTCPeerConnection/onicecandidate

When onicecandidate event in callback is null, issue that the peer connection has gather ice candidate complete. So at that time Create offer to other peer connection and the Offer's SDP info will contain 'a=candidate' attribute.

Reference: https://aggresss.github.io/webrtc-samples/src/content/peerconnection/pc1-mod/