webRTC 学习笔记:相关概念,和建立视频通话的流程。
Signal - Middle server
WebRTC establish connection on already communication. We call it **signal channel** or signaling service。
Component
ICE:(交互式连接建立)是WebRTC(以及其他技术)使用的框架,用于将两个对等方彼此连接,而与网络拓扑结构无关(通常用于音频和/或视频聊天)。即使两个对等方可能都使用网络地址转换器(NAT)与各自本地网络上的其他设备共享全局IP地址,该协议也可以使两个对等方之间找到并建立连接。
- ICE candidates: details the available methods the peer is able to communicate (directly or through a TURN server)
- STUN/TURN:a protocol over NAT
Video Call Process
Description
The caller captures local Media via
navigator.mediaDevices.getUserMedia()
The caller creates
RTCPeerConnection
and calledRTCPeerConnection.addTrack()
(SinceaddStream
is deprecating)The caller calls
RTCPeerConnection.createOffer()
to create an offer.The caller calls
RTCPeerConnection.setLocalDescription()
to set that offer as the local description (that is, the description of the local end of the connection).After setLocalDescription(), the caller asks STUN servers to generate the ice candidates
The caller uses the signaling server to transmit the offer to the intended receiver of the call.
The recipient receives the offer and calls
RTCPeerConnection.setRemoteDescription()
to record it as the remote description (the description of the other end of the connection).The recipient does any setup it needs to do for its end of the call: capture its local media, and attach each media tracks into the peer connection via
RTCPeerConnection.addTrack()
<br />
The recipient then creates an answer by calling
RTCPeerConnection.createAnswer()
.The recipient calls
RTCPeerConnection.setLocalDescription()
, passing in the created answer, to set the answer as its local description. The recipient now knows the configuration of both ends of the connection.The recipient uses the signaling server to send the answer to the caller.
The caller receives the answer.
The caller calls
RTCPeerConnection.setRemoteDescription()
to set the answer as the remote description for its end of the call. It now knows the configuration of both peers. Media begins to flow as configured.
Process Picture
Guide
视频通话聊天室:A example display how to create a room which could chat and video call.