@observertc/observer-js 0.42.9 → 1.0.1-57a1811.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc +6 -6
- package/README.md +0 -104
- package/lib/ObservedCall.d.ts +38 -41
- package/lib/ObservedCall.d.ts.map +1 -1
- package/lib/ObservedCall.js +97 -109
- package/lib/ObservedCertificate.d.ts +19 -0
- package/lib/ObservedCertificate.d.ts.map +1 -0
- package/lib/ObservedCertificate.js +38 -0
- package/lib/ObservedClient.d.ts +49 -127
- package/lib/ObservedClient.d.ts.map +1 -1
- package/lib/ObservedClient.js +201 -750
- package/lib/ObservedCodec.d.ts +22 -0
- package/lib/ObservedCodec.d.ts.map +1 -0
- package/lib/ObservedCodec.js +45 -0
- package/lib/ObservedDataChannel.d.ts +23 -69
- package/lib/ObservedDataChannel.d.ts.map +1 -1
- package/lib/ObservedDataChannel.js +67 -109
- package/lib/ObservedIceCandidate.d.ts +29 -0
- package/lib/ObservedIceCandidate.d.ts.map +1 -0
- package/lib/ObservedIceCandidate.js +59 -0
- package/lib/ObservedIceCandidatePair.d.ts +44 -0
- package/lib/ObservedIceCandidatePair.d.ts.map +1 -0
- package/lib/ObservedIceCandidatePair.js +111 -0
- package/lib/ObservedIceTransport.d.ts +32 -0
- package/lib/ObservedIceTransport.d.ts.map +1 -0
- package/lib/ObservedIceTransport.js +65 -0
- package/lib/ObservedInboundRtp.d.ts +92 -0
- package/lib/ObservedInboundRtp.d.ts.map +1 -0
- package/lib/ObservedInboundRtp.js +193 -0
- package/lib/ObservedInboundTrack.d.ts +29 -0
- package/lib/ObservedInboundTrack.d.ts.map +1 -0
- package/lib/ObservedInboundTrack.js +57 -0
- package/lib/ObservedMediaPlayout.d.ts +22 -0
- package/lib/ObservedMediaPlayout.d.ts.map +1 -0
- package/lib/ObservedMediaPlayout.js +42 -0
- package/lib/ObservedMediaSource.d.ts +28 -0
- package/lib/ObservedMediaSource.d.ts.map +1 -0
- package/lib/ObservedMediaSource.js +55 -0
- package/lib/ObservedOutboundRtp.d.ts +62 -0
- package/lib/ObservedOutboundRtp.d.ts.map +1 -0
- package/lib/ObservedOutboundRtp.js +144 -0
- package/lib/ObservedOutboundTrack.d.ts +29 -0
- package/lib/ObservedOutboundTrack.d.ts.map +1 -0
- package/lib/ObservedOutboundTrack.js +57 -0
- package/lib/ObservedPeerConnection.d.ts +128 -78
- package/lib/ObservedPeerConnection.d.ts.map +1 -1
- package/lib/ObservedPeerConnection.js +624 -357
- package/lib/ObservedPeerConnectionTransport.d.ts +17 -0
- package/lib/ObservedPeerConnectionTransport.d.ts.map +1 -0
- package/lib/ObservedPeerConnectionTransport.js +34 -0
- package/lib/ObservedRemoteInboundRtp.d.ts +30 -0
- package/lib/ObservedRemoteInboundRtp.d.ts.map +1 -0
- package/lib/ObservedRemoteInboundRtp.js +60 -0
- package/lib/ObservedRemoteOutboundRtp.d.ts +30 -0
- package/lib/ObservedRemoteOutboundRtp.d.ts.map +1 -0
- package/lib/ObservedRemoteOutboundRtp.js +60 -0
- package/lib/ObservedTURN.d.ts +31 -0
- package/lib/ObservedTURN.d.ts.map +1 -0
- package/lib/ObservedTURN.js +58 -0
- package/lib/ObservedTurnServer.d.ts +25 -0
- package/lib/ObservedTurnServer.d.ts.map +1 -0
- package/lib/ObservedTurnServer.js +59 -0
- package/lib/Observer.d.ts +31 -51
- package/lib/Observer.d.ts.map +1 -1
- package/lib/Observer.js +75 -229
- package/lib/common/Middleware.d.ts +10 -1
- package/lib/common/Middleware.d.ts.map +1 -1
- package/lib/common/Middleware.js +55 -36
- package/lib/common/logger.d.ts +8 -4
- package/lib/common/logger.d.ts.map +1 -1
- package/lib/common/logger.js +44 -68
- package/lib/common/types.d.ts +0 -21
- package/lib/common/types.d.ts.map +1 -1
- package/lib/common/types.js +1 -0
- package/lib/common/utils.d.ts +1 -0
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +13 -1
- package/lib/detectors/Detector.d.ts +5 -0
- package/lib/detectors/Detector.d.ts.map +1 -0
- package/lib/detectors/Detector.js +3 -0
- package/lib/detectors/Detectors.d.ts +11 -0
- package/lib/detectors/Detectors.d.ts.map +1 -0
- package/lib/detectors/Detectors.js +34 -0
- package/lib/index.d.ts +24 -25
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +41 -41
- package/lib/monitors/TurnUsageMonitor.d.ts +0 -52
- package/lib/monitors/TurnUsageMonitor.d.ts.map +1 -1
- package/lib/monitors/TurnUsageMonitor.js +145 -120
- package/lib/schema/ClientEventTypes.d.ts +33 -0
- package/lib/schema/ClientEventTypes.d.ts.map +1 -0
- package/lib/schema/ClientEventTypes.js +38 -0
- package/lib/schema/ClientMetaTypes.d.ts +34 -0
- package/lib/schema/ClientMetaTypes.d.ts.map +1 -0
- package/lib/schema/ClientMetaTypes.js +16 -0
- package/lib/schema/ClientSample.d.ts +1333 -0
- package/lib/schema/ClientSample.d.ts.map +1 -0
- package/lib/schema/ClientSample.js +4 -0
- package/lib/scores/CalculatedScore.d.ts +6 -0
- package/lib/scores/CalculatedScore.d.ts.map +1 -0
- package/lib/scores/DefaultCallScoreCalculator.d.ts +7 -0
- package/lib/scores/DefaultCallScoreCalculator.d.ts.map +1 -0
- package/lib/scores/DefaultCallScoreCalculator.js +21 -0
- package/lib/scores/ScoreCalculator.d.ts +4 -0
- package/lib/scores/ScoreCalculator.d.ts.map +1 -0
- package/lib/scores/ScoreCalculator.js +2 -0
- package/lib/utils/CallUpdater.d.ts +5 -0
- package/lib/utils/CallUpdater.d.ts.map +1 -0
- package/lib/utils/CallUpdater.js +2 -0
- package/lib/utils/OnAllClientCallUpdater.d.ts +16 -0
- package/lib/utils/OnAllClientCallUpdater.d.ts.map +1 -0
- package/lib/utils/OnAllClientCallUpdater.js +58 -0
- package/lib/utils/RemoteTrackResolver.d.ts +7 -0
- package/lib/utils/RemoteTrackResolver.d.ts.map +1 -0
- package/lib/utils/RemoteTrackResolver.js +2 -0
- package/lib/utils/onAnyClientCallUpdater.d.ts +14 -0
- package/lib/utils/onAnyClientCallUpdater.d.ts.map +1 -0
- package/lib/utils/onAnyClientCallUpdater.js +51 -0
- package/package.json +4 -4
- package/src/ObservedCall.ts +116 -166
- package/src/ObservedCertificate.ts +43 -0
- package/src/ObservedClient.ts +213 -1060
- package/src/ObservedCodec.ts +49 -0
- package/src/ObservedDataChannel.ts +68 -181
- package/src/ObservedIceCandidate.ts +64 -0
- package/src/ObservedIceCandidatePair.ts +118 -0
- package/src/ObservedIceTransport.ts +70 -0
- package/src/ObservedInboundRtp.ts +205 -0
- package/src/ObservedInboundTrack.ts +70 -0
- package/src/ObservedMediaPlayout.ts +49 -0
- package/src/ObservedMediaSource.ts +60 -0
- package/src/ObservedOutboundRtp.ts +156 -0
- package/src/ObservedOutboundTrack.ts +69 -0
- package/src/ObservedPeerConnection.ts +827 -405
- package/src/ObservedPeerConnectionTransport.ts +38 -0
- package/src/ObservedRemoteInboundRtp.ts +64 -0
- package/src/ObservedRemoteOutboundRtp.ts +65 -0
- package/src/ObservedTURN.ts +86 -0
- package/src/ObservedTurnServer.ts +72 -0
- package/src/Observer.ts +91 -302
- package/src/common/Middleware.ts +70 -42
- package/src/common/logger.ts +60 -69
- package/src/common/types.ts +0 -42
- package/src/common/utils.ts +12 -0
- package/src/detectors/Detector.ts +6 -0
- package/src/detectors/Detectors.ts +38 -0
- package/src/index.ts +24 -90
- package/src/monitors/TurnUsageMonitor.ts +164 -164
- package/src/schema/ClientEventTypes.ts +36 -0
- package/src/schema/ClientMetaTypes.ts +41 -0
- package/src/schema/ClientSample.ts +1682 -0
- package/src/scores/CalculatedScore.ts +6 -0
- package/src/scores/DefaultCallScoreCalculator.ts +23 -0
- package/src/scores/ScoreCalculator.ts +3 -0
- package/src/utils/CallUpdater.ts +5 -0
- package/src/utils/OnAllClientCallUpdater.ts +68 -0
- package/src/utils/RemoteTrackResolver.ts +12 -0
- package/src/utils/onAnyClientCallUpdater.ts +59 -0
- package/tsconfig.json +3 -3
- package/lib/ObservedICE.d.ts +0 -64
- package/lib/ObservedICE.d.ts.map +0 -1
- package/lib/ObservedICE.js +0 -141
- package/lib/ObservedInboundAudioTrack.d.ts +0 -96
- package/lib/ObservedInboundAudioTrack.d.ts.map +0 -1
- package/lib/ObservedInboundAudioTrack.js +0 -217
- package/lib/ObservedInboundVideoTrack.d.ts +0 -101
- package/lib/ObservedInboundVideoTrack.d.ts.map +0 -1
- package/lib/ObservedInboundVideoTrack.js +0 -232
- package/lib/ObservedOutboundAudioTrack.d.ts +0 -87
- package/lib/ObservedOutboundAudioTrack.d.ts.map +0 -1
- package/lib/ObservedOutboundAudioTrack.js +0 -186
- package/lib/ObservedOutboundVideoTrack.d.ts +0 -91
- package/lib/ObservedOutboundVideoTrack.d.ts.map +0 -1
- package/lib/ObservedOutboundVideoTrack.js +0 -193
- package/lib/ObservedSfu.d.ts +0 -59
- package/lib/ObservedSfu.d.ts.map +0 -1
- package/lib/ObservedSfu.js +0 -157
- package/lib/ObservedSfuInboundRtpPad.d.ts +0 -42
- package/lib/ObservedSfuInboundRtpPad.d.ts.map +0 -1
- package/lib/ObservedSfuInboundRtpPad.js +0 -71
- package/lib/ObservedSfuOutboundRtpPad.d.ts +0 -42
- package/lib/ObservedSfuOutboundRtpPad.d.ts.map +0 -1
- package/lib/ObservedSfuOutboundRtpPad.js +0 -72
- package/lib/ObservedSfuSctpChannel.d.ts +0 -42
- package/lib/ObservedSfuSctpChannel.d.ts.map +0 -1
- package/lib/ObservedSfuSctpChannel.js +0 -57
- package/lib/ObservedSfuTransport.d.ts +0 -58
- package/lib/ObservedSfuTransport.d.ts.map +0 -1
- package/lib/ObservedSfuTransport.js +0 -120
- package/lib/RemoteTrackAssigner.d.ts +0 -14
- package/lib/RemoteTrackAssigner.d.ts.map +0 -1
- package/lib/RemoteTrackAssigner.js +0 -52
- package/lib/ReportsCollector.d.ts +0 -109
- package/lib/ReportsCollector.d.ts.map +0 -1
- package/lib/ReportsCollector.js +0 -207
- package/lib/common/CalculatedScore.d.ts +0 -80
- package/lib/common/CalculatedScore.d.ts.map +0 -1
- package/lib/common/CalculatedScore.js +0 -162
- package/lib/common/CallEventType.d.ts +0 -63
- package/lib/common/CallEventType.d.ts.map +0 -1
- package/lib/common/CallEventType.js +0 -39
- package/lib/common/CallMetaReports.d.ts +0 -42
- package/lib/common/CallMetaReports.d.ts.map +0 -1
- package/lib/common/CallMetaReports.js +0 -36
- package/lib/common/QualityScoreUtils.d.ts +0 -1
- package/lib/common/QualityScoreUtils.d.ts.map +0 -1
- package/lib/common/QualityScoreUtils.js +0 -1
- package/lib/common/TypedEventEmitter.d.ts +0 -22
- package/lib/common/TypedEventEmitter.d.ts.map +0 -1
- package/lib/common/TypedEventEmitter.js +0 -11
- package/lib/common/callEventReports.d.ts +0 -10
- package/lib/common/callEventReports.d.ts.map +0 -1
- package/lib/common/callEventReports.js +0 -112
- package/lib/monitors/CallSummary.d.ts +0 -37
- package/lib/monitors/CallSummary.d.ts.map +0 -1
- package/lib/monitors/CallSummaryMonitor.d.ts +0 -32
- package/lib/monitors/CallSummaryMonitor.d.ts.map +0 -1
- package/lib/monitors/CallSummaryMonitor.js +0 -152
- package/lib/monitors/ClientIssueMonitor.d.ts +0 -32
- package/lib/monitors/ClientIssueMonitor.d.ts.map +0 -1
- package/lib/monitors/ClientIssueMonitor.js +0 -49
- package/lib/monitors/SfuServerMonitor.d.ts +0 -79
- package/lib/monitors/SfuServerMonitor.d.ts.map +0 -1
- package/lib/monitors/SfuServerMonitor.js +0 -198
- package/src/ObservedICE.ts +0 -237
- package/src/ObservedInboundAudioTrack.ts +0 -344
- package/src/ObservedInboundVideoTrack.ts +0 -361
- package/src/ObservedOutboundAudioTrack.ts +0 -307
- package/src/ObservedOutboundVideoTrack.ts +0 -319
- package/src/ObservedSfu.ts +0 -231
- package/src/ObservedSfuInboundRtpPad.ts +0 -106
- package/src/ObservedSfuOutboundRtpPad.ts +0 -107
- package/src/ObservedSfuSctpChannel.ts +0 -103
- package/src/ObservedSfuTransport.ts +0 -185
- package/src/RemoteTrackAssigner.ts +0 -68
- package/src/ReportsCollector.ts +0 -336
- package/src/common/CalculatedScore.ts +0 -188
- package/src/common/CallEventType.ts +0 -69
- package/src/common/CallMetaReports.ts +0 -82
- package/src/common/QualityScoreUtils.ts +0 -0
- package/src/common/TypedEventEmitter.ts +0 -32
- package/src/common/callEventReports.ts +0 -178
- package/src/monitors/CallSummary.ts +0 -38
- package/src/monitors/CallSummaryMonitor.ts +0 -192
- package/src/monitors/ClientIssueMonitor.ts +0 -88
- package/src/monitors/SfuServerMonitor.ts +0 -285
- /package/lib/{monitors/CallSummary.js → scores/CalculatedScore.js} +0 -0
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
import { ObservedPeerConnection } from '../ObservedPeerConnection';
|
|
3
|
-
|
|
4
|
-
export type SfuServerMonitorMetricsRecord = {
|
|
5
|
-
sfuId: string,
|
|
6
|
-
receivedPacketsPerSecond: number,
|
|
7
|
-
sentPacketsPerSecond: number,
|
|
8
|
-
receivingAudioBitrate: number,
|
|
9
|
-
receivingVideoBitrate: number,
|
|
10
|
-
sendingAudioBitrate: number,
|
|
11
|
-
sendingVideoBitrate: number,
|
|
12
|
-
numberOfPeerConnectionsRttLt50: number,
|
|
13
|
-
numberOfPeerConnectionsRttLt150: number,
|
|
14
|
-
numberOfPeerConnectionsRttLt300: number,
|
|
15
|
-
numberOfPeerConnectionsRttOver300: number,
|
|
16
|
-
numberOfPeerConnections: number,
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type SfuServerMonitorConfig = {
|
|
20
|
-
tooHighRttAlertSettings: {
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The threshold for the RTT that will trigger the alert
|
|
24
|
-
*/
|
|
25
|
-
threshold: 'rtt-gt-300' | 'rtt-gt-150' | 'rtt-gt-50',
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* The percentage of peer connections that need to be above the threshold to trigger the alert
|
|
29
|
-
*/
|
|
30
|
-
percentageOfPeerConnectionsHighWatermark: number,
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* The percentage of peer connections that need to be above the threshold to clear the alert
|
|
34
|
-
*/
|
|
35
|
-
percentageOfPeerConnectionsLowWatermark: number,
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The minimum number of clients that need to be connected to trigger the alert
|
|
39
|
-
*/
|
|
40
|
-
minNumberOfPeerConnections: number,
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export type SfuServerMonitorEvents = {
|
|
45
|
-
'metrics': [SfuServerMonitorMetricsRecord],
|
|
46
|
-
'high-rtt-started': [{
|
|
47
|
-
sfuId: string,
|
|
48
|
-
threshold: SfuServerMonitorConfig['tooHighRttAlertSettings']['threshold'],
|
|
49
|
-
percentageOfPeerConnections: number,
|
|
50
|
-
}],
|
|
51
|
-
'high-rtt-cleared': [{
|
|
52
|
-
sfuId: string,
|
|
53
|
-
}],
|
|
54
|
-
'too-many-clients': [{ ip: string, numberOfClients: number }],
|
|
55
|
-
'close': [],
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
type PeerConnectionRecord = {
|
|
59
|
-
lastSendingPacketsPerSecond: number,
|
|
60
|
-
lastReceivingPacketsPerSecond: number,
|
|
61
|
-
lastSendingAudioBitrate: number,
|
|
62
|
-
lastSendingVideoBitrate: number,
|
|
63
|
-
lastReceivingAudioBitrate: number,
|
|
64
|
-
lastReceivingVideoBitrate: number,
|
|
65
|
-
lastAvgRttInMs?: number,
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export declare interface SfuServerMonitor {
|
|
69
|
-
on<U extends keyof SfuServerMonitorEvents>(event: U, listener: (...args: SfuServerMonitorEvents[U]) => void): this;
|
|
70
|
-
off<U extends keyof SfuServerMonitorEvents>(event: U, listener: (...args: SfuServerMonitorEvents[U]) => void): this;
|
|
71
|
-
once<U extends keyof SfuServerMonitorEvents>(event: U, listener: (...args: SfuServerMonitorEvents[U]) => void): this;
|
|
72
|
-
emit<U extends keyof SfuServerMonitorEvents>(event: U, ...args: SfuServerMonitorEvents[U]): boolean;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export class SfuServerMonitor extends EventEmitter {
|
|
76
|
-
private _closed = false;
|
|
77
|
-
private readonly _peerConnections = new Map<string, PeerConnectionRecord>();
|
|
78
|
-
private readonly _metrics = new Map<string, SfuServerMonitorMetricsRecord>();
|
|
79
|
-
private readonly _rttAlertsOn = new Set<string>();
|
|
80
|
-
|
|
81
|
-
public constructor(
|
|
82
|
-
public readonly config: SfuServerMonitorConfig
|
|
83
|
-
) {
|
|
84
|
-
super();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
public get stats() {
|
|
88
|
-
return Array.from(this._metrics.values());
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
public get closed() {
|
|
92
|
-
return this._closed;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
public close() {
|
|
96
|
-
if (this.closed) return;
|
|
97
|
-
this._closed = true;
|
|
98
|
-
this._peerConnections.clear();
|
|
99
|
-
this._metrics.clear();
|
|
100
|
-
this._rttAlertsOn.clear();
|
|
101
|
-
|
|
102
|
-
this.emit('close');
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
public addPeerConnection(peerConnection: ObservedPeerConnection) {
|
|
106
|
-
if (this.closed) return;
|
|
107
|
-
let registered = false;
|
|
108
|
-
|
|
109
|
-
const onUpdate = () => {
|
|
110
|
-
const sfuId = peerConnection.client.sfuId;
|
|
111
|
-
const peerConnectionRecord = this._peerConnections.get(peerConnection.peerConnectionId);
|
|
112
|
-
|
|
113
|
-
if (!sfuId) return;
|
|
114
|
-
|
|
115
|
-
let metrics = this._metrics.get(sfuId);
|
|
116
|
-
|
|
117
|
-
if (!metrics) {
|
|
118
|
-
metrics = {
|
|
119
|
-
sfuId,
|
|
120
|
-
receivedPacketsPerSecond: 0,
|
|
121
|
-
sentPacketsPerSecond: 0,
|
|
122
|
-
receivingAudioBitrate: 0,
|
|
123
|
-
receivingVideoBitrate: 0,
|
|
124
|
-
sendingAudioBitrate: 0,
|
|
125
|
-
sendingVideoBitrate: 0,
|
|
126
|
-
numberOfPeerConnectionsRttLt150: 0,
|
|
127
|
-
numberOfPeerConnectionsRttLt300: 0,
|
|
128
|
-
numberOfPeerConnectionsRttLt50: 0,
|
|
129
|
-
numberOfPeerConnectionsRttOver300: 0,
|
|
130
|
-
numberOfPeerConnections: 0,
|
|
131
|
-
};
|
|
132
|
-
this._metrics.set(sfuId, metrics);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (!registered) {
|
|
136
|
-
registered = true;
|
|
137
|
-
++metrics.numberOfPeerConnections;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (peerConnectionRecord) {
|
|
141
|
-
this._subtract(metrics, peerConnectionRecord);
|
|
142
|
-
}
|
|
143
|
-
this._increase(metrics, peerConnection);
|
|
144
|
-
|
|
145
|
-
this._peerConnections.set(peerConnection.peerConnectionId, {
|
|
146
|
-
lastSendingAudioBitrate: peerConnection.sendingAudioBitrate,
|
|
147
|
-
lastSendingVideoBitrate: peerConnection.sendingVideoBitrate,
|
|
148
|
-
lastReceivingAudioBitrate: peerConnection.receivingAudioBitrate,
|
|
149
|
-
lastReceivingVideoBitrate: peerConnection.receivingVideoBitrate,
|
|
150
|
-
lastAvgRttInMs: peerConnection.avgRttInMs,
|
|
151
|
-
lastReceivingPacketsPerSecond: peerConnection.receivingPacketsPerSecond,
|
|
152
|
-
lastSendingPacketsPerSecond: peerConnection.sendingPacketsPerSecond,
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
this._checkHighRttForClients(metrics);
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
peerConnection.once('close', () => {
|
|
159
|
-
const address = peerConnection.ICE.selectedRemoteCandidate?.address ?? '';
|
|
160
|
-
const peerConnectionRecord = this._peerConnections.get(peerConnection.peerConnectionId);
|
|
161
|
-
const metrics = this._metrics.get(address);
|
|
162
|
-
|
|
163
|
-
if (metrics) {
|
|
164
|
-
if (peerConnectionRecord) {
|
|
165
|
-
this._subtract(metrics, peerConnectionRecord);
|
|
166
|
-
}
|
|
167
|
-
if (registered) {
|
|
168
|
-
if (--metrics.numberOfPeerConnections === 0) {
|
|
169
|
-
this._metrics.delete(address);
|
|
170
|
-
this._rttAlertsOn.delete(address);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
this._peerConnections.delete(peerConnection.peerConnectionId);
|
|
175
|
-
|
|
176
|
-
peerConnection.off('update', onUpdate);
|
|
177
|
-
});
|
|
178
|
-
peerConnection.on('update', onUpdate);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
private _checkHighRttForClients(metrics: SfuServerMonitorMetricsRecord) {
|
|
182
|
-
const totalClients = metrics.numberOfPeerConnections;
|
|
183
|
-
const {
|
|
184
|
-
percentageOfPeerConnectionsHighWatermark,
|
|
185
|
-
percentageOfPeerConnectionsLowWatermark,
|
|
186
|
-
minNumberOfPeerConnections,
|
|
187
|
-
threshold
|
|
188
|
-
} = this.config.tooHighRttAlertSettings;
|
|
189
|
-
|
|
190
|
-
if (metrics.numberOfPeerConnections < minNumberOfPeerConnections) return;
|
|
191
|
-
|
|
192
|
-
const rttLt150Percentage = (metrics.numberOfPeerConnectionsRttLt150 + metrics.numberOfPeerConnectionsRttLt300 + metrics.numberOfPeerConnectionsRttOver300) / totalClients;
|
|
193
|
-
const rttLt300Percentage = (metrics.numberOfPeerConnectionsRttLt150 + metrics.numberOfPeerConnectionsRttLt300) / totalClients;
|
|
194
|
-
const rttOver300Percentage = metrics.numberOfPeerConnectionsRttOver300 / totalClients;
|
|
195
|
-
const alertOn = this._rttAlertsOn.has(metrics.sfuId);
|
|
196
|
-
|
|
197
|
-
switch (threshold) {
|
|
198
|
-
case 'rtt-gt-50': {
|
|
199
|
-
if (!alertOn && percentageOfPeerConnectionsHighWatermark < rttLt150Percentage) {
|
|
200
|
-
this.emit('high-rtt-started', {
|
|
201
|
-
sfuId: metrics.sfuId,
|
|
202
|
-
threshold: 'rtt-gt-50',
|
|
203
|
-
percentageOfPeerConnections: rttLt150Percentage
|
|
204
|
-
});
|
|
205
|
-
this._rttAlertsOn.add(metrics.sfuId);
|
|
206
|
-
} else if (alertOn && rttLt150Percentage < percentageOfPeerConnectionsLowWatermark) {
|
|
207
|
-
this.emit('high-rtt-cleared', { sfuId: metrics.sfuId });
|
|
208
|
-
this._rttAlertsOn.delete(metrics.sfuId);
|
|
209
|
-
}
|
|
210
|
-
break;
|
|
211
|
-
}
|
|
212
|
-
case 'rtt-gt-150': {
|
|
213
|
-
if (!alertOn && percentageOfPeerConnectionsHighWatermark < rttLt300Percentage) {
|
|
214
|
-
this.emit('high-rtt-started', {
|
|
215
|
-
sfuId: metrics.sfuId,
|
|
216
|
-
threshold: 'rtt-gt-150',
|
|
217
|
-
percentageOfPeerConnections: rttLt300Percentage
|
|
218
|
-
});
|
|
219
|
-
this._rttAlertsOn.add(metrics.sfuId);
|
|
220
|
-
} else if (alertOn && rttLt300Percentage < percentageOfPeerConnectionsLowWatermark) {
|
|
221
|
-
this.emit('high-rtt-cleared', { sfuId: metrics.sfuId });
|
|
222
|
-
this._rttAlertsOn.delete(metrics.sfuId);
|
|
223
|
-
}
|
|
224
|
-
break;
|
|
225
|
-
}
|
|
226
|
-
case 'rtt-gt-300': {
|
|
227
|
-
if (!alertOn && percentageOfPeerConnectionsHighWatermark < rttOver300Percentage) {
|
|
228
|
-
this.emit('high-rtt-started', {
|
|
229
|
-
sfuId: metrics.sfuId,
|
|
230
|
-
threshold: 'rtt-gt-300',
|
|
231
|
-
percentageOfPeerConnections: rttOver300Percentage
|
|
232
|
-
});
|
|
233
|
-
this._rttAlertsOn.add(metrics.sfuId);
|
|
234
|
-
} else if (alertOn && rttOver300Percentage < percentageOfPeerConnectionsLowWatermark) {
|
|
235
|
-
this.emit('high-rtt-cleared', { sfuId: metrics.sfuId });
|
|
236
|
-
this._rttAlertsOn.delete(metrics.sfuId);
|
|
237
|
-
}
|
|
238
|
-
break;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
private _increase(metrics: SfuServerMonitorMetricsRecord, peerConnection: ObservedPeerConnection) {
|
|
244
|
-
metrics.sendingAudioBitrate += peerConnection.receivingAudioBitrate;
|
|
245
|
-
metrics.sendingVideoBitrate += peerConnection.receivingVideoBitrate;
|
|
246
|
-
metrics.receivingAudioBitrate += peerConnection.sendingAudioBitrate;
|
|
247
|
-
metrics.receivingVideoBitrate += peerConnection.sendingVideoBitrate;
|
|
248
|
-
metrics.receivedPacketsPerSecond += peerConnection.sendingPacketsPerSecond;
|
|
249
|
-
metrics.sentPacketsPerSecond += peerConnection.receivingPacketsPerSecond;
|
|
250
|
-
|
|
251
|
-
if (peerConnection.avgRttInMs) {
|
|
252
|
-
if (peerConnection.avgRttInMs < 50) {
|
|
253
|
-
++metrics.numberOfPeerConnectionsRttLt50;
|
|
254
|
-
} else if (peerConnection.avgRttInMs < 150) {
|
|
255
|
-
++metrics.numberOfPeerConnectionsRttLt150;
|
|
256
|
-
} else if (peerConnection.avgRttInMs < 300) {
|
|
257
|
-
++metrics.numberOfPeerConnectionsRttLt300;
|
|
258
|
-
} else {
|
|
259
|
-
++metrics.numberOfPeerConnectionsRttOver300;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
private _subtract(metrics: SfuServerMonitorMetricsRecord, peerConnectionRecord: PeerConnectionRecord) {
|
|
265
|
-
metrics.sendingAudioBitrate -= peerConnectionRecord.lastReceivingAudioBitrate;
|
|
266
|
-
metrics.sendingVideoBitrate -= peerConnectionRecord.lastReceivingVideoBitrate;
|
|
267
|
-
metrics.receivingAudioBitrate -= peerConnectionRecord.lastSendingAudioBitrate;
|
|
268
|
-
metrics.receivingVideoBitrate -= peerConnectionRecord.lastSendingVideoBitrate;
|
|
269
|
-
metrics.receivedPacketsPerSecond -= peerConnectionRecord.lastSendingPacketsPerSecond;
|
|
270
|
-
metrics.sentPacketsPerSecond -= peerConnectionRecord.lastReceivingPacketsPerSecond;
|
|
271
|
-
|
|
272
|
-
if (peerConnectionRecord.lastAvgRttInMs) {
|
|
273
|
-
if (peerConnectionRecord.lastAvgRttInMs < 50) {
|
|
274
|
-
--metrics.numberOfPeerConnectionsRttLt50;
|
|
275
|
-
} else if (peerConnectionRecord.lastAvgRttInMs < 150) {
|
|
276
|
-
--metrics.numberOfPeerConnectionsRttLt150;
|
|
277
|
-
} else if (peerConnectionRecord.lastAvgRttInMs < 300) {
|
|
278
|
-
--metrics.numberOfPeerConnectionsRttLt300;
|
|
279
|
-
} else {
|
|
280
|
-
--metrics.numberOfPeerConnectionsRttOver300;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
}
|
|
File without changes
|