Quality Control in Mediasoup-client

To control media quality with Mediasoup-client, you can follow these steps:

Configure Transpor

When creating a Transport, you can specify configurations related to media quality.

For example, you can use parameters like maxBitrate to limit the maximum bitrate for media streams.

const transport = await device.createSendTransport({
  // Transport configuration
  maxBitrate: 500000 // Limit maximum bitrate to 500kbps
});

 

Adjust Producer Configuration

When creating a Producer, you can adjust the configuration to control media quality.

For example, you can use parameters like maxBitrate or scaleResolutionDownBy to limit the bitrate or scale down the resolution of media streams.

const producer = await transport.produce({
  kind: 'video',
  // Producer configuration
  maxBitrate: 300000, // Limit maximum bitrate to 300kbps
  scaleResolutionDownBy: 2 // Scale down resolution by 1/2
});

 

Adjust Consumer Configuration

When creating a Consumer, you can adjust the configuration to control media quality.

For example, you can use parameters like preferredCodec to prioritize a specific codec or preferredBitrate to request a preferred bitrate for media streams.

const consumer = await transport.consume({
  // Consumer configuration
  preferredCodec: 'h264', // Prefer using H.264 codec
  preferredBitrate: 500000 // Request preferred bitrate of 500kbps
});

 

Monitor Events and Handle

Mediasoup-client provides events like producer, consumer, downlinkBwe and uplinkBwe that you can monitor and handle for media quality control.

For example, you can listen for the 'uplinkBwe' event to adjust the quality based on the uplink bandwidth.

transport.on('uplinkBwe', (event) => {
  const targetBitrate = event.targetBitrate;
  // Adjust quality based on uplink bandwidth
});

 

Please note that the specific approach to control media quality and the available configurations may vary depending on the requirements and scenarios of your application. Refer to the Mediasoup-client documentation to learn more about the relevant configurations and events for adjusting media quality according to your needs.