Skip to content

Commit

Permalink
webrtc: support WHIP/WHEP endpoints without PATCH support (#3273) (#3277
Browse files Browse the repository at this point in the history
)
  • Loading branch information
aler9 authored Apr 20, 2024
1 parent 4ed1a39 commit bfa83fc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions internal/protocols/webrtc/whip_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ type WHIPClient struct {
URL *url.URL
Log logger.Writer

pc *PeerConnection
pc *PeerConnection
patchIsSupported bool
}

// Publish publishes tracks.
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bfa83fc

Please sign in to comment.