Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.x] [audiobridge] jitter buffer: manually update internal delay and set a max size #3353

Merged
merged 4 commits into from
Apr 8, 2024

Conversation

atoppi
Copy link
Member

@atoppi atoppi commented Apr 5, 2024

Context
We observed that speex jitter buffer suffered from a "stuck" delay evaluation in very difficult network scenarios.
When network delay/jitter have huge oscillations and then go back to a stable state, the buffer might potentially end up in a status where it's unable to update its internal delay anymore.
The effect is that even in optimal conditions, the buffer will add a de-jittering delay. This can be tested by conditioning the network link and observing the buffer-in value through the Admin API. The expected result is a low buffer-in when network conditions are restored.
As a consequence, we implemented a workaround in the audiobridge some time ago that once in a while checked the buffer length did not exceed a JITTER_BUFFER_MAX_PACKETS length. If that happened, we requested a jitter buffer reset.

Findings
We discovered that this behavior could be triggered by frequent calls to jitter_buffer_delay_update under high network variance. That function basically recalculates the buffer internal delay.
By default the buffer is auto-adjusting and the delay is updated anytime a jitter_buffer_tick is invoked. We issue a buffer tick any time a participant audio packet must be added to the mix, so every ~20ms we indirectly update the jitter internal delay. By collecting examples of how the library is used, we found out that many implementations switched to manual updates through condition-related jitter_buffer_delay_update calls.

The PR
This patch is twofold:

  1. in speex library code: add an interface to set an internal max length in place of the hard-coded 200.
  2. in audiobridge code: it sets buffer max size to JITTER_BUFFER_MAX_PACKETS, disables automatic buffer delay adjusting and performs a jitter_buffer_delay_update every JITTER_BUFFER_MAX_PACKETS ticks.

With these changes we are unable to reproduce the issue but given its nature and the difficult steps for reproducing it, we'd like to collect some feedback from people interested in improving the audiobridge experience.

@atoppi atoppi changed the title Ab buffer set max 0x [0.x] [audiobridge] Set a jitter buffer max size Apr 5, 2024
@atoppi atoppi changed the title [0.x] [audiobridge] Set a jitter buffer max size [0.x] [audiobridge] jitter buffer: manually update internal delay and set a max size Apr 8, 2024
@atoppi atoppi merged commit 7809ba3 into 0.x Apr 8, 2024
atoppi added a commit that referenced this pull request Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant