mirror of
https://github.com/livekit/livekit.git
synced 2026-10-23 13:02:53 +00:00
web egress (#1126)
This commit is contained in:
1 parent
26fe910e88
commit
7223d9c132
3 files changed
+17
-31
No files matched your search
@@ -18,7 +18,7 @@ require (
|
||||
github.com/hashicorp/golang-lru v0.5.4
|
||||
github.com/livekit/mageutil v0.0.0-20221002073820-d9198083cfdc
|
||||
github.com/livekit/mediatransportutil v0.0.0-20221007030528-7440725c362b
|
||||
github.com/livekit/protocol v1.1.3-0.20221025145130-b01c630e70a6
|
||||
github.com/livekit/protocol v1.1.3-0.20221026203734-d3635b12268c
|
||||
github.com/livekit/rtcscore-go v0.0.0-20220815072451-20ee10ae1995
|
||||
github.com/mackerelio/go-osstat v0.2.3
|
||||
github.com/magefile/mage v1.14.0
|
||||
|
||||
@@ -246,8 +246,8 @@ github.com/livekit/mageutil v0.0.0-20221002073820-d9198083cfdc h1:e3GIA9AL6h4a38
|
||||
github.com/livekit/mageutil v0.0.0-20221002073820-d9198083cfdc/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ=
|
||||
github.com/livekit/mediatransportutil v0.0.0-20221007030528-7440725c362b h1:RBNV8TckETSkIkKxcD12d8nZKVkB9GSY/sQlMoaruP4=
|
||||
github.com/livekit/mediatransportutil v0.0.0-20221007030528-7440725c362b/go.mod h1:1Dlx20JPoIKGP45eo+yuj0HjeE25zmyeX/EWHiPCjFw=
|
||||
github.com/livekit/protocol v1.1.3-0.20221025145130-b01c630e70a6 h1:uhdIYpF6z9K8AV5xYeyruLCODxCdWvgjG47L2CRdeNo=
|
||||
github.com/livekit/protocol v1.1.3-0.20221025145130-b01c630e70a6/go.mod h1:ue2AMoIScDwxvIJZDJm7L18gvKHZ1LvVckCGNn6rvFA=
|
||||
github.com/livekit/protocol v1.1.3-0.20221026203734-d3635b12268c h1:5BciCRrrcYE8HyKACliG2RTwNhkT8dYtPu4rp2O8Sq4=
|
||||
github.com/livekit/protocol v1.1.3-0.20221026203734-d3635b12268c/go.mod h1:BIjSeLm8mZA7c91gKGwyXzenMFxVva0wjbxOftSGuEI=
|
||||
github.com/livekit/rtcscore-go v0.0.0-20220815072451-20ee10ae1995 h1:vOaY2qvfLihDyeZtnGGN1Law9wRrw8BMGCr1TygTvMw=
|
||||
github.com/livekit/rtcscore-go v0.0.0-20220815072451-20ee10ae1995/go.mod h1:116ych8UaEs9vfIE8n6iZCZ30iagUFTls0vRmC+Ix5U=
|
||||
github.com/mackerelio/go-osstat v0.2.3 h1:jAMXD5erlDE39kdX2CU7YwCGRcxIO33u/p8+Fhe5dJw=
|
||||
|
||||
+14
-28
@@ -103,6 +103,14 @@ func (s *EgressService) StartTrackEgress(ctx context.Context, req *livekit.Track
|
||||
})
|
||||
}
|
||||
|
||||
func (s *EgressService) StartWebEgress(ctx context.Context, req *livekit.WebEgressRequest) (*livekit.EgressInfo, error) {
|
||||
return s.StartEgress(ctx, "", &livekit.StartEgressRequest{
|
||||
Request: &livekit.StartEgressRequest_Web{
|
||||
Web: req,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (s *EgressService) StartEgress(ctx context.Context, roomName livekit.RoomName, req *livekit.StartEgressRequest) (*livekit.EgressInfo, error) {
|
||||
if err := EnsureRecordPermission(ctx); err != nil {
|
||||
return nil, twirpAuthError(err)
|
||||
@@ -110,11 +118,13 @@ func (s *EgressService) StartEgress(ctx context.Context, roomName livekit.RoomNa
|
||||
return nil, ErrEgressNotConnected
|
||||
}
|
||||
|
||||
room, _, err := s.store.LoadRoom(ctx, roomName, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if roomName != "" {
|
||||
room, _, err := s.store.LoadRoom(ctx, roomName, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.RoomId = room.Sid
|
||||
}
|
||||
req.RoomId = room.Sid
|
||||
|
||||
return s.launcher.StartEgress(ctx, req)
|
||||
}
|
||||
@@ -125,8 +135,6 @@ func (s *egressLauncher) StartEgress(ctx context.Context, req *livekit.StartEgre
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ensureRoomName(info)
|
||||
|
||||
s.telemetry.EgressStarted(ctx, info)
|
||||
go func() {
|
||||
if err := s.es.StoreEgress(ctx, info); err != nil {
|
||||
@@ -154,8 +162,6 @@ func (s *EgressService) UpdateLayout(ctx context.Context, req *livekit.UpdateLay
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ensureRoomName(info)
|
||||
|
||||
metadata, err := json.Marshal(&LayoutMetadata{Layout: req.Layout})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -195,8 +201,6 @@ func (s *EgressService) UpdateStream(ctx context.Context, req *livekit.UpdateStr
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ensureRoomName(info)
|
||||
|
||||
go func() {
|
||||
if err := s.es.UpdateEgress(ctx, info); err != nil {
|
||||
logger.Errorw("could not write egress info", err)
|
||||
@@ -240,8 +244,6 @@ func (s *EgressService) StopEgress(ctx context.Context, req *livekit.StopEgressR
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ensureRoomName(info)
|
||||
|
||||
go func() {
|
||||
if err := s.es.UpdateEgress(ctx, info); err != nil {
|
||||
logger.Errorw("could not write egress info", err)
|
||||
@@ -277,8 +279,6 @@ func (s *EgressService) startWorker() error {
|
||||
continue
|
||||
}
|
||||
|
||||
ensureRoomName(res)
|
||||
|
||||
switch res.Status {
|
||||
case livekit.EgressStatus_EGRESS_COMPLETE,
|
||||
livekit.EgressStatus_EGRESS_FAILED,
|
||||
@@ -320,17 +320,3 @@ func (s *EgressService) startWorker() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Ensure compatibility with Egress <= v1.0.5
|
||||
func ensureRoomName(info *livekit.EgressInfo) {
|
||||
if info.RoomName == "" {
|
||||
switch r := info.Request.(type) {
|
||||
case *livekit.EgressInfo_RoomComposite:
|
||||
info.RoomName = r.RoomComposite.RoomName
|
||||
case *livekit.EgressInfo_TrackComposite:
|
||||
info.RoomName = r.TrackComposite.RoomName
|
||||
case *livekit.EgressInfo_Track:
|
||||
info.RoomName = r.Track.RoomName
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user