UNPKG

@observertc/client-monitor-js

Version:

ObserveRTC Client Integration Javascript Library

1 lines 2.88 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 c}from"../detectors/PlayoutDiscrepancyDetector";import{AudioConcealmentDetector as n}from"../detectors/AudioConcealmentDetector";import{JitterBufferStressDetector as i}from"../detectors/JitterBufferStressDetector";import{DecoderPerformanceDetector as s}from"../detectors/DecoderPerformanceDetector";import{StuckDecoderDetector as d}from"../detectors/StuckDecoderDetector";import{VideoResolutionChangeDetector as a}from"../detectors/VideoResolutionChangeDetector";import{CodecChangeDetector as u}from"../detectors/CodecChangeDetector";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(h,l,m){this.track=h,this._inboundRtp=l,this.attachments=m;const p=this.getPeerConnection().parent.config;this.detectors=new e,null!==p.dryInboundTrackDetector&&this.detectors.add(new r(this)),null!==p.codecChangeDetector&&this.detectors.add(new u(this)),"audio"===this.kind?(null!==p.audioDesyncDetector&&this.detectors.add(new t(this)),null!==p.audioConcealmentDetector&&this.detectors.add(new n(this)),null!==p.jitterBufferStressDetector&&this.detectors.add(new i(this)),this.calculatedScore.weight=1):"video"===this.kind&&(null===p.videoFreezesDetector&&null===p.videoRecoveryDetector||this.detectors.add(new o(this)),null!==p.playoutDiscrepancyDetector&&this.detectors.add(new c(this)),null!==p.decoderPerformanceDetector&&this.detectors.add(new s(this)),null!==p.stuckDecoderDetector&&this.detectors.add(new d(this)),null!==p.videoResolutionChangeDetector&&this.detectors.add(new a(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.deltaFractionLost}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}}}