icegatheringstate.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
  2. // SPDX-License-Identifier: MIT
  3. package webrtc
  4. // ICEGatheringState describes the state of the candidate gathering process.
  5. type ICEGatheringState int
  6. const (
  7. // ICEGatheringStateNew indicates that any of the ICETransports are
  8. // in the "new" gathering state and none of the transports are in the
  9. // "gathering" state, or there are no transports.
  10. ICEGatheringStateNew ICEGatheringState = iota + 1
  11. // ICEGatheringStateGathering indicates that any of the ICETransports
  12. // are in the "gathering" state.
  13. ICEGatheringStateGathering
  14. // ICEGatheringStateComplete indicates that at least one ICETransport
  15. // exists, and all ICETransports are in the "completed" gathering state.
  16. ICEGatheringStateComplete
  17. )
  18. // This is done this way because of a linter.
  19. const (
  20. iceGatheringStateNewStr = "new"
  21. iceGatheringStateGatheringStr = "gathering"
  22. iceGatheringStateCompleteStr = "complete"
  23. )
  24. // NewICEGatheringState takes a string and converts it to ICEGatheringState
  25. func NewICEGatheringState(raw string) ICEGatheringState {
  26. switch raw {
  27. case iceGatheringStateNewStr:
  28. return ICEGatheringStateNew
  29. case iceGatheringStateGatheringStr:
  30. return ICEGatheringStateGathering
  31. case iceGatheringStateCompleteStr:
  32. return ICEGatheringStateComplete
  33. default:
  34. return ICEGatheringState(Unknown)
  35. }
  36. }
  37. func (t ICEGatheringState) String() string {
  38. switch t {
  39. case ICEGatheringStateNew:
  40. return iceGatheringStateNewStr
  41. case ICEGatheringStateGathering:
  42. return iceGatheringStateGatheringStr
  43. case ICEGatheringStateComplete:
  44. return iceGatheringStateCompleteStr
  45. default:
  46. return ErrUnknownType.Error()
  47. }
  48. }