大网数据广告活动
Web 标准与前端开发

RTCIceTransport: getSelectedCandidatePair() method

· 52CE 我爱测

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

WebRTC

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

Syntax

getSelectedCandidatePair()

Parameters

None.

Return value

An RTCIceCandidatePair instance describing the configurations of the currently-selected candidate pair's RTCIceCandidatePair.local and RTCIceCandidatePair.remote endpoints.

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

Description

As the ICE agent performs negotiation of a RTCPeerConnection, it gathers and analyzes candidate configurations from each of the two peers. As soon as it finds an acceptable matching pair of candidates, meeting the requirements for the connection, a RTCIceTransport.selectedcandidatepairchange_event 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

Browser compatibility

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。