复制项目

This commit is contained in:
kim.dev.6789
2026-01-14 22:35:45 +08:00
parent 305d526110
commit b7f8db7d08
297 changed files with 81784 additions and 0 deletions

30
pkg/common/rtc/rtc.go Normal file
View File

@@ -0,0 +1,30 @@
package rtc
import (
"github.com/livekit/protocol/auth"
"time"
)
func NewLiveKit(key, secret, url string) *LiveKit {
return &LiveKit{
token: auth.NewAccessToken(key, secret),
url: url,
}
}
type LiveKit struct {
token *auth.AccessToken
url string
}
func (l *LiveKit) GetLiveKitURL() string {
return l.url
}
func (l *LiveKit) GetLiveKitToken(room string, identity string) (string, error) {
grant := &auth.VideoGrant{
RoomJoin: true,
Room: room,
}
return l.token.AddGrant(grant).SetIdentity(identity).SetValidFor(time.Hour).ToJWT()
}