@observertc/observer-js 0.42.9 → 1.0.1-28c6425.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 +66 -42
- package/lib/ObservedCall.d.ts.map +1 -1
- package/lib/ObservedCall.js +232 -108
- 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 +71 -130
- package/lib/ObservedClient.d.ts.map +1 -1
- package/lib/ObservedClient.js +311 -750
- 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 +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 +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 +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 +132 -80
- package/lib/ObservedPeerConnection.d.ts.map +1 -1
- package/lib/ObservedPeerConnection.js +630 -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 +45 -51
- package/lib/Observer.d.ts.map +1 -1
- package/lib/Observer.js +150 -226
- 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 +2 -1
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +17 -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 +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 +100 -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/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 +13 -0
- package/lib/updaters/OnAllCallObserverUpdater_.d.ts.map +1 -0
- package/lib/updaters/OnAllCallObserverUpdater_.js +38 -0
- package/lib/updaters/OnAllClientCallUpdater.d.ts +13 -0
- package/lib/updaters/OnAllClientCallUpdater.d.ts.map +1 -0
- package/lib/updaters/OnAllClientCallUpdater.js +37 -0
- package/lib/updaters/OnAnyCallObserverUpdater_.d.ts +11 -0
- package/lib/updaters/OnAnyCallObserverUpdater_.d.ts.map +1 -0
- package/lib/updaters/OnAnyCallObserverUpdater_.js +27 -0
- package/lib/updaters/OnAnyClientCallUpdater.d.ts +11 -0
- package/lib/updaters/OnAnyClientCallUpdater.d.ts.map +1 -0
- package/lib/updaters/OnAnyClientCallUpdater.js +27 -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/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 +291 -164
- package/src/ObservedCallSummary.ts +22 -0
- package/src/ObservedCertificate.ts +43 -0
- package/src/ObservedClient.ts +342 -1064
- package/src/ObservedClientSummary.ts +24 -0
- 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 +99 -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 +839 -408
- 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 +171 -294
- 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 +18 -2
- 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 +112 -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 +46 -0
- package/src/updaters/OnAllClientCallUpdater.ts +46 -0
- package/src/updaters/OnAnyCallObserverUpdater_.ts +32 -0
- package/src/updaters/OnAnyClientCallUpdater.ts +32 -0
- package/src/updaters/OnIntervalUpdater.ts +19 -0
- package/src/updaters/Updater.ts +5 -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
|
@@ -2,169 +2,189 @@
|
|
|
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 utils_1 = require("./common/utils");
|
|
22
|
+
const logger = (0, logger_1.createLogger)('ObservedPeerConnection');
|
|
12
23
|
class ObservedPeerConnection extends events_1.EventEmitter {
|
|
13
|
-
|
|
24
|
+
peerConnectionId;
|
|
25
|
+
client;
|
|
26
|
+
_visited = true;
|
|
27
|
+
appData;
|
|
28
|
+
calculatedScore = {
|
|
29
|
+
weight: 1,
|
|
30
|
+
value: undefined,
|
|
31
|
+
};
|
|
32
|
+
closed = false;
|
|
33
|
+
// timestamp of the PEER_CONNECTION_OPENED event
|
|
34
|
+
openedAt;
|
|
35
|
+
// timestamp of the PEER_CONNECTION_CLOSED event
|
|
36
|
+
closedAt;
|
|
37
|
+
updated = Date.now();
|
|
38
|
+
availableIncomingBitrate = 0;
|
|
39
|
+
availableOutgoingBitrate = 0;
|
|
40
|
+
totalInboundPacketsLost = 0;
|
|
41
|
+
totalInboundPacketsReceived = 0;
|
|
42
|
+
totalOutboundPacketsSent = 0;
|
|
43
|
+
totalDataChannelBytesSent = 0;
|
|
44
|
+
totalDataChannelBytesReceived = 0;
|
|
45
|
+
totalDataChannelMessagesSent = 0;
|
|
46
|
+
totalDataChannelMessagesReceived = 0;
|
|
47
|
+
totalSentAudioBytes = 0;
|
|
48
|
+
totalSentVideoBytes = 0;
|
|
49
|
+
totalSentAudioPackets = 0;
|
|
50
|
+
totalSentVideoPackets = 0;
|
|
51
|
+
totalReceivedAudioPacktes = 0;
|
|
52
|
+
totalReceivedVideoPackets = 0;
|
|
53
|
+
totalReceivedAudioBytes = 0;
|
|
54
|
+
totalReceivedVideoBytes = 0;
|
|
55
|
+
deltaInboundPacketsLost = 0;
|
|
56
|
+
deltaInboundPacketsReceived = 0;
|
|
57
|
+
deltaOutboundPacketsSent = 0;
|
|
58
|
+
deltaDataChannelBytesSent = 0;
|
|
59
|
+
deltaDataChannelBytesReceived = 0;
|
|
60
|
+
deltaDataChannelMessagesSent = 0;
|
|
61
|
+
deltaDataChannelMessagesReceived = 0;
|
|
62
|
+
deltaInboundReceivedBytes = 0;
|
|
63
|
+
deltaOutboundSentBytes = 0;
|
|
64
|
+
deltaReceivedAudioBytes = 0;
|
|
65
|
+
deltaReceivedVideoBytes = 0;
|
|
66
|
+
deltaReceivedAudioPackets = 0;
|
|
67
|
+
deltaReceivedVideoPackets = 0;
|
|
68
|
+
deltaSentAudioBytes = 0;
|
|
69
|
+
deltaSentVideoBytes = 0;
|
|
70
|
+
deltaTransportSentBytes = 0;
|
|
71
|
+
deltaTransportReceivedBytes = 0;
|
|
72
|
+
receivingPacketsPerSecond = 0;
|
|
73
|
+
sendingPacketsPerSecond = 0;
|
|
74
|
+
sendingAudioBitrate = 0;
|
|
75
|
+
sendingVideoBitrate = 0;
|
|
76
|
+
receivingAudioBitrate = 0;
|
|
77
|
+
receivingVideoBitrate = 0;
|
|
78
|
+
currentRttInMs;
|
|
79
|
+
currentJitter;
|
|
80
|
+
usingTCP = false;
|
|
81
|
+
usingTURN = false;
|
|
82
|
+
observedTurnServer;
|
|
83
|
+
observedCertificates = new Map();
|
|
84
|
+
observedCodecs = new Map();
|
|
85
|
+
observedDataChannels = new Map();
|
|
86
|
+
observedIceCandidates = new Map();
|
|
87
|
+
observedIceCandidatesPair = new Map();
|
|
88
|
+
observedIceTransports = new Map();
|
|
89
|
+
observedInboundRtps = new Map();
|
|
90
|
+
observedInboundTracks = new Map();
|
|
91
|
+
observedMediaPlayouts = new Map();
|
|
92
|
+
observedMediaSources = new Map();
|
|
93
|
+
observedOutboundRtps = new Map();
|
|
94
|
+
observedOutboundTracks = new Map();
|
|
95
|
+
observedPeerConnectionTransports = new Map();
|
|
96
|
+
observedRemoteInboundRtps = new Map();
|
|
97
|
+
observedRemoteOutboundRtps = new Map();
|
|
98
|
+
constructor(peerConnectionId, client) {
|
|
14
99
|
super();
|
|
15
|
-
this.
|
|
100
|
+
this.peerConnectionId = peerConnectionId;
|
|
16
101
|
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
102
|
this.setMaxListeners(Infinity);
|
|
62
103
|
}
|
|
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;
|
|
80
|
-
}
|
|
81
|
-
set label(value) {
|
|
82
|
-
this._model.label = value;
|
|
83
|
-
}
|
|
84
|
-
get usingTURN() {
|
|
85
|
-
return this.ICE.usingTURN;
|
|
104
|
+
get score() {
|
|
105
|
+
return this.calculatedScore.value;
|
|
86
106
|
}
|
|
87
|
-
get
|
|
88
|
-
|
|
89
|
-
|
|
107
|
+
get visited() {
|
|
108
|
+
const visited = this._visited;
|
|
109
|
+
this._visited = false;
|
|
110
|
+
return visited;
|
|
90
111
|
}
|
|
91
|
-
get
|
|
92
|
-
|
|
93
|
-
return (_a = this.ICE.stats) === null || _a === void 0 ? void 0 : _a.availableIncomingBitrate;
|
|
112
|
+
get codecs() {
|
|
113
|
+
return [...this.observedCodecs.values()];
|
|
94
114
|
}
|
|
95
|
-
get
|
|
96
|
-
|
|
97
|
-
return this._model.peerConnectionId;
|
|
115
|
+
get inboundRtps() {
|
|
116
|
+
return [...this.observedInboundRtps.values()];
|
|
98
117
|
}
|
|
99
|
-
get
|
|
100
|
-
return this.
|
|
118
|
+
get remoteOutboundRtps() {
|
|
119
|
+
return [...this.observedRemoteOutboundRtps.values()];
|
|
101
120
|
}
|
|
102
|
-
get
|
|
103
|
-
return this.
|
|
121
|
+
get outboundRtps() {
|
|
122
|
+
return [...this.observedOutboundRtps.values()];
|
|
104
123
|
}
|
|
105
|
-
get
|
|
106
|
-
return this.
|
|
124
|
+
get remoteInboundRtps() {
|
|
125
|
+
return [...this.observedRemoteInboundRtps.values()];
|
|
107
126
|
}
|
|
108
|
-
get
|
|
109
|
-
return this.
|
|
127
|
+
get mediaSources() {
|
|
128
|
+
return [...this.observedMediaSources.values()];
|
|
110
129
|
}
|
|
111
|
-
get
|
|
112
|
-
return this.
|
|
130
|
+
get mediaPlayouts() {
|
|
131
|
+
return [...this.observedMediaPlayouts.values()];
|
|
113
132
|
}
|
|
114
|
-
get
|
|
115
|
-
return this.
|
|
133
|
+
get dataChannels() {
|
|
134
|
+
return [...this.observedDataChannels.values()];
|
|
116
135
|
}
|
|
117
|
-
get
|
|
118
|
-
return this.
|
|
136
|
+
get peerConnectionTransports() {
|
|
137
|
+
return [...this.observedPeerConnectionTransports.values()];
|
|
119
138
|
}
|
|
120
|
-
get
|
|
121
|
-
return this.
|
|
139
|
+
get iceTransports() {
|
|
140
|
+
return [...this.observedIceTransports.values()];
|
|
122
141
|
}
|
|
123
|
-
get
|
|
124
|
-
return this.
|
|
142
|
+
get iceCandidates() {
|
|
143
|
+
return [...this.observedIceCandidates.values()];
|
|
125
144
|
}
|
|
126
|
-
get
|
|
127
|
-
return this.
|
|
145
|
+
get iceCandidatePairs() {
|
|
146
|
+
return [...this.observedIceCandidatesPair.values()];
|
|
128
147
|
}
|
|
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;
|
|
148
|
+
get certificates() {
|
|
149
|
+
return [...this.observedCertificates.values()];
|
|
137
150
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
151
|
+
get selectedIceCandidatePairs() {
|
|
152
|
+
return this.iceTransports.map((iceTransport) => iceTransport.getSelectedCandidatePair())
|
|
153
|
+
.filter((pair) => pair !== undefined);
|
|
141
154
|
}
|
|
142
|
-
get
|
|
143
|
-
return this.
|
|
155
|
+
get selectedIceCandiadtePairForTurn() {
|
|
156
|
+
return this.selectedIceCandidatePairs
|
|
157
|
+
.filter((pair) => pair.getLocalCandidate()?.candidateType === 'relay' &&
|
|
158
|
+
pair.getRemoteCandidate()?.url?.startsWith('turn:'));
|
|
144
159
|
}
|
|
145
160
|
close() {
|
|
146
|
-
if (this.
|
|
161
|
+
if (this.closed)
|
|
147
162
|
return;
|
|
148
|
-
this.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
163
|
+
this.closed = true;
|
|
164
|
+
this.observedCertificates.clear();
|
|
165
|
+
this.observedCodecs.clear();
|
|
166
|
+
this.observedDataChannels.clear();
|
|
167
|
+
this.observedIceCandidates.clear();
|
|
168
|
+
this.observedIceCandidatesPair.clear();
|
|
169
|
+
this.observedIceTransports.clear();
|
|
170
|
+
this.observedInboundRtps.clear();
|
|
171
|
+
this.observedInboundTracks.clear();
|
|
172
|
+
this.observedMediaPlayouts.clear();
|
|
173
|
+
this.observedMediaSources.clear();
|
|
174
|
+
this.observedOutboundRtps.clear();
|
|
175
|
+
this.observedOutboundTracks.clear();
|
|
176
|
+
this.observedPeerConnectionTransports.clear();
|
|
177
|
+
this.observedRemoteInboundRtps.clear();
|
|
178
|
+
this.observedRemoteOutboundRtps.clear();
|
|
179
|
+
this.client.call.observer.observedTURN.removePeerConnection(this);
|
|
161
180
|
this.emit('close');
|
|
162
181
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
182
|
+
accept(sample) {
|
|
183
|
+
if (this.closed)
|
|
184
|
+
return;
|
|
185
|
+
this._visited = true;
|
|
186
|
+
this.availableIncomingBitrate = 0;
|
|
187
|
+
this.availableOutgoingBitrate = 0;
|
|
168
188
|
this.deltaInboundPacketsLost = 0;
|
|
169
189
|
this.deltaInboundPacketsReceived = 0;
|
|
170
190
|
this.deltaOutboundPacketsSent = 0;
|
|
@@ -182,240 +202,493 @@ class ObservedPeerConnection extends events_1.EventEmitter {
|
|
|
182
202
|
this.sendingVideoBitrate = 0;
|
|
183
203
|
this.receivingAudioBitrate = 0;
|
|
184
204
|
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
205
|
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
|
-
|
|
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
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
206
|
+
const elapsedTimeInMs = now - this.updated;
|
|
207
|
+
const elapsedTimeInSec = elapsedTimeInMs / 1000;
|
|
208
|
+
const rttMeasurementsInSec = [];
|
|
209
|
+
const jitterMeasurements = [];
|
|
210
|
+
if (sample.certificates) {
|
|
211
|
+
for (const certificate of sample.certificates) {
|
|
212
|
+
this._updateCertificateStats(certificate);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (sample.codecs) {
|
|
216
|
+
for (const codec of sample.codecs) {
|
|
217
|
+
this._updateCodecStats(codec);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (sample.dataChannels) {
|
|
221
|
+
for (const dataChannel of sample.dataChannels) {
|
|
222
|
+
const observedDataChannel = this._updateDataChannelStats(dataChannel);
|
|
223
|
+
if (!observedDataChannel)
|
|
224
|
+
continue;
|
|
225
|
+
this.deltaDataChannelBytesSent += observedDataChannel.deltaBytesSent;
|
|
226
|
+
this.deltaDataChannelBytesReceived += observedDataChannel.deltaBytesReceived;
|
|
227
|
+
this.deltaDataChannelMessagesSent += observedDataChannel.deltaMessagesSent;
|
|
228
|
+
this.deltaDataChannelMessagesReceived += observedDataChannel.deltaMessagesReceived;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (sample.iceCandidates) {
|
|
232
|
+
for (const iceCandidate of sample.iceCandidates) {
|
|
233
|
+
this._updateIceCandidateStats(iceCandidate);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (sample.iceCandidatePairs) {
|
|
237
|
+
for (const iceCandidatePair of sample.iceCandidatePairs) {
|
|
238
|
+
const observedCandidatePair = this._updateIceCandidatePairStats(iceCandidatePair);
|
|
239
|
+
if (!observedCandidatePair)
|
|
240
|
+
continue;
|
|
241
|
+
if (observedCandidatePair.currentRoundTripTime) {
|
|
242
|
+
rttMeasurementsInSec.push(observedCandidatePair.currentRoundTripTime);
|
|
243
|
+
}
|
|
244
|
+
if (observedCandidatePair.availableIncomingBitrate) {
|
|
245
|
+
this.availableIncomingBitrate += observedCandidatePair.availableIncomingBitrate;
|
|
246
|
+
}
|
|
247
|
+
if (observedCandidatePair.availableOutgoingBitrate) {
|
|
248
|
+
this.availableOutgoingBitrate += observedCandidatePair.availableOutgoingBitrate;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
if (sample.iceTransports) {
|
|
253
|
+
for (const iceTransport of sample.iceTransports) {
|
|
254
|
+
const observedIceTransport = this._updateIceTransportStats(iceTransport);
|
|
255
|
+
if (!observedIceTransport)
|
|
256
|
+
return;
|
|
257
|
+
observedIceTransport.bytesReceived;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (sample.inboundRtps) {
|
|
261
|
+
for (const inboundRtp of sample.inboundRtps) {
|
|
262
|
+
const observedInboundRtp = this._updateInboundRtpStats(inboundRtp);
|
|
263
|
+
if (!observedInboundRtp)
|
|
264
|
+
continue;
|
|
265
|
+
this.deltaInboundPacketsLost += observedInboundRtp.deltaLostPackets;
|
|
266
|
+
this.deltaInboundPacketsReceived += observedInboundRtp.deltaReceivedPackets;
|
|
267
|
+
this.deltaInboundReceivedBytes += observedInboundRtp.deltaBytesReceived;
|
|
268
|
+
switch (inboundRtp.kind) {
|
|
269
|
+
case 'audio':
|
|
270
|
+
this.deltaReceivedAudioBytes += observedInboundRtp.deltaBytesReceived;
|
|
271
|
+
this.deltaReceivedAudioPackets += observedInboundRtp.deltaReceivedPackets;
|
|
272
|
+
break;
|
|
273
|
+
case 'video':
|
|
274
|
+
this.deltaReceivedVideoBytes += observedInboundRtp.deltaBytesReceived;
|
|
275
|
+
this.deltaReceivedVideoPackets += observedInboundRtp.deltaReceivedPackets;
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
if (observedInboundRtp.jitter) {
|
|
279
|
+
jitterMeasurements.push(observedInboundRtp.jitter);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
if (sample.mediaPlayouts) {
|
|
284
|
+
for (const mediaPlayout of sample.mediaPlayouts) {
|
|
285
|
+
this._updateMediaPlayoutStats(mediaPlayout);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
if (sample.mediaSources) {
|
|
289
|
+
for (const mediaSource of sample.mediaSources) {
|
|
290
|
+
this._updateMediaSourceStats(mediaSource);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
if (sample.outboundRtps) {
|
|
294
|
+
for (const outboundRtp of sample.outboundRtps) {
|
|
295
|
+
const observedOutboundRtp = this._updateOutboundRtpStats(outboundRtp);
|
|
296
|
+
if (!observedOutboundRtp)
|
|
297
|
+
continue;
|
|
298
|
+
this.deltaOutboundPacketsSent += observedOutboundRtp.deltaPacketsSent ?? 0;
|
|
299
|
+
this.deltaOutboundSentBytes += observedOutboundRtp.deltaBytesSent ?? 0;
|
|
300
|
+
switch (outboundRtp.kind) {
|
|
301
|
+
case 'audio':
|
|
302
|
+
this.deltaSentAudioBytes += observedOutboundRtp.deltaBytesSent;
|
|
303
|
+
this.deltaSentAudioBytes += observedOutboundRtp.deltaPacketsSent;
|
|
304
|
+
break;
|
|
305
|
+
case 'video':
|
|
306
|
+
this.deltaSentVideoBytes += observedOutboundRtp.deltaBytesSent;
|
|
307
|
+
this.deltaSentVideoBytes += observedOutboundRtp.deltaPacketsSent;
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (sample.peerConnectionTransports) {
|
|
313
|
+
for (const peerConnectionTransport of sample.peerConnectionTransports) {
|
|
314
|
+
this._updatePeerConnectionTransportStats(peerConnectionTransport);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (sample.remoteInboundRtps) {
|
|
318
|
+
for (const remoteInboundRtp of sample.remoteInboundRtps) {
|
|
319
|
+
const observedRemoteInboundRtp = this._updateRemoteInboundRtpStats(remoteInboundRtp);
|
|
320
|
+
if (!observedRemoteInboundRtp)
|
|
321
|
+
continue;
|
|
322
|
+
if (observedRemoteInboundRtp.roundTripTime) {
|
|
323
|
+
rttMeasurementsInSec.push(observedRemoteInboundRtp.roundTripTime);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
if (sample.remoteOutboundRtps) {
|
|
328
|
+
for (const remoteOutboundRtp of sample.remoteOutboundRtps) {
|
|
329
|
+
const observedRemoteOutboundRtp = this._updateRemoteOutboundRtpStats(remoteOutboundRtp);
|
|
330
|
+
if (!observedRemoteOutboundRtp)
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
// tracks should be updated last as they are derived stats
|
|
335
|
+
// and depends on base stats but they all received in the sample sample
|
|
336
|
+
if (sample.inboundTracks) {
|
|
337
|
+
for (const inboundTrack of sample.inboundTracks) {
|
|
338
|
+
this._updateInboundTrackSample(inboundTrack);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
if (sample.outboundTracks) {
|
|
342
|
+
for (const outboundTrack of sample.outboundTracks) {
|
|
343
|
+
this._updateOutboundTrackSample(outboundTrack);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
333
346
|
this.totalInboundPacketsLost += this.deltaInboundPacketsLost;
|
|
334
347
|
this.totalInboundPacketsReceived += this.deltaInboundPacketsReceived;
|
|
335
348
|
this.totalOutboundPacketsSent += this.deltaOutboundPacketsSent;
|
|
336
|
-
this.
|
|
337
|
-
this.
|
|
349
|
+
this.totalDataChannelBytesSent += this.deltaDataChannelBytesSent;
|
|
350
|
+
this.totalDataChannelBytesReceived += this.deltaDataChannelBytesReceived;
|
|
351
|
+
this.totalDataChannelMessagesSent += this.deltaDataChannelMessagesSent;
|
|
352
|
+
this.totalDataChannelMessagesReceived += this.deltaDataChannelMessagesReceived;
|
|
338
353
|
this.totalReceivedAudioBytes += this.deltaReceivedAudioBytes;
|
|
339
354
|
this.totalReceivedVideoBytes += this.deltaReceivedVideoBytes;
|
|
355
|
+
this.totalSentAudioBytes += this.deltaSentAudioBytes;
|
|
356
|
+
this.totalSentVideoBytes += this.deltaSentVideoBytes;
|
|
340
357
|
this.totalReceivedAudioPacktes += this.deltaReceivedAudioPackets;
|
|
341
358
|
this.totalReceivedVideoPackets += this.deltaReceivedVideoPackets;
|
|
342
359
|
this.totalSentAudioPackets += this.deltaSentAudioBytes;
|
|
343
360
|
this.totalSentVideoPackets += this.deltaSentVideoBytes;
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
361
|
+
this.receivingPacketsPerSecond = this.deltaInboundPacketsReceived / elapsedTimeInSec;
|
|
362
|
+
this.sendingPacketsPerSecond = this.deltaOutboundPacketsSent / elapsedTimeInSec;
|
|
363
|
+
this.sendingAudioBitrate = (this.deltaSentAudioBytes * 8) / elapsedTimeInSec;
|
|
364
|
+
this.sendingVideoBitrate = (this.deltaSentVideoBytes * 8) / elapsedTimeInSec;
|
|
365
|
+
this.receivingAudioBitrate = (this.deltaReceivedAudioBytes * 8) / elapsedTimeInSec;
|
|
366
|
+
this.receivingVideoBitrate = (this.deltaReceivedVideoBytes * 8) / elapsedTimeInSec;
|
|
367
|
+
if (rttMeasurementsInSec.length > 0) {
|
|
368
|
+
this.currentRttInMs = (0, utils_1.getMedian)(rttMeasurementsInSec, false) * 1000;
|
|
347
369
|
}
|
|
348
370
|
else {
|
|
349
|
-
this.
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
371
|
+
this.currentRttInMs = undefined;
|
|
372
|
+
}
|
|
373
|
+
if (jitterMeasurements.length > 0) {
|
|
374
|
+
this.currentJitter = (0, utils_1.getMedian)(jitterMeasurements, false);
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
this.currentJitter = undefined;
|
|
378
|
+
}
|
|
379
|
+
const selectedIceCandidatePairs = this.selectedIceCandidatePairs;
|
|
380
|
+
const selectedCandidatePairForTurn = selectedIceCandidatePairs.filter((pair) => pair.getLocalCandidate()?.candidateType === 'relay' &&
|
|
381
|
+
pair.getRemoteCandidate()?.url?.startsWith('turn:'));
|
|
382
|
+
const wasUsingTURN = this.usingTURN;
|
|
383
|
+
this.usingTCP = selectedIceCandidatePairs.some((pair) => pair.getLocalCandidate()?.protocol === 'tcp');
|
|
384
|
+
this.usingTURN = 0 < selectedCandidatePairForTurn.length;
|
|
385
|
+
if (this.usingTURN) {
|
|
386
|
+
if (!this.observedTurnServer) {
|
|
387
|
+
this.observedTurnServer = this.client.call.observer.observedTURN.addPeerConnection(this);
|
|
388
|
+
}
|
|
389
|
+
this.observedTurnServer?.updateTurnUsage(...selectedCandidatePairForTurn);
|
|
390
|
+
}
|
|
391
|
+
else if (wasUsingTURN) {
|
|
392
|
+
if (!this.usingTURN) {
|
|
393
|
+
this.client.call.observer.observedTURN.removePeerConnection(this);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
this.calculatedScore.value = sample.score;
|
|
397
|
+
this.updated = now;
|
|
398
|
+
this._checkVisited();
|
|
399
|
+
this.emit('update');
|
|
400
|
+
}
|
|
401
|
+
_checkVisited() {
|
|
402
|
+
for (const certificate of [...this.observedCertificates.values()]) {
|
|
403
|
+
if (certificate.visited)
|
|
404
|
+
continue;
|
|
405
|
+
this.observedCertificates.delete(certificate.id);
|
|
406
|
+
}
|
|
407
|
+
for (const codec of [...this.observedCodecs.values()]) {
|
|
408
|
+
if (codec.visited)
|
|
409
|
+
continue;
|
|
410
|
+
this.observedCodecs.delete(codec.id);
|
|
411
|
+
this.emit('removed-codec', codec);
|
|
412
|
+
}
|
|
413
|
+
for (const dataChannel of [...this.observedDataChannels.values()]) {
|
|
414
|
+
if (dataChannel.visited)
|
|
415
|
+
continue;
|
|
416
|
+
this.observedDataChannels.delete(dataChannel.id);
|
|
417
|
+
this.emit('removed-data-channel', dataChannel);
|
|
418
|
+
}
|
|
419
|
+
for (const iceCandidate of [...this.observedIceCandidates.values()]) {
|
|
420
|
+
if (iceCandidate.visited)
|
|
421
|
+
continue;
|
|
422
|
+
this.observedIceCandidates.delete(iceCandidate.id);
|
|
423
|
+
this.emit('removed-ice-candidate', iceCandidate);
|
|
424
|
+
}
|
|
425
|
+
for (const iceCandidatePair of [...this.observedIceCandidatesPair.values()]) {
|
|
426
|
+
if (iceCandidatePair.visited)
|
|
427
|
+
continue;
|
|
428
|
+
this.observedIceCandidatesPair.delete(iceCandidatePair.id);
|
|
429
|
+
this.emit('removed-ice-candidate-pair', iceCandidatePair);
|
|
430
|
+
}
|
|
431
|
+
for (const iceTransport of [...this.observedIceTransports.values()]) {
|
|
432
|
+
if (iceTransport.visited)
|
|
433
|
+
continue;
|
|
434
|
+
this.observedIceTransports.delete(iceTransport.id);
|
|
435
|
+
this.emit('removed-ice-transport', iceTransport);
|
|
436
|
+
}
|
|
437
|
+
for (const inboundRtp of [...this.observedInboundRtps.values()]) {
|
|
438
|
+
if (inboundRtp.visited)
|
|
439
|
+
continue;
|
|
440
|
+
this.observedInboundRtps.delete(inboundRtp.ssrc);
|
|
441
|
+
this.emit('removed-inbound-rtp', inboundRtp);
|
|
442
|
+
}
|
|
443
|
+
for (const inboundTrack of [...this.observedInboundTracks.values()]) {
|
|
444
|
+
if (inboundTrack.visited)
|
|
445
|
+
continue;
|
|
446
|
+
this.observedInboundTracks.delete(inboundTrack.id);
|
|
447
|
+
this.emit('removed-inbound-track', inboundTrack);
|
|
448
|
+
}
|
|
449
|
+
for (const mediaPlayout of [...this.observedMediaPlayouts.values()]) {
|
|
450
|
+
if (mediaPlayout.visited)
|
|
451
|
+
continue;
|
|
452
|
+
this.observedMediaPlayouts.delete(mediaPlayout.id);
|
|
453
|
+
this.emit('removed-media-playout', mediaPlayout);
|
|
454
|
+
}
|
|
455
|
+
for (const mediaSource of [...this.observedMediaSources.values()]) {
|
|
456
|
+
if (mediaSource.visited)
|
|
457
|
+
continue;
|
|
458
|
+
this.observedMediaSources.delete(mediaSource.id);
|
|
459
|
+
this.emit('removed-media-source', mediaSource);
|
|
460
|
+
}
|
|
461
|
+
for (const outboundRtp of [...this.observedOutboundRtps.values()]) {
|
|
462
|
+
if (outboundRtp.visited)
|
|
463
|
+
continue;
|
|
464
|
+
this.observedOutboundRtps.delete(outboundRtp.ssrc);
|
|
465
|
+
this.emit('removed-outbound-rtp', outboundRtp);
|
|
466
|
+
}
|
|
467
|
+
for (const outboundTrack of [...this.observedOutboundTracks.values()]) {
|
|
468
|
+
if (outboundTrack.visited)
|
|
469
|
+
continue;
|
|
470
|
+
this.observedOutboundTracks.delete(outboundTrack.id);
|
|
471
|
+
this.emit('removed-outbound-track', outboundTrack);
|
|
472
|
+
}
|
|
473
|
+
for (const peerConnectionTransport of [...this.observedPeerConnectionTransports.values()]) {
|
|
474
|
+
if (peerConnectionTransport.visited)
|
|
475
|
+
continue;
|
|
476
|
+
this.observedPeerConnectionTransports.delete(peerConnectionTransport.id);
|
|
477
|
+
this.emit('removed-peer-connection-transport', peerConnectionTransport);
|
|
478
|
+
}
|
|
479
|
+
for (const remoteInboundRtp of [...this.observedRemoteInboundRtps.values()]) {
|
|
480
|
+
if (remoteInboundRtp.visited)
|
|
481
|
+
continue;
|
|
482
|
+
this.observedRemoteInboundRtps.delete(remoteInboundRtp.ssrc);
|
|
483
|
+
this.emit('removed-remote-inbound-rtp', remoteInboundRtp);
|
|
484
|
+
}
|
|
485
|
+
for (const remoteOutboundRtp of [...this.observedRemoteOutboundRtps.values()]) {
|
|
486
|
+
if (remoteOutboundRtp.visited)
|
|
487
|
+
continue;
|
|
488
|
+
this.observedRemoteOutboundRtps.delete(remoteOutboundRtp.ssrc);
|
|
489
|
+
this.emit('removed-remote-outbound-rtp', remoteOutboundRtp);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
_updateCertificateStats(stats) {
|
|
493
|
+
let observedCertificate = this.observedCertificates.get(stats.id);
|
|
494
|
+
if (!observedCertificate) {
|
|
495
|
+
if (!stats.timestamp || !stats.id || !stats.fingerprint) {
|
|
496
|
+
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);
|
|
497
|
+
}
|
|
498
|
+
observedCertificate = new ObservedCertificate_1.ObservedCertificate(stats.timestamp, stats.id, this);
|
|
499
|
+
this.observedCertificates.set(stats.id, observedCertificate);
|
|
500
|
+
this.emit('added-certificate', observedCertificate);
|
|
501
|
+
}
|
|
502
|
+
observedCertificate.update(stats);
|
|
503
|
+
return observedCertificate;
|
|
504
|
+
}
|
|
505
|
+
_updateCodecStats(stats) {
|
|
506
|
+
let observedCodec = this.observedCodecs.get(stats.id);
|
|
507
|
+
if (!observedCodec) {
|
|
508
|
+
if (!stats.timestamp || !stats.id || !stats.mimeType) {
|
|
509
|
+
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);
|
|
510
|
+
}
|
|
511
|
+
observedCodec = new ObservedCodec_1.ObservedCodec(stats.timestamp, stats.id, stats.mimeType, this);
|
|
512
|
+
this.observedCodecs.set(stats.id, observedCodec);
|
|
513
|
+
this.emit('added-codec', observedCodec);
|
|
514
|
+
}
|
|
515
|
+
observedCodec.update(stats);
|
|
516
|
+
return observedCodec;
|
|
517
|
+
}
|
|
518
|
+
_updateDataChannelStats(stats) {
|
|
519
|
+
let observedDataChannel = this.observedDataChannels.get(stats.id);
|
|
520
|
+
if (!observedDataChannel) {
|
|
521
|
+
if (!stats.timestamp || !stats.id) {
|
|
522
|
+
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);
|
|
523
|
+
}
|
|
524
|
+
observedDataChannel = new ObservedDataChannel_1.ObservedDataChannel(stats.timestamp, stats.id, this);
|
|
525
|
+
this.observedDataChannels.set(stats.id, observedDataChannel);
|
|
526
|
+
this.emit('added-data-channel', observedDataChannel);
|
|
527
|
+
}
|
|
528
|
+
observedDataChannel.update(stats);
|
|
529
|
+
return observedDataChannel;
|
|
530
|
+
}
|
|
531
|
+
_updateIceCandidateStats(stats) {
|
|
532
|
+
let observedIceCandidate = this.observedIceCandidates.get(stats.id);
|
|
533
|
+
if (!observedIceCandidate) {
|
|
534
|
+
if (!stats.timestamp || !stats.id) {
|
|
535
|
+
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);
|
|
536
|
+
}
|
|
537
|
+
observedIceCandidate = new ObservedIceCandidate_1.ObservedIceCandidate(stats.timestamp, stats.id, this);
|
|
538
|
+
this.observedIceCandidates.set(stats.id, observedIceCandidate);
|
|
539
|
+
this.emit('added-ice-candidate', observedIceCandidate);
|
|
540
|
+
}
|
|
541
|
+
observedIceCandidate.update(stats);
|
|
542
|
+
return observedIceCandidate;
|
|
543
|
+
}
|
|
544
|
+
_updateIceCandidatePairStats(stats) {
|
|
545
|
+
let observedIceCandidatePair = this.observedIceCandidatesPair.get(stats.id);
|
|
546
|
+
if (!observedIceCandidatePair) {
|
|
547
|
+
if (!stats.timestamp || !stats.id) {
|
|
548
|
+
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);
|
|
549
|
+
}
|
|
550
|
+
observedIceCandidatePair = new ObservedIceCandidatePair_1.ObservedIceCandidatePair(stats.timestamp, stats.id, this);
|
|
551
|
+
this.observedIceCandidatesPair.set(stats.id, observedIceCandidatePair);
|
|
552
|
+
this.emit('added-ice-candidate-pair', observedIceCandidatePair);
|
|
553
|
+
}
|
|
554
|
+
observedIceCandidatePair.update(stats);
|
|
555
|
+
return observedIceCandidatePair;
|
|
556
|
+
}
|
|
557
|
+
_updateIceTransportStats(stats) {
|
|
558
|
+
let observedIceTransport = this.observedIceTransports.get(stats.id);
|
|
559
|
+
if (!observedIceTransport) {
|
|
560
|
+
if (!stats.timestamp || !stats.id) {
|
|
561
|
+
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);
|
|
562
|
+
}
|
|
563
|
+
observedIceTransport = new ObservedIceTransport_1.ObservedIceTransport(stats.timestamp, stats.id, this);
|
|
564
|
+
this.observedIceTransports.set(stats.id, observedIceTransport);
|
|
565
|
+
this.emit('added-ice-transport', observedIceTransport);
|
|
566
|
+
}
|
|
567
|
+
observedIceTransport.update(stats);
|
|
568
|
+
return observedIceTransport;
|
|
569
|
+
}
|
|
570
|
+
_updateInboundRtpStats(stats) {
|
|
571
|
+
let observedInboundRtp = this.observedInboundRtps.get(stats.ssrc);
|
|
572
|
+
if (!observedInboundRtp) {
|
|
573
|
+
if (!stats.timestamp || !stats.id || !stats.ssrc || !stats.kind || !stats.trackIdentifier) {
|
|
574
|
+
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);
|
|
575
|
+
}
|
|
576
|
+
observedInboundRtp = new ObservedInboundRtp_1.ObservedInboundRtp(stats.timestamp, stats.id, stats.ssrc, stats.kind, stats.trackIdentifier, this);
|
|
577
|
+
this.observedInboundRtps.set(stats.ssrc, observedInboundRtp);
|
|
578
|
+
this.emit('added-inbound-rtp', observedInboundRtp);
|
|
579
|
+
}
|
|
580
|
+
observedInboundRtp.update(stats);
|
|
581
|
+
return observedInboundRtp;
|
|
582
|
+
}
|
|
583
|
+
_updateInboundTrackSample(stats) {
|
|
584
|
+
let observedInboundTrack = this.observedInboundTracks.get(stats.id);
|
|
585
|
+
if (!observedInboundTrack) {
|
|
586
|
+
if (!stats.timestamp || !stats.id || !stats.kind) {
|
|
587
|
+
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);
|
|
588
|
+
}
|
|
589
|
+
const inboundRtp = [...this.observedInboundRtps.values()].find((inbRtp) => inbRtp.trackIdentifier === stats.id);
|
|
590
|
+
const mediaPlayout = inboundRtp ?
|
|
591
|
+
[...this.observedMediaPlayouts.values()].find((mp) => mp.id === inboundRtp.playoutId) : undefined;
|
|
592
|
+
observedInboundTrack = new ObservedInboundTrack_1.ObservedInboundTrack(stats.timestamp, stats.id, stats.kind, this, inboundRtp, mediaPlayout);
|
|
593
|
+
this.observedInboundTracks.set(stats.id, observedInboundTrack);
|
|
594
|
+
this.emit('added-inbound-track', observedInboundTrack);
|
|
595
|
+
}
|
|
596
|
+
observedInboundTrack.update(stats);
|
|
597
|
+
return observedInboundTrack;
|
|
598
|
+
}
|
|
599
|
+
_updateMediaPlayoutStats(stats) {
|
|
600
|
+
let observedMediaPlayout = this.observedMediaPlayouts.get(stats.id);
|
|
601
|
+
if (!observedMediaPlayout) {
|
|
602
|
+
if (!stats.timestamp || !stats.id || !stats.kind) {
|
|
603
|
+
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);
|
|
604
|
+
}
|
|
605
|
+
observedMediaPlayout = new ObservedMediaPlayout_1.ObservedMediaPlayout(stats.timestamp, stats.id, stats.kind, this);
|
|
606
|
+
this.observedMediaPlayouts.set(stats.id, observedMediaPlayout);
|
|
607
|
+
this.emit('added-media-playout', observedMediaPlayout);
|
|
608
|
+
}
|
|
609
|
+
observedMediaPlayout.update(stats);
|
|
610
|
+
return observedMediaPlayout;
|
|
611
|
+
}
|
|
612
|
+
_updateMediaSourceStats(stats) {
|
|
613
|
+
let observedMediaSource = this.observedMediaSources.get(stats.id);
|
|
614
|
+
if (!observedMediaSource) {
|
|
615
|
+
if (!stats.timestamp || !stats.id || !stats.kind) {
|
|
616
|
+
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);
|
|
617
|
+
}
|
|
618
|
+
observedMediaSource = new ObservedMediaSource_1.ObservedMediaSource(stats.timestamp, stats.id, stats.kind, this);
|
|
619
|
+
this.observedMediaSources.set(stats.id, observedMediaSource);
|
|
620
|
+
this.emit('added-media-source', observedMediaSource);
|
|
621
|
+
}
|
|
622
|
+
observedMediaSource.update(stats);
|
|
623
|
+
return observedMediaSource;
|
|
624
|
+
}
|
|
625
|
+
_updateOutboundRtpStats(stats) {
|
|
626
|
+
let observedOutboundRtp = this.observedOutboundRtps.get(stats.ssrc);
|
|
627
|
+
if (!observedOutboundRtp) {
|
|
628
|
+
if (!stats.timestamp || !stats.id || !stats.ssrc || !stats.kind) {
|
|
629
|
+
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);
|
|
630
|
+
}
|
|
631
|
+
observedOutboundRtp = new ObservedOutboundRtp_1.ObservedOutboundRtp(stats.timestamp, stats.id, stats.ssrc, stats.kind, this);
|
|
632
|
+
this.observedOutboundRtps.set(stats.ssrc, observedOutboundRtp);
|
|
633
|
+
this.emit('added-outbound-rtp', observedOutboundRtp);
|
|
634
|
+
}
|
|
635
|
+
observedOutboundRtp.update(stats);
|
|
636
|
+
return observedOutboundRtp;
|
|
637
|
+
}
|
|
638
|
+
_updateOutboundTrackSample(stats) {
|
|
639
|
+
let observedOutboundTrack = this.observedOutboundTracks.get(stats.id);
|
|
640
|
+
if (!observedOutboundTrack) {
|
|
641
|
+
if (!stats.timestamp || !stats.id || !stats.kind) {
|
|
642
|
+
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);
|
|
643
|
+
}
|
|
644
|
+
const observedMediaSource = [...this.observedMediaSources.values()].find((mediaSource) => mediaSource.trackIdentifier === stats.id);
|
|
645
|
+
const outboundRtps = observedMediaSource
|
|
646
|
+
? [...this.observedOutboundRtps.values()].filter((outboundRtp) => outboundRtp.mediaSourceId === observedMediaSource?.id) : undefined;
|
|
647
|
+
observedOutboundTrack = new ObservedOutboundTrack_1.ObservedOutboundTrack(stats.timestamp, stats.id, stats.kind, this, outboundRtps, observedMediaSource);
|
|
648
|
+
this.observedOutboundTracks.set(stats.id, observedOutboundTrack);
|
|
649
|
+
this.emit('added-outbound-track', observedOutboundTrack);
|
|
650
|
+
}
|
|
651
|
+
observedOutboundTrack.update(stats);
|
|
652
|
+
return observedOutboundTrack;
|
|
653
|
+
}
|
|
654
|
+
_updatePeerConnectionTransportStats(stats) {
|
|
655
|
+
let observedPeerConnectionTransport = this.observedPeerConnectionTransports.get(stats.id);
|
|
656
|
+
if (!observedPeerConnectionTransport) {
|
|
657
|
+
if (!stats.timestamp || !stats.id) {
|
|
658
|
+
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);
|
|
659
|
+
}
|
|
660
|
+
observedPeerConnectionTransport = new ObservedPeerConnectionTransport_1.ObservedPeerConnectionTransport(stats.timestamp, stats.id, this);
|
|
661
|
+
this.observedPeerConnectionTransports.set(stats.id, observedPeerConnectionTransport);
|
|
662
|
+
this.emit('added-peer-connection-transport', observedPeerConnectionTransport);
|
|
663
|
+
}
|
|
664
|
+
observedPeerConnectionTransport.update(stats);
|
|
665
|
+
return observedPeerConnectionTransport;
|
|
666
|
+
}
|
|
667
|
+
_updateRemoteInboundRtpStats(stats) {
|
|
668
|
+
let observedRemoteInboundRtp = this.observedRemoteInboundRtps.get(stats.ssrc);
|
|
669
|
+
if (!observedRemoteInboundRtp) {
|
|
670
|
+
if (!stats.timestamp || !stats.id || !stats.ssrc || !stats.kind) {
|
|
671
|
+
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);
|
|
672
|
+
}
|
|
673
|
+
observedRemoteInboundRtp = new ObservedRemoteInboundRtp_1.ObservedRemoteInboundRtp(stats.timestamp, stats.id, stats.ssrc, stats.kind, this);
|
|
674
|
+
this.observedRemoteInboundRtps.set(stats.ssrc, observedRemoteInboundRtp);
|
|
675
|
+
this.emit('added-remote-inbound-rtp', observedRemoteInboundRtp);
|
|
676
|
+
}
|
|
677
|
+
observedRemoteInboundRtp.update(stats);
|
|
678
|
+
return observedRemoteInboundRtp;
|
|
679
|
+
}
|
|
680
|
+
_updateRemoteOutboundRtpStats(stats) {
|
|
681
|
+
let observedRemoteOutboundRtp = this.observedRemoteOutboundRtps.get(stats.ssrc);
|
|
682
|
+
if (!observedRemoteOutboundRtp) {
|
|
683
|
+
if (!stats.timestamp || !stats.id || !stats.ssrc || !stats.kind) {
|
|
684
|
+
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);
|
|
685
|
+
}
|
|
686
|
+
observedRemoteOutboundRtp = new ObservedRemoteOutboundRtp_1.ObservedRemoteOutboundRtp(stats.timestamp, stats.id, stats.ssrc, stats.kind, this);
|
|
687
|
+
this.observedRemoteOutboundRtps.set(stats.ssrc, observedRemoteOutboundRtp);
|
|
688
|
+
this.emit('added-remote-outbound-rtp', observedRemoteOutboundRtp);
|
|
372
689
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
let totalScore = 0;
|
|
376
|
-
for (const score of this._stabilityScores) {
|
|
377
|
-
weight += 1;
|
|
378
|
-
counter += weight;
|
|
379
|
-
totalScore += weight * score;
|
|
380
|
-
}
|
|
381
|
-
const weightedStabilityScore = totalScore / counter;
|
|
382
|
-
let sumTrackScores = 0;
|
|
383
|
-
for (const trackScore of trackScores) {
|
|
384
|
-
sumTrackScores += trackScore.score;
|
|
385
|
-
}
|
|
386
|
-
const avgTrackScores = sumTrackScores / trackScores.length;
|
|
387
|
-
const score = {
|
|
388
|
-
remarks: [{
|
|
389
|
-
severity: 'none',
|
|
390
|
-
text: `Peer Connection stability score: ${weightedStabilityScore}`,
|
|
391
|
-
},
|
|
392
|
-
{
|
|
393
|
-
severity: 'none',
|
|
394
|
-
text: `Avg. Track score: ${avgTrackScores}`,
|
|
395
|
-
}],
|
|
396
|
-
score: Math.round(((weightedStabilityScore + avgTrackScores) * 5 * 100)) / 100.0,
|
|
397
|
-
timestamp: (_f = this._statsTimestamp) !== null && _f !== void 0 ? _f : Date.now(),
|
|
398
|
-
};
|
|
399
|
-
for (const pendingIssue of this.ωpendingIssuesForScores) {
|
|
400
|
-
switch (pendingIssue.severity) {
|
|
401
|
-
case 'critical':
|
|
402
|
-
score.score = 0.0;
|
|
403
|
-
break;
|
|
404
|
-
case 'major':
|
|
405
|
-
score.score *= 0.5;
|
|
406
|
-
break;
|
|
407
|
-
case 'minor':
|
|
408
|
-
score.score *= 0.8;
|
|
409
|
-
break;
|
|
410
|
-
}
|
|
411
|
-
score.remarks.push({
|
|
412
|
-
severity: pendingIssue.severity,
|
|
413
|
-
text: (_g = pendingIssue.description) !== null && _g !== void 0 ? _g : 'Issue occurred',
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
this.ωpendingIssuesForScores = [];
|
|
417
|
-
this.score = score;
|
|
418
|
-
this.emit('score', score);
|
|
690
|
+
observedRemoteOutboundRtp.update(stats);
|
|
691
|
+
return observedRemoteOutboundRtp;
|
|
419
692
|
}
|
|
420
693
|
}
|
|
421
694
|
exports.ObservedPeerConnection = ObservedPeerConnection;
|