UNPKG

@observertc/observer-js

Version:

Server Side NodeJS Library for processing ObserveRTC Samples

255 lines (254 loc) 12.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ObservedClientEventMonitor = void 0; class ObservedClientEventMonitor { observedClient; context; constructor(observedClient, context) { this.observedClient = observedClient; this.context = context; this._onPeerConnconnectionAdded = this._onPeerConnconnectionAdded.bind(this); this._onPeerConnectionRemoved = this._onPeerConnectionRemoved.bind(this); this._onCertificateAdded = this._onCertificateAdded.bind(this); this._onCertificateRemoved = this._onCertificateRemoved.bind(this); this._onInboundTrackAdded = this._onInboundTrackAdded.bind(this); this._onInboundTrackRemoved = this._onInboundTrackRemoved.bind(this); this._onOutboundTrackAdded = this._onOutboundTrackAdded.bind(this); this._onOutboundTrackRemoved = this._onOutboundTrackRemoved.bind(this); this._onInboundRtpAdded = this._onInboundRtpAdded.bind(this); this._onInboundRtpRemoved = this._onInboundRtpRemoved.bind(this); this._onOutboundRtpAdded = this._onOutboundRtpAdded.bind(this); this._onOutboundRtpRemoved = this._onOutboundRtpRemoved.bind(this); this._onDataChannelAdded = this._onDataChannelAdded.bind(this); this._onDataChannelRemoved = this._onDataChannelRemoved.bind(this); this._onAddedIceTransport = this._onAddedIceTransport.bind(this); this._onRemovedIceTransport = this._onRemovedIceTransport.bind(this); this._onIceCandidateAdded = this._onIceCandidateAdded.bind(this); this._onIceCandidateRemoved = this._onIceCandidateRemoved.bind(this); this._onAddedIceCandidatePair = this._onAddedIceCandidatePair.bind(this); this._onRemovedIceCandidatePair = this._onRemovedIceCandidatePair.bind(this); this._onAddedMediaCodec = this._onAddedMediaCodec.bind(this); this._onRemovedMediaCodec = this._onRemovedMediaCodec.bind(this); this._onAddedMediaPlayout = this._onAddedMediaPlayout.bind(this); this._onRemovedMediaPlayout = this._onRemovedMediaPlayout.bind(this); this._onMediaSourceAdded = this._onMediaSourceAdded.bind(this); this._onMediaSourceRemoved = this._onMediaSourceRemoved.bind(this); this._onClientClosed = this._onClientClosed.bind(this); this._onClientIssue = this._onClientIssue.bind(this); this._onClientMetadata = this._onClientMetadata.bind(this); this._onClientJoined = this._onClientJoined.bind(this); this._onClientLeft = this._onClientLeft.bind(this); this._onUserMediaError = this._onUserMediaError.bind(this); this._onUsingTurn = this._onUsingTurn.bind(this); this._onClientUpdated = this._onClientUpdated.bind(this); this._onClientExtensionStats = this._onClientExtensionStats.bind(this); this.observedClient.on('newpeerconnection', this._onPeerConnconnectionAdded); this.observedClient.on('issue', this._onClientIssue); this.observedClient.on('metaData', this._onClientMetadata); this.observedClient.on('joined', this._onClientJoined); this.observedClient.on('left', this._onClientLeft); this.observedClient.on('rejoined', this._onClientJoined); this.observedClient.on('usermediaerror', this._onUserMediaError); this.observedClient.on('usingturn', this._onUsingTurn); this.observedClient.on('update', this._onClientUpdated); this.observedClient.once('close', this._onClientClosed); } onClientUpdated; _onClientUpdated(...args) { this.onClientUpdated?.(this.observedClient, args[0], this.context); } onClientClosed; _onClientClosed() { this.onClientClosed?.(this.observedClient, this.context); this.observedClient.off('newpeerconnection', this._onPeerConnconnectionAdded); this.observedClient.off('issue', this._onClientIssue); this.observedClient.off('metaData', this._onClientMetadata); this.observedClient.off('joined', this._onClientJoined); this.observedClient.off('left', this._onClientLeft); this.observedClient.off('rejoined', this._onClientJoined); this.observedClient.off('usermediaerror', this._onUserMediaError); this.observedClient.off('usingturn', this._onUsingTurn); } onPeerConnectionAdded; _onPeerConnconnectionAdded(peerConnection) { this.onPeerConnectionAdded?.(peerConnection, this.context); peerConnection.once('close', () => this._onPeerConnectionRemoved(peerConnection)); peerConnection.on('added-certificate', this._onCertificateAdded); peerConnection.on('removed-certificate', this._onCertificateRemoved); peerConnection.on('added-inbound-track', this._onInboundTrackAdded); peerConnection.on('removed-inbound-track', this._onInboundTrackRemoved); peerConnection.on('added-outbound-track', this._onOutboundTrackAdded); peerConnection.on('removed-outbound-track', this._onOutboundTrackRemoved); peerConnection.on('added-inbound-rtp', this._onInboundRtpAdded); peerConnection.on('removed-inbound-rtp', this._onInboundRtpRemoved); peerConnection.on('added-outbound-rtp', this._onOutboundRtpAdded); peerConnection.on('removed-outbound-rtp', this._onOutboundRtpRemoved); peerConnection.on('added-data-channel', this._onDataChannelAdded); peerConnection.on('removed-data-channel', this._onDataChannelRemoved); peerConnection.on('added-ice-transport', this._onAddedIceTransport); peerConnection.on('removed-ice-transport', this._onRemovedIceTransport); peerConnection.on('added-ice-candidate', this._onIceCandidateAdded); peerConnection.on('removed-ice-candidate', this._onIceCandidateRemoved); peerConnection.on('added-ice-candidate-pair', this._onAddedIceCandidatePair); peerConnection.on('removed-ice-candidate-pair', this._onRemovedIceCandidatePair); peerConnection.on('added-codec', this._onAddedMediaCodec); peerConnection.on('removed-codec', this._onRemovedMediaCodec); peerConnection.on('added-media-playout', this._onAddedMediaPlayout); peerConnection.on('removed-media-playout', this._onRemovedMediaPlayout); peerConnection.on('added-media-source', this._onMediaSourceAdded); peerConnection.on('removed-media-source', this._onMediaSourceRemoved); } onPeerConnectionRemoved; _onPeerConnectionRemoved(peerConnection) { this.onPeerConnectionRemoved?.(peerConnection, this.context); peerConnection.off('added-certificate', this._onCertificateAdded); peerConnection.off('removed-certificate', this._onCertificateRemoved); peerConnection.off('added-inbound-track', this._onInboundTrackAdded); peerConnection.off('removed-inbound-track', this._onInboundTrackRemoved); peerConnection.off('added-outbound-track', this._onOutboundTrackAdded); peerConnection.off('removed-outbound-track', this._onOutboundTrackRemoved); peerConnection.off('added-inbound-rtp', this._onInboundRtpAdded); peerConnection.off('removed-inbound-rtp', this._onInboundRtpRemoved); peerConnection.off('added-outbound-rtp', this._onOutboundRtpAdded); peerConnection.off('removed-outbound-rtp', this._onOutboundRtpRemoved); peerConnection.off('added-data-channel', this._onDataChannelAdded); peerConnection.off('removed-data-channel', this._onDataChannelRemoved); peerConnection.off('added-ice-transport', this._onAddedIceTransport); peerConnection.off('removed-ice-transport', this._onRemovedIceTransport); peerConnection.off('added-ice-candidate', this._onIceCandidateAdded); peerConnection.off('removed-ice-candidate', this._onIceCandidateRemoved); peerConnection.off('added-ice-candidate-pair', this._onAddedIceCandidatePair); peerConnection.off('removed-ice-candidate-pair', this._onRemovedIceCandidatePair); peerConnection.off('added-codec', this._onAddedMediaCodec); peerConnection.off('removed-codec', this._onRemovedMediaCodec); peerConnection.off('added-media-playout', this._onAddedMediaPlayout); peerConnection.off('removed-media-playout', this._onRemovedMediaPlayout); peerConnection.off('added-media-source', this._onMediaSourceAdded); peerConnection.off('removed-media-source', this._onMediaSourceRemoved); } onCertificateAdded; _onCertificateAdded(certificate) { this.onCertificateAdded?.(certificate, this.context); } onCertificateRemoved; _onCertificateRemoved(certificate) { this.onCertificateRemoved?.(certificate, this.context); } onInboundTrackAdded; _onInboundTrackAdded(inboundTrack) { this.onInboundTrackAdded?.(inboundTrack, this.context); } onInboundTrackRemoved; _onInboundTrackRemoved(inboundTrack) { this.onInboundTrackRemoved?.(inboundTrack, this.context); } onOutboundTrackAdded; _onOutboundTrackAdded(outboundTrack) { this.onOutboundTrackAdded?.(outboundTrack, this.context); } onOutboundTrackRemoved; _onOutboundTrackRemoved(outboundTrack) { this.onOutboundTrackRemoved?.(outboundTrack, this.context); } onInboundRtpAdded; _onInboundRtpAdded(inboundRtp) { this.onInboundRtpAdded?.(inboundRtp, this.context); } onInboundRtpRemoved; _onInboundRtpRemoved(inboundRtp) { this.onInboundRtpRemoved?.(inboundRtp, this.context); } onOutboundRtpAdded; _onOutboundRtpAdded(outboundRtp) { this.onOutboundRtpAdded?.(outboundRtp, this.context); } onOutboundRtpRemoved; _onOutboundRtpRemoved(outboundRtp) { this.onOutboundRtpRemoved?.(outboundRtp, this.context); } onDataChannelAdded; _onDataChannelAdded(dataChannel) { this.onDataChannelAdded?.(dataChannel, this.context); } onDataChannelRemoved; _onDataChannelRemoved(dataChannel) { this.onDataChannelRemoved?.(dataChannel, this.context); } onAddedIceTransport; _onAddedIceTransport(iceTransport) { this.onAddedIceTransport?.(iceTransport, this.context); } onRemovedIceTransport; _onRemovedIceTransport(iceTransport) { this.onRemovedIceTransport?.(iceTransport, this.context); } onIceCandidateAdded; _onIceCandidateAdded(iceCandidate) { this.onIceCandidateAdded?.(iceCandidate, this.context); } onIceCandidateRemoved; _onIceCandidateRemoved(iceCandidate) { this.onIceCandidateRemoved?.(iceCandidate, this.context); } onAddedIceCandidatePair; _onAddedIceCandidatePair(candidatePair) { this.onAddedIceCandidatePair?.(candidatePair, this.context); } onRemovedIceCandidatePair; _onRemovedIceCandidatePair(candidatePair) { this.onRemovedIceCandidatePair?.(candidatePair, this.context); } onAddedMediaCodec; _onAddedMediaCodec(codec) { this.onAddedMediaCodec?.(codec, this.context); } onRemovedMediaCodec; _onRemovedMediaCodec(codec) { this.onRemovedMediaCodec?.(codec, this.context); } onAddedMediaPlayout; _onAddedMediaPlayout(mediaPlayout) { this.onAddedMediaPlayout?.(mediaPlayout, this.context); } onRemovedMediaPlayout; _onRemovedMediaPlayout(mediaPlayout) { this.onRemovedMediaPlayout?.(mediaPlayout, this.context); } onMediaSourceAdded; _onMediaSourceAdded(mediaSource) { this.onMediaSourceAdded?.(mediaSource, this.context); } onMediaSourceRemoved; _onMediaSourceRemoved(mediaSource) { this.onMediaSourceRemoved?.(mediaSource, this.context); } onClientIssue; _onClientIssue(issue) { this.onClientIssue?.(issue, this.context); } onClientMetadata; _onClientMetadata(metadata) { this.onClientMetadata?.(metadata, this.context); } onClientExtensionStats; _onClientExtensionStats(extensionStats) { this.onClientExtensionStats?.(extensionStats, this.context); } onClientJoined; _onClientJoined() { this.onClientJoined?.(this.observedClient, this.context); } onClientLeft; _onClientLeft() { this.onClientLeft?.(this.observedClient, this.context); } onUserMediaError; _onUserMediaError(error) { this.onUserMediaError?.(error, this.observedClient, this.context); } onUsingTurn; _onUsingTurn() { this.onUsingTurn?.(this.observedClient, this.context); } } exports.ObservedClientEventMonitor = ObservedClientEventMonitor;