Constructor
new BaseRTCStatsReport(originalReport)
Create a BaseRTCStatsReport.
Parameters:
Name | Type | Description |
---|---|---|
originalReport |
RTCStatsReport
|
original stats report from |
Throws:
- When given stats has undefined type or kind.
Example
import {
BaseRTCStatsReport,
RTCStatsReferences
} from 'rtcstats-wrapper';
const report = new BaseRTCStatsReport(await pc.getStats());
// get stats of incoming RTP stream
const recvVideoStats = report.get(RTCStatsReferences.RTCInboundRtpVideoStreams.key);
// get each log of inbound-rtp
for (const stats of recvVideoStats) {
logger.info(`ts:${stats.timestamp} id:${stats.trackId} recv:${stats.bytesReceived}`);
}
Methods
get(key) → {Array.<RTCStats>}
Get the array of type of stats referred by key
.
Parameters:
Name | Type | Description |
---|---|---|
key |
string
|
A stats object reference defined in RTCStatsReferences enum. |
Returns:
- Type:
-
Array.<RTCStats>
An array of stats referred by key
.
Example
const report = new BaseRTCStatsReport(await pc.getStats());
if (report.get(RTCStatsReferences.RTCInboundRtpVideoStreams.key)) {
const stats = report.get(
RTCStatsReferences.RTCInboundRtpVideoStreams.key
)[0];
logger.info(`ts:${stats.timestamp} id:${stats.trackId} recv:${stats.bytesReceived}`);
has(key) → {bool}
Check if the instance has the type of stats referred by key
.
Parameters:
Name | Type | Description |
---|---|---|
key |
string
|
A stats object reference defined in RTCStatsReferences enum. |
Returns:
- Type:
-
bool
True if the referred stats exists.
Example
const report = new BaseRTCStatsReport(await pc.getStats());
if (report.has(RTCStatsReferences.RTCInboundRtpVideoStreams.key)) {
logger.info("receiving video.");
} else {
logger.info("no video streams receiving.");
}