webrtc: emit RFC 9261 §5.2 Link headers on WHIP 201 Publish response (issue #21)
Some checks failed
ci / race tests (push) Blocked by required conditions
ci / WebRTC smoke (5-viewer fanout) (push) Blocked by required conditions
ci / WebRTC latency p95 gate (push) Blocked by required conditions
ci / vet + build (push) Has been cancelled

This commit is contained in:
Zac Gaetano 2026-05-10 20:34:47 -04:00
parent 6ec0328b19
commit f1062a4c36

View file

@ -174,6 +174,13 @@ func (h *WHIPHandler) Publish(c echo.Context) error {
h.recordRequest("publish", id, http.StatusCreated, t0)
// RFC 9261 §5.2: emit one Link header per configured ICE server so
// that the publisher (OBS, browser, GStreamer, etc.) can discover
// STUN/TURN without a separate signalling round-trip — symmetric
// with the WHEP Subscribe Link header added in issue #19.
for _, uri := range h.sub.ICEServerURIs() {
c.Response().Header().Add("Link", "<"+uri+">; rel=\"ice-server\"")
}
c.Response().Header().Set("Content-Type", "application/sdp")
c.Response().Header().Set("Location", "/whip/"+id+"/"+rid)
c.Response().Header().Set("ETag", `"`+rid+`"`)
@ -229,6 +236,13 @@ func (h *WHIPHandler) Unpublish(c echo.Context) error {
// TrickleIngest handles PATCH /whip/:id/:resource — adds ICE candidates
// from a trickle-ice-sdpfrag body.
//
// The body format follows draft-ietf-wish-whip §5: one or more
// "a=candidate:…" lines in application/trickle-ice-sdpfrag. Each
// matching line is forwarded directly to the underlying PeerConnection.
// An empty body or a body with no candidate lines is a no-op (clients
// signal end-of-candidates via an a=end-of-candidates line, which
// AddICECandidate correctly ignores at the Pion level).
//
// @Summary Trickle ICE candidates for a WHIP publish session
// @Tags v16.16.0
// @ID webrtc-3-whip-trickle