如何添加WebRTC ICE Candidate?

问题描述 投票:0回答:1

我正在编写一个自定义应用程序服务器来控制Kurento Media Server。

当我尝试使用以下方法添加 IceCandidate 时:

webRtcPeer.addIceCandidate

我收到错误:

Failed to construct 'RTCIceCandidate': cannot convert to dictionary. 
at WebRtcPeerSendrecv.WebRtcPeer.addIceCandidate (kurento-utils.min.js:2)

以下是一些需要添加到 webrtc 的候选者:

candidate:1 1 UDP 2015363327 172.31.46.122 11836 typ host
candidate:2 1 TCP 1015021823 172.31.46.122 9 typ host tcptype active
candidate:3 1 TCP 1010827519 172.31.46.122 2089 typ host tcptype passive
candidate:4 1 UDP 2015363583 fe80::c08:83ff:feef:264c 7391 typ host
candidate:5 1 TCP 1015022079 fe80::c08:83ff:feef:264c 9 typ host tcptype active

如何解决此错误?

javascript webrtc
1个回答
0
投票

查看Kurento 客户端文档

addIceCandidate
的输入必须是IceCandidate。 根据您的描述,您仅设置对象的
candidate
属性。您还需要
sdpMid
sdpMLineIndex
才能成功。

所以你应该是这样的:

IceCandidate incomingCandidate = new IceCandidate(candidate, sdpMid, sdpMLineIndex);

webRtcPeer.addIceCandidate(incomingCandidate);

您应该从信令服务器获取

sdpMLineIndex
sdpMid
的信息以及您已有的候选字符串(又名
candidate:1 1 UDP 2015363327 172.31.46.122 11836 typ host
)。

© www.soinside.com 2019 - 2024. All rights reserved.