mark final ice candidate (#2871)

* add IsFinal flag to last ice candidate

* deps
This commit is contained in:
Paul Wells
2024-07-16 09:50:55 -07:00
committed by GitHub
parent 8605ada485
commit c905336fec
6 changed files with 23 additions and 16 deletions
+3 -1
View File
@@ -191,6 +191,8 @@ type ParticipantImpl struct {
*UpTrackManager
*SubscriptionManager
icQueue atomic.Pointer[webrtc.ICECandidate]
// keeps track of unpublished tracks in order to reuse trackID
unpublishedTracks []*livekit.TrackInfo
@@ -1610,7 +1612,7 @@ func (p *ParticipantImpl) onDataMessage(kind livekit.DataPacket_Kind, data []byt
}
func (p *ParticipantImpl) onICECandidate(c *webrtc.ICECandidate, target livekit.SignalTarget) error {
if c == nil || p.IsDisconnected() || p.IsClosed() {
if p.IsDisconnected() || p.IsClosed() {
return nil
}
+6 -3
View File
@@ -264,10 +264,13 @@ func (p *ParticipantImpl) sendDisconnectUpdatesForReconnect() error {
})
}
func (p *ParticipantImpl) sendICECandidate(c *webrtc.ICECandidate, target livekit.SignalTarget) error {
trickle := ToProtoTrickle(c.ToJSON())
trickle.Target = target
func (p *ParticipantImpl) sendICECandidate(ic *webrtc.ICECandidate, target livekit.SignalTarget) error {
prevIC := p.icQueue.Swap(ic)
if prevIC == nil {
return nil
}
trickle := ToProtoTrickle(prevIC.ToJSON(), target, ic == nil)
p.params.Logger.Debugw("sending ICE candidate", "transport", target, "trickle", logger.Proto(trickle))
return p.writeMessage(&livekit.SignalResponse{
+3 -1
View File
@@ -101,10 +101,12 @@ func FromProtoSessionDescription(sd *livekit.SessionDescription) webrtc.SessionD
}
}
func ToProtoTrickle(candidateInit webrtc.ICECandidateInit) *livekit.TrickleRequest {
func ToProtoTrickle(candidateInit webrtc.ICECandidateInit, target livekit.SignalTarget, final bool) *livekit.TrickleRequest {
data, _ := json.Marshal(candidateInit)
return &livekit.TrickleRequest{
CandidateInit: string(data),
Target: target,
Final: final,
}
}