candidate.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
  2. // SPDX-License-Identifier: MIT
  3. package ice
  4. import (
  5. "context"
  6. "net"
  7. "time"
  8. )
  9. const (
  10. receiveMTU = 8192
  11. defaultLocalPreference = 65535
  12. // ComponentRTP indicates that the candidate is used for RTP
  13. ComponentRTP uint16 = 1
  14. // ComponentRTCP indicates that the candidate is used for RTCP
  15. ComponentRTCP
  16. )
  17. // Candidate represents an ICE candidate
  18. type Candidate interface {
  19. // An arbitrary string used in the freezing algorithm to
  20. // group similar candidates. It is the same for two candidates that
  21. // have the same type, base IP address, protocol (UDP, TCP, etc.),
  22. // and STUN or TURN server.
  23. Foundation() string
  24. // ID is a unique identifier for just this candidate
  25. // Unlike the foundation this is different for each candidate
  26. ID() string
  27. // A component is a piece of a data stream.
  28. // An example is one for RTP, and one for RTCP
  29. Component() uint16
  30. SetComponent(uint16)
  31. // The last time this candidate received traffic
  32. LastReceived() time.Time
  33. // The last time this candidate sent traffic
  34. LastSent() time.Time
  35. NetworkType() NetworkType
  36. Address() string
  37. Port() int
  38. Priority() uint32
  39. // A transport address related to a
  40. // candidate, which is useful for diagnostics and other purposes
  41. RelatedAddress() *CandidateRelatedAddress
  42. String() string
  43. Type() CandidateType
  44. TCPType() TCPType
  45. Equal(other Candidate) bool
  46. Marshal() string
  47. addr() net.Addr
  48. agent() *Agent
  49. context() context.Context
  50. close() error
  51. copy() (Candidate, error)
  52. seen(outbound bool)
  53. start(a *Agent, conn net.PacketConn, initializedCh <-chan struct{})
  54. writeTo(raw []byte, dst Candidate) (int, error)
  55. }