Dynamic viewer tracks

The last piece of the puzzle is to be able to receive more than one audio or video track within the same viewer session. However, you couldn’t have multiple video tracks and multiplexed audio from the server. So there was an important feature missing:

The addRemoteTrack method on our Javascript SDK provides the ability to add new tracks on demand on the viewer side. This method will perform a local renegotiation and create the track event with the added track and transceiver.

// Add remote track and wait until the SDP O/A is performed and mid is assigned to the transceiver
const transceiver = await viewer.addRemoteTrack("video",[new MediaStream()]);
// Get mid for new created remote track
const mediaId = transceiver.mid;

After the renegotiation is done, you can use the newly created transceiver mid attribute on the projection or layer selection methods to receive media from any source on the new track.