WebRTC Allows You To Set Up Peer
WebRTC Allows You To Set Up Peer
The first step is to get access to the camera and microphone of the user's device. We detect the
type of devices available, get user permission to access these devices and manage the stream.
Transportation Layer
The transportation layer manages the order of packets, deal with packet loss and connecting to
other users. Again the WebRTC API gives us an easy access to events that tell us when there are
issues with the connection.
Session Management
The session management deals with managing, opening and organizing connections. This is
commonly called signaling. If you transfer audio and video streams to the user it also makes
sense to transfer collateral data. This is done by the RTCDataChannel API.
Engineers from companies like Google, Mozilla, Opera and others have done a great job to bring
this real-time experience to the Web.
Browser Compatibility
The WebRTC standards are one of the fastest evolving on the web, so it doesn't mean that every
browser supports all the same features at the same time. To check whether your browser supports
WebRTC or not, you may visit http://caniuse.com/#feat=rtcpeerconnection. Throughout all the
tutorials, I recommend you to use Chrome for all the examples.
Click the “Allow” button to start streaming your video and audio to the web page. You should
see a video stream of yourself.
Now open the URL you are currently on in a new browser tab and click on “JOIN”. You should
see two video streams − one from your first client and another from the second one.
Advertisements
The WebRTC API
It consists of a few main javascript objects −
RTCPeerConnection
MediaStream
RTCDataChannel
The RTCPeerConnection object
This object is the main entry point to the WebRTC API. It helps us connect to peers, initialize
connections and attach media streams. It also manages a UDP connection with another user.
The main task of the RTCPeerConnection object is to setup and create a peer connection. We can
easily hook keys points of the connection because this object fires a set of events when they
appear. These events give you access to the configuration of our connection −
MediaStream API
Modern browsers give a developer access to the getUserMedia API, also known as
the MediaStream API. There are three key points of functionality −
It gives a developer access to a stream object that represent video and audio streams
It manages the selection of input user devices in case a user has multiple cameras or
microphones on his device
It provides a security level asking user all the time he wants to fetch s stream