WebRTC for Streaming Applications

WebRTC for Streaming Applications

Neverinstall Team
Neverinstall Team

Our previous article Understanding WebRTC gave a high-level overview of what WebRTC is, its primary use cases, and why it's become such a favorite for online audio-video communication.

This time, we'll go a little deeper into the WebRTC protocol – why it works, why it's such a beloved choice, and what lies in its future.

A quick recap: What is WebRTC?

Built as an alternative to proprietary technology, WebRTC is an open-source standard for web-based, real-time communication. It supports browser-to-browser interaction and peer-to-peer live streaming via specific, standardized protocols. Thanks to WebRTC, internet users can now immediately launch video calls with a single click from their browsers – calls run with data fast enough to offer face-to-face online interaction.

While initial adoption was slow, WebRTC has now become a synonym for digital video communication. Most major browsers, Chrome, Firefox, Opera, Safari, and Microsoft Edge, support WebRTC, as do the mobile platforms Android and iOS. Of course, Microsoft and Apple came on board the WebRTC train much later, with Chrome being the earliest adopter (no big surprise here).

WebRTC’s most significant advantage is that it merges an open-source, community-driven technology with wide-range platform support and serious backing by Google. It's also been validated and adopted by the World Wide Web Consortium (W3C) and Internet Engineering Task Force (IETF).

As things stand today, WebRTC is poised to evolve, expand and align with new, future-forward use cases like IoT (Internet of Things) endpoints and live processing of audio/video feeds.

The capabilities of WebRTC

From a purely technical lens, here’s what WebRTC is capable of:

  • Streaming video from a desktop app to a remote browser. When built with WebRTC, such an app can send anything from video files to live streams, as long as it is a web camera and/or the required input devices.
  • Receiving video or audio from a remote browser (the recipient is the application).
  • Exchanging and transmitting data streams and messages between two native applications.

How WebRTC works for application streaming

WebRTC eliminates any need for additional web servers, software integration, or hardware support. Unlike the now obsolete Adobe Flash Player (once the default technology for this purpose), WebRTC streams work on any HTML5 video player. With Flash Player, you could only play videos on players with proprietary software.

If you’ve attended any online meetings in virtual meeting rooms that you joined by clicking on a URL (Google Meet, for example), you have seen WebRTC in action.

WebRTC uses HTML5 APIs to capture, encode and transmit video streaming. Most no-frills WebRTC use cases (like launching video calls from your browser) require just a webcam and said browser. If you want to stream workflows or share your screen, you’ll need an IP camera, an encoder, and streaming tech.

WebRTC supports audio codecs such as iSAC, Opus, and iLBC. Similarly, it supports video codecs H.264, VP8, and VP9. Streaming leverages the User Datagram Protocol – a commonly used protocol that facilitates low-latency communication and accelerates data transmission. It does so by sending data without the TCP handshake required to establish a connection, which cuts down on time otherwise required to establish the said connection. It also doesn't bother with a "guarantee” of delivering all data packets.

This isn't as alarming as it sounds. A few dropped data packets don't usually result in video disconnection – you get slightly lower video quality at most. This is almost always better than the long delay other protocols experience when trying to re-send undelivered data.

WebRTC Pros

  • Inherently low latency, especially compared to alternative protocols like RTMP and HLS.
  • Enjoys broad support across mainstream browsers and platforms. It makes it easy to integrate with almost any application without lugging in excess infra/setup effort.
  • Device-independent. WebRTC uses in-built HTML5 components, which keeps it browser-based and highly accessible.
  • The wide browser and platform support ensures very few compatibility issues when integrating WebRTC with existing tech stacks. This is the direct opposite of proprietary software.
  • Open source is almost always much easier for developers to work with.
  • WebRTC is constantly being refined and debugged by a massive open-source community. This keeps it perpetually evolved, you don't have to deal with anomalies or incompatibilities that show up when software is not updated.
  • Thanks to simulcast, WebRTC can automatically adjust video streams to poor conditions. This is not the same as adaptive bitrate streaming (an HLS staple). Simulcast adjusts the stream on the publisher's side by generating multiple encoded packets of a single stream so that the one matching the viewer's network connection can be automatically sent out.

WebRTC Cons

In the interest of full disclosure, we should highlight the issues engineers might face when working with WebRTC for their audio-video tech stack. However, it must also be mentioned that most of these cons can be easily overcome.

  • Since WebRTC configurations consume significant bandwidth, WebRTC poses some restrictions on scalability. High bandwidth consumption comes from each participant establishing a browser-based peer-to-peer connection for real-time media processing.

Let’s say you’re streaming a low-res video that needs 500kbps to 10 viewers. That’s a total of 5mbps uplink speed. As more viewers join in the stream, bandwidth requirements go up since the video has to be streamed to more peers. Given that it’s rare for everyone in a call to have the same pristine network conditions, one or more participants might end up with a dropped call or a heavily degraded stream due to their network muscle.

Generally, WebRTC works great for calls with up to 50 peer connections. To scale up further, you’ll have to bring a media server into the mix. At this point, WebRTC will require the same infra as other streaming protocols.

  • As the previous point should indicate, WebRTC streams can have questionable broadcast quality in certain situations. WebRTC work on top of each peer’s network connectivity and the quality of their input devices. Naturally, the state of these external factors has a direct effect on the stream.

WebRTC uses UDP to deliver video, and this method doesn’t guarantee video delivery – it drops B-frames to compress the video and data packets. While this facilitates low latency and instant, uninterrupted streams, it can adversely affect the stream quality (if too many frames and packets are dropped to manage low network conditions).

WebRTC Security

In a world suffering the perpetual data of digital data theft and unauthorized access, security is a key concern for every single technical and/or business stakeholder.

There aren’t too many questions that have been raised on WebRTC’s security. It uses SRTP (Secure Real Time Protocol) encryption and numerous other security standards. It is encrypted at the protocol level and utilizes browser and community security mechanisms.

Fortunately, since it has wide browser support, WebRTC is secured meticulously by the browsers themselves – Firefox, Chrome, Safari, and Edge – all of which use HTTPS to access the protocol and its functions as well auxiliary protections against IP leakage, user permissions for camera and mic access and guardrails for privacy.

Additionally, WebRTC’s open-source nature ensures that developers and cybersecurity experts keep calibrating it to meet the industry-best security standards.

WebRTC – The future of video communication?

The global WebRTC market is estimated to hit around $21 million by 2025. This is unsurprising since the applications of WebRTC are nearly infinite, especially in this digital-first world.

Since the pandemic, it has become our sector to click a link to join a work meeting, a live event, or a catch-up with friends. A significant portion of our online interaction (and human interaction) is generalized and normalized through video calls. WebRTC has made this possible by facilitating said interaction from any browser, device, and location.

Obviously, there’s much scope for improvement – enhancing screen sharing, enabling 4k+ video on calls, multi-channel audio, etc. But every niche of every industry now has the space to accommodate WebRTC-powered video communication – EdTech and telehealth being common examples that come to mind. Anyone who requires nearly instant video/audio exchange between individuals or groups can leverage WebRTC to create pristine video power applications.

As with technology, software engineers and organizations continue to expand on WebRTC capabilities. For example, think of software that streams volumetric data, depth or point cloud, to facilitate real-time 3D virtual reconstruction similar to the Metaverse. Such software can capture depth data with sensors and play with it to provide state-of-the-art real-time communication.

Wrapping up

WebRTC's potential is unquestionable and only limited by imagination. You’d be hard-pressed to find an industry or professional/personal experience that would not be enhanced with video interaction (in the absence of in-person communication). Video calls have erased geographical limitations more stridently than ever before, and a protocol like WebRTC helps create better video streaming experiences, bringing online encounters closer to reality.

Widely acknowledged as one of the most superior and easily adaptable video protocols, WebRTC is not just the future of video; it is the future of a hyper-connected, eternally available world.

Author: Shreya Bose

Shreya is a seasoned tech writer. Besides technology, she loves writing about healthcare, heavy metal, alcohol, and coffee. When she is not writing, she is reading, drinking tea, and waiting for naptime.