mirror of
https://github.com/pion/webrtc.git
synced 2025-11-03 09:40:59 +08:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user