Skip ICE restart on unestablished peer connection. (#2967)

* Do not ICE restart on an idle/not yet started peer connection.

* Skip ICE restart on unestablished peer connection.

For publish only participants, the subscriber peer connection is not
negotiated. So, ICE restart was hitting an error while trying to restart
the SUBSCRIBER peer connection.

* use ICE gathering state as peer connection state may not have changed if first offer/answer was missed
This commit is contained in:
Raja Subramanian authored and GitHub committed 2024-08-30 11:19:51 +05:30
1 parent 28417ef599
commit a4baa8b550
2 files changed
+9 -2

No files matched your search

+8 -1
View File
@@ -1790,8 +1790,15 @@ func (t *PCTransport) doICERestart() error {
return nil
}
// if restart is requested, but negotiation never started
iceGatheringState := t.pc.ICEGatheringState()
if iceGatheringState == webrtc.ICEGatheringStateNew {
t.params.Logger.Debugw("skipping ICE restart on not yet started peer connection")
return nil
}
// if restart is requested, and we are not ready, then continue afterwards
if t.pc.ICEGatheringState() == webrtc.ICEGatheringStateGathering {
if iceGatheringState == webrtc.ICEGatheringStateGathering {
t.params.Logger.Debugw("deferring ICE restart to after gathering")
t.restartAfterGathering = true
return nil
+1 -1
View File
@@ -315,7 +315,7 @@ func TestFirstAnswerMissedDuringICERestart(t *testing.T) {
handlerA.OnOfferCalls(func(sd webrtc.SessionDescription) error {
offerCount.Inc()
// the second offer is a ice restart offer, so we wait transportB complete the ice gathering
// the second offer is a ice restart offer, so we wait for transportB to complete ICE gathering
if transportB.pc.ICEGatheringState() == webrtc.ICEGatheringStateGathering {
require.Eventually(t, func() bool {
return transportB.pc.ICEGatheringState() == webrtc.ICEGatheringStateComplete