refine negotiation process (#807)

* refine negotiation process

* not restart during ice gathering

* fix test case
This commit is contained in:
cnderrauber
2022-07-04 17:11:09 +08:00
committed by GitHub
parent e30046f537
commit f17ed9b925
5 changed files with 213 additions and 13 deletions
+15
View File
@@ -225,6 +225,8 @@ func NewParticipant(params ParticipantParams) (*ParticipantImpl, error) {
return nil, err
}
p.subscriber.OnNegotiationFailed(p.handleNegotiationFailed)
p.publisher.pc.OnICECandidate(func(c *webrtc.ICECandidate) {
if c == nil || p.State() == livekit.ParticipantInfo_DISCONNECTED {
return
@@ -2055,3 +2057,16 @@ func (p *ParticipantImpl) GetCachedDownTrack(trackID livekit.TrackID) (*webrtc.R
return nil, sfu.ForwarderState{}
}
func (p *ParticipantImpl) handleNegotiationFailed() {
p.params.Logger.Infow("negotiation failed, notify client do full reconnect")
_ = p.writeMessage(&livekit.SignalResponse{
Message: &livekit.SignalResponse_Leave{
Leave: &livekit.LeaveRequest{
CanReconnect: true,
Reason: types.ParticipantCloseReasonNegotiateFailed.ToDisconnectReason(),
},
},
})
p.closeSignalConnection()
}