mirror of
https://github.com/livekit/livekit.git
synced 2026-10-15 09:00:14 +00:00
Move reset of local description sent on ICE restart internally (#909)
This commit is contained in:
@@ -410,7 +410,7 @@ func (p *ParticipantImpl) onPublisherAnswer(answer webrtc.SessionDescription) {
|
||||
prometheus.ServiceOperationCounter.WithLabelValues("answer", "error", "write_message").Add(1)
|
||||
return
|
||||
}
|
||||
p.TransportManager.SetPublisherLocalDescriptionSent(true)
|
||||
p.TransportManager.PublisherLocalDescriptionSent()
|
||||
|
||||
if p.isPublisher.Load() != p.CanPublish() {
|
||||
p.isPublisher.Store(p.CanPublish())
|
||||
@@ -1003,7 +1003,7 @@ func (p *ParticipantImpl) onSubscriberOffer(offer webrtc.SessionDescription) {
|
||||
} else {
|
||||
prometheus.ServiceOperationCounter.WithLabelValues("offer", "success", "").Add(1)
|
||||
}
|
||||
p.TransportManager.SetSubscriberLocalDescriptionSent(true)
|
||||
p.TransportManager.SubscriberLocalDescriptionSent()
|
||||
}
|
||||
|
||||
// when a new remoteTrack is created, creates a Track and adds it to room
|
||||
|
||||
+20
-16
@@ -464,19 +464,13 @@ func (t *PCTransport) maybeNotifyFullyEstablished() {
|
||||
}
|
||||
}
|
||||
|
||||
func (t *PCTransport) SetLocalDescriptionSent(sent bool) {
|
||||
func (t *PCTransport) LocalDescriptionSent() {
|
||||
var cachedLocalCandidates []*webrtc.ICECandidate
|
||||
t.lock.Lock()
|
||||
t.localDescriptionSent = sent
|
||||
if sent {
|
||||
cachedLocalCandidates = t.cachedLocalCandidates
|
||||
t.cachedLocalCandidates = nil
|
||||
} else {
|
||||
t.allowedLocalCandidates = nil
|
||||
t.allowedRemoteCandidates = nil
|
||||
t.filteredLocalCandidates = nil
|
||||
t.filteredRemoteCandidates = nil
|
||||
}
|
||||
t.localDescriptionSent = true
|
||||
|
||||
cachedLocalCandidates = t.cachedLocalCandidates
|
||||
t.cachedLocalCandidates = nil
|
||||
t.lock.Unlock()
|
||||
|
||||
if t.onICECandidate != nil {
|
||||
@@ -486,6 +480,15 @@ func (t *PCTransport) SetLocalDescriptionSent(sent bool) {
|
||||
}
|
||||
}
|
||||
|
||||
func (t *PCTransport) clearLocalDescriptionSentLocked() {
|
||||
t.localDescriptionSent = false
|
||||
|
||||
t.allowedLocalCandidates = nil
|
||||
t.allowedRemoteCandidates = nil
|
||||
t.filteredLocalCandidates = nil
|
||||
t.filteredRemoteCandidates = nil
|
||||
}
|
||||
|
||||
func (t *PCTransport) SetPreferTCP(preferTCP bool) {
|
||||
t.lock.Lock()
|
||||
t.preferTCP = preferTCP
|
||||
@@ -703,11 +706,7 @@ func (t *PCTransport) SetRemoteDescription(sd webrtc.SessionDescription) error {
|
||||
}
|
||||
|
||||
if offerRestartICE && t.pendingRestartIceOffer == nil {
|
||||
t.localDescriptionSent = false
|
||||
t.allowedLocalCandidates = nil
|
||||
t.allowedRemoteCandidates = nil
|
||||
t.filteredLocalCandidates = nil
|
||||
t.filteredRemoteCandidates = nil
|
||||
t.clearLocalDescriptionSentLocked()
|
||||
}
|
||||
|
||||
if offerRestartICE && t.pc.ICEGatheringState() == webrtc.ICEGatheringStateGathering {
|
||||
@@ -978,6 +977,11 @@ func (t *PCTransport) CreateAndSendAnswer(enableDTX bool) error {
|
||||
func (t *PCTransport) CreateAndSendOffer(options *webrtc.OfferOptions) error {
|
||||
t.lock.Lock()
|
||||
defer t.lock.Unlock()
|
||||
|
||||
if options != nil && options.ICERestart {
|
||||
t.clearLocalDescriptionSentLocked()
|
||||
}
|
||||
|
||||
return t.createAndSendOffer(options)
|
||||
}
|
||||
|
||||
|
||||
@@ -173,8 +173,8 @@ func (t *TransportManager) GetPublisherRTPReceiver(mid string) *webrtc.RTPReceiv
|
||||
return t.publisher.GetRTPReceiver(mid)
|
||||
}
|
||||
|
||||
func (t *TransportManager) SetPublisherLocalDescriptionSent(sent bool) {
|
||||
t.publisher.SetLocalDescriptionSent(sent)
|
||||
func (t *TransportManager) PublisherLocalDescriptionSent() {
|
||||
t.publisher.LocalDescriptionSent()
|
||||
}
|
||||
|
||||
func (t *TransportManager) WritePublisherRTCP(pkts []rtcp.Packet) error {
|
||||
@@ -201,8 +201,8 @@ func (t *TransportManager) OnSubscriberStreamStateChange(f func(update *sfu.Stre
|
||||
t.subscriber.OnStreamStateChange(f)
|
||||
}
|
||||
|
||||
func (t *TransportManager) SetSubscriberLocalDescriptionSent(sent bool) {
|
||||
t.subscriber.SetLocalDescriptionSent(sent)
|
||||
func (t *TransportManager) SubscriberLocalDescriptionSent() {
|
||||
t.subscriber.LocalDescriptionSent()
|
||||
}
|
||||
|
||||
func (t *TransportManager) HasSubscriberEverConnected() bool {
|
||||
@@ -375,7 +375,6 @@ func (t *TransportManager) ICERestart(iceConfig *types.IceConfig) error {
|
||||
t.SetICEConfig(*iceConfig)
|
||||
}
|
||||
|
||||
t.subscriber.SetLocalDescriptionSent(false)
|
||||
return t.subscriber.CreateAndSendOffer(&webrtc.OfferOptions{
|
||||
ICERestart: true,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user