Add GetRemoteCandidates()

This is analogue to GetLocalCandidates() and provides
the user with the ability to get a slice of previously added
remote candidates without keeping track of them in the
application code.
This commit is contained in:
Steffen Vogel
2023-07-04 11:28:15 +02:00
parent 53beccaed5
commit ef637050e2
+18
View File
@@ -838,6 +838,24 @@ func (a *Agent) addCandidate(ctx context.Context, c Candidate, candidateConn net
})
}
// GetRemoteCandidates returns the remote candidates
func (a *Agent) GetRemoteCandidates() ([]Candidate, error) {
var res []Candidate
err := a.run(a.context(), func(ctx context.Context, agent *Agent) {
var candidates []Candidate
for _, set := range agent.remoteCandidates {
candidates = append(candidates, set...)
}
res = candidates
})
if err != nil {
return nil, err
}
return res, nil
}
// GetLocalCandidates returns the local candidates
func (a *Agent) GetLocalCandidates() ([]Candidate, error) {
var res []Candidate