summaryrefslogtreecommitdiff
path: root/vendor/github.com/pion/webrtc/v3/icegathererstate.go
blob: 80dc77a2de8a5757e27d204d038850ec469ab294 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package webrtc

import (
	"sync/atomic"
)

// ICEGathererState represents the current state of the ICE gatherer.
type ICEGathererState uint32

const (
	// ICEGathererStateNew indicates object has been created but
	// gather() has not been called.
	ICEGathererStateNew ICEGathererState = iota + 1

	// ICEGathererStateGathering indicates gather() has been called,
	// and the ICEGatherer is in the process of gathering candidates.
	ICEGathererStateGathering

	// ICEGathererStateComplete indicates the ICEGatherer has completed gathering.
	ICEGathererStateComplete

	// ICEGathererStateClosed indicates the closed state can only be entered
	// when the ICEGatherer has been closed intentionally by calling close().
	ICEGathererStateClosed
)

func (s ICEGathererState) String() string {
	switch s {
	case ICEGathererStateNew:
		return "new"
	case ICEGathererStateGathering:
		return "gathering"
	case ICEGathererStateComplete:
		return "complete"
	case ICEGathererStateClosed:
		return "closed"
	default:
		return unknownStr
	}
}

func atomicStoreICEGathererState(state *ICEGathererState, newState ICEGathererState) {
	atomic.StoreUint32((*uint32)(state), uint32(newState))
}

func atomicLoadICEGathererState(state *ICEGathererState) ICEGathererState {
	return ICEGathererState(atomic.LoadUint32((*uint32)(state)))
}