From 11749eace9cc52e89067a8135dfb3267a9f0c4ba Mon Sep 17 00:00:00 2001 From: Benjamin Pracht Date: Tue, 2 May 2023 13:26:47 -0700 Subject: [PATCH] Add support for creating WHIP ingress (#1674) --- config-sample.yaml | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- pkg/config/config.go | 1 + pkg/service/ingress.go | 12 +++++++++++- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/config-sample.yaml b/config-sample.yaml index 7375b239..122fac28 100644 --- a/config-sample.yaml +++ b/config-sample.yaml @@ -224,9 +224,9 @@ keys: # ingress server # ingress: # # Prefix used to generate RTMP URLs for RTMP ingress. -# # The stream_key will be appended to this base and returned as part of the -# # ingress info # rtmp_base_url: "rtmp://my.domain.com/live" +# # Prefix used to generate WHIP URLs for WHIP ingress. +# whip_base_url: "http://my.domain.com/whip" # egress server # egress: diff --git a/go.mod b/go.mod index b6292142..25a0643b 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/jxskiss/base62 v1.1.0 github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1 github.com/livekit/mediatransportutil v0.0.0-20230326055817-ed569ca13d26 - github.com/livekit/protocol v1.5.6-0.20230428011359-db5afb1c7f9b + github.com/livekit/protocol v1.5.6-0.20230501213748-b2974692ebfd github.com/livekit/psrpc v0.3.1-0.20230502152150-df9dd21fba11 github.com/mackerelio/go-osstat v0.2.4 github.com/magefile/mage v1.14.0 diff --git a/go.sum b/go.sum index 3b4cb427..01f70187 100644 --- a/go.sum +++ b/go.sum @@ -121,8 +121,8 @@ github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1 h1:jm09419p0lqTkD github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ= github.com/livekit/mediatransportutil v0.0.0-20230326055817-ed569ca13d26 h1:QlQFyMwCDgjyySsrgmrMcVbEBA6KZcyTzvK+z346tUA= github.com/livekit/mediatransportutil v0.0.0-20230326055817-ed569ca13d26/go.mod h1:eDA41kiySZoG+wy4Etsjb3w0jjLx69i/vAmSjG4bteA= -github.com/livekit/protocol v1.5.6-0.20230428011359-db5afb1c7f9b h1:UEFMJr1OTF0yAX9mRRaQQ/YrTA6H7hCkbuABWfT6wLk= -github.com/livekit/protocol v1.5.6-0.20230428011359-db5afb1c7f9b/go.mod h1:MBW05GWdhbl+o6u2gLLCQtDvr9EvcV4VWckpIYtoM2c= +github.com/livekit/protocol v1.5.6-0.20230501213748-b2974692ebfd h1:5gCLKGemm4JCEZvKIPpKVPOpguFt3/S2ZzYQd+4tInA= +github.com/livekit/protocol v1.5.6-0.20230501213748-b2974692ebfd/go.mod h1:MBW05GWdhbl+o6u2gLLCQtDvr9EvcV4VWckpIYtoM2c= github.com/livekit/psrpc v0.3.1-0.20230502152150-df9dd21fba11 h1:VS23iVQu/TNiLEM5XjbBSY28+B6nSewjKWPDbieg0Ho= github.com/livekit/psrpc v0.3.1-0.20230502152150-df9dd21fba11/go.mod h1:n6JntEg+zT6Ji8InoyTpV7wusPNwGqqtxmHlkNhDN0U= github.com/mackerelio/go-osstat v0.2.4 h1:qxGbdPkFo65PXOb/F/nhDKpF2nGmGaCFDLXoZjJTtUs= diff --git a/pkg/config/config.go b/pkg/config/config.go index f0dc1e1c..315fb3aa 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -259,6 +259,7 @@ type EgressConfig struct { type IngressConfig struct { RTMPBaseURL string `yaml:"rtmp_base_url"` + WHIPBaseURL string `yaml:"whip_base_url"` } // not exposed to YAML diff --git a/pkg/service/ingress.go b/pkg/service/ingress.go index 52ff81e6..9456224a 100644 --- a/pkg/service/ingress.go +++ b/pkg/service/ingress.go @@ -56,7 +56,17 @@ func (s *IngressService) CreateIngress(ctx context.Context, req *livekit.CreateI AppendLogFields(ctx, fields...) }() - ig, err := s.CreateIngressWithUrlPrefix(ctx, s.conf.RTMPBaseURL, req) + var urlPrefix string + switch req.InputType { + case livekit.IngressInput_RTMP_INPUT: + urlPrefix = s.conf.RTMPBaseURL + case livekit.IngressInput_WHIP_INPUT: + urlPrefix = s.conf.WHIPBaseURL + default: + return nil, ingress.ErrInvalidIngressType + } + + ig, err := s.CreateIngressWithUrlPrefix(ctx, urlPrefix, req) if err != nil { return nil, err }