ICE config using protocol model (#1233)

* ICE config using protocol model

* use pointers consistently

* protocol pointer

* mage generate
This commit is contained in:
Raja Subramanian
2022-12-19 10:25:08 +05:30
committed by GitHub
parent 33902a9f2a
commit 241a7120f5
8 changed files with 64 additions and 87 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ require (
github.com/jxskiss/base62 v1.1.0
github.com/livekit/mageutil v0.0.0-20221002073820-d9198083cfdc
github.com/livekit/mediatransportutil v0.0.0-20221007030528-7440725c362b
github.com/livekit/protocol v1.3.1-0.20221210053957-e43a6056a641
github.com/livekit/protocol v1.3.1-0.20221219041553-fc943512b0fb
github.com/livekit/rtcscore-go v0.0.0-20220815072451-20ee10ae1995
github.com/mackerelio/go-osstat v0.2.3
github.com/magefile/mage v1.14.0
+2 -13
View File
@@ -115,10 +115,8 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/zapr v1.2.3/go.mod h1:eIauM6P8qSvTw5o2ez6UEAfGjQKrxQTl5EoK+Qa2oG4=
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
@@ -245,8 +243,8 @@ github.com/livekit/mageutil v0.0.0-20221002073820-d9198083cfdc h1:e3GIA9AL6h4a38
github.com/livekit/mageutil v0.0.0-20221002073820-d9198083cfdc/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ=
github.com/livekit/mediatransportutil v0.0.0-20221007030528-7440725c362b h1:RBNV8TckETSkIkKxcD12d8nZKVkB9GSY/sQlMoaruP4=
github.com/livekit/mediatransportutil v0.0.0-20221007030528-7440725c362b/go.mod h1:1Dlx20JPoIKGP45eo+yuj0HjeE25zmyeX/EWHiPCjFw=
github.com/livekit/protocol v1.3.1-0.20221210053957-e43a6056a641 h1:CXGhAjIOaq/yzQz7OVEqN2CZcEZ8J3Bq7GbMufe35CA=
github.com/livekit/protocol v1.3.1-0.20221210053957-e43a6056a641/go.mod h1:87MLIMbKaZs0SbDebMw1b7n/gD5utwEDq3zIRYcHJHA=
github.com/livekit/protocol v1.3.1-0.20221219041553-fc943512b0fb h1:Kt92FupD3q4GzAlabx7bxUZAz+MOPgBnsUnTDU3EuWo=
github.com/livekit/protocol v1.3.1-0.20221219041553-fc943512b0fb/go.mod h1:lTX4zmLbKoeDWHjBJEzo5wYNcFb8MaJFlc5gUnFbHTc=
github.com/livekit/rtcscore-go v0.0.0-20220815072451-20ee10ae1995 h1:vOaY2qvfLihDyeZtnGGN1Law9wRrw8BMGCr1TygTvMw=
github.com/livekit/rtcscore-go v0.0.0-20220815072451-20ee10ae1995/go.mod h1:116ych8UaEs9vfIE8n6iZCZ30iagUFTls0vRmC+Ix5U=
github.com/mackerelio/go-osstat v0.2.3 h1:jAMXD5erlDE39kdX2CU7YwCGRcxIO33u/p8+Fhe5dJw=
@@ -301,7 +299,6 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
github.com/pion/datachannel v1.5.2/go.mod h1:FTGQWaHrdCwIJ1rw6xBIfZVkslikjShim5yr05XFuCQ=
github.com/pion/datachannel v1.5.5 h1:10ef4kwdjije+M9d7Xm9im2Y3O6A6ccQb0zcqZcJew8=
github.com/pion/datachannel v1.5.5/go.mod h1:iMz+lECmfdCMqFRhXhcA/219B0SQlbpoR2V118yimL0=
github.com/pion/dtls/v2 v2.1.5 h1:jlh2vtIyUBShchoTDqpCCqiYCyRFJ/lvf/gQ8TALs+c=
@@ -322,8 +319,6 @@ github.com/pion/rtcp v1.2.10 h1:nkr3uj+8Sp97zyItdN60tE/S6vk4al5CPRR6Gejsdjc=
github.com/pion/rtcp v1.2.10/go.mod h1:ztfEwXZNLGyF1oQDttz/ZKIBaeeg/oWbRYqzBM9TL1I=
github.com/pion/rtp v1.7.13 h1:qcHwlmtiI50t1XivvoawdCGTP4Uiypzfrsap+bijcoA=
github.com/pion/rtp v1.7.13/go.mod h1:bDb5n+BFZxXx0Ea7E5qe+klMuqiBrP+w8XSjiWtCUko=
github.com/pion/sctp v1.8.0/go.mod h1:xFe9cLMZ5Vj6eOzpyiKjT9SwGM4KpK/8Jbw5//jc+0s=
github.com/pion/sctp v1.8.3/go.mod h1:OHbDjdk7kg+L+7TJim9q/qGVefdEJohuA2SZyihccgI=
github.com/pion/sctp v1.8.5 h1:JCc25nghnXWOlSn3OVtEnA9PjQ2JsxQbG+CXZ1UkJKQ=
github.com/pion/sctp v1.8.5/go.mod h1:SUFFfDpViyKejTAdwD1d/HQsCu+V/40cCs2nZIvC3s0=
github.com/pion/sdp/v3 v3.0.6 h1:WuDLhtuFUUVpTfus9ILC4HRyHsW6TdugjEX/QY9OiUw=
@@ -333,7 +328,6 @@ github.com/pion/srtp/v2 v2.0.10/go.mod h1:XEeSWaK9PfuMs7zxXyiN252AHPbH12NX5q/CFD
github.com/pion/stun v0.3.5 h1:uLUCBCkQby4S1cf6CGuR9QrVOKcvUwFeemaC865QHDg=
github.com/pion/stun v0.3.5/go.mod h1:gDMim+47EeEtfWogA37n6qXZS88L5V6LqFcf+DZA2UA=
github.com/pion/transport v0.12.2/go.mod h1:N3+vZQD9HlDP5GWkZ85LohxNsDcNgofQmyL6ojX5d8Q=
github.com/pion/transport v0.12.3/go.mod h1:OViWW9SP2peE/HbwBvARicmAVnesphkNkCVZIWJ6q9A=
github.com/pion/transport v0.13.0/go.mod h1:yxm9uXpK9bpBBWkITk13cLo1y5/ur5VQpG22ny6EP7g=
github.com/pion/transport v0.13.1/go.mod h1:EBxbqzyv+ZrmDb82XswEE0BjfQFtuw1Nu6sjnjWCsGg=
github.com/pion/transport v0.14.1 h1:XSM6olwW+o8J4SCmOBb/BpwZypkHeyM0PGFCxNQBr40=
@@ -343,7 +337,6 @@ github.com/pion/turn/v2 v2.0.9 h1:jcDPw0Vfd5I4iTc7s0Upfc2aMnyu2lgJ9vV0SUrNC1o=
github.com/pion/turn/v2 v2.0.9/go.mod h1:DQlwUwx7hL8Xya6TTAabbd9DdKXTNR96Xf5g5Qqso/M=
github.com/pion/udp v0.1.1 h1:8UAPvyqmsxK8oOjloDk4wUt63TzFe9WEJkg5lChlj7o=
github.com/pion/udp v0.1.1/go.mod h1:6AFo+CMdKQm7UiA0eUPA8/eVCTx8jBIITLZHc9DWX5M=
github.com/pion/webrtc/v3 v3.1.49/go.mod h1:kHf/o47QW4No1rgpsFux/h7lUhtUnwFnSFDZOXeLapw=
github.com/pion/webrtc/v3 v3.1.50 h1:wLMo1+re4WMZ9Kun9qcGcY+XoHkE3i0CXrrc0sjhVCk=
github.com/pion/webrtc/v3 v3.1.50/go.mod h1:y9n09weIXB+sjb9mi0GBBewNxo4TKUQm5qdtT5v3/X4=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
@@ -436,12 +429,10 @@ go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqe
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
@@ -674,7 +665,6 @@ golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgw
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
@@ -810,7 +800,6 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
+5 -5
View File
@@ -154,7 +154,7 @@ type ParticipantImpl struct {
onClose func(types.LocalParticipant, map[livekit.TrackID]livekit.ParticipantID)
onClaimsChanged func(participant types.LocalParticipant)
onICEConfigChanged func(participant types.LocalParticipant, iceConfig types.IceConfig)
onICEConfigChanged func(participant types.LocalParticipant, iceConfig *livekit.ICEConfig)
cachedDownTracks map[livekit.TrackID]*downTrackState
@@ -759,7 +759,7 @@ func (p *ParticipantImpl) MigrateState() types.MigrateState {
}
// ICERestart restarts subscriber ICE connections
func (p *ParticipantImpl) ICERestart(iceConfig *types.IceConfig) {
func (p *ParticipantImpl) ICERestart(iceConfig *livekit.ICEConfig) {
p.clearDisconnectTimer()
p.clearMigrationTimer()
@@ -770,7 +770,7 @@ func (p *ParticipantImpl) ICERestart(iceConfig *types.IceConfig) {
p.TransportManager.ICERestart(iceConfig)
}
func (p *ParticipantImpl) OnICEConfigChanged(f func(participant types.LocalParticipant, iceConfig types.IceConfig)) {
func (p *ParticipantImpl) OnICEConfigChanged(f func(participant types.LocalParticipant, iceConfig *livekit.ICEConfig)) {
p.lock.Lock()
p.onICEConfigChanged = f
p.lock.Unlock()
@@ -1097,14 +1097,14 @@ func (p *ParticipantImpl) setupTransportManager() error {
return err
}
tm.OnICEConfigChanged(func(iceConfig types.IceConfig) {
tm.OnICEConfigChanged(func(iceConfig *livekit.ICEConfig) {
p.lock.Lock()
onICEConfigChanged := p.onICEConfigChanged
if p.params.ClientConf == nil {
p.params.ClientConf = &livekit.ClientConfiguration{}
}
if iceConfig.PreferSub == types.PreferTls {
if iceConfig.PreferenceSubscriber == livekit.ICECandidateType_ICT_TLS {
p.params.ClientConf.ForceRelay = livekit.ClientConfigSetting_ENABLED
} else {
// UNSET indicates that clients could override RTCConfiguration to forceRelay
+3 -3
View File
@@ -651,9 +651,9 @@ func (r *Room) SimulateScenario(participant types.LocalParticipant, simulateScen
case *livekit.SimulateScenario_SwitchCandidateProtocol:
r.Logger.Infow("simulating switch candidate protocol", "participant", participant.Identity())
participant.ICERestart(&types.IceConfig{
PreferSub: types.PreferCandidateType(scenario.SwitchCandidateProtocol),
PreferPub: types.PreferCandidateType(scenario.SwitchCandidateProtocol),
participant.ICERestart(&livekit.ICEConfig{
PreferenceSubscriber: livekit.ICECandidateType(scenario.SwitchCandidateProtocol),
PreferencePublisher: livekit.ICECandidateType(scenario.SwitchCandidateProtocol),
})
}
return nil
+27 -26
View File
@@ -10,6 +10,7 @@ import (
"github.com/pion/webrtc/v3"
"github.com/pkg/errors"
"go.uber.org/atomic"
"google.golang.org/protobuf/proto"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/livekit-server/pkg/rtc/types"
@@ -61,7 +62,7 @@ type TransportManager struct {
pendingDataChannelsPublisher []*livekit.DataChannelInfo
lastPublisherAnswer atomic.Value
lastPublisherOffer atomic.Value
iceConfig types.IceConfig
iceConfig *livekit.ICEConfig
mediaLossProxy *MediaLossProxy
udpLossUnstableCount uint32
@@ -72,7 +73,7 @@ type TransportManager struct {
onPrimaryTransportInitialConnected func()
onAnyTransportFailed func()
onICEConfigChanged func(iceConfig types.IceConfig)
onICEConfigChanged func(iceConfig *livekit.ICEConfig)
}
func NewTransportManager(params TransportManagerParams) (*TransportManager, error) {
@@ -433,27 +434,27 @@ func (t *TransportManager) NegotiateSubscriber(force bool) {
t.subscriber.Negotiate(force)
}
func (t *TransportManager) ICERestart(iceConfig *types.IceConfig) {
func (t *TransportManager) ICERestart(iceConfig *livekit.ICEConfig) {
if iceConfig != nil {
t.SetICEConfig(*iceConfig)
t.SetICEConfig(iceConfig)
}
t.subscriber.ICERestart()
}
func (t *TransportManager) OnICEConfigChanged(f func(iceConfig types.IceConfig)) {
func (t *TransportManager) OnICEConfigChanged(f func(iceConfig *livekit.ICEConfig)) {
t.lock.Lock()
t.onICEConfigChanged = f
t.lock.Unlock()
}
func (t *TransportManager) SetICEConfig(iceConfig types.IceConfig) {
func (t *TransportManager) SetICEConfig(iceConfig *livekit.ICEConfig) {
t.configureICE(iceConfig, true)
}
func (t *TransportManager) configureICE(iceConfig types.IceConfig, reset bool) {
func (t *TransportManager) configureICE(iceConfig *livekit.ICEConfig, reset bool) {
t.lock.Lock()
if t.iceConfig == iceConfig {
if proto.Equal(t.iceConfig, iceConfig) {
t.lock.Unlock()
return
}
@@ -465,12 +466,12 @@ func (t *TransportManager) configureICE(iceConfig types.IceConfig, reset bool) {
t.isTransportReconfigured = !reset
t.lock.Unlock()
if iceConfig.PreferSub != types.PreferNone {
if iceConfig.PreferenceSubscriber != livekit.ICECandidateType_ICT_NONE {
t.mediaLossProxy.OnMediaLossUpdate(nil)
}
t.publisher.SetPreferTCP(iceConfig.PreferPub == types.PreferTcp)
t.subscriber.SetPreferTCP(iceConfig.PreferSub == types.PreferTcp)
t.publisher.SetPreferTCP(iceConfig.PreferencePublisher == livekit.ICECandidateType_ICT_TCP)
t.subscriber.SetPreferTCP(iceConfig.PreferenceSubscriber == livekit.ICECandidateType_ICT_TCP)
if onICEConfigChanged != nil {
onICEConfigChanged(iceConfig)
@@ -506,22 +507,22 @@ func (t *TransportManager) handleConnectionFailed(isShortLived bool) {
}
//
// Checking only `PreferSub` field although any connection failure (PUBLISHER OR SUBSCRIBER) will
// Checking only `PreferenceSubcriber` field although any connection failure (PUBLISHER OR SUBSCRIBER) will
// flow through here.
//
// As both transports are switched to the same type on any failure, checking just subscriber should be fine.
//
getNext := func(ic types.IceConfig) types.PreferCandidateType {
if ic.PreferSub == types.PreferNone && t.params.ClientInfo.SupportsICETCP() {
return types.PreferTcp
} else if ic.PreferSub != types.PreferTls && t.params.TURNSEnabled {
return types.PreferTls
getNext := func(ic *livekit.ICEConfig) livekit.ICECandidateType {
if ic.PreferenceSubscriber == livekit.ICECandidateType_ICT_NONE && t.params.ClientInfo.SupportsICETCP() {
return livekit.ICECandidateType_ICT_TCP
} else if ic.PreferenceSubscriber != livekit.ICECandidateType_ICT_TLS && t.params.TURNSEnabled {
return livekit.ICECandidateType_ICT_TLS
} else {
return types.PreferNone
return livekit.ICECandidateType_ICT_NONE
}
}
var preferNext types.PreferCandidateType
var preferNext livekit.ICECandidateType
if isShortLived {
preferNext = getNext(t.iceConfig)
} else {
@@ -534,7 +535,7 @@ func (t *TransportManager) handleConnectionFailed(isShortLived bool) {
preferNext = getNext(t.iceConfig)
}
if preferNext == t.iceConfig.PreferSub {
if preferNext == t.iceConfig.PreferenceSubscriber {
t.lock.Unlock()
return
}
@@ -543,21 +544,21 @@ func (t *TransportManager) handleConnectionFailed(isShortLived bool) {
t.lock.Unlock()
switch preferNext {
case types.PreferTcp:
case livekit.ICECandidateType_ICT_TCP:
t.params.Logger.Infow("prefer TCP transport on both peer connections")
case types.PreferTls:
case livekit.ICECandidateType_ICT_TLS:
t.params.Logger.Infow("prefer TLS transport both peer connections")
case types.PreferNone:
case livekit.ICECandidateType_ICT_NONE:
t.params.Logger.Infow("allowing all transports on both peer connections")
}
// irrespective of which one fails, force prefer candidate on both as the other one might
// fail at a different time and cause another disruption
t.configureICE(types.IceConfig{
PreferPub: preferNext,
PreferSub: preferNext,
t.configureICE(&livekit.ICEConfig{
PreferenceSubscriber: preferNext,
PreferencePublisher: preferNext,
}, false)
}
+3 -16
View File
@@ -207,19 +207,6 @@ type Participant interface {
DebugInfo() map[string]interface{}
}
type PreferCandidateType int
const (
PreferNone PreferCandidateType = iota
PreferTcp
PreferTls
)
type IceConfig struct {
PreferSub PreferCandidateType
PreferPub PreferCandidateType
}
// -------------------------------------------------------
type ICEConnectionType string
@@ -269,7 +256,7 @@ type LocalParticipant interface {
HandleAnswer(sdp webrtc.SessionDescription)
Negotiate(force bool)
ICERestart(iceConfig *IceConfig)
ICERestart(iceConfig *livekit.ICEConfig)
AddTrackToSubscriber(trackLocal webrtc.TrackLocal, params AddTrackParams) (*webrtc.RTPSender, *webrtc.RTPTransceiver, error)
AddTransceiverFromTrackToSubscriber(trackLocal webrtc.TrackLocal, params AddTrackParams) (*webrtc.RTPSender, *webrtc.RTPTransceiver, error)
RemoveTrackFromSubscriber(sender *webrtc.RTPSender) error
@@ -335,8 +322,8 @@ type LocalParticipant interface {
ProcessSubscriptionRequestsQueue(trackID livekit.TrackID)
ClearInProgressAndProcessSubscriptionRequestsQueue(trackID livekit.TrackID)
SetICEConfig(iceConfig IceConfig)
OnICEConfigChanged(callback func(participant LocalParticipant, iceConfig IceConfig))
SetICEConfig(iceConfig *livekit.ICEConfig)
OnICEConfigChanged(callback func(participant LocalParticipant, iceConfig *livekit.ICEConfig))
UpdateSubscribedQuality(nodeID livekit.NodeID, trackID livekit.TrackID, maxQualities []SubscribedCodecQuality) error
UpdateMediaLoss(nodeID livekit.NodeID, trackID livekit.TrackID, fractionalLoss uint32) error
@@ -340,10 +340,10 @@ type FakeLocalParticipant struct {
hiddenReturnsOnCall map[int]struct {
result1 bool
}
ICERestartStub func(*types.IceConfig)
ICERestartStub func(*livekit.ICEConfig)
iCERestartMutex sync.RWMutex
iCERestartArgsForCall []struct {
arg1 *types.IceConfig
arg1 *livekit.ICEConfig
}
IDStub func() livekit.ParticipantID
iDMutex sync.RWMutex
@@ -448,10 +448,10 @@ type FakeLocalParticipant struct {
onDataPacketArgsForCall []struct {
arg1 func(types.LocalParticipant, *livekit.DataPacket)
}
OnICEConfigChangedStub func(func(participant types.LocalParticipant, iceConfig types.IceConfig))
OnICEConfigChangedStub func(func(participant types.LocalParticipant, iceConfig *livekit.ICEConfig))
onICEConfigChangedMutex sync.RWMutex
onICEConfigChangedArgsForCall []struct {
arg1 func(participant types.LocalParticipant, iceConfig types.IceConfig)
arg1 func(participant types.LocalParticipant, iceConfig *livekit.ICEConfig)
}
OnParticipantUpdateStub func(func(types.LocalParticipant))
onParticipantUpdateMutex sync.RWMutex
@@ -607,10 +607,10 @@ type FakeLocalParticipant struct {
sendSpeakerUpdateReturnsOnCall map[int]struct {
result1 error
}
SetICEConfigStub func(types.IceConfig)
SetICEConfigStub func(*livekit.ICEConfig)
setICEConfigMutex sync.RWMutex
setICEConfigArgsForCall []struct {
arg1 types.IceConfig
arg1 *livekit.ICEConfig
}
SetMetadataStub func(string)
setMetadataMutex sync.RWMutex
@@ -2464,10 +2464,10 @@ func (fake *FakeLocalParticipant) HiddenReturnsOnCall(i int, result1 bool) {
}{result1}
}
func (fake *FakeLocalParticipant) ICERestart(arg1 *types.IceConfig) {
func (fake *FakeLocalParticipant) ICERestart(arg1 *livekit.ICEConfig) {
fake.iCERestartMutex.Lock()
fake.iCERestartArgsForCall = append(fake.iCERestartArgsForCall, struct {
arg1 *types.IceConfig
arg1 *livekit.ICEConfig
}{arg1})
stub := fake.ICERestartStub
fake.recordInvocation("ICERestart", []interface{}{arg1})
@@ -2483,13 +2483,13 @@ func (fake *FakeLocalParticipant) ICERestartCallCount() int {
return len(fake.iCERestartArgsForCall)
}
func (fake *FakeLocalParticipant) ICERestartCalls(stub func(*types.IceConfig)) {
func (fake *FakeLocalParticipant) ICERestartCalls(stub func(*livekit.ICEConfig)) {
fake.iCERestartMutex.Lock()
defer fake.iCERestartMutex.Unlock()
fake.ICERestartStub = stub
}
func (fake *FakeLocalParticipant) ICERestartArgsForCall(i int) *types.IceConfig {
func (fake *FakeLocalParticipant) ICERestartArgsForCall(i int) *livekit.ICEConfig {
fake.iCERestartMutex.RLock()
defer fake.iCERestartMutex.RUnlock()
argsForCall := fake.iCERestartArgsForCall[i]
@@ -3065,10 +3065,10 @@ func (fake *FakeLocalParticipant) OnDataPacketArgsForCall(i int) func(types.Loca
return argsForCall.arg1
}
func (fake *FakeLocalParticipant) OnICEConfigChanged(arg1 func(participant types.LocalParticipant, iceConfig types.IceConfig)) {
func (fake *FakeLocalParticipant) OnICEConfigChanged(arg1 func(participant types.LocalParticipant, iceConfig *livekit.ICEConfig)) {
fake.onICEConfigChangedMutex.Lock()
fake.onICEConfigChangedArgsForCall = append(fake.onICEConfigChangedArgsForCall, struct {
arg1 func(participant types.LocalParticipant, iceConfig types.IceConfig)
arg1 func(participant types.LocalParticipant, iceConfig *livekit.ICEConfig)
}{arg1})
stub := fake.OnICEConfigChangedStub
fake.recordInvocation("OnICEConfigChanged", []interface{}{arg1})
@@ -3084,13 +3084,13 @@ func (fake *FakeLocalParticipant) OnICEConfigChangedCallCount() int {
return len(fake.onICEConfigChangedArgsForCall)
}
func (fake *FakeLocalParticipant) OnICEConfigChangedCalls(stub func(func(participant types.LocalParticipant, iceConfig types.IceConfig))) {
func (fake *FakeLocalParticipant) OnICEConfigChangedCalls(stub func(func(participant types.LocalParticipant, iceConfig *livekit.ICEConfig))) {
fake.onICEConfigChangedMutex.Lock()
defer fake.onICEConfigChangedMutex.Unlock()
fake.OnICEConfigChangedStub = stub
}
func (fake *FakeLocalParticipant) OnICEConfigChangedArgsForCall(i int) func(participant types.LocalParticipant, iceConfig types.IceConfig) {
func (fake *FakeLocalParticipant) OnICEConfigChangedArgsForCall(i int) func(participant types.LocalParticipant, iceConfig *livekit.ICEConfig) {
fake.onICEConfigChangedMutex.RLock()
defer fake.onICEConfigChangedMutex.RUnlock()
argsForCall := fake.onICEConfigChangedArgsForCall[i]
@@ -3979,10 +3979,10 @@ func (fake *FakeLocalParticipant) SendSpeakerUpdateReturnsOnCall(i int, result1
}{result1}
}
func (fake *FakeLocalParticipant) SetICEConfig(arg1 types.IceConfig) {
func (fake *FakeLocalParticipant) SetICEConfig(arg1 *livekit.ICEConfig) {
fake.setICEConfigMutex.Lock()
fake.setICEConfigArgsForCall = append(fake.setICEConfigArgsForCall, struct {
arg1 types.IceConfig
arg1 *livekit.ICEConfig
}{arg1})
stub := fake.SetICEConfigStub
fake.recordInvocation("SetICEConfig", []interface{}{arg1})
@@ -3998,13 +3998,13 @@ func (fake *FakeLocalParticipant) SetICEConfigCallCount() int {
return len(fake.setICEConfigArgsForCall)
}
func (fake *FakeLocalParticipant) SetICEConfigCalls(stub func(types.IceConfig)) {
func (fake *FakeLocalParticipant) SetICEConfigCalls(stub func(*livekit.ICEConfig)) {
fake.setICEConfigMutex.Lock()
defer fake.setICEConfigMutex.Unlock()
fake.SetICEConfigStub = stub
}
func (fake *FakeLocalParticipant) SetICEConfigArgsForCall(i int) types.IceConfig {
func (fake *FakeLocalParticipant) SetICEConfigArgsForCall(i int) *livekit.ICEConfig {
fake.setICEConfigMutex.RLock()
defer fake.setICEConfigMutex.RUnlock()
argsForCall := fake.setICEConfigArgsForCall[i]
+5 -5
View File
@@ -31,7 +31,7 @@ const (
)
type iceConfigCacheEntry struct {
iceConfig types.IceConfig
iceConfig *livekit.ICEConfig
modifiedAt time.Time
}
@@ -323,7 +323,7 @@ func (r *RoomManager) StartSession(
opts := rtc.ParticipantOptions{
AutoSubscribe: pi.AutoSubscribe,
}
if err = room.Join(participant, &opts, r.iceServersForRoom(protoRoom, iceConfig.PreferSub == types.PreferTls)); err != nil {
if err = room.Join(participant, &opts, r.iceServersForRoom(protoRoom, iceConfig.PreferenceSubscriber == livekit.ICECandidateType_ICT_TLS)); err != nil {
pLogger.Errorw("could not join room", err)
_ = participant.Close(true, types.ParticipantCloseReasonJoinFailed)
return err
@@ -364,7 +364,7 @@ func (r *RoomManager) StartSession(
logger.Errorw("could not refresh token", err)
}
})
participant.OnICEConfigChanged(func(participant types.LocalParticipant, iceConfig types.IceConfig) {
participant.OnICEConfigChanged(func(participant types.LocalParticipant, iceConfig *livekit.ICEConfig) {
r.lock.Lock()
r.iceConfigCache[participant.Identity()] = &iceConfigCacheEntry{
iceConfig: iceConfig,
@@ -687,13 +687,13 @@ func (r *RoomManager) refreshToken(participant types.LocalParticipant) error {
return nil
}
func (r *RoomManager) setIceConfig(participant types.LocalParticipant) types.IceConfig {
func (r *RoomManager) setIceConfig(participant types.LocalParticipant) *livekit.ICEConfig {
r.lock.Lock()
iceConfigCacheEntry, ok := r.iceConfigCache[participant.Identity()]
if !ok || time.Since(iceConfigCacheEntry.modifiedAt) > iceConfigTTL {
delete(r.iceConfigCache, participant.Identity())
r.lock.Unlock()
return types.IceConfig{}
return &livekit.ICEConfig{}
}
r.lock.Unlock()