MCPcopy Create free account
hub / github.com/pion/ice / AddRemoteCandidate

Method AddRemoteCandidate

agent.go:956–999  ·  view source on GitHub ↗

AddRemoteCandidate adds a new remote candidate.

(cand Candidate)

Source from the content-addressed store, hash-verified

954
955// AddRemoteCandidate adds a new remote candidate.
956func (a *Agent) AddRemoteCandidate(cand Candidate) error {
957 if cand == nil {
958 return nil
959 }
960
961 // TCP Candidates with TCP type active will probe server passive ones, so
962 // no need to do anything with them.
963 if cand.TCPType() == TCPTypeActive {
964 a.log.Infof("Ignoring remote candidate with tcpType active: %s", cand)
965
966 return nil
967 }
968
969 // If we have a mDNS Candidate lets fully resolve it before adding it locally
970 if cand.Type() == CandidateTypeHost && strings.HasSuffix(cand.Address(), ".local") {
971 if a.mDNSMode == MulticastDNSModeDisabled {
972 a.log.Warnf("Remote mDNS candidate added, but mDNS is disabled: (%s)", cand.Address())
973
974 return nil
975 }
976
977 hostCandidate, ok := cand.(*CandidateHost)
978 if !ok {
979 return ErrAddressParseFailed
980 }
981
982 go a.resolveAndAddMulticastCandidate(hostCandidate)
983
984 return nil
985 }
986
987 go func() {
988 if err := a.loop.Run(a.loop, func(_ context.Context) {
989 // nolint: contextcheck
990 a.addRemoteCandidate(cand)
991 }); err != nil {
992 a.log.Warnf("Failed to add remote candidate %s: %v", cand.Address(), err)
993
994 return
995 }
996 }()
997
998 return nil
999}
1000
1001func (a *Agent) resolveAndAddMulticastCandidate(cand *CandidateHost) {
1002 if a.mDNSConn == nil {

Calls 8

addRemoteCandidateMethod · 0.95
RunMethod · 0.80
TCPTypeMethod · 0.65
TypeMethod · 0.65
AddressMethod · 0.65
InfofMethod · 0.45
WarnfMethod · 0.45