How to make sure you have WebRTC incoming audio using testRTC

I hear this one far too many times:

How can I make sure there’s incoming audio? We had this issue a few weeks/months ago, where sessions got connected in our WebRTC service, but there was no incoming audio. Can testRTC alert me of such a situation?

Looking for your WebRTC inocming audio? testRTC can do just that for you.

There are two things that our customers are looking for in such cases:

  1. Making sure that the exact channels they expected to open in the call actually opened (here the idea is no more and no less)
  2. Validating there’s media being sent on these channels at all

Some customers even have more specific expectations – in the domain of the packet loss or latency of these channels.

This is one of the reasons why we’ve added the test expectations capability to testRTC. What this means is that you can indicate inside your test script what you expect to happen – with a focus on media channels and media – and if these expectations aren’t met, the test will either fail or just have an added warning on it.

Here’s how it works. The code below is a simple test script for Google’s AppRTC that I’ve written for the occasion:

// *** My expectations ***
client
    .rtcSetTestExpectation("audio.in == 1", "No incoming audio channel", "error")
    .rtcSetTestExpectation("video.in == 1", "No incoming video channel", "error")
    .rtcSetTestExpectation("audio.in.bitrate > 0", "No media on audio channel", "error")
    .rtcSetTestExpectation("video.in.bitrate > 0", "No media on video channel", "error");

// *** My actual test script
client
    .url("https://appr.tc/r/testRTCexpectations-5")
    .waitForElementVisible('body', 5000)
    .pause(500)
    .click('#confirm-join-button')

    .pause(30000);

It is nothing fancy. It just gets the user into a predetermined URL (testRTCexpectations) and gives it 30 seconds to run.

We run this on two agents (=two browsers) and you get a call. That call should have two incoming and two channels (one video and one voice in each direction).

To make sure this really happens, I added those first four lines with rtcSetTestExpectation() – they indicate that I want to fail the test if I don’t get these incoming channels with media on them.

Here’s how a successful test will look like:

WebRTC test expectations

Perfect scoring. No warnings or errors. All channels are listeed nicely in the test results.

And here what happened when I ran this test with only a single browser of testRTC – and join the same room with my own laptop with its camera disabled:

WebRTC test expectations

As you can see, the test failed and the reasons given were that there was no incoming video channel (or media on it).

You can see from the channels list at the bottom that there is no incoming channel, along with all the other channels and the information about them.

What else can I do?

  • Use it on outgoing channels
  • Check other parameters such as packet loss
  • Place expectations on custom metrics and timers you use in the test

You can learn more about this capability in our knowledge base on expectations.

Leave a Reply 0 comments

Leave a Reply: