Today we’re telling you about our recent experience of contributing a feature to the JsSIP project, and how we discovered a Safari bug in the process.
What are priority encodings?
When working with VOIP, and especially when developing a VOIP application, there are some lesser known tools that we can use to tailor the application to our specific needs, and to make sure it performs as well as it can for its particular use case.
One of these tools is the option to set the sender's priority on media stream tracks that are added to an RTC peer connection. What does this do? It lets you set a header on the RTP packets which assigns them a different (usually higher) priority, relative to the other packets. The levels are very-low
, low
, medium
and high
, with low being the default value. You can read the full spec here, if you’re interested.
By setting a high priority to the stream we’re most interested in, while keeping the less critical ones low, we can make sure that resources are applied as efficiently as possible. In most cases, this might not make a huge difference. In some applications, however, this could be used as a QoS marker, to make sure packets are given priority by the elements of the network as they make their way to their destination.
We found the need for priority encodings while working on a VOIP application based on the JsSIP module. As it turns out, JsSIP did not support setting priority encodings, so we set out to add it ourselves!
Building the feature into JsSIP
We like to use the patch-package module to make changes to our dependencies. It lets you make your changes to the code in the node_modules folder directly, and then creates a patch that can be reapplied whenever you reinstall your dependencies. It’s a quick way to test what works and to see the results directly in the code that uses that dependency, before forking the original project and opening a PR on it.
Setting the encoders on the RTCRtpSender
in the JsSIP codebase is pretty straightforward: