The code in this is currently outdated because our Video SDK was in BETA and has updated since the writing of this blog post. Check out this tutorial instead if you want help using Twilio video.

The WebRTC statistics spec details an API that gives developers access to a ton of statistical information about a WebRTC peer connection. It is currently evolving and is partially implemented in Chrome and FireFox. Neither browser has their stats API implementation up the to full spec yet and they both vary in execution. Code you write for one browser will almost certainly not work in the other browser.

This post will highlight notable differences between the two implementations. We will be writing browser-agnostic code to gather statistics via a peer connection from a Twilio Video conversation.

Getting started with a Twilio Video conversation

In order to use the stats API, we will need to gather statistics on a WebRTC peer connection. Let’s begin by building a basic application with Twilio Video.

Twilio Video makes it super easy to build multi-person video chat applications and takes care of all the complicated WebRTC boilerplate that we would otherwise have to deal with. No dealing with STUN/TURN servers or ICE candidates. This is perfect for quickly demonstrating the getStats API in both browsers.