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)
|
prometheus.ServiceOperationCounter.WithLabelValues("answer", "error", "write_message").Add(1)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
p.TransportManager.SetPublisherLocalDescriptionSent(true)
|
p.TransportManager.PublisherLocalDescriptionSent()
|
||||||
|
|
||||||
if p.isPublisher.Load() != p.CanPublish() {
|
if p.isPublisher.Load() != p.CanPublish() {
|
||||||
p.isPublisher.Store(p.CanPublish())
|
p.isPublisher.Store(p.CanPublish())
|
||||||
@@ -1003,7 +1003,7 @@ func (p *ParticipantImpl) onSubscriberOffer(offer webrtc.SessionDescription) {
|
|||||||
} else {
|
} else {
|
||||||
prometheus.ServiceOperationCounter.WithLabelValues("offer", "success", "").Add(1)
|
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
|
// 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
|
var cachedLocalCandidates []*webrtc.ICECandidate
|
||||||
t.lock.Lock()
|
t.lock.Lock()
|
||||||
t.localDescriptionSent = sent
|
t.localDescriptionSent = true
|
||||||
if sent {
|
|
||||||
cachedLocalCandidates = t.cachedLocalCandidates
|
cachedLocalCandidates = t.cachedLocalCandidates
|
||||||
t.cachedLocalCandidates = nil
|
t.cachedLocalCandidates = nil
|
||||||
} else {
|
|
||||||
t.allowedLocalCandidates = nil
|
|
||||||
t.allowedRemoteCandidates = nil
|
|
||||||
t.filteredLocalCandidates = nil
|
|
||||||
t.filteredRemoteCandidates = nil
|
|
||||||
}
|
|
||||||
t.lock.Unlock()
|
t.lock.Unlock()
|
||||||
|
|
||||||
if t.onICECandidate != nil {
|
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) {
|
func (t *PCTransport) SetPreferTCP(preferTCP bool) {
|
||||||
t.lock.Lock()
|
t.lock.Lock()
|
||||||
t.preferTCP = preferTCP
|
t.preferTCP = preferTCP
|
||||||
@@ -703,11 +706,7 @@ func (t *PCTransport) SetRemoteDescription(sd webrtc.SessionDescription) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if offerRestartICE && t.pendingRestartIceOffer == nil {
|
if offerRestartICE && t.pendingRestartIceOffer == nil {
|
||||||
t.localDescriptionSent = false
|
t.clearLocalDescriptionSentLocked()
|
||||||
t.allowedLocalCandidates = nil
|
|
||||||
t.allowedRemoteCandidates = nil
|
|
||||||
t.filteredLocalCandidates = nil
|
|
||||||
t.filteredRemoteCandidates = nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if offerRestartICE && t.pc.ICEGatheringState() == webrtc.ICEGatheringStateGathering {
|
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 {
|
func (t *PCTransport) CreateAndSendOffer(options *webrtc.OfferOptions) error {
|
||||||
t.lock.Lock()
|
t.lock.Lock()
|
||||||
defer t.lock.Unlock()
|
defer t.lock.Unlock()
|
||||||
|
|
||||||
|
if options != nil && options.ICERestart {
|
||||||
|
t.clearLocalDescriptionSentLocked()
|
||||||
|
}
|
||||||
|
|
||||||
return t.createAndSendOffer(options)
|
return t.createAndSendOffer(options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -173,8 +173,8 @@ func (t *TransportManager) GetPublisherRTPReceiver(mid string) *webrtc.RTPReceiv
|
|||||||
return t.publisher.GetRTPReceiver(mid)
|
return t.publisher.GetRTPReceiver(mid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TransportManager) SetPublisherLocalDescriptionSent(sent bool) {
|
func (t *TransportManager) PublisherLocalDescriptionSent() {
|
||||||
t.publisher.SetLocalDescriptionSent(sent)
|
t.publisher.LocalDescriptionSent()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TransportManager) WritePublisherRTCP(pkts []rtcp.Packet) error {
|
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)
|
t.subscriber.OnStreamStateChange(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TransportManager) SetSubscriberLocalDescriptionSent(sent bool) {
|
func (t *TransportManager) SubscriberLocalDescriptionSent() {
|
||||||
t.subscriber.SetLocalDescriptionSent(sent)
|
t.subscriber.LocalDescriptionSent()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TransportManager) HasSubscriberEverConnected() bool {
|
func (t *TransportManager) HasSubscriberEverConnected() bool {
|
||||||
@@ -375,7 +375,6 @@ func (t *TransportManager) ICERestart(iceConfig *types.IceConfig) error {
|
|||||||
t.SetICEConfig(*iceConfig)
|
t.SetICEConfig(*iceConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.subscriber.SetLocalDescriptionSent(false)
|
|
||||||
return t.subscriber.CreateAndSendOffer(&webrtc.OfferOptions{
|
return t.subscriber.CreateAndSendOffer(&webrtc.OfferOptions{
|
||||||
ICERestart: true,
|
ICERestart: true,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user