forked from calebdoxsey/webrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rtciceconnectionstate.go
93 lines (82 loc) · 3.22 KB
/
rtciceconnectionstate.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
package webrtc
// RTCIceConnectionState indicates signaling state of the Ice Connection.
type RTCIceConnectionState int
const (
// RTCIceConnectionStateNew indicates that any of the RTCIceTransports are
// in the "new" state and none of them are in the "checking", "disconnected"
// or "failed" state, or all RTCIceTransports are in the "closed" state, or
// there are no transports.
RTCIceConnectionStateNew RTCIceConnectionState = iota + 1
// RTCIceConnectionStateChecking indicates that any of the RTCIceTransports
// are in the "checking" state and none of them are in the "disconnected"
// or "failed" state.
RTCIceConnectionStateChecking
// RTCIceConnectionStateConnected indicates that all RTCIceTransports are
// in the "connected", "completed" or "closed" state and at least one of
// them is in the "connected" state.
RTCIceConnectionStateConnected
// RTCIceConnectionStateCompleted indicates that all RTCIceTransports are
// in the "completed" or "closed" state and at least one of them is in the
// "completed" state.
RTCIceConnectionStateCompleted
// RTCIceConnectionStateDisconnected indicates that any of the
// RTCIceTransports are in the "disconnected" state and none of them are
// in the "failed" state.
RTCIceConnectionStateDisconnected
// RTCIceConnectionStateFailed indicates that any of the RTCIceTransports
// are in the "failed" state.
RTCIceConnectionStateFailed
// RTCIceConnectionStateClosed indicates that the RTCPeerConnection's
// isClosed is true.
RTCIceConnectionStateClosed
)
// This is done this way because of a linter.
const (
rtcIceConnectionStateNewStr = "new"
rtcIceConnectionStateCheckingStr = "checking"
rtcIceConnectionStateConnectedStr = "connected"
rtcIceConnectionStateCompletedStr = "completed"
rtcIceConnectionStateDisconnectedStr = "disconnected"
rtcIceConnectionStateFailedStr = "failed"
rtcIceConnectionStateClosedStr = "closed"
)
func newRTCIceConnectionState(raw string) RTCIceConnectionState {
switch raw {
case rtcIceConnectionStateNewStr:
return RTCIceConnectionStateNew
case rtcIceConnectionStateCheckingStr:
return RTCIceConnectionStateChecking
case rtcIceConnectionStateConnectedStr:
return RTCIceConnectionStateConnected
case rtcIceConnectionStateCompletedStr:
return RTCIceConnectionStateCompleted
case rtcIceConnectionStateDisconnectedStr:
return RTCIceConnectionStateDisconnected
case rtcIceConnectionStateFailedStr:
return RTCIceConnectionStateFailed
case rtcIceConnectionStateClosedStr:
return RTCIceConnectionStateClosed
default:
return RTCIceConnectionState(Unknown)
}
}
func (c RTCIceConnectionState) String() string {
switch c {
case RTCIceConnectionStateNew:
return rtcIceConnectionStateNewStr
case RTCIceConnectionStateChecking:
return rtcIceConnectionStateCheckingStr
case RTCIceConnectionStateConnected:
return rtcIceConnectionStateConnectedStr
case RTCIceConnectionStateCompleted:
return rtcIceConnectionStateCompletedStr
case RTCIceConnectionStateDisconnected:
return rtcIceConnectionStateDisconnectedStr
case RTCIceConnectionStateFailed:
return rtcIceConnectionStateFailedStr
case RTCIceConnectionStateClosed:
return rtcIceConnectionStateClosedStr
default:
return ErrUnknownType.Error()
}
}