RTCIceTransport.onselectedcandidatepairchange - Web APIs 编辑
The RTCIceTransport
interface's onselectedcandidatepairchange
event handler specifies a function to be called to handle the selectedcandidatepairchange
event, which is fired when the ICE agent selects a new candidate pair to be used for the connection.
Syntax
RTCIceTransport.onselectedcandidatepairchange = candidatePairHandler;
Value
This propoerty should be set to reference an event handler function to be called by the ICE agent when it discovers a new candidate pair that the RTCIceTransport
will be using for communication with the remote peer. This event will occur at least once, and may occur more than once if the ICE agent continues to identify candidate pairs that will work better, more closely match the requested parameters, and so forth.
The event handler can determine the current state by calling the transport's getSelectedCandidatePair()
method, which returns a RTCIceCandidatePair
whose RTCIceCandidatePair.local
and RTCIceCandidatePair.global
properties specify RTCIceCandidate
objects describing the local and remote candidates that are currently being used.
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
Specification | Status | Comment |
---|---|---|
WebRTC 1.0: Real-time Communication Between Browsers The definition of 'RTCIceTransport.onselectedcandidatepairchange' in that specification. | Candidate Recommendation | Initial specification. |
Browser compatibility
BCD tables only load in the browser
See also
- The
selectedcandidatepair
event and its type,Event
. - The other event handlers for
RTCIceTransport
:onstatechange
andongatheringstatechange
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论