UNPKG

@dolbyio/webrtc-stats

Version:
61 lines (60 loc) 1.99 kB
import { EventEmitter } from 'events'; import { WebRTCStatsOptions } from './types/options'; import { WebRTCStatsEvents } from './types/webRTCStatsEvents'; export interface WebRTCStats { /** * Adds the `listener` function to the end of the listeners array for the * event named `eventName`. No checks are made to see if the `listener` has * already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple * times. * * @param eventName The name of the event. * @param listener The callback function. * * @returns A reference to the {@link EventEmitter}, so that calls can be chained. */ on<N extends keyof WebRTCStatsEvents>(eventName: N, listener: WebRTCStatsEvents[N]): this; /** @hidden */ emit<N extends keyof WebRTCStatsEvents>(eventName: N, ...args: Parameters<WebRTCStatsEvents[N]>): boolean; } /** * Representation of the WebRTC Statistics collection object. * * @example * ```ts * import { WebRTCStats } from '@dolbyio/webrtc-stats'; * * const collection = new WebRTCStats({ * getStatsInterval: 1000, * getStats: () => { * // TODO: return the statistics. * }, * includeRawStats: false, * }); * * // The stats event is triggered after each interval has elapsed * collection.on('stats', (event: OnStats) => { * console.log(event); * }); * * // Start the statistics collection * collection.start(); * ``` */ export declare class WebRTCStats extends EventEmitter implements WebRTCStats { #private; /** * Creates an instance of the {@link WebRTCStats} class. * * @param options Options for the WebRTC statistics collection. */ constructor(options: WebRTCStatsOptions); /** * Starts the WebRTC statistics collection. */ start: () => void; /** * Stops the WebRTC statistics collection. */ stop: () => void; }