icegathererstate.go 1.3 KB

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