1
votes

Below i have given the excerpt from this link about RTCPeerConnection.onicecandidate and wish to ask two question on the best of my understanding and need help if i got the concept correct or not . its bit complicated for me

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.

My interpretation with reference to below code

1.Does this means that RTCPeerconnection.onicecandidate automatically call the below Anonymous javascript function when it gets its Local Icecandidate with helps of ICE. And at the same time Anonymous function help to deliver a Ice candidate to remote Peer through signal SERVER.

2.With reference to below code : Does parameter event from event handler RTCPeerconnection.onicecandidate contain details about SDP info such as media type and codec and method candidate gives information from Ice candidate (ie ip address and port number). which further combine into sdp and passed to remote peer.

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

2 Answers

1
votes

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

Yes. As per rtcpeerconnection-onicecandidate:

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

Thus, the handler gets called automatically when a new Ice Candidate is available.

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

No SDP info. Just candidate and url.

As per rtcpeerconnectioniceevent, it is a RTCPeerConnectionIceEvent:

interface RTCPeerConnectionIceEvent : Event {
    readonly attribute RTCIceCandidate? candidate;
    readonly attribute DOMString?       url;
};
0
votes
  1. RTCPeerconnection.onicecandidate will be called when a new candidate reached. The EventHandler will get a event parameter, which contain the infomation of candidate. You need to send the parameter to your signal server by yourself.

2.The parameter of RTCPeerconnection.onicecandidate do not contain any details of SDP. Only contains IP information. As following:

candidate:"candidate:2944045467 1 udp 2122260223 172.25.34.14 58967 typ host generation 0 ufrag K3mY network-id 1"
component:1
foundation:"2944045467"
generation:"0"
ip:"172.25.34.14"
network-id:"1"
port:58967
priority:2122260223
protocol:"udp"
sdpMLineIndex:0
sdpMid:"audio"
toJSON:ƒ()
type:"host"
ufrag:"K3mY"
usernameFragment:"K3mY"