WebRTC allows peer-to-peer communication between two browsers in a simple and easy manner without needing to install any plugins or extra software.
Real-time communication for the web with WebRTC, you can add real-time communication capabilities to your application that works on top of an open standard. It supports video, voice, and generic data to be sent between peers, allowing developers to build powerful voice- and video-communication solutions. The technology is available on all modern browsers as well as on native clients for all major platforms
What can WebRTC do?
There are many different use-cases for WebRTC, from basic web apps that uses the camera or microphone, to more advanced video-calling applications and screen sharing. We have gathered a number of code samples to better illustrate how the technology works and what you can use it for.
WebRTC components and audiences:
WebRTC has the following functional components:
Media capture: WebRTC media capture API allows access to the camera and microphone of the end-user devices after their consent.
Audio and Video encoding and decoding: The Audio and Video data is broken into smaller chunks for transport and exchange between the peer endpoints involved using encoding and decoding component called a codec.
Transport: The transport layer functions involve ordering the packets, dealing with the packet loss, and setting up the connection between the peers
Session management: This stage involves the management of connection between the peers (RTCPeerConnection) through information exchange and protocol negotiation though a process called signaling. With the AV streams transferred on this connection, data can also be exchanged between the peers through RTC Data Channel.
The WebRTC API caters to the following audiences:
- WebRTC client application developers
- Browser vendors
- Overridable API for browser vendors
Developer API:
The Developer API deals with the following elements provided by all browsers that support WebRTC:
RTC Peer Connection encapsulates the functions for peer connection negotiation, connection lifecycle and media stream attachments.
Media Stream API allows access to the video and audio streams objects, selection of sources, and security enforcement through consent of the user.
RTC Data Channel provides a channel for data exchange using the peer connection.
The key concept for WebRTC is traversal of the network address translation (NAT) path. Setting up RTCPeerConnection involves of information and protocol negotiation between the peers before the network packets can traverse the NAT path. Depending on the security level of the NAT infrastructure involved at the peer endpoints, you might need a proxy between the peers to establish a connection.
NAT maintains a table of entries to enable translation of transport addresses between the NAT device’s external and internal interfaces. An entry is created in the NAT table when the first outbound packet arrives at the routing device, which becomes the traversal rule for any subsequent inbound packets.
Signaling: Setting up RTCPeerConnection involves signaling and connection negotiation to establish a direct peer-to-peer connection between browsers as the result.
The following diagram captures how different tools and components fit into WebRTC implementations:
The first step to finding a clear route is for each peer to find its own IP address, aided by a STUN protocol enabled server. After receiving a STUN request, the STUN server responds with a public facing IP address of the requestor. If the requestor is sitting behind a router and has a private IP, the router creates a NAT record and translates the private IP to the public IP, which is visible to the STUN server, and it returns the address it sees, as a response to the STUN request.
RTC Data Channel:
RTCDataChannel uses stream control transmission protocol (SCTP) for data exchange over an existing RTCPeerConnection. SCTP is built on top of DTLS to allow data blob transfer using RTCDataChannel on the same RTCPeerConnection established between the peers.
SCTP provides similar reliability as TCP but is more efficient than TCP and allows multiple streams to the sent simultaneously. RTC Data Channel provides an alternate channel for data transfer that can be customized as needed for traditional TCP-based data transfer mechanisms. SCTP uses multiple endpoints and connections between two IP addresses and by breaking down a message into multiple chunks that can be sent on those connections and reassembled at the receiving endpoint.
Oracle Cloud Infrastructure: Oracle Cloud Infrastructure is a platform of cloud services that enable you to build and run a wide range of applications in a highly-available, consistently high-performance environment. It is the next-generation cloud designed to run any application, faster, and more securely for less money.
Sample WebRTC application: The following is a sample single-page web application using WebRTC to demonstrate a simple video chat using peer-to-peer connection. It illustrates all the component interactions, APIs, signaling, and protocol negotiation process.
The application is served through an HTTPS-enabled webserver to allow access to the web cameras and microphones of the peer devices for AV streams.
Use Cases for WebRTC:
WebRTC includes the following applications
One-way conversational devices: Conversational digital assistants like Amazon Alexa and Amazon Chime, Google Duplex, and Dialog flow.
Internet of Things (IOT): DroneSense, a software platform for drones uses WebRTC for video conferencing
Metaverse: With recent interest in Metaverse, WebRTC is one of the key technologies sure to play a key role in enabling immersive experience.
Click-to-chat video conferencing: Examples include Slack, Google Hangouts, Facebook Messenger and Houseparty.
Emergency response and communication: WebRTC-enabled body cams, video-enabled emergency calls, bomb disposal, and disaster relief robots
Connected fitness and health: Connected fitness equipment and wearables like Mirror, Fitbit, and Peloton.
Live commerce and shoppable video: Jewelry Television (JTV), Facebook Live shopping events, live auctions, and influencer streaming.
Online education: Remote and online learning and tutoring