fixed potentially skipping offer in PCTransport

this could explain the "missing" track problem when the server fails to send some tracks to some of the subscribers
This commit is contained in:
David Zhao
2021-06-09 16:06:10 -07:00
parent b10d903d3e
commit b3e6bd10cf
3 changed files with 60 additions and 17 deletions
+7 -2
View File
@@ -144,8 +144,10 @@ func (t *PCTransport) SetRemoteDescription(sd webrtc.SessionDescription) error {
state := t.negotiationState
t.negotiationState = negotiationStateNone
if state == negotiationRetry {
// need to Negotiate again
t.Negotiate()
// need to Negotiate again, do it immediately
if err := t.CreateAndSendOffer(nil); err != nil {
logger.Errorw("could not negotiate", err)
}
}
return nil
@@ -199,6 +201,9 @@ func (t *PCTransport) CreateAndSendOffer(options *webrtc.OfferOptions) error {
t.negotiationState = negotiationRetry
return nil
}
} else if t.negotiationState == negotiationRetry {
// already set to retry, we can safely skip this attempt
return nil
}
offer, err := t.pc.CreateOffer(options)