Fix reflect PeerConnection usage

AddTrack MUST be called before `SetRemoteDescription`. During this
operation we are trying to satisfy the remote transceivers with
our local ones.

Resolves #1021
This commit is contained in:
Sean DuBois
2020-02-11 14:49:02 -08:00
parent 0652581dd1
commit 8c7bd66706

View File

@@ -50,11 +50,6 @@ func main() {
if err != nil {
panic(err)
}
// Set the remote SessionDescription
err = peerConnection.SetRemoteDescription(offer)
if err != nil {
panic(err)
}
// Create Track that we send video back to browser on
outputTrack, err := peerConnection.NewTrack(videoCodecs[0].PayloadType, rand.Uint32(), "video", "pion")
@@ -67,6 +62,12 @@ func main() {
panic(err)
}
// Set the remote SessionDescription
err = peerConnection.SetRemoteDescription(offer)
if err != nil {
panic(err)
}
// Set a handler for when a new remote track starts, this handler copies inbound RTP packets,
// replaces the SSRC and sends them back
peerConnection.OnTrack(func(track *webrtc.Track, receiver *webrtc.RTPReceiver) {