@observertc/observer-js 0.42.9 → 1.0.1-23e88d8.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 +25 -41
- package/lib/ObservedCall.d.ts.map +1 -1
- package/lib/ObservedCall.js +61 -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 +33 -143
- package/lib/ObservedClient.d.ts.map +1 -1
- package/lib/ObservedClient.js +156 -757
- 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 +20 -70
- package/lib/ObservedDataChannel.d.ts.map +1 -1
- package/lib/ObservedDataChannel.js +39 -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 +40 -0
- package/lib/ObservedIceCandidatePair.d.ts.map +1 -0
- package/lib/ObservedIceCandidatePair.js +83 -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 +118 -78
- package/lib/ObservedPeerConnection.d.ts.map +1 -1
- package/lib/ObservedPeerConnection.js +556 -359
- 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/Observer.d.ts +30 -53
- package/lib/Observer.d.ts.map +1 -1
- package/lib/Observer.js +52 -225
- 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 +23 -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 +74 -167
- package/src/ObservedCertificate.ts +43 -0
- package/src/ObservedClient.ts +173 -1085
- package/src/ObservedCodec.ts +49 -0
- package/src/ObservedDataChannel.ts +36 -178
- package/src/ObservedIceCandidate.ts +64 -0
- package/src/ObservedIceCandidatePair.ts +92 -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 +743 -401
- package/src/ObservedPeerConnectionTransport.ts +38 -0
- package/src/ObservedRemoteInboundRtp.ts +64 -0
- package/src/ObservedRemoteOutboundRtp.ts +65 -0
- package/src/Observer.ts +65 -285
- 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 +23 -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
|
@@ -2,169 +2,171 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ObservedPeerConnection = void 0;
|
|
4
4
|
const events_1 = require("events");
|
|
5
|
-
const
|
|
5
|
+
const ObservedInboundRtp_1 = require("./ObservedInboundRtp");
|
|
6
|
+
const logger_1 = require("./common/logger");
|
|
7
|
+
const ObservedOutboundRtp_1 = require("./ObservedOutboundRtp");
|
|
8
|
+
const ObservedCertificate_1 = require("./ObservedCertificate");
|
|
9
|
+
const ObservedCodec_1 = require("./ObservedCodec");
|
|
6
10
|
const ObservedDataChannel_1 = require("./ObservedDataChannel");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
11
|
+
const ObservedIceCandidate_1 = require("./ObservedIceCandidate");
|
|
12
|
+
const ObservedIceCandidatePair_1 = require("./ObservedIceCandidatePair");
|
|
13
|
+
const ObservedIceTransport_1 = require("./ObservedIceTransport");
|
|
14
|
+
const ObservedMediaSource_1 = require("./ObservedMediaSource");
|
|
15
|
+
const ObservedPeerConnectionTransport_1 = require("./ObservedPeerConnectionTransport");
|
|
16
|
+
const ObservedMediaPlayout_1 = require("./ObservedMediaPlayout");
|
|
17
|
+
const ObservedRemoteInboundRtp_1 = require("./ObservedRemoteInboundRtp");
|
|
18
|
+
const ObservedRemoteOutboundRtp_1 = require("./ObservedRemoteOutboundRtp");
|
|
19
|
+
const ObservedInboundTrack_1 = require("./ObservedInboundTrack");
|
|
20
|
+
const ObservedOutboundTrack_1 = require("./ObservedOutboundTrack");
|
|
21
|
+
const logger = (0, logger_1.createLogger)('ObservedPeerConnection');
|
|
12
22
|
class ObservedPeerConnection extends events_1.EventEmitter {
|
|
13
|
-
|
|
23
|
+
peerConnectionId;
|
|
24
|
+
client;
|
|
25
|
+
_visited = true;
|
|
26
|
+
appData;
|
|
27
|
+
calculatedScore = {
|
|
28
|
+
weight: 1,
|
|
29
|
+
value: undefined,
|
|
30
|
+
};
|
|
31
|
+
closed = false;
|
|
32
|
+
// timestamp of the PEER_CONNECTION_OPENED event
|
|
33
|
+
openedAt;
|
|
34
|
+
// timestamp of the PEER_CONNECTION_CLOSED event
|
|
35
|
+
closedAt;
|
|
36
|
+
updated = Date.now();
|
|
37
|
+
totalInboundPacketsLost = 0;
|
|
38
|
+
totalInboundPacketsReceived = 0;
|
|
39
|
+
totalOutboundPacketsSent = 0;
|
|
40
|
+
totalDataChannelBytesSent = 0;
|
|
41
|
+
totalDataChannelBytesReceived = 0;
|
|
42
|
+
totalSentAudioBytes = 0;
|
|
43
|
+
totalSentVideoBytes = 0;
|
|
44
|
+
totalSentAudioPackets = 0;
|
|
45
|
+
totalSentVideoPackets = 0;
|
|
46
|
+
totalReceivedAudioPacktes = 0;
|
|
47
|
+
totalReceivedVideoPackets = 0;
|
|
48
|
+
totalReceivedAudioBytes = 0;
|
|
49
|
+
totalReceivedVideoBytes = 0;
|
|
50
|
+
deltaInboundPacketsLost = 0;
|
|
51
|
+
deltaInboundPacketsReceived = 0;
|
|
52
|
+
deltaOutboundPacketsSent = 0;
|
|
53
|
+
deltaDataChannelBytesSent = 0;
|
|
54
|
+
deltaDataChannelBytesReceived = 0;
|
|
55
|
+
deltaInboundReceivedBytes = 0;
|
|
56
|
+
deltaOutboundSentBytes = 0;
|
|
57
|
+
deltaReceivedAudioBytes = 0;
|
|
58
|
+
deltaReceivedVideoBytes = 0;
|
|
59
|
+
deltaReceivedAudioPackets = 0;
|
|
60
|
+
deltaReceivedVideoPackets = 0;
|
|
61
|
+
deltaSentAudioBytes = 0;
|
|
62
|
+
deltaSentVideoBytes = 0;
|
|
63
|
+
receivingPacketsPerSecond = 0;
|
|
64
|
+
sendingPacketsPerSecond = 0;
|
|
65
|
+
sendingAudioBitrate = 0;
|
|
66
|
+
sendingVideoBitrate = 0;
|
|
67
|
+
receivingAudioBitrate = 0;
|
|
68
|
+
receivingVideoBitrate = 0;
|
|
69
|
+
avgRttInMs;
|
|
70
|
+
avgJitter;
|
|
71
|
+
usingTCP = false;
|
|
72
|
+
usingTURN = false;
|
|
73
|
+
observedCertificates = new Map();
|
|
74
|
+
observedCodecs = new Map();
|
|
75
|
+
observedDataChannels = new Map();
|
|
76
|
+
observedIceCandidates = new Map();
|
|
77
|
+
observedIceCandidatesPair = new Map();
|
|
78
|
+
observedIceTransports = new Map();
|
|
79
|
+
observedInboundRtps = new Map();
|
|
80
|
+
observedInboundTracks = new Map();
|
|
81
|
+
observedMediaPlayouts = new Map();
|
|
82
|
+
observedMediaSources = new Map();
|
|
83
|
+
observedOutboundRtps = new Map();
|
|
84
|
+
observedOutboundTracks = new Map();
|
|
85
|
+
observedPeerConnectionTransports = new Map();
|
|
86
|
+
observedRemoteInboundRtps = new Map();
|
|
87
|
+
observedRemoteOutboundRtps = new Map();
|
|
88
|
+
constructor(peerConnectionId, client) {
|
|
14
89
|
super();
|
|
15
|
-
this.
|
|
90
|
+
this.peerConnectionId = peerConnectionId;
|
|
16
91
|
this.client = client;
|
|
17
|
-
this.created = Date.now();
|
|
18
|
-
this.visited = true;
|
|
19
|
-
this._stabilityScores = [];
|
|
20
|
-
this.ωpendingIssuesForScores = [];
|
|
21
|
-
this.totalInboundPacketsLost = 0;
|
|
22
|
-
this.totalInboundPacketsReceived = 0;
|
|
23
|
-
this.totalOutboundPacketsSent = 0;
|
|
24
|
-
this.totalDataChannelBytesSent = 0;
|
|
25
|
-
this.totalDataChannelBytesReceived = 0;
|
|
26
|
-
this.totalSentAudioBytes = 0;
|
|
27
|
-
this.totalSentVideoBytes = 0;
|
|
28
|
-
this.totalSentAudioPackets = 0;
|
|
29
|
-
this.totalSentVideoPackets = 0;
|
|
30
|
-
this.totalReceivedAudioPacktes = 0;
|
|
31
|
-
this.totalReceivedVideoPackets = 0;
|
|
32
|
-
this.totalReceivedAudioBytes = 0;
|
|
33
|
-
this.totalReceivedVideoBytes = 0;
|
|
34
|
-
this.deltaInboundPacketsLost = 0;
|
|
35
|
-
this.deltaInboundPacketsReceived = 0;
|
|
36
|
-
this.deltaOutboundPacketsSent = 0;
|
|
37
|
-
this.deltaDataChannelBytesSent = 0;
|
|
38
|
-
this.deltaDataChannelBytesReceived = 0;
|
|
39
|
-
this.deltaInboundReceivedBytes = 0;
|
|
40
|
-
this.deltaOutboundSentBytes = 0;
|
|
41
|
-
this.deltaReceivedAudioBytes = 0;
|
|
42
|
-
this.deltaReceivedVideoBytes = 0;
|
|
43
|
-
this.deltaReceivedAudioPackets = 0;
|
|
44
|
-
this.deltaReceivedVideoPackets = 0;
|
|
45
|
-
this.deltaSentAudioBytes = 0;
|
|
46
|
-
this.deltaSentVideoBytes = 0;
|
|
47
|
-
this.receivingPacketsPerSecond = 0;
|
|
48
|
-
this.sendingPacketsPerSecond = 0;
|
|
49
|
-
this.sendingAudioBitrate = 0;
|
|
50
|
-
this.sendingVideoBitrate = 0;
|
|
51
|
-
this.receivingAudioBitrate = 0;
|
|
52
|
-
this.receivingVideoBitrate = 0;
|
|
53
|
-
this._closed = false;
|
|
54
|
-
this._updated = Date.now();
|
|
55
|
-
this.ICE = ObservedICE_1.ObservedICE.create(this);
|
|
56
|
-
this._inboundAudioTracks = new Map();
|
|
57
|
-
this._inboundVideoTracks = new Map();
|
|
58
|
-
this._outboundAudioTracks = new Map();
|
|
59
|
-
this._outboundVideoTracks = new Map();
|
|
60
|
-
this._dataChannels = new Map();
|
|
61
92
|
this.setMaxListeners(Infinity);
|
|
62
93
|
}
|
|
63
|
-
get
|
|
64
|
-
return this.
|
|
65
|
-
}
|
|
66
|
-
get roomId() {
|
|
67
|
-
return this.client.roomId;
|
|
68
|
-
}
|
|
69
|
-
get callId() {
|
|
70
|
-
return this.client.callId;
|
|
71
|
-
}
|
|
72
|
-
get clientId() {
|
|
73
|
-
return this.client.clientId;
|
|
74
|
-
}
|
|
75
|
-
get mediaUnitId() {
|
|
76
|
-
return this.client.mediaUnitId;
|
|
77
|
-
}
|
|
78
|
-
get label() {
|
|
79
|
-
return this._model.label;
|
|
94
|
+
get score() {
|
|
95
|
+
return this.calculatedScore.value;
|
|
80
96
|
}
|
|
81
|
-
|
|
82
|
-
|
|
97
|
+
get visited() {
|
|
98
|
+
const visited = this._visited;
|
|
99
|
+
this._visited = false;
|
|
100
|
+
return visited;
|
|
83
101
|
}
|
|
84
|
-
get
|
|
85
|
-
return this.
|
|
102
|
+
get codecs() {
|
|
103
|
+
return [...this.observedCodecs.values()];
|
|
86
104
|
}
|
|
87
|
-
get
|
|
88
|
-
|
|
89
|
-
return (_a = this.ICE.stats) === null || _a === void 0 ? void 0 : _a.availableOutgoingBitrate;
|
|
105
|
+
get inboundRtps() {
|
|
106
|
+
return [...this.observedInboundRtps.values()];
|
|
90
107
|
}
|
|
91
|
-
get
|
|
92
|
-
|
|
93
|
-
return (_a = this.ICE.stats) === null || _a === void 0 ? void 0 : _a.availableIncomingBitrate;
|
|
108
|
+
get remoteOutboundRtps() {
|
|
109
|
+
return [...this.observedRemoteOutboundRtps.values()];
|
|
94
110
|
}
|
|
95
|
-
get
|
|
96
|
-
|
|
97
|
-
return this._model.peerConnectionId;
|
|
111
|
+
get outboundRtps() {
|
|
112
|
+
return [...this.observedOutboundRtps.values()];
|
|
98
113
|
}
|
|
99
|
-
get
|
|
100
|
-
return this.
|
|
114
|
+
get remoteInboundRtps() {
|
|
115
|
+
return [...this.observedRemoteInboundRtps.values()];
|
|
101
116
|
}
|
|
102
|
-
get
|
|
103
|
-
return this.
|
|
117
|
+
get mediaSources() {
|
|
118
|
+
return [...this.observedMediaSources.values()];
|
|
104
119
|
}
|
|
105
|
-
get
|
|
106
|
-
return this.
|
|
107
|
-
}
|
|
108
|
-
get inboundAudioTracks() {
|
|
109
|
-
return this._inboundAudioTracks;
|
|
110
|
-
}
|
|
111
|
-
get inboundVideoTracks() {
|
|
112
|
-
return this._inboundVideoTracks;
|
|
113
|
-
}
|
|
114
|
-
get outboundAudioTracks() {
|
|
115
|
-
return this._outboundAudioTracks;
|
|
116
|
-
}
|
|
117
|
-
get outboundVideoTracks() {
|
|
118
|
-
return this._outboundVideoTracks;
|
|
120
|
+
get mediaPlayouts() {
|
|
121
|
+
return [...this.observedMediaPlayouts.values()];
|
|
119
122
|
}
|
|
120
123
|
get dataChannels() {
|
|
121
|
-
return this.
|
|
124
|
+
return [...this.observedDataChannels.values()];
|
|
122
125
|
}
|
|
123
|
-
get
|
|
124
|
-
return this.
|
|
126
|
+
get peerConnectionTransports() {
|
|
127
|
+
return [...this.observedPeerConnectionTransports.values()];
|
|
125
128
|
}
|
|
126
|
-
get
|
|
127
|
-
return this.
|
|
129
|
+
get iceTransports() {
|
|
130
|
+
return [...this.observedIceTransports.values()];
|
|
128
131
|
}
|
|
129
|
-
|
|
130
|
-
this.
|
|
131
|
-
this._inboundAudioTracks.forEach((track) => (track.marker = value));
|
|
132
|
-
this._inboundVideoTracks.forEach((track) => (track.marker = value));
|
|
133
|
-
this._outboundAudioTracks.forEach((track) => (track.marker = value));
|
|
134
|
-
this._outboundVideoTracks.forEach((track) => (track.marker = value));
|
|
135
|
-
this._dataChannels.forEach((channel) => (channel.marker = value));
|
|
136
|
-
this.ICE.marker = value;
|
|
132
|
+
get iceCandidates() {
|
|
133
|
+
return [...this.observedIceCandidates.values()];
|
|
137
134
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
this.reports.addCallEventReport(Object.assign(Object.assign({}, params), { serviceId: this.serviceId, mediaUnitId: this.mediaUnitId, roomId: this.roomId, callId: this.callId, clientId: this.clientId, userId: this.client.userId, peerConnectionId: this.peerConnectionId, marker: this.client.marker, timestamp: (_a = params.timestamp) !== null && _a !== void 0 ? _a : Date.now() }));
|
|
135
|
+
get iceCandidatePairs() {
|
|
136
|
+
return [...this.observedIceCandidatesPair.values()];
|
|
141
137
|
}
|
|
142
|
-
get
|
|
143
|
-
return this.
|
|
138
|
+
get certificates() {
|
|
139
|
+
return [...this.observedCertificates.values()];
|
|
140
|
+
}
|
|
141
|
+
get selectedIceCandidatePairs() {
|
|
142
|
+
return this.iceTransports.map((iceTransport) => iceTransport.getSelectedCandidatePair())
|
|
143
|
+
.filter((pair) => pair !== undefined);
|
|
144
144
|
}
|
|
145
145
|
close() {
|
|
146
|
-
if (this.
|
|
146
|
+
if (this.closed)
|
|
147
147
|
return;
|
|
148
|
-
this.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
148
|
+
this.closed = true;
|
|
149
|
+
this.observedCertificates.clear();
|
|
150
|
+
this.observedCodecs.clear();
|
|
151
|
+
this.observedDataChannels.clear();
|
|
152
|
+
this.observedIceCandidates.clear();
|
|
153
|
+
this.observedIceCandidatesPair.clear();
|
|
154
|
+
this.observedIceTransports.clear();
|
|
155
|
+
this.observedInboundRtps.clear();
|
|
156
|
+
this.observedInboundTracks.clear();
|
|
157
|
+
this.observedMediaPlayouts.clear();
|
|
158
|
+
this.observedMediaSources.clear();
|
|
159
|
+
this.observedOutboundRtps.clear();
|
|
160
|
+
this.observedOutboundTracks.clear();
|
|
161
|
+
this.observedPeerConnectionTransports.clear();
|
|
162
|
+
this.observedRemoteInboundRtps.clear();
|
|
163
|
+
this.observedRemoteOutboundRtps.clear();
|
|
161
164
|
this.emit('close');
|
|
162
165
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
resetMetrics() {
|
|
166
|
+
accept(sample) {
|
|
167
|
+
if (this.closed)
|
|
168
|
+
return;
|
|
169
|
+
this._visited = true;
|
|
168
170
|
this.deltaInboundPacketsLost = 0;
|
|
169
171
|
this.deltaInboundPacketsReceived = 0;
|
|
170
172
|
this.deltaOutboundPacketsSent = 0;
|
|
@@ -182,240 +184,435 @@ class ObservedPeerConnection extends events_1.EventEmitter {
|
|
|
182
184
|
this.sendingVideoBitrate = 0;
|
|
183
185
|
this.receivingAudioBitrate = 0;
|
|
184
186
|
this.receivingVideoBitrate = 0;
|
|
185
|
-
this.ICE.resetMetrics();
|
|
186
|
-
}
|
|
187
|
-
update(sample, timestamp) {
|
|
188
|
-
if (this._closed)
|
|
189
|
-
return;
|
|
190
|
-
if (sample.peerConnectionId !== this._model.peerConnectionId)
|
|
191
|
-
throw new Error(`TransportId mismatch. PeerConnectionId: ${this._model.peerConnectionId} TransportId: ${sample.transportId}`);
|
|
192
|
-
this._sample = sample;
|
|
193
|
-
if (this._model.label !== sample.label) {
|
|
194
|
-
this._model.label = sample.label;
|
|
195
|
-
}
|
|
196
187
|
const now = Date.now();
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
if (
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
this._outboundVideoTracks.forEach((track) => {
|
|
308
|
-
var _a, _b;
|
|
309
|
-
track.updateMetrics();
|
|
310
|
-
this.deltaOutboundPacketsSent += track.deltaSentPackets;
|
|
311
|
-
this.deltaOutboundSentBytes += track.deltaSentBytes;
|
|
312
|
-
this.deltaSentVideoBytes += track.deltaSentBytes;
|
|
313
|
-
this.deltaSentVideoBytes += track.deltaSentPackets;
|
|
314
|
-
this.sendingVideoBitrate += track.bitrate;
|
|
315
|
-
sumRttInMs += ((_a = track.rttInMs) !== null && _a !== void 0 ? _a : 0);
|
|
316
|
-
sumJitter += ((_b = track.jitter) !== null && _b !== void 0 ? _b : 0);
|
|
317
|
-
track.score && trackScores.push(track.score);
|
|
318
|
-
});
|
|
319
|
-
this._dataChannels.forEach((channel) => {
|
|
320
|
-
this.deltaDataChannelBytesSent += channel.deltaBytesSent;
|
|
321
|
-
this.deltaDataChannelBytesReceived += channel.deltaBytesReceived;
|
|
322
|
-
});
|
|
323
|
-
const iceRttInMs = (_a = this.ICE.stats) === null || _a === void 0 ? void 0 : _a.currentRoundTripTime;
|
|
324
|
-
let nrOfBelongings = this._inboundAudioTracks.size + this._inboundVideoTracks.size + this._outboundAudioTracks.size + this._outboundVideoTracks.size;
|
|
325
|
-
this.avgJitter = 0 < nrOfBelongings ? sumJitter / nrOfBelongings : undefined;
|
|
326
|
-
if (iceRttInMs) {
|
|
327
|
-
sumRttInMs += iceRttInMs;
|
|
328
|
-
nrOfBelongings += 1;
|
|
329
|
-
}
|
|
330
|
-
this.avgRttInMs = 0 < nrOfBelongings ? sumRttInMs / nrOfBelongings : undefined;
|
|
331
|
-
this.totalDataChannelBytesReceived += this.deltaDataChannelBytesReceived;
|
|
332
|
-
this.totalDataChannelBytesSent += this.deltaDataChannelBytesSent;
|
|
188
|
+
const elapsedTimeInMs = now - this.updated;
|
|
189
|
+
const elapsedTimeInSec = elapsedTimeInMs / 1000;
|
|
190
|
+
if (sample.certificates) {
|
|
191
|
+
for (const certificate of sample.certificates) {
|
|
192
|
+
this._updateCertificateStats(certificate);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (sample.codecs) {
|
|
196
|
+
for (const codec of sample.codecs) {
|
|
197
|
+
this._updateCodecStats(codec);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (sample.dataChannels) {
|
|
201
|
+
for (const dataChannel of sample.dataChannels) {
|
|
202
|
+
this._updateDataChannelStats(dataChannel);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (sample.iceCandidates) {
|
|
206
|
+
for (const iceCandidate of sample.iceCandidates) {
|
|
207
|
+
this._updateIceCandidateStats(iceCandidate);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (sample.iceCandidatePairs) {
|
|
211
|
+
for (const iceCandidatePair of sample.iceCandidatePairs) {
|
|
212
|
+
this._updateIceCandidatePairStats(iceCandidatePair);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (sample.iceTransports) {
|
|
216
|
+
for (const iceTransport of sample.iceTransports) {
|
|
217
|
+
this._updateIceTransportStats(iceTransport);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (sample.inboundRtps) {
|
|
221
|
+
for (const inboundRtp of sample.inboundRtps) {
|
|
222
|
+
const observedInboundRtp = this._updateInboundRtpStats(inboundRtp);
|
|
223
|
+
if (!observedInboundRtp)
|
|
224
|
+
continue;
|
|
225
|
+
this.deltaInboundPacketsLost += observedInboundRtp.deltaLostPackets;
|
|
226
|
+
this.deltaInboundPacketsReceived += observedInboundRtp.deltaReceivedPackets;
|
|
227
|
+
this.deltaInboundReceivedBytes += observedInboundRtp.deltaBytesReceived;
|
|
228
|
+
switch (inboundRtp.kind) {
|
|
229
|
+
case 'audio':
|
|
230
|
+
this.deltaReceivedAudioBytes += observedInboundRtp.deltaBytesReceived;
|
|
231
|
+
this.deltaReceivedAudioPackets += observedInboundRtp.deltaReceivedPackets;
|
|
232
|
+
break;
|
|
233
|
+
case 'video':
|
|
234
|
+
this.deltaReceivedVideoBytes += observedInboundRtp.deltaBytesReceived;
|
|
235
|
+
this.deltaReceivedVideoPackets += observedInboundRtp.deltaReceivedPackets;
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (sample.mediaPlayouts) {
|
|
241
|
+
for (const mediaPlayout of sample.mediaPlayouts) {
|
|
242
|
+
this._updateMediaPlayoutStats(mediaPlayout);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (sample.mediaSources) {
|
|
246
|
+
for (const mediaSource of sample.mediaSources) {
|
|
247
|
+
this._updateMediaSourceStats(mediaSource);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (sample.outboundRtps) {
|
|
251
|
+
for (const outboundRtp of sample.outboundRtps) {
|
|
252
|
+
const observedOutboundRtp = this._updateOutboundRtpStats(outboundRtp);
|
|
253
|
+
if (!observedOutboundRtp)
|
|
254
|
+
continue;
|
|
255
|
+
this.deltaOutboundPacketsSent += observedOutboundRtp.deltaPacketsSent ?? 0;
|
|
256
|
+
this.deltaOutboundSentBytes += observedOutboundRtp.deltaBytesSent ?? 0;
|
|
257
|
+
switch (outboundRtp.kind) {
|
|
258
|
+
case 'audio':
|
|
259
|
+
this.deltaSentAudioBytes += observedOutboundRtp.deltaBytesSent;
|
|
260
|
+
this.deltaSentAudioBytes += observedOutboundRtp.deltaPacketsSent;
|
|
261
|
+
break;
|
|
262
|
+
case 'video':
|
|
263
|
+
this.deltaSentVideoBytes += observedOutboundRtp.deltaBytesSent;
|
|
264
|
+
this.deltaSentVideoBytes += observedOutboundRtp.deltaPacketsSent;
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (sample.peerConnectionTransports) {
|
|
270
|
+
for (const peerConnectionTransport of sample.peerConnectionTransports) {
|
|
271
|
+
this._updatePeerConnectionTransportStats(peerConnectionTransport);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
if (sample.remoteInboundRtps) {
|
|
275
|
+
for (const remoteInboundRtp of sample.remoteInboundRtps) {
|
|
276
|
+
this._updateRemoteInboundRtpStats(remoteInboundRtp);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (sample.remoteOutboundRtps) {
|
|
280
|
+
for (const remoteOutboundRtp of sample.remoteOutboundRtps) {
|
|
281
|
+
const observedRemoteOutboundRtp = this._updateRemoteOutboundRtpStats(remoteOutboundRtp);
|
|
282
|
+
if (!observedRemoteOutboundRtp)
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
// tracks should be updated last as they are derived stats
|
|
287
|
+
// and depends on base stats but they all received in the sample sample
|
|
288
|
+
if (sample.inboundTracks) {
|
|
289
|
+
for (const inboundTrack of sample.inboundTracks) {
|
|
290
|
+
this._updateInboundTrackSample(inboundTrack);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
if (sample.outboundTracks) {
|
|
294
|
+
for (const outboundTrack of sample.outboundTracks) {
|
|
295
|
+
this._updateOutboundTrackSample(outboundTrack);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
333
298
|
this.totalInboundPacketsLost += this.deltaInboundPacketsLost;
|
|
334
299
|
this.totalInboundPacketsReceived += this.deltaInboundPacketsReceived;
|
|
335
300
|
this.totalOutboundPacketsSent += this.deltaOutboundPacketsSent;
|
|
336
|
-
this.
|
|
337
|
-
this.
|
|
301
|
+
this.totalDataChannelBytesSent += this.deltaDataChannelBytesSent;
|
|
302
|
+
this.totalDataChannelBytesReceived += this.deltaDataChannelBytesReceived;
|
|
338
303
|
this.totalReceivedAudioBytes += this.deltaReceivedAudioBytes;
|
|
339
304
|
this.totalReceivedVideoBytes += this.deltaReceivedVideoBytes;
|
|
305
|
+
this.totalSentAudioBytes += this.deltaSentAudioBytes;
|
|
306
|
+
this.totalSentVideoBytes += this.deltaSentVideoBytes;
|
|
340
307
|
this.totalReceivedAudioPacktes += this.deltaReceivedAudioPackets;
|
|
341
308
|
this.totalReceivedVideoPackets += this.deltaReceivedVideoPackets;
|
|
342
309
|
this.totalSentAudioPackets += this.deltaSentAudioBytes;
|
|
343
310
|
this.totalSentVideoPackets += this.deltaSentVideoBytes;
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
this.
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
|
|
311
|
+
this.receivingPacketsPerSecond = this.deltaInboundPacketsReceived / elapsedTimeInSec;
|
|
312
|
+
this.sendingPacketsPerSecond = this.deltaOutboundPacketsSent / elapsedTimeInSec;
|
|
313
|
+
this.sendingAudioBitrate = this.deltaSentAudioBytes * 8 / elapsedTimeInSec;
|
|
314
|
+
this.sendingVideoBitrate = this.deltaSentVideoBytes * 8 / elapsedTimeInSec;
|
|
315
|
+
this.receivingAudioBitrate = this.deltaReceivedAudioBytes * 8 / elapsedTimeInSec;
|
|
316
|
+
this.receivingVideoBitrate = this.deltaReceivedVideoBytes * 8 / elapsedTimeInSec;
|
|
317
|
+
const selectedIceCandidatePairs = this.selectedIceCandidatePairs;
|
|
318
|
+
this.usingTCP = selectedIceCandidatePairs.some((pair) => pair.getLocalCandidate()?.protocol === 'tcp');
|
|
319
|
+
this.usingTURN = selectedIceCandidatePairs.some((pair) => pair.getLocalCandidate()?.candidateType === 'relay') &&
|
|
320
|
+
selectedIceCandidatePairs.some((pair) => pair.getRemoteCandidate()?.url?.startsWith('turn:'));
|
|
321
|
+
this.calculatedScore.value = sample.score;
|
|
322
|
+
this.updated = now;
|
|
323
|
+
this._checkVisited();
|
|
324
|
+
}
|
|
325
|
+
_checkVisited() {
|
|
326
|
+
for (const certificate of [...this.observedCertificates.values()]) {
|
|
327
|
+
if (certificate.visited)
|
|
328
|
+
continue;
|
|
329
|
+
this.observedCertificates.delete(certificate.id);
|
|
330
|
+
}
|
|
331
|
+
for (const codec of [...this.observedCodecs.values()]) {
|
|
332
|
+
if (codec.visited)
|
|
333
|
+
continue;
|
|
334
|
+
this.observedCodecs.delete(codec.id);
|
|
335
|
+
this.emit('removed-codec', codec);
|
|
336
|
+
}
|
|
337
|
+
for (const dataChannel of [...this.observedDataChannels.values()]) {
|
|
338
|
+
if (dataChannel.visited)
|
|
339
|
+
continue;
|
|
340
|
+
this.observedDataChannels.delete(dataChannel.id);
|
|
341
|
+
this.emit('removed-data-channel', dataChannel);
|
|
372
342
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
343
|
+
for (const iceCandidate of [...this.observedIceCandidates.values()]) {
|
|
344
|
+
if (iceCandidate.visited)
|
|
345
|
+
continue;
|
|
346
|
+
this.observedIceCandidates.delete(iceCandidate.id);
|
|
347
|
+
this.emit('removed-ice-candidate', iceCandidate);
|
|
348
|
+
}
|
|
349
|
+
for (const iceCandidatePair of [...this.observedIceCandidatesPair.values()]) {
|
|
350
|
+
if (iceCandidatePair.visited)
|
|
351
|
+
continue;
|
|
352
|
+
this.observedIceCandidatesPair.delete(iceCandidatePair.id);
|
|
353
|
+
this.emit('removed-ice-candidate-pair', iceCandidatePair);
|
|
354
|
+
}
|
|
355
|
+
for (const iceTransport of [...this.observedIceTransports.values()]) {
|
|
356
|
+
if (iceTransport.visited)
|
|
357
|
+
continue;
|
|
358
|
+
this.observedIceTransports.delete(iceTransport.id);
|
|
359
|
+
this.emit('removed-ice-transport', iceTransport);
|
|
360
|
+
}
|
|
361
|
+
for (const inboundRtp of [...this.observedInboundRtps.values()]) {
|
|
362
|
+
if (inboundRtp.visited)
|
|
363
|
+
continue;
|
|
364
|
+
this.observedInboundRtps.delete(inboundRtp.ssrc);
|
|
365
|
+
this.emit('removed-inbound-rtp', inboundRtp);
|
|
366
|
+
}
|
|
367
|
+
for (const inboundTrack of [...this.observedInboundTracks.values()]) {
|
|
368
|
+
if (inboundTrack.visited)
|
|
369
|
+
continue;
|
|
370
|
+
this.observedInboundTracks.delete(inboundTrack.id);
|
|
371
|
+
this.emit('removed-inbound-track', inboundTrack);
|
|
372
|
+
}
|
|
373
|
+
for (const mediaPlayout of [...this.observedMediaPlayouts.values()]) {
|
|
374
|
+
if (mediaPlayout.visited)
|
|
375
|
+
continue;
|
|
376
|
+
this.observedMediaPlayouts.delete(mediaPlayout.id);
|
|
377
|
+
this.emit('removed-media-playout', mediaPlayout);
|
|
378
|
+
}
|
|
379
|
+
for (const mediaSource of [...this.observedMediaSources.values()]) {
|
|
380
|
+
if (mediaSource.visited)
|
|
381
|
+
continue;
|
|
382
|
+
this.observedMediaSources.delete(mediaSource.id);
|
|
383
|
+
this.emit('removed-media-source', mediaSource);
|
|
384
|
+
}
|
|
385
|
+
for (const outboundRtp of [...this.observedOutboundRtps.values()]) {
|
|
386
|
+
if (outboundRtp.visited)
|
|
387
|
+
continue;
|
|
388
|
+
this.observedOutboundRtps.delete(outboundRtp.ssrc);
|
|
389
|
+
this.emit('removed-outbound-rtp', outboundRtp);
|
|
390
|
+
}
|
|
391
|
+
for (const outboundTrack of [...this.observedOutboundTracks.values()]) {
|
|
392
|
+
if (outboundTrack.visited)
|
|
393
|
+
continue;
|
|
394
|
+
this.observedOutboundTracks.delete(outboundTrack.id);
|
|
395
|
+
this.emit('removed-outbound-track', outboundTrack);
|
|
396
|
+
}
|
|
397
|
+
for (const peerConnectionTransport of [...this.observedPeerConnectionTransports.values()]) {
|
|
398
|
+
if (peerConnectionTransport.visited)
|
|
399
|
+
continue;
|
|
400
|
+
this.observedPeerConnectionTransports.delete(peerConnectionTransport.id);
|
|
401
|
+
this.emit('removed-peer-connection-transport', peerConnectionTransport);
|
|
402
|
+
}
|
|
403
|
+
for (const remoteInboundRtp of [...this.observedRemoteInboundRtps.values()]) {
|
|
404
|
+
if (remoteInboundRtp.visited)
|
|
405
|
+
continue;
|
|
406
|
+
this.observedRemoteInboundRtps.delete(remoteInboundRtp.ssrc);
|
|
407
|
+
this.emit('removed-remote-inbound-rtp', remoteInboundRtp);
|
|
408
|
+
}
|
|
409
|
+
for (const remoteOutboundRtp of [...this.observedRemoteOutboundRtps.values()]) {
|
|
410
|
+
if (remoteOutboundRtp.visited)
|
|
411
|
+
continue;
|
|
412
|
+
this.observedRemoteOutboundRtps.delete(remoteOutboundRtp.ssrc);
|
|
413
|
+
this.emit('removed-remote-outbound-rtp', remoteOutboundRtp);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
_updateCertificateStats(stats) {
|
|
417
|
+
let observedCertificate = this.observedCertificates.get(stats.id);
|
|
418
|
+
if (!observedCertificate) {
|
|
419
|
+
if (!stats.timestamp || !stats.id || !stats.fingerprint) {
|
|
420
|
+
return logger.warn(`ObservedPeerConnection received an invalid CertificateStats (missing timestamp OR id OR fingerprint field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
|
|
410
421
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
422
|
+
observedCertificate = new ObservedCertificate_1.ObservedCertificate(stats.timestamp, stats.id, this);
|
|
423
|
+
this.observedCertificates.set(stats.id, observedCertificate);
|
|
424
|
+
this.emit('added-certificate', observedCertificate);
|
|
425
|
+
}
|
|
426
|
+
observedCertificate.update(stats);
|
|
427
|
+
return observedCertificate;
|
|
428
|
+
}
|
|
429
|
+
_updateCodecStats(stats) {
|
|
430
|
+
let observedCodec = this.observedCodecs.get(stats.id);
|
|
431
|
+
if (!observedCodec) {
|
|
432
|
+
if (!stats.timestamp || !stats.id || !stats.mimeType) {
|
|
433
|
+
return logger.warn(`ObservedPeerConnection received an invalid CodecStats (missing timestamp OR id OR mimeType field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
|
|
434
|
+
}
|
|
435
|
+
observedCodec = new ObservedCodec_1.ObservedCodec(stats.timestamp, stats.id, stats.mimeType, this);
|
|
436
|
+
this.observedCodecs.set(stats.id, observedCodec);
|
|
437
|
+
this.emit('added-codec', observedCodec);
|
|
438
|
+
}
|
|
439
|
+
observedCodec.update(stats);
|
|
440
|
+
return observedCodec;
|
|
441
|
+
}
|
|
442
|
+
_updateDataChannelStats(stats) {
|
|
443
|
+
let observedDataChannel = this.observedDataChannels.get(stats.id);
|
|
444
|
+
if (!observedDataChannel) {
|
|
445
|
+
if (!stats.timestamp || !stats.id) {
|
|
446
|
+
return logger.warn(`ObservedPeerConnection received an invalid DataChannelStats (missing timestamp OR id field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
|
|
447
|
+
}
|
|
448
|
+
observedDataChannel = new ObservedDataChannel_1.ObservedDataChannel(stats.timestamp, stats.id, this);
|
|
449
|
+
this.observedDataChannels.set(stats.id, observedDataChannel);
|
|
450
|
+
this.emit('added-data-channel', observedDataChannel);
|
|
451
|
+
}
|
|
452
|
+
observedDataChannel.update(stats);
|
|
453
|
+
return observedDataChannel;
|
|
454
|
+
}
|
|
455
|
+
_updateIceCandidateStats(stats) {
|
|
456
|
+
let observedIceCandidate = this.observedIceCandidates.get(stats.id);
|
|
457
|
+
if (!observedIceCandidate) {
|
|
458
|
+
if (!stats.timestamp || !stats.id) {
|
|
459
|
+
return logger.warn(`ObservedPeerConnection received an invalid IceCandidateStats (missing timestamp OR id field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
|
|
460
|
+
}
|
|
461
|
+
observedIceCandidate = new ObservedIceCandidate_1.ObservedIceCandidate(stats.timestamp, stats.id, this);
|
|
462
|
+
this.observedIceCandidates.set(stats.id, observedIceCandidate);
|
|
463
|
+
this.emit('added-ice-candidate', observedIceCandidate);
|
|
464
|
+
}
|
|
465
|
+
observedIceCandidate.update(stats);
|
|
466
|
+
return observedIceCandidate;
|
|
467
|
+
}
|
|
468
|
+
_updateIceCandidatePairStats(stats) {
|
|
469
|
+
let observedIceCandidatePair = this.observedIceCandidatesPair.get(stats.id);
|
|
470
|
+
if (!observedIceCandidatePair) {
|
|
471
|
+
if (!stats.timestamp || !stats.id) {
|
|
472
|
+
return logger.warn(`ObservedPeerConnection received an invalid IceCandidateStats (missing timestamp OR id field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
|
|
473
|
+
}
|
|
474
|
+
observedIceCandidatePair = new ObservedIceCandidatePair_1.ObservedIceCandidatePair(stats.timestamp, stats.id, this);
|
|
475
|
+
this.observedIceCandidatesPair.set(stats.id, observedIceCandidatePair);
|
|
476
|
+
this.emit('added-ice-candidate-pair', observedIceCandidatePair);
|
|
477
|
+
}
|
|
478
|
+
observedIceCandidatePair.update(stats);
|
|
479
|
+
return observedIceCandidatePair;
|
|
480
|
+
}
|
|
481
|
+
_updateIceTransportStats(stats) {
|
|
482
|
+
let observedIceTransport = this.observedIceTransports.get(stats.id);
|
|
483
|
+
if (!observedIceTransport) {
|
|
484
|
+
if (!stats.timestamp || !stats.id) {
|
|
485
|
+
return logger.warn(`ObservedPeerConnection received an invalid IceCandidateStats (missing timestamp OR id field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
|
|
486
|
+
}
|
|
487
|
+
observedIceTransport = new ObservedIceTransport_1.ObservedIceTransport(stats.timestamp, stats.id, this);
|
|
488
|
+
this.observedIceTransports.set(stats.id, observedIceTransport);
|
|
489
|
+
this.emit('added-ice-transport', observedIceTransport);
|
|
490
|
+
}
|
|
491
|
+
observedIceTransport.update(stats);
|
|
492
|
+
return observedIceTransport;
|
|
493
|
+
}
|
|
494
|
+
_updateInboundRtpStats(stats) {
|
|
495
|
+
let observedInboundRtp = this.observedInboundRtps.get(stats.ssrc);
|
|
496
|
+
if (!observedInboundRtp) {
|
|
497
|
+
if (!stats.timestamp || !stats.id || !stats.ssrc || !stats.kind || !stats.trackIdentifier) {
|
|
498
|
+
return logger.warn(`ObservedPeerConnection received an invalid InboundRtpStats (missing timestamp OR id OR ssrc OR kind OR trackIdentifier field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
|
|
499
|
+
}
|
|
500
|
+
observedInboundRtp = new ObservedInboundRtp_1.ObservedInboundRtp(stats.timestamp, stats.id, stats.ssrc, stats.kind, stats.trackIdentifier, this);
|
|
501
|
+
this.observedInboundRtps.set(stats.ssrc, observedInboundRtp);
|
|
502
|
+
this.emit('added-inbound-rtp', observedInboundRtp);
|
|
503
|
+
}
|
|
504
|
+
observedInboundRtp.update(stats);
|
|
505
|
+
return observedInboundRtp;
|
|
506
|
+
}
|
|
507
|
+
_updateInboundTrackSample(stats) {
|
|
508
|
+
let observedInboundTrack = this.observedInboundTracks.get(stats.id);
|
|
509
|
+
if (!observedInboundTrack) {
|
|
510
|
+
if (!stats.timestamp || !stats.id || !stats.kind) {
|
|
511
|
+
return logger.warn(`ObservedPeerConnection received an invalid InboundTrackSample (missing timestamp OR id OR kind field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
|
|
512
|
+
}
|
|
513
|
+
const inboundRtp = [...this.observedInboundRtps.values()].find((inbRtp) => inbRtp.trackIdentifier === stats.id);
|
|
514
|
+
const mediaPlayout = inboundRtp ?
|
|
515
|
+
[...this.observedMediaPlayouts.values()].find((mp) => mp.id === inboundRtp.playoutId) : undefined;
|
|
516
|
+
observedInboundTrack = new ObservedInboundTrack_1.ObservedInboundTrack(stats.timestamp, stats.id, stats.kind, this, inboundRtp, mediaPlayout);
|
|
517
|
+
this.observedInboundTracks.set(stats.id, observedInboundTrack);
|
|
518
|
+
this.emit('added-inbound-track', observedInboundTrack);
|
|
519
|
+
}
|
|
520
|
+
observedInboundTrack.update(stats);
|
|
521
|
+
return observedInboundTrack;
|
|
522
|
+
}
|
|
523
|
+
_updateMediaPlayoutStats(stats) {
|
|
524
|
+
let observedMediaPlayout = this.observedMediaPlayouts.get(stats.id);
|
|
525
|
+
if (!observedMediaPlayout) {
|
|
526
|
+
if (!stats.timestamp || !stats.id || !stats.kind) {
|
|
527
|
+
return logger.warn(`ObservedPeerConnection received an invalid InboundRtpStats (missing timestamp OR id OR kind OR trackIdentifier field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
|
|
528
|
+
}
|
|
529
|
+
observedMediaPlayout = new ObservedMediaPlayout_1.ObservedMediaPlayout(stats.timestamp, stats.id, stats.kind, this);
|
|
530
|
+
this.observedMediaPlayouts.set(stats.id, observedMediaPlayout);
|
|
531
|
+
this.emit('added-media-playout', observedMediaPlayout);
|
|
532
|
+
}
|
|
533
|
+
observedMediaPlayout.update(stats);
|
|
534
|
+
return observedMediaPlayout;
|
|
535
|
+
}
|
|
536
|
+
_updateMediaSourceStats(stats) {
|
|
537
|
+
let observedMediaSource = this.observedMediaSources.get(stats.id);
|
|
538
|
+
if (!observedMediaSource) {
|
|
539
|
+
if (!stats.timestamp || !stats.id || !stats.kind) {
|
|
540
|
+
return logger.warn(`ObservedPeerConnection received an invalid InboundRtpStats (missing timestamp OR id OR kind field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
|
|
541
|
+
}
|
|
542
|
+
observedMediaSource = new ObservedMediaSource_1.ObservedMediaSource(stats.timestamp, stats.id, stats.kind, this);
|
|
543
|
+
this.observedMediaSources.set(stats.id, observedMediaSource);
|
|
544
|
+
this.emit('added-media-source', observedMediaSource);
|
|
545
|
+
}
|
|
546
|
+
observedMediaSource.update(stats);
|
|
547
|
+
return observedMediaSource;
|
|
548
|
+
}
|
|
549
|
+
_updateOutboundRtpStats(stats) {
|
|
550
|
+
let observedOutboundRtp = this.observedOutboundRtps.get(stats.ssrc);
|
|
551
|
+
if (!observedOutboundRtp) {
|
|
552
|
+
if (!stats.timestamp || !stats.id || !stats.ssrc || !stats.kind) {
|
|
553
|
+
return logger.warn(`ObservedPeerConnection received an invalid OutboundRtpStats (missing timestamp OR id OR ssrc OR kind field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
|
|
554
|
+
}
|
|
555
|
+
observedOutboundRtp = new ObservedOutboundRtp_1.ObservedOutboundRtp(stats.timestamp, stats.id, stats.ssrc, stats.kind, this);
|
|
556
|
+
this.observedOutboundRtps.set(stats.ssrc, observedOutboundRtp);
|
|
557
|
+
this.emit('added-outbound-rtp', observedOutboundRtp);
|
|
558
|
+
}
|
|
559
|
+
observedOutboundRtp.update(stats);
|
|
560
|
+
return observedOutboundRtp;
|
|
561
|
+
}
|
|
562
|
+
_updateOutboundTrackSample(stats) {
|
|
563
|
+
let observedOutboundTrack = this.observedOutboundTracks.get(stats.id);
|
|
564
|
+
if (!observedOutboundTrack) {
|
|
565
|
+
if (!stats.timestamp || !stats.id || !stats.kind) {
|
|
566
|
+
return logger.warn(`ObservedPeerConnection received an invalid OutboundTrackSample (missing timestamp OR id OR kind field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
|
|
567
|
+
}
|
|
568
|
+
const observedMediaSource = [...this.observedMediaSources.values()].find((mediaSource) => mediaSource.trackIdentifier === stats.id);
|
|
569
|
+
const outboundRtps = observedMediaSource
|
|
570
|
+
? [...this.observedOutboundRtps.values()].filter((outboundRtp) => outboundRtp.mediaSourceId === observedMediaSource?.id) : undefined;
|
|
571
|
+
observedOutboundTrack = new ObservedOutboundTrack_1.ObservedOutboundTrack(stats.timestamp, stats.id, stats.kind, this, outboundRtps, observedMediaSource);
|
|
572
|
+
this.observedOutboundTracks.set(stats.id, observedOutboundTrack);
|
|
573
|
+
this.emit('added-outbound-track', observedOutboundTrack);
|
|
574
|
+
}
|
|
575
|
+
observedOutboundTrack.update(stats);
|
|
576
|
+
return observedOutboundTrack;
|
|
577
|
+
}
|
|
578
|
+
_updatePeerConnectionTransportStats(stats) {
|
|
579
|
+
let observedPeerConnectionTransport = this.observedPeerConnectionTransports.get(stats.id);
|
|
580
|
+
if (!observedPeerConnectionTransport) {
|
|
581
|
+
if (!stats.timestamp || !stats.id) {
|
|
582
|
+
return logger.warn(`ObservedPeerConnection received an invalid PeerConnectionTransportStats (missing timestamp OR id field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
|
|
583
|
+
}
|
|
584
|
+
observedPeerConnectionTransport = new ObservedPeerConnectionTransport_1.ObservedPeerConnectionTransport(stats.timestamp, stats.id, this);
|
|
585
|
+
this.observedPeerConnectionTransports.set(stats.id, observedPeerConnectionTransport);
|
|
586
|
+
this.emit('added-peer-connection-transport', observedPeerConnectionTransport);
|
|
587
|
+
}
|
|
588
|
+
observedPeerConnectionTransport.update(stats);
|
|
589
|
+
return observedPeerConnectionTransport;
|
|
590
|
+
}
|
|
591
|
+
_updateRemoteInboundRtpStats(stats) {
|
|
592
|
+
let observedRemoteInboundRtp = this.observedRemoteInboundRtps.get(stats.ssrc);
|
|
593
|
+
if (!observedRemoteInboundRtp) {
|
|
594
|
+
if (!stats.timestamp || !stats.id || !stats.ssrc || !stats.kind) {
|
|
595
|
+
return logger.warn(`ObservedPeerConnection received an invalid RemoteInboundRtpStats (missing timestamp OR id OR ssrc OR kind field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
|
|
596
|
+
}
|
|
597
|
+
observedRemoteInboundRtp = new ObservedRemoteInboundRtp_1.ObservedRemoteInboundRtp(stats.timestamp, stats.id, stats.ssrc, stats.kind, this);
|
|
598
|
+
this.observedRemoteInboundRtps.set(stats.ssrc, observedRemoteInboundRtp);
|
|
599
|
+
this.emit('added-remote-inbound-rtp', observedRemoteInboundRtp);
|
|
600
|
+
}
|
|
601
|
+
observedRemoteInboundRtp.update(stats);
|
|
602
|
+
return observedRemoteInboundRtp;
|
|
603
|
+
}
|
|
604
|
+
_updateRemoteOutboundRtpStats(stats) {
|
|
605
|
+
let observedRemoteOutboundRtp = this.observedRemoteOutboundRtps.get(stats.ssrc);
|
|
606
|
+
if (!observedRemoteOutboundRtp) {
|
|
607
|
+
if (!stats.timestamp || !stats.id || !stats.ssrc || !stats.kind) {
|
|
608
|
+
return logger.warn(`ObservedPeerConnection received an invalid RemoteOutboundRtpStats (missing timestamp OR id OR ssrc OR kind field). PeerConnectionId: ${this.peerConnectionId} ClientId: ${this.client.clientId}, CallId: ${this.client.call.callId}`, stats);
|
|
609
|
+
}
|
|
610
|
+
observedRemoteOutboundRtp = new ObservedRemoteOutboundRtp_1.ObservedRemoteOutboundRtp(stats.timestamp, stats.id, stats.ssrc, stats.kind, this);
|
|
611
|
+
this.observedRemoteOutboundRtps.set(stats.ssrc, observedRemoteOutboundRtp);
|
|
612
|
+
this.emit('added-remote-outbound-rtp', observedRemoteOutboundRtp);
|
|
613
|
+
}
|
|
614
|
+
observedRemoteOutboundRtp.update(stats);
|
|
615
|
+
return observedRemoteOutboundRtp;
|
|
419
616
|
}
|
|
420
617
|
}
|
|
421
618
|
exports.ObservedPeerConnection = ObservedPeerConnection;
|