@@ -633,41 +633,21 @@ func sourceToString(source livekit.TrackSource) string {
633633}
634634
635635func sourceToProto (sourceStr string ) livekit.TrackSource {
636- switch strings .ToLower (sourceStr ) {
637- case "camera" :
638- return livekit .TrackSource_CAMERA
639- case "microphone" :
640- return livekit .TrackSource_MICROPHONE
641- case "screen_share" :
642- return livekit .TrackSource_SCREEN_SHARE
643- case "screen_share_audio" :
644- return livekit .TrackSource_SCREEN_SHARE_AUDIO
645- default :
646- return livekit .TrackSource_UNKNOWN
636+ if val , ok := livekit .TrackSource_value [strings .ToUpper (sourceStr )]; ok {
637+ return livekit .TrackSource (val )
647638 }
639+ return livekit .TrackSource_UNKNOWN
648640}
649641
650642func kindFromProto (source livekit.ParticipantInfo_Kind ) string {
651643 return strings .ToLower (source .String ())
652644}
653645
654646func kindToProto (sourceStr string ) livekit.ParticipantInfo_Kind {
655- switch strings .ToLower (sourceStr ) {
656- case "" , "standard" :
657- return livekit .ParticipantInfo_STANDARD
658- case "ingress" :
659- return livekit .ParticipantInfo_INGRESS
660- case "egress" :
661- return livekit .ParticipantInfo_EGRESS
662- case "sip" :
663- return livekit .ParticipantInfo_SIP
664- case "agent" :
665- return livekit .ParticipantInfo_AGENT
666- case "connector" :
667- return livekit .ParticipantInfo_CONNECTOR
668- default :
669- return livekit .ParticipantInfo_STANDARD
647+ if val , ok := livekit .ParticipantInfo_Kind_value [strings .ToUpper (sourceStr )]; ok {
648+ return livekit .ParticipantInfo_Kind (val )
670649 }
650+ return livekit .ParticipantInfo_STANDARD
671651}
672652
673653func kindDetailsFromProto (details []livekit.ParticipantInfo_KindDetail ) []string {
@@ -681,15 +661,8 @@ func kindDetailsFromProto(details []livekit.ParticipantInfo_KindDetail) []string
681661func kindDetailsToProto (details []string ) []livekit.ParticipantInfo_KindDetail {
682662 result := make ([]livekit.ParticipantInfo_KindDetail , 0 , len (details ))
683663 for _ , d := range details {
684- switch strings .ToLower (d ) {
685- case "cloud_agent" :
686- result = append (result , livekit .ParticipantInfo_CLOUD_AGENT )
687- case "forwarded" :
688- result = append (result , livekit .ParticipantInfo_FORWARDED )
689- case "connector_whatsapp" :
690- result = append (result , livekit .ParticipantInfo_CONNECTOR_WHATSAPP )
691- case "connector_twilio" :
692- result = append (result , livekit .ParticipantInfo_CONNECTOR_TWILIO )
664+ if val , ok := livekit .ParticipantInfo_KindDetail_value [strings .ToUpper (d )]; ok {
665+ result = append (result , livekit .ParticipantInfo_KindDetail (val ))
693666 }
694667 }
695668 return result
0 commit comments