Add JSEP flag to invert processing order of rid in SDP #2385
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I described in detail the way simulcast works in Janus in this blog post, last year, so I won't spend too many words on that. One thing worth mentioning, though, is that when
rid
is used, Janus expects a specific order: high substream first, then medium, and finally low. This means that the encoding object should be initialized like this:which would result in an SDP containing something like this:
This assumption on the order is required, because otherwise Janus has no clue on what will constitute a high quality substream, and what would be something else: the name of the
rid
values are of course useless for that, as they're user-provided and so can be anything. As such, we simply assume that the order will always be high-medium-low, and expect that in the SDP we receive. That said, I've been made aware that there are some implementations that fail to initialize when that's the enforced order, and only work when doing it the other way around, that is low-medium-high. Of course, in that case Janus messes up the mappings, because it ends up mapping the SSRC of what actually is a low quality stream to what it thinks is the high quality one instead, and viceversa, which breaks the automated switches too.As such, I've come up with this simple PR, which simply just adds a way for you to specify whether the order will be high-medium-low (the default) or low-medium-high, so that Janus can do the mapping properly. Specifically, this can be specified in a new property you can set in the
jsep
object when sending the offer, calledrid_order
: the only allowed values are"hml"
(which is the default if omitted) and"lmh"
. Notice that these strings have nothing to do with how you actually called yourrid
identifiers:"hml"
is simply a compact way of saying High-Medium-Low, and"lmh"
does the other way around. Trying to pass strings that differ from those patterns will simply result in Janus ignoring them, and so assuming the default"hml"
value. I'm not going to add any mapping more complex than that, so don't ask.I tested this by messing with
janus.js
to invert the order of encodings, and passing the properrid_order
property, and it seems to be working as expected. I only tested with the EchoTest, though. Feedback welcome.