icegatheringstate.go 1.5 KB

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