HACKER Q&A
📣 anovikov

Why WebRTC media servers are NOT built upon webrtc.org source?


WebRTC's "canonical" implementation is by definition the "right" one because it is directly used in the Chromium browser, which means directly or indirectly, most WebRTC users in the world. So if something else interfaces with it poorly, it's their own problem. Yet, no major WebRTC media server - like Janus, Mediasoup, Wowza, ... - uses it, they build their own implementation, usually kind of lame in some way, either buggy or limited in supported protocols and codecs, or both.

Why? I know every "why don't you just..." styled question always has an answer totally exposing ignorance of one's asking, and yet... Why not build a media server which will use www.webrtc.org code to send and receive streams - and libav* for transcoding and other media-related tasks?

Is there some licensing pitfall there?

Just out of curiosity, i have simulated it by running some javascript to shuffle streams, in Chromium on Xvfb, manipulated by a Node script. It works just fine and totally simulates a well-functional media server. In addition, making a video MCU (Achilles' heel of most WebRTC servers), trivial :D. Obviously, hopelessly inefficient in terms of CPU and (especially) memory consumption, since i'm pulling whole browser along, but what if i just take the webrtc part, right in C++?


  👤 Sean-Der Accepted Answer ✓
I created Pion WebRTC so I am biased, but these are my thoughts

* It is dangerous to say libwebrtc is the "right" one. That is the same attitude that created the browser monoculture with IE6. WebRTC is an IETF/W3C standard, as long as you implement everything it shouldn't be a problem. Also calling other implementations buggy/limited isn't the full story. Chrome has made changes in the past that break everyone else (FireFox and WebRTC servers), so it isn't fair to blame everyone else.

* libwebrtc was designed with clients in mind (not servers). This is more of an anecdote, I don't work with libwebrtc but this is what I have heard from other developers. It spins up a lot of threads, and does a lot of things that SFUs/MCUs don't care to deal with.

* libwebrtc is very hard to compile/work with. See [0]

* If you are on outsider it is hard to land your changes. In 2015 I attempted to get involved, but was unable to get anyone interested in my changes. This wasn't out of spite though, libwebrtc needs to serve the business interests of the people who fund it. But if you are a small SFU developer, you are going to have a hard time getting your changes upstreamed. Also if your changes put official projects in danger that use libwebrtc it will never happen.

libwebrtc isn't the hard part with making an MCU. When I did this the hardest part is doing all the compositing (and all the resizing/modifications that Chromium is getting you). It is probably possible with libav, but much easier with GStreamer. There is a user that does it now with Pion + GStreamer. This could be a lot easier (and would be a great Open Source project!). If you are interested would love to hack on it with you.

[0] https://www.cosmosoftware.io/blog/libwebrtc-is-open-source-h...