From 7eb1105d631a8b672978f971702eccd6621430bd Mon Sep 17 00:00:00 2001 From: David Colburn Date: Tue, 4 Jun 2024 18:56:07 -0700 Subject: [PATCH] Remove early returns from updateOutputs (#689) * remove early returns * check keyframe interval in stream tests * float64 --- pkg/config/output.go | 8 +++----- test/stream.go | 3 +++ test/web.go | 4 +--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pkg/config/output.go b/pkg/config/output.go index 065dbd57..4b059087 100644 --- a/pkg/config/output.go +++ b/pkg/config/output.go @@ -21,6 +21,8 @@ import ( "github.com/livekit/protocol/livekit" ) +const StreamKeyframeInterval = 4.0 + type OutputConfig interface { GetOutputType() types.OutputType } @@ -67,7 +69,6 @@ func (p *PipelineConfig) updateEncodedOutputs(req egress.EncodedOutput) error { p.Info.FileResults = []*livekit.FileInfo{conf.FileInfo} if len(streams)+len(segments)+len(images) == 0 { p.Info.Result = &livekit.EgressInfo_File{File: conf.FileInfo} - return nil } } @@ -107,7 +108,6 @@ func (p *PipelineConfig) updateEncodedOutputs(req egress.EncodedOutput) error { } p.Info.Result = &livekit.EgressInfo_Stream{Stream: &livekit.StreamInfoList{Info: streamInfoList}} - return nil } } @@ -139,7 +139,6 @@ func (p *PipelineConfig) updateEncodedOutputs(req egress.EncodedOutput) error { p.Info.SegmentResults = []*livekit.SegmentsInfo{conf.SegmentsInfo} if len(streams)+len(files)+len(images) == 0 { p.Info.Result = &livekit.EgressInfo_Segments{Segments: conf.SegmentsInfo} - return nil } } @@ -152,7 +151,7 @@ func (p *PipelineConfig) updateEncodedOutputs(req egress.EncodedOutput) error { p.KeyFrameInterval = 0 } else if p.KeyFrameInterval == 0 && p.Outputs[types.EgressTypeStream] != nil { // default 4s for streams - p.KeyFrameInterval = 4 + p.KeyFrameInterval = StreamKeyframeInterval } err := p.updateImageOutputs(images) @@ -206,7 +205,6 @@ func (p *PipelineConfig) updateDirectOutput(req *livekit.TrackEgressRequest) err } func (p *PipelineConfig) updateImageOutputs(images []*livekit.ImageOutput) error { - if len(images) > 0 && !p.VideoEnabled { return errors.ErrInvalidInput("audio_only") } diff --git a/test/stream.go b/test/stream.go index 05c3ccaf..1f512a69 100644 --- a/test/stream.go +++ b/test/stream.go @@ -38,6 +38,9 @@ func (r *Runner) runStreamTest(t *testing.T, req *rpc.StartEgressRequest, test * p, err := config.GetValidatedPipelineConfig(r.ServiceConfig, req) require.NoError(t, err) require.Equal(t, test.expectVideoEncoding, p.VideoEncoding) + if test.expectVideoEncoding { + require.Equal(t, config.StreamKeyframeInterval, p.KeyFrameInterval) + } // verify and check update time.Sleep(time.Second * 5) diff --git a/test/web.go b/test/web.go index d5ba8440..8fae9a13 100644 --- a/test/web.go +++ b/test/web.go @@ -95,9 +95,7 @@ func (r *Runner) testWebStream(t *testing.T) { }, } - r.runStreamTest(t, req, &testCase{ - expectVideoEncoding: true, - }) + r.runStreamTest(t, req, &testCase{expectVideoEncoding: true}) }) }