Accept nil Candidate in AddRemoteCandidate

Allow a user to pass a nil Candidate. We perform no actions off of this
currently. Until browsers implement end-of-candidates consistently it
isn't something we can do.

Relates to pion/webrtc#1212 and #271
This commit is contained in:
ZHENK
2020-12-08 20:50:37 -08:00
committed by Sean DuBois
parent 5e5f171a92
commit 7c897626c1
2 changed files with 13 additions and 1 deletions
+5 -1
View File
@@ -706,7 +706,11 @@ func (a *Agent) checkKeepalive() {
// AddRemoteCandidate adds a new remote candidate
func (a *Agent) AddRemoteCandidate(c Candidate) error {
// canot check for network yet because it might not be applied
if c == nil {
return nil
}
// cannot check for network yet because it might not be applied
// when mDNS hostame is used.
if c.TCPType() == TCPTypeActive {
// TCP Candidates with tcptype active will probe server passive ones, so
+8
View File
@@ -1686,3 +1686,11 @@ func TestLiteLifecycle(t *testing.T) {
<-bFailed
assert.NoError(t, bAgent.Close())
}
func TestNilCandidate(t *testing.T) {
a, err := NewAgent(&AgentConfig{})
assert.NoError(t, err)
assert.NoError(t, a.AddRemoteCandidate(nil))
assert.NoError(t, a.Close())
}