@ceeblue/webrtc-client
    Preparing search index...

    Class PlayerStats

    IStats is the interface used to implement statistics seralization The serialized object can then be sent to a server for analysis with Telemetry.

    // MyStats implementation
    class MyStats extends IStats {
    constructor(obj) {
    this._obj = obj;
    // Subscribe to onClose event to signal object release (will stop this stats report)
    obj.onClose = () => this.onRelease();
    }
    async serialize() {
    // serialize stats to a JSON object {recvBytes, sendBytes}
    return {
    recvBytes: this._obj.recvBytes,
    sendBytes: this._obj.sendBytes
    }
    }
    }

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    audioByteRate?: number
    audioPerSecond?: number
    audioTrackBandwidth?: number
    audioTrackId?: number
    bufferAmount?: number
    currentTime?: number
    dataByteRate?: number
    jitter?: number
    latency?: number
    log: ILog

    Start a log

    a Log object with the levels of log to call

    lostPacketCount?: number
    nackCount?: number
    playbackRate?: number
    playbackSpeed?: number
    protocol?: string
    rtt?: number
    skippedAudio?: number
    skippedVideo?: number
    stallCount?: number
    videoByteRate?: number
    videoPerSecond?: number
    videoTrackBandwidth?: number
    videoTrackId?: number
    waitingData?: boolean

    Methods

    • Computes and updates all player statistics based on the current connection infos, metadata, and playback state. Updates the internal properties of this class including those inherited from utils.PlayerStats.

      Parameters

      • infos: ConnectionInfos

        ConnectionInfos: WebRTC connection and input stats.

      • metadata: Metadata

        Metadata: Stream metadata and track info.

      • currentTime: number

        number: Current playback time (media time) in seconds.

      • OptionalaudioTrackId: number

        number (optional): Selected audio track ID.

      • OptionalvideoTrackId: number

        number (optional): Selected video track ID.

      Returns void

    • Converts the current PlayerStats snapshot into a CMCD (Common Media Client Data) payload.

      Parameters

      • url: URL

        The full URL of the media object.

      • trackId: number

        The track ID for which to generate the CMCD payload.

      • OptionalprevStats: utils.PlayerStats

        Optional previous PlayerStats snapshot to calculate deltas for incremental metrics since their last reset.

      Returns Cmcd

      A CML.Cmcd object representing the CMCD payload.

    Events