diff --git a/engine.go b/engine.go index bc15e76d..b44b906e 100644 --- a/engine.go +++ b/engine.go @@ -166,7 +166,18 @@ func (e *RTCEngine) JoinContext(ctx context.Context, url string, token string, p e.token.Store(token) e.connParams = params - err = e.configure(res.IceServers, res.ClientConfiguration, proto.Bool(res.SubscriberPrimary)) + usedIceServers := params.ICEServers + if len(usedIceServers) == 0 { + usedIceServers = res.IceServers + } + clientConfig := res.ClientConfiguration + if params.ForceRelay { + if clientConfig == nil { + clientConfig = &livekit.ClientConfiguration{} + } + clientConfig.ForceRelay = livekit.ClientConfigSetting_ENABLED + } + err = e.configure(usedIceServers, clientConfig, proto.Bool(res.SubscriberPrimary)) if err != nil { return nil, err } diff --git a/room.go b/room.go index 6d08e5d1..8e3c7aba 100644 --- a/room.go +++ b/room.go @@ -103,6 +103,8 @@ type SignalClientConnectParams struct { Interceptors []interceptor.Factory ICETransportPolicy webrtc.ICETransportPolicy + ICEServers []*livekit.ICEServer + ForceRelay bool } type ConnectOption func(*SignalClientConnectParams) @@ -147,6 +149,18 @@ func WithDisableRegionDiscovery() ConnectOption { } } +func WithICEServers(iceServers []*livekit.ICEServer) ConnectOption { + return func(p *SignalClientConnectParams) { + p.ICEServers = iceServers + } +} + +func WithForceRelay(forceRelay bool) ConnectOption { + return func(p *SignalClientConnectParams) { + p.ForceRelay = forceRelay + } +} + type PLIWriter func(webrtc.SSRC) type Room struct {