[英]WebRTC The ICE candidate could not be added
I am trying to establish a p2p audio/video connection b/w two peers.我正在尝试建立一个 p2p 音频/视频连接 b/w 两个对等方。 Following: Getting started with WebRTC .
以下: WebRTC 入门。
It works fine at my home in LAN Environment between 2 PCs, but throws an error message when running at my company's LAN Environment, there is part the javascript它在我家的 2 台 PC 之间的 LAN 环境中运行良好,但在我公司的 LAN 环境中运行时会抛出错误消息,其中一部分是 javascript
function processSignalingMessage(message) {
var msg = JSON.parse(message);
if (msg.type === 'offer') {
// Callee creates PeerConnection
if (!initiator && !started)
maybeStart();
// We only know JSEP version after createPeerConnection().
if (isRTCPeerConnection)
pc.setRemoteDescription(new RTCSessionDescription(msg));
else
pc.setRemoteDescription(pc.SDP_OFFER,
new SessionDescription(msg.sdp));
doAnswer();
} else if (msg.type === 'answer' && started) {
pc.setRemoteDescription(new RTCSessionDescription(msg));
} else if (msg.type === 'candidate' && started) {
var candidate = new RTCIceCandidate({
sdpMLineIndex : msg.label,
candidate : msg.candidate
});
pc.addIceCandidate(candidate);
} else if (msg.type === 'bye' && started) {
onRemoteHangup();
}
}
when the first user recieved message "type":"candidate",get wrong当第一个用户收到消息“type”:“candidate”时,会出错
and part of the console log:和控制台日志的一部分:
I think you can create the ICE candidate message by using just the msg.candidate,我认为您可以仅使用 msg.candidate 创建 ICE 候选消息,
var candidate = new RTCIceCandidate(msg.candidate);
And pass that into the addIceCandidate
function并将其传递给
addIceCandidate
function
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.