move createOffer to goroutine

This commit is contained in:
David Colburn
2021-06-17 22:33:26 -07:00
parent 6d6423c29d
commit 089d1d366d
2 changed files with 12 additions and 9 deletions
+9 -7
View File
@@ -93,14 +93,16 @@ func NewPCTransport(params TransportParams) (*PCTransport, error) {
}
t.pc.OnICEGatheringStateChange(func(state webrtc.ICEGathererState) {
if state == webrtc.ICEGathererStateComplete {
t.lock.Lock()
defer t.lock.Unlock()
if t.restartAfterGathering {
logger.Debugw("restarting ICE after ICE gathering")
if err := t.createAndSendOffer(&webrtc.OfferOptions{ICERestart: true}); err != nil {
logger.Warnw("could not restart ICE", err)
go func() {
t.lock.Lock()
defer t.lock.Unlock()
if t.restartAfterGathering {
logger.Debugw("restarting ICE after ICE gathering")
if err := t.createAndSendOffer(&webrtc.OfferOptions{ICERestart: true}); err != nil {
logger.Warnw("could not restart ICE", err)
}
}
}
}()
}
})
+3 -2
View File
@@ -5,10 +5,11 @@ import (
"testing"
"time"
"github.com/livekit/livekit-server/pkg/testutils"
livekit "github.com/livekit/livekit-server/proto"
"github.com/pion/webrtc/v3"
"github.com/stretchr/testify/require"
"github.com/livekit/livekit-server/pkg/testutils"
livekit "github.com/livekit/livekit-server/proto"
)
func TestMissingAnswerDuringICERestart(t *testing.T) {