What is WebRTC: A Comprehensive Guide to Real-Time Communication on the Web

Tencent RTC-Dev Team
Jan 9, 2024

When engaging in audio and video calls, screen sharing, or real-time data transfer through your web browser, you may not often ponder the underlying technology. However, one of the core driving forces behind these functionalities is WebRTC. Announced by Google in 2011, this open-source project now has developed a highly comprehensive and continuously expanding ecosystem.

With just a bit of coding knowledge, anyone can now create sophisticated applications for communication, collaboration, and data-rich experiences in hours or days. WebRTC is changing the tech landscape, empowering aspiring developers and creators.

Unveiling the Core of WebRTC

WebRTC is an open-source project that empowers real-time communication directly within web browsers. It eliminates the need for additional plugins or downloads, providing a seamless experience for users. The project offers a set of APIs and protocols that create direct peer-to-peer(P2P) communication to allow secure audio and video communication and data sharing between browsers.

We can break it down into 3 points:

  • It's a technology that offers low-latency, high-quality real-time audio and video communication.
  • It's a comprehensive client-side multimedia framework with audio and video processing capabilities, designed for cross-platform compatibility.
  • It's a standardized set of APIs (part of the W3C recommendation), allowing web developers to create diverse real-time audio and video applications.

WebRTC enjoys support from all major web browsers (Google Chrome, Mozilla Firefox, Safari), making it a universal solution for real-time communication.

How does WebRTC work?

WebRTC offers a user-friendly JavaScript API layer that can be utilized within web browsers. This significantly simplifies the development and integration of real-time communication features across various applications. While WebRTC's core implementation primarily relies on C/C++, most developers using WebRTC won't have to delve deeply into these lower-level details to create their applications.

The WebRTC architecture is characterized by a layered and modular structure.

The Web APP layer utilize the standard Web API interfaces provided by WebRTC for real-time audio and video communication. It is applications developed by developers based on the WebRTC technology specification. Strictly speaking, this doesn't fall under the architecture of WebRTC itself.

The WebRTC Native C++ API layer is provided by WebRTC for application layer developers. At this level, developers don't need to delve into intricate underlying technical details. They only need to have a general understanding of WebRTC's workflow and principles to utilize its APIs for implementing peer-to-peer communication features. 

The top layer of the WebRTC core comprises the Transport / Session layer, responsible for managing logic related to audio and video data transmission and processing. It involves various protocols, such as SDP (Session Description Protocol) for signaling servers, mainly used for signaling exchange and managing the connection state of RTCPeerConnection.

The essential components of WebRTC include the video engine, audio engine, and transport module. They have the responsibility of collecting and recording data from devices in video, audio, and text formats. These three modules work together to enable real-time communication and data transfer within the WebRTC framework.

At the bottom layer is the hardware adaptation layer related to hardware components, including audio capture and rendering, video capture, network I/O, and more. This layer can be customized to provide the foundation for cross-platform support in WebRTC.

WebRTC Use Cases

WebRTC has a wide range of applications in domains that require real-time communication. Some key use cases include: 

  1. Unified communications

WebRTC empowers real-time video chats and meetings, eliminating the need for dedicated conferencing software. Multiple participants can engage in conference calls, exchange video and audio streams, collaborate on documents, and engage in interactive communication directly from their web browsers. 

  1. Live Streaming and Broadcasting

In the field of real-time audio and video, WebRTC achieves outstanding low-latency and robust performance in weak network conditions through the use of the RTP/RTCP protocols and excellent congestion control algorithms. It's an excellent choice for live streaming and broadcasting applications. Content creators can stream video and audio directly from their browsers to a broad audience, facilitating real-time interactions and immersive experiences.

  1. Cloud Gaming

Cloud gaming involves hosting all game-related computations, including rendering, on remote cloud servers. These computations are then transmitted to the user's device for display via audio and video streaming. Users have minimal hardware requirements on their local devices, and they can instantly experience the game without the need for downloads. 

What are the pros and cons of WebRTC?

The advantages of WebRTC are quite obvious:

  1. WebRTC is an open-source project, and it's both free and readily available for both commercial and private applications.
  2. You'll find WebRTC support in all modern web browsers, facilitating the creation of new use cases and business models. It extends beyond web browsers and is also accessible for mobile applications, boasting a portable source code already employed in numerous mobile APPs.
  3. WebRTC's versatility is impressive, allowing you to develop group calling services, incorporate recording features, or use it solely for data transmission. Your application possibilities are virtually limitless. 

So, are there any disadvantages? Unfortunately, it has its limitations.

Although WebRTC was originally designed for low-latency peer-to-peer (P2P) communication, but it faces challenges when applied to live streaming scenarios:

  1. Complex Signaling Process

Standard WebRTC signaling involves SDP (Session Description Protocol) exchange, ICE (Interactive Connectivity Establishment) interaction, and DTLS (Datagram Transport Layer Security) handshake before media data transmission can begin. This results in significant delays, especially in meeting the real-time requirements of live streaming. 

  1. Inadequate Retransmission Strategy

WebRTC's retransmission strategy is primarily designed for peer-to-peer calls and conferences, making it less suitable for one-to-many live streaming scenarios. In communication scenarios, aggressive retransmission ensures low latency, but in high-bitrate, high-quality live streaming, this approach leads to significant bandwidth wastage.

  1. Inflexible Bitrate Adjustment

Native WebRTC adjusts encoding and packet transmission rates based on bandwidth capacity. However, in large-scale live streaming with multiple downstream users sharing the same upstream stream from the broadcaster, individual users cannot provide feedback to adjust the broadcaster's encoding. This necessitates the development of alternative solutions.

Optimizing WebRTC performance: Tencent RTC (Real-Time Communication)

Tencent Real-Time Communication (Tencent RTC) offers solutions for group audio/video calls and low-latency interactive live streaming. With Tencent RTC, you can quickly develop cost-effective, low-latency, and high-quality interactive audio/video services.

  • Group audio/video call

Built on Tencent Cloud’s Direct Connect network, this solution allows global connection and offers client SDKs and cloud-based APIs for both mobile and desktop platforms. Users can also easily access Tencent RTC services on webpages.

  • Low-latency interactive live streaming

This solution leverages Tencent Cloud's industry-leading network and audio/video technologies as well as high-quality node resources to help you build interactive live streaming services with minimal lag and latency below 1 second, taking live streaming into the era of CDN 2.0. 

With SDKs for mini programs, web, Android, iOS, Electron, Windows, macOS, and other platforms, you can quickly integrate Tencent RTC services into your projects and connect to the Tencent RTC backend. You can also combine Tencent RTC with other Tencent Cloud products such as Instant Messaging (IM), Cloud Streaming Services (CSS), and Video on Demand (VOD) to explore more use cases. Explore more about our products on the official website Tencent RTC.

If you have any questions or need assistance, our support team is always ready to help. Please feel free to Contact Us or join us in Discord .