From 9a5c8b6b430fd29955b63d7b8815943e820b3baa Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Tue, 19 Jan 2021 23:30:01 +0100 Subject: [PATCH] Handle answers in stable state. Don't break the stream, just ignore the SDP. --- rtpconn/webclient.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/rtpconn/webclient.go b/rtpconn/webclient.go index fada36c..721c642 100644 --- a/rtpconn/webclient.go +++ b/rtpconn/webclient.go @@ -554,12 +554,17 @@ func gotAnswer(c *webClient, id string, sdp string) error { if down == nil { return ErrUnknownId } - err := down.pc.SetRemoteDescription(webrtc.SessionDescription{ - Type: webrtc.SDPTypeAnswer, - SDP: sdp, - }) - if err != nil { - return err + + if down.pc.SignalingState() == webrtc.SignalingStateStable { + log.Printf("Got answer in stable state -- this shouldn't happen") + } else { + err := down.pc.SetRemoteDescription(webrtc.SessionDescription{ + Type: webrtc.SDPTypeAnswer, + SDP: sdp, + }) + if err != nil { + return err + } } for _, t := range down.tracks { @@ -571,7 +576,7 @@ func gotAnswer(c *webClient, id string, sdp string) error { } } - err = down.flushICECandidates() + err := down.flushICECandidates() if err != nil { log.Printf("ICE: %v", err) }