Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webrtc: support WHIP/WHEP endpoints without PATCH support (#3273) #3277

Merged
merged 1 commit into from
Apr 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
URL *url.URL
Log logger.Writer

pc *PeerConnection
pc *PeerConnection
patchIsSupported bool
}

// Publish publishes tracks.
Expand Down Expand Up @@ -290,10 +291,7 @@
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")

Check warning on line 294 in internal/protocols/webrtc/whip_client.go

View check run for this annotation

Codecov / codecov/patch

internal/protocols/webrtc/whip_client.go#L294

Added line #L294 was not covered by tests

Location := res.Header.Get("Location")

Expand Down Expand Up @@ -325,6 +323,10 @@
etag string,
candidate *webrtc.ICECandidateInit,
) error {
if !c.patchIsSupported {
return nil
}

Check warning on line 328 in internal/protocols/webrtc/whip_client.go

View check run for this annotation

Codecov / codecov/patch

internal/protocols/webrtc/whip_client.go#L326-L328

Added lines #L326 - L328 were not covered by tests

frag, err := ICEFragmentMarshal(offer.SDP, []*webrtc.ICECandidateInit{candidate})
if err != nil {
return err
Expand Down
Loading