From 878887b624ac789557593db9a226d70cd7a6016c Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Fri, 6 Jan 2023 21:39:45 +0530 Subject: [PATCH] Reset state if requested even if config is same (#1287) --- pkg/rtc/transportmanager.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/rtc/transportmanager.go b/pkg/rtc/transportmanager.go index 13125504..45e22bae 100644 --- a/pkg/rtc/transportmanager.go +++ b/pkg/rtc/transportmanager.go @@ -455,7 +455,14 @@ func (t *TransportManager) SetICEConfig(iceConfig *livekit.ICEConfig) { func (t *TransportManager) configureICE(iceConfig *livekit.ICEConfig, reset bool) { t.lock.Lock() - if proto.Equal(t.iceConfig, iceConfig) { + isEqual := proto.Equal(t.iceConfig, iceConfig) + if reset || !isEqual { + t.failureCount = 0 + t.isTransportReconfigured = !reset + t.udpLossUnstableCount = 0 + } + + if isEqual { t.lock.Unlock() return } @@ -463,8 +470,6 @@ func (t *TransportManager) configureICE(iceConfig *livekit.ICEConfig, reset bool t.params.Logger.Infow("setting ICE config", "iceConfig", iceConfig) onICEConfigChanged := t.onICEConfigChanged t.iceConfig = iceConfig - t.failureCount = 0 - t.isTransportReconfigured = !reset t.lock.Unlock() if iceConfig.PreferenceSubscriber != livekit.ICECandidateType_ICT_NONE { @@ -641,6 +646,7 @@ func (t *TransportManager) onMediaLossUpdate(loss uint8) { if t.udpRTT > 0 && t.tcpRTT < uint32(float32(t.udpRTT)*1.3) && t.tcpRTT < tcpGoodRTT { t.udpLossUnstableCount = 0 t.lock.Unlock() + t.params.Logger.Infow("udp connection unstable, switch to tcp") t.handleConnectionFailed(true) if t.onAnyTransportFailed != nil {