-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
icegathererstate.go
54 lines (43 loc) · 1.47 KB
/
icegathererstate.go
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
49
50
51
52
53
54
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT
package webrtc
import (
"sync/atomic"
)
// ICEGathererState represents the current state of the ICE gatherer.
type ICEGathererState uint32
const (
// ICEGathererStateUnknown is the enum's zero-value
ICEGathererStateUnknown ICEGathererState = iota
// ICEGathererStateNew indicates object has been created but
// gather() has not been called.
ICEGathererStateNew
// 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 ErrUnknownType.Error()
}
}
func atomicStoreICEGathererState(state *ICEGathererState, newState ICEGathererState) {
atomic.StoreUint32((*uint32)(state), uint32(newState))
}
func atomicLoadICEGathererState(state *ICEGathererState) ICEGathererState {
return ICEGathererState(atomic.LoadUint32((*uint32)(state)))
}