Update webrtc library to v3.0.0

This update required two main changes to how we use the library. First,
we had to make sure we created the datachannel on the offering peer side
before creating the offer. Second, we had to make sure we wait for the
gathering of all candidates to complete since trickle-ice is enabled by
default. See the release notes for more details:
https://github.com/pion/webrtc/wiki/Release-WebRTC@v3.0.0.
This commit is contained in:
Cecylia Bocovich 2020-12-17 12:25:11 -05:00
parent f908576c60
commit 83c01565ef
9 changed files with 174 additions and 136 deletions

View file

@ -24,7 +24,7 @@ import (
"git.torproject.org/pluggable-transports/snowflake.git/common/safelog"
"git.torproject.org/pluggable-transports/snowflake.git/common/util"
"github.com/pion/webrtc/v2"
"github.com/pion/webrtc/v3"
"golang.org/x/crypto/acme/autocert"
)
@ -58,7 +58,10 @@ func makePeerConnectionFromOffer(sdp *webrtc.SessionDescription,
dc.Close()
})
})
// As of v3.0.0, pion-webrtc uses trickle ICE by default.
// We have to wait for candidate gathering to complete
// before we send the offer
done := webrtc.GatheringCompletePromise(pc)
err = pc.SetRemoteDescription(*sdp)
if err != nil {
if inerr := pc.Close(); inerr != nil {
@ -82,7 +85,8 @@ func makePeerConnectionFromOffer(sdp *webrtc.SessionDescription,
}
return nil, err
}
// Wait for ICE candidate gathering to complete
<-done
return pc, nil
}