Sunday 8 September 2019

How to use getStats api

I am using Puppeteer headless browser and doing WebRTC call. At the end of call I want to know statistics like bandwidth, Jitter, ICE details etc.

So far what I have been able to collect from google search is we can get the stats data using getStats api.

But in a puppeteer script how I can call getStats api, I could not find any example.

My code looks as below.

const puppeteer = require('puppeteer');
const sleep = (waitTimeInMs) => new Promise(resolve => setTimeout(resolve, waitTimeInMs));

(async () => {
    const browser = await puppeteer.launch({headless: false});
    const page = await browser.newPage();
    await page.goto('https://janus.conf.meetecho.com/videocalltest.html');
    await page.waitForSelector('#start');
    await page.click('[id=start]');
    await page.waitForSelector('#username', { visible: true });
    await page.type('input[id="username"]', 'user1');
    await page.click('button[id=register]');
    await page.waitFor(5000);
    await page.type('input[id=peer]', 'user0');
    await page.click('button[id=call]');
    await sleep(16000);
    await page.click('button[id=start]');
    await sleep(3000);
    await browser.close();
})();

Just before browser.close(), I want to know stats data. Can you please help me to understand, how can I make use of getStats api in this context to get the stats data.

Is there any better way to get stats data then getsStats api?



from How to use getStats api

No comments:

Post a Comment