@@ -21,25 +21,35 @@ import (
2121 "github.com/livekit/protocol/livekit"
2222)
2323
24- func BuildSIPToken (
25- apiKey , secret , roomName string ,
26- participantIdentity , participantName , participantMeta string ,
27- participantAttrs map [string ]string ,
28- ) (string , error ) {
24+ type SIPTokenParams struct {
25+ APIKey string
26+ APISecret string
27+ RoomName string
28+ ParticipantIdentity string
29+ ParticipantName string
30+ ParticipantMetadata string
31+ ParticipantAttributes map [string ]string
32+ RoomPreset string
33+ RoomConfig * livekit.RoomConfiguration
34+ }
35+
36+ func BuildSIPToken (params SIPTokenParams ) (string , error ) {
2937 t := true
30- at := auth .NewAccessToken (apiKey , secret ).
31- AddGrant (& auth.VideoGrant {
38+ at := auth .NewAccessToken (params . APIKey , params . APISecret ).
39+ SetVideoGrant (& auth.VideoGrant {
3240 RoomJoin : true ,
33- Room : roomName ,
41+ Room : params . RoomName ,
3442 CanSubscribe : & t ,
3543 CanPublish : & t ,
3644 CanPublishData : & t ,
3745 CanUpdateOwnMetadata : & t ,
3846 }).
39- SetIdentity (participantIdentity ).
40- SetName (participantName ).
41- SetMetadata (participantMeta ).
42- SetAttributes (participantAttrs ).
47+ SetIdentity (params .ParticipantIdentity ).
48+ SetName (params .ParticipantName ).
49+ SetMetadata (params .ParticipantMetadata ).
50+ SetAttributes (params .ParticipantAttributes ).
51+ SetRoomPreset (params .RoomPreset ).
52+ SetRoomConfig (params .RoomConfig ).
4353 SetKind (livekit .ParticipantInfo_SIP ).
4454 SetValidFor (24 * time .Hour )
4555
0 commit comments