github.com/pion/webrtc/v4@v4.0.1/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  	// ICEGathererStateUnknown is the enum's zero-value
    15  	ICEGathererStateUnknown ICEGathererState = iota
    16  
    17  	// ICEGathererStateNew indicates object has been created but
    18  	// gather() has not been called.
    19  	ICEGathererStateNew
    20  
    21  	// ICEGathererStateGathering indicates gather() has been called,
    22  	// and the ICEGatherer is in the process of gathering candidates.
    23  	ICEGathererStateGathering
    24  
    25  	// ICEGathererStateComplete indicates the ICEGatherer has completed gathering.
    26  	ICEGathererStateComplete
    27  
    28  	// ICEGathererStateClosed indicates the closed state can only be entered
    29  	// when the ICEGatherer has been closed intentionally by calling close().
    30  	ICEGathererStateClosed
    31  )
    32  
    33  func (s ICEGathererState) String() string {
    34  	switch s {
    35  	case ICEGathererStateNew:
    36  		return "new"
    37  	case ICEGathererStateGathering:
    38  		return "gathering"
    39  	case ICEGathererStateComplete:
    40  		return "complete"
    41  	case ICEGathererStateClosed:
    42  		return "closed"
    43  	default:
    44  		return ErrUnknownType.Error()
    45  	}
    46  }
    47  
    48  func atomicStoreICEGathererState(state *ICEGathererState, newState ICEGathererState) {
    49  	atomic.StoreUint32((*uint32)(state), uint32(newState))
    50  }
    51  
    52  func atomicLoadICEGathererState(state *ICEGathererState) ICEGathererState {
    53  	return ICEGathererState(atomic.LoadUint32((*uint32)(state)))
    54  }