diff --git a/internal/protocols/webrtc/whip_client.go b/internal/protocols/webrtc/whip_client.go index 6feb51f2..04bc5757 100644 --- a/internal/protocols/webrtc/whip_client.go +++ b/internal/protocols/webrtc/whip_client.go @@ -23,7 +23,8 @@ type WHIPClient struct { URL *url.URL Log logger.Writer - pc *PeerConnection + pc *PeerConnection + patchIsSupported bool } // Publish publishes tracks. @@ -290,10 +291,7 @@ func (c *WHIPClient) postOffer( return nil, fmt.Errorf("bad Content-Type: expected 'application/sdp', got '%s'", contentType) } - acceptPatch := res.Header.Get("Accept-Patch") - if acceptPatch != "application/trickle-ice-sdpfrag" { - return nil, fmt.Errorf("wrong Accept-Patch: expected 'application/trickle-ice-sdpfrag', got '%s'", acceptPatch) - } + c.patchIsSupported = (res.Header.Get("Accept-Patch") == "application/trickle-ice-sdpfrag") Location := res.Header.Get("Location") @@ -325,6 +323,10 @@ func (c *WHIPClient) patchCandidate( etag string, candidate *webrtc.ICECandidateInit, ) error { + if !c.patchIsSupported { + return nil + } + frag, err := ICEFragmentMarshal(offer.SDP, []*webrtc.ICECandidateInit{candidate}) if err != nil { return err