RTCStatsMoment

RTCStatsMoment

Class to get the momentary metrics based on the RTCStats.

Constructor

new RTCStatsMoment()

Create a RTCStatsMoment.

See:
Example
import { RTCStatsMoment } from 'rtcstats-wrapper';

const moment = new RTCStatsMoment();

const report = await pc.getStats();
moment.update(report);
moment.report();
//=> {
//    "send": {
//        "video": { ... },
//        "audio": { ... },
//    },
//    "receive": {
//        "video": { ... },
//        "audio": { ... },
//    },
//    "candidatePair": { ... }
//}

Methods

report() → {MomentaryReport}

Calculate the momentary value based on the updated value. MomentaryReport does not have attribute that can not be obtained.

Returns:
Type:
MomentaryReport
Example
import { RTCStatsMoment } from 'rtcstats-wrapper';

const moment = new RTCStatsMoment();

const receiver = pc.getReceivers().find(sender => sender.kind === "video");
const report = receiver.getStats();
moment.update(report);
moment.report();
//=> {
//    "send": {
//        "video": { ... },
//    }
//}

update(report)

Update the report.

Parameters:
Name Type Description
report RTCStatsReport

original stats report from (pc|sender|receiver).getStats().

Example
import { RTCStatsMoment } from 'rtcstats-wrapper';

const moment = new RTCStatsMoment();

const id = setInterval(() => {
  const report = await pc.getStats();
  moment.update(report);
}, INTERVAL);