forked from pion/webrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignalingstate.go
98 lines (85 loc) · 2.98 KB
/
signalingstate.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package webrtc
type stateChangeOp int
const (
stateChangeOpSetLocal stateChangeOp = iota + 1
stateChangeOpSetRemote
)
func (op stateChangeOp) String() string {
switch op {
case stateChangeOpSetLocal:
return "SetLocal"
case stateChangeOpSetRemote:
return "SetRemote"
default:
return "Unknown State Change Operation"
}
}
// SignalingState indicates the signaling state of the offer/answer process.
type SignalingState int
const (
// SignalingStateStable indicates there is no offer/answer exchange in
// progress. This is also the initial state, in which case the local and
// remote descriptions are nil.
SignalingStateStable SignalingState = iota + 1
// SignalingStateHaveLocalOffer indicates that a local description, of
// type "offer", has been successfully applied.
SignalingStateHaveLocalOffer
// SignalingStateHaveRemoteOffer indicates that a remote description, of
// type "offer", has been successfully applied.
SignalingStateHaveRemoteOffer
// SignalingStateHaveLocalPranswer indicates that a remote description
// of type "offer" has been successfully applied and a local description
// of type "pranswer" has been successfully applied.
SignalingStateHaveLocalPranswer
// SignalingStateHaveRemotePranswer indicates that a local description
// of type "offer" has been successfully applied and a remote description
// of type "pranswer" has been successfully applied.
SignalingStateHaveRemotePranswer
// SignalingStateClosed indicates The PeerConnection has been closed.
SignalingStateClosed
)
// This is done this way because of a linter.
const (
signalingStateStableStr = "stable"
signalingStateHaveLocalOfferStr = "have-local-offer"
signalingStateHaveRemoteOfferStr = "have-remote-offer"
signalingStateHaveLocalPranswerStr = "have-local-pranswer"
signalingStateHaveRemotePranswerStr = "have-remote-pranswer"
signalingStateClosedStr = "closed"
)
func newSignalingState(raw string) SignalingState {
switch raw {
case signalingStateStableStr:
return SignalingStateStable
case signalingStateHaveLocalOfferStr:
return SignalingStateHaveLocalOffer
case signalingStateHaveRemoteOfferStr:
return SignalingStateHaveRemoteOffer
case signalingStateHaveLocalPranswerStr:
return SignalingStateHaveLocalPranswer
case signalingStateHaveRemotePranswerStr:
return SignalingStateHaveRemotePranswer
case signalingStateClosedStr:
return SignalingStateClosed
default:
return SignalingState(Unknown)
}
}
func (t SignalingState) String() string {
switch t {
case SignalingStateStable:
return signalingStateStableStr
case SignalingStateHaveLocalOffer:
return signalingStateHaveLocalOfferStr
case SignalingStateHaveRemoteOffer:
return signalingStateHaveRemoteOfferStr
case SignalingStateHaveLocalPranswer:
return signalingStateHaveLocalPranswerStr
case SignalingStateHaveRemotePranswer:
return signalingStateHaveRemotePranswerStr
case SignalingStateClosed:
return signalingStateClosedStr
default:
return ErrUnknownType.Error()
}
}