Potential Support Response Time Delays Due to Surge in Toll-Free Queries: We’re experiencing a surge in inquiries due to the November 8, 2023 Toll-Free Restricted Traffic Shutdown Deadline. We’re committed to helping you; please bear with us as there might be some delays. For more details, see Toll-Free Message Verification for US/Canada.

Constrain WebRTC Call Audio Sources in Google Chrome

The Twilio Voice JavaScript SDK (formerly "Twilio Client") allows you to constrain the audio sources used in a WebRTC call with its audioConstraints setting. audioConstraints allow you to directly specify what mandatory and/or optional MediaTrackConstraints should be used when selecting a local media stream.

While the W3C has begun standardizing the constraints available on media streams across browsers, Google implements a number of optional MediaTrackConstraints that enable or disable functionality specific to Chrome. These MediaTrackConstraints are added to and change with each release, so we encourage you to refer to the source whenever possible.

That being said, there are a few MediaTrackConstraints specific to Chrome that you can use with twilio.js’s audioConstraints setting that we think you may find useful, such as

  • googEchoCancellation Set to false to disable echo cancellation
  • googAutoGainControl Set to false to disable automatic gain control (AGC)
  • googNoiseSuppression Set to false to disable noise suppression
  • googHighpassFilter Set to false to remove a highpass filter from the audio source

For example, to disable AGC in twilio.js, call Twilio.Device.setup as follows:

var token;

// Set your capability token here
Twilio.Device.setup(token, {
    audioConstraints: {
        optional: [ { googAutoGainControl: false } ]
    }
});

Note: It is not recommended that you specify any browser-specific constraint as mandatory, as your call will fail in a browser that does not support the constraint. Instead, specify your constraints as optional. Your browser will do its best to satisfy as many optional constraints as possible.

Have more questions? Submit a request
Powered by Zendesk