@observertc/observer-js 0.9.27-beta → 0.30.0-e12fcb4.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/lib/ObservedCall.d.ts +54 -0
- package/lib/ObservedCall.d.ts.map +1 -0
- package/lib/ObservedCall.js +166 -0
- package/lib/ObservedClient.d.ts +73 -0
- package/lib/ObservedClient.d.ts.map +1 -0
- package/lib/ObservedClient.js +487 -0
- package/lib/ObservedInboundTrack.d.ts +65 -0
- package/lib/ObservedInboundTrack.d.ts.map +1 -0
- package/lib/ObservedInboundTrack.js +192 -0
- package/lib/ObservedOutboundTrack.d.ts +55 -0
- package/lib/ObservedOutboundTrack.d.ts.map +1 -0
- package/lib/ObservedOutboundTrack.js +166 -0
- package/lib/ObservedPeerConnection.d.ts +57 -0
- package/lib/ObservedPeerConnection.d.ts.map +1 -0
- package/lib/ObservedPeerConnection.js +217 -0
- package/lib/Observer.d.ts +26 -1465
- package/lib/Observer.d.ts.map +1 -1
- package/lib/Observer.js +53 -605
- package/lib/{sinks/ObserverSink.d.ts → ReportsCollector.d.ts} +7 -23
- package/lib/ReportsCollector.d.ts.map +1 -0
- package/lib/{sinks/ObserverSink.js → ReportsCollector.js} +27 -85
- package/lib/common/ReportsCollector.d.ts +21 -24
- package/lib/common/ReportsCollector.d.ts.map +1 -1
- package/lib/common/ReportsCollector.js +24 -0
- package/lib/common/SingleExecutor.d.ts +3 -0
- package/lib/common/SingleExecutor.d.ts.map +1 -0
- package/lib/common/SingleExecutor.js +31 -0
- package/lib/common/TypedEventEmitter.d.ts +22 -0
- package/lib/common/TypedEventEmitter.d.ts.map +1 -0
- package/lib/common/TypedEventEmitter.js +11 -0
- package/lib/common/callEventReports.d.ts.map +1 -0
- package/lib/common/logger.d.ts +3 -9
- package/lib/common/logger.d.ts.map +1 -1
- package/lib/common/logger.js +58 -141
- package/lib/common/types.d.ts +2 -14
- package/lib/common/types.d.ts.map +1 -1
- package/lib/common/utils.d.ts +1 -0
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +6 -1
- package/lib/index.d.ts +8 -19
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -2
- package/package.json +1 -1
- package/src/ObservedCall.ts +201 -0
- package/src/ObservedClient.ts +681 -0
- package/src/ObservedInboundTrack.ts +238 -0
- package/src/ObservedOutboundTrack.ts +205 -0
- package/src/ObservedPeerConnection.ts +249 -0
- package/src/Observer.ts +86 -442
- package/src/{sinks/ObserverSink.ts → ReportsCollector.ts} +29 -94
- package/src/common/ReportsCollector.ts +48 -23
- package/src/common/SingleExecutor.ts +36 -0
- package/src/common/TypedEventEmitter.ts +32 -0
- package/src/common/logger.ts +58 -161
- package/src/common/types.ts +4 -24
- package/src/common/utils.ts +6 -0
- package/src/index.ts +12 -23
- package/lib/Evaluator.d.ts +0 -43
- package/lib/Evaluator.d.ts.map +0 -1
- package/lib/Evaluator.js +0 -171
- package/lib/common/Semaphore.d.ts +0 -31
- package/lib/common/Semaphore.d.ts.map +0 -1
- package/lib/common/Semaphore.js +0 -16
- package/lib/entries/CallEntry.d.ts +0 -619
- package/lib/entries/CallEntry.d.ts.map +0 -1
- package/lib/entries/CallEntry.js +0 -75
- package/lib/entries/ClientEntry.d.ts +0 -478
- package/lib/entries/ClientEntry.d.ts.map +0 -1
- package/lib/entries/ClientEntry.js +0 -114
- package/lib/entries/InboundTrackEntry.d.ts +0 -682
- package/lib/entries/InboundTrackEntry.d.ts.map +0 -1
- package/lib/entries/InboundTrackEntry.js +0 -76
- package/lib/entries/OutboundTrackEntry.d.ts +0 -682
- package/lib/entries/OutboundTrackEntry.d.ts.map +0 -1
- package/lib/entries/OutboundTrackEntry.js +0 -73
- package/lib/entries/PeerConnectionEntry.d.ts +0 -505
- package/lib/entries/PeerConnectionEntry.d.ts.map +0 -1
- package/lib/entries/PeerConnectionEntry.js +0 -144
- package/lib/entries/SfuEntry.d.ts +0 -150
- package/lib/entries/SfuEntry.d.ts.map +0 -1
- package/lib/entries/SfuEntry.js +0 -77
- package/lib/entries/SfuInboundRtpPadEntry.d.ts +0 -14
- package/lib/entries/SfuInboundRtpPadEntry.d.ts.map +0 -1
- package/lib/entries/SfuInboundRtpPadEntry.js +0 -49
- package/lib/entries/SfuOutboundRtpPadEntry.d.ts +0 -14
- package/lib/entries/SfuOutboundRtpPadEntry.d.ts.map +0 -1
- package/lib/entries/SfuOutboundRtpPadEntry.js +0 -47
- package/lib/entries/SfuSctpChannelEntry.d.ts +0 -12
- package/lib/entries/SfuSctpChannelEntry.d.ts.map +0 -1
- package/lib/entries/SfuSctpChannelEntry.js +0 -43
- package/lib/entries/SfuTransportEntry.d.ts +0 -82
- package/lib/entries/SfuTransportEntry.d.ts.map +0 -1
- package/lib/entries/SfuTransportEntry.js +0 -122
- package/lib/evaluators/SetClientsCoordinateEvaluator.d.ts +0 -9
- package/lib/evaluators/SetClientsCoordinateEvaluator.d.ts.map +0 -1
- package/lib/evaluators/SetClientsCoordinateEvaluator.js +0 -95
- package/lib/middlewares/CallOperationsContext.d.ts +0 -18
- package/lib/middlewares/CallOperationsContext.d.ts.map +0 -1
- package/lib/middlewares/CallOperationsContext.js +0 -27
- package/lib/middlewares/CallProcessor.d.ts +0 -6
- package/lib/middlewares/CallProcessor.d.ts.map +0 -1
- package/lib/middlewares/CallProcessor.js +0 -36
- package/lib/middlewares/CommitTransactionMiddleware.d.ts +0 -6
- package/lib/middlewares/CommitTransactionMiddleware.d.ts.map +0 -1
- package/lib/middlewares/CommitTransactionMiddleware.js +0 -179
- package/lib/middlewares/DeleteOutdatedCallEntries.d.ts +0 -6
- package/lib/middlewares/DeleteOutdatedCallEntries.d.ts.map +0 -1
- package/lib/middlewares/DeleteOutdatedCallEntries.js +0 -121
- package/lib/middlewares/DeleteOutdatedSfuEntries.d.ts +0 -6
- package/lib/middlewares/DeleteOutdatedSfuEntries.d.ts.map +0 -1
- package/lib/middlewares/DeleteOutdatedSfuEntries.js +0 -127
- package/lib/middlewares/Middleware.d.ts +0 -3
- package/lib/middlewares/Middleware.d.ts.map +0 -1
- package/lib/middlewares/Middleware.js +0 -21
- package/lib/middlewares/Processor.d.ts +0 -9
- package/lib/middlewares/Processor.d.ts.map +0 -1
- package/lib/middlewares/Processor.js +0 -54
- package/lib/middlewares/TransactionContext.d.ts +0 -35
- package/lib/middlewares/TransactionContext.d.ts.map +0 -1
- package/lib/middlewares/TransactionContext.js +0 -90
- package/lib/middlewares/TransactoinProcessor.d.ts +0 -6
- package/lib/middlewares/TransactoinProcessor.d.ts.map +0 -1
- package/lib/middlewares/TransactoinProcessor.js +0 -17
- package/lib/middlewares/VisitObservedCallsMiddleware.d.ts +0 -7
- package/lib/middlewares/VisitObservedCallsMiddleware.d.ts.map +0 -1
- package/lib/middlewares/VisitObservedCallsMiddleware.js +0 -96
- package/lib/middlewares/VisitObservedSfusMiddleware.d.ts +0 -6
- package/lib/middlewares/VisitObservedSfusMiddleware.d.ts.map +0 -1
- package/lib/middlewares/VisitObservedSfusMiddleware.js +0 -151
- package/lib/middlewares/visitors/visitClient.d.ts +0 -5
- package/lib/middlewares/visitors/visitClient.d.ts.map +0 -1
- package/lib/middlewares/visitors/visitClient.js +0 -174
- package/lib/middlewares/visitors/visitInboundAudioTrack.d.ts +0 -5
- package/lib/middlewares/visitors/visitInboundAudioTrack.d.ts.map +0 -1
- package/lib/middlewares/visitors/visitInboundAudioTrack.js +0 -93
- package/lib/middlewares/visitors/visitInboundVideoTrack.d.ts +0 -5
- package/lib/middlewares/visitors/visitInboundVideoTrack.d.ts.map +0 -1
- package/lib/middlewares/visitors/visitInboundVideoTrack.js +0 -94
- package/lib/middlewares/visitors/visitOutboundAudioTrack.d.ts +0 -5
- package/lib/middlewares/visitors/visitOutboundAudioTrack.d.ts.map +0 -1
- package/lib/middlewares/visitors/visitOutboundAudioTrack.js +0 -90
- package/lib/middlewares/visitors/visitOutboundVideoTarck.d.ts +0 -5
- package/lib/middlewares/visitors/visitOutboundVideoTarck.d.ts.map +0 -1
- package/lib/middlewares/visitors/visitOutboundVideoTarck.js +0 -90
- package/lib/middlewares/visitors/visitPeerConnection.d.ts +0 -5
- package/lib/middlewares/visitors/visitPeerConnection.d.ts.map +0 -1
- package/lib/middlewares/visitors/visitPeerConnection.js +0 -111
- package/lib/middlewares/visitors/visitSfu.d.ts +0 -5
- package/lib/middlewares/visitors/visitSfu.d.ts.map +0 -1
- package/lib/middlewares/visitors/visitSfu.js +0 -78
- package/lib/middlewares/visitors/visitSfuInboundRtpPad.d.ts +0 -5
- package/lib/middlewares/visitors/visitSfuInboundRtpPad.d.ts.map +0 -1
- package/lib/middlewares/visitors/visitSfuInboundRtpPad.js +0 -56
- package/lib/middlewares/visitors/visitSfuOutboundRtpPad.d.ts +0 -5
- package/lib/middlewares/visitors/visitSfuOutboundRtpPad.d.ts.map +0 -1
- package/lib/middlewares/visitors/visitSfuOutboundRtpPad.js +0 -56
- package/lib/middlewares/visitors/visitSfuSctpChannel.d.ts +0 -5
- package/lib/middlewares/visitors/visitSfuSctpChannel.d.ts.map +0 -1
- package/lib/middlewares/visitors/visitSfuSctpChannel.js +0 -55
- package/lib/middlewares/visitors/visitSfuTransport.d.ts +0 -5
- package/lib/middlewares/visitors/visitSfuTransport.d.ts.map +0 -1
- package/lib/middlewares/visitors/visitSfuTransport.js +0 -56
- package/lib/processes/closePeerConnectionProcess.d.ts +0 -10
- package/lib/processes/closePeerConnectionProcess.d.ts.map +0 -1
- package/lib/processes/closePeerConnectionProcess.js +0 -51
- package/lib/processes/detachClientProcess.d.ts +0 -14
- package/lib/processes/detachClientProcess.d.ts.map +0 -1
- package/lib/processes/detachClientProcess.js +0 -106
- package/lib/processes/findRemoteMatches.d.ts +0 -9
- package/lib/processes/findRemoteMatches.d.ts.map +0 -1
- package/lib/processes/findRemoteMatches.js +0 -96
- package/lib/processes/inboundTrackRemoved.d.ts +0 -9
- package/lib/processes/inboundTrackRemoved.d.ts.map +0 -1
- package/lib/processes/inboundTrackRemoved.js +0 -22
- package/lib/processes/joinClientProcess.d.ts +0 -11
- package/lib/processes/joinClientProcess.d.ts.map +0 -1
- package/lib/processes/joinClientProcess.js +0 -120
- package/lib/processes/outboundTrackRemoved.d.ts +0 -9
- package/lib/processes/outboundTrackRemoved.d.ts.map +0 -1
- package/lib/processes/outboundTrackRemoved.js +0 -22
- package/lib/samples/ObservedCall.d.ts +0 -17
- package/lib/samples/ObservedCall.d.ts.map +0 -1
- package/lib/samples/ObservedCall.js +0 -29
- package/lib/samples/ObservedCalls.d.ts +0 -19
- package/lib/samples/ObservedCalls.d.ts.map +0 -1
- package/lib/samples/ObservedCalls.js +0 -113
- package/lib/samples/ObservedClient.d.ts +0 -28
- package/lib/samples/ObservedClient.d.ts.map +0 -1
- package/lib/samples/ObservedClient.js +0 -110
- package/lib/samples/ObservedInboundAudioTrack.d.ts +0 -17
- package/lib/samples/ObservedInboundAudioTrack.d.ts.map +0 -1
- package/lib/samples/ObservedInboundAudioTrack.js +0 -17
- package/lib/samples/ObservedInboundVideoTrack.d.ts +0 -17
- package/lib/samples/ObservedInboundVideoTrack.d.ts.map +0 -1
- package/lib/samples/ObservedInboundVideoTrack.js +0 -17
- package/lib/samples/ObservedOutboundAudioTrack.d.ts +0 -16
- package/lib/samples/ObservedOutboundAudioTrack.d.ts.map +0 -1
- package/lib/samples/ObservedOutboundAudioTrack.js +0 -17
- package/lib/samples/ObservedOutboundVideoTrack.d.ts +0 -16
- package/lib/samples/ObservedOutboundVideoTrack.d.ts.map +0 -1
- package/lib/samples/ObservedOutboundVideoTrack.js +0 -17
- package/lib/samples/ObservedPeerConnection.d.ts +0 -47
- package/lib/samples/ObservedPeerConnection.d.ts.map +0 -1
- package/lib/samples/ObservedPeerConnection.js +0 -130
- package/lib/samples/ObservedSfu.d.ts +0 -27
- package/lib/samples/ObservedSfu.d.ts.map +0 -1
- package/lib/samples/ObservedSfu.js +0 -65
- package/lib/samples/ObservedSfuInboundRtpPad.d.ts +0 -15
- package/lib/samples/ObservedSfuInboundRtpPad.d.ts.map +0 -1
- package/lib/samples/ObservedSfuInboundRtpPad.js +0 -17
- package/lib/samples/ObservedSfuOutboundRtpPad.d.ts +0 -15
- package/lib/samples/ObservedSfuOutboundRtpPad.d.ts.map +0 -1
- package/lib/samples/ObservedSfuOutboundRtpPad.js +0 -17
- package/lib/samples/ObservedSfuSctpChannel.d.ts +0 -15
- package/lib/samples/ObservedSfuSctpChannel.d.ts.map +0 -1
- package/lib/samples/ObservedSfuSctpChannel.js +0 -17
- package/lib/samples/ObservedSfuTransport.d.ts +0 -30
- package/lib/samples/ObservedSfuTransport.d.ts.map +0 -1
- package/lib/samples/ObservedSfuTransport.js +0 -86
- package/lib/samples/ObservedSfus.d.ts +0 -16
- package/lib/samples/ObservedSfus.d.ts.map +0 -1
- package/lib/samples/ObservedSfus.js +0 -72
- package/lib/sinks/ObserverSink.d.ts.map +0 -1
- package/lib/sinks/callEventReports.d.ts.map +0 -1
- package/lib/sources/ObservedCallSource.d.ts +0 -18
- package/lib/sources/ObservedCallSource.d.ts.map +0 -1
- package/lib/sources/ObservedCallSource.js +0 -2
- package/lib/sources/ObservedClientSource.d.ts +0 -19
- package/lib/sources/ObservedClientSource.d.ts.map +0 -1
- package/lib/sources/ObservedClientSource.js +0 -2
- package/lib/sources/ObservedSfuSource.d.ts +0 -15
- package/lib/sources/ObservedSfuSource.d.ts.map +0 -1
- package/lib/sources/ObservedSfuSource.js +0 -2
- package/lib/sources/Sources.d.ts +0 -49
- package/lib/sources/Sources.d.ts.map +0 -1
- package/lib/sources/Sources.js +0 -213
- package/src/Evaluator.ts +0 -229
- package/src/common/Semaphore.ts +0 -45
- package/src/entries/CallEntry.ts +0 -62
- package/src/entries/ClientEntry.ts +0 -106
- package/src/entries/InboundTrackEntry.ts +0 -74
- package/src/entries/OutboundTrackEntry.ts +0 -72
- package/src/entries/PeerConnectionEntry.ts +0 -133
- package/src/entries/SfuEntry.ts +0 -62
- package/src/entries/SfuInboundRtpPadEntry.ts +0 -46
- package/src/entries/SfuOutboundRtpPadEntry.ts +0 -44
- package/src/entries/SfuSctpChannelEntry.ts +0 -39
- package/src/entries/SfuTransportEntry.ts +0 -109
- package/src/evaluators/SetClientsCoordinateEvaluator.ts +0 -78
- package/src/middlewares/CallOperationsContext.ts +0 -56
- package/src/middlewares/CallProcessor.ts +0 -38
- package/src/middlewares/CommitTransactionMiddleware.ts +0 -328
- package/src/middlewares/DeleteOutdatedCallEntries.ts +0 -159
- package/src/middlewares/DeleteOutdatedSfuEntries.ts +0 -168
- package/src/middlewares/Middleware.ts +0 -10
- package/src/middlewares/Processor.ts +0 -59
- package/src/middlewares/TransactionContext.ts +0 -176
- package/src/middlewares/TransactoinProcessor.ts +0 -28
- package/src/middlewares/VisitObservedCallsMiddleware.ts +0 -172
- package/src/middlewares/VisitObservedSfusMiddleware.ts +0 -203
- package/src/middlewares/visitors/visitClient.ts +0 -239
- package/src/middlewares/visitors/visitInboundAudioTrack.ts +0 -113
- package/src/middlewares/visitors/visitInboundVideoTrack.ts +0 -117
- package/src/middlewares/visitors/visitOutboundAudioTrack.ts +0 -100
- package/src/middlewares/visitors/visitOutboundVideoTarck.ts +0 -102
- package/src/middlewares/visitors/visitPeerConnection.ts +0 -151
- package/src/middlewares/visitors/visitSfu.ts +0 -70
- package/src/middlewares/visitors/visitSfuInboundRtpPad.ts +0 -52
- package/src/middlewares/visitors/visitSfuOutboundRtpPad.ts +0 -53
- package/src/middlewares/visitors/visitSfuSctpChannel.ts +0 -50
- package/src/middlewares/visitors/visitSfuTransport.ts +0 -50
- package/src/processes/closePeerConnectionProcess.ts +0 -54
- package/src/processes/detachClientProcess.ts +0 -136
- package/src/processes/findRemoteMatches.ts +0 -104
- package/src/processes/inboundTrackRemoved.ts +0 -22
- package/src/processes/joinClientProcess.ts +0 -138
- package/src/processes/outboundTrackRemoved.ts +0 -22
- package/src/samples/ObservedCall.ts +0 -49
- package/src/samples/ObservedCalls.ts +0 -143
- package/src/samples/ObservedClient.ts +0 -172
- package/src/samples/ObservedInboundAudioTrack.ts +0 -35
- package/src/samples/ObservedInboundVideoTrack.ts +0 -36
- package/src/samples/ObservedOutboundAudioTrack.ts +0 -35
- package/src/samples/ObservedOutboundVideoTrack.ts +0 -35
- package/src/samples/ObservedPeerConnection.ts +0 -227
- package/src/samples/ObservedSfu.ts +0 -115
- package/src/samples/ObservedSfuInboundRtpPad.ts +0 -35
- package/src/samples/ObservedSfuOutboundRtpPad.ts +0 -35
- package/src/samples/ObservedSfuSctpChannel.ts +0 -35
- package/src/samples/ObservedSfuTransport.ts +0 -142
- package/src/samples/ObservedSfus.ts +0 -95
- package/src/sources/ObservedCallSource.ts +0 -26
- package/src/sources/ObservedClientSource.ts +0 -28
- package/src/sources/ObservedSfuSource.ts +0 -19
- package/src/sources/Sources.ts +0 -301
- /package/lib/{sinks → common}/callEventReports.d.ts +0 -0
- /package/lib/{sinks → common}/callEventReports.js +0 -0
- /package/src/{sinks → common}/callEventReports.ts +0 -0
package/lib/common/logger.js
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createLogger = exports.forwardLogsTo = exports.getLogLevel = exports.setLogLevel = void 0;
|
|
4
|
+
let logLevel = 'error';
|
|
5
|
+
const loggers = new Map();
|
|
6
|
+
let target = {
|
|
7
|
+
// eslint-disable-next-line no-console
|
|
8
|
+
trace: (...args) => console.log(...args),
|
|
9
|
+
// eslint-disable-next-line no-console
|
|
10
|
+
debug: (...args) => console.log(...args),
|
|
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;
|
|
4
33
|
const COLORS = {
|
|
5
34
|
black: '\x1b[30m',
|
|
6
35
|
red: '\x1b[31m',
|
|
@@ -12,146 +41,34 @@ const COLORS = {
|
|
|
12
41
|
white: '\x1b[37m',
|
|
13
42
|
default: '\x1b[39m',
|
|
14
43
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/* eslint-disable no-debugger, no-console */
|
|
42
|
-
console.error(...args);
|
|
43
|
-
};
|
|
44
|
-
return {
|
|
45
|
-
trace,
|
|
46
|
-
debug,
|
|
47
|
-
info,
|
|
48
|
-
warn,
|
|
49
|
-
error,
|
|
50
|
-
};
|
|
44
|
+
function createLogger(moduleName) {
|
|
45
|
+
if (loggers.has(moduleName)) {
|
|
46
|
+
// eslint-disable-next-line no-console
|
|
47
|
+
console.warn(`Logger for module ${moduleName} already exists`);
|
|
48
|
+
}
|
|
49
|
+
const trace = logLevel === 'trace' ? (message, ...args) => {
|
|
50
|
+
target === null || target === void 0 ? void 0 : target.trace(`${COLORS.magenta}[TRACE]${COLORS.default} ${moduleName} ${message}`, ...args);
|
|
51
|
+
} : () => void 0;
|
|
52
|
+
const debug = logLevel === 'trace' || logLevel === 'debug' ? (message, ...args) => {
|
|
53
|
+
target === null || target === void 0 ? void 0 : target.debug(`${COLORS.cyan}[DEBUG]${COLORS.default} ${moduleName} ${message}`, ...args);
|
|
54
|
+
} : () => void 0;
|
|
55
|
+
const info = logLevel === 'trace' || logLevel === 'debug' || logLevel === 'info' ? (message, ...args) => {
|
|
56
|
+
target === null || target === void 0 ? void 0 : target.info(`${COLORS.green}[INFO]${COLORS.default} ${moduleName} ${message}`, ...args);
|
|
57
|
+
} : () => void 0;
|
|
58
|
+
const warn = logLevel === 'trace' || logLevel === 'debug' || logLevel === 'info' || logLevel === 'warn' ? (message, ...args) => {
|
|
59
|
+
target === null || target === void 0 ? void 0 : target.warn(`${COLORS.yellow}[WARN]${COLORS.default} ${moduleName} ${message}`, ...args);
|
|
60
|
+
} : () => void 0;
|
|
61
|
+
const error = logLevel === 'trace' || logLevel === 'debug' || logLevel === 'info' || logLevel === 'warn' || logLevel === 'error' ? (message, ...args) => {
|
|
62
|
+
target === null || target === void 0 ? void 0 : target.error(`${COLORS.red}[ERROR]${COLORS.default} ${moduleName} ${message}`, ...args);
|
|
63
|
+
} : () => void 0;
|
|
64
|
+
const logger = {
|
|
65
|
+
trace,
|
|
66
|
+
debug,
|
|
67
|
+
info,
|
|
68
|
+
warn,
|
|
69
|
+
error,
|
|
51
70
|
};
|
|
71
|
+
loggers.set(moduleName, logger);
|
|
72
|
+
return logger;
|
|
52
73
|
}
|
|
53
|
-
const wrapLogger = (logger, moduleName, logLevel) => {
|
|
54
|
-
let isTrace = false;
|
|
55
|
-
let isDebug = false;
|
|
56
|
-
let isInfo = false;
|
|
57
|
-
let isWarning = false;
|
|
58
|
-
let isError = false;
|
|
59
|
-
let _level = logLevel;
|
|
60
|
-
let _logger = logger;
|
|
61
|
-
const tracePrefix = `${COLORS.magenta}[TRACE]${COLORS.default} ${moduleName}`;
|
|
62
|
-
const debugPrefix = `${COLORS.cyan}[DEBUG]${COLORS.default} ${moduleName}`;
|
|
63
|
-
const infoPrefix = `${COLORS.green}[INFO]${COLORS.default} ${moduleName}`;
|
|
64
|
-
const warnPrefix = `${COLORS.yellow}[WARN]${COLORS.default} ${moduleName}`;
|
|
65
|
-
const errorPrefix = `${COLORS.red}[ERROR]${COLORS.default} ${moduleName}`;
|
|
66
|
-
const result = new class {
|
|
67
|
-
init() {
|
|
68
|
-
isTrace = ['trace'].includes(_level !== null && _level !== void 0 ? _level : defaultLevel);
|
|
69
|
-
isDebug = ['trace', 'debug'].includes(_level !== null && _level !== void 0 ? _level : defaultLevel);
|
|
70
|
-
isInfo = ['trace', 'debug', 'info'].includes(_level !== null && _level !== void 0 ? _level : defaultLevel);
|
|
71
|
-
isWarning = ['trace', 'debug', 'info', 'warn'].includes(_level !== null && _level !== void 0 ? _level : defaultLevel);
|
|
72
|
-
isError = ['trace', 'debug', 'info', 'warn', 'error'].includes(_level !== null && _level !== void 0 ? _level : defaultLevel);
|
|
73
|
-
}
|
|
74
|
-
get logger() {
|
|
75
|
-
return _logger;
|
|
76
|
-
}
|
|
77
|
-
set logger(value) {
|
|
78
|
-
_logger = value;
|
|
79
|
-
}
|
|
80
|
-
get level() {
|
|
81
|
-
return _level;
|
|
82
|
-
}
|
|
83
|
-
set level(value) {
|
|
84
|
-
_level = value;
|
|
85
|
-
}
|
|
86
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
87
|
-
trace(...args) {
|
|
88
|
-
if (isTrace) {
|
|
89
|
-
const elapsedInMs = `${COLORS.magenta}+${Date.now() - created}ms${COLORS.default}`;
|
|
90
|
-
logger.trace(tracePrefix, ...args, elapsedInMs);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
94
|
-
debug(...args) {
|
|
95
|
-
if (isDebug) {
|
|
96
|
-
const elapsedInMs = `${COLORS.magenta}+${Date.now() - created}ms${COLORS.default}`;
|
|
97
|
-
logger.debug(debugPrefix, ...args, elapsedInMs);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
101
|
-
info(...args) {
|
|
102
|
-
if (isInfo) {
|
|
103
|
-
const elapsedInMs = `${COLORS.magenta}+${Date.now() - created}ms${COLORS.default}`;
|
|
104
|
-
logger.info(infoPrefix, ...args, elapsedInMs);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
108
|
-
warn(...args) {
|
|
109
|
-
if (isWarning) {
|
|
110
|
-
const elapsedInMs = `${COLORS.magenta}+${Date.now() - created}ms${COLORS.default}`;
|
|
111
|
-
logger.warn(warnPrefix, ...args, elapsedInMs);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
115
|
-
error(...args) {
|
|
116
|
-
if (isError) {
|
|
117
|
-
const elapsedInMs = `${COLORS.magenta}+${Date.now() - created}ms${COLORS.default}`;
|
|
118
|
-
logger.error(errorPrefix, ...args, elapsedInMs);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
return result;
|
|
123
|
-
};
|
|
124
|
-
let actualLoggerFactory = createDefaultLoggerFactory();
|
|
125
|
-
const loggers = new Map();
|
|
126
|
-
const createLogger = (moduleName, logLevel) => {
|
|
127
|
-
let wrappedLogger = loggers.get(moduleName);
|
|
128
|
-
if (!wrappedLogger) {
|
|
129
|
-
const logger = actualLoggerFactory();
|
|
130
|
-
wrappedLogger = wrapLogger(logger, moduleName, logLevel !== null && logLevel !== void 0 ? logLevel : defaultLevel);
|
|
131
|
-
loggers.set(moduleName, wrappedLogger);
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
wrappedLogger.level = logLevel !== null && logLevel !== void 0 ? logLevel : defaultLevel;
|
|
135
|
-
}
|
|
136
|
-
wrappedLogger.init();
|
|
137
|
-
return wrappedLogger;
|
|
138
|
-
};
|
|
139
74
|
exports.createLogger = createLogger;
|
|
140
|
-
const setLogLevel = (level) => {
|
|
141
|
-
defaultLevel = level;
|
|
142
|
-
for (const [moduleName] of Array.from(loggers.entries())) {
|
|
143
|
-
loggers.set(moduleName, (0, exports.createLogger)(moduleName, level));
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
exports.setLogLevel = setLogLevel;
|
|
147
|
-
const setLoggerFactory = (loggerFactory) => {
|
|
148
|
-
actualLoggerFactory = loggerFactory;
|
|
149
|
-
for (const [moduleName, logger] of Array.from(loggers.entries())) {
|
|
150
|
-
loggers.set(moduleName, (0, exports.createLogger)(moduleName, logger.level));
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
exports.setLoggerFactory = setLoggerFactory;
|
|
154
|
-
const getLogLevel = () => {
|
|
155
|
-
return defaultLevel;
|
|
156
|
-
};
|
|
157
|
-
exports.getLogLevel = getLogLevel;
|
package/lib/common/types.d.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
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
|
-
import { ObservedCalls } from '../samples/ObservedCalls';
|
|
3
|
-
import { ReportsCollector } from './ReportsCollector';
|
|
4
2
|
import * as Models from '../models/Models';
|
|
5
3
|
import { StorageProvider } from '../storages/StorageProvider';
|
|
6
4
|
import { Message } from '@bufbuild/protobuf';
|
|
7
|
-
|
|
8
|
-
import { ObservedSfus } from '../samples/ObservedSfus';
|
|
9
|
-
export type ObserverReport = CallEventReport | CallMetaReport | ClientExtensionReport | PeerConnectionTransportReport | InboundAudioTrackReport | InboundVideoTrackReport | OutboundAudioTrackReport | OutboundVideoTrackReport;
|
|
5
|
+
export type MediaKind = 'audio' | 'video';
|
|
10
6
|
export interface EvaluatorContext {
|
|
11
7
|
readonly startedCallIds: string[];
|
|
12
8
|
readonly endedCalls: (Omit<Models.Call, keyof Message> & {
|
|
@@ -56,16 +52,9 @@ export interface EvaluatorContext {
|
|
|
56
52
|
readonly closedSfuSctpChannels: (Omit<Models.SfuSctpChannel, keyof Message> & {
|
|
57
53
|
closed: number;
|
|
58
54
|
})[];
|
|
59
|
-
readonly observedCalls: ObservedCalls;
|
|
60
|
-
readonly observedSfus: ObservedSfus;
|
|
61
55
|
readonly storages: StorageProvider;
|
|
62
|
-
readonly reports:
|
|
63
|
-
readonly clientExtensionStats: ClientExtensionReport[];
|
|
64
|
-
readonly callEvents: CallEventReport[];
|
|
65
|
-
readonly sfuEvents: SfuEventReport[];
|
|
66
|
-
readonly sfuExtensionStats: SfuExtensionReport[];
|
|
56
|
+
readonly reports: ObserverSinkContext;
|
|
67
57
|
}
|
|
68
|
-
export type EvaluatorMiddleware = Middleware<EvaluatorContext>;
|
|
69
58
|
export interface ObserverSinkContext {
|
|
70
59
|
readonly callEventReports: CallEventReport[];
|
|
71
60
|
readonly callMetaReports: CallMetaReport[];
|
|
@@ -86,5 +75,4 @@ export interface ObserverSinkContext {
|
|
|
86
75
|
readonly sfuTransportReports: SFUTransportReport[];
|
|
87
76
|
readonly sfuMetaReports: SfuMetaReport[];
|
|
88
77
|
}
|
|
89
|
-
export type ObserverSinkMiddleware = Middleware<ObserverSinkContext>;
|
|
90
78
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,qBA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C3D,QAAQ,CAAC,wBAAwB,EAAE,uBAAuB,EAAE,CAAC;IAC7D,QAAQ,CAAC,wBAAwB,EAAE,uBAAuB,EAAE,CAAC;IAC7D,QAAQ,CAAC,8BAA8B,EAAE,6BAA6B,EAAE,CAAC;IACzE,QAAQ,CAAC,oBAAoB,EAAE,mBAAmB,EAAE,CAAC;IACrD,QAAQ,CAAC,yBAAyB,EAAE,wBAAwB,EAAE,CAAC;IAC/D,QAAQ,CAAC,yBAAyB,EAAE,wBAAwB,EAAE,CAAC;IAC/D,QAAQ,CAAC,eAAe,EAAE,cAAc,EAAE,CAAC;IAC3C,QAAQ,CAAC,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;IACnD,QAAQ,CAAC,uBAAuB,EAAE,sBAAsB,EAAE,CAAC;IAC3D,QAAQ,CAAC,wBAAwB,EAAE,uBAAuB,EAAE,CAAC;IAC7D,QAAQ,CAAC,oBAAoB,EAAE,mBAAmB,EAAE,CAAC;IACrD,QAAQ,CAAC,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;IACnD,QAAQ,CAAC,cAAc,EAAE,aAAa,EAAE,CAAC;CACzC"}
|
package/lib/common/utils.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export type Writable<T> = T extends object ? {
|
|
|
4
4
|
} : T;
|
|
5
5
|
export declare function iteratorConverter<T>(generator: Generator<T, void, undefined>): IterableIterator<T>;
|
|
6
6
|
export declare function asyncIteratorConverter<T>(generator: AsyncGenerator<T, void, undefined>): AsyncIterableIterator<T>;
|
|
7
|
+
export declare function isValidUuid(str: string): boolean;
|
|
7
8
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/common/utils.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO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ASjH;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAIhD"}
|
package/lib/common/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.asyncIteratorConverter = exports.iteratorConverter = void 0;
|
|
3
|
+
exports.isValidUuid = exports.asyncIteratorConverter = exports.iteratorConverter = void 0;
|
|
4
4
|
function iteratorConverter(generator) {
|
|
5
5
|
return {
|
|
6
6
|
[Symbol.iterator]() {
|
|
@@ -23,3 +23,8 @@ function asyncIteratorConverter(generator) {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
exports.asyncIteratorConverter = asyncIteratorConverter;
|
|
26
|
+
function isValidUuid(str) {
|
|
27
|
+
const regexp = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
28
|
+
return regexp.test(str);
|
|
29
|
+
}
|
|
30
|
+
exports.isValidUuid = isValidUuid;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,30 +1,19 @@
|
|
|
1
1
|
export type { ObserverConfig, ObserverEvents } from './Observer';
|
|
2
|
-
export type { EvaluatorConfig, EvaluatorProcess } from './Evaluator';
|
|
3
|
-
export type { SourcesConfig } from './sources/Sources';
|
|
4
2
|
export { Observer } from './Observer';
|
|
5
|
-
export type { ObserverReportsEmitter, ObserverSinkProcess } from './sinks/ObserverSink';
|
|
6
3
|
export type { ObserverStorage } from './storages/ObserverStorage';
|
|
7
4
|
export type { StorageProvider } from './storages/StorageProvider';
|
|
8
|
-
export * as Models from './models/Models';
|
|
9
5
|
export * as SampleSchema from '@observertc/sample-schemas-js';
|
|
10
6
|
export * as ReportSchema from '@observertc/report-schemas-js';
|
|
11
|
-
export type {
|
|
12
|
-
export type { ClientEntry } from './entries/ClientEntry';
|
|
13
|
-
export type { PeerConnectionEntry } from './entries/PeerConnectionEntry';
|
|
14
|
-
export type { InboundTrackEntry } from './entries/InboundTrackEntry';
|
|
15
|
-
export type { OutboundTrackEntry } from './entries/OutboundTrackEntry';
|
|
16
|
-
export type { SfuEntry } from './entries/SfuEntry';
|
|
17
|
-
export type { SfuTransportEntry } from './entries/SfuTransportEntry';
|
|
18
|
-
export type { SfuInboundRtpPadEntry } from './entries/SfuInboundRtpPadEntry';
|
|
19
|
-
export type { SfuOutboundRtpPadEntry } from './entries/SfuOutboundRtpPadEntry';
|
|
20
|
-
export type { SfuSctpChannelEntry } from './entries/SfuSctpChannelEntry';
|
|
21
|
-
export type { GetClientCoordinate, ClientCoordinate } from './evaluators/SetClientsCoordinateEvaluator';
|
|
7
|
+
export type { LogLevel, Logger } from './common/logger';
|
|
22
8
|
export type { Samples, ClientSample, SfuSample, ExtensionStat, PeerConnectionTransport, IceCandidatePair, MediaSourceStat, MediaCodecStats, InboundAudioTrack, InboundVideoTrack, OutboundAudioTrack, OutboundVideoTrack, IceLocalCandidate, IceRemoteCandidate, CustomCallEvent, SfuTransport, SfuInboundRtpPad, SfuOutboundRtpPad, SfuSctpChannel, SfuExtensionStats, DataChannel, } from '@observertc/sample-schemas-js';
|
|
23
9
|
export type { CallEventReport, CallMetaReport, ClientDataChannelReport, ClientExtensionReport, IceCandidatePairReport, InboundAudioTrackReport, InboundVideoTrackReport, ObserverEventReport, OutboundAudioTrackReport, OutboundVideoTrackReport, PeerConnectionTransportReport, SfuEventReport, SfuExtensionReport, SfuInboundRtpPadReport, SfuMetaReport, SfuOutboundRtpPadReport, SfuSctpStreamReport, SFUTransportReport, } from '@observertc/report-schemas-js';
|
|
24
|
-
export type {
|
|
25
|
-
export type {
|
|
26
|
-
export type {
|
|
27
|
-
export type {
|
|
10
|
+
export type { ObservedClient, ObservedClientConfig } from './ObservedClient';
|
|
11
|
+
export type { ObservedPeerConnection, ObservedPeerConnectionConfig, ObservedPeerConnectionEvents } from './ObservedPeerConnection';
|
|
12
|
+
export type { ObservedInboundTrack, ObservedInboundTrackConfig, ObservedInboundTrackEvents } from './ObservedInboundTrack';
|
|
13
|
+
export type { ObservedOutboundTrack, ObservedOutboundTrackConfig, ObservedOutboundTrackEvents } from './ObservedOutboundTrack';
|
|
14
|
+
export type { EvaluatorContext, ObserverSinkContext } from './common/types';
|
|
28
15
|
import { Observer, ObserverConfig } from './Observer';
|
|
29
16
|
export declare function createObserver(config?: Partial<ObserverConfig>): Observer;
|
|
17
|
+
import { LogLevel, Logger } from './common/logger';
|
|
18
|
+
export declare function setupLogs(logLevel: LogLevel, logger: Logger): void;
|
|
30
19
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,KAAK,YAAY,MAAM,+BAA+B,CAAC;AAC9D,OAAO,KAAK,YAAY,MAAM,+BAA+B,CAAC;AAE9D,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAExD,YAAY,EACX,OAAO,EACP,YAAY,EACZ,SAAS,EACT,aAAa,EACb,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,WAAW,GACX,MAAM,+BAA+B,CAAC;AAEvC,YAAY,EACX,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,EAC7B,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,EACb,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,GAClB,MAAM,+BAA+B,CAAC;AAEvC,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,YAAY,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACnI,YAAY,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAC3H,YAAY,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAE/H,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE5E,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACtD,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,YAE9D;AAED,OAAO,EAAE,QAAQ,EAAE,MAAM,EAA8B,MAAM,iBAAiB,CAAC;AAC/E,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAG3D"}
|
package/lib/index.js
CHANGED
|
@@ -23,10 +23,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.setupLogs = exports.createObserver = exports.ReportSchema = exports.SampleSchema = exports.Observer = void 0;
|
|
27
27
|
var Observer_1 = require("./Observer");
|
|
28
28
|
Object.defineProperty(exports, "Observer", { enumerable: true, get: function () { return Observer_1.Observer; } });
|
|
29
|
-
exports.Models = __importStar(require("./models/Models"));
|
|
30
29
|
exports.SampleSchema = __importStar(require("@observertc/sample-schemas-js"));
|
|
31
30
|
exports.ReportSchema = __importStar(require("@observertc/report-schemas-js"));
|
|
32
31
|
const Observer_2 = require("./Observer");
|
|
@@ -34,3 +33,9 @@ function createObserver(config) {
|
|
|
34
33
|
return Observer_2.Observer.create(config !== null && config !== void 0 ? config : {});
|
|
35
34
|
}
|
|
36
35
|
exports.createObserver = createObserver;
|
|
36
|
+
const logger_1 = require("./common/logger");
|
|
37
|
+
function setupLogs(logLevel, logger) {
|
|
38
|
+
(0, logger_1.setLogLevel)(logLevel);
|
|
39
|
+
(0, logger_1.forwardLogsTo)(logger);
|
|
40
|
+
}
|
|
41
|
+
exports.setupLogs = setupLogs;
|
package/package.json
CHANGED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
import * as Models from './models/Models';
|
|
3
|
+
import { ObservedClient, ObservedClientConfig } from './ObservedClient';
|
|
4
|
+
import { createSingleExecutor } from './common/SingleExecutor';
|
|
5
|
+
import { ObservedOutboundTrack } from './ObservedOutboundTrack';
|
|
6
|
+
import { Observer } from './Observer';
|
|
7
|
+
import { createClientJoinedEventReport, createClientLeftEventReport } from './common/callEventReports';
|
|
8
|
+
|
|
9
|
+
export type ObservedCallConfig<AppData extends Record<string, unknown> = Record<string, unknown>> = {
|
|
10
|
+
serviceId: string;
|
|
11
|
+
roomId: string;
|
|
12
|
+
callId: string;
|
|
13
|
+
started: number,
|
|
14
|
+
appData: AppData,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type ObservedCallEvents = {
|
|
18
|
+
update: [],
|
|
19
|
+
newclient: [ObservedClient],
|
|
20
|
+
close: [],
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export declare interface ObservedCall {
|
|
24
|
+
on<U extends keyof ObservedCallEvents>(event: U, listener: (...args: ObservedCallEvents[U]) => void): this;
|
|
25
|
+
off<U extends keyof ObservedCallEvents>(event: U, listener: (...args: ObservedCallEvents[U]) => void): this;
|
|
26
|
+
once<U extends keyof ObservedCallEvents>(event: U, listener: (...args: ObservedCallEvents[U]) => void): this;
|
|
27
|
+
emit<U extends keyof ObservedCallEvents>(event: U, ...args: ObservedCallEvents[U]): boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export class ObservedCall<AppData extends Record<string, unknown> = Record<string, unknown>> extends EventEmitter {
|
|
31
|
+
public static async create<T extends Record<string, unknown> = Record<string, unknown>>(
|
|
32
|
+
config: ObservedCallConfig<T>,
|
|
33
|
+
observer: Observer,
|
|
34
|
+
// storageProvider: StorageProvider,
|
|
35
|
+
// reportsCollector: ReportsCollector,
|
|
36
|
+
) {
|
|
37
|
+
const model = new Models.Call({
|
|
38
|
+
roomId: config.roomId,
|
|
39
|
+
serviceId: config.serviceId,
|
|
40
|
+
callId: config.callId,
|
|
41
|
+
clientIds: [],
|
|
42
|
+
started: BigInt(config.started ?? Date.now()),
|
|
43
|
+
});
|
|
44
|
+
const result = new ObservedCall(
|
|
45
|
+
model,
|
|
46
|
+
observer,
|
|
47
|
+
// storageProvider,
|
|
48
|
+
// reportsCollector,
|
|
49
|
+
config.appData,
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const alreadyInserted = await observer.storage.callStorage.insert(config.callId, model);
|
|
53
|
+
|
|
54
|
+
if (alreadyInserted) throw new Error(`Call with id ${config.callId} already exists`);
|
|
55
|
+
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private readonly _execute = createSingleExecutor();
|
|
60
|
+
private readonly _creatingClients = new Map<string, Promise<ObservedClient>>();
|
|
61
|
+
private readonly _clients = new Map<string, ObservedClient>();
|
|
62
|
+
|
|
63
|
+
public readonly sfuStreamIdToOutboundAudioTrack = new Map<string | number, ObservedOutboundTrack<'audio'>>();
|
|
64
|
+
public readonly sfuStreamIdToOutboundVideoTrack = new Map<string | number, ObservedOutboundTrack<'video'>>();
|
|
65
|
+
private _closed = false;
|
|
66
|
+
private _ended?: number;
|
|
67
|
+
|
|
68
|
+
private constructor(
|
|
69
|
+
private readonly _model: Models.Call,
|
|
70
|
+
public readonly observer: Observer,
|
|
71
|
+
public readonly appData: AppData,
|
|
72
|
+
) {
|
|
73
|
+
super();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public get serviceId(): string {
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
78
|
+
return this._model.serviceId!;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public get reports() {
|
|
82
|
+
return this.observer.reports;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public get roomId() {
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
87
|
+
return this._model.roomId!;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public get callId() {
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
92
|
+
return this._model.callId!;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public get started() {
|
|
96
|
+
return Number(this._model.started);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
public get ended() {
|
|
100
|
+
return this._ended;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
public get clients(): ReadonlyMap<string, ObservedClient> {
|
|
104
|
+
return this._clients;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
public get closed() {
|
|
108
|
+
return this._closed;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
public close(timestamp?: number) {
|
|
112
|
+
if (this._closed) return;
|
|
113
|
+
this._closed = true;
|
|
114
|
+
this._ended = timestamp ?? Date.now();
|
|
115
|
+
|
|
116
|
+
Array.from(this._clients.values()).forEach((client) => client.close());
|
|
117
|
+
|
|
118
|
+
this._execute(() => this.observer.storage.callStorage.remove(this.callId))
|
|
119
|
+
.catch(() => void 0)
|
|
120
|
+
.finally(() => this.emit('close'));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
public async createClient<ClientAppData extends Record<string, unknown> = Record<string, unknown>>(
|
|
124
|
+
clientId: string,
|
|
125
|
+
config: { mediaUnitId?: string, appData: ClientAppData, joined?: number }
|
|
126
|
+
): Promise<ObservedClient> {
|
|
127
|
+
if (this._closed) throw new Error(`Call ${this.callId} is closed`);
|
|
128
|
+
let creating = this._creatingClients.get(clientId);
|
|
129
|
+
|
|
130
|
+
if (creating) return creating;
|
|
131
|
+
|
|
132
|
+
creating = this._createObservedClient<ClientAppData>(clientId, {
|
|
133
|
+
callId: this.callId,
|
|
134
|
+
appData: config.appData,
|
|
135
|
+
clientId,
|
|
136
|
+
overflowingProcessingThreshold: 2,
|
|
137
|
+
mediaUnitId: config.mediaUnitId ?? this.observer.config.defaultMediaUnitId,
|
|
138
|
+
joined: config.joined,
|
|
139
|
+
}).finally(() => this._creatingClients.delete(clientId));
|
|
140
|
+
|
|
141
|
+
this._creatingClients.set(clientId, creating);
|
|
142
|
+
|
|
143
|
+
return creating;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
public async save() {
|
|
147
|
+
if (this._closed) throw new Error(`Call ${this.callId} is closed`);
|
|
148
|
+
|
|
149
|
+
return this._execute(async () => {
|
|
150
|
+
if (this._closed) throw new Error(`Call ${this.callId} is closed`);
|
|
151
|
+
await this.observer.storage.callStorage.set(this.callId, this._model);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
private async _createObservedClient<ClientAppData extends Record<string, unknown> = Record<string, unknown>>(clientId: string, config: ObservedClientConfig<ClientAppData>): Promise<ObservedClient> {
|
|
156
|
+
const client = await ObservedClient.create<ClientAppData>(config, this, this.observer.storage);
|
|
157
|
+
const onUpdate = () => this.emit('update');
|
|
158
|
+
|
|
159
|
+
await this.save();
|
|
160
|
+
|
|
161
|
+
client.once('close', () => {
|
|
162
|
+
client.off('update', onUpdate);
|
|
163
|
+
|
|
164
|
+
this._clients.delete(clientId);
|
|
165
|
+
this._model.clientIds = this._model.clientIds.filter((id) => id !== clientId);
|
|
166
|
+
this.save().catch(() => void 0);
|
|
167
|
+
|
|
168
|
+
if (this.observer.config.addJoinAndDetachClientEvent) {
|
|
169
|
+
this.reports.addCallEventReport(createClientLeftEventReport(
|
|
170
|
+
this.serviceId,
|
|
171
|
+
client.mediaUnitId,
|
|
172
|
+
this.roomId,
|
|
173
|
+
this.callId,
|
|
174
|
+
client.clientId,
|
|
175
|
+
client.joined,
|
|
176
|
+
client.userId,
|
|
177
|
+
client.marker,
|
|
178
|
+
));
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
client.on('update', onUpdate);
|
|
183
|
+
this._clients.set(clientId, client);
|
|
184
|
+
this._model.clientIds.push(clientId);
|
|
185
|
+
|
|
186
|
+
if (this.observer.config.addJoinAndDetachClientEvent) {
|
|
187
|
+
this.reports.addCallEventReport(createClientJoinedEventReport(
|
|
188
|
+
this.serviceId,
|
|
189
|
+
client.mediaUnitId,
|
|
190
|
+
this.roomId,
|
|
191
|
+
this.callId,
|
|
192
|
+
client.clientId,
|
|
193
|
+
client.joined,
|
|
194
|
+
client.userId,
|
|
195
|
+
client.marker,
|
|
196
|
+
));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return client;
|
|
200
|
+
}
|
|
201
|
+
}
|