RTCIceTransport: getSelectedCandidatePair() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The getSelectedCandidatePair() method of the RTCIceTransport interface returns an RTCIceCandidatePair object containing the current best-choice pair of ICE candidates describing the configuration of the endpoints of the transport.

Syntax

js
getSelectedCandidatePair()

Parameters

None.

Return value

A RTCIceCandidatePair object describing the configurations of the currently-selected candidate pair's two endpoints. local describes the configuration of the local end of the connection, while remote describes the remote peer's configuration.

The return value is null if no pair of candidates has been selected yet.

Usage notes

As the ICE agent performs negotiation of a RTCPeerConnection, it gathers and analyzes candidate configurations from each the two peers. As soon as it finds an acceptable matching pair of candidates, meeting the requirements for the connection, a selectedcandidatepairchange event is fired at the RTCIceTransport. From that time forward, the best matching pair of candidates will always be available by calling getSelectedCandidatePair().

As ICE negotiation continues, any time a pair of candidates is discovered that is better than the currently-selected pair, the new pair is selected, replacing the previous pairing, and the selectedcandidatepairchange event is fired again.

Note: It's possible for one of the configurations in the selected candidate pair to remain unchanged when a new pairing is chosen.

Examples

See RTCIceTransport.onselectedcandidatepairchange for example code.

Specifications

Specification
WebRTC: Real-Time Communication in Browsers
# dom-rtcicetransport-getselectedcandidatepair

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
getSelectedCandidatePair
Chrome – Full support
Chrome 75 (Release date: 2019-06-04)
footnote Full support
Edge – No support
Edge 13 – 18 (Release date: 2015-11-12)
altname
altname Alternate name: getNominatedCandidatePair
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 62 (Release date: 2019-06-27)
footnote Full support
Safari – Full support
Safari 16.4 (Release date: 2023-03-27)
footnote Full support
Chrome Android – Full support
Chrome Android 75 (Release date: 2019-06-04)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 54 (Release date: 2019-10-18)
footnote Full support
Safari on iOS – Full support
Safari on iOS 16.4 (Release date: 2023-03-27)
footnote Full support
Samsung Internet – Full support
Samsung Internet 11 (Release date: 2019-12-05)
footnote Full support
WebView Android – Full support
WebView Android 75 (Release date: 2019-06-04)
footnote Full support
WebView on iOS – Full support
WebView on iOS 16.4 (Release date: 2023-03-27)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Uses a non-standard name
Has more compatibility info.