Allow passing extra attributes to RTC endpoint. (#3693)

This commit is contained in:
Denys Smirnov
2025-06-06 14:40:06 +03:00
committed by GitHub
parent 758e176250
commit 425f6bb3a9
4 changed files with 116 additions and 11 deletions
+10
View File
@@ -16,6 +16,8 @@ package client
import (
"context"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"io"
@@ -113,6 +115,7 @@ var (
type Options struct {
AutoSubscribe bool
Publish string
Attributes map[string]string
ClientInfo *livekit.ClientInfo
DisabledCodecs []webrtc.RTPCodecCapability
TokenCustomizer func(token *auth.AccessToken, grants *auth.VideoGrant)
@@ -135,6 +138,13 @@ func NewWebSocketConn(host, token string, opts *Options) (*websocket.Conn, error
if opts.Publish != "" {
connectUrl += encodeQueryParam("publish", opts.Publish)
}
if len(opts.Attributes) != 0 {
data, err := json.Marshal(opts.Attributes)
if err != nil {
return nil, err
}
connectUrl += encodeQueryParam("attributes", base64.URLEncoding.EncodeToString(data))
}
if opts.ClientInfo != nil {
if opts.ClientInfo.DeviceModel != "" {
connectUrl += encodeQueryParam("device_model", opts.ClientInfo.DeviceModel)