RTCPeerConnection API
The RTCPeerConnection API is the heart of the peer-to-peer connection between each of the WebRTC enabled browsers or peers. To create an RTCPeerConnection object, you use the var peerconnection = RTCPeerConnection(configuration);
constructor. The configuration
variable contains at least one key named iceServers
, which is an array of URL objects that contain information about STUN, and possibly TURN servers, used during the finding candidates phase.
The peerconnection
object is then used in slightly different ways on each client, depending upon whether you are the caller or the callee.
The caller's flow
Here's a summary of the caller's flow after the peerconnection
object is created:
Register the
onicecandidate
handlerRegister the
onaddstream
handlerRegister the
message
handlerUse getUserMedia to access the local camera
The JSEP offer/answer process
Register the onicecandidate handler
First, you register an onicecandidate
handler that sends any ICE candidates to the other peer...