@observertc/observer-js 0.30.0-e12fcb4.0 → 0.30.2-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 (39) hide show
  1. package/lib/ObservedCall.d.ts +1 -1
  2. package/lib/ObservedCall.d.ts.map +1 -1
  3. package/lib/ObservedCall.js +0 -7
  4. package/lib/ObservedClient.d.ts +36 -6
  5. package/lib/ObservedClient.d.ts.map +1 -1
  6. package/lib/ObservedClient.js +129 -71
  7. package/lib/ObservedICE.d.ts +47 -0
  8. package/lib/ObservedICE.d.ts.map +1 -0
  9. package/lib/ObservedICE.js +105 -0
  10. package/lib/ObservedInboundTrack.d.ts +16 -0
  11. package/lib/ObservedInboundTrack.d.ts.map +1 -1
  12. package/lib/ObservedInboundTrack.js +39 -2
  13. package/lib/ObservedPeerConnection.d.ts +39 -1
  14. package/lib/ObservedPeerConnection.d.ts.map +1 -1
  15. package/lib/ObservedPeerConnection.js +61 -0
  16. package/lib/Observer.d.ts +1 -4
  17. package/lib/Observer.d.ts.map +1 -1
  18. package/lib/Observer.js +1 -0
  19. package/lib/common/CallEventType.d.ts +22 -0
  20. package/lib/common/CallEventType.d.ts.map +1 -0
  21. package/lib/common/CallEventType.js +26 -0
  22. package/lib/common/callEventReports.d.ts +0 -10
  23. package/lib/common/callEventReports.d.ts.map +1 -1
  24. package/lib/common/callEventReports.js +10 -21
  25. package/lib/models/Models.d.ts +3 -70
  26. package/lib/models/Models.d.ts.map +1 -1
  27. package/lib/models/Models.js +2 -72
  28. package/lib/models/samples_pb.js +1 -1
  29. package/package.json +1 -1
  30. package/src/ObservedCall.ts +3 -29
  31. package/src/ObservedClient.ts +168 -84
  32. package/src/ObservedICE.ts +176 -0
  33. package/src/ObservedInboundTrack.ts +50 -1
  34. package/src/ObservedPeerConnection.ts +79 -2
  35. package/src/Observer.ts +4 -5
  36. package/src/common/CallEventType.ts +23 -0
  37. package/src/common/callEventReports.ts +1 -11
  38. package/src/models/Models.ts +4 -113
  39. package/src/models/samples_pb.ts +1 -1
@@ -47,7 +47,7 @@ export declare class ObservedCall<AppData extends Record<string, unknown> = Reco
47
47
  mediaUnitId?: string;
48
48
  appData: ClientAppData;
49
49
  joined?: number;
50
- }): Promise<ObservedClient>;
50
+ }): Promise<ObservedClient<ClientAppData>>;
51
51
  save(): Promise<void>;
52
52
  private _createObservedClient;
53
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ObservedCall.d.ts","sourceRoot":"","sources":["../src/ObservedCall.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAwB,MAAM,kBAAkB,CAAC;AAExE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,MAAM,MAAM,kBAAkB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IACnG,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAChC,MAAM,EAAE,EAAE,CAAC;IACX,SAAS,EAAE,CAAC,cAAc,CAAC,CAAC;IAC5B,KAAK,EAAE,EAAE,CAAC;CACV,CAAA;AAED,MAAM,CAAC,OAAO,WAAW,YAAY;IACpC,EAAE,CAAC,CAAC,SAAS,MAAM,kBAAkB,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI,CAAC;IAC3G,GAAG,CAAC,CAAC,SAAS,MAAM,kBAAkB,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;IAE9D,SAAgB,+BAA+B,uDAA8D;IAC7G,SAAgB,+BAA+B,uDAA8D;IAC7G,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAC,CAAS;IAExB,OAAO;IAQP,IAAW,SAAS,IAAI,MAAM,CAG7B;IAED,IAAW,OAAO,kDAEjB;IAED,IAAW,MAAM,WAGhB;IAED,IAAW,MAAM,WAGhB;IAED,IAAW,OAAO,WAEjB;IAED,IAAW,KAAK,uBAEf;IAED,IAAW,OAAO,IAAI,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,CAExD;IAED,IAAW,MAAM,YAEhB;IAEM,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM;IAYlB,YAAY,CAAC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChG,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,aAAa,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GACvE,OAAO,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;IAoB5B,IAAI;YASH,qBAAqB;CAqBnC"}
@@ -37,7 +37,6 @@ const events_1 = require("events");
37
37
  const Models = __importStar(require("./models/Models"));
38
38
  const ObservedClient_1 = require("./ObservedClient");
39
39
  const SingleExecutor_1 = require("./common/SingleExecutor");
40
- const callEventReports_1 = require("./common/callEventReports");
41
40
  class ObservedCall extends events_1.EventEmitter {
42
41
  static create(config, observer) {
43
42
  var _a;
@@ -149,16 +148,10 @@ class ObservedCall extends events_1.EventEmitter {
149
148
  this._clients.delete(clientId);
150
149
  this._model.clientIds = this._model.clientIds.filter((id) => id !== clientId);
151
150
  this.save().catch(() => void 0);
152
- if (this.observer.config.addJoinAndDetachClientEvent) {
153
- this.reports.addCallEventReport((0, callEventReports_1.createClientLeftEventReport)(this.serviceId, client.mediaUnitId, this.roomId, this.callId, client.clientId, client.joined, client.userId, client.marker));
154
- }
155
151
  });
156
152
  client.on('update', onUpdate);
157
153
  this._clients.set(clientId, client);
158
154
  this._model.clientIds.push(clientId);
159
- if (this.observer.config.addJoinAndDetachClientEvent) {
160
- this.reports.addCallEventReport((0, callEventReports_1.createClientJoinedEventReport)(this.serviceId, client.mediaUnitId, this.roomId, this.callId, client.clientId, client.joined, client.userId, client.marker));
161
- }
162
155
  return client;
163
156
  });
164
157
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { ClientSample, IceLocalCandidate } from '@observertc/sample-schemas-js';
2
+ import { ClientSample } from '@observertc/sample-schemas-js';
3
3
  import { ObservedCall } from './ObservedCall';
4
4
  import { StorageProvider } from './storages/StorageProvider';
5
5
  import { EventEmitter } from 'events';
@@ -12,12 +12,15 @@ export type ObservedClientConfig<AppData extends Record<string, unknown> = Recor
12
12
  appData: AppData;
13
13
  overflowingProcessingThreshold?: number;
14
14
  joined?: number;
15
+ /**
16
+ * before client-monitor-js 3.4.0 the client joined event was generated by the observer, this flag is to keep the compatibility with the old behavior
17
+ */
18
+ addJoinAndDetachClientEvent?: boolean;
15
19
  };
16
20
  export type ObservedClientEvents = {
17
21
  update: [];
18
22
  close: [];
19
23
  'processing-sample-overflow': [];
20
- 'candidate-pair-change': [];
21
24
  newpeerconnection: [ObservedPeerConnection];
22
25
  };
23
26
  export declare interface ObservedClient<AppData extends Record<string, unknown> = Record<string, unknown>> {
@@ -40,8 +43,35 @@ export declare class ObservedClient<AppData extends Record<string, unknown> = Re
40
43
  private _updated;
41
44
  private _acceptedSample;
42
45
  private _processingSample;
43
- private _iceLocalCandidate?;
44
- private _iceRemoteCandidate?;
46
+ private _timeZoneOffsetInHours?;
47
+ private _leaveReported;
48
+ totalInboundPacketsLost: number;
49
+ totalInboundPacketsReceived: number;
50
+ totalOutboundPacketsLost: number;
51
+ totalOutboundPacketsReceived: number;
52
+ totalOutboundPacketsSent: number;
53
+ totalDataChannelBytesSent: number;
54
+ totalDataChannelBytesReceived: number;
55
+ totalSentAudioBytes: number;
56
+ totalSentVideoBytes: number;
57
+ totalReceivedAudioBytes: number;
58
+ totalReceivedVideoBytes: number;
59
+ deltaInboundPacketsLost?: number;
60
+ deltaInboundPacketsReceived?: number;
61
+ deltaOutboundPacketsLost?: number;
62
+ deltaOutboundPacketsReceived?: number;
63
+ deltaOutboundPacketsSent?: number;
64
+ deltaDataChannelBytesSent?: number;
65
+ deltaDataChannelBytesReceived?: number;
66
+ deltaReceivedAudioBytes?: number;
67
+ deltaReceivedVideoBytes?: number;
68
+ deltaSentAudioBytes?: number;
69
+ deltaSentVideoBytes?: number;
70
+ avgRttInS?: number;
71
+ sendingAudioBitrate?: number;
72
+ sendingVideoBitrate?: number;
73
+ receivingAudioBitrate?: number;
74
+ receivingVideoBitrate?: number;
45
75
  readonly mediaDevices: string[];
46
76
  readonly codecs: string[];
47
77
  readonly userMediaErrors: string[];
@@ -54,8 +84,7 @@ export declare class ObservedClient<AppData extends Record<string, unknown> = Re
54
84
  get mediaUnitId(): string;
55
85
  get reports(): import("./ReportsCollector").ReportsCollector;
56
86
  get userId(): string | undefined;
57
- get iceLocalCandidate(): IceLocalCandidate | undefined;
58
- get iceRemoteCandidate(): IceLocalCandidate | undefined;
87
+ get timeZoneOffsetInHours(): number | undefined;
59
88
  get marker(): string | undefined;
60
89
  get browser(): Samples_ClientSample_Browser | undefined;
61
90
  get engine(): Samples_ClientSample_Engine | undefined;
@@ -69,5 +98,6 @@ export declare class ObservedClient<AppData extends Record<string, unknown> = Re
69
98
  accept(sample: ClientSample): Promise<void>;
70
99
  private _createPeerConnection;
71
100
  private _save;
101
+ private _addClientLeftReport;
72
102
  }
73
103
  //# sourceMappingURL=ObservedClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ObservedClient.d.ts","sourceRoot":"","sources":["../src/ObservedClient.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,iBAAi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IAAW,eAAe,IAAI,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAExE;IAEM,KAAK;IAWC,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;YA2e1C,qBAAqB;YAmBrB,KAAK;IAMnB,OAAO,CAAC,oBAAoB;CAe5B"}
@@ -53,6 +53,8 @@ const callMetaReports_1 = require("./common/callMetaReports");
53
53
  // eslint-disable-next-line camelcase
54
54
  const samples_pb_1 = require("./models/samples_pb");
55
55
  const utils_1 = require("./common/utils");
56
+ const callEventReports_1 = require("./common/callEventReports");
57
+ const CallEventType_1 = require("./common/CallEventType");
56
58
  const logger = (0, logger_1.createLogger)('ObservedClient');
57
59
  class ObservedClient extends events_1.EventEmitter {
58
60
  static create(config, call, storageProvider) {
@@ -73,6 +75,10 @@ class ObservedClient extends events_1.EventEmitter {
73
75
  if (alreadyInserted)
74
76
  throw new Error(`Client with id ${clientId} already exists`);
75
77
  result._overflowingProcessingThreshold = (_b = config.overflowingProcessingThreshold) !== null && _b !== void 0 ? _b : 0;
78
+ if (config.addJoinAndDetachClientEvent) {
79
+ call.reports.addCallEventReport((0, callEventReports_1.createClientJoinedEventReport)(call.serviceId, result.mediaUnitId, call.roomId, call.callId, result.clientId, result.joined, result.userId, result.marker));
80
+ }
81
+ result.once('close', () => result._addClientLeftReport());
76
82
  return result;
77
83
  });
78
84
  }
@@ -89,6 +95,18 @@ class ObservedClient extends events_1.EventEmitter {
89
95
  this._updated = Date.now();
90
96
  this._acceptedSample = 0;
91
97
  this._processingSample = 0;
98
+ this._leaveReported = false;
99
+ this.totalInboundPacketsLost = 0;
100
+ this.totalInboundPacketsReceived = 0;
101
+ this.totalOutboundPacketsLost = 0;
102
+ this.totalOutboundPacketsReceived = 0;
103
+ this.totalOutboundPacketsSent = 0;
104
+ this.totalDataChannelBytesSent = 0;
105
+ this.totalDataChannelBytesReceived = 0;
106
+ this.totalSentAudioBytes = 0;
107
+ this.totalSentVideoBytes = 0;
108
+ this.totalReceivedAudioBytes = 0;
109
+ this.totalReceivedVideoBytes = 0;
92
110
  this.mediaDevices = [];
93
111
  this.codecs = [];
94
112
  this.userMediaErrors = [];
@@ -123,11 +141,8 @@ class ObservedClient extends events_1.EventEmitter {
123
141
  get userId() {
124
142
  return this._model.userId;
125
143
  }
126
- get iceLocalCandidate() {
127
- return this._iceLocalCandidate;
128
- }
129
- get iceRemoteCandidate() {
130
- return this._iceRemoteCandidate;
144
+ get timeZoneOffsetInHours() {
145
+ return this._timeZoneOffsetInHours;
131
146
  }
132
147
  get marker() {
133
148
  return this._model.marker;
@@ -178,7 +193,7 @@ class ObservedClient extends events_1.EventEmitter {
178
193
  this.emit('processing-sample-overflow');
179
194
  }
180
195
  return this._execute(() => __awaiter(this, void 0, void 0, function* () {
181
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16;
196
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
182
197
  let executeSave = false;
183
198
  if (this.userId !== sample.userId) {
184
199
  this._model.userId = sample.userId;
@@ -188,6 +203,10 @@ class ObservedClient extends events_1.EventEmitter {
188
203
  this._model.marker = sample.marker;
189
204
  executeSave = true;
190
205
  }
206
+ if (this._timeZoneOffsetInHours !== sample.timeZoneOffsetInHours) {
207
+ this._timeZoneOffsetInHours = sample.timeZoneOffsetInHours;
208
+ executeSave = true;
209
+ }
191
210
  if (sample.os && (((_a = this._model.operationSystem) === null || _a === void 0 ? void 0 : _a.name) !== sample.os.name ||
192
211
  ((_b = this._model.operationSystem) === null || _b === void 0 ? void 0 : _b.version) !== sample.os.version ||
193
212
  ((_c = this._model.operationSystem) === null || _c === void 0 ? void 0 : _c.versionName) !== sample.os.versionName)) {
@@ -257,11 +276,26 @@ class ObservedClient extends events_1.EventEmitter {
257
276
  extensionType: extensionStats.type,
258
277
  });
259
278
  }
260
- for (let _17 of (_p = sample.customCallEvents) !== null && _p !== void 0 ? _p : []) {
261
- const { timestamp = Date.now() } = _17, callEvent = __rest(_17, ["timestamp"]);
279
+ for (let _16 of (_p = sample.customCallEvents) !== null && _p !== void 0 ? _p : []) {
280
+ const { timestamp = Date.now() } = _16, callEvent = __rest(_16, ["timestamp"]);
281
+ const peerConnection = this._peerConnections.get((_q = callEvent.peerConnectionId) !== null && _q !== void 0 ? _q : '');
282
+ switch (callEvent.name) {
283
+ case CallEventType_1.CallEventType.CLIENT_LEFT:
284
+ this._leaveReported = true;
285
+ break;
286
+ case CallEventType_1.CallEventType.ICE_CONNECTION_STATE_CHANGED:
287
+ peerConnection && callEvent.value && peerConnection.emit('iceconnectionstatechange', callEvent.value);
288
+ break;
289
+ case CallEventType_1.CallEventType.ICE_GATHERING_STATE_CHANGED:
290
+ peerConnection && callEvent.value && peerConnection.emit('icegatheringstatechange', callEvent.value);
291
+ break;
292
+ case CallEventType_1.CallEventType.PEER_CONNECTION_STATE_CHANGED:
293
+ peerConnection && callEvent.value && peerConnection.emit('connectionstatechange', callEvent.value);
294
+ break;
295
+ }
262
296
  this.reports.addCallEventReport(Object.assign({ serviceId: this.serviceId, mediaUnitId: this.mediaUnitId, roomId: this.roomId, callId: this.callId, clientId: this.clientId, userId: this.userId, timestamp }, callEvent));
263
297
  }
264
- for (const userMediaError of (_q = sample.userMediaErrors) !== null && _q !== void 0 ? _q : []) {
298
+ for (const userMediaError of (_r = sample.userMediaErrors) !== null && _r !== void 0 ? _r : []) {
265
299
  const callMetaReport = (0, callMetaReports_1.createCallMetaReport)(this.serviceId, this.mediaUnitId, this.roomId, this.callId, this.clientId, {
266
300
  type: callMetaReports_1.CallMetaType.USER_MEDIA_ERROR,
267
301
  payload: userMediaError,
@@ -269,14 +303,14 @@ class ObservedClient extends events_1.EventEmitter {
269
303
  this.reports.addCallMetaReport(callMetaReport);
270
304
  this.userMediaErrors.push(userMediaError);
271
305
  }
272
- for (const certificate of (_r = sample.certificates) !== null && _r !== void 0 ? _r : []) {
306
+ for (const certificate of (_s = sample.certificates) !== null && _s !== void 0 ? _s : []) {
273
307
  const callMetaReport = (0, callMetaReports_1.createCallMetaReport)(this.serviceId, this.mediaUnitId, this.roomId, this.callId, this.clientId, {
274
308
  type: callMetaReports_1.CallMetaType.CERTIFICATE,
275
309
  payload: certificate,
276
310
  }, this.userId);
277
311
  this.reports.addCallMetaReport(callMetaReport);
278
312
  }
279
- for (const codec of (_s = sample.codecs) !== null && _s !== void 0 ? _s : []) {
313
+ for (const codec of (_t = sample.codecs) !== null && _t !== void 0 ? _t : []) {
280
314
  const callMetaReport = (0, callMetaReports_1.createCallMetaReport)(this.serviceId, this.mediaUnitId, this.roomId, this.callId, this.clientId, {
281
315
  type: callMetaReports_1.CallMetaType.CODEC,
282
316
  payload: codec,
@@ -284,14 +318,14 @@ class ObservedClient extends events_1.EventEmitter {
284
318
  this.reports.addCallMetaReport(callMetaReport);
285
319
  codec.mimeType && this.codecs.push(codec.mimeType);
286
320
  }
287
- for (const iceServer of (_t = sample.iceServers) !== null && _t !== void 0 ? _t : []) {
321
+ for (const iceServer of (_u = sample.iceServers) !== null && _u !== void 0 ? _u : []) {
288
322
  const callMetaReport = (0, callMetaReports_1.createCallMetaReport)(this.serviceId, this.mediaUnitId, this.roomId, this.callId, this.clientId, {
289
323
  type: callMetaReports_1.CallMetaType.ICE_SERVER,
290
324
  payload: iceServer,
291
325
  }, this.userId);
292
326
  this.reports.addCallMetaReport(callMetaReport);
293
327
  }
294
- for (const mediaDevice of (_u = sample.mediaDevices) !== null && _u !== void 0 ? _u : []) {
328
+ for (const mediaDevice of (_v = sample.mediaDevices) !== null && _v !== void 0 ? _v : []) {
295
329
  const callMetaReport = (0, callMetaReports_1.createCallMetaReport)(this.serviceId, this.mediaUnitId, this.roomId, this.callId, this.clientId, {
296
330
  type: callMetaReports_1.CallMetaType.MEDIA_DEVICE,
297
331
  payload: mediaDevice,
@@ -299,77 +333,38 @@ class ObservedClient extends events_1.EventEmitter {
299
333
  this.reports.addCallMetaReport(callMetaReport);
300
334
  mediaDevice.label && this.mediaDevices.push(mediaDevice.label);
301
335
  }
302
- for (const mediaSource of (_v = sample.mediaSources) !== null && _v !== void 0 ? _v : []) {
336
+ for (const mediaSource of (_w = sample.mediaSources) !== null && _w !== void 0 ? _w : []) {
303
337
  const callMetaReport = (0, callMetaReports_1.createCallMetaReport)(this.serviceId, this.mediaUnitId, this.roomId, this.callId, this.clientId, {
304
338
  type: callMetaReports_1.CallMetaType.MEDIA_SOURCE,
305
339
  payload: mediaSource,
306
340
  }, this.userId);
307
341
  this.reports.addCallMetaReport(callMetaReport);
308
342
  }
309
- let selectedLocalCandidateId;
310
- let selectedRemoteCandidateId;
311
- for (const candidatePair of (_w = sample.iceCandidatePairs) !== null && _w !== void 0 ? _w : []) {
312
- if (candidatePair.nominated) {
313
- if (!selectedLocalCandidateId)
314
- selectedLocalCandidateId = candidatePair.localCandidateId;
315
- if (!selectedRemoteCandidateId)
316
- selectedRemoteCandidateId = candidatePair.remoteCandidateId;
317
- }
318
- const report = Object.assign(Object.assign({ serviceId: this.serviceId, mediaUnitId: this.mediaUnitId, roomId: this.roomId, callId: this.callId, clientId: this.clientId, userId: this.userId, timestamp: sample.timestamp }, candidatePair), { sampleSeq: -1 });
319
- this.reports.addIceCandidatePairReport(report);
320
- }
321
- let changeIceCandidatePair = false;
322
- for (const iceLocalCandidate of (_x = sample.iceLocalCandidates) !== null && _x !== void 0 ? _x : []) {
323
- if (iceLocalCandidate.id && selectedLocalCandidateId &&
324
- iceLocalCandidate.id === selectedLocalCandidateId &&
325
- ((_y = this._iceLocalCandidate) === null || _y === void 0 ? void 0 : _y.id) !== iceLocalCandidate.id) {
326
- this._iceLocalCandidate = iceLocalCandidate;
327
- changeIceCandidatePair = true;
328
- }
329
- const callMetaReport = (0, callMetaReports_1.createCallMetaReport)(this.serviceId, this.mediaUnitId, this.roomId, this.callId, this.clientId, {
330
- type: callMetaReports_1.CallMetaType.ICE_LOCAL_CANDIDATE,
331
- payload: iceLocalCandidate,
332
- }, this.userId);
333
- this.reports.addCallMetaReport(callMetaReport);
334
- }
335
- for (const iceRemoteCandidate of (_z = sample.iceRemoteCandidates) !== null && _z !== void 0 ? _z : []) {
336
- if (iceRemoteCandidate.id && selectedRemoteCandidateId &&
337
- iceRemoteCandidate.id === selectedRemoteCandidateId &&
338
- ((_0 = this._iceRemoteCandidate) === null || _0 === void 0 ? void 0 : _0.id) !== iceRemoteCandidate.id) {
339
- this._iceRemoteCandidate = iceRemoteCandidate;
340
- changeIceCandidatePair = true;
341
- }
342
- const callMetaReport = (0, callMetaReports_1.createCallMetaReport)(this.serviceId, this.mediaUnitId, this.roomId, this.callId, this.clientId, {
343
- type: callMetaReports_1.CallMetaType.ICE_REMOTE_CANDIDATE,
344
- payload: iceRemoteCandidate,
345
- }, this.userId);
346
- this.reports.addCallMetaReport(callMetaReport);
347
- }
348
- for (const transport of (_1 = sample.pcTransports) !== null && _1 !== void 0 ? _1 : []) {
343
+ for (const transport of (_x = sample.pcTransports) !== null && _x !== void 0 ? _x : []) {
349
344
  try {
350
- const peerConnection = (_2 = this._peerConnections.get(transport.transportId)) !== null && _2 !== void 0 ? _2 : yield this._createPeerConnection(transport.peerConnectionId);
345
+ const peerConnection = (_y = this._peerConnections.get(transport.transportId)) !== null && _y !== void 0 ? _y : yield this._createPeerConnection(transport.peerConnectionId);
351
346
  peerConnection.update(transport, sample.timestamp);
352
347
  }
353
348
  catch (err) {
354
349
  logger.error(`Error creating peer connection: ${err === null || err === void 0 ? void 0 : err.message}`);
355
350
  }
356
351
  }
357
- for (const track of (_3 = sample.inboundAudioTracks) !== null && _3 !== void 0 ? _3 : []) {
352
+ for (const track of (_z = sample.inboundAudioTracks) !== null && _z !== void 0 ? _z : []) {
358
353
  if (!track.peerConnectionId || !track.trackId) {
359
354
  logger.warn(`InboundAudioTrack without peerConnectionId or trackId: ${JSON.stringify(track)}`);
360
355
  continue;
361
356
  }
362
357
  try {
363
- const peerConnection = (_4 = this._peerConnections.get(track.peerConnectionId)) !== null && _4 !== void 0 ? _4 : yield this._createPeerConnection(track.peerConnectionId);
358
+ const peerConnection = (_0 = this._peerConnections.get(track.peerConnectionId)) !== null && _0 !== void 0 ? _0 : yield this._createPeerConnection(track.peerConnectionId);
364
359
  if (!peerConnection)
365
360
  continue;
366
- const inboundAudioTrack = (_5 = peerConnection.inboundAudioTracks.get(track.trackId)) !== null && _5 !== void 0 ? _5 : yield peerConnection.createInboundAudioTrack({
361
+ const inboundAudioTrack = (_1 = peerConnection.inboundAudioTracks.get(track.trackId)) !== null && _1 !== void 0 ? _1 : yield peerConnection.createInboundAudioTrack({
367
362
  trackId: track.trackId,
368
363
  sfuStreamId: track.sfuStreamId,
369
364
  sfuSinkId: track.sfuSinkId,
370
365
  });
371
366
  yield inboundAudioTrack.update(track, sample.timestamp);
372
- const remoteOutboundTrack = this.call.sfuStreamIdToOutboundAudioTrack.get((_6 = track.sfuStreamId) !== null && _6 !== void 0 ? _6 : '');
367
+ const remoteOutboundTrack = this.call.sfuStreamIdToOutboundAudioTrack.get((_2 = track.sfuStreamId) !== null && _2 !== void 0 ? _2 : '');
373
368
  if (remoteOutboundTrack && inboundAudioTrack.sfuStreamId && !remoteOutboundTrack.remoteInboundTracks.has(inboundAudioTrack.sfuStreamId)) {
374
369
  remoteOutboundTrack.connectInboundTrack(inboundAudioTrack);
375
370
  }
@@ -378,7 +373,7 @@ class ObservedClient extends events_1.EventEmitter {
378
373
  logger.error(`Error creating inbound audio track: ${err === null || err === void 0 ? void 0 : err.message}`);
379
374
  }
380
375
  }
381
- for (const track of (_7 = sample.inboundVideoTracks) !== null && _7 !== void 0 ? _7 : []) {
376
+ for (const track of (_3 = sample.inboundVideoTracks) !== null && _3 !== void 0 ? _3 : []) {
382
377
  if (!track.peerConnectionId || !track.trackId) {
383
378
  logger.warn(`InboundVideoTrack without peerConnectionId or trackId: ${JSON.stringify(track)}`);
384
379
  continue;
@@ -391,16 +386,16 @@ class ObservedClient extends events_1.EventEmitter {
391
386
  continue;
392
387
  }
393
388
  try {
394
- const peerConnection = (_8 = this._peerConnections.get(track.peerConnectionId)) !== null && _8 !== void 0 ? _8 : yield this._createPeerConnection(track.peerConnectionId);
389
+ const peerConnection = (_4 = this._peerConnections.get(track.peerConnectionId)) !== null && _4 !== void 0 ? _4 : yield this._createPeerConnection(track.peerConnectionId);
395
390
  if (!peerConnection)
396
391
  continue;
397
- const inboundVideoTrack = (_9 = peerConnection.inboundVideoTracks.get(track.trackId)) !== null && _9 !== void 0 ? _9 : yield peerConnection.createInboundVideoTrack({
392
+ const inboundVideoTrack = (_5 = peerConnection.inboundVideoTracks.get(track.trackId)) !== null && _5 !== void 0 ? _5 : yield peerConnection.createInboundVideoTrack({
398
393
  trackId: track.trackId,
399
394
  sfuStreamId: track.sfuStreamId,
400
395
  sfuSinkId: track.sfuSinkId,
401
396
  });
402
397
  yield inboundVideoTrack.update(track, sample.timestamp);
403
- const remoteOutboundTrack = this.call.sfuStreamIdToOutboundVideoTrack.get((_10 = inboundVideoTrack.sfuStreamId) !== null && _10 !== void 0 ? _10 : '');
398
+ const remoteOutboundTrack = this.call.sfuStreamIdToOutboundVideoTrack.get((_6 = inboundVideoTrack.sfuStreamId) !== null && _6 !== void 0 ? _6 : '');
404
399
  if (remoteOutboundTrack && inboundVideoTrack.sfuStreamId && !remoteOutboundTrack.remoteInboundTracks.has(inboundVideoTrack.sfuStreamId)) {
405
400
  remoteOutboundTrack.connectInboundTrack(inboundVideoTrack);
406
401
  }
@@ -409,16 +404,16 @@ class ObservedClient extends events_1.EventEmitter {
409
404
  logger.error(`Error creating inbound video track: ${err === null || err === void 0 ? void 0 : err.message}`);
410
405
  }
411
406
  }
412
- for (const track of (_11 = sample.outboundAudioTracks) !== null && _11 !== void 0 ? _11 : []) {
407
+ for (const track of (_7 = sample.outboundAudioTracks) !== null && _7 !== void 0 ? _7 : []) {
413
408
  if (!track.peerConnectionId || !track.trackId) {
414
409
  logger.warn(`OutboundAudioTrack without peerConnectionId or trackId: ${JSON.stringify(track)}`);
415
410
  continue;
416
411
  }
417
412
  try {
418
- const peerConnection = (_12 = this._peerConnections.get(track.peerConnectionId)) !== null && _12 !== void 0 ? _12 : yield this._createPeerConnection(track.peerConnectionId);
413
+ const peerConnection = (_8 = this._peerConnections.get(track.peerConnectionId)) !== null && _8 !== void 0 ? _8 : yield this._createPeerConnection(track.peerConnectionId);
419
414
  if (!peerConnection)
420
415
  continue;
421
- const outboundAudioTrack = (_13 = peerConnection.outboundAudioTracks.get(track.trackId)) !== null && _13 !== void 0 ? _13 : yield peerConnection.createOutboundAudioTrack({
416
+ const outboundAudioTrack = (_9 = peerConnection.outboundAudioTracks.get(track.trackId)) !== null && _9 !== void 0 ? _9 : yield peerConnection.createOutboundAudioTrack({
422
417
  trackId: track.trackId,
423
418
  sfuStreamId: track.sfuStreamId,
424
419
  });
@@ -428,16 +423,16 @@ class ObservedClient extends events_1.EventEmitter {
428
423
  logger.error(`Error creating outbound audio track: ${err === null || err === void 0 ? void 0 : err.message}`);
429
424
  }
430
425
  }
431
- for (const track of (_14 = sample.outboundVideoTracks) !== null && _14 !== void 0 ? _14 : []) {
426
+ for (const track of (_10 = sample.outboundVideoTracks) !== null && _10 !== void 0 ? _10 : []) {
432
427
  if (!track.peerConnectionId || !track.trackId) {
433
428
  logger.warn(`OutboundVideoTrack without peerConnectionId or trackId: ${JSON.stringify(track)}`);
434
429
  continue;
435
430
  }
436
431
  try {
437
- const peerConnection = (_15 = this._peerConnections.get(track.peerConnectionId)) !== null && _15 !== void 0 ? _15 : yield this._createPeerConnection(track.peerConnectionId);
432
+ const peerConnection = (_11 = this._peerConnections.get(track.peerConnectionId)) !== null && _11 !== void 0 ? _11 : yield this._createPeerConnection(track.peerConnectionId);
438
433
  if (!peerConnection)
439
434
  continue;
440
- const outboundVideoTrack = (_16 = peerConnection.outboundVideoTracks.get(track.trackId)) !== null && _16 !== void 0 ? _16 : yield peerConnection.createOutboundVideoTrack({
435
+ const outboundVideoTrack = (_12 = peerConnection.outboundVideoTracks.get(track.trackId)) !== null && _12 !== void 0 ? _12 : yield peerConnection.createOutboundVideoTrack({
441
436
  trackId: track.trackId,
442
437
  sfuStreamId: track.sfuStreamId,
443
438
  });
@@ -447,8 +442,65 @@ class ObservedClient extends events_1.EventEmitter {
447
442
  logger.error(`Error creating outbound video track: ${err === null || err === void 0 ? void 0 : err.message}`);
448
443
  }
449
444
  }
450
- if (changeIceCandidatePair) {
451
- this.emit('candidate-pair-change');
445
+ for (const iceLocalCandidate of (_13 = sample.iceLocalCandidates) !== null && _13 !== void 0 ? _13 : []) {
446
+ if (!iceLocalCandidate.peerConnectionId) {
447
+ logger.warn(`Local ice candidate without peerConnectionId: ${JSON.stringify(iceLocalCandidate)}`);
448
+ continue;
449
+ }
450
+ const peerConnection = this._peerConnections.get(iceLocalCandidate.peerConnectionId);
451
+ if (!peerConnection) {
452
+ logger.debug(`Peer connection ${iceLocalCandidate.peerConnectionId} not found for ice local candidate ${iceLocalCandidate.id}`);
453
+ continue;
454
+ }
455
+ peerConnection.ICE.addLocalCandidate(iceLocalCandidate);
456
+ }
457
+ for (const iceRemoteCandidate of (_14 = sample.iceRemoteCandidates) !== null && _14 !== void 0 ? _14 : []) {
458
+ if (!iceRemoteCandidate.peerConnectionId) {
459
+ logger.warn(`Remote ice candidate without peerConnectionId: ${JSON.stringify(iceRemoteCandidate)}`);
460
+ continue;
461
+ }
462
+ const peerConnection = this._peerConnections.get(iceRemoteCandidate.peerConnectionId);
463
+ if (!peerConnection) {
464
+ logger.debug(`Peer connection ${iceRemoteCandidate.peerConnectionId} not found for ice remote candidate ${iceRemoteCandidate.id}`);
465
+ continue;
466
+ }
467
+ peerConnection.ICE.addRemoteCandidate(iceRemoteCandidate);
468
+ }
469
+ for (const candidatePair of (_15 = sample.iceCandidatePairs) !== null && _15 !== void 0 ? _15 : []) {
470
+ const peerConnection = this._peerConnections.get(candidatePair.peerConnectionId);
471
+ if (!peerConnection) {
472
+ logger.debug(`Peer connection ${candidatePair.peerConnectionId} not found for ice candidate pair ${candidatePair.localCandidateId}, ${candidatePair.remoteCandidateId}`);
473
+ continue;
474
+ }
475
+ peerConnection.ICE.update(candidatePair, sample.timestamp);
476
+ }
477
+ // close entries that are idle for too long
478
+ if (this.call.observer.config.maxEntryIdleTimeInMs && this._updated < sample.timestamp) {
479
+ for (const peerConnection of this._peerConnections.values()) {
480
+ if (this.call.observer.config.maxEntryIdleTimeInMs < sample.timestamp - peerConnection.updated) {
481
+ logger.debug(`Closing peer connection ${peerConnection.peerConnectionId} due to inactivity`);
482
+ peerConnection.close();
483
+ continue;
484
+ }
485
+ for (const track of peerConnection.inboundAudioTracks.values()) {
486
+ if (this.call.observer.config.maxEntryIdleTimeInMs < sample.timestamp - track.updated) {
487
+ logger.debug(`Closing inbound audio track ${track.trackId} due to inactivity`);
488
+ track.close();
489
+ }
490
+ }
491
+ for (const track of peerConnection.inboundVideoTracks.values()) {
492
+ if (this.call.observer.config.maxEntryIdleTimeInMs < sample.timestamp - track.updated) {
493
+ logger.debug(`Closing inbound video track ${track.trackId} due to inactivity`);
494
+ track.close();
495
+ }
496
+ }
497
+ for (const track of peerConnection.outboundAudioTracks.values()) {
498
+ if (this.call.observer.config.maxEntryIdleTimeInMs < sample.timestamp - track.updated) {
499
+ logger.debug(`Closing outbound audio track ${track.trackId} due to inactivity`);
500
+ track.close();
501
+ }
502
+ }
503
+ }
452
504
  }
453
505
  if (executeSave)
454
506
  yield this._save();
@@ -483,5 +535,11 @@ class ObservedClient extends events_1.EventEmitter {
483
535
  return this._storageProvider.clientStorage.set(this.clientId, this._model);
484
536
  });
485
537
  }
538
+ _addClientLeftReport() {
539
+ if (this._leaveReported)
540
+ return;
541
+ this._leaveReported = true;
542
+ this.reports.addCallEventReport((0, callEventReports_1.createClientLeftEventReport)(this.serviceId, this.mediaUnitId, this.roomId, this.callId, this.clientId, this.joined, this.userId, this.marker));
543
+ }
486
544
  }
487
545
  exports.ObservedClient = ObservedClient;
@@ -0,0 +1,47 @@
1
+ /// <reference types="node" />
2
+ import { IceCandidatePair, IceLocalCandidate, IceRemoteCandidate } from '@observertc/sample-schemas-js';
3
+ import { EventEmitter } from 'events';
4
+ import { ObservedPeerConnection } from './ObservedPeerConnection';
5
+ export type ObservedICEEvents = {
6
+ update: [];
7
+ 'new-local-candidate': [IceLocalCandidate];
8
+ 'new-remote-candidate': [IceRemoteCandidate];
9
+ 'new-selected-candidate-pair': [
10
+ {
11
+ localCandidate: IceLocalCandidate;
12
+ remoteCandidate: IceRemoteCandidate;
13
+ }
14
+ ];
15
+ close: [];
16
+ };
17
+ export declare interface ObservedICE {
18
+ on<U extends keyof ObservedICEEvents>(event: U, listener: (...args: ObservedICEEvents[U]) => void): this;
19
+ off<U extends keyof ObservedICEEvents>(event: U, listener: (...args: ObservedICEEvents[U]) => void): this;
20
+ once<U extends keyof ObservedICEEvents>(event: U, listener: (...args: ObservedICEEvents[U]) => void): this;
21
+ emit<U extends keyof ObservedICEEvents>(event: U, ...args: ObservedICEEvents[U]): boolean;
22
+ }
23
+ export declare class ObservedICE extends EventEmitter {
24
+ readonly peerConnection: ObservedPeerConnection;
25
+ static create(peerConnection: ObservedPeerConnection): ObservedICE;
26
+ private readonly _localCandidates;
27
+ private readonly _remoteCandidates;
28
+ private _selectedLocalCandidateId?;
29
+ private _selectedRemoteCandidateId?;
30
+ private _updated;
31
+ private _stats?;
32
+ private _closed;
33
+ private constructor();
34
+ get reports(): import("./ReportsCollector").ReportsCollector;
35
+ get localCandidates(): ReadonlyMap<string, IceLocalCandidate>;
36
+ get remoteCandidates(): ReadonlyMap<string, IceRemoteCandidate>;
37
+ get selectedLocalCandidate(): IceLocalCandidate | undefined;
38
+ get selectedRemoteCandidate(): IceLocalCandidate | undefined;
39
+ get stats(): IceCandidatePair | undefined;
40
+ get updated(): number;
41
+ get closed(): boolean;
42
+ close(): void;
43
+ addLocalCandidate(candidate: IceLocalCandidate): void;
44
+ addRemoteCandidate(candidate: IceRemoteCandidate): void;
45
+ update(candidatePair: IceCandidatePair, timestamp: number): void;
46
+ }
47
+ //# sourceMappingURL=ObservedICE.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObservedICE.d.ts","sourceRoot":"","sources":["../src/ObservedICE.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxG,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAIlE,MAAM,MAAM,iBAAiB,GAAG;IAC/B,MAAM,EAAE,EAAE,CAAC;IACX,qBAAqB,EAAE,CAAC,iBAAiB,CAAC,CAAC;IAC3C,sBAAsB,EAAE,CAAC,kBAAkB,CAAC,CAAC;IAC7C,6BAA6B,EAAE;QAAC;YAC/B,cAAc,EAAE,iBAAiB,CAAC;YAClC,eAAe,EAAE,kBAAkB,CAAC;SACpC;KAAC,CAAC;IACH,KAAK,EAAE,EAAE,CAAC;CACV,CAAC;AAEF,MAAM,CAAC,OAAO,WAAW,WAAW;IACnC,EAAE,CAAC,CAAC,SAAS,MAAM,iBAAiB,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI,CAAC;IACzG,GAAG,CAAC,CAAC,SAAS,MAAM,iBAAiB,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI,CAAC;IAC1G,IAAI,CAAC,CAAC,SAA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