WebRTC onicecandidate发射21次。可以吗?

时间:2015-01-13 16:34:25

标签: webrtc

我正在学习WebRTC。在教程中我写了一个代码:

var pc = new RTCPeerConnection({'iceServers': [{ 'url': 'stun:stun.l.google.com:19302'}]});
pc.onicecandidate = function (evnt) {
    console.log('GOT ICE CANDIDATE');
socket.emit('msg', { by: currentId, to: id, ice: evnt.candidate, type: 'ice' });
    iceCandidate = evnt.candidate;
};
pc.onaddstream = function (evnt) {
        console.log('Received new stream');
        remoteStream = evnt.stream;
};

onicecandidate发射21次。所以套接字发送消息21次。我很困惑,我有21个iceCandidates,那个套接字此时发送了21次消息?谢谢 这是候选人的日志

 GOT ICE CANDIDATE:  RTCIceCandidate {sdpMLineIndex: 0, sdpMid: "audio", candidate: "candidate:3612426851 1 udp 2122260223 10.5.123.27 51569 typ host generation 0"}
conversation.client.controller.js:14 GOT ICE CANDIDATE:  RTCIceCandidate {sdpMLineIndex: 0, sdpMid: "audio", candidate: "candidate:3612426851 2 udp 2122260223 10.5.123.27 51569 typ host generation 0"}
conversation.client.controller.js:14 GOT ICE CANDIDATE:  RTCIceCandidate {sdpMLineIndex: 0, sdpMid: "audio", candidate: "candidate:2541423865 1 udp 2122129151 169.254.22.161 51570 typ host generation 0"}
conversation.client.controller.js:14 GOT ICE CANDIDATE:  RTCIceCandidate {sdpMLineIndex: 0, sdpMid: "audio", candidate: "candidate:2541423865 2 udp 2122129151 169.254.22.161 51570 typ host generation 0"}
conversation.client.controller.js:14 GOT ICE CANDIDATE:  RTCIceCandidate {sdpMLineIndex: 1, sdpMid: "video", candidate: "candidate:3612426851 1 udp 2122260223 10.5.123.27 51569 typ host generation 0"}
conversation.client.controller.js:14 GOT ICE CANDIDATE:  RTCIceCandidate {sdpMLineIndex: 1, sdpMid: "video", candidate: "candidate:3612426851 2 udp 2122260223 10.5.123.27 51569 typ host generation 0"}
conversation.client.controller.js:14 GOT ICE CANDIDATE:  RTCIceCandidate {sdpMLineIndex: 1, sdpMid: "video", candidate: "candidate:2541423865 1 udp 2122129151 169.254.22.161 51570 typ host generation 0"}
conversation.client.controller.js:14 GOT ICE CANDIDATE:  RTCIceCandidate {sdpMLineIndex: 1, sdpMid: "video", candidate: "candidate:2541423865 2 udp 2122129151 169.254.22.161 51570 typ host generation 0"}
conversation.client.controller.js:14 GOT ICE CANDIDATE:  RTCIceCandidate {sdpMLineIndex: 0, sdpMid: "audio", candidate: "candidate:2580725395 1 tcp 1518280447 10.5.123.27 0 typ host tcptype active generation 0"}
conversation.client.controller.js:14 GOT ICE CANDIDATE:  RTCIceCandidate {sdpMLineIndex: 0, sdpMid: "audio", candidate: "candidate:2580725395 2 tcp 1518280447 10.5.123.27 0 typ host tcptype active generation 0"}
conversation.client.controller.js:14 GOT ICE CANDIDATE:  RTCIceCandidate {sdpMLineIndex: 0, sdpMid: "audio", candidate: "candidate:3656970249 1 tcp 1518149375 169.254.22.161 0 typ host tcptype active generation 0"}
conversation.client.controller.js:14 GOT ICE CANDIDATE:  RTCIceCandidate {sdpMLineIndex: 0, sdpMid: "audio", candidate: "candidate:3656970249 2 tcp 1518149375 169.254.22.161 0 typ host tcptype active generation 0"}
conversation.client.controller.js:14 GOT ICE CANDIDATE:  RTCIceCandidate {sdpMLineIndex: 1, sdpMid: "video", candidate: "candidate:2580725395 1 tcp 1518280447 10.5.123.27 0 typ host tcptype active generation 0"}
conversation.client.controller.js:14 GOT ICE CANDIDATE:  RTCIceCandidate {sdpMLineIndex: 1, sdpMid: "video", candidate: "candidate:2580725395 2 tcp 1518280447 10.5.123.27 0 typ host tcptype active generation 0"}
conversation.client.controller.js:14 GOT ICE CANDIDATE:  RTCIceCandidate {sdpMLineIndex: 1, sdpMid: "video", candidate: "candidate:3656970249 1 tcp 1518149375 169.254.22.161 0 typ host tcptype active generation 0"}
conversation.client.controller.js:14 GOT ICE CANDIDATE:  RTCIceCandidate {sdpMLineIndex: 1, sdpMid: "video", candidate: "candidate:3656970249 2 tcp 1518149375 169.254.22.161 0 typ host tcptype active generation 0"}
conversation.client.controller.js:14 GOT ICE CANDIDATE:  RTCIceCandidate {sdpMLineIndex: 0, sdpMid: "audio", candidate: "candidate:2114899382 1 udp 1686052607 213.230.83.5… srflx raddr 10.5.123.27 rport 51569 generation 0"}
conversation.client.controller.js:14 GOT ICE CANDIDATE:  RTCIceCandidate {sdpMLineIndex: 0, sdpMid: "audio", candidate: "candidate:2114899382 2 udp 1686052607 213.230.83.5… srflx raddr 10.5.123.27 rport 51569 generation 0"}
conversation.client.controller.js:14 GOT ICE CANDIDATE:  RTCIceCandidate {sdpMLineIndex: 1, sdpMid: "video", candidate: "candidate:2114899382 1 udp 1686052607 213.230.83.5… srflx raddr 10.5.123.27 rport 51569 generation 0"}
conversation.client.controller.js:14 GOT ICE CANDIDATE:  RTCIceCandidate {sdpMLineIndex: 1, sdpMid: "video", candidate: "candidate:2114899382 2 udp 1686052607 213.230.83.5… srflx raddr 10.5.123.27 rport 51569 generation 0"}
conversation.client.controller.js:14 GOT ICE CANDIDATE:  null

0 个答案:

没有答案