UNPKG

@observertc/client-monitor-js

Version:

ObserveRTC Client Integration Javascript Library

1 lines 1.75 kB
import{AudioDesyncDetector as t}from"../detectors/AudioDesyncDetector";import{Detectors as e}from"../detectors/Detectors";import{FreezedVideoTrackDetector as o}from"../detectors/FreezedVideoTrackDetector";import{DryInboundTrackDetector as r}from"../detectors/DryInboundTrackDetector";import{PlayoutDiscrepancyDetector as i}from"../detectors/PlayoutDiscrepancyDetector";export class InboundTrackMonitor{track;_inboundRtp;direction="inbound";detectors;dtxMode=!1;remoteOutboundTrackPaused=!1;calculatedScore={weight:0,value:void 0};get score(){return this.calculatedScore.value}get scoreReasons(){return this.calculatedScore.reasons}attachments;appData;constructor(n,s,c){this.track=n,this._inboundRtp=s,this.attachments=c,this.detectors=new e(new r(this)),"audio"===this.kind?(this.detectors.add(new t(this)),this.calculatedScore.weight=1):"video"===this.kind&&(this.detectors.add(new o(this)),this.detectors.add(new i(this)),this.calculatedScore.weight=2),"probator"===this.track.id&&this.detectors.clear()}getInboundRtp(){return this._inboundRtp}getPeerConnection(){return this._inboundRtp.getPeerConnection()}get kind(){return this._inboundRtp.kind}get bitrate(){return this._inboundRtp.bitrate}get jitter(){return this._inboundRtp.jitter}get fractionLost(){return this._inboundRtp.fractionLost}update(){this.detectors.update()}createSample(){let t;return"audio"===this.kind?t=this.getPeerConnection()?.parent.scoreCalculator?.encodeInboundAudioScoreReasons?.(this.calculatedScore.reasons):"video"===this.kind&&(t=this.getPeerConnection()?.parent.scoreCalculator?.encodeInboundVideoScoreReasons?.(this.calculatedScore.reasons)),{id:this.track.id,kind:this.track.kind,timestamp:Date.now(),attachments:this.attachments,score:this.score,scoreReasons:t}}}