When stream support was added to Asterisk it was initially done with the focus being for SFU with a single video stream from each participant with the call starting out with video. This is a use case which is useful for a lot of people and has worked well. Coming soon, however, is the ability for an external entity (such as an endpoint) to add or remove video mid-call. Let’s take a look at how this works!
In SIP when you are manipulating media attributes of a call this is done through SDP. After a call is set up you can do what is known as a re-INVITE to renegotiate these aspects. For the Asterisk SFU support this is used to add or remove participant streams by sending a re-INVITE from Asterisk to each endpoint with a new SDP. Up until now the reverse, that is an endpoint sending a re-INVITE to Asterisk, has resulted in the negotiation occurring but the Asterisk core and applications not receiving notification this has occurred. Going forward this now changes and notification is provided that the things have changed on the channel. It is then up to what is handling the channel to react accordingly if need be.
In the case of bridge_simple or bridge_native_rtp upon a channel changing the stream attributes (such as adding or removing a stream) a re-INVITE is sent to the other channel to try to get it to match. If Alice adds video mid-call then a re-INVITE is sent to Bob to add video. Once this completes the streams are mapped and media flows appropriately.
In the case of bridge_softmix with SFU support a bit more work has to go into things. We determine how many video streams are sending media into the video bridge from each channel and ensure that the other participants have an outgoing stream for each. Mapping and re-INVITEs work as they do before in the SFU, they can now just occur as a result of video being added and removed. This functionality has also removed the limitation of having a single video source from each channel. Now there is no limit except the maximum video streams configured on the PJSIP endpoint itself.
This change not only improves user experience but also allows some fun new functionality in the SFU. For example you can now have both a webcam displayed in a video conference bridge as well as a screen share!