gpt4 book ai didi

javascript - RTCPeerconnection.onicecandidate 功能?

转载 作者:行者123 更新时间:2023-12-03 01:48:53 30 4
gpt4 key购买 nike

下面我摘录了this link关于 RTCPeerConnection.onicecandidate 并希望根据我的理解提出两个问题,如果我的概念正确与否,则需要帮助。对我来说有点复杂

The RTCPeerConnection.onicecandidate property is an EventHandler which specifies a function to be called when the icecandidate event occurs on an RTCPeerConnection instance. This happens whenever the local ICE agent needs to deliver a message to the other peer through the signaling server.

我的解释引用下面的代码

1.这是否意味着 RTCPeerconnection.onicecandidate 在 ICE 的帮助下获取其本地 Icecandidate 时会自动调用以下匿名 javascript 函数。同时匿名功能有助于通过信号SERVER将Ice候选者传递到远程Peer。

2.引用以下代码:事件处理程序 RTCPeerconnection.onicecandidate 中的参数 event 是否包含有关 SDP 信息的详细信息,例如媒体类型、编解码器和方法 candidate 提供 Ice Candidate 的信息(即 IP 地址和端口号)。进一步组合成 sdp 并传递给远程对等点。

pc=new RTCPeerConnection();    
pc.onicecandidate = function(event) {
if (event.candidate) {
// Send the candidate to the remote peer
} else {
// All ICE candidates have been sent
}
}

最佳答案

1.Does this means that RTCPeerconnection.onicecandidate automatically call the below Anonymous javascript function

是的。根据rtcpeerconnection-onicecandidate :

onicecandidate of type EventHandler
The event type of this event handler is icecandidate .

因此,当新的 Ice Candidate 可用时,会自动调用处理程序。

2.With reference to below code : Does parameter event from event handler RTCPeerconnection.onicecandidate contain details about SDP info...

没有 SDP 信息。只需candidateurl

根据 rtcpeerconnectioniceevent ,它是一个RTCPeerConnectionIceEvent:

interface RTCPeerConnectionIceEvent : Event {
readonly attribute RTCIceCandidate? candidate;
readonly attribute DOMString? url;
};

关于javascript - RTCPeerconnection.onicecandidate 功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50509149/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com