@observertc/observer-js 0.42.9 → 1.0.1-57a1811.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc +6 -6
- package/README.md +0 -104
- package/lib/ObservedCall.d.ts +38 -41
- package/lib/ObservedCall.d.ts.map +1 -1
- package/lib/ObservedCall.js +97 -109
- package/lib/ObservedCertificate.d.ts +19 -0
- package/lib/ObservedCertificate.d.ts.map +1 -0
- package/lib/ObservedCertificate.js +38 -0
- package/lib/ObservedClient.d.ts +49 -127
- package/lib/ObservedClient.d.ts.map +1 -1
- package/lib/ObservedClient.js +201 -750
- package/lib/ObservedCodec.d.ts +22 -0
- package/lib/ObservedCodec.d.ts.map +1 -0
- package/lib/ObservedCodec.js +45 -0
- package/lib/ObservedDataChannel.d.ts +23 -69
- package/lib/ObservedDataChannel.d.ts.map +1 -1
- package/lib/ObservedDataChannel.js +67 -109
- package/lib/ObservedIceCandidate.d.ts +29 -0
- package/lib/ObservedIceCandidate.d.ts.map +1 -0
- package/lib/ObservedIceCandidate.js +59 -0
- package/lib/ObservedIceCandidatePair.d.ts +44 -0
- package/lib/ObservedIceCandidatePair.d.ts.map +1 -0
- package/lib/ObservedIceCandidatePair.js +111 -0
- package/lib/ObservedIceTransport.d.ts +32 -0
- package/lib/ObservedIceTransport.d.ts.map +1 -0
- package/lib/ObservedIceTransport.js +65 -0
- package/lib/ObservedInboundRtp.d.ts +92 -0
- package/lib/ObservedInboundRtp.d.ts.map +1 -0
- package/lib/ObservedInboundRtp.js +193 -0
- package/lib/ObservedInboundTrack.d.ts +29 -0
- package/lib/ObservedInboundTrack.d.ts.map +1 -0
- package/lib/ObservedInboundTrack.js +57 -0
- package/lib/ObservedMediaPlayout.d.ts +22 -0
- package/lib/ObservedMediaPlayout.d.ts.map +1 -0
- package/lib/ObservedMediaPlayout.js +42 -0
- package/lib/ObservedMediaSource.d.ts +28 -0
- package/lib/ObservedMediaSource.d.ts.map +1 -0
- package/lib/ObservedMediaSource.js +55 -0
- package/lib/ObservedOutboundRtp.d.ts +62 -0
- package/lib/ObservedOutboundRtp.d.ts.map +1 -0
- package/lib/ObservedOutboundRtp.js +144 -0
- package/lib/ObservedOutboundTrack.d.ts +29 -0
- package/lib/ObservedOutboundTrack.d.ts.map +1 -0
- package/lib/ObservedOutboundTrack.js +57 -0
- package/lib/ObservedPeerConnection.d.ts +128 -78
- package/lib/ObservedPeerConnection.d.ts.map +1 -1
- package/lib/ObservedPeerConnection.js +624 -357
- package/lib/ObservedPeerConnectionTransport.d.ts +17 -0
- package/lib/ObservedPeerConnectionTransport.d.ts.map +1 -0
- package/lib/ObservedPeerConnectionTransport.js +34 -0
- package/lib/ObservedRemoteInboundRtp.d.ts +30 -0
- package/lib/ObservedRemoteInboundRtp.d.ts.map +1 -0
- package/lib/ObservedRemoteInboundRtp.js +60 -0
- package/lib/ObservedRemoteOutboundRtp.d.ts +30 -0
- package/lib/ObservedRemoteOutboundRtp.d.ts.map +1 -0
- package/lib/ObservedRemoteOutboundRtp.js +60 -0
- package/lib/ObservedTURN.d.ts +31 -0
- package/lib/ObservedTURN.d.ts.map +1 -0
- package/lib/ObservedTURN.js +58 -0
- package/lib/ObservedTurnServer.d.ts +25 -0
- package/lib/ObservedTurnServer.d.ts.map +1 -0
- package/lib/ObservedTurnServer.js +59 -0
- package/lib/Observer.d.ts +31 -51
- package/lib/Observer.d.ts.map +1 -1
- package/lib/Observer.js +75 -229
- package/lib/common/Middleware.d.ts +10 -1
- package/lib/common/Middleware.d.ts.map +1 -1
- package/lib/common/Middleware.js +55 -36
- package/lib/common/logger.d.ts +8 -4
- package/lib/common/logger.d.ts.map +1 -1
- package/lib/common/logger.js +44 -68
- package/lib/common/types.d.ts +0 -21
- package/lib/common/types.d.ts.map +1 -1
- package/lib/common/types.js +1 -0
- package/lib/common/utils.d.ts +1 -0
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +13 -1
- package/lib/detectors/Detector.d.ts +5 -0
- package/lib/detectors/Detector.d.ts.map +1 -0
- package/lib/detectors/Detector.js +3 -0
- package/lib/detectors/Detectors.d.ts +11 -0
- package/lib/detectors/Detectors.d.ts.map +1 -0
- package/lib/detectors/Detectors.js +34 -0
- package/lib/index.d.ts +24 -25
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +41 -41
- package/lib/monitors/TurnUsageMonitor.d.ts +0 -52
- package/lib/monitors/TurnUsageMonitor.d.ts.map +1 -1
- package/lib/monitors/TurnUsageMonitor.js +145 -120
- package/lib/schema/ClientEventTypes.d.ts +33 -0
- package/lib/schema/ClientEventTypes.d.ts.map +1 -0
- package/lib/schema/ClientEventTypes.js +38 -0
- package/lib/schema/ClientMetaTypes.d.ts +34 -0
- package/lib/schema/ClientMetaTypes.d.ts.map +1 -0
- package/lib/schema/ClientMetaTypes.js +16 -0
- package/lib/schema/ClientSample.d.ts +1333 -0
- package/lib/schema/ClientSample.d.ts.map +1 -0
- package/lib/schema/ClientSample.js +4 -0
- package/lib/scores/CalculatedScore.d.ts +6 -0
- package/lib/scores/CalculatedScore.d.ts.map +1 -0
- package/lib/scores/DefaultCallScoreCalculator.d.ts +7 -0
- package/lib/scores/DefaultCallScoreCalculator.d.ts.map +1 -0
- package/lib/scores/DefaultCallScoreCalculator.js +21 -0
- package/lib/scores/ScoreCalculator.d.ts +4 -0
- package/lib/scores/ScoreCalculator.d.ts.map +1 -0
- package/lib/scores/ScoreCalculator.js +2 -0
- package/lib/utils/CallUpdater.d.ts +5 -0
- package/lib/utils/CallUpdater.d.ts.map +1 -0
- package/lib/utils/CallUpdater.js +2 -0
- package/lib/utils/OnAllClientCallUpdater.d.ts +16 -0
- package/lib/utils/OnAllClientCallUpdater.d.ts.map +1 -0
- package/lib/utils/OnAllClientCallUpdater.js +58 -0
- package/lib/utils/RemoteTrackResolver.d.ts +7 -0
- package/lib/utils/RemoteTrackResolver.d.ts.map +1 -0
- package/lib/utils/RemoteTrackResolver.js +2 -0
- package/lib/utils/onAnyClientCallUpdater.d.ts +14 -0
- package/lib/utils/onAnyClientCallUpdater.d.ts.map +1 -0
- package/lib/utils/onAnyClientCallUpdater.js +51 -0
- package/package.json +4 -4
- package/src/ObservedCall.ts +116 -166
- package/src/ObservedCertificate.ts +43 -0
- package/src/ObservedClient.ts +213 -1060
- package/src/ObservedCodec.ts +49 -0
- package/src/ObservedDataChannel.ts +68 -181
- package/src/ObservedIceCandidate.ts +64 -0
- package/src/ObservedIceCandidatePair.ts +118 -0
- package/src/ObservedIceTransport.ts +70 -0
- package/src/ObservedInboundRtp.ts +205 -0
- package/src/ObservedInboundTrack.ts +70 -0
- package/src/ObservedMediaPlayout.ts +49 -0
- package/src/ObservedMediaSource.ts +60 -0
- package/src/ObservedOutboundRtp.ts +156 -0
- package/src/ObservedOutboundTrack.ts +69 -0
- package/src/ObservedPeerConnection.ts +827 -405
- package/src/ObservedPeerConnectionTransport.ts +38 -0
- package/src/ObservedRemoteInboundRtp.ts +64 -0
- package/src/ObservedRemoteOutboundRtp.ts +65 -0
- package/src/ObservedTURN.ts +86 -0
- package/src/ObservedTurnServer.ts +72 -0
- package/src/Observer.ts +91 -302
- package/src/common/Middleware.ts +70 -42
- package/src/common/logger.ts +60 -69
- package/src/common/types.ts +0 -42
- package/src/common/utils.ts +12 -0
- package/src/detectors/Detector.ts +6 -0
- package/src/detectors/Detectors.ts +38 -0
- package/src/index.ts +24 -90
- package/src/monitors/TurnUsageMonitor.ts +164 -164
- package/src/schema/ClientEventTypes.ts +36 -0
- package/src/schema/ClientMetaTypes.ts +41 -0
- package/src/schema/ClientSample.ts +1682 -0
- package/src/scores/CalculatedScore.ts +6 -0
- package/src/scores/DefaultCallScoreCalculator.ts +23 -0
- package/src/scores/ScoreCalculator.ts +3 -0
- package/src/utils/CallUpdater.ts +5 -0
- package/src/utils/OnAllClientCallUpdater.ts +68 -0
- package/src/utils/RemoteTrackResolver.ts +12 -0
- package/src/utils/onAnyClientCallUpdater.ts +59 -0
- package/tsconfig.json +3 -3
- package/lib/ObservedICE.d.ts +0 -64
- package/lib/ObservedICE.d.ts.map +0 -1
- package/lib/ObservedICE.js +0 -141
- package/lib/ObservedInboundAudioTrack.d.ts +0 -96
- package/lib/ObservedInboundAudioTrack.d.ts.map +0 -1
- package/lib/ObservedInboundAudioTrack.js +0 -217
- package/lib/ObservedInboundVideoTrack.d.ts +0 -101
- package/lib/ObservedInboundVideoTrack.d.ts.map +0 -1
- package/lib/ObservedInboundVideoTrack.js +0 -232
- package/lib/ObservedOutboundAudioTrack.d.ts +0 -87
- package/lib/ObservedOutboundAudioTrack.d.ts.map +0 -1
- package/lib/ObservedOutboundAudioTrack.js +0 -186
- package/lib/ObservedOutboundVideoTrack.d.ts +0 -91
- package/lib/ObservedOutboundVideoTrack.d.ts.map +0 -1
- package/lib/ObservedOutboundVideoTrack.js +0 -193
- package/lib/ObservedSfu.d.ts +0 -59
- package/lib/ObservedSfu.d.ts.map +0 -1
- package/lib/ObservedSfu.js +0 -157
- package/lib/ObservedSfuInboundRtpPad.d.ts +0 -42
- package/lib/ObservedSfuInboundRtpPad.d.ts.map +0 -1
- package/lib/ObservedSfuInboundRtpPad.js +0 -71
- package/lib/ObservedSfuOutboundRtpPad.d.ts +0 -42
- package/lib/ObservedSfuOutboundRtpPad.d.ts.map +0 -1
- package/lib/ObservedSfuOutboundRtpPad.js +0 -72
- package/lib/ObservedSfuSctpChannel.d.ts +0 -42
- package/lib/ObservedSfuSctpChannel.d.ts.map +0 -1
- package/lib/ObservedSfuSctpChannel.js +0 -57
- package/lib/ObservedSfuTransport.d.ts +0 -58
- package/lib/ObservedSfuTransport.d.ts.map +0 -1
- package/lib/ObservedSfuTransport.js +0 -120
- package/lib/RemoteTrackAssigner.d.ts +0 -14
- package/lib/RemoteTrackAssigner.d.ts.map +0 -1
- package/lib/RemoteTrackAssigner.js +0 -52
- package/lib/ReportsCollector.d.ts +0 -109
- package/lib/ReportsCollector.d.ts.map +0 -1
- package/lib/ReportsCollector.js +0 -207
- package/lib/common/CalculatedScore.d.ts +0 -80
- package/lib/common/CalculatedScore.d.ts.map +0 -1
- package/lib/common/CalculatedScore.js +0 -162
- package/lib/common/CallEventType.d.ts +0 -63
- package/lib/common/CallEventType.d.ts.map +0 -1
- package/lib/common/CallEventType.js +0 -39
- package/lib/common/CallMetaReports.d.ts +0 -42
- package/lib/common/CallMetaReports.d.ts.map +0 -1
- package/lib/common/CallMetaReports.js +0 -36
- package/lib/common/QualityScoreUtils.d.ts +0 -1
- package/lib/common/QualityScoreUtils.d.ts.map +0 -1
- package/lib/common/QualityScoreUtils.js +0 -1
- package/lib/common/TypedEventEmitter.d.ts +0 -22
- package/lib/common/TypedEventEmitter.d.ts.map +0 -1
- package/lib/common/TypedEventEmitter.js +0 -11
- package/lib/common/callEventReports.d.ts +0 -10
- package/lib/common/callEventReports.d.ts.map +0 -1
- package/lib/common/callEventReports.js +0 -112
- package/lib/monitors/CallSummary.d.ts +0 -37
- package/lib/monitors/CallSummary.d.ts.map +0 -1
- package/lib/monitors/CallSummaryMonitor.d.ts +0 -32
- package/lib/monitors/CallSummaryMonitor.d.ts.map +0 -1
- package/lib/monitors/CallSummaryMonitor.js +0 -152
- package/lib/monitors/ClientIssueMonitor.d.ts +0 -32
- package/lib/monitors/ClientIssueMonitor.d.ts.map +0 -1
- package/lib/monitors/ClientIssueMonitor.js +0 -49
- package/lib/monitors/SfuServerMonitor.d.ts +0 -79
- package/lib/monitors/SfuServerMonitor.d.ts.map +0 -1
- package/lib/monitors/SfuServerMonitor.js +0 -198
- package/src/ObservedICE.ts +0 -237
- package/src/ObservedInboundAudioTrack.ts +0 -344
- package/src/ObservedInboundVideoTrack.ts +0 -361
- package/src/ObservedOutboundAudioTrack.ts +0 -307
- package/src/ObservedOutboundVideoTrack.ts +0 -319
- package/src/ObservedSfu.ts +0 -231
- package/src/ObservedSfuInboundRtpPad.ts +0 -106
- package/src/ObservedSfuOutboundRtpPad.ts +0 -107
- package/src/ObservedSfuSctpChannel.ts +0 -103
- package/src/ObservedSfuTransport.ts +0 -185
- package/src/RemoteTrackAssigner.ts +0 -68
- package/src/ReportsCollector.ts +0 -336
- package/src/common/CalculatedScore.ts +0 -188
- package/src/common/CallEventType.ts +0 -69
- package/src/common/CallMetaReports.ts +0 -82
- package/src/common/QualityScoreUtils.ts +0 -0
- package/src/common/TypedEventEmitter.ts +0 -32
- package/src/common/callEventReports.ts +0 -178
- package/src/monitors/CallSummary.ts +0 -38
- package/src/monitors/CallSummaryMonitor.ts +0 -192
- package/src/monitors/ClientIssueMonitor.ts +0 -88
- package/src/monitors/SfuServerMonitor.ts +0 -285
- /package/lib/{monitors/CallSummary.js → scores/CalculatedScore.js} +0 -0
package/lib/Observer.js
CHANGED
|
@@ -1,255 +1,101 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.Observer = void 0;
|
|
15
4
|
const logger_1 = require("./common/logger");
|
|
16
5
|
const ObservedCall_1 = require("./ObservedCall");
|
|
17
|
-
const ReportsCollector_1 = require("./ReportsCollector");
|
|
18
6
|
const events_1 = require("events");
|
|
19
|
-
const
|
|
20
|
-
const ObservedSfu_1 = require("./ObservedSfu");
|
|
21
|
-
const CallSummaryMonitor_1 = require("./monitors/CallSummaryMonitor");
|
|
22
|
-
const TurnUsageMonitor_1 = require("./monitors/TurnUsageMonitor");
|
|
23
|
-
const ClientIssueMonitor_1 = require("./monitors/ClientIssueMonitor");
|
|
24
|
-
const SfuServerMonitor_1 = require("./monitors/SfuServerMonitor");
|
|
7
|
+
const ObservedTURN_1 = require("./ObservedTURN");
|
|
25
8
|
const logger = (0, logger_1.createLogger)('Observer');
|
|
26
9
|
class Observer extends events_1.EventEmitter {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return new Observer(config);
|
|
10
|
+
observedTURN = new ObservedTURN_1.ObservedTURN();
|
|
11
|
+
observedCalls = new Map();
|
|
12
|
+
config;
|
|
13
|
+
closed = false;
|
|
14
|
+
numberOfClients = 0;
|
|
15
|
+
numberOfInboundRtpStreams = 0;
|
|
16
|
+
numberOfOutboundRtpStreams = 0;
|
|
17
|
+
numberOfDataChannels = 0;
|
|
18
|
+
numberOfPeerConnections = 0;
|
|
19
|
+
get numberOfCalls() {
|
|
20
|
+
return this.observedCalls.size;
|
|
39
21
|
}
|
|
40
|
-
|
|
22
|
+
_timer;
|
|
23
|
+
constructor(config = {
|
|
24
|
+
updateIntervalInMs: 10000,
|
|
25
|
+
}) {
|
|
41
26
|
super();
|
|
42
|
-
this.config = config;
|
|
43
|
-
this.reports = new ReportsCollector_1.ReportsCollector();
|
|
44
|
-
this._observedCalls = new Map();
|
|
45
|
-
this._observedSfus = new Map();
|
|
46
|
-
this._monitors = new Map();
|
|
47
|
-
this._closed = false;
|
|
48
27
|
this.setMaxListeners(Infinity);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return;
|
|
54
|
-
if (this.config.maxReports < collectedReports) {
|
|
55
|
-
this._emitReports();
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
this._emitReports();
|
|
59
|
-
this.once('close', () => {
|
|
60
|
-
this.reports.off('newreport', onNewReport);
|
|
61
|
-
this.reports.off('reports', onReports);
|
|
62
|
-
});
|
|
63
|
-
this.reports.on('newreport', onNewReport);
|
|
64
|
-
this.reports.on('reports', onReports);
|
|
65
|
-
}
|
|
66
|
-
createObservedCall(config) {
|
|
67
|
-
if (this._closed) {
|
|
68
|
-
throw new Error('Attempted to create a call source on a closed observer');
|
|
69
|
-
}
|
|
70
|
-
const { appData, reportCallEnded = true, reportCallStarted = true } = config, model = __rest(config, ["appData", "reportCallEnded", "reportCallStarted"]);
|
|
71
|
-
const call = new ObservedCall_1.ObservedCall(Object.assign(Object.assign({}, model), { serviceId: this.config.defaultServiceId }), this, appData);
|
|
72
|
-
if (this._closed)
|
|
73
|
-
throw new Error('Cannot create an observed call on a closed observer');
|
|
74
|
-
if (this._observedCalls.has(call.callId))
|
|
75
|
-
throw new Error(`Observed Call with id ${call.callId} already exists`);
|
|
76
|
-
call.once('close', () => {
|
|
77
|
-
var _a;
|
|
78
|
-
this._observedCalls.delete(call.callId);
|
|
79
|
-
reportCallEnded && this.reports.addCallEventReport((0, callEventReports_1.createCallEndedEventReport)(call.serviceId, call.roomId, call.callId, (_a = call.observationEnded) !== null && _a !== void 0 ? _a : Date.now()));
|
|
80
|
-
});
|
|
81
|
-
this._observedCalls.set(call.callId, call);
|
|
82
|
-
reportCallStarted && this.reports.addCallEventReport((0, callEventReports_1.createCallStartedEventReport)(call.serviceId, call.roomId, call.callId, call.observationStarted));
|
|
83
|
-
this.emit('newcall', call);
|
|
84
|
-
return call;
|
|
85
|
-
}
|
|
86
|
-
createObservedSfu(model, appData) {
|
|
87
|
-
if (this._closed) {
|
|
88
|
-
throw new Error('Attempted to create an sfu source on a closed observer');
|
|
28
|
+
this.config = config;
|
|
29
|
+
this.update = this.update.bind(this);
|
|
30
|
+
if (this.config.updateIntervalInMs) {
|
|
31
|
+
this._timer = setInterval(this.update.bind(this), this.config.updateIntervalInMs);
|
|
89
32
|
}
|
|
90
|
-
const sfu = new ObservedSfu_1.ObservedSfu(model, this, appData);
|
|
91
|
-
if (this._closed)
|
|
92
|
-
throw new Error('Cannot create an observed sfu on a closed observer');
|
|
93
|
-
if (this._observedSfus.has(sfu.sfuId))
|
|
94
|
-
throw new Error(`Observed SFU with id ${sfu.sfuId} already exists`);
|
|
95
|
-
sfu.once('close', () => {
|
|
96
|
-
this._observedSfus.delete(sfu.sfuId);
|
|
97
|
-
});
|
|
98
|
-
this._observedSfus.set(sfu.sfuId, sfu);
|
|
99
|
-
this.emit('newsfu', sfu);
|
|
100
|
-
return sfu;
|
|
101
|
-
}
|
|
102
|
-
createCallSummaryMonitor(options) {
|
|
103
|
-
if (this._closed)
|
|
104
|
-
throw new Error('Cannot create a call summary monitor on a closed observer');
|
|
105
|
-
const existingMonitor = this._monitors.get(CallSummaryMonitor_1.CallSummaryMonitor.name);
|
|
106
|
-
if (existingMonitor)
|
|
107
|
-
return existingMonitor;
|
|
108
|
-
const monitor = new CallSummaryMonitor_1.CallSummaryMonitor(options);
|
|
109
|
-
const onNewCall = (call) => {
|
|
110
|
-
monitor.addCall(call);
|
|
111
|
-
call.once('close', () => {
|
|
112
|
-
var _a;
|
|
113
|
-
return setTimeout(() => {
|
|
114
|
-
const summary = monitor.takeSummary(call.callId);
|
|
115
|
-
summary && monitor.emit('summary', summary);
|
|
116
|
-
}, (_a = options === null || options === void 0 ? void 0 : options.timeoutAfterCallClose) !== null && _a !== void 0 ? _a : 1000);
|
|
117
|
-
});
|
|
118
|
-
};
|
|
119
|
-
monitor.once('close', () => {
|
|
120
|
-
this._monitors.delete(CallSummaryMonitor_1.CallSummaryMonitor.name);
|
|
121
|
-
this.off('newcall', onNewCall);
|
|
122
|
-
});
|
|
123
|
-
this._monitors.set(CallSummaryMonitor_1.CallSummaryMonitor.name, monitor);
|
|
124
|
-
this.on('newcall', onNewCall);
|
|
125
|
-
this.once('close', () => {
|
|
126
|
-
monitor.close();
|
|
127
|
-
});
|
|
128
|
-
return monitor;
|
|
129
|
-
}
|
|
130
|
-
createTurnUsageMonitor() {
|
|
131
|
-
if (this._closed)
|
|
132
|
-
throw new Error('Cannot create a turn usage monitor on a closed observer');
|
|
133
|
-
const existingMonitor = this._monitors.get(TurnUsageMonitor_1.TurnUsageMonitor.name);
|
|
134
|
-
if (existingMonitor)
|
|
135
|
-
return existingMonitor;
|
|
136
|
-
const monitor = new TurnUsageMonitor_1.TurnUsageMonitor();
|
|
137
|
-
const onNewCall = (call) => {
|
|
138
|
-
const onNewClient = (client) => {
|
|
139
|
-
const onNewPeerConnection = (pc) => {
|
|
140
|
-
const onUsingTurnChanged = (usingTurn) => {
|
|
141
|
-
if (usingTurn)
|
|
142
|
-
monitor.addPeerConnection(pc);
|
|
143
|
-
else
|
|
144
|
-
monitor.removePeerConnection(pc);
|
|
145
|
-
};
|
|
146
|
-
pc.once('close', () => {
|
|
147
|
-
pc.ICE.off('usingturnchanged', onUsingTurnChanged);
|
|
148
|
-
monitor.removePeerConnection(pc);
|
|
149
|
-
});
|
|
150
|
-
pc.ICE.on('usingturnchanged', onUsingTurnChanged);
|
|
151
|
-
};
|
|
152
|
-
client.once('close', () => client.off('newpeerconnection', onNewPeerConnection));
|
|
153
|
-
client.on('newpeerconnection', onNewPeerConnection);
|
|
154
|
-
};
|
|
155
|
-
call.once('close', () => call.off('newclient', onNewClient));
|
|
156
|
-
call.on('newclient', onNewClient);
|
|
157
|
-
};
|
|
158
|
-
monitor.once('close', () => {
|
|
159
|
-
this._monitors.delete(TurnUsageMonitor_1.TurnUsageMonitor.name);
|
|
160
|
-
this.off('newcall', onNewCall);
|
|
161
|
-
});
|
|
162
|
-
this._monitors.set(TurnUsageMonitor_1.TurnUsageMonitor.name, monitor);
|
|
163
|
-
this.on('newcall', onNewCall);
|
|
164
|
-
this.once('close', () => {
|
|
165
|
-
monitor.close();
|
|
166
|
-
});
|
|
167
|
-
return monitor;
|
|
168
33
|
}
|
|
169
|
-
|
|
170
|
-
if (this.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (existingMonitor)
|
|
174
|
-
return existingMonitor;
|
|
175
|
-
const monitor = new SfuServerMonitor_1.SfuServerMonitor({
|
|
176
|
-
tooHighRttAlertSettings: {
|
|
177
|
-
minNumberOfPeerConnections: 10,
|
|
178
|
-
percentageOfPeerConnectionsHighWatermark: 0.5,
|
|
179
|
-
percentageOfPeerConnectionsLowWatermark: 0.2,
|
|
180
|
-
threshold: 'rtt-gt-300',
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
const onNewCall = (call) => {
|
|
184
|
-
const onNewClient = (client) => {
|
|
185
|
-
const onNewPeerConnection = (pc) => {
|
|
186
|
-
monitor.addPeerConnection(pc);
|
|
187
|
-
};
|
|
188
|
-
client.once('close', () => client.off('newpeerconnection', onNewPeerConnection));
|
|
189
|
-
client.on('newpeerconnection', onNewPeerConnection);
|
|
190
|
-
};
|
|
191
|
-
call.once('close', () => call.off('newclient', onNewClient));
|
|
192
|
-
call.on('newclient', onNewClient);
|
|
193
|
-
};
|
|
194
|
-
monitor.once('close', () => {
|
|
195
|
-
this._monitors.delete(SfuServerMonitor_1.SfuServerMonitor.name);
|
|
196
|
-
this.off('newcall', onNewCall);
|
|
197
|
-
});
|
|
198
|
-
this._monitors.set(SfuServerMonitor_1.SfuServerMonitor.name, monitor);
|
|
199
|
-
this.on('newcall', onNewCall);
|
|
200
|
-
this.once('close', () => {
|
|
201
|
-
monitor.close();
|
|
202
|
-
});
|
|
203
|
-
return monitor;
|
|
34
|
+
getObservedCall(callId) {
|
|
35
|
+
if (this.closed || !this.observedCalls.has(callId))
|
|
36
|
+
return;
|
|
37
|
+
return this.observedCalls.get(callId);
|
|
204
38
|
}
|
|
205
|
-
|
|
206
|
-
if (this.
|
|
207
|
-
throw new Error('
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
this.off('newcall', onNewCall);
|
|
216
|
-
});
|
|
217
|
-
this._monitors.set(ClientIssueMonitor_1.ClientIssueMonitor.name, monitor);
|
|
218
|
-
this.on('newcall', onNewCall);
|
|
219
|
-
this.once('close', () => {
|
|
220
|
-
monitor.close();
|
|
39
|
+
createObservedCall(settings) {
|
|
40
|
+
if (this.closed) {
|
|
41
|
+
throw new Error('Attempted to create a call source on a closed observer');
|
|
42
|
+
}
|
|
43
|
+
const observedCall = new ObservedCall_1.ObservedCall(settings, this);
|
|
44
|
+
if (this.observedCalls.has(observedCall.callId))
|
|
45
|
+
throw new Error(`Observed Call with id ${observedCall.callId} already exists`);
|
|
46
|
+
observedCall.once('close', () => {
|
|
47
|
+
this.observedCalls.delete(observedCall.callId);
|
|
48
|
+
observedCall.off('update', this.update);
|
|
221
49
|
});
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
return
|
|
226
|
-
}
|
|
227
|
-
get observedSfus() {
|
|
228
|
-
return this._observedSfus;
|
|
229
|
-
}
|
|
230
|
-
get closed() {
|
|
231
|
-
return this._closed;
|
|
50
|
+
this.observedCalls.set(observedCall.callId, observedCall);
|
|
51
|
+
observedCall.on('update', this.update);
|
|
52
|
+
this.emit('newcall', observedCall);
|
|
53
|
+
return observedCall;
|
|
232
54
|
}
|
|
233
55
|
close() {
|
|
234
|
-
if (this.
|
|
56
|
+
if (this.closed) {
|
|
235
57
|
return logger.debug('Attempted to close twice');
|
|
236
58
|
}
|
|
237
|
-
this.
|
|
238
|
-
this.
|
|
59
|
+
this.closed = true;
|
|
60
|
+
clearInterval(this._timer);
|
|
61
|
+
this._timer = undefined;
|
|
62
|
+
this.observedCalls.forEach((call) => call.close());
|
|
239
63
|
this.emit('close');
|
|
240
64
|
}
|
|
241
|
-
|
|
242
|
-
if (this.
|
|
243
|
-
|
|
244
|
-
|
|
65
|
+
accept(sample) {
|
|
66
|
+
if (this.closed)
|
|
67
|
+
return;
|
|
68
|
+
if (!sample.callId)
|
|
69
|
+
return logger.warn('Received sample without callId. %o', sample);
|
|
70
|
+
if (!sample.clientId)
|
|
71
|
+
return logger.warn('Received sample without clientId %o', sample);
|
|
72
|
+
const call = this.getObservedCall(sample.callId);
|
|
73
|
+
if (!call) {
|
|
74
|
+
return logger.warn(`Received sample for unknown call ${sample.callId}. %o`, sample);
|
|
75
|
+
}
|
|
76
|
+
const client = call.getObservedClient(sample.clientId);
|
|
77
|
+
if (!client) {
|
|
78
|
+
return logger.warn(`Received sample for unknown client ${sample.clientId} in call ${sample.callId}. %o`, sample);
|
|
79
|
+
}
|
|
80
|
+
client.accept(sample);
|
|
81
|
+
}
|
|
82
|
+
update() {
|
|
83
|
+
if (this.closed) {
|
|
84
|
+
return;
|
|
245
85
|
}
|
|
246
|
-
this.
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
86
|
+
this.numberOfInboundRtpStreams = 0;
|
|
87
|
+
this.numberOfOutboundRtpStreams = 0;
|
|
88
|
+
this.numberOfPeerConnections = 0;
|
|
89
|
+
this.numberOfDataChannels = 0;
|
|
90
|
+
this.numberOfClients = 0;
|
|
91
|
+
for (const call of this.observedCalls.values()) {
|
|
92
|
+
this.numberOfInboundRtpStreams += call.numberOfInboundRtpStreams;
|
|
93
|
+
this.numberOfOutboundRtpStreams += call.numberOfOutboundRtpStreams;
|
|
94
|
+
this.numberOfPeerConnections += call.numberOfPeerConnections;
|
|
95
|
+
this.numberOfDataChannels += call.numberOfDataChannels;
|
|
96
|
+
this.numberOfClients += call.numberOfClients;
|
|
252
97
|
}
|
|
98
|
+
this.observedTURN.update();
|
|
253
99
|
}
|
|
254
100
|
}
|
|
255
101
|
exports.Observer = Observer;
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
export type Middleware<T> = (input: T, next: (nextInput: T) => void) => void;
|
|
2
2
|
export interface Processor<T> {
|
|
3
|
+
finalCallback?: Callback<T>;
|
|
3
4
|
process(value: T): void;
|
|
4
5
|
addMiddleware(...middlewares: Middleware<T>[]): Processor<T>;
|
|
5
6
|
removeMiddleware(...middlewares: Middleware<T>[]): Processor<T>;
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
+
type Callback<T> = (input: T) => void;
|
|
9
|
+
export declare class MiddlewareProcessor<T> implements Processor<T> {
|
|
10
|
+
private stack;
|
|
11
|
+
finalCallback?: Callback<T>;
|
|
12
|
+
addMiddleware(...middlewares: Middleware<T>[]): Processor<T>;
|
|
13
|
+
removeMiddleware(...middlewares: Middleware<T>[]): Processor<T>;
|
|
14
|
+
process(value: T): void;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
8
17
|
//# sourceMappingURL=Middleware.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Middleware.d.ts","sourceRoot":"","sources":["../../src/common/Middleware.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAC3B,KAAK,EAAE,CAAC,EACR,IAAI,EAAE,CAAC,SAAS,EAAE,CAAC,KAAK,IAAI,KACxB,IAAI,CAAC;AAEV,MAAM,WAAW,SAAS,CAAC,CAAC;IAC3B,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACxB,aAAa,CAAC,GAAG,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IAC7D,gBAAgB,CAAC,GAAG,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;CAChE;AAED,
|
|
1
|
+
{"version":3,"file":"Middleware.d.ts","sourceRoot":"","sources":["../../src/common/Middleware.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAC3B,KAAK,EAAE,CAAC,EACR,IAAI,EAAE,CAAC,SAAS,EAAE,CAAC,KAAK,IAAI,KACxB,IAAI,CAAC;AAEV,MAAM,WAAW,SAAS,CAAC,CAAC;IAC3B,aAAa,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACxB,aAAa,CAAC,GAAG,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IAC7D,gBAAgB,CAAC,GAAG,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;CAChE;AAED,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAoCtC,qBAAa,mBAAmB,CAAC,CAAC,CAAE,YAAW,SAAS,CAAC,CAAC,CAAC;IAC1D,OAAO,CAAC,KAAK,CAAuB;IAC7B,aAAa,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAE5B,aAAa,CAAC,GAAG,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;IAQ5D,gBAAgB,CAAC,GAAG,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;IAc/D,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;CAS9B"}
|
package/lib/common/Middleware.js
CHANGED
|
@@ -1,41 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
exports.MiddlewareProcessor = void 0;
|
|
4
|
+
class Executor {
|
|
5
|
+
stack;
|
|
6
|
+
finalCallback;
|
|
7
|
+
done = false;
|
|
8
|
+
index = 0;
|
|
9
|
+
prevIndex = -1;
|
|
10
|
+
constructor(stack, finalCallback) {
|
|
11
|
+
this.stack = stack;
|
|
12
|
+
this.finalCallback = finalCallback;
|
|
13
|
+
}
|
|
14
|
+
// Executes the middleware stack
|
|
15
|
+
execute(input) {
|
|
16
|
+
if (this.index <= this.prevIndex) {
|
|
17
|
+
throw new Error('Middleware must call next() only once!');
|
|
18
|
+
}
|
|
19
|
+
else if (this.done) {
|
|
20
|
+
throw new Error('Middleware stack has already been executed!');
|
|
21
|
+
}
|
|
22
|
+
this.prevIndex = this.index;
|
|
23
|
+
const middleware = this.stack[this.index];
|
|
24
|
+
this.index++;
|
|
25
|
+
if (middleware) {
|
|
26
|
+
return middleware(input, (nextInput) => this.execute(nextInput));
|
|
27
|
+
}
|
|
28
|
+
this.done = true;
|
|
29
|
+
this.finalCallback?.(input);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
class MiddlewareProcessor {
|
|
33
|
+
stack = [];
|
|
34
|
+
finalCallback;
|
|
35
|
+
addMiddleware(...middlewares) {
|
|
36
|
+
if (middlewares && middlewares.length > 0) {
|
|
37
|
+
this.stack.push(...middlewares);
|
|
38
|
+
}
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
removeMiddleware(...middlewares) {
|
|
42
|
+
if (middlewares && middlewares.length > 0) {
|
|
43
|
+
for (const middleware of middlewares) {
|
|
44
|
+
const index = this.stack.indexOf(middleware);
|
|
45
|
+
if (index >= 0) {
|
|
46
|
+
this.stack.splice(index, 1);
|
|
19
47
|
}
|
|
20
48
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (!middleware)
|
|
32
|
-
return;
|
|
33
|
-
const next = (nextInput) => execute(index + 1, nextInput);
|
|
34
|
-
return middleware(input, next);
|
|
35
|
-
};
|
|
36
|
-
return execute(0, value);
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
return result;
|
|
49
|
+
}
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
process(value) {
|
|
53
|
+
if (this.stack.length === 0) {
|
|
54
|
+
return this.finalCallback?.(value);
|
|
55
|
+
}
|
|
56
|
+
const executor = new Executor(this.stack, this.finalCallback);
|
|
57
|
+
executor.execute(value);
|
|
58
|
+
}
|
|
40
59
|
}
|
|
41
|
-
exports.
|
|
60
|
+
exports.MiddlewareProcessor = MiddlewareProcessor;
|
package/lib/common/logger.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
2
1
|
export interface Logger {
|
|
3
2
|
trace(...args: any[]): void;
|
|
4
3
|
debug(...args: any[]): void;
|
|
@@ -6,8 +5,13 @@ export interface Logger {
|
|
|
6
5
|
warn(...args: any[]): void;
|
|
7
6
|
error(...args: any[]): void;
|
|
8
7
|
}
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
export interface ObserverLogger {
|
|
9
|
+
trace(module: string, ...args: any[]): void;
|
|
10
|
+
debug(module: string, ...args: any[]): void;
|
|
11
|
+
info(module: string, ...args: any[]): void;
|
|
12
|
+
warn(module: string, ...args: any[]): void;
|
|
13
|
+
error(module: string, ...args: any[]): void;
|
|
14
|
+
}
|
|
12
15
|
export declare function createLogger(moduleName: string): Logger;
|
|
16
|
+
export declare function setObserverLogger(logger: ObserverLogger): void;
|
|
13
17
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/common/logger.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/common/logger.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IAEtB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE5B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE5B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE3B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE3B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;IAE9B,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE5C,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE5C,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE3C,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE3C,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;CAC5C;AA8BD,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAuBvD;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,QAEvD"}
|
package/lib/common/logger.js
CHANGED
|
@@ -1,74 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
let
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// eslint-disable-next-line no-console
|
|
8
|
-
|
|
9
|
-
//
|
|
10
|
-
debug
|
|
11
|
-
// eslint-disable-next-line no-console
|
|
12
|
-
info: (...args) => console.log(...args),
|
|
13
|
-
// eslint-disable-next-line no-console
|
|
14
|
-
warn: (...args) => console.warn(...args),
|
|
15
|
-
// eslint-disable-next-line no-console
|
|
16
|
-
error: (...args) => console.error(...args),
|
|
17
|
-
};
|
|
18
|
-
function setLogLevel(level) {
|
|
19
|
-
logLevel = level;
|
|
20
|
-
const moduleNames = Array.from(loggers.keys());
|
|
21
|
-
loggers.clear();
|
|
22
|
-
moduleNames.forEach((moduleName) => createLogger(moduleName));
|
|
23
|
-
}
|
|
24
|
-
exports.setLogLevel = setLogLevel;
|
|
25
|
-
const getLogLevel = () => {
|
|
26
|
-
return logLevel;
|
|
27
|
-
};
|
|
28
|
-
exports.getLogLevel = getLogLevel;
|
|
29
|
-
function forwardLogsTo(logger) {
|
|
30
|
-
target = logger;
|
|
31
|
-
}
|
|
32
|
-
exports.forwardLogsTo = forwardLogsTo;
|
|
33
|
-
const COLORS = {
|
|
34
|
-
black: '\x1b[30m',
|
|
35
|
-
red: '\x1b[31m',
|
|
36
|
-
green: '\x1b[32m',
|
|
37
|
-
yellow: '\x1b[33m',
|
|
38
|
-
blue: '\x1b[34m',
|
|
39
|
-
magenta: '\x1b[35m',
|
|
40
|
-
cyan: '\x1b[36m',
|
|
41
|
-
white: '\x1b[37m',
|
|
42
|
-
default: '\x1b[39m',
|
|
43
|
-
};
|
|
44
|
-
function createLogger(moduleName) {
|
|
45
|
-
if (loggers.has(moduleName)) {
|
|
3
|
+
exports.setObserverLogger = exports.createLogger = void 0;
|
|
4
|
+
let mainLogger = new class {
|
|
5
|
+
trace = () => void 0;
|
|
6
|
+
// trace(module: string, ...args: any[]) {
|
|
7
|
+
// // eslint-disable-next-line no-console
|
|
8
|
+
// console.log(`[TRACE] ${module}`, ...args);
|
|
9
|
+
// }
|
|
10
|
+
debug(module, ...args) {
|
|
46
11
|
// eslint-disable-next-line no-console
|
|
47
|
-
console.
|
|
12
|
+
console.log(`[DEBUG] ${module}`, ...args);
|
|
48
13
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
14
|
+
info(module, ...args) {
|
|
15
|
+
// eslint-disable-next-line no-console
|
|
16
|
+
console.info(`[INFO] ${module}`, ...args);
|
|
17
|
+
}
|
|
18
|
+
warn(module, ...args) {
|
|
19
|
+
// eslint-disable-next-line no-console
|
|
20
|
+
console.warn(`[WARN] ${module}`, ...args);
|
|
21
|
+
}
|
|
22
|
+
error(module, ...args) {
|
|
23
|
+
// eslint-disable-next-line no-console
|
|
24
|
+
console.error(`[ERROR] ${module}`, ...args);
|
|
25
|
+
}
|
|
26
|
+
}();
|
|
27
|
+
function createLogger(moduleName) {
|
|
28
|
+
return new class {
|
|
29
|
+
trace(...args) {
|
|
30
|
+
mainLogger.trace(moduleName, ...args);
|
|
31
|
+
}
|
|
32
|
+
debug(...args) {
|
|
33
|
+
mainLogger.debug(moduleName, ...args);
|
|
34
|
+
}
|
|
35
|
+
info(...args) {
|
|
36
|
+
mainLogger.info(moduleName, ...args);
|
|
37
|
+
}
|
|
38
|
+
warn(...args) {
|
|
39
|
+
mainLogger.warn(moduleName, ...args);
|
|
40
|
+
}
|
|
41
|
+
error(...args) {
|
|
42
|
+
mainLogger.error(moduleName, ...args);
|
|
43
|
+
}
|
|
44
|
+
}();
|
|
73
45
|
}
|
|
74
46
|
exports.createLogger = createLogger;
|
|
47
|
+
function setObserverLogger(logger) {
|
|
48
|
+
mainLogger = logger;
|
|
49
|
+
}
|
|
50
|
+
exports.setObserverLogger = setObserverLogger;
|
package/lib/common/types.d.ts
CHANGED
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
import { CallEventReport, CallMetaReport, ClientDataChannelReport, ClientExtensionReport, IceCandidatePairReport, InboundAudioTrackReport, InboundVideoTrackReport, ObserverEventReport, OutboundAudioTrackReport, OutboundVideoTrackReport, PeerConnectionTransportReport, SfuEventReport, SfuExtensionReport, SfuInboundRtpPadReport, SfuMetaReport, SfuOutboundRtpPadReport, SfuSctpStreamReport, SFUTransportReport } from '@observertc/report-schemas-js';
|
|
2
1
|
export type MediaKind = 'audio' | 'video';
|
|
3
2
|
export type SupportedVideoCodecType = 'vp8' | 'vp9' | 'h264' | 'h265';
|
|
4
|
-
export interface ObserverSinkContext {
|
|
5
|
-
readonly callEventReports: CallEventReport[];
|
|
6
|
-
readonly callMetaReports: CallMetaReport[];
|
|
7
|
-
readonly clientDataChannelReports: ClientDataChannelReport[];
|
|
8
|
-
readonly clientExtensionReports: ClientExtensionReport[];
|
|
9
|
-
readonly iceCandidatePairReports: IceCandidatePairReport[];
|
|
10
|
-
readonly inboundAudioTrackReports: InboundAudioTrackReport[];
|
|
11
|
-
readonly inboundVideoTrackReports: InboundVideoTrackReport[];
|
|
12
|
-
readonly peerConnectionTransportReports: PeerConnectionTransportReport[];
|
|
13
|
-
readonly observerEventReports: ObserverEventReport[];
|
|
14
|
-
readonly outboundAudioTrackReports: OutboundAudioTrackReport[];
|
|
15
|
-
readonly outboundVideoTrackReports: OutboundVideoTrackReport[];
|
|
16
|
-
readonly sfuEventReports: SfuEventReport[];
|
|
17
|
-
readonly sfuExtensionReports: SfuExtensionReport[];
|
|
18
|
-
readonly sfuInboundRtpPadReports: SfuInboundRtpPadReport[];
|
|
19
|
-
readonly sfuOutboundRtpPadReports: SfuOutboundRtpPadReport[];
|
|
20
|
-
readonly sfuSctpStreamReports: SfuSctpStreamReport[];
|
|
21
|
-
readonly sfuTransportReports: SFUTransportReport[];
|
|
22
|
-
readonly sfuMetaReports: SfuMetaReport[];
|
|
23
|
-
}
|
|
24
3
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAC1C,MAAM,MAAM,uBAAuB,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC"}
|
package/lib/common/types.js
CHANGED
package/lib/common/utils.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ export declare function iteratorConverter<T>(generator: Generator<T, void, undef
|
|
|
6
6
|
export declare function asyncIteratorConverter<T>(generator: AsyncGenerator<T, void, undefined>): AsyncIterableIterator<T>;
|
|
7
7
|
export declare function isValidUuid(str: string): boolean;
|
|
8
8
|
export declare function getMedian(arr: number[]): number;
|
|
9
|
+
export declare function parseJsonAs<T>(json?: string): T | undefined;
|
|
9
10
|
//# sourceMappingURL=utils.d.ts.map
|