Options
Menu

Options passed to MediaConnectionBitrateTest constructor.

Hierarchy

Index

Properties

iceServers

iceServers: RTCIceServer[]

The array of RTCIceServer configurations to use. You need to provide STUN and TURN server configurations to ensure that your network bitrate is tested. You can use Twilio's Network Traversal Service to get STUN and TURN server configurations.

The following example demonstrates how to use the twilio npm module to generate credentials with a ttl of 120 seconds, using UDP protocol, and specifying ashburn as the edge location.

import Client from 'twilio';
import { testMediaConnectionBitrate } from '@twilio/rtc-diagnostics';

// Generate the STUN and TURN server credentials with a ttl of 120 seconds
const client = Client(twilioAccountSid, authToken);
const token = await client.tokens.create({ ttl: 120 });
const iceServers = [];

// Grab STUN server
iceServers.push({ urls: token.iceServers.find(item => item.urls.includes('stun:global.stun.twilio.com')).urls });

// Grab TURN servers.
// Use the following filters if you want to use UDP, TCP, or TLS
// UDP: turn:global.turn.twilio.com:3478?transport=udp
// TCP: turn:global.turn.twilio.com:3478?transport=tcp
// TLS: turn:global.turn.twilio.com:443?transport=tcp
let { urls, username, credential } = token.iceServers
  .find(item => item.url === 'turn:global.turn.twilio.com:3478?transport=udp');
iceServers.push({ urls, username, credential });

// By default, global will be used as the default edge location.
// You can replace global with a specific edge name.
iceServers.forEach(iceServer => {
  iceServer.urls = iceServer.urls.replace('global', 'ashburn');
});

// Use the TURN credentials using the iceServers parameter
const mediaConnectionBitrateTest = testMediaConnectionBitrate({ iceServers });

Note, for production code, the above code should not be executed client side as it requires the authToken which must be treated like a private key.

Optional minBitrateThreshold

minBitrateThreshold: undefined | number

The minimum bitrate in kilobits per second expected to be available. This value is used to determine when to raise WarningName.LowBitrate warning.

default

100

Generated using TypeDoc