Skip to main content

Overview

The ICETransport 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
Example:

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
Example:

Stop

Irreversibly stops the ICETransport.
icetransport.go
error
Returns nil on success, or an error if stopping fails
Example:

GracefulStop

Irreversibly stops the ICETransport and waits for goroutines to complete.
This is only safe to call outside of ICETransport callbacks or if in a callback, in its own goroutine.
icetransport.go
error
Returns nil on success, or an error if stopping fails
Example:

State

Returns the current ICE transport state.
icetransport.go
ICETransportState
The current state (New, Checking, Connected, Completed, Failed, Disconnected, Closed)
Example:

Role

Returns the current role of the ICE transport.
icetransport.go
ICERole
The current ICE role (Controlling or Controlled)
Example:

GetLocalParameters

Returns an ICEParameters object uniquely identifying the local peer.
icetransport.go
ICEParameters, error
Returns the local ICE parameters or an error
Example:

GetRemoteParameters

Returns an ICEParameters object uniquely identifying the remote peer.
icetransport.go
ICEParameters, error
Returns the remote ICE parameters or an error
Example:

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
Example:

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
Example:

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
Example:

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
Example:

OnConnectionStateChange

Sets a handler that fires when the ICE connection state changes.
icetransport.go
func(ICETransportState)
required
Callback function that receives state change notifications
Example:

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
Example:

Stats

Reports the current statistics of the ICETransport.
icetransport.go
TransportStats
Returns transport statistics including bytes sent and received
Example:

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