@observertc/observer-js 0.9.20-beta → 0.9.22-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/.eslintrc.json +143 -0
- package/lib/Evaluator.d.ts.map +1 -1
- package/lib/Evaluator.js +54 -47
- package/lib/Observer.d.ts +1408 -38
- package/lib/Observer.d.ts.map +1 -1
- package/lib/Observer.js +484 -180
- package/lib/common/Semaphore.d.ts.map +1 -1
- package/lib/common/callMetaReports.d.ts.map +1 -1
- package/lib/common/callMetaReports.js +1 -0
- package/lib/common/logger.d.ts.map +1 -1
- package/lib/common/logger.js +15 -15
- package/lib/common/utils.d.ts +1 -0
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +12 -1
- package/lib/entries/CallEntry.d.ts +611 -0
- package/lib/entries/CallEntry.d.ts.map +1 -0
- package/lib/entries/CallEntry.js +75 -0
- package/lib/entries/ClientEntry.d.ts +474 -0
- package/lib/entries/ClientEntry.d.ts.map +1 -0
- package/lib/entries/ClientEntry.js +101 -0
- package/lib/entries/InboundTrackEntry.d.ts +670 -0
- package/lib/entries/InboundTrackEntry.d.ts.map +1 -0
- package/lib/entries/InboundTrackEntry.js +76 -0
- package/lib/entries/OutboundTrackEntry.d.ts +670 -0
- package/lib/entries/OutboundTrackEntry.d.ts.map +1 -0
- package/lib/entries/OutboundTrackEntry.js +73 -0
- package/lib/entries/PeerConnectionEntry.d.ts +469 -0
- package/lib/entries/PeerConnectionEntry.d.ts.map +1 -0
- package/lib/entries/PeerConnectionEntry.js +144 -0
- package/lib/entries/SfuEntry.d.ts +150 -0
- package/lib/entries/SfuEntry.d.ts.map +1 -0
- package/lib/entries/SfuEntry.js +77 -0
- package/lib/entries/SfuInboundRtpPadEntry.d.ts +14 -0
- package/lib/entries/SfuInboundRtpPadEntry.d.ts.map +1 -0
- package/lib/entries/SfuInboundRtpPadEntry.js +49 -0
- package/lib/entries/SfuOutboundRtpPadEntry.d.ts +14 -0
- package/lib/entries/SfuOutboundRtpPadEntry.d.ts.map +1 -0
- package/lib/entries/SfuOutboundRtpPadEntry.js +47 -0
- package/lib/entries/SfuSctpChannelEntry.d.ts +12 -0
- package/lib/entries/SfuSctpChannelEntry.d.ts.map +1 -0
- package/lib/entries/SfuSctpChannelEntry.js +43 -0
- package/lib/entries/SfuTransportEntry.d.ts +82 -0
- package/lib/entries/SfuTransportEntry.d.ts.map +1 -0
- package/lib/entries/SfuTransportEntry.js +122 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/middlewares/CallOperationsContext.d.ts.map +1 -1
- package/lib/middlewares/CallOperationsContext.js +2 -6
- package/lib/middlewares/CallProcessor.d.ts.map +1 -1
- package/lib/middlewares/CallProcessor.js +15 -6
- package/lib/middlewares/CommitTransactionMiddleware.d.ts.map +1 -1
- package/lib/middlewares/CommitTransactionMiddleware.js +22 -26
- package/lib/middlewares/DeleteOutdatedCallEntries.d.ts.map +1 -1
- package/lib/middlewares/DeleteOutdatedCallEntries.js +29 -20
- package/lib/middlewares/DeleteOutdatedSfuEntries.d.ts.map +1 -1
- package/lib/middlewares/DeleteOutdatedSfuEntries.js +27 -18
- package/lib/middlewares/Middleware.d.ts.map +1 -1
- package/lib/middlewares/Middleware.js +13 -4
- package/lib/middlewares/Processor.d.ts.map +1 -1
- package/lib/middlewares/Processor.js +18 -9
- package/lib/middlewares/TransactionContext.d.ts.map +1 -1
- package/lib/middlewares/TransactionContext.js +84 -73
- package/lib/middlewares/VisitObservedCallsMiddleware.d.ts.map +1 -1
- package/lib/middlewares/VisitObservedCallsMiddleware.js +16 -7
- package/lib/middlewares/VisitObservedSfusMiddleware.d.ts.map +1 -1
- package/lib/middlewares/VisitObservedSfusMiddleware.js +15 -6
- package/lib/middlewares/visitors/visitClient.d.ts.map +1 -1
- package/lib/middlewares/visitors/visitClient.js +6 -18
- package/lib/middlewares/visitors/visitInboundAudioTrack.d.ts.map +1 -1
- package/lib/middlewares/visitors/visitInboundAudioTrack.js +17 -20
- package/lib/middlewares/visitors/visitInboundVideoTrack.d.ts.map +1 -1
- package/lib/middlewares/visitors/visitInboundVideoTrack.js +16 -21
- package/lib/middlewares/visitors/visitOutboundAudioTrack.d.ts.map +1 -1
- package/lib/middlewares/visitors/visitOutboundAudioTrack.js +16 -16
- package/lib/middlewares/visitors/visitOutboundVideoTarck.d.ts.map +1 -1
- package/lib/middlewares/visitors/visitOutboundVideoTarck.js +16 -17
- package/lib/middlewares/visitors/visitPeerConnection.d.ts.map +1 -1
- package/lib/middlewares/visitors/visitPeerConnection.js +24 -40
- package/lib/middlewares/visitors/visitSfu.d.ts.map +1 -1
- package/lib/middlewares/visitors/visitSfu.js +6 -7
- package/lib/middlewares/visitors/visitSfuInboundRtpPad.d.ts.map +1 -1
- package/lib/middlewares/visitors/visitSfuInboundRtpPad.js +3 -7
- package/lib/middlewares/visitors/visitSfuOutboundRtpPad.d.ts.map +1 -1
- package/lib/middlewares/visitors/visitSfuOutboundRtpPad.js +3 -8
- package/lib/middlewares/visitors/visitSfuSctpChannel.d.ts.map +1 -1
- package/lib/middlewares/visitors/visitSfuSctpChannel.js +3 -6
- package/lib/middlewares/visitors/visitSfuTransport.d.ts.map +1 -1
- package/lib/middlewares/visitors/visitSfuTransport.js +3 -6
- package/lib/processes/closePeerConnectionProcess.d.ts.map +1 -1
- package/lib/processes/closePeerConnectionProcess.js +14 -5
- package/lib/processes/detachClientProcess.d.ts.map +1 -1
- package/lib/processes/detachClientProcess.js +20 -17
- package/lib/processes/findRemoteMatches.d.ts +2 -2
- package/lib/processes/findRemoteMatches.d.ts.map +1 -1
- package/lib/processes/findRemoteMatches.js +70 -56
- package/lib/processes/inboundTrackRemoved.d.ts.map +1 -1
- package/lib/processes/inboundTrackRemoved.js +12 -3
- package/lib/processes/joinClientProcess.d.ts.map +1 -1
- package/lib/processes/joinClientProcess.js +15 -6
- package/lib/processes/outboundTrackRemoved.d.ts.map +1 -1
- package/lib/processes/outboundTrackRemoved.js +12 -3
- package/lib/samples/ObservedCall.d.ts.map +1 -1
- package/lib/samples/ObservedCall.js +1 -5
- package/lib/samples/ObservedCalls.d.ts.map +1 -1
- package/lib/samples/ObservedClient.d.ts.map +1 -1
- package/lib/samples/ObservedClient.js +1 -9
- package/lib/samples/ObservedInboundAudioTrack.d.ts.map +1 -1
- package/lib/samples/ObservedInboundAudioTrack.js +1 -5
- package/lib/samples/ObservedInboundVideoTrack.d.ts.map +1 -1
- package/lib/samples/ObservedInboundVideoTrack.js +1 -5
- package/lib/samples/ObservedOutboundAudioTrack.d.ts.map +1 -1
- package/lib/samples/ObservedOutboundAudioTrack.js +1 -5
- package/lib/samples/ObservedOutboundVideoTrack.d.ts.map +1 -1
- package/lib/samples/ObservedOutboundVideoTrack.js +1 -5
- package/lib/samples/ObservedPeerConnection.d.ts.map +1 -1
- package/lib/samples/ObservedPeerConnection.js +1 -12
- package/lib/samples/ObservedSfu.d.ts.map +1 -1
- package/lib/samples/ObservedSfu.js +1 -8
- package/lib/samples/ObservedSfuInboundRtpPad.d.ts.map +1 -1
- package/lib/samples/ObservedSfuInboundRtpPad.js +1 -5
- package/lib/samples/ObservedSfuOutboundRtpPad.d.ts.map +1 -1
- package/lib/samples/ObservedSfuOutboundRtpPad.js +1 -5
- package/lib/samples/ObservedSfuSctpChannel.d.ts.map +1 -1
- package/lib/samples/ObservedSfuSctpChannel.js +1 -5
- package/lib/samples/ObservedSfuTransport.d.ts.map +1 -1
- package/lib/samples/ObservedSfuTransport.js +1 -8
- package/lib/samples/ObservedSfus.d.ts.map +1 -1
- package/lib/sinks/ObserverSink.d.ts.map +1 -1
- package/lib/sinks/ObserverSink.js +42 -31
- package/lib/sinks/callEventReports.js +1 -0
- package/lib/sources/ObservedCallSource.d.ts +5 -3
- package/lib/sources/ObservedCallSource.d.ts.map +1 -1
- package/lib/sources/ObservedClientSource.d.ts +3 -2
- package/lib/sources/ObservedClientSource.d.ts.map +1 -1
- package/lib/sources/ObservedSfuSource.d.ts +3 -2
- package/lib/sources/ObservedSfuSource.d.ts.map +1 -1
- package/lib/sources/Sources.d.ts +8 -4
- package/lib/sources/Sources.d.ts.map +1 -1
- package/lib/sources/Sources.js +71 -46
- package/lib/storages/ObserverStorage.d.ts.map +1 -1
- package/lib/storages/SimpleStorage.d.ts.map +1 -1
- package/lib/storages/SimpleStorage.js +40 -23
- package/package.json +2 -1
- package/src/Evaluator.ts +17 -9
- package/src/Observer.ts +239 -171
- package/src/common/Semaphore.ts +2 -0
- package/src/common/callMetaReports.ts +30 -28
- package/src/common/logger.ts +140 -132
- package/src/common/types.ts +1 -1
- package/src/common/utils.ts +12 -1
- package/src/entries/CallEntry.ts +62 -0
- package/src/entries/ClientEntry.ts +90 -0
- package/src/entries/InboundTrackEntry.ts +74 -0
- package/src/entries/OutboundTrackEntry.ts +72 -0
- package/src/entries/PeerConnectionEntry.ts +133 -0
- package/src/entries/SfuEntry.ts +62 -0
- package/src/entries/SfuInboundRtpPadEntry.ts +46 -0
- package/src/entries/SfuOutboundRtpPadEntry.ts +44 -0
- package/src/entries/SfuSctpChannelEntry.ts +39 -0
- package/src/entries/SfuTransportEntry.ts +109 -0
- package/src/index.ts +11 -0
- package/src/middlewares/CallOperationsContext.ts +9 -5
- package/src/middlewares/CallProcessor.ts +4 -2
- package/src/middlewares/CommitTransactionMiddleware.ts +8 -5
- package/src/middlewares/DeleteOutdatedCallEntries.ts +24 -16
- package/src/middlewares/DeleteOutdatedSfuEntries.ts +24 -15
- package/src/middlewares/Middleware.ts +1 -0
- package/src/middlewares/Processor.ts +10 -5
- package/src/middlewares/TransactionContext.ts +1 -2
- package/src/middlewares/VisitObservedCallsMiddleware.ts +5 -2
- package/src/middlewares/VisitObservedSfusMiddleware.ts +8 -7
- package/src/middlewares/visitors/visitClient.ts +15 -1
- package/src/middlewares/visitors/visitInboundAudioTrack.ts +4 -1
- package/src/middlewares/visitors/visitInboundVideoTrack.ts +5 -1
- package/src/middlewares/visitors/visitOutboundAudioTrack.ts +5 -1
- package/src/middlewares/visitors/visitOutboundVideoTarck.ts +5 -1
- package/src/middlewares/visitors/visitPeerConnection.ts +15 -2
- package/src/middlewares/visitors/visitSfu.ts +7 -1
- package/src/middlewares/visitors/visitSfuInboundRtpPad.ts +4 -2
- package/src/middlewares/visitors/visitSfuOutboundRtpPad.ts +3 -1
- package/src/middlewares/visitors/visitSfuSctpChannel.ts +23 -21
- package/src/middlewares/visitors/visitSfuTransport.ts +3 -1
- package/src/processes/closePeerConnectionProcess.ts +3 -0
- package/src/processes/detachClientProcess.ts +13 -4
- package/src/processes/findRemoteMatches.ts +32 -21
- package/src/processes/inboundTrackRemoved.ts +2 -0
- package/src/processes/joinClientProcess.ts +8 -2
- package/src/processes/outboundTrackRemoved.ts +2 -0
- package/src/samples/ObservedCall.ts +6 -0
- package/src/samples/ObservedCalls.ts +13 -7
- package/src/samples/ObservedClient.ts +24 -8
- package/src/samples/ObservedInboundAudioTrack.ts +3 -2
- package/src/samples/ObservedInboundVideoTrack.ts +3 -2
- package/src/samples/ObservedOutboundAudioTrack.ts +3 -2
- package/src/samples/ObservedOutboundVideoTrack.ts +3 -2
- package/src/samples/ObservedPeerConnection.ts +27 -11
- package/src/samples/ObservedSfu.ts +17 -10
- package/src/samples/ObservedSfuInboundRtpPad.ts +5 -4
- package/src/samples/ObservedSfuOutboundRtpPad.ts +5 -4
- package/src/samples/ObservedSfuSctpChannel.ts +13 -13
- package/src/samples/ObservedSfuTransport.ts +19 -7
- package/src/samples/ObservedSfus.ts +10 -5
- package/src/sinks/ObserverSink.ts +51 -44
- package/src/sinks/callEventReports.ts +1 -1
- package/src/sources/ObservedCallSource.ts +6 -5
- package/src/sources/ObservedClientSource.ts +3 -2
- package/src/sources/ObservedSfuSource.ts +4 -8
- package/src/sources/Sources.ts +96 -22
- package/src/storages/ObserverStorage.ts +1 -0
- package/src/storages/SimpleStorage.ts +44 -21
- package/tsconfig.json +7 -5
- package/.eslintrc.js +0 -27
package/src/Observer.ts
CHANGED
|
@@ -1,23 +1,36 @@
|
|
|
1
1
|
import { ObserverReportsEmitter, ObserverSinkProcess, SinkConfig, SinkImpl } from './sinks/ObserverSink';
|
|
2
2
|
import { Sources, SourcesConfig } from './sources/Sources';
|
|
3
3
|
import { createSimpleStorageProvider, StorageProvider } from './storages/StorageProvider';
|
|
4
|
-
import * as Models from './models/Models';
|
|
5
4
|
import { Evaluator, EvaluatorConfig, EvaluatorProcess } from './Evaluator';
|
|
6
5
|
import { createSimpleSemaphoreProvider, SemaphoreProvider } from './common/Semaphore';
|
|
7
6
|
import { ObservedCallSourceConfig, ObservedCallSource } from './sources/ObservedCallSource';
|
|
8
|
-
import {
|
|
9
|
-
import { PartialBy } from './common/utils';
|
|
7
|
+
import { PartialBy, asyncIteratorConverter } from './common/utils';
|
|
10
8
|
import { createLogger, LogLevel } from './common/logger';
|
|
11
9
|
import { ObservedSfuSource, ObservedSfuSourceConfig } from './sources/ObservedSfuSource';
|
|
12
|
-
import EventEmitter from 'events';
|
|
10
|
+
import { EventEmitter } from 'events';
|
|
11
|
+
import { CallEntry, createCallEntry } from './entries/CallEntry';
|
|
12
|
+
import { ClientEntry, createClientEntry } from './entries/ClientEntry';
|
|
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';
|
|
13
21
|
|
|
14
22
|
const logger = createLogger('Observer');
|
|
15
23
|
|
|
16
24
|
export type ObserverEvents = {
|
|
25
|
+
'processing-started': undefined,
|
|
26
|
+
'client-added': string,
|
|
27
|
+
'client-removed': string,
|
|
28
|
+
'processing-ended': undefined,
|
|
17
29
|
'close': undefined,
|
|
18
30
|
}
|
|
19
31
|
|
|
20
32
|
export type ObserverConfig = {
|
|
33
|
+
|
|
21
34
|
/**
|
|
22
35
|
*
|
|
23
36
|
* Sets the default serviceId for samples.
|
|
@@ -67,8 +80,8 @@ export class Observer {
|
|
|
67
80
|
);
|
|
68
81
|
|
|
69
82
|
const semaphores = providedConfig.semaphores ?? createSimpleSemaphoreProvider();
|
|
70
|
-
|
|
71
83
|
const storages = providedConfig.storages ?? createSimpleStorageProvider();
|
|
84
|
+
|
|
72
85
|
return new Observer(config, storages, semaphores);
|
|
73
86
|
}
|
|
74
87
|
|
|
@@ -84,110 +97,93 @@ export class Observer {
|
|
|
84
97
|
) {
|
|
85
98
|
this._sources = new Sources(config.sources);
|
|
86
99
|
this._sink = new SinkImpl(config.sink);
|
|
87
|
-
this._evaluator = new Evaluator(
|
|
100
|
+
this._evaluator = new Evaluator(
|
|
101
|
+
this.config.evaluator,
|
|
102
|
+
this._semaphores.callSemaphore,
|
|
103
|
+
this._storages,
|
|
104
|
+
this._sink
|
|
105
|
+
);
|
|
88
106
|
|
|
89
107
|
this._sources.on('observed-samples', (event) => {
|
|
108
|
+
this._emitter.emit('processing-started');
|
|
90
109
|
this._evaluator.addObservedSamples(event);
|
|
91
110
|
});
|
|
92
111
|
this._sources.on('added-client-source', (event) => {
|
|
93
112
|
this._evaluator.addCreatedClientSource(event);
|
|
113
|
+
this._emitter.emit('client-added', event.clientId);
|
|
94
114
|
});
|
|
95
115
|
this._sources.on('removed-client-source', (event) => {
|
|
96
116
|
this._evaluator.addClosedClientSource(event);
|
|
117
|
+
this._emitter.emit('client-added', event.clientId);
|
|
97
118
|
});
|
|
98
119
|
this._evaluator.on('ready', () => {
|
|
99
120
|
this._sink.emit();
|
|
121
|
+
this._emitter.emit('processing-ended');
|
|
100
122
|
});
|
|
101
|
-
logger.debug(
|
|
123
|
+
logger.debug('Observer is created with config', this.config);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
public get sources(): Sources {
|
|
127
|
+
return this._sources;
|
|
102
128
|
}
|
|
103
129
|
|
|
104
130
|
public on<K extends keyof ObserverEvents>(event: K, listener: (arg: ObserverEvents[K]) => void): this {
|
|
105
131
|
this._emitter.on(event, listener);
|
|
132
|
+
|
|
106
133
|
return this;
|
|
107
134
|
}
|
|
108
135
|
|
|
109
136
|
public once<K extends keyof ObserverEvents>(event: K, listener: (arg: ObserverEvents[K]) => void): this {
|
|
110
137
|
this._emitter.once(event, listener);
|
|
138
|
+
|
|
111
139
|
return this;
|
|
112
140
|
}
|
|
113
141
|
|
|
114
142
|
public off<K extends keyof ObserverEvents>(event: K, listener: (arg: ObserverEvents[K]) => void): this {
|
|
115
143
|
this._emitter.off(event, listener);
|
|
144
|
+
|
|
116
145
|
return this;
|
|
117
146
|
}
|
|
118
147
|
|
|
119
|
-
public createCallSource(
|
|
120
|
-
config: PartialBy<ObservedCallSourceConfig
|
|
121
|
-
): ObservedCallSource {
|
|
148
|
+
public createCallSource<T extends Record<string, unknown> = Record<string, unknown>>(
|
|
149
|
+
config: PartialBy<ObservedCallSourceConfig<T>, 'serviceId' | 'mediaUnitId' | 'appData'>
|
|
150
|
+
): ObservedCallSource<T> {
|
|
122
151
|
if (this._closed) {
|
|
123
|
-
throw new Error(
|
|
152
|
+
throw new Error('Attempted to create a call source on a closed observer');
|
|
124
153
|
}
|
|
125
|
-
let closed = false;
|
|
126
|
-
const serviceId = config.serviceId ?? this.config.defaultServiceId;
|
|
127
|
-
const mediaUnitId = config.mediaUnitId ?? this.config.defaultMediaUnitId;
|
|
128
|
-
const clientSources = new Map<string, ObservedClientSource>();
|
|
129
|
-
const callSource: ObservedCallSource = {
|
|
130
|
-
...config,
|
|
131
|
-
serviceId,
|
|
132
|
-
mediaUnitId,
|
|
133
|
-
createClientSource: (context) => {
|
|
134
|
-
const clientSource = this._sources.createClientSource({
|
|
135
|
-
...config,
|
|
136
|
-
...context,
|
|
137
|
-
serviceId,
|
|
138
|
-
mediaUnitId,
|
|
139
|
-
});
|
|
140
|
-
const closeClientSource = clientSource.close;
|
|
141
|
-
clientSource.close = () => {
|
|
142
|
-
closeClientSource();
|
|
143
|
-
clientSources.delete(context.clientId);
|
|
144
|
-
};
|
|
145
|
-
clientSources.set(context.clientId, clientSource);
|
|
146
|
-
return clientSource;
|
|
147
|
-
},
|
|
148
|
-
close: () => {
|
|
149
|
-
if (closed) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
for (const clientSource of clientSources.values()) {
|
|
153
|
-
clientSource.close();
|
|
154
|
-
}
|
|
155
|
-
clientSources.clear();
|
|
156
|
-
closed = true;
|
|
157
|
-
},
|
|
158
|
-
closed,
|
|
159
|
-
};
|
|
160
|
-
return callSource;
|
|
161
|
-
}
|
|
162
154
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
...config,
|
|
174
|
-
serviceId,
|
|
155
|
+
const {
|
|
156
|
+
serviceId = this.config.defaultServiceId,
|
|
157
|
+
mediaUnitId = this.config.defaultMediaUnitId,
|
|
158
|
+
appData = {} as T,
|
|
159
|
+
...callConfig
|
|
160
|
+
} = config;
|
|
161
|
+
|
|
162
|
+
return this._sources.createCallSource({
|
|
163
|
+
...callConfig,
|
|
164
|
+
appData,
|
|
175
165
|
mediaUnitId,
|
|
176
|
-
|
|
166
|
+
serviceId,
|
|
177
167
|
});
|
|
178
168
|
}
|
|
179
169
|
|
|
180
|
-
public createSfuSource(
|
|
181
|
-
config: PartialBy<ObservedSfuSourceConfig
|
|
170
|
+
public createSfuSource<T extends Record<string, unknown> = Record<string, unknown>>(
|
|
171
|
+
config: PartialBy<ObservedSfuSourceConfig<T>, 'serviceId' | 'mediaUnitId' | 'joined' | 'appData'>
|
|
182
172
|
): ObservedSfuSource {
|
|
183
173
|
if (this._closed) {
|
|
184
|
-
throw new Error(
|
|
174
|
+
throw new Error('Attempted to create a sfu source on a closed observer');
|
|
185
175
|
}
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
176
|
+
const {
|
|
177
|
+
appData = {} as T,
|
|
178
|
+
serviceId = this.config.defaultServiceId,
|
|
179
|
+
mediaUnitId = this.config.defaultMediaUnitId,
|
|
180
|
+
joined = Date.now(),
|
|
181
|
+
...sfuConfig
|
|
182
|
+
} = config;
|
|
183
|
+
|
|
184
|
+
return this._sources.createSfuSource<T>({
|
|
185
|
+
...sfuConfig,
|
|
186
|
+
appData,
|
|
191
187
|
serviceId,
|
|
192
188
|
mediaUnitId,
|
|
193
189
|
joined,
|
|
@@ -196,7 +192,7 @@ export class Observer {
|
|
|
196
192
|
|
|
197
193
|
public async evaluate() {
|
|
198
194
|
return new Promise<void>((resolve, reject) => {
|
|
199
|
-
this._evaluator.once('ready', err => {
|
|
195
|
+
this._evaluator.once('ready', (err) => {
|
|
200
196
|
if (err) reject(err);
|
|
201
197
|
else resolve();
|
|
202
198
|
});
|
|
@@ -210,7 +206,7 @@ export class Observer {
|
|
|
210
206
|
|
|
211
207
|
public addEvaluators(...processes: EvaluatorProcess[]) {
|
|
212
208
|
if (this._closed) {
|
|
213
|
-
throw new Error(
|
|
209
|
+
throw new Error('Attempted to add an evaluator to a closed observer');
|
|
214
210
|
}
|
|
215
211
|
for (const process of processes) {
|
|
216
212
|
this._evaluator.addProcess(process);
|
|
@@ -219,7 +215,7 @@ export class Observer {
|
|
|
219
215
|
|
|
220
216
|
public removeEvaluators(...processes: EvaluatorProcess[]) {
|
|
221
217
|
if (this._closed) {
|
|
222
|
-
throw new Error(
|
|
218
|
+
throw new Error('Attempted to remove an evaluator from a closed observer');
|
|
223
219
|
}
|
|
224
220
|
for (const process of processes) {
|
|
225
221
|
this._evaluator.removeProcess(process);
|
|
@@ -228,7 +224,7 @@ export class Observer {
|
|
|
228
224
|
|
|
229
225
|
public addSinks(...processes: ObserverSinkProcess[]) {
|
|
230
226
|
if (this._closed) {
|
|
231
|
-
throw new Error(
|
|
227
|
+
throw new Error('Attempted to add an evaluator to a closed observer');
|
|
232
228
|
}
|
|
233
229
|
for (const process of processes) {
|
|
234
230
|
this._sink.addProcess(process);
|
|
@@ -237,194 +233,267 @@ export class Observer {
|
|
|
237
233
|
|
|
238
234
|
public removeSinks(...processes: ObserverSinkProcess[]) {
|
|
239
235
|
if (this._closed) {
|
|
240
|
-
throw new Error(
|
|
236
|
+
throw new Error('Attempted to remove an evaluator from a closed observer');
|
|
241
237
|
}
|
|
242
238
|
for (const process of processes) {
|
|
243
239
|
this._sink.removeProcess(process);
|
|
244
240
|
}
|
|
245
241
|
}
|
|
246
242
|
|
|
247
|
-
public calls(): AsyncIterableIterator<
|
|
248
|
-
const
|
|
249
|
-
|
|
243
|
+
public calls(): AsyncIterableIterator<CallEntry> {
|
|
244
|
+
const storageProvider = this._storages;
|
|
245
|
+
|
|
246
|
+
return asyncIteratorConverter((async function *() {
|
|
247
|
+
for await (const [ , callModel ] of storageProvider.callStorage[Symbol.asyncIterator]()) {
|
|
248
|
+
if (!callModel) continue;
|
|
249
|
+
yield createCallEntry(storageProvider, callModel);
|
|
250
|
+
}
|
|
251
|
+
})());
|
|
250
252
|
}
|
|
251
253
|
|
|
252
|
-
public sfus(): AsyncIterableIterator<
|
|
253
|
-
const
|
|
254
|
-
|
|
254
|
+
public sfus(): AsyncIterableIterator<SfuEntry> {
|
|
255
|
+
const storageProvider = this._storages;
|
|
256
|
+
|
|
257
|
+
return asyncIteratorConverter((async function *() {
|
|
258
|
+
for await (const [ , sfuModel ] of storageProvider.sfuStorage[Symbol.asyncIterator]()) {
|
|
259
|
+
if (!sfuModel) continue;
|
|
260
|
+
yield createSfuEntry(storageProvider, sfuModel);
|
|
261
|
+
}
|
|
262
|
+
})());
|
|
255
263
|
}
|
|
256
264
|
|
|
257
|
-
public sfuTransports(): AsyncIterableIterator<
|
|
258
|
-
const
|
|
259
|
-
|
|
265
|
+
public sfuTransports(): AsyncIterableIterator<SfuTransportEntry> {
|
|
266
|
+
const storageProvider = this._storages;
|
|
267
|
+
|
|
268
|
+
return asyncIteratorConverter((async function *() {
|
|
269
|
+
for await (const [ , sfuTransportModel ] of storageProvider.sfuTransportStorage[Symbol.asyncIterator]()) {
|
|
270
|
+
if (!sfuTransportModel) continue;
|
|
271
|
+
yield createSfuTransportEntry(storageProvider, sfuTransportModel);
|
|
272
|
+
}
|
|
273
|
+
})());
|
|
260
274
|
}
|
|
261
275
|
|
|
262
|
-
public sfuInboundRtpPads(): AsyncIterableIterator<
|
|
263
|
-
const
|
|
264
|
-
|
|
276
|
+
public sfuInboundRtpPads(): AsyncIterableIterator<SfuInboundRtpPadEntry> {
|
|
277
|
+
const storageProvider = this._storages;
|
|
278
|
+
|
|
279
|
+
return asyncIteratorConverter((async function *() {
|
|
280
|
+
for await (const [ , sfuInboundRtpPadModel ] of storageProvider.sfuInboundRtpPadStorage[Symbol.asyncIterator]()) {
|
|
281
|
+
if (!sfuInboundRtpPadModel) continue;
|
|
282
|
+
yield createSfuInboundRtpPadEntry(storageProvider, sfuInboundRtpPadModel);
|
|
283
|
+
}
|
|
284
|
+
})());
|
|
265
285
|
}
|
|
266
286
|
|
|
267
|
-
public sfuOutboundRtpPads(): AsyncIterableIterator<
|
|
268
|
-
const
|
|
269
|
-
|
|
287
|
+
public sfuOutboundRtpPads(): AsyncIterableIterator<SfuOutboundRtpPadEntry> {
|
|
288
|
+
const storageProvider = this._storages;
|
|
289
|
+
|
|
290
|
+
return asyncIteratorConverter((async function *() {
|
|
291
|
+
for await (const [ , sfuOutboundRtpPadModel ] of storageProvider.sfuOutboundRtpPadStorage[Symbol.asyncIterator]()) {
|
|
292
|
+
if (!sfuOutboundRtpPadModel) continue;
|
|
293
|
+
yield createSfuOutboundRtpPadEntry(storageProvider, sfuOutboundRtpPadModel);
|
|
294
|
+
}
|
|
295
|
+
})());
|
|
270
296
|
}
|
|
271
297
|
|
|
272
|
-
public clients(): AsyncIterableIterator<
|
|
273
|
-
const
|
|
274
|
-
|
|
298
|
+
public clients(): AsyncIterableIterator<ClientEntry> {
|
|
299
|
+
const storageProvider = this._storages;
|
|
300
|
+
|
|
301
|
+
return asyncIteratorConverter((async function *() {
|
|
302
|
+
for await (const [ , callModel ] of storageProvider.clientStorage[Symbol.asyncIterator]()) {
|
|
303
|
+
if (!callModel) continue;
|
|
304
|
+
yield createClientEntry(storageProvider, callModel);
|
|
305
|
+
}
|
|
306
|
+
})());
|
|
275
307
|
}
|
|
276
308
|
|
|
277
|
-
public peerConnections(): AsyncIterableIterator<
|
|
278
|
-
const
|
|
279
|
-
|
|
309
|
+
public peerConnections(): AsyncIterableIterator<PeerConnectionEntry> {
|
|
310
|
+
const storageProvider = this._storages;
|
|
311
|
+
|
|
312
|
+
return asyncIteratorConverter((async function *() {
|
|
313
|
+
for await (const [ , peerConnectionModel ] of storageProvider.peerConnectionStorage[Symbol.asyncIterator]()) {
|
|
314
|
+
if (!peerConnectionModel) continue;
|
|
315
|
+
yield createPeerConnectionEntry(storageProvider, peerConnectionModel);
|
|
316
|
+
}
|
|
317
|
+
})());
|
|
280
318
|
}
|
|
281
319
|
|
|
282
320
|
public async getTrack(trackId: string) {
|
|
283
321
|
const { inboundTrackStorage, outboundTrackStorage } = this._storages;
|
|
284
|
-
const [
|
|
322
|
+
const [ inbTrackModel, outbTrackModel ] = await Promise.all([
|
|
285
323
|
inboundTrackStorage.get(trackId),
|
|
286
324
|
outboundTrackStorage.get(trackId),
|
|
287
325
|
]);
|
|
288
|
-
|
|
289
|
-
|
|
326
|
+
|
|
327
|
+
if (inbTrackModel) return createInboundTrackEntry(this._storages, inbTrackModel);
|
|
328
|
+
else if (outbTrackModel) return createOutboundTrackEntry(this._storages, outbTrackModel);
|
|
290
329
|
}
|
|
291
330
|
|
|
292
331
|
public async getAllTracks(trackIds: Iterable<string>) {
|
|
332
|
+
const storageProvider = this._storages;
|
|
293
333
|
const { inboundTrackStorage, outboundTrackStorage } = this._storages;
|
|
294
|
-
|
|
334
|
+
|
|
335
|
+
const [ inbTrackModels, outbTrackModels ] = await Promise.all([
|
|
295
336
|
inboundTrackStorage.getAll(trackIds),
|
|
296
337
|
outboundTrackStorage.getAll(trackIds),
|
|
297
338
|
]);
|
|
298
|
-
|
|
339
|
+
|
|
340
|
+
const result = new Map<string, InboundTrackEntry | OutboundTrackEntry>();
|
|
341
|
+
|
|
342
|
+
for (const [ trackId, model ] of inbTrackModels) {
|
|
343
|
+
result.set(trackId, createInboundTrackEntry(storageProvider, model));
|
|
344
|
+
}
|
|
345
|
+
for (const [ trackId, model ] of outbTrackModels) {
|
|
346
|
+
result.set(trackId, createOutboundTrackEntry(storageProvider, model));
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
return result;
|
|
299
350
|
}
|
|
300
351
|
|
|
301
|
-
public inboundTracks(): AsyncIterableIterator<
|
|
302
|
-
const
|
|
303
|
-
|
|
352
|
+
public inboundTracks(): AsyncIterableIterator<InboundTrackEntry> {
|
|
353
|
+
const storageProvider = this._storages;
|
|
354
|
+
|
|
355
|
+
return asyncIteratorConverter((async function *() {
|
|
356
|
+
for await (const [ , inboundTrackModel ] of storageProvider.inboundTrackStorage[Symbol.asyncIterator]()) {
|
|
357
|
+
if (!inboundTrackModel) continue;
|
|
358
|
+
yield createInboundTrackEntry(storageProvider, inboundTrackModel);
|
|
359
|
+
}
|
|
360
|
+
})());
|
|
304
361
|
}
|
|
305
362
|
|
|
306
|
-
public outboundTracks(): AsyncIterableIterator<
|
|
307
|
-
const
|
|
308
|
-
|
|
363
|
+
public outboundTracks(): AsyncIterableIterator<OutboundTrackEntry> {
|
|
364
|
+
const storageProvider = this._storages;
|
|
365
|
+
|
|
366
|
+
return asyncIteratorConverter((async function *() {
|
|
367
|
+
for await (const [ , outboundTrackModel ] of storageProvider.outboundTrackStorage[Symbol.asyncIterator]()) {
|
|
368
|
+
if (!outboundTrackModel) continue;
|
|
369
|
+
yield createOutboundTrackEntry(storageProvider, outboundTrackModel);
|
|
370
|
+
}
|
|
371
|
+
})());
|
|
309
372
|
}
|
|
310
373
|
|
|
311
|
-
public sfuSctpChannels(): AsyncIterableIterator<
|
|
312
|
-
const
|
|
313
|
-
|
|
374
|
+
public sfuSctpChannels(): AsyncIterableIterator<SfuSctpChannelEntry> {
|
|
375
|
+
const storageProvider = this._storages;
|
|
376
|
+
|
|
377
|
+
return asyncIteratorConverter((async function *() {
|
|
378
|
+
for await (const [ , sfuSctpChannelModel ] of storageProvider.sfuSctpChannelStorage[Symbol.asyncIterator]()) {
|
|
379
|
+
if (!sfuSctpChannelModel) continue;
|
|
380
|
+
yield createSfuSctpChannelEntry(storageProvider, sfuSctpChannelModel);
|
|
381
|
+
}
|
|
382
|
+
})());
|
|
314
383
|
}
|
|
315
384
|
|
|
316
|
-
public async getCall(callId: string): Promise<
|
|
317
|
-
|
|
318
|
-
return callStorage.get(callId);
|
|
385
|
+
public async getCall(callId: string): Promise<CallEntry> {
|
|
386
|
+
return createCallEntry(this._storages, await this._storages.callStorage.get(callId));
|
|
319
387
|
}
|
|
320
388
|
|
|
321
|
-
public async getAllCalls(callIds: Iterable<string>): Promise<ReadonlyMap<string,
|
|
322
|
-
const
|
|
323
|
-
|
|
389
|
+
public async getAllCalls(callIds: Iterable<string>): Promise<ReadonlyMap<string, CallEntry>> {
|
|
390
|
+
const models = await this._storages.callStorage.getAll(callIds);
|
|
391
|
+
|
|
392
|
+
return new Map(Array.from(models).map(([ callId, model ]) => [ callId, createCallEntry(this._storages, model) ]));
|
|
324
393
|
}
|
|
325
394
|
|
|
326
|
-
public async getSfu(sfuId: string): Promise<
|
|
327
|
-
|
|
328
|
-
return sfuStorage.get(sfuId);
|
|
395
|
+
public async getSfu(sfuId: string): Promise<SfuEntry> {
|
|
396
|
+
return createSfuEntry(this._storages, await this._storages.sfuStorage.get(sfuId));
|
|
329
397
|
}
|
|
330
398
|
|
|
331
|
-
public async getAllSfus(sfuIds: Iterable<string>): Promise<ReadonlyMap<string,
|
|
332
|
-
const
|
|
333
|
-
|
|
399
|
+
public async getAllSfus(sfuIds: Iterable<string>): Promise<ReadonlyMap<string, SfuEntry>> {
|
|
400
|
+
const models = await this._storages.sfuStorage.getAll(sfuIds);
|
|
401
|
+
|
|
402
|
+
return new Map(Array.from(models).map(([ sfuId, model ]) => [ sfuId, createSfuEntry(this._storages, model) ]));
|
|
334
403
|
}
|
|
335
404
|
|
|
336
|
-
public async getSfuTransport(sfuTransportId: string): Promise<
|
|
337
|
-
|
|
338
|
-
return sfuTransportStorage.get(sfuTransportId);
|
|
405
|
+
public async getSfuTransport(sfuTransportId: string): Promise<SfuTransportEntry | undefined> {
|
|
406
|
+
return createSfuTransportEntry(this._storages, await this._storages.sfuTransportStorage.get(sfuTransportId));
|
|
339
407
|
}
|
|
340
408
|
|
|
341
409
|
public async getAllSfuTransports(
|
|
342
410
|
sfuTransportIds: Iterable<string>
|
|
343
|
-
): Promise<ReadonlyMap<string,
|
|
344
|
-
const
|
|
345
|
-
|
|
411
|
+
): Promise<ReadonlyMap<string, SfuTransportEntry>> {
|
|
412
|
+
const models = await this._storages.sfuTransportStorage.getAll(sfuTransportIds);
|
|
413
|
+
|
|
414
|
+
return new Map(Array.from(models).map(([ sfuTransportId, model ]) => [ sfuTransportId, createSfuTransportEntry(this._storages, model) ]));
|
|
346
415
|
}
|
|
347
416
|
|
|
348
|
-
public async getSfuInboundRtpPad(sfuInboundRtpPadId: string): Promise<
|
|
349
|
-
|
|
350
|
-
return sfuInboundRtpPadStorage.get(sfuInboundRtpPadId);
|
|
417
|
+
public async getSfuInboundRtpPad(sfuInboundRtpPadId: string): Promise<SfuInboundRtpPadEntry | undefined> {
|
|
418
|
+
return createSfuInboundRtpPadEntry(this._storages, await this._storages.sfuInboundRtpPadStorage.get(sfuInboundRtpPadId));
|
|
351
419
|
}
|
|
352
420
|
|
|
353
421
|
public async getAllSfuInboundRtpPads(
|
|
354
422
|
sfuInboundRtpPadIds: Iterable<string>
|
|
355
|
-
): Promise<ReadonlyMap<string,
|
|
356
|
-
const
|
|
357
|
-
|
|
423
|
+
): Promise<ReadonlyMap<string, SfuInboundRtpPadEntry>> {
|
|
424
|
+
const models = await this._storages.sfuInboundRtpPadStorage.getAll(sfuInboundRtpPadIds);
|
|
425
|
+
|
|
426
|
+
return new Map(Array.from(models).map(([ sfuInboundRtpPadId, model ]) => [ sfuInboundRtpPadId, createSfuInboundRtpPadEntry(this._storages, model) ]));
|
|
358
427
|
}
|
|
359
428
|
|
|
360
|
-
public async getSfuOutboundRtpPad(sfuOutboundRtpPadId: string): Promise<
|
|
361
|
-
|
|
362
|
-
return sfuOutboundRtpPadStorage.get(sfuOutboundRtpPadId);
|
|
429
|
+
public async getSfuOutboundRtpPad(sfuOutboundRtpPadId: string): Promise<SfuOutboundRtpPadEntry | undefined> {
|
|
430
|
+
return createSfuOutboundRtpPadEntry(this._storages, await this._storages.sfuOutboundRtpPadStorage.get(sfuOutboundRtpPadId));
|
|
363
431
|
}
|
|
364
432
|
|
|
365
433
|
public async getAllSfuOutboundRtpPads(
|
|
366
434
|
sfuOutboundRtpPadIds: Iterable<string>
|
|
367
|
-
): Promise<ReadonlyMap<string,
|
|
368
|
-
const
|
|
369
|
-
|
|
435
|
+
): Promise<ReadonlyMap<string, SfuOutboundRtpPadEntry>> {
|
|
436
|
+
const models = await this._storages.sfuOutboundRtpPadStorage.getAll(sfuOutboundRtpPadIds);
|
|
437
|
+
|
|
438
|
+
return new Map(Array.from(models).map(([ sfuOutboundRtpPadId, model ]) => [ sfuOutboundRtpPadId, createSfuOutboundRtpPadEntry(this._storages, model) ]));
|
|
370
439
|
}
|
|
371
440
|
|
|
372
|
-
public async getClient(clientId: string): Promise<
|
|
373
|
-
|
|
374
|
-
return clientStorage.get(clientId);
|
|
441
|
+
public async getClient(clientId: string): Promise<ClientEntry> {
|
|
442
|
+
return createClientEntry(this._storages, await this._storages.clientStorage.get(clientId));
|
|
375
443
|
}
|
|
376
444
|
|
|
377
|
-
public async getAllClient(clientIds: Iterable<string>): Promise<ReadonlyMap<string,
|
|
378
|
-
const
|
|
379
|
-
|
|
445
|
+
public async getAllClient(clientIds: Iterable<string>): Promise<ReadonlyMap<string, ClientEntry>> {
|
|
446
|
+
const models = await this._storages.clientStorage.getAll(clientIds);
|
|
447
|
+
|
|
448
|
+
return new Map(Array.from(models).map(([ clientId, model ]) => [ clientId, createClientEntry(this._storages, model) ]));
|
|
380
449
|
}
|
|
381
450
|
|
|
382
|
-
public async getPeerConnection(peerConnectionId: string): Promise<
|
|
383
|
-
|
|
384
|
-
return peerConnectionStorage.get(peerConnectionId);
|
|
451
|
+
public async getPeerConnection(peerConnectionId: string): Promise<PeerConnectionEntry> {
|
|
452
|
+
return createPeerConnectionEntry(this._storages, await this._storages.peerConnectionStorage.get(peerConnectionId));
|
|
385
453
|
}
|
|
386
454
|
|
|
387
455
|
public async getAllPeerConnections(
|
|
388
456
|
peerConnectionIds: Iterable<string>
|
|
389
|
-
): Promise<ReadonlyMap<string,
|
|
390
|
-
const
|
|
391
|
-
|
|
457
|
+
): Promise<ReadonlyMap<string, PeerConnectionEntry>> {
|
|
458
|
+
const models = await this._storages.peerConnectionStorage.getAll(peerConnectionIds);
|
|
459
|
+
|
|
460
|
+
return new Map(Array.from(models).map(([ peerConnectionId, model ]) => [ peerConnectionId, createPeerConnectionEntry(this._storages, model) ]));
|
|
392
461
|
}
|
|
393
462
|
|
|
394
|
-
public async getInboundTrack(inboundTrackId: string): Promise<
|
|
395
|
-
|
|
396
|
-
return inboundTrackStorage.get(inboundTrackId);
|
|
463
|
+
public async getInboundTrack(inboundTrackId: string): Promise<InboundTrackEntry> {
|
|
464
|
+
return createInboundTrackEntry(this._storages, await this._storages.inboundTrackStorage.get(inboundTrackId));
|
|
397
465
|
}
|
|
398
466
|
|
|
399
467
|
public async getAllInboundTracks(
|
|
400
468
|
inboundTrackIds: Iterable<string>
|
|
401
|
-
): Promise<ReadonlyMap<string,
|
|
402
|
-
const
|
|
403
|
-
|
|
469
|
+
): Promise<ReadonlyMap<string, InboundTrackEntry>> {
|
|
470
|
+
const models = await this._storages.inboundTrackStorage.getAll(inboundTrackIds);
|
|
471
|
+
|
|
472
|
+
return new Map(Array.from(models).map(([ inboundTrackId, model ]) => [ inboundTrackId, createInboundTrackEntry(this._storages, model) ]));
|
|
404
473
|
}
|
|
405
474
|
|
|
406
|
-
public async getOutboundTrack(outboundTrackId: string): Promise<
|
|
407
|
-
|
|
408
|
-
return outboundTrackStorage.get(outboundTrackId);
|
|
475
|
+
public async getOutboundTrack(outboundTrackId: string): Promise<OutboundTrackEntry> {
|
|
476
|
+
return createOutboundTrackEntry(this._storages, await this._storages.outboundTrackStorage.get(outboundTrackId));
|
|
409
477
|
}
|
|
410
478
|
|
|
411
479
|
public async getAllOutboundTracks(
|
|
412
480
|
outboundTrackIds: Iterable<string>
|
|
413
|
-
): Promise<ReadonlyMap<string,
|
|
414
|
-
const
|
|
415
|
-
|
|
481
|
+
): Promise<ReadonlyMap<string, OutboundTrackEntry>> {
|
|
482
|
+
const models = await this._storages.outboundTrackStorage.getAll(outboundTrackIds);
|
|
483
|
+
|
|
484
|
+
return new Map(Array.from(models).map(([ outboundTrackId, model ]) => [ outboundTrackId, createOutboundTrackEntry(this._storages, model) ]));
|
|
416
485
|
}
|
|
417
486
|
|
|
418
|
-
public async getSfuSctpChannel(sctpChannelId: string): Promise<
|
|
419
|
-
|
|
420
|
-
return sfuSctpChannelStorage.get(sctpChannelId);
|
|
487
|
+
public async getSfuSctpChannel(sctpChannelId: string): Promise<SfuSctpChannelEntry | undefined> {
|
|
488
|
+
return createSfuSctpChannelEntry(this._storages, await this._storages.sfuSctpChannelStorage.get(sctpChannelId));
|
|
421
489
|
}
|
|
422
490
|
|
|
423
491
|
public async getAllSfuSctpChannel(
|
|
424
492
|
sctpChannelIds: Iterable<string>
|
|
425
|
-
): Promise<ReadonlyMap<string,
|
|
426
|
-
const
|
|
427
|
-
|
|
493
|
+
): Promise<ReadonlyMap<string, SfuSctpChannelEntry>> {
|
|
494
|
+
const models = await this._storages.sfuSctpChannelStorage.getAll(sctpChannelIds);
|
|
495
|
+
|
|
496
|
+
return new Map(Array.from(models).map(([ sctpChannelId, model ]) => [ sctpChannelId, createSfuSctpChannelEntry(this._storages, model) ]));
|
|
428
497
|
}
|
|
429
498
|
|
|
430
499
|
public get closed() {
|
|
@@ -433,8 +502,7 @@ export class Observer {
|
|
|
433
502
|
|
|
434
503
|
public close() {
|
|
435
504
|
if (this._closed) {
|
|
436
|
-
logger.debug(
|
|
437
|
-
return;
|
|
505
|
+
return logger.debug('Attempted to close twice');
|
|
438
506
|
}
|
|
439
507
|
this._closed = true;
|
|
440
508
|
this._sources.close();
|
package/src/common/Semaphore.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Semaphores are used to ensure that only one process can access the shared resource at a time.
|
|
4
4
|
*/
|
|
5
5
|
export interface Semaphore {
|
|
6
|
+
|
|
6
7
|
/**
|
|
7
8
|
* Acquires the semaphore, blocking until the semaphore is available.
|
|
8
9
|
* When the semaphore is acquired, it prevents other processes from acquiring it.
|
|
@@ -29,6 +30,7 @@ export function createDummySemaphore(): Semaphore {
|
|
|
29
30
|
* SemaphoreProviders are used to manage access to shared resources across multiple processes.
|
|
30
31
|
*/
|
|
31
32
|
export interface SemaphoreProvider {
|
|
33
|
+
|
|
32
34
|
/**
|
|
33
35
|
* A Semaphore instance that manages access to the 'call' shared resource.
|
|
34
36
|
* This semaphore ensures that only one process can access the 'call' resource at a time.
|