UNPKG

@observertc/client-monitor-js

Version:

ObserveRTC Client Integration Javascript Library

1 lines 905 B
export class DryOutboundTrackDetector{trackMonitor;name="dry-outbound-track-detector";constructor(t){this.trackMonitor=t}_evented=!1;get peerConnection(){return this.trackMonitor.getPeerConnection()}get config(){return this.peerConnection.parent.config.dryOutboundTrackDetector}_activatedAt;update(){if(this._evented||this.config.disabled)return;if(0!==this.trackMonitor.getOutboundRtps()?.[0]?.bytesSent)return;if(this.trackMonitor.track.muted||"live"!==this.trackMonitor.track.readyState)return void(this._activatedAt=void 0);this._activatedAt||(this._activatedAt=Date.now());const t=Date.now()-this._activatedAt;if(t<this.config.thresholdInMs)return;this._evented=!0;const e=this.peerConnection.parent;e.emit("dry-outbound-track",{trackMonitor:this.trackMonitor,clientMonitor:e}),this.config.createIssue&&e.addIssue({type:"dry-outbound-track",payload:{trackId:this.trackMonitor.track.id,duration:t}})}}