@@ -129,9 +129,8 @@ type Conn struct {
129
129
localSessionDescriptionChannel chan webrtc.SessionDescription
130
130
remoteSessionDescriptionChannel chan webrtc.SessionDescription
131
131
132
- pendingRemoteCandidates []webrtc.ICECandidateInit
133
- pendingCandidatesMutex sync.Mutex
134
- pendingCandidatesFlushed bool
132
+ pendingRemoteCandidates []webrtc.ICECandidateInit
133
+ pendingCandidatesMutex sync.Mutex
135
134
136
135
pingChannelID uint16
137
136
pingEchoChannelID uint16
@@ -352,7 +351,6 @@ func (c *Conn) negotiate() {
352
351
c .opts .Logger .Debug (context .Background (), "flushed buffered remote candidates" ,
353
352
slog .F ("count" , len (c .pendingRemoteCandidates )),
354
353
)
355
- c .pendingCandidatesFlushed = true
356
354
c .pendingRemoteCandidates = make ([]webrtc.ICECandidateInit , 0 )
357
355
c .pendingCandidatesMutex .Unlock ()
358
356
@@ -395,7 +393,7 @@ func (c *Conn) AddRemoteCandidate(i webrtc.ICECandidateInit) error {
395
393
slog .F ("hash" , c .hashCandidate (i )),
396
394
slog .F ("length" , len (i .Candidate )),
397
395
}
398
- if ! c . pendingCandidatesFlushed {
396
+ if c . rtc . RemoteDescription () == nil {
399
397
c .opts .Logger .Debug (context .Background (), "bufferring remote candidate" , fields ... )
400
398
c .pendingRemoteCandidates = append (c .pendingRemoteCandidates , i )
401
399
return nil
0 commit comments