icerole.go 1.2 KB

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