2.11.2 被呼叫者流程 The following is a summary of the callee‘s flow, which is very similar in a lot of ways to the caller‘s flow, except that it responds to the offer with an answer: 下面是被呼叫都的流程总结,除了提供一个应答响应外,它和呼叫者的流程很相似: . 注册 onicecandidate 句柄 . 注册 onaddstream 句柄 . 注册 消息句柄 . 使用 getUserMedia 访问本地摄像头 . JSEP offer/answer 处理
1. 注册 onicecandidate 句柄 Just like the caller, you start by registering an onicecandidate handler that sends any ICE candidates to the other peer as they are received, using one of the signaling channels described previously.
2. 注册 onaddstream 句柄 Then, like the caller, you register an onaddstream handler that displays the video stream once it is received from the remote peer.
3. 注册 消息句柄 Like the caller, your signaling channel should also have a handler registered that responds to messages received from the other peer. If the message contains an RTCIceCandidate object, it should add those to the peerconnection object using the addIceCandidate() method. And if the message contains an RTCSessionDescription object, it should add those to the peerconnection object using the setRemoteDescription() method.
4. 使用 getUserMedia 访问本地摄像头 Then, like the caller, you can utilize getUserMedia() to set up your local media stream and display that on your local page, and also add it to the peerconnection object using the addStream() method.
5. JSEP offer/answer 处理 Here you differ from the caller and you play your part in the negotiation by passing remoteDescription to the createAnswer() method and registering a callback handler that receives an RTCSessionDescription object. This callback handler should then add this RTCSessionDescription to your peerconnection object using setLocalDescription(). And then finally, it should also send this RTCSessionDescription to the remote peer through your signaling channel. It is also important to note that this callee flow is all initiated after the offer is received from the caller.