SUPPORT.TWILIO.COM END OF LIFE NOTICE: This site, support.twilio.com, is scheduled to go End of Life on February 27, 2024. All Twilio Support content has been migrated to help.twilio.com, where you can continue to find helpful Support articles, API docs, and Twilio blog content, and escalate your issues to our Support team. We encourage you to update your bookmarks and begin using the new site today for all your Twilio Support needs.

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