Skip to main content

Mapping streams in watchRTC

Media channels in watchRTC are labeled based on the names assigned to them by WebRTC, which usually revolves around the SSRC of the streams.

In group sessions this can make figuring out which channel is coming from which participant quite difficult and time consuming. To make this simpler, you can use watchRTC.mapTrack() API in the SDK to let watchRTC know what display name to use for each stream:
watchRTC.mapTrack(id,name);

Where id is the RTCMediaStreamTrack with the trackIdentifier we wish to map, and name is the display name to associate with it.

Using this will cause the channels on that media stream to show the display name instead of the track identifier, making it easier to associate the media with its original sender. For example, if you want to map the track identified by “oUx4qq5T0xvng4vr9XISNwZnGv0cIl0xSGxJ”, to the display name “John Doe”, then we would use:
watchRTC.mapTrack("oUx4qq5T0xvng4vr9XISNwZnGv0cIl0xSGxJ", "John Doe");

Inbound vs Outbound Tracks

The watchRTC.mapTrack() API can be used for both incoming and outgoing tracks. It can be used in the following scenarios;

  1. When you create new outgoing tracks (tracks to be sent)
  2. When you receive new incoming tracks (when tracks are received front the other side)
  3. When you call the ‘replace Track’ function (when you want to change the ID of one track to another)

When any of these things are being done you will need to call the watchRTC.mapTrack() API to notify the SDK of the associated track identifier and the new name you wish to be displayed in its place.

Note: Track identifiers in WebRTC are typically generated and assigned by the WebRTC framework or the browser itself. Read the article Track Identifiers to learn more about track identifiers and how to access them.

Was this article helpful?

0 out of 0 found this helpful