forked from calebdoxsey/webrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rtcsignalingstate.go
80 lines (70 loc) · 2.81 KB
/
rtcsignalingstate.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
package webrtc
// RTCSignalingState indicates the signaling state of the offer/answer process.
type RTCSignalingState int
const (
// RTCSignalingStateStable 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.
RTCSignalingStateStable RTCSignalingState = iota + 1
// RTCSignalingStateHaveLocalOffer indicates that a local description, of
// type "offer", has been successfully applied.
RTCSignalingStateHaveLocalOffer
// RTCSignalingStateHaveRemoteOffer indicates that a remote description, of
// type "offer", has been successfully applied.
RTCSignalingStateHaveRemoteOffer
// RTCSignalingStateHaveLocalPranswer indicates that a remote description
// of type "offer" has been successfully applied and a local description
// of type "pranswer" has been successfully applied.
RTCSignalingStateHaveLocalPranswer
// RTCSignalingStateHaveRemotePranswer indicates that a local description
// of type "offer" has been successfully applied and a remote description
// of type "pranswer" has been successfully applied.
RTCSignalingStateHaveRemotePranswer
// RTCSignalingStateClosed indicates The RTCPeerConnection has been closed.
RTCSignalingStateClosed
)
// This is done this way because of a linter.
const (
rtcSignalingStateStableStr = "stable"
rtcSignalingStateHaveLocalOfferStr = "have-local-offer"
rtcSignalingStateHaveRemoteOfferStr = "have-remote-offer"
rtcSignalingStateHaveLocalPranswerStr = "have-local-pranswer"
rtcSignalingStateHaveRemotePranswerStr = "have-remote-pranswer"
rtcSignalingStateClosedStr = "closed"
)
func newRTCSignalingState(raw string) RTCSignalingState {
switch raw {
case rtcSignalingStateStableStr:
return RTCSignalingStateStable
case rtcSignalingStateHaveLocalOfferStr:
return RTCSignalingStateHaveLocalOffer
case rtcSignalingStateHaveRemoteOfferStr:
return RTCSignalingStateHaveRemoteOffer
case rtcSignalingStateHaveLocalPranswerStr:
return RTCSignalingStateHaveLocalPranswer
case rtcSignalingStateHaveRemotePranswerStr:
return RTCSignalingStateHaveRemotePranswer
case rtcSignalingStateClosedStr:
return RTCSignalingStateClosed
default:
return RTCSignalingState(Unknown)
}
}
func (t RTCSignalingState) String() string {
switch t {
case RTCSignalingStateStable:
return rtcSignalingStateStableStr
case RTCSignalingStateHaveLocalOffer:
return rtcSignalingStateHaveLocalOfferStr
case RTCSignalingStateHaveRemoteOffer:
return rtcSignalingStateHaveRemoteOfferStr
case RTCSignalingStateHaveLocalPranswer:
return rtcSignalingStateHaveLocalPranswerStr
case RTCSignalingStateHaveRemotePranswer:
return rtcSignalingStateHaveRemotePranswerStr
case RTCSignalingStateClosed:
return rtcSignalingStateClosedStr
default:
return ErrUnknownType.Error()
}
}