UNPKG

@observertc/observer-js

Version:

Server Side NodeJS Library for processing ObserveRTC Samples

94 lines (93 loc) 3.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ObservedIceTransport = void 0; class ObservedIceTransport { timestamp; id; _peerConnection; _visited = false; appData; packetsSent; packetsReceived; bytesSent; bytesReceived; iceRole; iceLocalUsernameFragment; dtlsState; iceState; selectedCandidatePairId; localCertificateId; remoteCertificateId; tlsVersion; dtlsCipher; dtlsRole; srtpCipher; selectedCandidatePairChanges; attachments; deltaPacketsReceived = 0; deltaPacketsSent = 0; deltaBytesReceived = 0; deltaBytesSent = 0; constructor(timestamp, id, _peerConnection) { this.timestamp = timestamp; this.id = id; this._peerConnection = _peerConnection; } get visited() { const visited = this._visited; this._visited = false; return visited; } getPeerConnection() { return this._peerConnection; } getSelectedCandidatePair() { return this._peerConnection.observedIceCandidatesPair.get(this.selectedCandidatePairId ?? ''); } update(stats) { this._visited = true; if (this.bytesReceived !== undefined && stats.bytesReceived !== undefined && this.bytesReceived <= stats.bytesReceived) { this.deltaBytesReceived = stats.bytesReceived - this.bytesReceived; } else { this.deltaBytesReceived = 0; } if (this.bytesSent !== undefined && stats.bytesSent !== undefined && this.bytesSent <= stats.bytesSent) { this.deltaBytesSent = stats.bytesSent - this.bytesSent; } else { this.deltaBytesSent = 0; } if (this.packetsReceived !== undefined && stats.packetsReceived !== undefined && this.packetsReceived <= stats.packetsReceived) { this.deltaPacketsReceived = stats.packetsReceived - this.packetsReceived; } else { this.deltaPacketsReceived = 0; } if (this.packetsSent !== undefined && stats.packetsSent !== undefined && this.packetsSent <= stats.packetsSent) { this.deltaPacketsSent = stats.packetsSent - this.packetsSent; } else { this.deltaPacketsSent = 0; } this.timestamp = stats.timestamp; this.packetsSent = stats.packetsSent; this.packetsReceived = stats.packetsReceived; this.bytesSent = stats.bytesSent; this.bytesReceived = stats.bytesReceived; this.iceRole = stats.iceRole; this.iceLocalUsernameFragment = stats.iceLocalUsernameFragment; this.dtlsState = stats.dtlsState; this.iceState = stats.iceState; this.selectedCandidatePairId = stats.selectedCandidatePairId; this.localCertificateId = stats.localCertificateId; this.remoteCertificateId = stats.remoteCertificateId; this.tlsVersion = stats.tlsVersion; this.dtlsCipher = stats.dtlsCipher; this.dtlsRole = stats.dtlsRole; this.srtpCipher = stats.srtpCipher; this.selectedCandidatePairChanges = stats.selectedCandidatePairChanges; this.attachments = stats.attachments; } } exports.ObservedIceTransport = ObservedIceTransport;