Skip to main content

Mapping Peer Connections to Display Names Using watchRTC SDK

Peer connections in watchRTC are labelled based on the names assigned to them by WebRTC. These can be mapped to more logical names by using the watchRTC.mapPC API. Continue reading to learn more.

Example of a Peer Connection Label

In the following example PC_0 indicates the specific Peer Connection instance. If there are multiple peer connections, each one can be uniquely identified (e.g., PC_1, PC_2, etc.).

PC_0-ssrc-12345678912345-recv

These identifiers are essential for managing and routing the media streams correctly between peers, ensuring that audio and video data are properly synchronized and delivered to the correct endpoints. However, in practice this can make figuring out which channel is coming from which participant quite difficult and time consuming.

How to Map Peer Connections

To make this simpler, you can use the watchRTC.mapPC() API in the SDK to map peer connections to human-readable names. In doing so you will also let watchRTC know what display name to use for each peer.

To use the watchRTC.mapPC function, you need to pass an RTCPeerConnection object as the first parameter.
const pc = new PeerConnection();
watchRTC.mapPC(pc, “Name”);
  1. const pc = new PeerConnection();: This line creates a new instance of the RTCPeerConnection object and assigns it to the variable pc.
  2. watchRTC.mapPC(pc, "Name");: This line calls the mapPC method of the watchRTC object. It maps the RTCPeerConnection object pc to a display name, which in this case is "Name".

Was this article helpful?

0 out of 0 found this helpful