ice.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
  2. // SPDX-License-Identifier: MIT
  3. package ice
  4. // ConnectionState is an enum showing the state of a ICE Connection
  5. type ConnectionState int
  6. // List of supported States
  7. const (
  8. // ConnectionStateUnknown represents an unknown state
  9. ConnectionStateUnknown ConnectionState = iota
  10. // ConnectionStateNew ICE agent is gathering addresses
  11. ConnectionStateNew
  12. // ConnectionStateChecking ICE agent has been given local and remote candidates, and is attempting to find a match
  13. ConnectionStateChecking
  14. // ConnectionStateConnected ICE agent has a pairing, but is still checking other pairs
  15. ConnectionStateConnected
  16. // ConnectionStateCompleted ICE agent has finished
  17. ConnectionStateCompleted
  18. // ConnectionStateFailed ICE agent never could successfully connect
  19. ConnectionStateFailed
  20. // ConnectionStateDisconnected ICE agent connected successfully, but has entered a failed state
  21. ConnectionStateDisconnected
  22. // ConnectionStateClosed ICE agent has finished and is no longer handling requests
  23. ConnectionStateClosed
  24. )
  25. func (c ConnectionState) String() string {
  26. switch c {
  27. case ConnectionStateNew:
  28. return "New"
  29. case ConnectionStateChecking:
  30. return "Checking"
  31. case ConnectionStateConnected:
  32. return "Connected"
  33. case ConnectionStateCompleted:
  34. return "Completed"
  35. case ConnectionStateFailed:
  36. return "Failed"
  37. case ConnectionStateDisconnected:
  38. return "Disconnected"
  39. case ConnectionStateClosed:
  40. return "Closed"
  41. default:
  42. return "Invalid"
  43. }
  44. }
  45. // GatheringState describes the state of the candidate gathering process
  46. type GatheringState int
  47. const (
  48. // GatheringStateUnknown represents an unknown state
  49. GatheringStateUnknown GatheringState = iota
  50. // GatheringStateNew indicates candidate gathering is not yet started
  51. GatheringStateNew
  52. // GatheringStateGathering indicates candidate gathering is ongoing
  53. GatheringStateGathering
  54. // GatheringStateComplete indicates candidate gathering has been completed
  55. GatheringStateComplete
  56. )
  57. func (t GatheringState) String() string {
  58. switch t {
  59. case GatheringStateNew:
  60. return "new"
  61. case GatheringStateGathering:
  62. return "gathering"
  63. case GatheringStateComplete:
  64. return "complete"
  65. default:
  66. return ErrUnknownType.Error()
  67. }
  68. }