Split ICE candidate queue. (#2885)

Shared ICE candidate queue meant only one of PUBLISHER/SUBSCRIBER pc got
final candidate notification. Split the queue.
This commit is contained in:
Raja Subramanian
2024-07-20 10:25:06 +05:30
committed by GitHub
parent 73b3a91a5c
commit bd616d6074
4 changed files with 21 additions and 8 deletions
+1 -1
View File
@@ -191,7 +191,7 @@ type ParticipantImpl struct {
*UpTrackManager
*SubscriptionManager
icQueue atomic.Pointer[webrtc.ICECandidate]
icQueue [2]atomic.Pointer[webrtc.ICECandidate]
// keeps track of unpublished tracks in order to reuse trackID
unpublishedTracks []*livekit.TrackInfo
+8 -1
View File
@@ -20,6 +20,7 @@ import (
"time"
"github.com/pion/webrtc/v3"
"go.uber.org/atomic"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
@@ -265,7 +266,13 @@ func (p *ParticipantImpl) sendDisconnectUpdatesForReconnect() error {
}
func (p *ParticipantImpl) sendICECandidate(ic *webrtc.ICECandidate, target livekit.SignalTarget) error {
prevIC := p.icQueue.Swap(ic)
var icQueue *atomic.Pointer[webrtc.ICECandidate]
if target == livekit.SignalTarget_PUBLISHER {
icQueue = &p.icQueue[0]
} else {
icQueue = &p.icQueue[1]
}
prevIC := icQueue.Swap(ic)
if prevIC == nil {
return nil
}