admin管理员组文章数量:1023885
Below is the sample webrtc peer to peer connection code from google webrtc tutorilal. this link. I couldn't understand properly ,how addIceCandidate() add its Ice candidate to its remote peer using onIceCandidate(). what does event.candidate means here. A clear explanation would be appreciated
function onIceCandidate(pc, event) { //pc1.onicecandidate
if (event.candidate) {
getOtherPc(pc).addIceCandidate(
new RTCIceCandidate(event.candidate)
).then(
function() {
onAddIceCandidateSuccess(pc);
},
function(err) {
onAddIceCandidateError(pc, err);
}
);
Below is the sample webrtc peer to peer connection code from google webrtc tutorilal. this link. I couldn't understand properly ,how addIceCandidate() add its Ice candidate to its remote peer using onIceCandidate(). what does event.candidate means here. A clear explanation would be appreciated
function onIceCandidate(pc, event) { //pc1.onicecandidate
if (event.candidate) {
getOtherPc(pc).addIceCandidate(
new RTCIceCandidate(event.candidate)
).then(
function() {
onAddIceCandidateSuccess(pc);
},
function(err) {
onAddIceCandidateError(pc, err);
}
);
Share
Improve this question
asked May 24, 2018 at 7:29
ambach 66ambach 66
1133 silver badges11 bronze badges
1
- 1 html5rocks./en/tutorials/webrtc/infrastructure explains what an ice candidate is (along with many other concepts needed to understand things) – Philipp Hancke Commented May 24, 2018 at 7:41
1 Answer
Reset to default 7When peer A has discovered an ICE candidate (a potential route which could be used to municate), it needs to send this ICE candidate to peer B (and vice versa). Peer B then adds that ICE candidate to its connection. Both peers exchange ICE candidates this way until they have found the optimal route that both are able to use to municate with each other directly.
In that simple sample, peer A and B seem to be in the same machine, so the (dummy) getOtherPc
function can get a handle of "the other peer" and you can directly use its addIceCandidate
method. In practice however you will have to send that ICE candidate using a signalling server; some other way in which the peer can exchange the information across a network. Typically that signalling server will use a websocket connection via which information can be relayed in near-realtime.
Below is the sample webrtc peer to peer connection code from google webrtc tutorilal. this link. I couldn't understand properly ,how addIceCandidate() add its Ice candidate to its remote peer using onIceCandidate(). what does event.candidate means here. A clear explanation would be appreciated
function onIceCandidate(pc, event) { //pc1.onicecandidate
if (event.candidate) {
getOtherPc(pc).addIceCandidate(
new RTCIceCandidate(event.candidate)
).then(
function() {
onAddIceCandidateSuccess(pc);
},
function(err) {
onAddIceCandidateError(pc, err);
}
);
Below is the sample webrtc peer to peer connection code from google webrtc tutorilal. this link. I couldn't understand properly ,how addIceCandidate() add its Ice candidate to its remote peer using onIceCandidate(). what does event.candidate means here. A clear explanation would be appreciated
function onIceCandidate(pc, event) { //pc1.onicecandidate
if (event.candidate) {
getOtherPc(pc).addIceCandidate(
new RTCIceCandidate(event.candidate)
).then(
function() {
onAddIceCandidateSuccess(pc);
},
function(err) {
onAddIceCandidateError(pc, err);
}
);
Share
Improve this question
asked May 24, 2018 at 7:29
ambach 66ambach 66
1133 silver badges11 bronze badges
1
- 1 html5rocks./en/tutorials/webrtc/infrastructure explains what an ice candidate is (along with many other concepts needed to understand things) – Philipp Hancke Commented May 24, 2018 at 7:41
1 Answer
Reset to default 7When peer A has discovered an ICE candidate (a potential route which could be used to municate), it needs to send this ICE candidate to peer B (and vice versa). Peer B then adds that ICE candidate to its connection. Both peers exchange ICE candidates this way until they have found the optimal route that both are able to use to municate with each other directly.
In that simple sample, peer A and B seem to be in the same machine, so the (dummy) getOtherPc
function can get a handle of "the other peer" and you can directly use its addIceCandidate
method. In practice however you will have to send that ICE candidate using a signalling server; some other way in which the peer can exchange the information across a network. Typically that signalling server will use a websocket connection via which information can be relayed in near-realtime.
本文标签: javascriptWebrtc adding ice candidate to remote peerStack Overflow
版权声明:本文标题:javascript - Webrtc adding ice candidate to remote peer - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745575380a2156986.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论