Proof of concept of an open and standardized WebRTC based streaming
In this blog post we will describe a proof of concept that we are working on with the aim to find an open and standardized way of using WebRTC for real-time low-latency streaming. This is our contribution to the technical work in the context of standardizing WebRTC-based streaming, and all source code related to this proof of concept are made available as open source.
There are a number of use cases that are made possible by integrating WebRTC streaming. A report developed by DASH-IF describes some of the use cases and the technical considerations that needs to be taken into account . Use cases that ranges from interactive live concerts / music events to, in-stadium interactivity and lower latency broadcasting.
WebRTC is a set of standards and support for WebRTC is today included in all modern browsers, and even some more modern Smart TVs. Original focus of WebRTC was around video conferencing but its ultra-low latency features (demanded by two-way communication) is an attractive feature in real-time streaming. Reducing the glass-to-glass latency is one of the most discussed topics in the streaming industry. But adopting and integrating WebRTC in the streaming industry has been a slow process and the lack of standards on how to integrate WebRTC in this context we believe has contributed to that slow pace.
There are two main areas that needs to be standardized as a start: ingest and playback. When we started this proof of concept we decided to reduce the scope to cover these two fundamental areas. On the ingest side there is already an initiative to standardize ingesting of media into a streaming service or CDN using WebRTC called WHIP (WebRTC-HTTP Ingestion Protocol ). A draft standard that was published in October 2021 and written by S. Murillo and A. Gouaillard from CoSMo Software.
We found that a relevant use case that would cover these two areas was to develop a simple web-based application that allows you to instantly start a broadcast from either your computer or mobile just using the in-built browser. When the broadcast is live you will get a link to another web page that you can share with your viewers. As for the sender / broadcaster a viewer would not need any additional application installed to watch the broadcast, and should only need to open the provided link in a web browser. A perfect use case that also demonstrates the benefit of using WebRTC as all modern browsers have in-built support for it.
Next thing to tackle was the playback of this channel. At the time of writing this post and this project it did not yet exist a standard for consuming and playing a channel using WebRTC. Here we had to take a bit of a different approach due to this fact. We developed a player library for WebRTC playback  that was designed to be media server independent. We achieved this by designing the player using media server adapters.
The adapter is responsible for the SDP exchange (offer/answer) while the other commonalities are handled outside of the adapter and in the player. The player attach the WebRTC stream to an HTML video element but does not render any type of skin or controls. That was intentionally left outside of the scope of this library. We started by implementing an adapter that worked with our media server that we developed for this prototype. The SDP exchange in this case is inspired by WHIP as it uses HTTP as the transport protocol with a resource based API design. A channel resource is located with a URL and the media server adapter issues an HTTP POST with an application/json payload including the SDP offer. The reason for using JSON was in case we wanted to extend it with other data than just the SDP. In response the adapter receives the SDP answer from the media server.
Then we added this WebRTC player library into our Eyevinn Web Player . The Eyevinn Web Player is a modular player framework that incorporates other player libraries such as HLS.js, Shaka Player and DASH.js for supporting playback of the most common HTTP streaming protocols. Adding the WebRTC support by using the WebRTC player library was a breeze and we could utilize the skin and controls already available in the Web Player.
We now have a player that is not bound to a specific media server however how do we signal what adapter the player should be using? The way we solved this, and hope this could be an inspiration to the standardization work that is ongoing around DASH and WebRTC, was to extend an MPEG-DASH manifest a small bit. Our media server can return an MPEG-DASH manifest for a channel, for example:
would return this MPEG-DASH:
An MPEG-DASH manifest that contains a single period with an xlink:href and the channel resource locator. For the WebRTC player to understand which adapter to use we added an xlink:rel attribute describing what type of resource it points to. We could then parse this manifest and know which adapter to use in the player.
With this prototype we have a proof-of-concept where a browser based WebRTC ingest application can ingest to any type of WHIP compatible media server and a way to signal to a media server independent WebRTC player what adapter to use. Everything is open source and you are welcome to use it in the standardization efforts around WebRTC and playback. The end goal is to not have to have media server specific adapters and instead one that implements a common standard by all media servers.
If you want to try it out the prototype is available online at https://webcast.eyevinn.technology/
Contributors to this project so far are Jonas Birmé, Benjamin Wallberg and Marcus Spangenberg, all from Eyevinn Technology AB.
If you want to know more about this prototype and proof-of-concept you can contact Jonas Birmé, VP R&D Eyevinn Technology.
Related developer blogs:
Links in this article: