@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
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { SfuOutboundRtpPad } from '@observertc/sample-schemas-js';
|
|
2
|
-
import { ObservedSfuTransport } from './ObservedSfuTransport';
|
|
3
|
-
|
|
4
|
-
export interface ObservedSfuOutboundRtpPad {
|
|
5
|
-
readonly sfuTransport: ObservedSfuTransport;
|
|
6
|
-
readonly padId: string;
|
|
7
|
-
|
|
8
|
-
samples(): IterableIterator<SfuOutboundRtpPad>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class ObservedSfuOutboundRtpPadBuilder {
|
|
12
|
-
private _samples: SfuOutboundRtpPad[] = [];
|
|
13
|
-
public constructor(
|
|
14
|
-
private _config: Omit<
|
|
15
|
-
ObservedSfuOutboundRtpPad,
|
|
16
|
-
| keyof IterableIterator<SfuOutboundRtpPad>
|
|
17
|
-
| 'sfuTransport'
|
|
18
|
-
| 'samples'
|
|
19
|
-
>
|
|
20
|
-
) {}
|
|
21
|
-
|
|
22
|
-
public addSample(sfuInboundRtpPad: SfuOutboundRtpPad) {
|
|
23
|
-
this._samples.push(sfuInboundRtpPad);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public build(sfuTransport: ObservedSfuTransport): ObservedSfuOutboundRtpPad {
|
|
27
|
-
const result: ObservedSfuOutboundRtpPad = {
|
|
28
|
-
sfuTransport,
|
|
29
|
-
...this._config,
|
|
30
|
-
samples: () => this._samples.values(),
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { SfuSctpChannel } from '@observertc/sample-schemas-js';
|
|
2
|
-
import { ObservedSfuTransport } from './ObservedSfuTransport';
|
|
3
|
-
|
|
4
|
-
export interface ObservedSfuSctpChannel {
|
|
5
|
-
readonly sfuTransport: ObservedSfuTransport;
|
|
6
|
-
readonly channelId: string;
|
|
7
|
-
|
|
8
|
-
samples(): IterableIterator<SfuSctpChannel>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class ObservedSfuSctpChannelBuilder {
|
|
12
|
-
private _samples: SfuSctpChannel[] = [];
|
|
13
|
-
public constructor(
|
|
14
|
-
private _config: Omit<
|
|
15
|
-
ObservedSfuSctpChannel,
|
|
16
|
-
| keyof IterableIterator<SfuSctpChannel>
|
|
17
|
-
| 'sfuTransport'
|
|
18
|
-
| 'samples'
|
|
19
|
-
>
|
|
20
|
-
) {}
|
|
21
|
-
|
|
22
|
-
public addSample(sfuSctpChannel: SfuSctpChannel) {
|
|
23
|
-
this._samples.push(sfuSctpChannel);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public build(sfuTransport: ObservedSfuTransport): ObservedSfuSctpChannel {
|
|
27
|
-
const result: ObservedSfuSctpChannel = {
|
|
28
|
-
sfuTransport,
|
|
29
|
-
...this._config,
|
|
30
|
-
samples: () => this._samples.values(),
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SfuInboundRtpPad,
|
|
3
|
-
SfuOutboundRtpPad,
|
|
4
|
-
SfuSctpChannel,
|
|
5
|
-
SfuTransport,
|
|
6
|
-
} from '@observertc/sample-schemas-js';
|
|
7
|
-
import { ObservedSfu } from './ObservedSfu';
|
|
8
|
-
import { ObservedSfuInboundRtpPad, ObservedSfuInboundRtpPadBuilder } from './ObservedSfuInboundRtpPad';
|
|
9
|
-
import { ObservedSfuOutboundRtpPad, ObservedSfuOutboundRtpPadBuilder } from './ObservedSfuOutboundRtpPad';
|
|
10
|
-
import { ObservedSfuSctpChannel, ObservedSfuSctpChannelBuilder } from './ObservedSfuSctpChannel';
|
|
11
|
-
|
|
12
|
-
export interface ObservedSfuTransport {
|
|
13
|
-
readonly sfu: ObservedSfu;
|
|
14
|
-
readonly transportId: string;
|
|
15
|
-
|
|
16
|
-
inboundRtpPads(): IterableIterator<ObservedSfuInboundRtpPad>;
|
|
17
|
-
outboundRtpPads(): IterableIterator<ObservedSfuOutboundRtpPad>;
|
|
18
|
-
sfuSctpChannels(): IterableIterator<ObservedSfuSctpChannel>;
|
|
19
|
-
|
|
20
|
-
transportSamples(): IterableIterator<SfuTransport>;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export class ObservedSfuTransportBuilder {
|
|
24
|
-
private _inboundRtpPads = new Map<string, ObservedSfuInboundRtpPadBuilder>();
|
|
25
|
-
private _outboundRtpPads = new Map<string, ObservedSfuOutboundRtpPadBuilder>();
|
|
26
|
-
private _sctpChannels = new Map<string, ObservedSfuSctpChannelBuilder>();
|
|
27
|
-
private _transportSamples: SfuTransport[] = [];
|
|
28
|
-
public constructor(
|
|
29
|
-
private _config: Omit<
|
|
30
|
-
ObservedSfuTransport,
|
|
31
|
-
| keyof IterableIterator<ObservedSfuTransport>
|
|
32
|
-
| 'sfu'
|
|
33
|
-
| 'inboundRtpPads'
|
|
34
|
-
| 'outboundRtpPads'
|
|
35
|
-
| 'sfuSctpChannels'
|
|
36
|
-
| 'transportSamples'
|
|
37
|
-
>
|
|
38
|
-
) {}
|
|
39
|
-
|
|
40
|
-
public addTransportSample(transportSample: SfuTransport) {
|
|
41
|
-
this._transportSamples.push(transportSample);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public addSfuInboundRtpPad(inboundRtpPad: SfuInboundRtpPad) {
|
|
45
|
-
if (inboundRtpPad.padId) {
|
|
46
|
-
const builder = this._getSfuInboundRtpPadBuilder(inboundRtpPad.padId);
|
|
47
|
-
|
|
48
|
-
builder.addSample(inboundRtpPad);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
private _getSfuInboundRtpPadBuilder(padId: string): ObservedSfuInboundRtpPadBuilder {
|
|
53
|
-
let result = this._inboundRtpPads.get(padId);
|
|
54
|
-
|
|
55
|
-
if (!result) {
|
|
56
|
-
result = new ObservedSfuInboundRtpPadBuilder({
|
|
57
|
-
padId,
|
|
58
|
-
});
|
|
59
|
-
this._inboundRtpPads.set(padId, result);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return result;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
public addSfuOutboundRtpPad(outboundRtpPad: SfuOutboundRtpPad) {
|
|
66
|
-
if (outboundRtpPad.padId) {
|
|
67
|
-
const builder = this._getSfuOutboundRtpPadBuilder(outboundRtpPad.padId);
|
|
68
|
-
|
|
69
|
-
builder.addSample(outboundRtpPad);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
private _getSfuOutboundRtpPadBuilder(padId: string): ObservedSfuOutboundRtpPadBuilder {
|
|
74
|
-
let result = this._outboundRtpPads.get(padId);
|
|
75
|
-
|
|
76
|
-
if (!result) {
|
|
77
|
-
result = new ObservedSfuOutboundRtpPadBuilder({
|
|
78
|
-
padId,
|
|
79
|
-
});
|
|
80
|
-
this._outboundRtpPads.set(padId, result);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return result;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
public addSfuSctpChannel(sfuSctpChannel: SfuSctpChannel) {
|
|
87
|
-
if (sfuSctpChannel.channelId) {
|
|
88
|
-
const builder = this._getSfuSctpChannel(sfuSctpChannel.channelId);
|
|
89
|
-
|
|
90
|
-
builder.addSample(sfuSctpChannel);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
private _getSfuSctpChannel(channelId: string): ObservedSfuSctpChannelBuilder {
|
|
95
|
-
let result = this._sctpChannels.get(channelId);
|
|
96
|
-
|
|
97
|
-
if (!result) {
|
|
98
|
-
result = new ObservedSfuSctpChannelBuilder({
|
|
99
|
-
channelId,
|
|
100
|
-
});
|
|
101
|
-
this._sctpChannels.set(channelId, result);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return result;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
public build(sfu: ObservedSfu): ObservedSfuTransport {
|
|
108
|
-
const sfuInboundRtpPads = new Map<string, ObservedSfuInboundRtpPad>();
|
|
109
|
-
const sfuOutboundRtpPads = new Map<string, ObservedSfuOutboundRtpPad>();
|
|
110
|
-
const sfuSctpChannelsMap = new Map<string, ObservedSfuSctpChannel>();
|
|
111
|
-
|
|
112
|
-
const result: ObservedSfuTransport = {
|
|
113
|
-
sfu,
|
|
114
|
-
...this._config,
|
|
115
|
-
transportSamples: () => this._transportSamples.values(),
|
|
116
|
-
|
|
117
|
-
inboundRtpPads: () => sfuInboundRtpPads.values(),
|
|
118
|
-
outboundRtpPads: () => sfuOutboundRtpPads.values(),
|
|
119
|
-
sfuSctpChannels: () => sfuSctpChannelsMap.values(),
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
for (const builder of this._inboundRtpPads.values()) {
|
|
123
|
-
const observedInboundRtpPad = builder.build(result);
|
|
124
|
-
|
|
125
|
-
sfuInboundRtpPads.set(observedInboundRtpPad.padId, observedInboundRtpPad);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
for (const builder of this._outboundRtpPads.values()) {
|
|
129
|
-
const observedOutboundRtpPad = builder.build(result);
|
|
130
|
-
|
|
131
|
-
sfuOutboundRtpPads.set(observedOutboundRtpPad.padId, observedOutboundRtpPad);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
for (const builder of this._sctpChannels.values()) {
|
|
135
|
-
const observedSfuSctpChannel = builder.build(result);
|
|
136
|
-
|
|
137
|
-
sfuSctpChannelsMap.set(observedSfuSctpChannel.channelId, observedSfuSctpChannel);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return result;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { iteratorConverter } from '../common/utils';
|
|
2
|
-
import { ObservedSfu, ObservedSfuBuilder } from './ObservedSfu';
|
|
3
|
-
|
|
4
|
-
export interface ObservedSfus {
|
|
5
|
-
sfuIds(): IterableIterator<string>;
|
|
6
|
-
sfuTransportIds(): IterableIterator<string>;
|
|
7
|
-
sfuInboundRtpPadIds(): IterableIterator<string>;
|
|
8
|
-
sfuOutboundRtpPadIds(): IterableIterator<string>;
|
|
9
|
-
|
|
10
|
-
observedSfus(): IterableIterator<ObservedSfu>;
|
|
11
|
-
getObservedSfu(sfuId: string): ObservedSfu | undefined;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export class ObservedSfusBuilder {
|
|
15
|
-
private _builders = new Map<string, ObservedSfuBuilder>();
|
|
16
|
-
public constructor() {
|
|
17
|
-
// nothing
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
public getOrCreateObservedSfuBuilder(
|
|
21
|
-
sfuId: string,
|
|
22
|
-
configSupplier: () => ConstructorParameters<typeof ObservedSfuBuilder>[0]
|
|
23
|
-
) {
|
|
24
|
-
let result = this._builders.get(sfuId);
|
|
25
|
-
|
|
26
|
-
if (!result) {
|
|
27
|
-
const config = configSupplier();
|
|
28
|
-
|
|
29
|
-
result = new ObservedSfuBuilder(config);
|
|
30
|
-
this._builders.set(sfuId, result);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public build(): ObservedSfus {
|
|
37
|
-
const observedSfus = new Map<string, ObservedSfu>();
|
|
38
|
-
|
|
39
|
-
const sfuIdsGenerator = function *() {
|
|
40
|
-
for (const observedSfu of observedSfus.values()) {
|
|
41
|
-
yield observedSfu.sfuId;
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const sfuIds = () => iteratorConverter<string>(sfuIdsGenerator());
|
|
45
|
-
|
|
46
|
-
const sfuTransportIdsGenerator = function *() {
|
|
47
|
-
for (const observedSfu of observedSfus.values()) {
|
|
48
|
-
for (const observedTransport of observedSfu.observedSfuTransports()) {
|
|
49
|
-
yield observedTransport.transportId;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
const sfuTransportIds = () => iteratorConverter<string>(sfuTransportIdsGenerator());
|
|
54
|
-
|
|
55
|
-
const sfuInboundRtpPadIdsGenerator = function *() {
|
|
56
|
-
for (const observedSfu of observedSfus.values()) {
|
|
57
|
-
for (const observedTransport of observedSfu.observedSfuTransports()) {
|
|
58
|
-
for (const sfuInboundRtpPad of observedTransport.inboundRtpPads()) {
|
|
59
|
-
yield sfuInboundRtpPad.padId;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
const sfuInboundRtpPadIds = () => iteratorConverter<string>(sfuInboundRtpPadIdsGenerator());
|
|
65
|
-
|
|
66
|
-
const sfuOutboundRtpPadIdsGenerator = function *() {
|
|
67
|
-
for (const observedSfu of observedSfus.values()) {
|
|
68
|
-
for (const observedTransport of observedSfu.observedSfuTransports()) {
|
|
69
|
-
for (const sfuOutboundRtpPad of observedTransport.outboundRtpPads()) {
|
|
70
|
-
yield sfuOutboundRtpPad.padId;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
const sfuOutboundRtpPadIds = () => iteratorConverter<string>(sfuOutboundRtpPadIdsGenerator());
|
|
76
|
-
|
|
77
|
-
const result: ObservedSfus = {
|
|
78
|
-
sfuIds,
|
|
79
|
-
sfuTransportIds,
|
|
80
|
-
sfuInboundRtpPadIds,
|
|
81
|
-
sfuOutboundRtpPadIds,
|
|
82
|
-
observedSfus: () => observedSfus.values(),
|
|
83
|
-
getObservedSfu: (sfuId) => observedSfus.get(sfuId),
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
for (const builder of this._builders.values()) {
|
|
87
|
-
const observedSfu = builder.build();
|
|
88
|
-
|
|
89
|
-
observedSfus.set(observedSfu.sfuId, observedSfu);
|
|
90
|
-
}
|
|
91
|
-
this._builders.clear();
|
|
92
|
-
|
|
93
|
-
return result;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { PartialBy } from '../common/utils';
|
|
2
|
-
import { ObservedClientSource, ObservedClientSourceConfig } from './ObservedClientSource';
|
|
3
|
-
|
|
4
|
-
export type ObservedCallSourceConfig<T extends Record<string, unknown>> = {
|
|
5
|
-
readonly appData: T
|
|
6
|
-
readonly serviceId: string;
|
|
7
|
-
readonly mediaUnitId: string;
|
|
8
|
-
readonly roomId: string;
|
|
9
|
-
readonly callId: string;
|
|
10
|
-
|
|
11
|
-
createCallStartedReport?: boolean,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export interface ObservedCallSource<T extends Record<string, unknown> = Record<string, unknown>> extends ObservedCallSourceConfig<T> {
|
|
15
|
-
readonly closed: boolean;
|
|
16
|
-
readonly clients: IterableIterator<ObservedClientSource>;
|
|
17
|
-
|
|
18
|
-
getClientSource<U extends Record<string, unknown>>(clientId: string): ObservedClientSource<U> | undefined;
|
|
19
|
-
|
|
20
|
-
createClientSource<U extends Record<string, unknown> = Record<string, unknown>>(
|
|
21
|
-
context: PartialBy<ObservedClientSourceConfig<U>, 'joined' | 'mediaUnitId' | 'serviceId' | 'callId' | 'roomId'>
|
|
22
|
-
): ObservedClientSource<U>;
|
|
23
|
-
|
|
24
|
-
// automatically close every
|
|
25
|
-
close(): void;
|
|
26
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ClientSample } from '@observertc/sample-schemas-js';
|
|
2
|
-
|
|
3
|
-
export type ObservedClientSourceConfig<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
4
|
-
readonly appData: T;
|
|
5
|
-
readonly serviceId: string;
|
|
6
|
-
readonly mediaUnitId: string;
|
|
7
|
-
readonly roomId: string;
|
|
8
|
-
readonly clientId: string;
|
|
9
|
-
readonly callId: string;
|
|
10
|
-
readonly joined: number;
|
|
11
|
-
|
|
12
|
-
marker?: string;
|
|
13
|
-
userId?: string;
|
|
14
|
-
timeZoneId?: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export interface ObservedClientSource<T extends Record<string, unknown> = Record<string, unknown>> extends ObservedClientSourceConfig<T> {
|
|
18
|
-
readonly closed: boolean;
|
|
19
|
-
|
|
20
|
-
accept(...samples: ClientSample[]): void;
|
|
21
|
-
|
|
22
|
-
// when you close this, client is disposed. so this triggers the client to dispose
|
|
23
|
-
// therefore this triggers the call to be disposed
|
|
24
|
-
// peer connections, and tracks the creation is evented by the client,
|
|
25
|
-
// the close of those object is evented by the observer or closing this
|
|
26
|
-
// call the close of this is mandatory, as only this closes the client inside the observer
|
|
27
|
-
close(): void;
|
|
28
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { SfuSample } from '@observertc/sample-schemas-js';
|
|
2
|
-
|
|
3
|
-
export type ObservedSfuSourceConfig<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
4
|
-
readonly appData: T;
|
|
5
|
-
readonly serviceId: string;
|
|
6
|
-
readonly mediaUnitId: string;
|
|
7
|
-
readonly sfuId: string;
|
|
8
|
-
readonly joined: number;
|
|
9
|
-
|
|
10
|
-
timeZoneId?: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export interface ObservedSfuSource<T extends Record<string, unknown> = Record<string, unknown>> extends ObservedSfuSourceConfig<T> {
|
|
14
|
-
readonly closed: boolean;
|
|
15
|
-
|
|
16
|
-
accept(...samples: SfuSample[]): void;
|
|
17
|
-
|
|
18
|
-
close(): void;
|
|
19
|
-
}
|
package/src/sources/Sources.ts
DELETED
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
import { ClientSample, SfuSample } from '@observertc/sample-schemas-js';
|
|
2
|
-
import { ObservedCalls, ObservedCallsBuilder } from '../samples/ObservedCalls';
|
|
3
|
-
import { ObservedClientSource, ObservedClientSourceConfig } from './ObservedClientSource';
|
|
4
|
-
import { EventEmitter } from 'events';
|
|
5
|
-
import { createLogger } from '../common/logger';
|
|
6
|
-
import { PartialBy } from '../common/utils';
|
|
7
|
-
import { ObservedSfuSourceConfig, ObservedSfuSource } from './ObservedSfuSource';
|
|
8
|
-
import { ObservedSfus, ObservedSfusBuilder } from '../samples/ObservedSfus';
|
|
9
|
-
import { ObservedCallSource, ObservedCallSourceConfig } from './ObservedCallSource';
|
|
10
|
-
|
|
11
|
-
const logger = createLogger('Sources');
|
|
12
|
-
|
|
13
|
-
export type SourcesConfig = {
|
|
14
|
-
maxSamples: number;
|
|
15
|
-
maxTimeInMs: number;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type SourcesEvents = {
|
|
19
|
-
'observed-samples': {
|
|
20
|
-
observedCalls: ObservedCalls;
|
|
21
|
-
observedSfus: ObservedSfus;
|
|
22
|
-
numberOfSamples: number;
|
|
23
|
-
};
|
|
24
|
-
'removed-client-source': ObservedClientSourceConfig;
|
|
25
|
-
'added-client-source': ObservedClientSourceConfig;
|
|
26
|
-
'removed-sfu-source': ObservedSfuSourceConfig;
|
|
27
|
-
'added-sfu-source': ObservedSfuSourceConfig;
|
|
28
|
-
'added-call-source': ObservedCallSource;
|
|
29
|
-
'removed-call-source': ObservedCallSource;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export class Sources {
|
|
33
|
-
|
|
34
|
-
private readonly _warnFlags = { autoEmitButEmitSamplesInvoked: false };
|
|
35
|
-
private readonly _callSources = new Map<string, ObservedCallSource>();
|
|
36
|
-
// private readonly _clientSources = new Map<string, ObservedClientSource>();
|
|
37
|
-
private readonly _sfuSources = new Map<string, ObservedSfuSource>();
|
|
38
|
-
private readonly _emitter = new EventEmitter();
|
|
39
|
-
|
|
40
|
-
private _observedCallsBuilder = new ObservedCallsBuilder();
|
|
41
|
-
private _observedSfusBuilder = new ObservedSfusBuilder();
|
|
42
|
-
private _timer?: ReturnType<typeof setTimeout>;
|
|
43
|
-
private _numberOfSamples = 0;
|
|
44
|
-
|
|
45
|
-
public constructor(public readonly config: SourcesConfig) {}
|
|
46
|
-
|
|
47
|
-
public getCallSource<T extends Record<string, unknown> = Record<string, unknown>>(callId: string): ObservedCallSource<T> | undefined {
|
|
48
|
-
if (!this._callSources.has(callId)) return;
|
|
49
|
-
|
|
50
|
-
return this._callSources.get(callId) as ObservedCallSource<T>;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
public getSfuSource<T extends Record<string, unknown> = Record<string, unknown>>(sfuId: string) {
|
|
54
|
-
if (!this._sfuSources.has(sfuId)) return;
|
|
55
|
-
|
|
56
|
-
return this._sfuSources.get(sfuId) as ObservedSfuSource<T>;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public on<K extends keyof SourcesEvents>(event: K, listener: (data: SourcesEvents[K]) => void): this {
|
|
60
|
-
this._emitter.addListener(event, listener);
|
|
61
|
-
|
|
62
|
-
return this;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
public off<K extends keyof SourcesEvents>(event: K, listener: (data: SourcesEvents[K]) => void): this {
|
|
66
|
-
this._emitter.removeListener(event, listener);
|
|
67
|
-
|
|
68
|
-
return this;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
private _emit<K extends keyof SourcesEvents>(event: K, data: SourcesEvents[K]): boolean {
|
|
72
|
-
return this._emitter.emit(event, data);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
public createCallSource<T extends Record<string, unknown> = Record<string, unknown>>(
|
|
76
|
-
config: ObservedCallSourceConfig<T>
|
|
77
|
-
): ObservedCallSource<T> {
|
|
78
|
-
let closed = false;
|
|
79
|
-
const {
|
|
80
|
-
serviceId,
|
|
81
|
-
mediaUnitId,
|
|
82
|
-
appData,
|
|
83
|
-
...callConfig
|
|
84
|
-
} = config;
|
|
85
|
-
const clientSources = new Map<string, ObservedClientSource>();
|
|
86
|
-
const callSource: ObservedCallSource<T> = {
|
|
87
|
-
...callConfig,
|
|
88
|
-
appData,
|
|
89
|
-
serviceId,
|
|
90
|
-
mediaUnitId,
|
|
91
|
-
get clients() {
|
|
92
|
-
return clientSources.values();
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
getClientSource: <U extends Record<string, unknown> = Record<string, unknown>>(clientId: string) => {
|
|
96
|
-
if (!clientSources.has(clientId)) return;
|
|
97
|
-
else return clientSources.get(clientId) as ObservedClientSource<U>;
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
createClientSource: <U extends Record<string, unknown> = Record<string, unknown>>(context: ObservedClientSourceConfig<U>) => {
|
|
101
|
-
const existingClientSource = clientSources.get(context.clientId);
|
|
102
|
-
|
|
103
|
-
if (existingClientSource) return existingClientSource as ObservedClientSource<U>;
|
|
104
|
-
|
|
105
|
-
const { appData: clientAppData, ...clientConfig } = context;
|
|
106
|
-
const clientSource = this._createClientSource<U>(callSource, {
|
|
107
|
-
...callConfig,
|
|
108
|
-
...clientConfig,
|
|
109
|
-
appData: clientAppData,
|
|
110
|
-
serviceId,
|
|
111
|
-
mediaUnitId,
|
|
112
|
-
});
|
|
113
|
-
const closeClientSource = clientSource.close;
|
|
114
|
-
|
|
115
|
-
clientSource.close = () => {
|
|
116
|
-
closeClientSource();
|
|
117
|
-
clientSources.delete(context.clientId);
|
|
118
|
-
};
|
|
119
|
-
clientSources.set(context.clientId, clientSource);
|
|
120
|
-
|
|
121
|
-
return clientSource as ObservedClientSource<U>;
|
|
122
|
-
},
|
|
123
|
-
close: () => {
|
|
124
|
-
if (closed) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
closed = true;
|
|
128
|
-
|
|
129
|
-
for (const clientSource of clientSources.values()) {
|
|
130
|
-
clientSource.close();
|
|
131
|
-
}
|
|
132
|
-
clientSources.clear();
|
|
133
|
-
this._callSources.delete(config.callId);
|
|
134
|
-
|
|
135
|
-
this._emit('removed-call-source', callSource);
|
|
136
|
-
},
|
|
137
|
-
closed,
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
if (this._callSources.size < 1) {
|
|
141
|
-
this._resetTimer();
|
|
142
|
-
}
|
|
143
|
-
this._callSources.set(config.callId, callSource);
|
|
144
|
-
|
|
145
|
-
this._emit('added-call-source', callSource);
|
|
146
|
-
|
|
147
|
-
return callSource;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
private _createClientSource<T extends Record<string, unknown> = Record<string, unknown>>(callSource: ObservedCallSource, config: PartialBy<ObservedClientSourceConfig<T>, 'joined'>): ObservedClientSource<T> {
|
|
151
|
-
let closed = false;
|
|
152
|
-
const {
|
|
153
|
-
appData,
|
|
154
|
-
...clientConfig
|
|
155
|
-
} = config;
|
|
156
|
-
|
|
157
|
-
const source: ObservedClientSource<T> = {
|
|
158
|
-
...clientConfig,
|
|
159
|
-
appData,
|
|
160
|
-
joined: config.joined ?? Date.now(),
|
|
161
|
-
|
|
162
|
-
accept: (...samples: ClientSample[]) => {
|
|
163
|
-
if (closed) {
|
|
164
|
-
throw new Error('Cannot accept ClientSample, because the ClientSource is closed');
|
|
165
|
-
}
|
|
166
|
-
const observedCallBuilder = this._observedCallsBuilder.getOrCreateObservedCallBuilder(callSource.callId, () => {
|
|
167
|
-
return {
|
|
168
|
-
...callSource,
|
|
169
|
-
};
|
|
170
|
-
});
|
|
171
|
-
const observedClientBuilder = observedCallBuilder.getOrCreateObservedClientBuilder(config.clientId, () => {
|
|
172
|
-
return {
|
|
173
|
-
...source,
|
|
174
|
-
};
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
for (const sample of samples) {
|
|
178
|
-
observedClientBuilder.addClientSample(sample);
|
|
179
|
-
}
|
|
180
|
-
this._incrementSamples(samples.length);
|
|
181
|
-
},
|
|
182
|
-
close: () => {
|
|
183
|
-
if (closed) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
closed = true;
|
|
187
|
-
this._emit('removed-client-source', source);
|
|
188
|
-
},
|
|
189
|
-
closed,
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
this._emit('added-client-source', source);
|
|
193
|
-
|
|
194
|
-
return source;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
public createSfuSource<T extends Record<string, unknown> = Record<string, unknown>>(config: PartialBy<ObservedSfuSourceConfig<T>, 'joined'>): ObservedSfuSource {
|
|
198
|
-
const existingSfuSource = this._sfuSources.get(config.sfuId);
|
|
199
|
-
|
|
200
|
-
if (existingSfuSource) {
|
|
201
|
-
return existingSfuSource;
|
|
202
|
-
}
|
|
203
|
-
let closed = false;
|
|
204
|
-
// config.joined = config.joined ?? Date.now();
|
|
205
|
-
const source: ObservedSfuSource = {
|
|
206
|
-
...config,
|
|
207
|
-
joined: config.joined ?? Date.now(),
|
|
208
|
-
|
|
209
|
-
accept: (...samples: SfuSample[]) => {
|
|
210
|
-
if (closed) {
|
|
211
|
-
throw new Error('Cannot accept SfuSample, because the SfuSource is closed');
|
|
212
|
-
}
|
|
213
|
-
const observedSfuBuilder = this._observedSfusBuilder.getOrCreateObservedSfuBuilder(config.sfuId, () => {
|
|
214
|
-
return {
|
|
215
|
-
...source,
|
|
216
|
-
};
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
for (const sample of samples) {
|
|
220
|
-
observedSfuBuilder.addSfuSample(sample);
|
|
221
|
-
}
|
|
222
|
-
this._incrementSamples(samples.length);
|
|
223
|
-
},
|
|
224
|
-
close: () => {
|
|
225
|
-
if (closed) {
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
closed = true;
|
|
229
|
-
this._sfuSources.delete(config.sfuId);
|
|
230
|
-
this._emit('removed-sfu-source', source);
|
|
231
|
-
},
|
|
232
|
-
closed,
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
if (this._sfuSources.size < 1) {
|
|
236
|
-
this._resetTimer();
|
|
237
|
-
}
|
|
238
|
-
this._sfuSources.set(config.sfuId, source);
|
|
239
|
-
this._emit('added-sfu-source', source);
|
|
240
|
-
|
|
241
|
-
return source;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
private _incrementSamples(increment = 1) {
|
|
245
|
-
this._numberOfSamples += increment;
|
|
246
|
-
if (this.config.maxSamples < 1 || this._numberOfSamples < this.config.maxSamples) {
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
this._emitSamples();
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
public emitSamples() {
|
|
253
|
-
if (0 < this.config.maxSamples || 0 < this.config.maxTimeInMs) {
|
|
254
|
-
if (!this._warnFlags.autoEmitButEmitSamplesInvoked) {
|
|
255
|
-
logger.warn(`Emitting Samples is called explicitly,
|
|
256
|
-
but samples are emitted automatically because of configuration
|
|
257
|
-
(maxSamples: ${this.config.maxSamples}, maxTImeInMs: ${this.config.maxTimeInMs})`
|
|
258
|
-
);
|
|
259
|
-
this._warnFlags.autoEmitButEmitSamplesInvoked = true;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
this._emitSamples();
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
private _emitSamples() {
|
|
266
|
-
this._resetTimer();
|
|
267
|
-
const observedCalls = this._observedCallsBuilder.build();
|
|
268
|
-
|
|
269
|
-
this._observedCallsBuilder = new ObservedCallsBuilder();
|
|
270
|
-
const observedSfus = this._observedSfusBuilder.build();
|
|
271
|
-
|
|
272
|
-
this._observedSfusBuilder = new ObservedSfusBuilder();
|
|
273
|
-
this._emit('observed-samples', {
|
|
274
|
-
observedCalls,
|
|
275
|
-
observedSfus,
|
|
276
|
-
numberOfSamples: this._numberOfSamples,
|
|
277
|
-
});
|
|
278
|
-
this._numberOfSamples = 0;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
private _resetTimer() {
|
|
282
|
-
if (this._timer) {
|
|
283
|
-
clearTimeout(this._timer);
|
|
284
|
-
this._timer = undefined;
|
|
285
|
-
}
|
|
286
|
-
if (0 < this.config.maxTimeInMs) {
|
|
287
|
-
this._timer = setTimeout(() => {
|
|
288
|
-
this._timer = undefined;
|
|
289
|
-
this._emitSamples();
|
|
290
|
-
}, this.config.maxTimeInMs);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
public close() {
|
|
295
|
-
[ ...this._callSources.values() ].forEach((callSource) => callSource.close());
|
|
296
|
-
[ ...this._sfuSources.values() ].forEach((sfuSource) => sfuSource.close());
|
|
297
|
-
this._callSources.clear();
|
|
298
|
-
this._sfuSources.clear();
|
|
299
|
-
this._emitSamples();
|
|
300
|
-
}
|
|
301
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|