Fix overwriting of 7-bit PictureID when doing VP8 simulcast #3121
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.
We noticed a problem in our simulcast management when using non-browser sources, specifically an FFmpeg source for RTP packets. When doing VP8 simulcast, the server needs to ensure monotonically increasing PictureID values, which is what we do in Janus. Older versions of FFmpeg (before this was patched), though, used 7-bit PictureID values in the VP8 payload header, and we found out our code didn't handle that well, since we were always assuming 15-bit values when overwriting it: this resulted in the payload getting one byte "eaten" away, and the VP8 payload to be corrupted as well.
This patch tries to address that, and to ensure we don't overflow either 7-bit or 15-bit PictureID values when an overwrite process is taking place. If you're using simulcast, please do test this out to ensure we're not introducing any regression, and that it still works as expected for you. Feedback on whether you notice something wrong in the code is welcome too, of course!
Edit: side note, as explained here, browsers don't really support 7-bit properly anyway (there's a bug open), so our fix for 7-bit PictureID improves things but doesn't fix them when 7-bit values are used (video still freezes occasionally). That said, I still think it's important we fix the behaviour in Janus, in case it's fixed in browsers too eventually.