Implement a Video Conference with WebRTC
Sudeep Kumar
SaaS Product Leader with expertise in Video Streaming, OTT, and Digital Transformation Product | Video Streaming | OTT | CDN | Transcoding | Video Analytics | Monetization | Video Surveillance
WebRTC introduction
WebRTC (Web Real Time Communication) is an open source project that enables peer-to-peer communication between browsers. In other words, WebRTC allows you to exchange any kind of media through the web (such as video, audio and data) without any required plugin or framework. WebRTC allows users to initiate click-to-start video chats from their browsers and exchange information quickly enough to replicate in-person interactions.?This supports interactive live streaming between individuals, as well as browser-to-browser communication through a set of standard protocols. WebRTC is referred to as peer-to-peer technology, whereby each browser communicates directly with one another. ?Currently following available standard Streaming protocols are there.
Direct communication between browsers improves performance and reduces latency times since clients don’t need to keep sending and receiving messages through a server. For instance, we could use?WebSockets?to connect two clients but a server would have to route their messages as in the next diagram:
By contrast, WebRTC only needs a server to establish and control clients’ connections. This process is known as?signalling. Once the browsers have collected the required information of the peers, they can communicate with each other:
WebRTC doesn’t specify the signalling messaging protocol so the chosen implementation has to be based on the application requirements, some of the most common approaches are: WebSockets, SIP, XHR, XMPP, etc.
The signalling process works as follows:
领英推荐
So how does Interactive Connectivity Establishment work? ICE is a peer-to-peer network communication method to send and receive media information over the Internet. How routing is made (NATs, firewalls …) is out of the scope of this article but it’s something that WebRTC needs to deal with. ICE gathers available network connections, known as?ICE candidates, and uses protocols?STUN?(Session Traversal Utilities for NAT) and?TURN?(Traversal Using Relays around NAT) for NAT and firewall traversal.
This is how ICE handles the connection:
As you can see, ICE tries to use STUN servers first but TURN relay servers will be needed for very restrictive corporate networks. TURN relay servers are expensive, you will need to pay for your own ones or use a service provider, however, most of the time ICE will be able to connect peers with STUN. The following schema shows a STUN/TURN communication:
To summarise, the signalling process is used to exchange media information with SDP files and ICE is used to exchange the network connection of the peers. After the communication has been set up, peers can finally exchange data directly through their browsers.
Regarding security, WebRTC includes some mandatory features to cope with different risks:
How to achieve scale with WebRTC
A live streaming server?like AMS/ Red5 or?cloud-based service?can be used to?transcode?the WebRTC stream into a protocol like?HLS?for distribution to thousands. That way, content distributors can combine simple, browser-based publishing with large-scale broadcasting — albeit at a higher latency. When easy content acquisition (and not real-time delivery) is the key reason for incorporating WebRTC into your streaming workflow, then this solution is the way to go.
CEO & Founder
3 年A very informative and well laid out document.. please keep writing more ??