-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Release [email protected]
Before Pion WebRTC would gather all candidates before a CreateOffer or CreateAnswer generated a SDP. This would
cause a few issues in real world applications. You can read about the benefits of Trickle ICE here
- Longer call connection times since we blocked for STUN/TURN even if not needed
- This didn't comply with the WebRTC spec
- Made it harder for users to filter/process ICE Candidates
Now you should exchange ICE Candidates that are pushed via the OnICECandidate callback.
peerConnection, _ := webrtc.NewPeerConnection(webrtc.Configuration{})
offer, _ := peerConnection.CreateOffer()
peerConnection.SetLocalDescription(offer)
// Send `offer` to remote peer
websocket.Write(offer) peerConnection, _ := webrtc.NewPeerConnection(webrtc.Configuration{})
// Set ICE Candidate handler. As soon as a PeerConnection has gathered a candidate
// send it to the other peer
peerConnection.OnICECandidate(func(i *webrtc.ICECandidate) {
// Send ICE Candidate via Websocket/HTTP/$X to remote peer
})
// Listen for ICE Candidates from the remote peer
peerConnection.AddICECandidate(remoteCandidate)
// You still signal like before, but `CreateOffer` will be much faster
offer, _ := peerConnection.CreateOffer()
peerConnection.SetLocalDescription(offer)
// Send `offer` to remote peer
websocket.Write(offer)If you are unable to migrate we have provided a helper function to simulate the pre-v3 behavior.
peerConnection, _ := webrtc.NewPeerConnection(webrtc.Configuration{})
offer, _ := peerConnection.CreateOffer()
// Create channel that is blocked until ICE Gathering is complete
gatherComplete := webrtc.GatheringCompletePromise(peerConnection)
peerConnection.SetLocalDescription(offer)
<-gatherComplete
// Send `LocalDescription` to remote peer
// This is the offer but populated with all the ICE Candidates
websocket.Write(*peerConnection.LocalDescription())This was changed with bb3aa9
To simulate the old functionality, call CreateDataChannel after creating your PeerConnection
You can now initiate and accept an ICE Restart! This means that if a PeerConnection goes to Disconnected or Failed because of network interruption it is no longer fatal.
To use you just need to pass ICERestart: true in your OfferOptions. The answering PeerConnection will then restart also. This is supported in FireFox/Chrome and Mobile WebRTC Clients.
peerConn, _ := NewPeerConnection(Configuration{})
// PeerConnection goes to ICEConnectionStateFailed
offer, _ := peerConn.CreateOffer(&OfferOptions{ICERestart: true})This was implemented in f29414
Sign up for the Pion Discord for discussions and support
If you need commercial support/don't want to use public methods you can contact us at [email protected]