icecandidatepair.go 861 B

1234567891011121314151617181920212223242526272829303132
  1. // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
  2. // SPDX-License-Identifier: MIT
  3. package webrtc
  4. import "fmt"
  5. // ICECandidatePair represents an ICE Candidate pair
  6. type ICECandidatePair struct {
  7. statsID string
  8. Local *ICECandidate
  9. Remote *ICECandidate
  10. }
  11. func newICECandidatePairStatsID(localID, remoteID string) string {
  12. return fmt.Sprintf("%s-%s", localID, remoteID)
  13. }
  14. func (p *ICECandidatePair) String() string {
  15. return fmt.Sprintf("(local) %s <-> (remote) %s", p.Local, p.Remote)
  16. }
  17. // NewICECandidatePair returns an initialized *ICECandidatePair
  18. // for the given pair of ICECandidate instances
  19. func NewICECandidatePair(local, remote *ICECandidate) *ICECandidatePair {
  20. statsID := newICECandidatePairStatsID(local.statsID, remote.statsID)
  21. return &ICECandidatePair{
  22. statsID: statsID,
  23. Local: local,
  24. Remote: remote,
  25. }
  26. }