From b34b047247441b0dd50c2f1e23560d30803ec64b Mon Sep 17 00:00:00 2001 From: Milos Pesic Date: Mon, 9 Mar 2026 13:17:05 +0100 Subject: [PATCH] Add StopEgress function to the EgressLauncher interface (#4353) This allows for abstracting away how the stop is implemented - default implementation stays the same - the existing OSS egress launcher just calls the existing Stop method on the client. --- pkg/rtc/egress.go | 1 + pkg/service/egress.go | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/rtc/egress.go b/pkg/rtc/egress.go index 06ff4eaf2..f403ea6bb 100644 --- a/pkg/rtc/egress.go +++ b/pkg/rtc/egress.go @@ -29,6 +29,7 @@ import ( type EgressLauncher interface { StartEgress(context.Context, *rpc.StartEgressRequest) (*livekit.EgressInfo, error) + StopEgress(context.Context, *livekit.StopEgressRequest) (*livekit.EgressInfo, error) } func StartParticipantEgress( diff --git a/pkg/service/egress.go b/pkg/service/egress.go index 6edc1f00b..961685de0 100644 --- a/pkg/service/egress.go +++ b/pkg/service/egress.go @@ -254,6 +254,13 @@ func (s *egressLauncher) StartEgress(ctx context.Context, req *rpc.StartEgressRe return info, nil } +func (s *egressLauncher) StopEgress(ctx context.Context, req *livekit.StopEgressRequest) (*livekit.EgressInfo, error) { + if s.client == nil { + return nil, ErrEgressNotConnected + } + return s.client.StopEgress(ctx, req.EgressId, req) +} + type LayoutMetadata struct { Layout string `json:"layout"` } @@ -344,11 +351,7 @@ func (s *EgressService) StopEgress(ctx context.Context, req *livekit.StopEgressR return nil, twirpAuthError(err) } - if s.client == nil { - return nil, ErrEgressNotConnected - } - - info, err = s.client.StopEgress(ctx, req.EgressId, req) + info, err = s.launcher.StopEgress(ctx, req) if err != nil { var loadErr error info, loadErr = s.io.GetEgress(ctx, &rpc.GetEgressRequest{EgressId: req.EgressId})