Overview
TheICETransport allows an application access to information about the ICE transport over which packets are sent and received.
This is part of the ORTC API. It is not meant to be used together with the basic WebRTC API.
Type Definition
icetransport.go
Constructor
NewICETransport
Creates a new ICETransport with the given ICEGatherer.icetransport.go
*ICEGatherer
required
The ICE gatherer to use for candidate gathering
logging.LoggerFactory
required
Factory for creating loggers
*ICETransport
Returns a new ICETransport instance
Methods
Start
Starts incoming connectivity checks based on the configured role.icetransport.go
*ICEGatherer
Optional ICE gatherer to use (can be nil to use the existing one)
ICEParameters
required
Remote ICE parameters (username fragment and password)
*ICERole
ICE role (controlling or controlled). If nil, defaults to controlled.
error
Returns nil on success, or an error if the transport cannot be started
Stop
Irreversibly stops the ICETransport.icetransport.go
error
Returns nil on success, or an error if stopping fails
GracefulStop
Irreversibly stops the ICETransport and waits for goroutines to complete.icetransport.go
error
Returns nil on success, or an error if stopping fails
State
Returns the current ICE transport state.icetransport.go
ICETransportState
The current state (New, Checking, Connected, Completed, Failed, Disconnected, Closed)
Role
Returns the current role of the ICE transport.icetransport.go
ICERole
The current ICE role (Controlling or Controlled)
GetLocalParameters
Returns an ICEParameters object uniquely identifying the local peer.icetransport.go
ICEParameters, error
Returns the local ICE parameters or an error
GetRemoteParameters
Returns an ICEParameters object uniquely identifying the remote peer.icetransport.go
ICEParameters, error
Returns the remote ICE parameters or an error
GetSelectedCandidatePair
Returns the selected candidate pair on which packets are sent.icetransport.go
*ICECandidatePair, error
Returns the selected candidate pair or nil if no pair is selected
GetSelectedCandidatePairStats
Returns statistics for the selected candidate pair.icetransport.go
ICECandidatePairStats, bool
Returns stats and true if available, or empty stats and false if not available
AddRemoteCandidate
Adds a candidate associated with the remote ICETransport.icetransport.go
*ICECandidate
The remote ICE candidate to add (can be nil to signal end-of-candidates)
error
Returns nil on success, or an error if the candidate cannot be added
SetRemoteCandidates
Sets the sequence of candidates associated with the remote ICETransport.icetransport.go
[]ICECandidate
required
Slice of remote ICE candidates to set
error
Returns nil on success, or an error if candidates cannot be set
OnConnectionStateChange
Sets a handler that fires when the ICE connection state changes.icetransport.go
func(ICETransportState)
required
Callback function that receives state change notifications
OnSelectedCandidatePairChange
Sets a handler invoked when a new ICE candidate pair is selected.icetransport.go
func(*ICECandidatePair)
required
Callback function that receives the selected candidate pair
Stats
Reports the current statistics of the ICETransport.icetransport.go
TransportStats
Returns transport statistics including bytes sent and received
States
The ICETransport can be in one of the following states:- ICETransportStateNew: Initial state
- ICETransportStateChecking: Checking candidate pairs
- ICETransportStateConnected: Successfully connected
- ICETransportStateCompleted: Completed gathering and checks
- ICETransportStateFailed: Failed to establish connection
- ICETransportStateDisconnected: Temporarily disconnected
- ICETransportStateClosed: Transport has been closed
Usage Example
See Also
- ICEGatherer - Gathers ICE candidates
- DTLSTransport - Handles DTLS encryption over ICE
- PeerConnection - High-level WebRTC API