@@ -17,8 +17,11 @@ package egress
1717import "github.com/livekit/protocol/livekit"
1818
1919const (
20+ EgressTypeTemplate = "template"
21+ EgressTypeWeb = "web"
22+ EgressTypeMedia = "media"
23+
2024 EgressTypeRoomComposite = "room_composite"
21- EgressTypeWeb = "web"
2225 EgressTypeParticipant = "participant"
2326 EgressTypeTrackComposite = "track_composite"
2427 EgressTypeTrack = "track"
@@ -55,6 +58,14 @@ type DirectOutput interface {
5558 GetWebsocketUrl () string
5659}
5760
61+ type EgressRequest interface {
62+ GetMedia () * livekit.MediaSource
63+ GetTemplate () * livekit.TemplateSource
64+ GetWeb () * livekit.WebSource
65+ GetOutputs () []* livekit.Output
66+ GetStorage () * livekit.StorageConfig
67+ }
68+
5869type UploadRequest interface {
5970 GetS3 () * livekit.S3Upload
6071 GetGcp () * livekit.GCPUpload
@@ -63,6 +74,20 @@ type UploadRequest interface {
6374}
6475
6576func GetTypes (request interface {}) (string , string ) {
77+ if r , ok := request .(EgressRequest ); ok {
78+ var egressType string
79+ if r .GetMedia () != nil {
80+ egressType = EgressTypeMedia
81+ } else if r .GetTemplate () != nil {
82+ egressType = EgressTypeTemplate
83+ } else if r .GetWeb () != nil {
84+ egressType = EgressTypeWeb
85+ } else {
86+ egressType = Unknown
87+ }
88+ return egressType , GetOutputTypeV2 (r .GetOutputs ())
89+ }
90+
6691 switch req := request .(type ) {
6792 case * livekit.EgressInfo_RoomComposite :
6893 return EgressTypeRoomComposite , GetOutputType (req .RoomComposite )
@@ -83,6 +108,27 @@ func GetTypes(request interface{}) (string, string) {
83108 return Unknown , Unknown
84109}
85110
111+ func GetOutputTypeV2 (outputs []* livekit.Output ) string {
112+ if len (outputs ) == 0 {
113+ return Unknown
114+ }
115+ if len (outputs ) > 1 {
116+ return OutputTypeMultiple
117+ }
118+ switch outputs [0 ].Config .(type ) {
119+ case * livekit.Output_File :
120+ return OutputTypeFile
121+ case * livekit.Output_Stream :
122+ return OutputTypeStream
123+ case * livekit.Output_Segments :
124+ return OutputTypeSegments
125+ case * livekit.Output_Images :
126+ return OutputTypeImages
127+ default :
128+ return Unknown
129+ }
130+ }
131+
86132func GetOutputType (req interface {}) string {
87133 if r , ok := req .(EncodedOutput ); ok {
88134 outputs := make ([]string , 0 )
0 commit comments