icerole.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package webrtc
  2. // ICERole describes the role ice.Agent is playing in selecting the
  3. // preferred the candidate pair.
  4. type ICERole int
  5. const (
  6. // ICERoleControlling indicates that the ICE agent that is responsible
  7. // for selecting the final choice of candidate pairs and signaling them
  8. // through STUN and an updated offer, if needed. In any session, one agent
  9. // is always controlling. The other is the controlled agent.
  10. ICERoleControlling ICERole = iota + 1
  11. // ICERoleControlled indicates that an ICE agent that waits for the
  12. // controlling agent to select the final choice of candidate pairs.
  13. ICERoleControlled
  14. )
  15. // This is done this way because of a linter.
  16. const (
  17. iceRoleControllingStr = "controlling"
  18. iceRoleControlledStr = "controlled"
  19. )
  20. func newICERole(raw string) ICERole {
  21. switch raw {
  22. case iceRoleControllingStr:
  23. return ICERoleControlling
  24. case iceRoleControlledStr:
  25. return ICERoleControlled
  26. default:
  27. return ICERole(Unknown)
  28. }
  29. }
  30. func (t ICERole) String() string {
  31. switch t {
  32. case ICERoleControlling:
  33. return iceRoleControllingStr
  34. case ICERoleControlled:
  35. return iceRoleControlledStr
  36. default:
  37. return ErrUnknownType.Error()
  38. }
  39. }