@observertc/observer-js 0.42.8 → 1.0.1-198a187.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 +63 -43
- package/lib/ObservedCall.d.ts.map +1 -1
- package/lib/ObservedCall.js +188 -108
- package/lib/ObservedCallEventMonitor.d.ts +104 -0
- package/lib/ObservedCallEventMonitor.d.ts.map +1 -0
- package/lib/ObservedCallEventMonitor.js +314 -0
- package/lib/ObservedCallSummary.d.ts +18 -0
- package/lib/ObservedCallSummary.d.ts.map +1 -0
- 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 +80 -130
- package/lib/ObservedClient.d.ts.map +1 -1
- package/lib/ObservedClient.js +584 -744
- package/lib/ObservedClientEventMonitor.d.ts +89 -0
- package/lib/ObservedClientEventMonitor.d.ts.map +1 -0
- package/lib/ObservedClientEventMonitor.js +247 -0
- package/lib/ObservedClientSummary.d.ts +23 -0
- package/lib/ObservedClientSummary.d.ts.map +1 -0
- package/lib/ObservedClientSummary.js +2 -0
- 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 +25 -69
- package/lib/ObservedDataChannel.d.ts.map +1 -1
- package/lib/ObservedDataChannel.js +69 -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 +45 -0
- package/lib/ObservedIceCandidatePair.d.ts.map +1 -0
- package/lib/ObservedIceCandidatePair.js +127 -0
- package/lib/ObservedIceTransport.d.ts +36 -0
- package/lib/ObservedIceTransport.d.ts.map +1 -0
- package/lib/ObservedIceTransport.js +93 -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 +32 -0
- package/lib/ObservedInboundTrack.d.ts.map +1 -0
- package/lib/ObservedInboundTrack.js +60 -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 +32 -0
- package/lib/ObservedOutboundTrack.d.ts.map +1 -0
- package/lib/ObservedOutboundTrack.js +60 -0
- package/lib/ObservedPeerConnection.d.ts +154 -80
- package/lib/ObservedPeerConnection.d.ts.map +1 -1
- package/lib/ObservedPeerConnection.js +709 -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 +49 -54
- package/lib/Observer.d.ts.map +1 -1
- package/lib/Observer.js +138 -225
- package/lib/ObserverEventMonitor.d.ts +138 -0
- package/lib/ObserverEventMonitor.d.ts.map +1 -0
- package/lib/ObserverEventMonitor.js +433 -0
- package/lib/ObserverSummary.d.ts +13 -0
- package/lib/ObserverSummary.d.ts.map +1 -0
- package/lib/ObserverSummary.js +2 -0
- 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 +3 -1
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +23 -3
- 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 +26 -24
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +45 -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 +228 -0
- package/lib/schema/ClientEventTypes.d.ts.map +1 -0
- package/lib/schema/ClientEventTypes.js +41 -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/CalculatedScore.js +2 -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/updaters/CallUpdater.d.ts +5 -0
- package/lib/updaters/CallUpdater.d.ts.map +1 -0
- package/lib/updaters/CallUpdater.js +2 -0
- package/lib/updaters/ObserverUpdater.d.ts +5 -0
- package/lib/updaters/ObserverUpdater.d.ts.map +1 -0
- package/lib/updaters/ObserverUpdater.js +2 -0
- package/lib/updaters/OnAllCallObserverUpdater.d.ts +15 -0
- package/lib/updaters/OnAllCallObserverUpdater.d.ts.map +1 -0
- package/lib/updaters/OnAllCallObserverUpdater.js +50 -0
- package/lib/updaters/OnAllClientCallUpdater.d.ts +15 -0
- package/lib/updaters/OnAllClientCallUpdater.d.ts.map +1 -0
- package/lib/updaters/OnAllClientCallUpdater.js +53 -0
- package/lib/updaters/OnAnyCallObserverUpdater.d.ts +12 -0
- package/lib/updaters/OnAnyCallObserverUpdater.d.ts.map +1 -0
- package/lib/updaters/OnAnyCallObserverUpdater.js +37 -0
- package/lib/updaters/OnAnyClientCallUpdater.d.ts +12 -0
- package/lib/updaters/OnAnyClientCallUpdater.d.ts.map +1 -0
- package/lib/updaters/OnAnyClientCallUpdater.js +36 -0
- package/lib/updaters/OnIntervalUpdater.d.ts +10 -0
- package/lib/updaters/OnIntervalUpdater.d.ts.map +1 -0
- package/lib/updaters/OnIntervalUpdater.js +17 -0
- package/lib/updaters/Updater.d.ts +6 -0
- package/lib/updaters/Updater.d.ts.map +1 -0
- package/lib/updaters/Updater.js +2 -0
- package/lib/utils/MediasoupRemoteTrackResolver.d.ts +25 -0
- package/lib/utils/MediasoupRemoteTrackResolver.d.ts.map +1 -0
- package/lib/utils/MediasoupRemoteTrackResolver.js +110 -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/package.json +4 -4
- package/src/ObservedCall.ts +276 -164
- package/src/ObservedCallEventMonitor.ts +392 -0
- package/src/ObservedCallSummary.ts +22 -0
- package/src/ObservedCertificate.ts +43 -0
- package/src/ObservedClient.ts +630 -1006
- package/src/ObservedClientEventMonitor.ts +301 -0
- package/src/ObservedClientSummary.ts +24 -0
- package/src/ObservedCodec.ts +49 -0
- package/src/ObservedDataChannel.ts +71 -181
- package/src/ObservedIceCandidate.ts +64 -0
- package/src/ObservedIceCandidatePair.ts +134 -0
- package/src/ObservedIceTransport.ts +99 -0
- package/src/ObservedInboundRtp.ts +205 -0
- package/src/ObservedInboundTrack.ts +75 -0
- package/src/ObservedMediaPlayout.ts +49 -0
- package/src/ObservedMediaSource.ts +60 -0
- package/src/ObservedOutboundRtp.ts +156 -0
- package/src/ObservedOutboundTrack.ts +74 -0
- package/src/ObservedPeerConnection.ts +917 -402
- 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 +187 -296
- package/src/ObserverEventMonitor.ts +551 -0
- package/src/ObserverSummary.ts +15 -0
- 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 +24 -2
- package/src/detectors/Detector.ts +6 -0
- package/src/detectors/Detectors.ts +38 -0
- package/src/index.ts +26 -88
- package/src/monitors/TurnUsageMonitor.ts +164 -164
- package/src/schema/ClientEventTypes.ts +280 -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/updaters/CallUpdater.ts +5 -0
- package/src/updaters/ObserverUpdater.ts +5 -0
- package/src/updaters/OnAllCallObserverUpdater.ts +59 -0
- package/src/updaters/OnAllClientCallUpdater.ts +61 -0
- package/src/updaters/OnAnyCallObserverUpdater.ts +41 -0
- package/src/updaters/OnAnyClientCallUpdater.ts +39 -0
- package/src/updaters/OnIntervalUpdater.ts +19 -0
- package/src/updaters/Updater.ts +5 -0
- package/src/utils/MediasoupRemoteTrackResolver.ts +155 -0
- package/src/utils/RemoteTrackResolver.ts +12 -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 → ObservedCallSummary.js} +0 -0
package/src/ObservedCall.ts
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
-
import { ObservedClient,
|
|
2
|
+
import { ObservedClient, ObservedClientSettings } from './ObservedClient';
|
|
3
3
|
import { Observer } from './Observer';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
import { ScoreCalculator } from './scores/ScoreCalculator';
|
|
5
|
+
import { CalculatedScore } from './scores/CalculatedScore';
|
|
6
|
+
import { DefaultCallScoreCalculator } from './scores/DefaultCallScoreCalculator';
|
|
7
|
+
import { Detectors } from './detectors/Detectors';
|
|
8
|
+
import { RemoteTrackResolver } from './utils/RemoteTrackResolver';
|
|
9
|
+
import { OnAllClientCallUpdater } from './updaters/OnAllClientCallUpdater';
|
|
10
|
+
import { Updater } from './updaters/Updater';
|
|
11
|
+
import { OnIntervalUpdater } from './updaters/OnIntervalUpdater';
|
|
12
|
+
import { OnAnyClientCallUpdater } from './updaters/OnAnyClientCallUpdater';
|
|
13
|
+
import { ObservedCallEventMonitor } from './ObservedCallEventMonitor';
|
|
14
|
+
|
|
15
|
+
export type ObservedCallSettings<AppData extends Record<string, unknown> = Record<string, unknown>> = {
|
|
16
16
|
callId: string;
|
|
17
|
+
appData?: AppData;
|
|
18
|
+
remoteTrackResolvePolicy?: 'p2p' | 'mediasoup-sfu',
|
|
19
|
+
updatePolicy?: 'update-on-any-client-updated' | 'update-when-all-client-updated' | 'update-on-interval',
|
|
20
|
+
updateIntervalInMs?: number,
|
|
17
21
|
};
|
|
18
22
|
|
|
19
23
|
export type ObservedCallEvents = {
|
|
20
24
|
update: [],
|
|
21
25
|
newclient: [ObservedClient],
|
|
22
|
-
callevent: [Omit<CallEventReport, 'callId' | 'serviceId' | 'roomId'>],
|
|
23
26
|
empty: [],
|
|
27
|
+
'not-empty': [],
|
|
24
28
|
close: [],
|
|
25
29
|
}
|
|
26
30
|
|
|
@@ -32,195 +36,303 @@ export declare interface ObservedCall {
|
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
export class ObservedCall<AppData extends Record<string, unknown> = Record<string, unknown>> extends EventEmitter {
|
|
35
|
-
public readonly
|
|
36
|
-
|
|
37
|
-
public
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
public readonly detectors: Detectors;
|
|
40
|
+
public updater?: Updater;
|
|
41
|
+
public scoreCalculator: ScoreCalculator;
|
|
42
|
+
public readonly callId: string;
|
|
43
|
+
public readonly observedClients = new Map<string, ObservedClient>();
|
|
44
|
+
public readonly clientsUsedTurn = new Set<string>();
|
|
45
|
+
public readonly calculatedScore: CalculatedScore = {
|
|
46
|
+
weight: 1,
|
|
47
|
+
value: undefined,
|
|
48
|
+
};
|
|
49
|
+
public remoteTrackResolver?: RemoteTrackResolver;
|
|
40
50
|
|
|
41
|
-
public
|
|
42
|
-
|
|
43
|
-
|
|
51
|
+
public totalAddedClients = 0;
|
|
52
|
+
public totalRemovedClients = 0;
|
|
53
|
+
|
|
54
|
+
public totalClientsReceivedAudioBytes = 0;
|
|
55
|
+
public totalClientsReceivedVideoBytes = 0;
|
|
56
|
+
public totalClientsReceivedDataChannelBytes = 0;
|
|
57
|
+
public totalClientsReceivedBytes = 0;
|
|
58
|
+
|
|
59
|
+
public totalClientsSentAudioBytes = 0;
|
|
60
|
+
public totalClientsSentDataChannelBytes = 0;
|
|
61
|
+
public totalClientsSentVideoBytes = 0;
|
|
62
|
+
public totalClientsSentBytes = 0;
|
|
63
|
+
|
|
64
|
+
public totalRttLt50Measurements = 0;
|
|
65
|
+
public totalRttLt150Measurements = 0;
|
|
66
|
+
public totalRttLt300Measurements = 0;
|
|
67
|
+
public totalRttGtOrEq300Measurements = 0;
|
|
68
|
+
|
|
69
|
+
public numberOfIssues = 0;
|
|
70
|
+
public numberOfPeerConnections = 0;
|
|
71
|
+
public numberOfInboundRtpStreams = 0;
|
|
72
|
+
public numberOfOutboundRtpStreams = 0;
|
|
73
|
+
public numberOfDataChannels = 0;
|
|
74
|
+
|
|
75
|
+
public maxNumberOfClients = 0;
|
|
76
|
+
public deltaNumberOfIssues = 0;
|
|
77
|
+
|
|
78
|
+
public deltaRttLt50Measurements = 0;
|
|
79
|
+
public deltaRttLt150Measurements = 0;
|
|
80
|
+
public deltaRttLt300Measurements = 0;
|
|
81
|
+
public deltaRttGtOrEq300Measurements = 0;
|
|
82
|
+
|
|
83
|
+
public appData: AppData;
|
|
84
|
+
public closed = false;
|
|
85
|
+
public startedAt?: number;
|
|
86
|
+
public endedAt?: number;
|
|
87
|
+
public closedAt?: number;
|
|
88
|
+
|
|
89
|
+
private _callStartedEvent: {
|
|
90
|
+
emitted: boolean,
|
|
91
|
+
timer?: ReturnType<typeof setTimeout>,
|
|
92
|
+
};
|
|
93
|
+
private _callEndedEvent: {
|
|
94
|
+
emitted: boolean
|
|
44
95
|
};
|
|
45
|
-
|
|
46
|
-
public readonly sfuStreamIdToOutboundAudioTrack = new Map<string | number, ObservedOutboundAudioTrack>();
|
|
47
|
-
public readonly sfuStreamIdToOutboundVideoTrack = new Map<string | number, ObservedOutboundVideoTrack>();
|
|
48
|
-
private _closed = false;
|
|
49
|
-
// this changes as clients emitting their joined event, as the call starts when the first client joins
|
|
50
|
-
public started?: number;
|
|
51
|
-
// this changes as clients emitting their left event, as the call ends when the last client leaves
|
|
52
|
-
public ended?: number;
|
|
53
|
-
|
|
54
|
-
public observationUpdated = Date.now();
|
|
55
|
-
public observationEnded?: number;
|
|
56
|
-
public readonly observationStarted = Date.now();
|
|
57
96
|
|
|
58
97
|
public constructor(
|
|
59
|
-
|
|
98
|
+
settings: ObservedCallSettings<AppData>,
|
|
60
99
|
public readonly observer: Observer,
|
|
61
|
-
public readonly appData: AppData,
|
|
62
100
|
) {
|
|
63
101
|
super();
|
|
64
102
|
this.setMaxListeners(Infinity);
|
|
65
|
-
}
|
|
66
103
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
104
|
+
this.callId = settings.callId;
|
|
105
|
+
this.appData = settings.appData ?? {} as AppData;
|
|
106
|
+
this.scoreCalculator = new DefaultCallScoreCalculator(this);
|
|
107
|
+
this.detectors = new Detectors();
|
|
108
|
+
|
|
109
|
+
if (settings.updateIntervalInMs) {
|
|
110
|
+
if (settings.updatePolicy !== 'update-on-interval') {
|
|
111
|
+
throw new Error('updatePolicy must be update-on-interval if updateIntervalInMs is set in config');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
switch (settings.updatePolicy) {
|
|
115
|
+
case 'update-on-any-client-updated':
|
|
116
|
+
this.updater = new OnAllClientCallUpdater(this);
|
|
117
|
+
break;
|
|
118
|
+
case 'update-when-all-client-updated':
|
|
119
|
+
this.updater = new OnAnyClientCallUpdater(this);
|
|
120
|
+
break;
|
|
121
|
+
case 'update-on-interval':
|
|
122
|
+
if (!settings.updateIntervalInMs) {
|
|
123
|
+
throw new Error('updateIntervalInMs setting in config must be set if updatePolicy is update-on-interval');
|
|
124
|
+
}
|
|
125
|
+
this.updater = new OnIntervalUpdater(
|
|
126
|
+
settings.updateIntervalInMs,
|
|
127
|
+
this.update.bind(this),
|
|
128
|
+
);
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
71
131
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
132
|
+
switch (settings.remoteTrackResolvePolicy) {
|
|
133
|
+
case 'mediasoup-sfu':
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
75
136
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
137
|
+
this._callStartedEvent = {
|
|
138
|
+
emitted: false,
|
|
139
|
+
};
|
|
140
|
+
this._callEndedEvent = {
|
|
141
|
+
emitted: false,
|
|
142
|
+
};
|
|
79
143
|
}
|
|
80
144
|
|
|
81
|
-
public get
|
|
82
|
-
|
|
83
|
-
return this._model.callId!;
|
|
145
|
+
public get numberOfClients() {
|
|
146
|
+
return this.observedClients.size;
|
|
84
147
|
}
|
|
85
148
|
|
|
86
|
-
public get
|
|
87
|
-
return this.
|
|
149
|
+
public get score() {
|
|
150
|
+
return this.calculatedScore.value;
|
|
88
151
|
}
|
|
89
152
|
|
|
90
|
-
public
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return this._scoreData?.score;
|
|
95
|
-
} else if (this.clients.size < 1) {
|
|
96
|
-
return {
|
|
97
|
-
remarks: [ {
|
|
98
|
-
severity: 'none',
|
|
99
|
-
text: 'No clients',
|
|
100
|
-
} ],
|
|
101
|
-
score: 5.0,
|
|
102
|
-
timestamp: now,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
const scores = [ ...this.clients.values() ].map((client) => client.score?.score ?? 5.0);
|
|
106
|
-
|
|
107
|
-
this._scoreData = {
|
|
108
|
-
score: {
|
|
109
|
-
remarks: [],
|
|
110
|
-
score: getMedian(scores),
|
|
111
|
-
timestamp: now,
|
|
112
|
-
},
|
|
113
|
-
calculated: now,
|
|
114
|
-
};
|
|
153
|
+
public close() {
|
|
154
|
+
if (this.closed) return;
|
|
155
|
+
this.update(); // last update before closing
|
|
156
|
+
this.closed = true;
|
|
115
157
|
|
|
116
|
-
|
|
117
|
-
}
|
|
158
|
+
this.updater?.close();
|
|
118
159
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
160
|
+
let minSampleTimestamps: number | undefined;
|
|
161
|
+
let maxSampleTimestamps: number | undefined;
|
|
122
162
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
this._closed = true;
|
|
163
|
+
for (const client of this.observedClients.values()) {
|
|
164
|
+
client.close();
|
|
126
165
|
|
|
127
|
-
|
|
166
|
+
if (client.joinedAt) minSampleTimestamps = Math.min(minSampleTimestamps ?? client.joinedAt, client.joinedAt);
|
|
167
|
+
if (client.leftAt) maxSampleTimestamps = Math.max(maxSampleTimestamps ?? client.leftAt, client.leftAt);
|
|
168
|
+
}
|
|
128
169
|
|
|
129
|
-
this.
|
|
130
|
-
|
|
131
|
-
this.emit('close');
|
|
132
|
-
}
|
|
170
|
+
if (this.startedAt === undefined) this.startedAt = minSampleTimestamps;
|
|
171
|
+
if (this.endedAt === undefined) this.endedAt = maxSampleTimestamps;
|
|
133
172
|
|
|
134
|
-
|
|
135
|
-
this.
|
|
136
|
-
...params,
|
|
137
|
-
serviceId: this.serviceId,
|
|
138
|
-
roomId: this.roomId,
|
|
139
|
-
callId: this.callId,
|
|
140
|
-
timestamp: params.timestamp ?? Date.now(),
|
|
141
|
-
});
|
|
173
|
+
this.closedAt = Date.now();
|
|
174
|
+
this.emit('close');
|
|
142
175
|
}
|
|
143
176
|
|
|
144
|
-
public
|
|
145
|
-
|
|
146
|
-
// in case we generate the CLIENT_JOINED report we can set the timestamp of the event
|
|
147
|
-
// in that case we should set the client.left to the timestamp of the leaving.
|
|
148
|
-
// by default the timestamp is set to the current time
|
|
149
|
-
joinedTimestamp?: number,
|
|
150
|
-
createClientJoinedReport?: boolean,
|
|
151
|
-
createClientLeftReport?: boolean,
|
|
152
|
-
}) {
|
|
153
|
-
if (this._closed) throw new Error(`Call ${this.callId} is closed`);
|
|
154
|
-
|
|
155
|
-
const {
|
|
156
|
-
appData,
|
|
157
|
-
createClientJoinedReport,
|
|
158
|
-
createClientLeftReport,
|
|
159
|
-
joinedTimestamp = Date.now(),
|
|
160
|
-
...model
|
|
161
|
-
} = config;
|
|
177
|
+
public getObservedClient<ClientAppData extends Record<string, unknown> = Record<string, unknown>>(clientId: string): ObservedClient<ClientAppData> | undefined {
|
|
178
|
+
if (this.closed || !this.observedClients.has(clientId)) return;
|
|
162
179
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
this.observationUpdated = Date.now();
|
|
166
|
-
if (result.joined) {
|
|
167
|
-
if (this.started === undefined || result.joined < this.started) {
|
|
168
|
-
this.started = result.joined;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
if (result.left) {
|
|
172
|
-
if (this.ended === undefined || result.left > this.ended) {
|
|
173
|
-
this.ended = result.left;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
180
|
+
return this.observedClients.get(clientId) as ObservedClient<ClientAppData>;
|
|
181
|
+
}
|
|
176
182
|
|
|
177
|
-
|
|
183
|
+
public createObservedClient<ClientAppData extends Record<string, unknown> = Record<string, unknown>>(settings: ObservedClientSettings<ClientAppData>): ObservedClient<ClientAppData> {
|
|
184
|
+
if (this.closed) throw new Error(`Call ${this.callId} is closed`);
|
|
185
|
+
if (this.observedClients.has(settings.clientId)) throw new Error(`Client with id ${settings.clientId} already exists`);
|
|
178
186
|
|
|
179
|
-
|
|
180
|
-
|
|
187
|
+
const result = new ObservedClient<ClientAppData>(settings, this);
|
|
188
|
+
const wasEmpty = this.observedClients.size === 0;
|
|
189
|
+
const onUpdate = () => this._onClientUpdate(result);
|
|
190
|
+
const joined = () => this._clientJoined(result);
|
|
191
|
+
const left = () => this._clientLeft(result);
|
|
181
192
|
|
|
182
193
|
result.once('close', () => {
|
|
183
194
|
result.off('update', onUpdate);
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
195
|
+
result.off('joined', joined);
|
|
196
|
+
result.off('left', left);
|
|
197
|
+
this.observedClients.delete(settings.clientId);
|
|
198
|
+
|
|
199
|
+
if (this.observedClients.size === 0) {
|
|
187
200
|
this.emit('empty');
|
|
188
201
|
}
|
|
202
|
+
++this.totalRemovedClients;
|
|
189
203
|
});
|
|
190
|
-
|
|
191
204
|
result.on('update', onUpdate);
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
this.reports.addCallEventReport(createClientJoinedEventReport(
|
|
196
|
-
this.serviceId,
|
|
197
|
-
result.mediaUnitId,
|
|
198
|
-
this.roomId,
|
|
199
|
-
this.callId,
|
|
200
|
-
result.clientId,
|
|
201
|
-
result.joined ?? joinedTimestamp,
|
|
202
|
-
result.userId,
|
|
203
|
-
result.marker,
|
|
204
|
-
));
|
|
205
|
-
}
|
|
205
|
+
result.on('joined', joined);
|
|
206
|
+
result.on('left', left);
|
|
207
|
+
++this.totalAddedClients;
|
|
206
208
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
this.reports.addCallEventReport(createClientLeftEventReport(
|
|
210
|
-
this.serviceId,
|
|
211
|
-
result.mediaUnitId,
|
|
212
|
-
this.roomId,
|
|
213
|
-
this.callId,
|
|
214
|
-
result.clientId,
|
|
215
|
-
result.left ?? Date.now(),
|
|
216
|
-
result.userId,
|
|
217
|
-
result.marker,
|
|
218
|
-
));
|
|
219
|
-
}
|
|
220
|
-
});
|
|
209
|
+
this.observedClients.set(settings.clientId, result);
|
|
210
|
+
this.maxNumberOfClients = Math.max(this.maxNumberOfClients, this.observedClients.size);
|
|
221
211
|
|
|
222
212
|
this.emit('newclient', result);
|
|
213
|
+
|
|
214
|
+
if (wasEmpty) {
|
|
215
|
+
this.emit('not-empty');
|
|
216
|
+
}
|
|
223
217
|
|
|
224
218
|
return result;
|
|
225
219
|
}
|
|
220
|
+
|
|
221
|
+
public createEventMonitor<CTX>(context: CTX): ObservedCallEventMonitor<CTX> {
|
|
222
|
+
return new ObservedCallEventMonitor(this, context);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
public update() {
|
|
226
|
+
if (this.closed) return;
|
|
227
|
+
|
|
228
|
+
this.numberOfInboundRtpStreams = 0;
|
|
229
|
+
this.numberOfOutboundRtpStreams = 0;
|
|
230
|
+
this.numberOfPeerConnections = 0;
|
|
231
|
+
this.numberOfDataChannels = 0;
|
|
232
|
+
|
|
233
|
+
for (const client of this.observedClients.values()) {
|
|
234
|
+
this.numberOfInboundRtpStreams += client.numberOfInboundRtpStreams;
|
|
235
|
+
this.numberOfOutboundRtpStreams += client.numberOfOutboundRtpStreams;
|
|
236
|
+
this.numberOfPeerConnections += client.numberOfPeerConnections;
|
|
237
|
+
this.numberOfDataChannels += client.numberOfDataChannels;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
this.detectors.update();
|
|
241
|
+
this.scoreCalculator.update();
|
|
242
|
+
|
|
243
|
+
this.emit('update');
|
|
244
|
+
|
|
245
|
+
this.deltaNumberOfIssues = 0;
|
|
246
|
+
this.deltaRttLt50Measurements = 0;
|
|
247
|
+
this.deltaRttLt150Measurements = 0;
|
|
248
|
+
this.deltaRttLt300Measurements = 0;
|
|
249
|
+
this.deltaRttGtOrEq300Measurements = 0;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
private _onClientUpdate(client: ObservedClient) {
|
|
253
|
+
this.totalClientsReceivedAudioBytes += client.deltaReceivedAudioBytes;
|
|
254
|
+
this.totalClientsReceivedVideoBytes += client.deltaReceivedVideoBytes;
|
|
255
|
+
this.totalClientsReceivedDataChannelBytes += client.deltaDataChannelBytesReceived;
|
|
256
|
+
this.totalClientsReceivedBytes += client.deltaTransportReceivedBytes;
|
|
257
|
+
this.totalClientsSentAudioBytes += client.deltaSentAudioBytes;
|
|
258
|
+
this.totalClientsSentVideoBytes += client.deltaSentVideoBytes;
|
|
259
|
+
this.totalClientsSentDataChannelBytes += client.deltaDataChannelBytesSent;
|
|
260
|
+
this.totalClientsSentBytes += client.deltaTransportSentBytes;
|
|
261
|
+
|
|
262
|
+
this.deltaRttLt50Measurements += client.deltaRttLt50Measurements;
|
|
263
|
+
this.deltaRttLt150Measurements += client.deltaRttLt150Measurements;
|
|
264
|
+
this.deltaRttLt300Measurements += client.deltaRttLt300Measurements;
|
|
265
|
+
this.deltaRttGtOrEq300Measurements += client.deltaRttGtOrEq300Measurements;
|
|
266
|
+
|
|
267
|
+
this.totalRttLt50Measurements += client.deltaRttLt50Measurements;
|
|
268
|
+
this.totalRttLt150Measurements += client.deltaRttLt150Measurements;
|
|
269
|
+
this.totalRttLt300Measurements += client.deltaRttLt300Measurements;
|
|
270
|
+
this.totalRttGtOrEq300Measurements += client.deltaRttGtOrEq300Measurements;
|
|
271
|
+
|
|
272
|
+
this.deltaNumberOfIssues += client.deltaNumberOfIssues;
|
|
273
|
+
this.numberOfIssues += client.deltaNumberOfIssues;
|
|
274
|
+
|
|
275
|
+
if (client.usingTURN) {
|
|
276
|
+
this.clientsUsedTurn.add(client.clientId);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
private _clientJoined(client: ObservedClient) {
|
|
281
|
+
if (!client.joinedAt) return;
|
|
282
|
+
|
|
283
|
+
this.startedAt = Math.min(this.startedAt ?? client.joinedAt, client.joinedAt);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
private _clientLeft(client: ObservedClient) {
|
|
287
|
+
if (!client.leftAt) return;
|
|
288
|
+
|
|
289
|
+
this.endedAt = Math.max(this.endedAt ?? client.leftAt, client.leftAt);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// public resetSummaryMetrics() {
|
|
293
|
+
// this.totalAddedClients = 0;
|
|
294
|
+
// this.totalRemovedClients = 0;
|
|
295
|
+
|
|
296
|
+
// this.totalClientsReceivedAudioBytes = 0;
|
|
297
|
+
// this.totalClientsReceivedVideoBytes = 0;
|
|
298
|
+
// this.totalClientsReceivedBytes = 0;
|
|
299
|
+
|
|
300
|
+
// this.totalClientsSentAudioBytes = 0;
|
|
301
|
+
// this.totalClientsSentVideoBytes = 0;
|
|
302
|
+
// this.totalClientsSentBytes = 0;
|
|
303
|
+
|
|
304
|
+
// this.totalRttLt50Measurements = 0;
|
|
305
|
+
// this.totalRttLt150Measurements = 0;
|
|
306
|
+
// this.totalRttLt300Measurements = 0;
|
|
307
|
+
// this.totalRttGtOrEq300Measurements = 0;
|
|
308
|
+
|
|
309
|
+
// this.numberOfIssues = 0;
|
|
310
|
+
|
|
311
|
+
// this.clientsUsedTurn.clear();
|
|
312
|
+
|
|
313
|
+
// }
|
|
314
|
+
|
|
315
|
+
// public createSummary(): ObservedCallSummary {
|
|
316
|
+
// return {
|
|
317
|
+
// currentActiveClients: this.observedClients.size,
|
|
318
|
+
// totalAddedClients: this.totalAddedClients,
|
|
319
|
+
// totalRemovedClients: this.totalRemovedClients,
|
|
320
|
+
|
|
321
|
+
// totalClientsReceivedAudioBytes: this.totalClientsReceivedBytes,
|
|
322
|
+
// totalClientsReceivedVideoBytes: this.totalClientsReceivedVideoBytes,
|
|
323
|
+
// totalClientsReceivedBytes: this.totalClientsReceivedBytes,
|
|
324
|
+
|
|
325
|
+
// totalClientsSentAudioBytes: this.totalClientsSentAudioBytes,
|
|
326
|
+
// totalClientsSentVideoBytes: this.totalClientsSentVideoBytes,
|
|
327
|
+
// totalClientsSentBytes: this.totalClientsSentBytes,
|
|
328
|
+
|
|
329
|
+
// totalRttLt50Measurements: this.totalRttLt50Measurements,
|
|
330
|
+
// totalRttLt150Measurements: this.totalRttLt150Measurements,
|
|
331
|
+
// totalRttLt300Measurements: this.totalRttLt300Measurements,
|
|
332
|
+
// totalRttGtOrEq300Measurements: this.totalRttGtOrEq300Measurements,
|
|
333
|
+
|
|
334
|
+
// numberOfIssues: this.numberOfIssues,
|
|
335
|
+
// numberOfClientsUsedTurn: this.clientsUsedTurn.size,
|
|
336
|
+
// };
|
|
337
|
+
// }
|
|
226
338
|
}
|