Make sure CreateIngest populates the stream_key and URL fields (#861)
This commit is contained in:
@@ -16,7 +16,7 @@ require (
|
|||||||
github.com/gorilla/websocket v1.4.2
|
github.com/gorilla/websocket v1.4.2
|
||||||
github.com/hashicorp/go-version v1.6.0
|
github.com/hashicorp/go-version v1.6.0
|
||||||
github.com/hashicorp/golang-lru v0.5.4
|
github.com/hashicorp/golang-lru v0.5.4
|
||||||
github.com/livekit/protocol v0.13.5-0.20220728214908-67539ebcab2a
|
github.com/livekit/protocol v0.13.5-0.20220801175011-ae34dc3ec45d
|
||||||
github.com/livekit/rtcscore-go v0.0.0-20220524203225-dfd1ba40744a
|
github.com/livekit/rtcscore-go v0.0.0-20220524203225-dfd1ba40744a
|
||||||
github.com/mackerelio/go-osstat v0.2.1
|
github.com/mackerelio/go-osstat v0.2.1
|
||||||
github.com/magefile/mage v1.13.0
|
github.com/magefile/mage v1.13.0
|
||||||
|
|||||||
@@ -237,6 +237,12 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
|||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
github.com/lithammer/shortuuid/v3 v3.0.7 h1:trX0KTHy4Pbwo/6ia8fscyHoGA+mf1jWbPJVuvyJQQ8=
|
github.com/lithammer/shortuuid/v3 v3.0.7 h1:trX0KTHy4Pbwo/6ia8fscyHoGA+mf1jWbPJVuvyJQQ8=
|
||||||
github.com/lithammer/shortuuid/v3 v3.0.7/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts=
|
github.com/lithammer/shortuuid/v3 v3.0.7/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts=
|
||||||
|
github.com/livekit/protocol v0.13.5-0.20220726184153-ad9c55ddef52 h1:E0trQ3RLu2b9hjSiJG1+1hyK/8v57NPJznA7/lKj0qY=
|
||||||
|
github.com/livekit/protocol v0.13.5-0.20220726184153-ad9c55ddef52/go.mod h1:Qd/Dn4BkJfZQy/IjtEeUOGXARrR7l09WDkg5SY8thkw=
|
||||||
|
github.com/livekit/protocol v0.13.5-0.20220727215941-ac26418a52e9 h1:e12j1EyiiTG56Ag44fwpVtnYQ6MVgLv4bYYI0nTgxZY=
|
||||||
|
github.com/livekit/protocol v0.13.5-0.20220727215941-ac26418a52e9/go.mod h1:Qd/Dn4BkJfZQy/IjtEeUOGXARrR7l09WDkg5SY8thkw=
|
||||||
|
github.com/livekit/protocol v0.13.5-0.20220801175011-ae34dc3ec45d h1:9VHZG4Tu723DA/jsg0APEmnk5blWRif9indB/nkdeFY=
|
||||||
|
github.com/livekit/protocol v0.13.5-0.20220801175011-ae34dc3ec45d/go.mod h1:vGQzKUaSYC92o5y7EbnhosgpoLWK9a3PneyYkGOGL0o=
|
||||||
github.com/livekit/protocol v0.13.5-0.20220728214908-67539ebcab2a h1:tRioM9WNDjxGryt03ROYa8zq17J0MqHftCLr8Ex4dM0=
|
github.com/livekit/protocol v0.13.5-0.20220728214908-67539ebcab2a h1:tRioM9WNDjxGryt03ROYa8zq17J0MqHftCLr8Ex4dM0=
|
||||||
github.com/livekit/protocol v0.13.5-0.20220728214908-67539ebcab2a/go.mod h1:vGQzKUaSYC92o5y7EbnhosgpoLWK9a3PneyYkGOGL0o=
|
github.com/livekit/protocol v0.13.5-0.20220728214908-67539ebcab2a/go.mod h1:vGQzKUaSYC92o5y7EbnhosgpoLWK9a3PneyYkGOGL0o=
|
||||||
github.com/livekit/rtcscore-go v0.0.0-20220524203225-dfd1ba40744a h1:cENjhGfslLSDV07gt8ASy47Wd12Q0kBS7hsdunyQ62I=
|
github.com/livekit/rtcscore-go v0.0.0-20220524203225-dfd1ba40744a h1:cENjhGfslLSDV07gt8ASy47Wd12Q0kBS7hsdunyQ62I=
|
||||||
@@ -757,6 +763,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba
|
|||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
|
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
|
||||||
|
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||||
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
|
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
|
||||||
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ type Config struct {
|
|||||||
Video VideoConfig `yaml:"video,omitempty"`
|
Video VideoConfig `yaml:"video,omitempty"`
|
||||||
Room RoomConfig `yaml:"room,omitempty"`
|
Room RoomConfig `yaml:"room,omitempty"`
|
||||||
TURN TURNConfig `yaml:"turn,omitempty"`
|
TURN TURNConfig `yaml:"turn,omitempty"`
|
||||||
|
Ingress IngressConfig `yaml:ingress,omitempty"`
|
||||||
WebHook WebHookConfig `yaml:"webhook,omitempty"`
|
WebHook WebHookConfig `yaml:"webhook,omitempty"`
|
||||||
NodeSelector NodeSelectorConfig `yaml:"node_selector,omitempty"`
|
NodeSelector NodeSelectorConfig `yaml:"node_selector,omitempty"`
|
||||||
KeyFile string `yaml:"key_file,omitempty"`
|
KeyFile string `yaml:"key_file,omitempty"`
|
||||||
@@ -190,6 +191,10 @@ type LimitConfig struct {
|
|||||||
BytesPerSec float32 `yaml:"bytes_per_sec"`
|
BytesPerSec float32 `yaml:"bytes_per_sec"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type IngressConfig struct {
|
||||||
|
RTMPBaseURL string `yaml:"rtmp_base_url"`
|
||||||
|
}
|
||||||
|
|
||||||
func NewConfig(confString string, c *cli.Context) (*Config, error) {
|
func NewConfig(confString string, c *cli.Context) (*Config, error) {
|
||||||
// start with defaults
|
// start with defaults
|
||||||
conf := &Config{
|
conf := &Config{
|
||||||
|
|||||||
+23
-3
@@ -2,9 +2,12 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
|
|
||||||
|
"github.com/livekit/livekit-server/pkg/config"
|
||||||
"github.com/livekit/livekit-server/pkg/telemetry"
|
"github.com/livekit/livekit-server/pkg/telemetry"
|
||||||
"github.com/livekit/protocol/ingress"
|
"github.com/livekit/protocol/ingress"
|
||||||
"github.com/livekit/protocol/livekit"
|
"github.com/livekit/protocol/livekit"
|
||||||
@@ -13,6 +16,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type IngressService struct {
|
type IngressService struct {
|
||||||
|
conf *config.IngressConfig
|
||||||
rpc ingress.RPC
|
rpc ingress.RPC
|
||||||
store IngressStore
|
store IngressStore
|
||||||
roomService livekit.RoomService
|
roomService livekit.RoomService
|
||||||
@@ -21,6 +25,7 @@ type IngressService struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewIngressService(
|
func NewIngressService(
|
||||||
|
conf *config.IngressConfig,
|
||||||
rpc ingress.RPC,
|
rpc ingress.RPC,
|
||||||
store IngressStore,
|
store IngressStore,
|
||||||
rs livekit.RoomService,
|
rs livekit.RoomService,
|
||||||
@@ -28,6 +33,7 @@ func NewIngressService(
|
|||||||
) *IngressService {
|
) *IngressService {
|
||||||
|
|
||||||
return &IngressService{
|
return &IngressService{
|
||||||
|
conf: conf,
|
||||||
rpc: rpc,
|
rpc: rpc,
|
||||||
store: store,
|
store: store,
|
||||||
roomService: rs,
|
roomService: rs,
|
||||||
@@ -52,11 +58,13 @@ func (s *IngressService) CreateIngress(ctx context.Context, req *livekit.CreateI
|
|||||||
return nil, twirpAuthError(err)
|
return nil, twirpAuthError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sk := utils.NewGuid("")
|
||||||
|
|
||||||
info := &livekit.IngressInfo{
|
info := &livekit.IngressInfo{
|
||||||
IngressId: utils.NewGuid(utils.IngressPrefix),
|
IngressId: utils.NewGuid(utils.IngressPrefix),
|
||||||
Name: req.Name,
|
Name: req.Name,
|
||||||
StreamKey: "TODO",
|
StreamKey: sk,
|
||||||
Url: "TODO",
|
Url: newRtmpUrl(s.conf.RTMPBaseURL, sk),
|
||||||
InputType: req.InputType,
|
InputType: req.InputType,
|
||||||
Audio: req.Audio,
|
Audio: req.Audio,
|
||||||
Video: req.Video,
|
Video: req.Video,
|
||||||
@@ -241,7 +249,15 @@ func (s *IngressService) entitiesWorker() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
info, err := s.store.LoadIngress(context.Background(), req.IngressId)
|
var info *livekit.IngressInfo
|
||||||
|
var err error
|
||||||
|
if req.IngressId != "" {
|
||||||
|
info, err = s.store.LoadIngress(context.Background(), req.IngressId)
|
||||||
|
} else if req.StreamKey != "" {
|
||||||
|
info, err = s.store.LoadIngressFromStreamKey(context.Background(), req.StreamKey)
|
||||||
|
} else {
|
||||||
|
err = errors.New("request needs to specity either IngressId or StreamKey")
|
||||||
|
}
|
||||||
err = s.rpc.SendResponse(context.Background(), req, info, err)
|
err = s.rpc.SendResponse(context.Background(), req, info, err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorw("could not send response", err)
|
logger.Errorw("could not send response", err)
|
||||||
@@ -253,3 +269,7 @@ func (s *IngressService) entitiesWorker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newRtmpUrl(baseUrl string, ingressId string) string {
|
||||||
|
return fmt.Sprintf("%s/%s", baseUrl, ingressId)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user