@observertc/observer-js 0.30.6-beta → 0.40.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 +6 -13
- package/lib/ObservedCall.d.ts.map +1 -1
- package/lib/ObservedCall.js +24 -104
- package/lib/ObservedClient.d.ts +16 -27
- package/lib/ObservedClient.d.ts.map +1 -1
- package/lib/ObservedClient.js +360 -523
- package/lib/ObservedInboundTrack.d.ts +3 -8
- package/lib/ObservedInboundTrack.d.ts.map +1 -1
- package/lib/ObservedInboundTrack.js +74 -154
- package/lib/ObservedOutboundTrack.d.ts +9 -8
- package/lib/ObservedOutboundTrack.d.ts.map +1 -1
- package/lib/ObservedOutboundTrack.js +76 -130
- package/lib/ObservedPeerConnection.d.ts +17 -15
- package/lib/ObservedPeerConnection.d.ts.map +1 -1
- package/lib/ObservedPeerConnection.js +64 -173
- package/lib/ObservedSfu.d.ts +5 -7
- package/lib/ObservedSfu.d.ts.map +1 -1
- package/lib/ObservedSfu.js +10 -74
- package/lib/Observer.d.ts +5 -6
- package/lib/Observer.d.ts.map +1 -1
- package/lib/Observer.js +28 -31
- package/lib/common/types.d.ts +0 -55
- package/lib/common/types.d.ts.map +1 -1
- package/lib/index.d.ts +5 -7
- package/lib/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ObservedCall.ts +27 -87
- package/src/ObservedClient.ts +425 -582
- package/src/ObservedInboundTrack.ts +14 -65
- package/src/ObservedOutboundTrack.ts +32 -53
- package/src/ObservedPeerConnection.ts +55 -117
- package/src/ObservedSfu.ts +11 -46
- package/src/Observer.ts +11 -16
- package/src/common/types.ts +0 -69
- package/src/index.ts +5 -7
- package/lib/models/Models.d.ts +0 -642
- package/lib/models/Models.d.ts.map +0 -1
- package/lib/models/Models.js +0 -481
- package/lib/models/samples_pb.d.ts +0 -2452
- package/lib/models/samples_pb.d.ts.map +0 -1
- package/lib/models/samples_pb.js +0 -1495
- package/lib/storages/ObserverStorage.d.ts +0 -87
- package/lib/storages/ObserverStorage.d.ts.map +0 -1
- package/lib/storages/ObserverStorage.js +0 -2
- package/lib/storages/SimpleStorage.d.ts +0 -19
- package/lib/storages/SimpleStorage.d.ts.map +0 -1
- package/lib/storages/SimpleStorage.js +0 -106
- package/lib/storages/StorageProvider.d.ts +0 -16
- package/lib/storages/StorageProvider.d.ts.map +0 -1
- package/lib/storages/StorageProvider.js +0 -29
- package/src/models/Models.ts +0 -1103
- package/src/models/samples_pb.ts +0 -4061
- package/src/storages/ObserverStorage.ts +0 -99
- package/src/storages/SimpleStorage.ts +0 -120
- package/src/storages/StorageProvider.ts +0 -42
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,EAC7B,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,EACb,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EAClB,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,EAC7B,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,EACb,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EAClB,MAAM,+BAA+B,CAAC;AAEvC,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAI1C,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,gBAAgB,EAAE,eAAe,EAAE,CAAC;IAC7C,QAAQ,CAAC,eAAe,EAAE,cAAc,EAAE,CAAC;IAC3C,QAAQ,CAAC,wBAAwB,EAAE,uBAAuB,EAAE,CAAC;IAC7D,QAAQ,CAAC,sBAAsB,EAAE,qBAAqB,EAAE,CAAC;IACzD,QAAQ,CAAC,uBAAuB,EAAE,sBAAsB,EAAE,CAAC;IAC3D,QAAQ,CAAC,wBAAwB,EAAE,uBAAuB,EAAE,CAAC;IAC7D,QAAQ,CAAC,wBAAwB,EAAE,uBAAuB,EAAE,CAAC;IAC7D,QAAQ,CAAC,8BAA8B,EAAE,6BAA6B,EAAE,CAAC;IACzE,QAAQ,CAAC,oBAAoB,EAAE,mBAAmB,EAAE,CAAC;IACrD,QAAQ,CAAC,yBAAyB,EAAE,wBAAwB,EAAE,CAAC;IAC/D,QAAQ,CAAC,yBAAyB,EAAE,wBAAwB,EAAE,CAAC;IAC/D,QAAQ,CAAC,eAAe,EAAE,cAAc,EAAE,CAAC;IAC3C,QAAQ,CAAC,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;IACnD,QAAQ,CAAC,uBAAuB,EAAE,sBAAsB,EAAE,CAAC;IAC3D,QAAQ,CAAC,wBAAwB,EAAE,uBAAuB,EAAE,CAAC;IAC7D,QAAQ,CAAC,oBAAoB,EAAE,mBAAmB,EAAE,CAAC;IACrD,QAAQ,CAAC,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;IACnD,QAAQ,CAAC,cAAc,EAAE,aAAa,EAAE,CAAC;CACzC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
export type { ObserverConfig, ObserverEvents } from './Observer';
|
|
2
2
|
export { Observer } from './Observer';
|
|
3
|
-
export type { ObserverStorage } from './storages/ObserverStorage';
|
|
4
|
-
export type { StorageProvider } from './storages/StorageProvider';
|
|
5
3
|
export * as SampleSchema from '@observertc/sample-schemas-js';
|
|
6
4
|
export * as ReportSchema from '@observertc/report-schemas-js';
|
|
7
5
|
export type { LogLevel, Logger } from './common/logger';
|
|
8
6
|
export type { Samples, ClientSample, SfuSample, ExtensionStat, PeerConnectionTransport, IceCandidatePair, MediaSourceStat, MediaCodecStats, InboundAudioTrack, InboundVideoTrack, OutboundAudioTrack, OutboundVideoTrack, IceLocalCandidate, IceRemoteCandidate, CustomCallEvent, SfuTransport, SfuInboundRtpPad, SfuOutboundRtpPad, SfuSctpChannel, SfuExtensionStats, DataChannel, } from '@observertc/sample-schemas-js';
|
|
9
7
|
export type { CallEventReport, CallMetaReport, ClientDataChannelReport, ClientExtensionReport, IceCandidatePairReport, InboundAudioTrackReport, InboundVideoTrackReport, ObserverEventReport, OutboundAudioTrackReport, OutboundVideoTrackReport, PeerConnectionTransportReport, SfuEventReport, SfuExtensionReport, SfuInboundRtpPadReport, SfuMetaReport, SfuOutboundRtpPadReport, SfuSctpStreamReport, SFUTransportReport, } from '@observertc/report-schemas-js';
|
|
10
|
-
export type { ObservedClient,
|
|
11
|
-
export type { ObservedPeerConnection,
|
|
12
|
-
export type { ObservedInboundTrack,
|
|
13
|
-
export type { ObservedOutboundTrack,
|
|
14
|
-
export type {
|
|
8
|
+
export type { ObservedClient, ObservedClientModel } from './ObservedClient';
|
|
9
|
+
export type { ObservedPeerConnection, ObservedPeerConnectionModel, ObservedPeerConnectionEvents } from './ObservedPeerConnection';
|
|
10
|
+
export type { ObservedInboundTrack, ObservedInboundTrackModel, ObservedInboundTrackEvents } from './ObservedInboundTrack';
|
|
11
|
+
export type { ObservedOutboundTrack, ObservedOutboundTrackModel, ObservedOutboundTrackEvents } from './ObservedOutboundTrack';
|
|
12
|
+
export type { ObserverSinkContext } from './common/types';
|
|
15
13
|
import { Observer, ObserverConfig } from './Observer';
|
|
16
14
|
export declare function createObserver(config?: Partial<ObserverConfig>): Observer;
|
|
17
15
|
import { LogLevel, Logger } from './common/logger';
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,KAAK,YAAY,MAAM,+BAA+B,CAAC;AAC9D,OAAO,KAAK,YAAY,MAAM,+BAA+B,CAAC;AAE9D,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAExD,YAAY,EACX,OAAO,EACP,YAAY,EACZ,SAAS,EACT,aAAa,EACb,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,WAAW,GACX,MAAM,+BAA+B,CAAC;AAEvC,YAAY,EACX,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,EAC7B,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,EACb,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,GAClB,MAAM,+BAA+B,CAAC;AAEvC,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,YAAY,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AAClI,YAAY,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAC1H,YAAY,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAE9H,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACtD,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,YAE9D;AAED,OAAO,EAAE,QAAQ,EAAE,MAAM,EAA8B,MAAM,iBAAiB,CAAC;AAC/E,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAG3D"}
|
package/package.json
CHANGED
package/src/ObservedCall.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
-
import
|
|
3
|
-
import { ObservedClient, ObservedClientConfig } from './ObservedClient';
|
|
4
|
-
import { createSingleExecutor } from './common/SingleExecutor';
|
|
2
|
+
import { ObservedClient, ObservedClientModel } from './ObservedClient';
|
|
5
3
|
import { ObservedOutboundTrack } from './ObservedOutboundTrack';
|
|
6
4
|
import { Observer } from './Observer';
|
|
5
|
+
import { createClientJoinedEventReport } from './common/callEventReports';
|
|
7
6
|
|
|
8
|
-
export type
|
|
7
|
+
export type ObservedCallModel = {
|
|
9
8
|
serviceId: string;
|
|
10
9
|
roomId: string;
|
|
11
10
|
callId: string;
|
|
12
11
|
started: number,
|
|
13
|
-
appData: AppData,
|
|
14
12
|
};
|
|
15
13
|
|
|
16
14
|
export type ObservedCallEvents = {
|
|
@@ -27,36 +25,6 @@ export declare interface ObservedCall {
|
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
export class ObservedCall<AppData extends Record<string, unknown> = Record<string, unknown>> extends EventEmitter {
|
|
30
|
-
public static async create<T extends Record<string, unknown> = Record<string, unknown>>(
|
|
31
|
-
config: ObservedCallConfig<T>,
|
|
32
|
-
observer: Observer,
|
|
33
|
-
// storageProvider: StorageProvider,
|
|
34
|
-
// reportsCollector: ReportsCollector,
|
|
35
|
-
) {
|
|
36
|
-
const model = new Models.Call({
|
|
37
|
-
roomId: config.roomId,
|
|
38
|
-
serviceId: config.serviceId,
|
|
39
|
-
callId: config.callId,
|
|
40
|
-
clientIds: [],
|
|
41
|
-
started: BigInt(config.started ?? Date.now()),
|
|
42
|
-
});
|
|
43
|
-
const result = new ObservedCall(
|
|
44
|
-
model,
|
|
45
|
-
observer,
|
|
46
|
-
// storageProvider,
|
|
47
|
-
// reportsCollector,
|
|
48
|
-
config.appData,
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
const alreadyInserted = await observer.storage.callStorage.insert(config.callId, model);
|
|
52
|
-
|
|
53
|
-
if (alreadyInserted) throw new Error(`Call with id ${config.callId} already exists`);
|
|
54
|
-
|
|
55
|
-
return result;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
private readonly _execute = createSingleExecutor();
|
|
59
|
-
private readonly _creatingClients = new Map<string, Promise<ObservedClient>>();
|
|
60
28
|
private readonly _clients = new Map<string, ObservedClient>();
|
|
61
29
|
|
|
62
30
|
public readonly sfuStreamIdToOutboundAudioTrack = new Map<string | number, ObservedOutboundTrack<'audio'>>();
|
|
@@ -64,8 +32,8 @@ export class ObservedCall<AppData extends Record<string, unknown> = Record<strin
|
|
|
64
32
|
private _closed = false;
|
|
65
33
|
private _ended?: number;
|
|
66
34
|
|
|
67
|
-
|
|
68
|
-
private readonly _model:
|
|
35
|
+
public constructor(
|
|
36
|
+
private readonly _model: ObservedCallModel,
|
|
69
37
|
public readonly observer: Observer,
|
|
70
38
|
public readonly appData: AppData,
|
|
71
39
|
) {
|
|
@@ -113,63 +81,35 @@ export class ObservedCall<AppData extends Record<string, unknown> = Record<strin
|
|
|
113
81
|
this._ended = timestamp ?? Date.now();
|
|
114
82
|
|
|
115
83
|
Array.from(this._clients.values()).forEach((client) => client.close());
|
|
116
|
-
|
|
117
|
-
this._execute(() => this.observer.storage.callStorage.remove(this.callId))
|
|
118
|
-
.catch(() => void 0)
|
|
119
|
-
.finally(() => this.emit('close'));
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
public async createClient<ClientAppData extends Record<string, unknown> = Record<string, unknown>>(
|
|
123
|
-
clientId: string,
|
|
124
|
-
config: { mediaUnitId?: string, appData: ClientAppData, joined?: number }
|
|
125
|
-
): Promise<ObservedClient<ClientAppData>> {
|
|
126
|
-
if (this._closed) throw new Error(`Call ${this.callId} is closed`);
|
|
127
|
-
let creating = this._creatingClients.get(clientId);
|
|
128
|
-
|
|
129
|
-
if (creating) return creating as Promise<ObservedClient<ClientAppData>>;
|
|
130
|
-
|
|
131
|
-
creating = this._createObservedClient<ClientAppData>(clientId, {
|
|
132
|
-
callId: this.callId,
|
|
133
|
-
appData: config.appData,
|
|
134
|
-
clientId,
|
|
135
|
-
overflowingProcessingThreshold: 2,
|
|
136
|
-
mediaUnitId: config.mediaUnitId ?? this.observer.config.defaultMediaUnitId,
|
|
137
|
-
joined: config.joined,
|
|
138
|
-
}).finally(() => this._creatingClients.delete(clientId));
|
|
139
|
-
|
|
140
|
-
this._creatingClients.set(clientId, creating);
|
|
141
84
|
|
|
142
|
-
|
|
85
|
+
this.emit('close');
|
|
143
86
|
}
|
|
144
87
|
|
|
145
|
-
public
|
|
88
|
+
public createClient<ClientAppData extends Record<string, unknown> = Record<string, unknown>>(config: ObservedClientModel & { appData: ClientAppData, generateClientJoinedReport?: boolean }) {
|
|
146
89
|
if (this._closed) throw new Error(`Call ${this.callId} is closed`);
|
|
147
|
-
|
|
148
|
-
return this._execute(async () => {
|
|
149
|
-
if (this._closed) throw new Error(`Call ${this.callId} is closed`);
|
|
150
|
-
await this.observer.storage.callStorage.set(this.callId, this._model);
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
private async _createObservedClient<ClientAppData extends Record<string, unknown> = Record<string, unknown>>(clientId: string, config: ObservedClientConfig<ClientAppData>): Promise<ObservedClient> {
|
|
155
|
-
const client = await ObservedClient.create<ClientAppData>(config, this, this.observer.storage);
|
|
156
|
-
const onUpdate = () => this.emit('update');
|
|
157
90
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
client.off('update', onUpdate);
|
|
162
|
-
|
|
163
|
-
this._clients.delete(clientId);
|
|
164
|
-
this._model.clientIds = this._model.clientIds.filter((id) => id !== clientId);
|
|
165
|
-
this.save().catch(() => void 0);
|
|
91
|
+
const { appData, generateClientJoinedReport, ...model } = config;
|
|
92
|
+
|
|
93
|
+
const result = new ObservedClient(model, this, appData);
|
|
166
94
|
|
|
95
|
+
result.once('close', () => {
|
|
96
|
+
this._clients.delete(result.clientId);
|
|
167
97
|
});
|
|
98
|
+
this._clients.set(result.clientId, result);
|
|
99
|
+
|
|
100
|
+
if (generateClientJoinedReport) {
|
|
101
|
+
this.reports.addCallEventReport(createClientJoinedEventReport(
|
|
102
|
+
this.serviceId,
|
|
103
|
+
result.mediaUnitId,
|
|
104
|
+
this.roomId,
|
|
105
|
+
this.callId,
|
|
106
|
+
result.clientId,
|
|
107
|
+
Date.now(),
|
|
108
|
+
result.userId,
|
|
109
|
+
result.marker,
|
|
110
|
+
));
|
|
111
|
+
}
|
|
168
112
|
|
|
169
|
-
|
|
170
|
-
this._clients.set(clientId, client);
|
|
171
|
-
this._model.clientIds.push(clientId);
|
|
172
|
-
|
|
173
|
-
return client;
|
|
113
|
+
return result;
|
|
174
114
|
}
|
|
175
115
|
}
|