RTCIceTransport.getSelectedCandidatePair() - Web APIs 编辑

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

Syntax

candidatePair = RTCIceTransport.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.

Example

In this example, an event handler for selectedcandidatepairchange is set up to update an on-screen display showing the protocol used by the currently selected candidate pair.

var iceTransport = pc.getSenders()[0].transport.iceTransport;
var localProto = document.getElementById("local-protocol");
var remoteProto = document.getElementById("remote-protocol");

iceTransport.onselectedcandidatepairchange = function(event) {
  var pair = iceTransport.getSelectedCandidatePair();
  localProtocol.innerText = pair.local.protocol.toUpperCase();
  remoteProtocol.innerText = pair.remote.protocol.toUpperCase();
}

Specifications

SpecificationStatusComment
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCIceTransport.getSelectedCandidatePair()' in that specification.
Candidate RecommendationInitial specification.

Browser compatibility

BCD tables only load in the browser

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:70 次

字数:4443

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文