Skip to content

Commit

Permalink
add directOutput interface (#681)
Browse files Browse the repository at this point in the history
  • Loading branch information
frostbyte73 authored Apr 16, 2024
1 parent 2d633a5 commit cb008da
Showing 1 changed file with 46 additions and 35 deletions.
81 changes: 46 additions & 35 deletions egress/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ type EncodedOutputDeprecated interface {
GetSegments() *livekit.SegmentedFileOutput
}

type DirectOutput interface {
GetFile() *livekit.DirectFileOutput
GetWebsocketUrl() string
}

func GetTypes(request interface{}) (string, string) {
switch req := request.(type) {
case *livekit.EgressInfo_RoomComposite:
Expand All @@ -60,50 +65,56 @@ func GetTypes(request interface{}) (string, string) {
return EgressTypeTrackComposite, GetOutputType(req.TrackComposite)

case *livekit.EgressInfo_Track:
switch req.Track.Output.(type) {
case *livekit.TrackEgressRequest_File:
return EgressTypeTrack, OutputTypeFile
case *livekit.TrackEgressRequest_WebsocketUrl:
return EgressTypeTrack, OutputTypeStream
}
return EgressTypeTrack, GetOutputType(req.Track)
}

return Unknown, Unknown
}

func GetOutputType(req EncodedOutput) string {
outputs := make([]string, 0)
if len(req.GetFileOutputs()) > 0 {
outputs = append(outputs, OutputTypeFile)
}
if len(req.GetStreamOutputs()) > 0 {
outputs = append(outputs, OutputTypeStream)
}
if len(req.GetSegmentOutputs()) > 0 {
outputs = append(outputs, OutputTypeSegments)
}
if len(req.GetImageOutputs()) > 0 {
outputs = append(outputs, OutputTypeImages)
}
func GetOutputType(req interface{}) string {
if r, ok := req.(EncodedOutput); ok {
outputs := make([]string, 0)
if len(r.GetFileOutputs()) > 0 {
outputs = append(outputs, OutputTypeFile)
}
if len(r.GetStreamOutputs()) > 0 {
outputs = append(outputs, OutputTypeStream)
}
if len(r.GetSegmentOutputs()) > 0 {
outputs = append(outputs, OutputTypeSegments)
}
if len(r.GetImageOutputs()) > 0 {
outputs = append(outputs, OutputTypeImages)
}

switch len(outputs) {
default:
return OutputTypeMultiple
case 1:
return outputs[0]
case 0:
if r, ok := req.(EncodedOutputDeprecated); ok {
if r.GetFile() != nil {
return OutputTypeFile
}
if r.GetStream() != nil {
return OutputTypeStream
}
if r.GetSegments() != nil {
return OutputTypeSegments
switch len(outputs) {
default:
return OutputTypeMultiple
case 1:
return outputs[0]
case 0:
if r, ok := req.(EncodedOutputDeprecated); ok {
if r.GetFile() != nil {
return OutputTypeFile
}
if r.GetStream() != nil {
return OutputTypeStream
}
if r.GetSegments() != nil {
return OutputTypeSegments
}
}
}
}

if r, ok := req.(DirectOutput); ok {
if r.GetFile() != nil {
return OutputTypeFile
}
if r.GetWebsocketUrl() != "" {
return OutputTypeStream
}
}

return Unknown
}

0 comments on commit cb008da

Please sign in to comment.