icegathererstate.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
  2. // SPDX-License-Identifier: MIT
  3. package webrtc
  4. import (
  5. "sync/atomic"
  6. )
  7. // ICEGathererState represents the current state of the ICE gatherer.
  8. type ICEGathererState uint32
  9. const (
  10. // ICEGathererStateNew indicates object has been created but
  11. // gather() has not been called.
  12. ICEGathererStateNew ICEGathererState = iota + 1
  13. // ICEGathererStateGathering indicates gather() has been called,
  14. // and the ICEGatherer is in the process of gathering candidates.
  15. ICEGathererStateGathering
  16. // ICEGathererStateComplete indicates the ICEGatherer has completed gathering.
  17. ICEGathererStateComplete
  18. // ICEGathererStateClosed indicates the closed state can only be entered
  19. // when the ICEGatherer has been closed intentionally by calling close().
  20. ICEGathererStateClosed
  21. )
  22. func (s ICEGathererState) String() string {
  23. switch s {
  24. case ICEGathererStateNew:
  25. return "new"
  26. case ICEGathererStateGathering:
  27. return "gathering"
  28. case ICEGathererStateComplete:
  29. return "complete"
  30. case ICEGathererStateClosed:
  31. return "closed"
  32. default:
  33. return unknownStr
  34. }
  35. }
  36. func atomicStoreICEGathererState(state *ICEGathererState, newState ICEGathererState) {
  37. atomic.StoreUint32((*uint32)(state), uint32(newState))
  38. }
  39. func atomicLoadICEGathererState(state *ICEGathererState) ICEGathererState {
  40. return ICEGathererState(atomic.LoadUint32((*uint32)(state)))
  41. }