mirror of
https://github.com/pion/webrtc.git
synced 2025-10-07 08:01:27 +08:00

Modify RTCSdpType to protect newRTCSdpType Modify RTCPriorityType to protect methods Modify RTCSctpTransportState to protect methods Modify RTCRtcpMuxPolicy to protect methods Modify RTCPeerConnectionState to protect methods Modify RTCIceTransportPolicy to protect methods Modify RTCIceGatheringState to protect methods Modify RTCIceCredentialType to protect methods Modify RTCIceConnectionState to protect methods Modify RTCDtlsTransportState to protect methods Modify RTCDataChannelState to protect methods Modify RTCBundlePolicy to protect methods Relates to #83
62 lines
1.9 KiB
Go
62 lines
1.9 KiB
Go
package webrtc
|
|
|
|
// RTCDataChannelState indicates the state of a data channel.
|
|
type RTCDataChannelState int
|
|
|
|
const (
|
|
// RTCDataChannelStateConnecting indicates that the data channel is being
|
|
// established. This is the initial state of RTCDataChannel, whether created
|
|
// with CreateDataChannel, or dispatched as a part of an RTCDataChannelEvent.
|
|
RTCDataChannelStateConnecting RTCDataChannelState = iota + 1
|
|
|
|
// RTCDataChannelStateOpen indicates that the underlying data transport is
|
|
// established and communication is possible.
|
|
RTCDataChannelStateOpen
|
|
|
|
// RTCDataChannelStateClosing indicates that the procedure to close down the
|
|
// underlying data transport has started.
|
|
RTCDataChannelStateClosing
|
|
|
|
// RTCDataChannelStateClosed indicates that the underlying data transport
|
|
// has been closed or could not be established.
|
|
RTCDataChannelStateClosed
|
|
)
|
|
|
|
// This is done this way because of a linter.
|
|
const (
|
|
rtcDataChannelStateConnectingStr = "connecting"
|
|
rtcDataChannelStateOpenStr = "open"
|
|
rtcDataChannelStateClosingStr = "closing"
|
|
rtcDataChannelStateClosedStr = "closed"
|
|
)
|
|
|
|
func newRTCDataChannelState(raw string) RTCDataChannelState {
|
|
switch raw {
|
|
case rtcDataChannelStateConnectingStr:
|
|
return RTCDataChannelStateConnecting
|
|
case rtcDataChannelStateOpenStr:
|
|
return RTCDataChannelStateOpen
|
|
case rtcDataChannelStateClosingStr:
|
|
return RTCDataChannelStateClosing
|
|
case rtcDataChannelStateClosedStr:
|
|
return RTCDataChannelStateClosed
|
|
default:
|
|
return RTCDataChannelState(Unknown)
|
|
}
|
|
}
|
|
|
|
func (t RTCDataChannelState) String() string {
|
|
switch t {
|
|
case RTCDataChannelStateConnecting:
|
|
return rtcDataChannelStateConnectingStr
|
|
case RTCDataChannelStateOpen:
|
|
return rtcDataChannelStateOpenStr
|
|
case RTCDataChannelStateClosing:
|
|
return rtcDataChannelStateClosingStr
|
|
case RTCDataChannelStateClosed:
|
|
return rtcDataChannelStateClosedStr
|
|
default:
|
|
return ErrUnknownType.Error()
|
|
}
|
|
}
|