Skip to content

Commit

Permalink
Remove early returns from updateOutputs (#689)
Browse files Browse the repository at this point in the history
* remove early returns

* check keyframe interval in stream tests

* float64
  • Loading branch information
frostbyte73 authored Jun 5, 2024
1 parent dd1694d commit 7eb1105
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
8 changes: 3 additions & 5 deletions pkg/config/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"github.com/livekit/protocol/livekit"
)

const StreamKeyframeInterval = 4.0

type OutputConfig interface {
GetOutputType() types.OutputType
}
Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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
}
}

Expand All @@ -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)
Expand Down Expand Up @@ -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")
}
Expand Down
3 changes: 3 additions & 0 deletions test/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions test/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
})
}

Expand Down

0 comments on commit 7eb1105

Please sign in to comment.