import type { StatsReport } from './types'; import { CallState } from '../store'; import { Publisher, Subscriber } from '../rtc'; export type StatsReporterOpts = { subscriber: Subscriber; publisher?: Publisher; state: CallState; datacenter: string; pollingIntervalInMs?: number; }; type PeerConnectionKind = 'subscriber' | 'publisher'; export type StatsReporter = { /** * Will turn on stats reporting for a given sessionId. * * @param sessionId the session id. */ startReportingStatsFor: (sessionId: string) => void; /** * Will turn off stats reporting for a given sessionId. * * @param sessionId the session id. */ stopReportingStatsFor: (sessionId: string) => void; /** * Helper method for retrieving stats for a given peer connection kind * and media stream flowing through it. * * @param kind the peer connection kind (subscriber or publisher). * @param mediaStream the media stream. */ getStatsForStream: (kind: PeerConnectionKind, tracks: MediaStreamTrack[]) => Promise; /** * Helper method for retrieving raw stats for a given peer connection kind. * * @param kind the peer connection kind (subscriber or publisher). * @param selector the track selector. If not provided, stats for all tracks will be returned. */ getRawStatsForTrack: (kind: PeerConnectionKind, selector?: MediaStreamTrack) => Promise; /** * Stops the stats reporter and releases all resources. */ stop: () => void; }; /** * Creates a new StatsReporter instance that collects metrics about the ongoing call and reports them to the state store */ export declare const createStatsReporter: ({ subscriber, publisher, state, datacenter, pollingIntervalInMs, }: StatsReporterOpts) => StatsReporter; export type StatsTransformOpts = { /** * The kind of track we are transforming stats for. */ trackKind: 'audio' | 'video'; /** * The kind of peer connection we are transforming stats for. */ kind: PeerConnectionKind; /** * The publisher instance. */ publisher: Publisher | undefined; }; export {};