candidate.go 1.6 KB

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