UNPKG

@observertc/client-monitor-js

Version:

ObserveRTC Client Integration Javascript Library

1 lines 1.42 kB
import{Detectors as t}from"../detectors/Detectors";import{SynthesizedSamplesDetector as e}from"../detectors/SynthesizedSamplesDetector";export class MediaPlayoutMonitor{_peerConnection;_visited=!0;detectors=new t;timestamp;id;kind;synthesizedSamplesDuration;synthesizedSamplesEvents;totalSamplesDuration;totalPlayoutDelay;totalSamplesCount;deltaSynthesizedSamplesDuration=0;deltaSamplesDuration=0;attachments;appData;constructor(t,s){this._peerConnection=t,this.id=s.id,this.timestamp=s.timestamp,this.kind=s.kind,Object.assign(this,s),this.detectors.add(new e(this))}get visited(){const t=this._visited;return this._visited=!1,t}getPeerConnection(){return this._peerConnection}accept(t){this._visited=!0;t.timestamp-this.timestamp<=0||(this.synthesizedSamplesDuration&&t.synthesizedSamplesDuration&&(this.deltaSynthesizedSamplesDuration=t.synthesizedSamplesDuration-this.synthesizedSamplesDuration),this.totalSamplesDuration&&t.totalSamplesDuration&&(this.deltaSamplesDuration=t.totalSamplesDuration-this.totalSamplesDuration),Object.assign(this,t),this.detectors.update())}createSample(){return{id:this.id,timestamp:this.timestamp,kind:this.kind,synthesizedSamplesDuration:this.synthesizedSamplesDuration,synthesizedSamplesEvents:this.synthesizedSamplesEvents,totalSamplesDuration:this.totalSamplesDuration,totalPlayoutDelay:this.totalPlayoutDelay,totalSamplesCount:this.totalSamplesCount,attachments:this.attachments}}}