snapshot of https://github.com/pion/webrtc.git (main, 2026-09-15; blobs > 131072B omitted)
Some checks failed
REUSE Compliance Check / lint (push) Failing after 0s
Browser E2E / Test (push) Failing after 3s
Test / test (1.24) (push) Failing after 0s
Test / test-i386 (1.25) (push) Failing after 0s
Test / test-i386 (1.24) (push) Failing after 0s
Test / test-windows (1.25) (push) Failing after 0s
Test / test-windows (1.24) (push) Failing after 0s
Test / test (1.25) (push) Failing after 0s
Examples Tests / Test (push) Failing after 3s
Test / test-macos (1.25) (push) Failing after 0s
Test / test-macos (1.24) (push) Failing after 0s
Go mod tidy / tidy (push) Failing after 0s
Test / test-wasm (push) Failing after 0s
CodeQL / analyze (push) Failing after 1s
Fuzz / fuzz (push) Failing after 0s
Some checks failed
REUSE Compliance Check / lint (push) Failing after 0s
Browser E2E / Test (push) Failing after 3s
Test / test (1.24) (push) Failing after 0s
Test / test-i386 (1.25) (push) Failing after 0s
Test / test-i386 (1.24) (push) Failing after 0s
Test / test-windows (1.25) (push) Failing after 0s
Test / test-windows (1.24) (push) Failing after 0s
Test / test (1.25) (push) Failing after 0s
Examples Tests / Test (push) Failing after 3s
Test / test-macos (1.25) (push) Failing after 0s
Test / test-macos (1.24) (push) Failing after 0s
Go mod tidy / tidy (push) Failing after 0s
Test / test-wasm (push) Failing after 0s
CodeQL / analyze (push) Failing after 1s
Fuzz / fuzz (push) Failing after 0s
This commit is contained in:
89
peerconnectionstate.go
Normal file
89
peerconnectionstate.go
Normal file
@@ -0,0 +1,89 @@
|
||||
// SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package webrtc
|
||||
|
||||
// PeerConnectionState indicates the state of the PeerConnection.
|
||||
type PeerConnectionState int
|
||||
|
||||
const (
|
||||
// PeerConnectionStateUnknown is the enum's zero-value.
|
||||
PeerConnectionStateUnknown PeerConnectionState = iota
|
||||
|
||||
// PeerConnectionStateNew indicates that any of the ICETransports or
|
||||
// DTLSTransports are in the "new" state and none of the transports are
|
||||
// in the "connecting", "checking", "failed" or "disconnected" state, or
|
||||
// all transports are in the "closed" state, or there are no transports.
|
||||
PeerConnectionStateNew
|
||||
|
||||
// PeerConnectionStateConnecting indicates that any of the
|
||||
// ICETransports or DTLSTransports are in the "connecting" or
|
||||
// "checking" state and none of them is in the "failed" state.
|
||||
PeerConnectionStateConnecting
|
||||
|
||||
// PeerConnectionStateConnected indicates that all ICETransports and
|
||||
// DTLSTransports are in the "connected", "completed" or "closed" state
|
||||
// and at least one of them is in the "connected" or "completed" state.
|
||||
PeerConnectionStateConnected
|
||||
|
||||
// PeerConnectionStateDisconnected indicates that any of the
|
||||
// ICETransports or DTLSTransports are in the "disconnected" state
|
||||
// and none of them are in the "failed" or "connecting" or "checking" state.
|
||||
PeerConnectionStateDisconnected
|
||||
|
||||
// PeerConnectionStateFailed indicates that any of the ICETransports
|
||||
// or DTLSTransports are in a "failed" state.
|
||||
PeerConnectionStateFailed
|
||||
|
||||
// PeerConnectionStateClosed indicates the peer connection is closed
|
||||
// and the isClosed member variable of PeerConnection is true.
|
||||
PeerConnectionStateClosed
|
||||
)
|
||||
|
||||
// This is done this way because of a linter.
|
||||
const (
|
||||
peerConnectionStateNewStr = "new"
|
||||
peerConnectionStateConnectingStr = "connecting"
|
||||
peerConnectionStateConnectedStr = "connected"
|
||||
peerConnectionStateDisconnectedStr = "disconnected"
|
||||
peerConnectionStateFailedStr = "failed"
|
||||
peerConnectionStateClosedStr = "closed"
|
||||
)
|
||||
|
||||
func newPeerConnectionState(raw string) PeerConnectionState {
|
||||
switch raw {
|
||||
case peerConnectionStateNewStr:
|
||||
return PeerConnectionStateNew
|
||||
case peerConnectionStateConnectingStr:
|
||||
return PeerConnectionStateConnecting
|
||||
case peerConnectionStateConnectedStr:
|
||||
return PeerConnectionStateConnected
|
||||
case peerConnectionStateDisconnectedStr:
|
||||
return PeerConnectionStateDisconnected
|
||||
case peerConnectionStateFailedStr:
|
||||
return PeerConnectionStateFailed
|
||||
case peerConnectionStateClosedStr:
|
||||
return PeerConnectionStateClosed
|
||||
default:
|
||||
return PeerConnectionStateUnknown
|
||||
}
|
||||
}
|
||||
|
||||
func (t PeerConnectionState) String() string {
|
||||
switch t {
|
||||
case PeerConnectionStateNew:
|
||||
return peerConnectionStateNewStr
|
||||
case PeerConnectionStateConnecting:
|
||||
return peerConnectionStateConnectingStr
|
||||
case PeerConnectionStateConnected:
|
||||
return peerConnectionStateConnectedStr
|
||||
case PeerConnectionStateDisconnected:
|
||||
return peerConnectionStateDisconnectedStr
|
||||
case PeerConnectionStateFailed:
|
||||
return peerConnectionStateFailedStr
|
||||
case PeerConnectionStateClosed:
|
||||
return peerConnectionStateClosedStr
|
||||
default:
|
||||
return ErrUnknownType.Error()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user