meetecho / janus-gateway

Janus WebRTC Server
https://janus.conf.meetecho.com
GNU General Public License v3.0
8.17k stars 2.47k forks source link

Use speexdsp's jitter buffer in the AudioBridge #3214

Closed lminiero closed 1 year ago

lminiero commented 1 year ago

The audio buffer in the AudioBridge has historically been a bit of its Achilles heel: while it worked fine in most situations, it definitely struggled more with problematic connections (e.g., high jitter or packet loss), which often resulted in broken or spotty audio for specific participants that could only be solved by having them reconnect (until the problem happened again).

This PR tries to fix this by using a proper jitter buffer, specifically the one made available as part of the Speex DSP library. In our tests in different circumstances where we could replicate problems before it seems to perform much better, so we thought we'd make this available as a PR so that you can test it before we merge. As a result of this change, we refactored a bit of related code too, which means that for instance the prebuffer property you used before is gone from configuration and API: in fact, that was only meaningful to our own old buffer, and doesn't make much sense using this new jitter buffer instead.

If you use the AudioBridge for anything in your application, you most definitely want to test this. Notice that this will be a breaking change for many: in fact, the fact we now rely on Speex DSP for its jitter buffer also means that the AudioBridge will not compile unless the library is available when rebuilding Janus. In most deployments currently relying on the AudioBridge this may not be the case, meaning they'd get stuck with an older version of the plugin. As such, make sure you install the library before compiling this PR, or when updating Janus after it's merged.

Also notice this PR is for the 0.x branch: when it will come the time to merge this, I'll port all the same changes to master as well.

Looking forward to your feedback!

lminiero commented 1 year ago

Pinging @tmatth explicitly since he seems to be an active contributor to speexdsp, and so may point out things we might be doing incredibly wrong :hand_over_mouth:

lminiero commented 1 year ago

Just some questions but LGTM.

Thanks for the review!

lminiero commented 1 year ago

Merging.