Overview
TheICEGatherer 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
Methods
Gather
Starts gathering ICE candidates.icegatherer.go
error
Returns nil on success, or an error if gathering cannot be started
GetLocalParameters
Returns the ICE parameters of the ICEGatherer.icegatherer.go
ICEParameters, error
Returns the local ICE parameters (username fragment, password) or an error
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
State
Returns the current state of the ICE gatherer.icegatherer.go
ICEGathererState
The current ICE gatherer state (New, Gathering, Complete, Closed)
OnLocalCandidate
Sets an event handler which fires when a new local ICE candidate is available.icegatherer.go
func(*ICECandidate)
required
Callback function that receives ICE candidates. Called with nil when gathering completes.
OnStateChange
Sets a handler that fires when the ICEGatherer state changes.icegatherer.go
func(ICEGathererState)
required
Callback function that receives state change notifications
Close
Prunes all local candidates and closes the ports.icegatherer.go
error
Returns nil on success, or an error if closing fails
GracefulClose
Prunes all local candidates and closes the ports, waiting for goroutines to complete.icegatherer.go
error
Returns nil on success, or an error if closing fails
Related Types
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
- ICETransport - Manages ICE connectivity
- DTLSTransport - Handles DTLS encryption over ICE
- PeerConnection - High-level WebRTC API