icecandidatepair.go 759 B

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