@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.
Files changed (55) hide show
  1. package/lib/ObservedCall.d.ts +6 -13
  2. package/lib/ObservedCall.d.ts.map +1 -1
  3. package/lib/ObservedCall.js +24 -104
  4. package/lib/ObservedClient.d.ts +16 -27
  5. package/lib/ObservedClient.d.ts.map +1 -1
  6. package/lib/ObservedClient.js +360 -523
  7. package/lib/ObservedInboundTrack.d.ts +3 -8
  8. package/lib/ObservedInboundTrack.d.ts.map +1 -1
  9. package/lib/ObservedInboundTrack.js +74 -154
  10. package/lib/ObservedOutboundTrack.d.ts +9 -8
  11. package/lib/ObservedOutboundTrack.d.ts.map +1 -1
  12. package/lib/ObservedOutboundTrack.js +76 -130
  13. package/lib/ObservedPeerConnection.d.ts +17 -15
  14. package/lib/ObservedPeerConnection.d.ts.map +1 -1
  15. package/lib/ObservedPeerConnection.js +64 -173
  16. package/lib/ObservedSfu.d.ts +5 -7
  17. package/lib/ObservedSfu.d.ts.map +1 -1
  18. package/lib/ObservedSfu.js +10 -74
  19. package/lib/Observer.d.ts +5 -6
  20. package/lib/Observer.d.ts.map +1 -1
  21. package/lib/Observer.js +28 -31
  22. package/lib/common/types.d.ts +0 -55
  23. package/lib/common/types.d.ts.map +1 -1
  24. package/lib/index.d.ts +5 -7
  25. package/lib/index.d.ts.map +1 -1
  26. package/package.json +1 -1
  27. package/src/ObservedCall.ts +27 -87
  28. package/src/ObservedClient.ts +425 -582
  29. package/src/ObservedInboundTrack.ts +14 -65
  30. package/src/ObservedOutboundTrack.ts +32 -53
  31. package/src/ObservedPeerConnection.ts +55 -117
  32. package/src/ObservedSfu.ts +11 -46
  33. package/src/Observer.ts +11 -16
  34. package/src/common/types.ts +0 -69
  35. package/src/index.ts +5 -7
  36. package/lib/models/Models.d.ts +0 -642
  37. package/lib/models/Models.d.ts.map +0 -1
  38. package/lib/models/Models.js +0 -481
  39. package/lib/models/samples_pb.d.ts +0 -2452
  40. package/lib/models/samples_pb.d.ts.map +0 -1
  41. package/lib/models/samples_pb.js +0 -1495
  42. package/lib/storages/ObserverStorage.d.ts +0 -87
  43. package/lib/storages/ObserverStorage.d.ts.map +0 -1
  44. package/lib/storages/ObserverStorage.js +0 -2
  45. package/lib/storages/SimpleStorage.d.ts +0 -19
  46. package/lib/storages/SimpleStorage.d.ts.map +0 -1
  47. package/lib/storages/SimpleStorage.js +0 -106
  48. package/lib/storages/StorageProvider.d.ts +0 -16
  49. package/lib/storages/StorageProvider.d.ts.map +0 -1
  50. package/lib/storages/StorageProvider.js +0 -29
  51. package/src/models/Models.ts +0 -1103
  52. package/src/models/samples_pb.ts +0 -4061
  53. package/src/storages/ObserverStorage.ts +0 -99
  54. package/src/storages/SimpleStorage.ts +0 -120
  55. package/src/storages/StorageProvider.ts +0 -42
@@ -1,65 +1,15 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
2
  Object.defineProperty(exports, "__esModule", { value: true });
35
3
  exports.ObservedPeerConnection = void 0;
36
4
  const events_1 = require("events");
37
- const Models = __importStar(require("./models/Models"));
38
5
  const ObservedInboundTrack_1 = require("./ObservedInboundTrack");
39
6
  const ObservedOutboundTrack_1 = require("./ObservedOutboundTrack");
40
- const SingleExecutor_1 = require("./common/SingleExecutor");
41
7
  const ObservedICE_1 = require("./ObservedICE");
42
8
  class ObservedPeerConnection extends events_1.EventEmitter {
43
- static create(config, client, storageProvider) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- const model = new Models.PeerConnection({
46
- roomId: client.roomId,
47
- serviceId: client.serviceId,
48
- callId: client.callId,
49
- clientId: client.clientId,
50
- peerConnectionId: config.peerConnectionId,
51
- });
52
- const alreadyInserted = yield storageProvider.peerConnectionStorage.insert(config.peerConnectionId, model);
53
- if (alreadyInserted)
54
- throw new Error(`PeerConnection with id ${config.peerConnectionId} already exists`);
55
- return new ObservedPeerConnection(model, client, storageProvider);
56
- });
57
- }
58
- constructor(_model, client, _storageProvider) {
9
+ constructor(_model, client) {
59
10
  super();
60
11
  this._model = _model;
61
12
  this.client = client;
62
- this._storageProvider = _storageProvider;
63
13
  this.created = Date.now();
64
14
  this.totalInboundPacketsLost = 0;
65
15
  this.totalInboundPacketsReceived = 0;
@@ -98,11 +48,28 @@ class ObservedPeerConnection extends events_1.EventEmitter {
98
48
  this._inboundVideoTracks = new Map();
99
49
  this._outboundAudioTracks = new Map();
100
50
  this._outboundVideoTracks = new Map();
101
- this._execute = (0, SingleExecutor_1.createSingleExecutor)();
51
+ }
52
+ get serviceId() {
53
+ return this.client.serviceId;
54
+ }
55
+ get roomId() {
56
+ return this.client.roomId;
57
+ }
58
+ get callId() {
59
+ return this.client.callId;
60
+ }
61
+ get clientId() {
62
+ return this.client.clientId;
63
+ }
64
+ get mediaUnitId() {
65
+ return this.client.mediaUnitId;
102
66
  }
103
67
  get label() {
104
68
  return this._model.label;
105
69
  }
70
+ set label(value) {
71
+ this._model.label = value;
72
+ }
106
73
  get usingTURN() {
107
74
  var _a, _b;
108
75
  return ((_b = (_a = this.ICE.selectedRemoteCandidate) === null || _a === void 0 ? void 0 : _a.candidateType) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'relay';
@@ -154,9 +121,7 @@ class ObservedPeerConnection extends events_1.EventEmitter {
154
121
  Array.from(this._inboundVideoTracks.values()).forEach((track) => track.close());
155
122
  Array.from(this._outboundAudioTracks.values()).forEach((track) => track.close());
156
123
  Array.from(this._outboundVideoTracks.values()).forEach((track) => track.close());
157
- this._execute(() => this._storageProvider.peerConnectionStorage.remove(this.peerConnectionId))
158
- .catch(() => void 0)
159
- .finally(() => this.emit('close'));
124
+ this.emit('close');
160
125
  }
161
126
  getTrack(trackId) {
162
127
  var _a, _b, _c;
@@ -254,136 +219,62 @@ class ObservedPeerConnection extends events_1.EventEmitter {
254
219
  this.avgRttInMs = 0 < nrOfBelongings ? sumRttInMs / nrOfBelongings : undefined;
255
220
  }
256
221
  update(sample, timestamp) {
257
- return __awaiter(this, void 0, void 0, function* () {
258
- if (this._closed)
259
- return;
260
- if (sample.peerConnectionId !== this._model.peerConnectionId)
261
- throw new Error(`TransportId mismatch. PeerConnectionId: ${this._model.peerConnectionId} TransportId: ${sample.transportId}`);
262
- this._sample = sample;
263
- if (this._model.label !== sample.label) {
264
- this._model.label = sample.label;
265
- yield this._save().catch(() => void 0);
266
- }
267
- const report = Object.assign(Object.assign({ serviceId: this.client.call.serviceId, roomId: this.client.call.roomId, callId: this.client.call.callId, clientId: this.client.clientId, userId: this.client.userId, mediaUnitId: this.client.mediaUnitId }, sample), { timestamp, sampleSeq: -1 });
268
- this.reports.addPeerConnectionTransportReports(report);
269
- this._updated = timestamp;
270
- this.emit('update');
271
- });
222
+ if (this._closed)
223
+ return;
224
+ if (sample.peerConnectionId !== this._model.peerConnectionId)
225
+ throw new Error(`TransportId mismatch. PeerConnectionId: ${this._model.peerConnectionId} TransportId: ${sample.transportId}`);
226
+ this._sample = sample;
227
+ if (this._model.label !== sample.label) {
228
+ this._model.label = sample.label;
229
+ }
230
+ const report = Object.assign(Object.assign({ serviceId: this.client.call.serviceId, roomId: this.client.call.roomId, callId: this.client.call.callId, clientId: this.client.clientId, userId: this.client.userId, mediaUnitId: this.client.mediaUnitId }, sample), { timestamp, sampleSeq: -1 });
231
+ this.reports.addPeerConnectionTransportReports(report);
232
+ this._updated = Date.now();
233
+ this.emit('update');
272
234
  }
273
235
  createInboundAudioTrack(config) {
274
- return __awaiter(this, void 0, void 0, function* () {
275
- if (this._closed)
276
- throw new Error(`PeerConnection ${this.peerConnectionId} is closed`);
277
- const result = yield ObservedInboundTrack_1.ObservedInboundTrack.create({
278
- kind: 'audio',
279
- trackId: config.trackId,
280
- }, this, this._storageProvider);
281
- const pendingTracksTimestamp = this.client.ωpendingCreatedTracksTimestamp.get(result.trackId);
282
- if (pendingTracksTimestamp) {
283
- this.client.ωpendingCreatedTracksTimestamp.delete(result.trackId);
284
- result.created = pendingTracksTimestamp;
285
- }
286
- result.on('close', () => {
287
- this._inboundAudioTracks.delete(result.trackId);
288
- this._model.inboundTrackIds = this._model.inboundTrackIds.filter((id) => id !== result.trackId);
289
- !this._closed && this._save().catch(() => void 0);
290
- });
291
- this._inboundAudioTracks.set(result.trackId, result);
292
- this._model.inboundTrackIds = [...(new Set([...this._model.inboundTrackIds, result.trackId]))];
293
- yield this._save();
294
- this.emit('newinboudaudiotrack', result);
295
- return result;
236
+ if (this._closed)
237
+ throw new Error(`PeerConnection ${this.peerConnectionId} is closed`);
238
+ const result = new ObservedInboundTrack_1.ObservedInboundTrack(Object.assign({ kind: 'audio' }, config), this);
239
+ result.on('close', () => {
240
+ this._inboundAudioTracks.delete(result.trackId);
296
241
  });
242
+ this._inboundAudioTracks.set(result.trackId, result);
243
+ this.emit('newinboudaudiotrack', result);
244
+ return result;
297
245
  }
298
246
  createInboundVideoTrack(config) {
299
- return __awaiter(this, void 0, void 0, function* () {
300
- if (this._closed)
301
- throw new Error(`PeerConnection ${this.peerConnectionId} is closed`);
302
- const result = yield ObservedInboundTrack_1.ObservedInboundTrack.create({
303
- kind: 'video',
304
- trackId: config.trackId,
305
- }, this, this._storageProvider);
306
- const pendingTracksTimestamp = this.client.ωpendingCreatedTracksTimestamp.get(result.trackId);
307
- if (pendingTracksTimestamp) {
308
- this.client.ωpendingCreatedTracksTimestamp.delete(result.trackId);
309
- result.created = pendingTracksTimestamp;
310
- }
311
- result.on('close', () => {
312
- this._inboundVideoTracks.delete(result.trackId);
313
- this._model.inboundTrackIds = this._model.inboundTrackIds.filter((id) => id !== result.trackId);
314
- !this._closed && this._save().catch(() => void 0);
315
- });
316
- this._inboundVideoTracks.set(result.trackId, result);
317
- this._model.inboundTrackIds = [...(new Set([...this._model.inboundTrackIds, result.trackId]))];
318
- yield this._save();
319
- this.emit('newinboudvideotrack', result);
320
- return result;
247
+ if (this._closed)
248
+ throw new Error(`PeerConnection ${this.peerConnectionId} is closed`);
249
+ const result = new ObservedInboundTrack_1.ObservedInboundTrack(Object.assign({ kind: 'video' }, config), this);
250
+ result.on('close', () => {
251
+ this._inboundVideoTracks.delete(result.trackId);
321
252
  });
253
+ this._inboundVideoTracks.set(result.trackId, result);
254
+ this.emit('newinboudvideotrack', result);
255
+ return result;
322
256
  }
323
257
  createOutboundAudioTrack(config) {
324
- return __awaiter(this, void 0, void 0, function* () {
325
- if (this._closed)
326
- throw new Error(`PeerConnection ${this.peerConnectionId} is closed`);
327
- const result = yield ObservedOutboundTrack_1.ObservedOutboundTrack.create({
328
- kind: 'audio',
329
- trackId: config.trackId,
330
- }, this, this._storageProvider);
331
- const pendingTracksTimestamp = this.client.ωpendingCreatedTracksTimestamp.get(result.trackId);
332
- if (pendingTracksTimestamp) {
333
- this.client.ωpendingCreatedTracksTimestamp.delete(result.trackId);
334
- result.created = pendingTracksTimestamp;
335
- }
336
- result.on('close', () => {
337
- this._outboundAudioTracks.delete(result.trackId);
338
- this._model.outboundTrackIds = this._model.outboundTrackIds.filter((id) => id !== result.trackId);
339
- result.sfuStreamId && this.client.call.sfuStreamIdToOutboundAudioTrack.delete(result.sfuStreamId);
340
- !this._closed && this._save().catch(() => void 0);
341
- });
342
- this._outboundAudioTracks.set(result.trackId, result);
343
- this._model.outboundTrackIds = [...(new Set([...this._model.outboundTrackIds, result.trackId]))];
344
- result.sfuStreamId && this.client.call.sfuStreamIdToOutboundAudioTrack.set(result.sfuStreamId, result);
345
- yield this._save();
346
- this.emit('newoutboundaudiotrack', result);
347
- return result;
258
+ if (this._closed)
259
+ throw new Error(`PeerConnection ${this.peerConnectionId} is closed`);
260
+ const result = new ObservedOutboundTrack_1.ObservedOutboundTrack(Object.assign({ kind: 'audio' }, config), this);
261
+ result.on('close', () => {
262
+ this._outboundAudioTracks.delete(result.trackId);
348
263
  });
264
+ this._outboundAudioTracks.set(result.trackId, result);
265
+ this.emit('newoutboundaudiotrack', result);
266
+ return result;
349
267
  }
350
268
  createOutboundVideoTrack(config) {
351
- return __awaiter(this, void 0, void 0, function* () {
352
- if (this._closed)
353
- throw new Error(`PeerConnection ${this.peerConnectionId} is closed`);
354
- const result = yield ObservedOutboundTrack_1.ObservedOutboundTrack.create({
355
- kind: 'video',
356
- trackId: config.trackId,
357
- }, this, this._storageProvider);
358
- const pendingTracksTimestamp = this.client.ωpendingCreatedTracksTimestamp.get(result.trackId);
359
- if (pendingTracksTimestamp) {
360
- this.client.ωpendingCreatedTracksTimestamp.delete(result.trackId);
361
- result.created = pendingTracksTimestamp;
362
- }
363
- result.on('close', () => {
364
- this._outboundVideoTracks.delete(result.trackId);
365
- result.sfuStreamId && this.client.call.sfuStreamIdToOutboundVideoTrack.set(result.sfuStreamId, result);
366
- this._model.outboundTrackIds = this._model.outboundTrackIds.filter((id) => id !== result.trackId);
367
- !this._closed && this._save().catch(() => void 0);
368
- });
369
- this._outboundVideoTracks.set(result.trackId, result);
370
- result.sfuStreamId && this.client.call.sfuStreamIdToOutboundVideoTrack.set(result.sfuStreamId, result);
371
- this._model.outboundTrackIds = [...(new Set([...this._model.outboundTrackIds, result.trackId]))];
372
- yield this._save();
373
- this.emit('newoutboundvideotrack', result);
374
- return result;
375
- });
376
- }
377
- _save() {
378
- return __awaiter(this, void 0, void 0, function* () {
379
- if (this._closed)
380
- throw new Error(`PeerConnection ${this.peerConnectionId} is closed`);
381
- return this._execute(() => __awaiter(this, void 0, void 0, function* () {
382
- if (this._closed)
383
- throw new Error(`PeerConnection ${this.peerConnectionId} is closed`);
384
- yield this._storageProvider.peerConnectionStorage.set(this.peerConnectionId, this._model);
385
- }));
269
+ if (this._closed)
270
+ throw new Error(`PeerConnection ${this.peerConnectionId} is closed`);
271
+ const result = new ObservedOutboundTrack_1.ObservedOutboundTrack(Object.assign({ kind: 'video' }, config), this);
272
+ result.on('close', () => {
273
+ this._outboundVideoTracks.delete(result.trackId);
386
274
  });
275
+ this._outboundVideoTracks.set(result.trackId, result);
276
+ this.emit('newoutboundvideotrack', result);
277
+ return result;
387
278
  }
388
279
  }
389
280
  exports.ObservedPeerConnection = ObservedPeerConnection;
@@ -2,11 +2,10 @@
2
2
  import { EventEmitter } from 'events';
3
3
  import { Observer } from './Observer';
4
4
  import { SfuSample } from '@observertc/sample-schemas-js';
5
- export type ObservedSfuConfig<AppData extends Record<string, unknown> = Record<string, unknown>> = {
5
+ export type ObservedSfuModel = {
6
6
  serviceId: string;
7
7
  sfuId: string;
8
8
  joined?: number;
9
- appData: AppData;
10
9
  };
11
10
  export type ObservedSfuEvents = {
12
11
  update: [];
@@ -22,17 +21,16 @@ export declare class ObservedSfu<AppData extends Record<string, unknown> = Recor
22
21
  private readonly _model;
23
22
  readonly observer: Observer;
24
23
  readonly appData: AppData;
25
- static create<T extends Record<string, unknown> = Record<string, unknown>>(config: ObservedSfuConfig<T>, observer: Observer): Promise<ObservedSfu<T>>;
24
+ readonly created: number;
26
25
  private _updated;
27
- private readonly _execute;
28
26
  private _closed;
29
- private constructor();
27
+ constructor(_model: ObservedSfuModel, observer: Observer, appData: AppData);
30
28
  get serviceId(): string;
31
29
  get sfuId(): string;
32
30
  get joined(): number;
31
+ get updated(): number;
33
32
  get closed(): boolean;
34
33
  close(): void;
35
- update(sample: SfuSample): Promise<void>;
36
- private _save;
34
+ update(sample: SfuSample): void;
37
35
  }
38
36
  //# sourceMappingURL=ObservedSfu.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ObservedSfu.d.ts","sourceRoot":"","sources":["../src/ObservedSfu.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,MAAM,MAAM,iBAAiB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IAClG,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC/B,MAAM,EAAE,EAAE,CAAC;IACX,KAAK,EAAE,EAAE,CAAC;CACV,CAAC;AAEF,MAAM,CAAC,OAAO,WAAW,WAAW;IACnC,EAAE,CAAC,CAAC,SAAS,MAAM,iBAAiB,EAAE,KAAK,EAAE,CAAC,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OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAE,SAAQ,YAAY;IAO9G,OAAO,CAAC,QAAQ,CAAC,MAAM;aACP,QAAQ,EAAE,QAAQ;aAClB,OAAO,EAAE,OAAO;IARjC,SAAgB,OAAO,SAAc;IAErC,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,OAAO,CAAS;gBAGN,MAAM,EAAE,gBAAgB,EACzB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO;IAKjC,IAAW,SAAS,WAGnB;IAED,IAAW,KAAK,WAGf;IAED,IAAW,MAAM,WAGhB;IAED,IAAW,OAAO,WAEjB;IAED,IAAW,MAAM,YAEhB;IAEM,KAAK;IAML,MAAM,CAAC,MAAM,EAAE,SAAS;CAO/B"}
@@ -1,65 +1,15 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
2
  Object.defineProperty(exports, "__esModule", { value: true });
35
3
  exports.ObservedSfu = void 0;
36
4
  const events_1 = require("events");
37
- const Models = __importStar(require("./models/Models"));
38
- const SingleExecutor_1 = require("./common/SingleExecutor");
39
5
  class ObservedSfu extends events_1.EventEmitter {
40
- static create(config, observer) {
41
- var _a;
42
- return __awaiter(this, void 0, void 0, function* () {
43
- const model = new Models.Sfu({
44
- serviceId: config.serviceId,
45
- sfuId: config.sfuId,
46
- sfuTransportIds: [],
47
- joined: BigInt((_a = config.joined) !== null && _a !== void 0 ? _a : Date.now()),
48
- });
49
- const result = new ObservedSfu(model, observer, config.appData);
50
- const alreadyInserted = yield observer.storage.sfuStorage.insert(config.sfuId, model);
51
- if (alreadyInserted)
52
- throw new Error(`Sfu with id ${config.sfuId} already exists`);
53
- return result;
54
- });
55
- }
56
6
  constructor(_model, observer, appData) {
57
7
  super();
58
8
  this._model = _model;
59
9
  this.observer = observer;
60
10
  this.appData = appData;
11
+ this.created = Date.now();
61
12
  this._updated = Date.now();
62
- this._execute = (0, SingleExecutor_1.createSingleExecutor)();
63
13
  this._closed = false;
64
14
  }
65
15
  get serviceId() {
@@ -74,6 +24,9 @@ class ObservedSfu extends events_1.EventEmitter {
74
24
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
75
25
  return Number(this._model.joined);
76
26
  }
27
+ get updated() {
28
+ return this._updated;
29
+ }
77
30
  get closed() {
78
31
  return this._closed;
79
32
  }
@@ -84,29 +37,12 @@ class ObservedSfu extends events_1.EventEmitter {
84
37
  this.emit('close');
85
38
  }
86
39
  update(sample) {
87
- return __awaiter(this, void 0, void 0, function* () {
88
- if (this._closed)
89
- throw new Error(`Sfu ${this.sfuId} is closed`);
90
- if (sample.sfuId !== this.sfuId)
91
- throw new Error(`Sfu ${this.sfuId} is not the same as sample.sfuId`);
92
- return this._execute(() => __awaiter(this, void 0, void 0, function* () {
93
- if (this._closed)
94
- throw new Error(`Sfu ${this.sfuId} is closed`);
95
- yield this._save();
96
- this.emit('update');
97
- }));
98
- });
99
- }
100
- _save() {
101
- return __awaiter(this, void 0, void 0, function* () {
102
- if (this._closed)
103
- throw new Error(`Sfu ${this.sfuId} is closed`);
104
- return this._execute(() => __awaiter(this, void 0, void 0, function* () {
105
- if (this._closed)
106
- throw new Error(`Sfu ${this.sfuId} is closed`);
107
- yield this.observer.storage.sfuStorage.set(this.sfuId, this._model);
108
- }));
109
- });
40
+ if (this._closed)
41
+ throw new Error(`Sfu ${this.sfuId} is closed`);
42
+ if (sample.sfuId !== this.sfuId)
43
+ throw new Error(`Sfu ${this.sfuId} is not the same as sample.sfuId`);
44
+ this._updated = Date.now();
45
+ this.emit('update');
110
46
  }
111
47
  }
112
48
  exports.ObservedSfu = ObservedSfu;
package/lib/Observer.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { StorageProvider } from './storages/StorageProvider';
3
- import { ObservedCall, ObservedCallConfig } from './ObservedCall';
2
+ import { ObservedCall, ObservedCallModel } from './ObservedCall';
4
3
  import { ReportsCollector } from './ReportsCollector';
5
4
  import { EventEmitter } from 'events';
6
5
  import { PartialBy } from './common/utils';
@@ -26,7 +25,6 @@ export type ObserverConfig = {
26
25
  maxReports?: number | undefined;
27
26
  maxCollectingTimeInMs?: number | undefined;
28
27
  maxEntryIdleTimeInMs?: number | undefined;
29
- storages?: StorageProvider;
30
28
  };
31
29
  export declare interface Observer {
32
30
  on<U extends keyof ObserverEvents>(event: U, listener: (...args: ObserverEvents[U]) => void): this;
@@ -36,14 +34,15 @@ export declare interface Observer {
36
34
  }
37
35
  export declare class Observer extends EventEmitter {
38
36
  readonly config: ObserverConfig;
39
- readonly storage: StorageProvider;
40
37
  static create(providedConfig: Partial<ObserverConfig>): Observer;
41
38
  readonly reports: ReportsCollector;
42
39
  private readonly _observedCalls;
43
40
  private _reportTimer?;
44
41
  private _closed;
45
- constructor(config: ObserverConfig, storage: StorageProvider);
46
- createObservedCall<T extends Record<string, unknown> = Record<string, unknown>>(config: PartialBy<ObservedCallConfig<T>, 'serviceId' | 'started'>): Promise<ObservedCall<T>>;
42
+ constructor(config: ObserverConfig);
43
+ createObservedCall<T extends Record<string, unknown> = Record<string, unknown>>(config: PartialBy<ObservedCallModel, 'serviceId' | 'started'> & {
44
+ appData: T;
45
+ }): ObservedCall<T>;
47
46
  get observedCalls(): ReadonlyMap<string, ObservedCall>;
48
47
  get closed(): boolean;
49
48
  close(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"Observer.d.ts","sourceRoot":"","sources":["../src/Observer.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAA+B,MAAM,4BAA4B,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAK3C,MAAM,MAAM,cAAc,GAAG;IAC5B,SAAS,EAAE,CAAC,YAAY,CAAC,CAAC;IAE1B,OAAO,EAAE,EAAE,CAAC;CACZ,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAE5B;;;;;;OAMG;IACH,gBAAgB,EAAE,MAAM,CAAC;IAEzB;;;;OAIG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAE3B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,qBAAqB,CAAC,EAAE,MA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AAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI,CAAC;IACpG,IAAI,CAAC,CAAC,SAAS,MAAM,cAAc,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI,CAAC;IACrG,IAAI,CAAC,CAAC,SAAS,MAAM,cAAc,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;CACpF;AAED,qBAAa,QAAS,SAAQ,YAAY;aAwBxB,MAAM,EAAE,cAAc;WAvBzB,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,QAAQ;IAkBvE,SAAgB,OAAO,mBAA0B;IACjD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAmC;IAClE,OAAO,CAAC,YAAY,CAAC,CAAgC;IACrD,OAAO,CAAC,OAAO,CAAS;gBAEP,MAAM,EAAE,cAAc;IAiBhC,kBAAkB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpF,MAAM,EAAE,SAAS,CAAC,iBAAiB,EAAE,WAAW,GAAG,SAAS,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC,CAAA;KAAE,GAC5E,YAAY,CAAC,CAAC,CAAC;IAsClB,IAAW,aAAa,IAAI,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,CAE5D;IAED,IAAW,MAAM,YAEhB;IAEM,KAAK;IASZ,OAAO,CAAC,YAAY;CAepB"}
package/lib/Observer.js CHANGED
@@ -1,17 +1,18 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
10
12
  };
11
13
  Object.defineProperty(exports, "__esModule", { value: true });
12
14
  exports.Observer = void 0;
13
15
  const logger_1 = require("./common/logger");
14
- const StorageProvider_1 = require("./storages/StorageProvider");
15
16
  const ObservedCall_1 = require("./ObservedCall");
16
17
  const ReportsCollector_1 = require("./ReportsCollector");
17
18
  const events_1 = require("events");
@@ -19,7 +20,6 @@ const callEventReports_1 = require("./common/callEventReports");
19
20
  const logger = (0, logger_1.createLogger)('Observer');
20
21
  class Observer extends events_1.EventEmitter {
21
22
  static create(providedConfig) {
22
- var _a;
23
23
  const config = Object.assign({
24
24
  defaultServiceId: 'default-service-id',
25
25
  defaultMediaUnitId: 'default-media-unit-id',
@@ -30,13 +30,11 @@ class Observer extends events_1.EventEmitter {
30
30
  sink: {},
31
31
  logLevel: 'info',
32
32
  }, providedConfig);
33
- const storages = (_a = providedConfig.storages) !== null && _a !== void 0 ? _a : (0, StorageProvider_1.createSimpleStorageProvider)();
34
- return new Observer(config, storages);
33
+ return new Observer(config);
35
34
  }
36
- constructor(config, storage) {
35
+ constructor(config) {
37
36
  super();
38
37
  this.config = config;
39
- this.storage = storage;
40
38
  this.reports = new ReportsCollector_1.ReportsCollector();
41
39
  this._observedCalls = new Map();
42
40
  this._closed = false;
@@ -53,24 +51,23 @@ class Observer extends events_1.EventEmitter {
53
51
  this.reports.on('newreport', onNewReport);
54
52
  }
55
53
  createObservedCall(config) {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- if (this._closed) {
58
- throw new Error('Attempted to create a call source on a closed observer');
59
- }
60
- const call = yield ObservedCall_1.ObservedCall.create(Object.assign({ serviceId: this.config.defaultServiceId, started: Date.now() }, config), this);
61
- if (this._closed)
62
- throw new Error('Cannot create an observed call on a closed observer');
63
- if (this._observedCalls.has(call.callId))
64
- throw new Error(`Observed Call with id ${call.callId} already exists`);
65
- call.once('close', () => {
66
- this._observedCalls.delete(call.callId);
67
- this.reports.addCallEventReport((0, callEventReports_1.createCallStartedEventReport)(call.serviceId, call.roomId, call.callId, Date.now()));
68
- });
69
- this._observedCalls.set(call.callId, call);
70
- this.reports.addCallEventReport((0, callEventReports_1.createCallStartedEventReport)(call.serviceId, call.roomId, call.callId, call.started));
71
- this.emit('newcall', call);
72
- return call;
54
+ if (this._closed) {
55
+ throw new Error('Attempted to create a call source on a closed observer');
56
+ }
57
+ const { appData } = config, model = __rest(config, ["appData"]);
58
+ const call = new ObservedCall_1.ObservedCall(Object.assign(Object.assign({}, model), { serviceId: this.config.defaultServiceId, started: Date.now() }), this, appData);
59
+ if (this._closed)
60
+ throw new Error('Cannot create an observed call on a closed observer');
61
+ if (this._observedCalls.has(call.callId))
62
+ throw new Error(`Observed Call with id ${call.callId} already exists`);
63
+ call.once('close', () => {
64
+ this._observedCalls.delete(call.callId);
65
+ this.reports.addCallEventReport((0, callEventReports_1.createCallEndedEventReport)(call.serviceId, call.roomId, call.callId, Date.now()));
73
66
  });
67
+ this._observedCalls.set(call.callId, call);
68
+ this.reports.addCallEventReport((0, callEventReports_1.createCallStartedEventReport)(call.serviceId, call.roomId, call.callId, call.started));
69
+ this.emit('newcall', call);
70
+ return call;
74
71
  }
75
72
  get observedCalls() {
76
73
  return this._observedCalls;
@@ -1,60 +1,5 @@
1
1
  import { CallEventReport, CallMetaReport, ClientDataChannelReport, ClientExtensionReport, IceCandidatePairReport, InboundAudioTrackReport, InboundVideoTrackReport, ObserverEventReport, OutboundAudioTrackReport, OutboundVideoTrackReport, PeerConnectionTransportReport, SfuEventReport, SfuExtensionReport, SfuInboundRtpPadReport, SfuMetaReport, SfuOutboundRtpPadReport, SfuSctpStreamReport, SFUTransportReport } from '@observertc/report-schemas-js';
2
- import * as Models from '../models/Models';
3
- import { StorageProvider } from '../storages/StorageProvider';
4
- import { Message } from '@bufbuild/protobuf';
5
2
  export type MediaKind = 'audio' | 'video';
6
- export interface EvaluatorContext {
7
- readonly startedCallIds: string[];
8
- readonly endedCalls: (Omit<Models.Call, keyof Message> & {
9
- ended: number;
10
- })[];
11
- readonly joinedClientIds: string[];
12
- readonly detachedClients: (Omit<Models.Client, keyof Message> & {
13
- detached: number;
14
- })[];
15
- readonly openedPeerConnectionIds: string[];
16
- readonly closedPeerConnections: (Omit<Models.PeerConnection, keyof Message> & {
17
- closed: number;
18
- })[];
19
- readonly addedInboundAudioTrackIds: string[];
20
- readonly removedInboundAudioTracks: (Omit<Models.InboundTrack, keyof Message> & {
21
- removed: number;
22
- })[];
23
- readonly addedInboundVideoTrackIds: string[];
24
- readonly removedInboundVideoTracks: (Omit<Models.InboundTrack, keyof Message> & {
25
- removed: number;
26
- })[];
27
- readonly addedOutboundAudioTrackIds: string[];
28
- readonly removedOutboundAudioTracks: (Omit<Models.OutboundTrack, keyof Message> & {
29
- removed: number;
30
- })[];
31
- readonly addedOutboundVideoTrackIds: string[];
32
- readonly removedOutboundVideoTracks: (Omit<Models.OutboundTrack, keyof Message> & {
33
- removed: number;
34
- })[];
35
- readonly joinedSfuIds: string[];
36
- readonly detachedSfus: (Omit<Models.Sfu, keyof Message> & {
37
- detached: number;
38
- })[];
39
- readonly openedSfuTransportIds: string[];
40
- readonly closedSfuTransports: (Omit<Models.SfuTransport, keyof Message> & {
41
- closed: number;
42
- })[];
43
- readonly addedSfuInbounRtpPadIds: string[];
44
- readonly removedSfuInbounRtpPadIds: (Omit<Models.SfuInboundRtpPad, keyof Message> & {
45
- removed: number;
46
- })[];
47
- readonly addedSfuOutbounRtpPadIds: string[];
48
- readonly removedSfuOutbounRtpPadIds: (Omit<Models.SfuOutboundRtpPad, keyof Message> & {
49
- removed: number;
50
- })[];
51
- readonly openedSfuSctpChannelIds: string[];
52
- readonly closedSfuSctpChannels: (Omit<Models.SfuSctpChannel, keyof Message> & {
53
- closed: number;
54
- })[];
55
- readonly storages: StorageProvider;
56
- readonly reports: ObserverSinkContext;
57
- }
58
3
  export interface ObserverSinkContext {
59
4
  readonly callEventReports: CallEventReport[];
60
5
  readonly callMetaReports: CallMetaReport[];