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