Make sure CreateIngest populates the stream_key and URL fields (#861)

This commit is contained in:
Benjamin Pracht
2022-08-01 11:35:30 -07:00
committed by GitHub
parent a393d64ccc
commit 5558aa5228
4 changed files with 37 additions and 4 deletions
+5
View File
@@ -38,6 +38,7 @@ type Config struct {
Video VideoConfig `yaml:"video,omitempty"`
Room RoomConfig `yaml:"room,omitempty"`
TURN TURNConfig `yaml:"turn,omitempty"`
Ingress IngressConfig `yaml:ingress,omitempty"`
WebHook WebHookConfig `yaml:"webhook,omitempty"`
NodeSelector NodeSelectorConfig `yaml:"node_selector,omitempty"`
KeyFile string `yaml:"key_file,omitempty"`
@@ -190,6 +191,10 @@ type LimitConfig struct {
BytesPerSec float32 `yaml:"bytes_per_sec"`
}
type IngressConfig struct {
RTMPBaseURL string `yaml:"rtmp_base_url"`
}
func NewConfig(confString string, c *cli.Context) (*Config, error) {
// start with defaults
conf := &Config{
+23 -3
View File
@@ -2,9 +2,12 @@ package service
import (
"context"
"errors"
"fmt"
"google.golang.org/protobuf/proto"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/livekit-server/pkg/telemetry"
"github.com/livekit/protocol/ingress"
"github.com/livekit/protocol/livekit"
@@ -13,6 +16,7 @@ import (
)
type IngressService struct {
conf *config.IngressConfig
rpc ingress.RPC
store IngressStore
roomService livekit.RoomService
@@ -21,6 +25,7 @@ type IngressService struct {
}
func NewIngressService(
conf *config.IngressConfig,
rpc ingress.RPC,
store IngressStore,
rs livekit.RoomService,
@@ -28,6 +33,7 @@ func NewIngressService(
) *IngressService {
return &IngressService{
conf: conf,
rpc: rpc,
store: store,
roomService: rs,
@@ -52,11 +58,13 @@ func (s *IngressService) CreateIngress(ctx context.Context, req *livekit.CreateI
return nil, twirpAuthError(err)
}
sk := utils.NewGuid("")
info := &livekit.IngressInfo{
IngressId: utils.NewGuid(utils.IngressPrefix),
Name: req.Name,
StreamKey: "TODO",
Url: "TODO",
StreamKey: sk,
Url: newRtmpUrl(s.conf.RTMPBaseURL, sk),
InputType: req.InputType,
Audio: req.Audio,
Video: req.Video,
@@ -241,7 +249,15 @@ func (s *IngressService) entitiesWorker() {
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)
if err != nil {
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)
}