JVB forwarding stream configuration

Hi guys,

So currently we are trying to understand and somehow modify the JVB forwarding algorithm (if possible). From what I’m able to understand, JVB decides which source to forward based on the user’s feedback (both in bandwidth estimation & viewport). May I ask if this is correct and if it’s so, what are the specs for the algorithm (for ex: if the bandwidth estimation under x Mbps, stop forwarding the 720p stream…). Is there a document or maybe the code for the implementation? And if we want to modify some specific specs, where can we do it?

Many thanks in advance & hope to hear from you soon.
Best regards,
Tien

Hi Tien, the algorithm lives in the BitrateController class. There are certain triggers that initiate a “bandwidth distribution decision” (bwd); for example, an endpoint joins the call, or the bandwidth estimation (bwe) changes, etc. The entry point is the BitrateController.update() method.

The algorithm isn’t described anywhere unfortunately but it’s fairly simple: the bridge arranges the participants in a prioritised list and goes over each one of them and tries to allocate some amount of bandwidth.

Let us know if you have further questions to help you better understand the algorithm.

Cheers

Hi @gpolitis,
Thanks for your swift response. I found the BitrateController class and planning to study it this week. But currently, I have some more questions though:

  • How does the BitrateController take lastN in to account? I’m asking this because we want to calculate the bandwidth required for client endpoint according to the lastN setting (or in general tbh).
  • Also, what if we set the lastN to unlimited? Does JVB (in this case BitrateController) control the user receiving sources?
    • For example, a conference has 10 members, lastN is set to -1. User A has limited bandwidth & tries to retrieve other member video sources. How does the JVB algorithm work in this case? Will JVB forward as many the video sources as possible to cope with A’s bandwidth & shut off some of the inactive users (according to the prioritized list) to save bandwidth? If I’m correct, does JVB prioritize the number of video sources more than the source quality? And can this be modified by changing the BitrateController code?
    • Let say, in this case, we want to limit the amount of video sources first (even though lastN is -1) to ensure the video quality. Instead of getting many poor quality video sources, I want to modify JVB so that it forwards the best quality of the source first then take the number of sources in to account later if that makes sense (in some way this would mean dynamically change the lastN value).

Thank you & hope to hear from you soon,
Tien

Hi @tiennguyen,

If you’re talking about the channelLastN property in config.js, then this value finds its way into the BitrateController.lastN field. The semantics of this field is the maximum number of endpoints that the bridge will ever consider forwarding towards a specific receiver. If the bandwidth estimation is low, then the number of forwarded endpoints will be smaller (this is what we call dynamic LastN).

As for your 2b question, concretely, you can have a look at the TrackBitrateAllocation.improve method; there you can allocate as much bandwidth as possible for the on-stage participant at the first step. I’m talking about steps here because the bwd algorithm is an iterative improvement process: in the first step each track is given the opportunity to improve i.e. forward a better quality or encoding (with the legacy simulcast implementation in Chrome, you have 9 encodings or qualities, 3 simulcast streams for spatial adaptivity with 3 temporal layers each), within the specific constraints that are passed as an argument. Same thing happens in the second step, and so on and so forth, until there’s no further improvement possible for any of the tracks that are considered for forwarding. No further improvement possible here means that the bridge either sends max quality or that there’s not enough available bandwidth for a next improvement step.

I hope this illuminates things a bit further. Please let us know if you have any further questions, we’re happy to answer!