@observertc/observer-js 0.9.27-beta → 0.30.0-beta
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/src/Observer.ts
CHANGED
|
@@ -1,33 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { createSimpleSemaphoreProvider, SemaphoreProvider } from './common/Semaphore';
|
|
6
|
-
import { ObservedCallSourceConfig, ObservedCallSource } from './sources/ObservedCallSource';
|
|
7
|
-
import { PartialBy, asyncIteratorConverter } from './common/utils';
|
|
8
|
-
import { createLogger, LogLevel } from './common/logger';
|
|
9
|
-
import { ObservedSfuSource, ObservedSfuSourceConfig } from './sources/ObservedSfuSource';
|
|
1
|
+
import { createLogger } from './common/logger';
|
|
2
|
+
import { StorageProvider, createSimpleStorageProvider } from './storages/StorageProvider';
|
|
3
|
+
import { ObservedCall, ObservedCallConfig } from './ObservedCall';
|
|
4
|
+
import { ReportsCollector } from './ReportsCollector';
|
|
10
5
|
import { EventEmitter } from 'events';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { PeerConnectionEntry, createPeerConnectionEntry } from './entries/PeerConnectionEntry';
|
|
14
|
-
import { InboundTrackEntry, createInboundTrackEntry } from './entries/InboundTrackEntry';
|
|
15
|
-
import { OutboundTrackEntry, createOutboundTrackEntry } from './entries/OutboundTrackEntry';
|
|
16
|
-
import { SfuEntry, createSfuEntry } from './entries/SfuEntry';
|
|
17
|
-
import { SfuTransportEntry, createSfuTransportEntry } from './entries/SfuTransportEntry';
|
|
18
|
-
import { SfuInboundRtpPadEntry, createSfuInboundRtpPadEntry } from './entries/SfuInboundRtpPadEntry';
|
|
19
|
-
import { SfuOutboundRtpPadEntry, createSfuOutboundRtpPadEntry } from './entries/SfuOutboundRtpPadEntry';
|
|
20
|
-
import { SfuSctpChannelEntry, createSfuSctpChannelEntry } from './entries/SfuSctpChannelEntry';
|
|
21
|
-
import { GetClientCoordinate, createSetClientsCoordinateEvaluator } from './evaluators/SetClientsCoordinateEvaluator';
|
|
6
|
+
import { PartialBy } from './common/utils';
|
|
7
|
+
import { createCallStartedEventReport } from './common/callEventReports';
|
|
22
8
|
|
|
23
9
|
const logger = createLogger('Observer');
|
|
24
10
|
|
|
25
11
|
export type ObserverEvents = {
|
|
26
|
-
'
|
|
27
|
-
'
|
|
28
|
-
'
|
|
29
|
-
'processing-ended': undefined,
|
|
30
|
-
'close': undefined,
|
|
12
|
+
'newcall': [ObservedCall],
|
|
13
|
+
// 'newsfu': [ObservedSfu],
|
|
14
|
+
'close': [],
|
|
31
15
|
}
|
|
32
16
|
|
|
33
17
|
export type ObserverConfig = {
|
|
@@ -48,28 +32,30 @@ export type ObserverConfig = {
|
|
|
48
32
|
*/
|
|
49
33
|
defaultMediaUnitId: string;
|
|
50
34
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
sources: SourcesConfig;
|
|
55
|
-
evaluator: EvaluatorConfig;
|
|
56
|
-
sink: SinkConfig;
|
|
35
|
+
maxReports?: number | undefined;
|
|
36
|
+
maxCollectingTimeInMs?: number | undefined;
|
|
37
|
+
|
|
57
38
|
storages?: StorageProvider;
|
|
58
|
-
semaphores?: SemaphoreProvider;
|
|
59
39
|
|
|
60
|
-
|
|
40
|
+
/**
|
|
41
|
+
* before client-monitor-js 3.4.0 the client joined event was generated by the observer, this flag is to keep the compatibility with the old behavior
|
|
42
|
+
*/
|
|
43
|
+
addJoinAndDetachClientEvent?: boolean;
|
|
61
44
|
};
|
|
62
45
|
|
|
63
|
-
export
|
|
46
|
+
export declare interface Observer {
|
|
47
|
+
on<U extends keyof ObserverEvents>(event: U, listener: (...args: ObserverEvents[U]) => void): this;
|
|
48
|
+
off<U extends keyof ObserverEvents>(event: U, listener: (...args: ObserverEvents[U]) => void): this;
|
|
49
|
+
once<U extends keyof ObserverEvents>(event: U, listener: (...args: ObserverEvents[U]) => void): this;
|
|
50
|
+
emit<U extends keyof ObserverEvents>(event: U, ...args: ObserverEvents[U]): boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class Observer extends EventEmitter {
|
|
64
54
|
public static create(providedConfig: Partial<ObserverConfig>): Observer {
|
|
65
55
|
const config: ObserverConfig = Object.assign(
|
|
66
56
|
{
|
|
67
57
|
defaultServiceId: 'default-service-id',
|
|
68
58
|
defaultMediaUnitId: 'default-media-unit-id',
|
|
69
|
-
sources: {
|
|
70
|
-
maxSamples: 1000,
|
|
71
|
-
maxTimeInMs: 10000,
|
|
72
|
-
},
|
|
73
59
|
evaluator: {
|
|
74
60
|
fetchSamples: true,
|
|
75
61
|
maxIdleTimeInMs: 300 * 1000,
|
|
@@ -80,430 +66,73 @@ export class Observer {
|
|
|
80
66
|
providedConfig
|
|
81
67
|
);
|
|
82
68
|
|
|
83
|
-
const semaphores = providedConfig.semaphores ?? createSimpleSemaphoreProvider();
|
|
84
69
|
const storages = providedConfig.storages ?? createSimpleStorageProvider();
|
|
85
70
|
|
|
86
|
-
return new Observer(config, storages
|
|
71
|
+
return new Observer(config, storages);
|
|
87
72
|
}
|
|
88
73
|
|
|
89
|
-
|
|
90
|
-
private
|
|
91
|
-
private
|
|
92
|
-
private _evaluator: Evaluator;
|
|
74
|
+
public readonly reports = new ReportsCollector();
|
|
75
|
+
private readonly _observedCalls = new Map<string, ObservedCall>();
|
|
76
|
+
private _reportTimer?: ReturnType<typeof setTimeout>;
|
|
93
77
|
private _closed = false;
|
|
94
78
|
public constructor(
|
|
95
79
|
public readonly config: ObserverConfig,
|
|
96
|
-
|
|
97
|
-
private readonly _semaphores: SemaphoreProvider
|
|
80
|
+
public readonly storage: StorageProvider,
|
|
98
81
|
) {
|
|
99
|
-
|
|
100
|
-
this._sink = new SinkImpl(config.sink);
|
|
101
|
-
this._evaluator = new Evaluator(
|
|
102
|
-
this.config.evaluator,
|
|
103
|
-
this._semaphores.callSemaphore,
|
|
104
|
-
this._storages,
|
|
105
|
-
this._sink
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
this._sources.on('observed-samples', (event) => {
|
|
109
|
-
this._emitter.emit('processing-started');
|
|
110
|
-
this._evaluator.addObservedSamples(event);
|
|
111
|
-
});
|
|
112
|
-
this._sources.on('added-client-source', (event) => {
|
|
113
|
-
this._evaluator.addCreatedClientSource(event);
|
|
114
|
-
this._emitter.emit('client-added', event.clientId);
|
|
115
|
-
});
|
|
116
|
-
this._sources.on('removed-client-source', (event) => {
|
|
117
|
-
this._evaluator.addClosedClientSource(event);
|
|
118
|
-
this._emitter.emit('client-added', event.clientId);
|
|
119
|
-
});
|
|
120
|
-
this._evaluator.on('ready', () => {
|
|
121
|
-
this._sink.emit();
|
|
122
|
-
this._emitter.emit('processing-ended');
|
|
123
|
-
});
|
|
82
|
+
super();
|
|
124
83
|
logger.debug('Observer is created with config', this.config);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
public on<K extends keyof ObserverEvents>(event: K, listener: (arg: ObserverEvents[K]) => void): this {
|
|
132
|
-
this._emitter.on(event, listener);
|
|
133
|
-
|
|
134
|
-
return this;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
public once<K extends keyof ObserverEvents>(event: K, listener: (arg: ObserverEvents[K]) => void): this {
|
|
138
|
-
this._emitter.once(event, listener);
|
|
139
|
-
|
|
140
|
-
return this;
|
|
141
|
-
}
|
|
84
|
+
const onNewReport = (collectedReports: number) => {
|
|
85
|
+
if (!this.config.maxReports || this._closed) return;
|
|
86
|
+
if (this.config.maxReports < collectedReports) {
|
|
87
|
+
this._emitReports();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
142
90
|
|
|
143
|
-
|
|
144
|
-
this.
|
|
145
|
-
|
|
146
|
-
return this;
|
|
91
|
+
this.once('close', () => this.reports.off('newreport', onNewReport));
|
|
92
|
+
this.reports.on('newreport', onNewReport);
|
|
147
93
|
}
|
|
148
94
|
|
|
149
|
-
public
|
|
150
|
-
config: PartialBy<
|
|
151
|
-
):
|
|
95
|
+
public async createObservedCall<T extends Record<string, unknown> = Record<string, unknown>>(
|
|
96
|
+
config: PartialBy<ObservedCallConfig<T>, 'serviceId' | 'started'>
|
|
97
|
+
): Promise<ObservedCall<T>> {
|
|
152
98
|
if (this._closed) {
|
|
153
99
|
throw new Error('Attempted to create a call source on a closed observer');
|
|
154
100
|
}
|
|
155
101
|
|
|
156
|
-
const {
|
|
157
|
-
serviceId
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
): ObservedSfuSource {
|
|
174
|
-
if (this._closed) {
|
|
175
|
-
throw new Error('Attempted to create a sfu source on a closed observer');
|
|
176
|
-
}
|
|
177
|
-
const {
|
|
178
|
-
appData = {} as T,
|
|
179
|
-
serviceId = this.config.defaultServiceId,
|
|
180
|
-
mediaUnitId = this.config.defaultMediaUnitId,
|
|
181
|
-
joined = Date.now(),
|
|
182
|
-
...sfuConfig
|
|
183
|
-
} = config;
|
|
184
|
-
|
|
185
|
-
return this._sources.createSfuSource<T>({
|
|
186
|
-
...sfuConfig,
|
|
187
|
-
appData,
|
|
188
|
-
serviceId,
|
|
189
|
-
mediaUnitId,
|
|
190
|
-
joined,
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
public async evaluate() {
|
|
195
|
-
return new Promise<void>((resolve, reject) => {
|
|
196
|
-
this._evaluator.once('ready', (err) => {
|
|
197
|
-
if (err) reject(err);
|
|
198
|
-
else resolve();
|
|
199
|
-
});
|
|
200
|
-
this._sources.emitSamples();
|
|
102
|
+
const call = await ObservedCall.create({
|
|
103
|
+
serviceId: this.config.defaultServiceId,
|
|
104
|
+
started: Date.now(),
|
|
105
|
+
...config,
|
|
106
|
+
}, this);
|
|
107
|
+
|
|
108
|
+
if (this._closed) throw new Error('Cannot create an observed call on a closed observer');
|
|
109
|
+
if (this._observedCalls.has(call.callId)) throw new Error(`Observed Call with id ${call.callId} already exists`);
|
|
110
|
+
|
|
111
|
+
call.once('close', () => {
|
|
112
|
+
this._observedCalls.delete(call.callId);
|
|
113
|
+
this.reports.addCallEventReport(createCallStartedEventReport(
|
|
114
|
+
call.serviceId,
|
|
115
|
+
call.roomId,
|
|
116
|
+
call.callId,
|
|
117
|
+
Date.now(),
|
|
118
|
+
));
|
|
201
119
|
});
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
public get reports(): ObserverReportsEmitter {
|
|
205
|
-
return this._sink;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
public addEvaluators(...processes: EvaluatorProcess[]) {
|
|
209
|
-
if (this._closed) {
|
|
210
|
-
throw new Error('Attempted to add an evaluator to a closed observer');
|
|
211
|
-
}
|
|
212
|
-
for (const process of processes) {
|
|
213
|
-
this._evaluator.addProcess(process);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
public removeEvaluators(...processes: EvaluatorProcess[]) {
|
|
218
|
-
if (this._closed) {
|
|
219
|
-
throw new Error('Attempted to remove an evaluator from a closed observer');
|
|
220
|
-
}
|
|
221
|
-
for (const process of processes) {
|
|
222
|
-
this._evaluator.removeProcess(process);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
public addCoordinateEvaluator(getClientCoordinate: GetClientCoordinate) {
|
|
227
|
-
if (this._closed) {
|
|
228
|
-
throw new Error('Attempted to add an evaluator to a closed observer');
|
|
229
|
-
}
|
|
230
|
-
const process = createSetClientsCoordinateEvaluator(getClientCoordinate);
|
|
231
|
-
|
|
232
|
-
this._evaluator.addProcess(async (context) => process(context));
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
public addSinks(...processes: ObserverSinkProcess[]) {
|
|
236
|
-
if (this._closed) {
|
|
237
|
-
throw new Error('Attempted to add an evaluator to a closed observer');
|
|
238
|
-
}
|
|
239
|
-
for (const process of processes) {
|
|
240
|
-
this._sink.addProcess(process);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
public removeSinks(...processes: ObserverSinkProcess[]) {
|
|
245
|
-
if (this._closed) {
|
|
246
|
-
throw new Error('Attempted to remove an evaluator from a closed observer');
|
|
247
|
-
}
|
|
248
|
-
for (const process of processes) {
|
|
249
|
-
this._sink.removeProcess(process);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
public calls(): AsyncIterableIterator<CallEntry> {
|
|
254
|
-
const storageProvider = this._storages;
|
|
255
|
-
|
|
256
|
-
return asyncIteratorConverter((async function *() {
|
|
257
|
-
for await (const [ , callModel ] of storageProvider.callStorage[Symbol.asyncIterator]()) {
|
|
258
|
-
if (!callModel) continue;
|
|
259
|
-
yield createCallEntry(storageProvider, callModel);
|
|
260
|
-
}
|
|
261
|
-
})());
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
public sfus(): AsyncIterableIterator<SfuEntry> {
|
|
265
|
-
const storageProvider = this._storages;
|
|
266
|
-
|
|
267
|
-
return asyncIteratorConverter((async function *() {
|
|
268
|
-
for await (const [ , sfuModel ] of storageProvider.sfuStorage[Symbol.asyncIterator]()) {
|
|
269
|
-
if (!sfuModel) continue;
|
|
270
|
-
yield createSfuEntry(storageProvider, sfuModel);
|
|
271
|
-
}
|
|
272
|
-
})());
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
public sfuTransports(): AsyncIterableIterator<SfuTransportEntry> {
|
|
276
|
-
const storageProvider = this._storages;
|
|
277
|
-
|
|
278
|
-
return asyncIteratorConverter((async function *() {
|
|
279
|
-
for await (const [ , sfuTransportModel ] of storageProvider.sfuTransportStorage[Symbol.asyncIterator]()) {
|
|
280
|
-
if (!sfuTransportModel) continue;
|
|
281
|
-
yield createSfuTransportEntry(storageProvider, sfuTransportModel);
|
|
282
|
-
}
|
|
283
|
-
})());
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
public sfuInboundRtpPads(): AsyncIterableIterator<SfuInboundRtpPadEntry> {
|
|
287
|
-
const storageProvider = this._storages;
|
|
288
|
-
|
|
289
|
-
return asyncIteratorConverter((async function *() {
|
|
290
|
-
for await (const [ , sfuInboundRtpPadModel ] of storageProvider.sfuInboundRtpPadStorage[Symbol.asyncIterator]()) {
|
|
291
|
-
if (!sfuInboundRtpPadModel) continue;
|
|
292
|
-
yield createSfuInboundRtpPadEntry(storageProvider, sfuInboundRtpPadModel);
|
|
293
|
-
}
|
|
294
|
-
})());
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
public sfuOutboundRtpPads(): AsyncIterableIterator<SfuOutboundRtpPadEntry> {
|
|
298
|
-
const storageProvider = this._storages;
|
|
299
|
-
|
|
300
|
-
return asyncIteratorConverter((async function *() {
|
|
301
|
-
for await (const [ , sfuOutboundRtpPadModel ] of storageProvider.sfuOutboundRtpPadStorage[Symbol.asyncIterator]()) {
|
|
302
|
-
if (!sfuOutboundRtpPadModel) continue;
|
|
303
|
-
yield createSfuOutboundRtpPadEntry(storageProvider, sfuOutboundRtpPadModel);
|
|
304
|
-
}
|
|
305
|
-
})());
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
public clients(): AsyncIterableIterator<ClientEntry> {
|
|
309
|
-
const storageProvider = this._storages;
|
|
310
|
-
|
|
311
|
-
return asyncIteratorConverter((async function *() {
|
|
312
|
-
for await (const [ , callModel ] of storageProvider.clientStorage[Symbol.asyncIterator]()) {
|
|
313
|
-
if (!callModel) continue;
|
|
314
|
-
yield createClientEntry(storageProvider, callModel);
|
|
315
|
-
}
|
|
316
|
-
})());
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
public peerConnections(): AsyncIterableIterator<PeerConnectionEntry> {
|
|
320
|
-
const storageProvider = this._storages;
|
|
321
120
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
public async getTrack(trackId: string) {
|
|
331
|
-
const { inboundTrackStorage, outboundTrackStorage } = this._storages;
|
|
332
|
-
const [ inbTrackModel, outbTrackModel ] = await Promise.all([
|
|
333
|
-
inboundTrackStorage.get(trackId),
|
|
334
|
-
outboundTrackStorage.get(trackId),
|
|
335
|
-
]);
|
|
336
|
-
|
|
337
|
-
if (inbTrackModel) return createInboundTrackEntry(this._storages, inbTrackModel);
|
|
338
|
-
else if (outbTrackModel) return createOutboundTrackEntry(this._storages, outbTrackModel);
|
|
339
|
-
}
|
|
121
|
+
this._observedCalls.set(call.callId, call);
|
|
122
|
+
this.reports.addCallEventReport(createCallStartedEventReport(
|
|
123
|
+
call.serviceId,
|
|
124
|
+
call.roomId,
|
|
125
|
+
call.callId,
|
|
126
|
+
call.started,
|
|
127
|
+
));
|
|
340
128
|
|
|
341
|
-
|
|
342
|
-
const storageProvider = this._storages;
|
|
343
|
-
const { inboundTrackStorage, outboundTrackStorage } = this._storages;
|
|
129
|
+
this.emit('newcall', call);
|
|
344
130
|
|
|
345
|
-
|
|
346
|
-
inboundTrackStorage.getAll(trackIds),
|
|
347
|
-
outboundTrackStorage.getAll(trackIds),
|
|
348
|
-
]);
|
|
349
|
-
|
|
350
|
-
const result = new Map<string, InboundTrackEntry | OutboundTrackEntry>();
|
|
351
|
-
|
|
352
|
-
for (const [ trackId, model ] of inbTrackModels) {
|
|
353
|
-
result.set(trackId, createInboundTrackEntry(storageProvider, model));
|
|
354
|
-
}
|
|
355
|
-
for (const [ trackId, model ] of outbTrackModels) {
|
|
356
|
-
result.set(trackId, createOutboundTrackEntry(storageProvider, model));
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
return result;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
public inboundTracks(): AsyncIterableIterator<InboundTrackEntry> {
|
|
363
|
-
const storageProvider = this._storages;
|
|
364
|
-
|
|
365
|
-
return asyncIteratorConverter((async function *() {
|
|
366
|
-
for await (const [ , inboundTrackModel ] of storageProvider.inboundTrackStorage[Symbol.asyncIterator]()) {
|
|
367
|
-
if (!inboundTrackModel) continue;
|
|
368
|
-
yield createInboundTrackEntry(storageProvider, inboundTrackModel);
|
|
369
|
-
}
|
|
370
|
-
})());
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
public outboundTracks(): AsyncIterableIterator<OutboundTrackEntry> {
|
|
374
|
-
const storageProvider = this._storages;
|
|
375
|
-
|
|
376
|
-
return asyncIteratorConverter((async function *() {
|
|
377
|
-
for await (const [ , outboundTrackModel ] of storageProvider.outboundTrackStorage[Symbol.asyncIterator]()) {
|
|
378
|
-
if (!outboundTrackModel) continue;
|
|
379
|
-
yield createOutboundTrackEntry(storageProvider, outboundTrackModel);
|
|
380
|
-
}
|
|
381
|
-
})());
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
public sfuSctpChannels(): AsyncIterableIterator<SfuSctpChannelEntry> {
|
|
385
|
-
const storageProvider = this._storages;
|
|
386
|
-
|
|
387
|
-
return asyncIteratorConverter((async function *() {
|
|
388
|
-
for await (const [ , sfuSctpChannelModel ] of storageProvider.sfuSctpChannelStorage[Symbol.asyncIterator]()) {
|
|
389
|
-
if (!sfuSctpChannelModel) continue;
|
|
390
|
-
yield createSfuSctpChannelEntry(storageProvider, sfuSctpChannelModel);
|
|
391
|
-
}
|
|
392
|
-
})());
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
public async getCall(callId: string): Promise<CallEntry> {
|
|
396
|
-
return createCallEntry(this._storages, await this._storages.callStorage.get(callId));
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
public async getAllCalls(callIds: Iterable<string>): Promise<ReadonlyMap<string, CallEntry>> {
|
|
400
|
-
const models = await this._storages.callStorage.getAll(callIds);
|
|
401
|
-
|
|
402
|
-
return new Map(Array.from(models).map(([ callId, model ]) => [ callId, createCallEntry(this._storages, model) ]));
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
public async getSfu(sfuId: string): Promise<SfuEntry> {
|
|
406
|
-
return createSfuEntry(this._storages, await this._storages.sfuStorage.get(sfuId));
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
public async getAllSfus(sfuIds: Iterable<string>): Promise<ReadonlyMap<string, SfuEntry>> {
|
|
410
|
-
const models = await this._storages.sfuStorage.getAll(sfuIds);
|
|
411
|
-
|
|
412
|
-
return new Map(Array.from(models).map(([ sfuId, model ]) => [ sfuId, createSfuEntry(this._storages, model) ]));
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
public async getSfuTransport(sfuTransportId: string): Promise<SfuTransportEntry | undefined> {
|
|
416
|
-
return createSfuTransportEntry(this._storages, await this._storages.sfuTransportStorage.get(sfuTransportId));
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
public async getAllSfuTransports(
|
|
420
|
-
sfuTransportIds: Iterable<string>
|
|
421
|
-
): Promise<ReadonlyMap<string, SfuTransportEntry>> {
|
|
422
|
-
const models = await this._storages.sfuTransportStorage.getAll(sfuTransportIds);
|
|
423
|
-
|
|
424
|
-
return new Map(Array.from(models).map(([ sfuTransportId, model ]) => [ sfuTransportId, createSfuTransportEntry(this._storages, model) ]));
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
public async getSfuInboundRtpPad(sfuInboundRtpPadId: string): Promise<SfuInboundRtpPadEntry | undefined> {
|
|
428
|
-
return createSfuInboundRtpPadEntry(this._storages, await this._storages.sfuInboundRtpPadStorage.get(sfuInboundRtpPadId));
|
|
131
|
+
return call;
|
|
429
132
|
}
|
|
430
133
|
|
|
431
|
-
public
|
|
432
|
-
|
|
433
|
-
): Promise<ReadonlyMap<string, SfuInboundRtpPadEntry>> {
|
|
434
|
-
const models = await this._storages.sfuInboundRtpPadStorage.getAll(sfuInboundRtpPadIds);
|
|
435
|
-
|
|
436
|
-
return new Map(Array.from(models).map(([ sfuInboundRtpPadId, model ]) => [ sfuInboundRtpPadId, createSfuInboundRtpPadEntry(this._storages, model) ]));
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
public async getSfuOutboundRtpPad(sfuOutboundRtpPadId: string): Promise<SfuOutboundRtpPadEntry | undefined> {
|
|
440
|
-
return createSfuOutboundRtpPadEntry(this._storages, await this._storages.sfuOutboundRtpPadStorage.get(sfuOutboundRtpPadId));
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
public async getAllSfuOutboundRtpPads(
|
|
444
|
-
sfuOutboundRtpPadIds: Iterable<string>
|
|
445
|
-
): Promise<ReadonlyMap<string, SfuOutboundRtpPadEntry>> {
|
|
446
|
-
const models = await this._storages.sfuOutboundRtpPadStorage.getAll(sfuOutboundRtpPadIds);
|
|
447
|
-
|
|
448
|
-
return new Map(Array.from(models).map(([ sfuOutboundRtpPadId, model ]) => [ sfuOutboundRtpPadId, createSfuOutboundRtpPadEntry(this._storages, model) ]));
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
public async getClient(clientId: string): Promise<ClientEntry> {
|
|
452
|
-
return createClientEntry(this._storages, await this._storages.clientStorage.get(clientId));
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
public async getAllClient(clientIds: Iterable<string>): Promise<ReadonlyMap<string, ClientEntry>> {
|
|
456
|
-
const models = await this._storages.clientStorage.getAll(clientIds);
|
|
457
|
-
|
|
458
|
-
return new Map(Array.from(models).map(([ clientId, model ]) => [ clientId, createClientEntry(this._storages, model) ]));
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
public async getPeerConnection(peerConnectionId: string): Promise<PeerConnectionEntry> {
|
|
462
|
-
return createPeerConnectionEntry(this._storages, await this._storages.peerConnectionStorage.get(peerConnectionId));
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
public async getAllPeerConnections(
|
|
466
|
-
peerConnectionIds: Iterable<string>
|
|
467
|
-
): Promise<ReadonlyMap<string, PeerConnectionEntry>> {
|
|
468
|
-
const models = await this._storages.peerConnectionStorage.getAll(peerConnectionIds);
|
|
469
|
-
|
|
470
|
-
return new Map(Array.from(models).map(([ peerConnectionId, model ]) => [ peerConnectionId, createPeerConnectionEntry(this._storages, model) ]));
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
public async getInboundTrack(inboundTrackId: string): Promise<InboundTrackEntry> {
|
|
474
|
-
return createInboundTrackEntry(this._storages, await this._storages.inboundTrackStorage.get(inboundTrackId));
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
public async getAllInboundTracks(
|
|
478
|
-
inboundTrackIds: Iterable<string>
|
|
479
|
-
): Promise<ReadonlyMap<string, InboundTrackEntry>> {
|
|
480
|
-
const models = await this._storages.inboundTrackStorage.getAll(inboundTrackIds);
|
|
481
|
-
|
|
482
|
-
return new Map(Array.from(models).map(([ inboundTrackId, model ]) => [ inboundTrackId, createInboundTrackEntry(this._storages, model) ]));
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
public async getOutboundTrack(outboundTrackId: string): Promise<OutboundTrackEntry> {
|
|
486
|
-
return createOutboundTrackEntry(this._storages, await this._storages.outboundTrackStorage.get(outboundTrackId));
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
public async getAllOutboundTracks(
|
|
490
|
-
outboundTrackIds: Iterable<string>
|
|
491
|
-
): Promise<ReadonlyMap<string, OutboundTrackEntry>> {
|
|
492
|
-
const models = await this._storages.outboundTrackStorage.getAll(outboundTrackIds);
|
|
493
|
-
|
|
494
|
-
return new Map(Array.from(models).map(([ outboundTrackId, model ]) => [ outboundTrackId, createOutboundTrackEntry(this._storages, model) ]));
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
public async getSfuSctpChannel(sctpChannelId: string): Promise<SfuSctpChannelEntry | undefined> {
|
|
498
|
-
return createSfuSctpChannelEntry(this._storages, await this._storages.sfuSctpChannelStorage.get(sctpChannelId));
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
public async getAllSfuSctpChannel(
|
|
502
|
-
sctpChannelIds: Iterable<string>
|
|
503
|
-
): Promise<ReadonlyMap<string, SfuSctpChannelEntry>> {
|
|
504
|
-
const models = await this._storages.sfuSctpChannelStorage.getAll(sctpChannelIds);
|
|
505
|
-
|
|
506
|
-
return new Map(Array.from(models).map(([ sctpChannelId, model ]) => [ sctpChannelId, createSfuSctpChannelEntry(this._storages, model) ]));
|
|
134
|
+
public get observedCalls(): ReadonlyMap<string, ObservedCall> {
|
|
135
|
+
return this._observedCalls;
|
|
507
136
|
}
|
|
508
137
|
|
|
509
138
|
public get closed() {
|
|
@@ -515,8 +144,23 @@ export class Observer {
|
|
|
515
144
|
return logger.debug('Attempted to close twice');
|
|
516
145
|
}
|
|
517
146
|
this._closed = true;
|
|
518
|
-
this._sources.close();
|
|
519
147
|
|
|
520
|
-
this.
|
|
148
|
+
this.emit('close');
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
private _emitReports() {
|
|
152
|
+
if (this._reportTimer) {
|
|
153
|
+
clearTimeout(this._reportTimer);
|
|
154
|
+
this._reportTimer = undefined;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
this.reports.emit();
|
|
158
|
+
|
|
159
|
+
if (this.config.maxCollectingTimeInMs) {
|
|
160
|
+
this._reportTimer = setTimeout(() => {
|
|
161
|
+
this._reportTimer = undefined;
|
|
162
|
+
this._emitReports();
|
|
163
|
+
}, this.config.maxCollectingTimeInMs);
|
|
164
|
+
}
|
|
521
165
|
}
|
|
522
166
|
}
|