Rpcs for ingress proxy WHIP (#3911)

See https://github.com/livekit/protocol/pull/1194
This commit is contained in:
cnderrauber
2025-09-09 22:49:42 +08:00
committed by GitHub
parent 991a4a4f53
commit 76645fad5e
13 changed files with 189 additions and 76 deletions
+8 -3
View File
@@ -23,6 +23,9 @@ import (
"net/url"
"strings"
"github.com/pion/webrtc/v4"
"github.com/tomnomnom/linkheader"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/livekit-server/pkg/routing"
"github.com/livekit/livekit-server/pkg/rtc"
@@ -33,8 +36,6 @@ import (
"github.com/livekit/protocol/rpc"
"github.com/livekit/protocol/utils/guid"
"github.com/livekit/psrpc"
"github.com/pion/webrtc/v4"
"github.com/tomnomnom/linkheader"
)
const (
@@ -115,6 +116,7 @@ type createRequest struct {
ClientIP string
OfferSDP string
SubscribedParticipantTrackNames map[string][]string
FromIngress bool
}
func (s *WHIPService) validateCreate(r *http.Request) (*createRequest, int, error) {
@@ -152,6 +154,8 @@ func (s *WHIPService) validateCreate(r *http.Request) (*createRequest, int, erro
}
}
fromIngress := r.Header.Get("X-Livekit-Ingress")
offerSDPBytes, err := ioutil.ReadAll(r.Body)
if err != nil {
return nil, http.StatusBadRequest, fmt.Errorf("body does not have SDP offer: %s", err)
@@ -196,6 +200,7 @@ func (s *WHIPService) validateCreate(r *http.Request) (*createRequest, int, erro
clientInfo.ClientIP,
offerSDP,
clientInfo.SubscribedParticipantTrackNames,
fromIngress != "",
}, http.StatusOK, nil
}
@@ -242,6 +247,7 @@ func (s *WHIPService) handleCreate(w http.ResponseWriter, r *http.Request) {
OfferSdp: req.OfferSDP,
StartSession: starSession,
SubscribedParticipantTracks: subscribedParticipantTracks,
FromIngress: req.FromIngress,
})
if err != nil {
s.handleError("Create", w, r, http.StatusServiceUnavailable, err)
@@ -298,7 +304,6 @@ func (s *WHIPService) handleCreate(w http.ResponseWriter, r *http.Request) {
"status", http.StatusCreated,
"response", logger.Proto(res),
)
return
}
func (s *WHIPService) handleParticipantGet(w http.ResponseWriter, r *http.Request) {