Skip to main content

Overview

The ICEGatherer gathers local host, server reflexive and relay candidates, as well as enabling the retrieval of local Interactive Connectivity Establishment (ICE) parameters which can be exchanged in signaling.
This is part of the ORTC API. It is not meant to be used together with the basic WebRTC API.

Type Definition

icegatherer.go

Constructor

NewICEGatherer

Creates a new ICEGatherer with the specified options.
icegatherer.go
ICEGatherOptions
required
Configuration options for the ICE gatherer
*ICEGatherer, error
Returns a new ICEGatherer instance or an error if creation fails
Example:

Methods

Gather

Starts gathering ICE candidates.
icegatherer.go
error
Returns nil on success, or an error if gathering cannot be started
Example:

GetLocalParameters

Returns the ICE parameters of the ICEGatherer.
icegatherer.go
ICEParameters, error
Returns the local ICE parameters (username fragment, password) or an error
Example:

GetLocalCandidates

Returns the sequence of valid local candidates associated with the ICEGatherer.
icegatherer.go
[]ICECandidate, error
Returns a slice of local ICE candidates or an error
Example:

State

Returns the current state of the ICE gatherer.
icegatherer.go
ICEGathererState
The current ICE gatherer state (New, Gathering, Complete, Closed)
Example:

OnLocalCandidate

Sets an event handler which fires when a new local ICE candidate is available.
The handler will be called with a nil pointer when gathering is finished.
icegatherer.go
func(*ICECandidate)
required
Callback function that receives ICE candidates. Called with nil when gathering completes.
Example:

OnStateChange

Sets a handler that fires when the ICEGatherer state changes.
icegatherer.go
func(ICEGathererState)
required
Callback function that receives state change notifications
Example:

Close

Prunes all local candidates and closes the ports.
icegatherer.go
error
Returns nil on success, or an error if closing fails
Example:

GracefulClose

Prunes all local candidates and closes the ports, waiting for goroutines to complete.
This is only safe to call outside of ICEGatherer callbacks or if in a callback, in its own goroutine.
icegatherer.go
error
Returns nil on success, or an error if closing fails
Example:

ICEAddressRewriteRule

Represents a rule for remapping candidate addresses.
icegatherer.go
[]string
External IP addresses to use
string
Local IP address to match
string
Network interface name to match
string
CIDR notation to match local addresses
ICECandidateType
Type to use for rewritten candidates
ICEAddressRewriteMode
Whether to replace or append candidates
[]NetworkType
Network types to apply this rule to

ICEAddressRewriteMode

Controls whether a rule replaces or appends candidates.
icegatherer.go

States

The ICEGatherer can be in one of the following states:
  • ICEGathererStateNew: Initial state
  • ICEGathererStateGathering: Currently gathering candidates
  • ICEGathererStateComplete: Gathering has completed
  • ICEGathererStateClosed: Gatherer has been closed

Usage Example

See Also