File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -400,6 +400,14 @@ func (pc *PeerConnection) checkNegotiationNeeded() bool { //nolint:gocognit
400
400
return true
401
401
}
402
402
track := sender .Track ()
403
+ if track == nil {
404
+ // Situation when sender's track is nil could happen when
405
+ // a) replaceTrack(nil) is called
406
+ // b) removeTrack() is called, changing the transceiver's direction to inactive
407
+ // As t.Direction() in this branch is either sendrecv or sendonly, we believe (a) option is the case
408
+ // As calling replaceTrack does not require renegotiation, we skip check for this transceiver
409
+ continue
410
+ }
403
411
if ! okMsid || descMsid != track .StreamID ()+ " " + track .ID () {
404
412
return true
405
413
}
Original file line number Diff line number Diff line change @@ -1323,3 +1323,29 @@ func TestNegotiationNeededWithRecvonlyTrack(t *testing.T) {
1323
1323
1324
1324
closePairNow (t , pcOffer , pcAnswer )
1325
1325
}
1326
+
1327
+ func TestNegotiationNotNeededAfterReplaceTrackNil (t * testing.T ) {
1328
+ lim := test .TimeOut (time .Second * 30 )
1329
+ defer lim .Stop ()
1330
+
1331
+ report := test .CheckRoutines (t )
1332
+ defer report ()
1333
+
1334
+ pcOffer , err := NewPeerConnection (Configuration {})
1335
+ assert .NoError (t , err )
1336
+
1337
+ pcAnswer , err := NewPeerConnection (Configuration {})
1338
+ assert .NoError (t , err )
1339
+
1340
+ tr , err := pcOffer .AddTransceiverFromKind (RTPCodecTypeAudio )
1341
+ assert .NoError (t , err )
1342
+
1343
+ assert .NoError (t , signalPair (pcOffer , pcAnswer ))
1344
+
1345
+ assert .NoError (t , tr .Sender ().ReplaceTrack (nil ))
1346
+
1347
+ assert .False (t , pcOffer .checkNegotiationNeeded ())
1348
+
1349
+ assert .NoError (t , pcOffer .Close ())
1350
+ assert .NoError (t , pcAnswer .Close ())
1351
+ }
You can’t perform that action at this time.
0 commit comments