@observertc/observer-js 1.0.1-646d974.0 → 1.0.1-72a904d.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,7 @@ import { CalculatedScore } from './scores/CalculatedScore';
7
7
  import { Detectors } from './detectors/Detectors';
8
8
  import { RemoteTrackResolver } from './utils/RemoteTrackResolver';
9
9
  import { Updater } from './updaters/Updater';
10
+ import { ObservedCallSummary } from './ObservedCallSummary';
10
11
  export type ObservedCallSettings<AppData extends Record<string, unknown> = Record<string, unknown>> = {
11
12
  callId: string;
12
13
  appData?: AppData;
@@ -20,6 +21,8 @@ export type ObservedCallEvents = {
20
21
  empty: [];
21
22
  'not-empty': [];
22
23
  close: [];
24
+ started: [];
25
+ ended: [];
23
26
  };
24
27
  export declare interface ObservedCall {
25
28
  on<U extends keyof ObservedCallEvents>(event: U, listener: (...args: ObservedCallEvents[U]) => void): this;
@@ -65,8 +68,7 @@ export declare class ObservedCall<AppData extends Record<string, unknown> = Reco
65
68
  appData: AppData;
66
69
  closed: boolean;
67
70
  startedAt?: number;
68
- endedAt?: number;
69
- closedAt?: number;
71
+ ended?: number;
70
72
  private _callStartedEvent;
71
73
  private _callEndedEvent;
72
74
  constructor(settings: ObservedCallSettings<AppData>, observer: Observer);
@@ -79,5 +81,9 @@ export declare class ObservedCall<AppData extends Record<string, unknown> = Reco
79
81
  private _onClientUpdate;
80
82
  private _clientJoined;
81
83
  private _clientLeft;
84
+ emitCallStartedEvent(): void;
85
+ emitCallEndedEvent(): void;
86
+ resetSummaryMetrics(): void;
87
+ createSummary(): ObservedCallSummary;
82
88
  }
83
89
  //# sourceMappingURL=ObservedCall.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ObservedCall.d.ts","sourceRoot":"","sources":["../src/ObservedCall.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,s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SAAK;IAC7B,yBAAyB,SAAK;IAC9B,yBAAyB,SAAK;IAC9B,6BAA6B,SAAK;IAElC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,UAAS;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEtB,OAAO,CAAC,iBAAiB,CAGvB;IACF,OAAO,CAAC,eAAe,CAErB;gBAGD,QAAQ,EAAE,oBAAoB,CAAC,OAAO,CAAC,EACvB,QAAQ,EAAE,QAAQ;IA8CnC,IAAW,eAAe,WAEzB;IAED,IAAW,KAAK,uBAEf;IAEM,KAAK;IAcL,iBAAiB,CAAC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,CAAC,aAAa,CAAC,GAAG,SAAS;IAMvJ,oBAAoB,CAAC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,sBAAsB,CAAC,aAAa,CAAC,GAAG,cAAc,CAAC,aAAa,CAAC;IAsC7K,MAAM;IA+Bb,OAAO,CAAC,eAAe;IAwBvB,OAAO,CAAC,aAAa;IAkBrB,OAAO,CAAC,WAAW;IAMZ,oBAAoB;IASpB,kBAAkB;IAOlB,mBAAmB;IAuBnB,aAAa,IAAI,mBAAmB;CAuB3C"}
@@ -49,8 +49,7 @@ class ObservedCall extends events_1.EventEmitter {
49
49
  appData;
50
50
  closed = false;
51
51
  startedAt;
52
- endedAt;
53
- closedAt;
52
+ ended;
54
53
  _callStartedEvent;
55
54
  _callEndedEvent;
56
55
  constructor(settings, observer) {
@@ -100,11 +99,12 @@ class ObservedCall extends events_1.EventEmitter {
100
99
  close() {
101
100
  if (this.closed)
102
101
  return;
103
- this.update(); // last update before closing
104
102
  this.closed = true;
105
103
  this.updater?.close();
106
104
  [...this.observedClients.values()].forEach((client) => client.close());
107
- this.closedAt = Date.now();
105
+ // make sure to emit the events
106
+ this.emitCallStartedEvent();
107
+ this.emitCallEndedEvent();
108
108
  this.emit('close');
109
109
  }
110
110
  getObservedClient(clientId) {
@@ -130,7 +130,7 @@ class ObservedCall extends events_1.EventEmitter {
130
130
  if (this.observedClients.size === 0) {
131
131
  this.emit('empty');
132
132
  }
133
- ++this.totalRemovedClients;
133
+ --this.totalRemovedClients;
134
134
  });
135
135
  result.on('update', onUpdate);
136
136
  result.on('joined', joined);
@@ -156,6 +156,9 @@ class ObservedCall extends events_1.EventEmitter {
156
156
  this.numberOfOutboundRtpStreams += client.numberOfOutboundRtpStreams;
157
157
  this.numberOfPeerConnections += client.numberOfPeerConnections;
158
158
  this.numberOfDataChannels += client.numberOfDataChannels;
159
+ if (client.usingTURN) {
160
+ this.clientsUsedTurn.add(client.clientId);
161
+ }
159
162
  }
160
163
  this.detectors.update();
161
164
  this.scoreCalculator.update();
@@ -168,12 +171,12 @@ class ObservedCall extends events_1.EventEmitter {
168
171
  }
169
172
  _onClientUpdate(client) {
170
173
  this.totalClientsReceivedAudioBytes += client.deltaReceivedAudioBytes;
174
+ this.totalClientsSentAudioBytes += client.deltaSentAudioBytes;
171
175
  this.totalClientsReceivedVideoBytes += client.deltaReceivedVideoBytes;
176
+ this.totalClientsReceivedVideoBytes += client.deltaSentVideoBytes;
172
177
  this.totalClientsReceivedDataChannelBytes += client.deltaDataChannelBytesReceived;
173
- this.totalClientsReceivedBytes += client.deltaTransportReceivedBytes;
174
- this.totalClientsSentAudioBytes += client.deltaSentAudioBytes;
175
- this.totalClientsSentVideoBytes += client.deltaSentVideoBytes;
176
178
  this.totalClientsSentDataChannelBytes += client.deltaDataChannelBytesSent;
179
+ this.totalClientsReceivedBytes += client.deltaTransportReceivedBytes;
177
180
  this.totalClientsSentBytes += client.deltaTransportSentBytes;
178
181
  this.deltaRttLt50Measurements += client.deltaRttLt50Measurements;
179
182
  this.deltaRttLt150Measurements += client.deltaRttLt150Measurements;
@@ -185,19 +188,76 @@ class ObservedCall extends events_1.EventEmitter {
185
188
  this.totalRttGtOrEq300Measurements += client.deltaRttGtOrEq300Measurements;
186
189
  this.deltaNumberOfIssues += client.deltaNumberOfIssues;
187
190
  this.numberOfIssues += client.deltaNumberOfIssues;
188
- if (client.usingTURN) {
189
- this.clientsUsedTurn.add(client.clientId);
190
- }
191
191
  }
192
192
  _clientJoined(client) {
193
193
  if (!client.joinedAt)
194
194
  return;
195
195
  this.startedAt = Math.min(this.startedAt ?? client.joinedAt, client.joinedAt);
196
+ if (this._callStartedEvent.emitted)
197
+ return;
198
+ if (this._callStartedEvent.timer) {
199
+ if (1 < this.observedClients.size) {
200
+ this.emitCallStartedEvent();
201
+ }
202
+ return;
203
+ }
204
+ this._callStartedEvent.timer = setTimeout(() => {
205
+ this.emitCallStartedEvent();
206
+ }, 5000);
196
207
  }
197
208
  _clientLeft(client) {
198
209
  if (!client.leftAt)
199
210
  return;
200
- this.endedAt = Math.max(this.endedAt ?? client.leftAt, client.leftAt);
211
+ this.ended = Math.max(this.ended ?? client.leftAt, client.leftAt);
212
+ }
213
+ emitCallStartedEvent() {
214
+ if (this._callStartedEvent.emitted)
215
+ return;
216
+ this._callStartedEvent.emitted = true;
217
+ clearTimeout(this._callStartedEvent.timer);
218
+ this._callStartedEvent.timer = undefined;
219
+ this.emit('started');
220
+ }
221
+ emitCallEndedEvent() {
222
+ if (this._callEndedEvent.emitted)
223
+ return;
224
+ this._callEndedEvent.emitted = true;
225
+ this.emit('ended');
226
+ }
227
+ resetSummaryMetrics() {
228
+ this.totalAddedClients = 0;
229
+ this.totalRemovedClients = 0;
230
+ this.totalClientsReceivedAudioBytes = 0;
231
+ this.totalClientsReceivedVideoBytes = 0;
232
+ this.totalClientsReceivedBytes = 0;
233
+ this.totalClientsSentAudioBytes = 0;
234
+ this.totalClientsSentVideoBytes = 0;
235
+ this.totalClientsSentBytes = 0;
236
+ this.totalRttLt50Measurements = 0;
237
+ this.totalRttLt150Measurements = 0;
238
+ this.totalRttLt300Measurements = 0;
239
+ this.totalRttGtOrEq300Measurements = 0;
240
+ this.numberOfIssues = 0;
241
+ this.clientsUsedTurn.clear();
242
+ }
243
+ createSummary() {
244
+ return {
245
+ currentActiveClients: this.observedClients.size,
246
+ totalAddedClients: this.totalAddedClients,
247
+ totalRemovedClients: this.totalRemovedClients,
248
+ totalClientsReceivedAudioBytes: this.totalClientsReceivedBytes,
249
+ totalClientsReceivedVideoBytes: this.totalClientsReceivedVideoBytes,
250
+ totalClientsReceivedBytes: this.totalClientsReceivedBytes,
251
+ totalClientsSentAudioBytes: this.totalClientsSentAudioBytes,
252
+ totalClientsSentVideoBytes: this.totalClientsSentVideoBytes,
253
+ totalClientsSentBytes: this.totalClientsSentBytes,
254
+ totalRttLt50Measurements: this.totalRttLt50Measurements,
255
+ totalRttLt150Measurements: this.totalRttLt150Measurements,
256
+ totalRttLt300Measurements: this.totalRttLt300Measurements,
257
+ totalRttGtOrEq300Measurements: this.totalRttGtOrEq300Measurements,
258
+ numberOfIssues: this.numberOfIssues,
259
+ numberOfClientsUsedTurn: this.clientsUsedTurn.size,
260
+ };
201
261
  }
202
262
  }
203
263
  exports.ObservedCall = ObservedCall;
@@ -6,6 +6,7 @@ import * as MetaData from './schema/ClientMetaTypes';
6
6
  import { ObservedCall } from './ObservedCall';
7
7
  import { CalculatedScore } from './scores/CalculatedScore';
8
8
  import { Detectors } from './detectors/Detectors';
9
+ import { ObservedClientSummary } from './ObservedClientSummary';
9
10
  export type ObservedClientSettings<AppData extends Record<string, unknown> = Record<string, unknown>> = {
10
11
  clientId: string;
11
12
  appData?: AppData;
@@ -46,14 +47,12 @@ export declare class ObservedClient<AppData extends Record<string, unknown> = Re
46
47
  closed: boolean;
47
48
  joinedAt?: number;
48
49
  leftAt?: number;
49
- closedAt?: number;
50
50
  operationSystem?: MetaData.OperationSystem;
51
51
  engine?: MetaData.Engine;
52
52
  platform?: MetaData.Platform;
53
53
  browser?: MetaData.Browser;
54
54
  mediaConstraints: string[];
55
55
  usingTURN: boolean;
56
- usingTCP: boolean;
57
56
  availableOutgoingBitrate: number;
58
57
  availableIncomingBitrate: number;
59
58
  totalInboundPacketsLost: number;
@@ -80,15 +79,14 @@ export declare class ObservedClient<AppData extends Record<string, unknown> = Re
80
79
  deltaInboundPacketsLost: number;
81
80
  deltaInboundPacketsReceived: number;
82
81
  deltaOutboundPacketsSent: number;
82
+ deltaRttInMsMeasurements: number[];
83
83
  deltaTransportSentBytes: number;
84
84
  deltaTransportReceivedBytes: number;
85
85
  deltaRttLt50Measurements: number;
86
86
  deltaRttLt150Measurements: number;
87
87
  deltaRttLt300Measurements: number;
88
88
  deltaRttGtOrEq300Measurements: number;
89
- currentMaxRttInMs?: number;
90
- currentMinRttInMs?: number;
91
- currentAvgRttInMs?: number;
89
+ currentRttInMs?: number;
92
90
  sendingAudioBitrate: number;
93
91
  sendingVideoBitrate: number;
94
92
  receivingAudioBitrate: number;
@@ -105,7 +103,7 @@ export declare class ObservedClient<AppData extends Record<string, unknown> = Re
105
103
  deltaNumberOfIssues: number;
106
104
  totalScoreSum: number;
107
105
  numberOfScoreMeasurements: number;
108
- totalNumberOfIssues: number;
106
+ numberOfIssues: number;
109
107
  readonly mediaDevices: MetaData.MediaDeviceInfo[];
110
108
  issues: ClientIssue[];
111
109
  constructor(settings: ObservedClientSettings<AppData>, call: ObservedCall);
@@ -118,5 +116,8 @@ export declare class ObservedClient<AppData extends Record<string, unknown> = Re
118
116
  addIssue(issue: ClientIssue): void;
119
117
  addExtensionStats(stats: ExtensionStat): void;
120
118
  private _updatePeerConnection;
119
+ resetSummaryMetrics(): void;
120
+ createSummary(): ObservedClientSummary;
121
+ private _updateRttMeasurements;
121
122
  }
122
123
  //# sourceMappingURL=ObservedClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ObservedClient.d.ts","sourceRoot":"","sources":["../src/ObservedClient.ts"],"names":[],"mappings":";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25,6 @@ class ObservedClient extends events_1.EventEmitter {
25
25
  closed = false;
26
26
  joinedAt;
27
27
  leftAt;
28
- closedAt;
29
28
  // the timestamp of the CLIENT_JOINED event
30
29
  operationSystem;
31
30
  engine;
@@ -33,7 +32,6 @@ class ObservedClient extends events_1.EventEmitter {
33
32
  browser;
34
33
  mediaConstraints = [];
35
34
  usingTURN = false;
36
- usingTCP = false;
37
35
  availableOutgoingBitrate = 0;
38
36
  availableIncomingBitrate = 0;
39
37
  totalInboundPacketsLost = 0;
@@ -60,15 +58,14 @@ class ObservedClient extends events_1.EventEmitter {
60
58
  deltaInboundPacketsLost = 0;
61
59
  deltaInboundPacketsReceived = 0;
62
60
  deltaOutboundPacketsSent = 0;
61
+ deltaRttInMsMeasurements = [];
63
62
  deltaTransportSentBytes = 0;
64
63
  deltaTransportReceivedBytes = 0;
65
64
  deltaRttLt50Measurements = 0;
66
65
  deltaRttLt150Measurements = 0;
67
66
  deltaRttLt300Measurements = 0;
68
67
  deltaRttGtOrEq300Measurements = 0;
69
- currentMaxRttInMs;
70
- currentMinRttInMs;
71
- currentAvgRttInMs;
68
+ currentRttInMs;
72
69
  sendingAudioBitrate = 0;
73
70
  sendingVideoBitrate = 0;
74
71
  receivingAudioBitrate = 0;
@@ -85,7 +82,7 @@ class ObservedClient extends events_1.EventEmitter {
85
82
  deltaNumberOfIssues = 0;
86
83
  totalScoreSum = 0;
87
84
  numberOfScoreMeasurements = 0;
88
- totalNumberOfIssues = 0;
85
+ numberOfIssues = 0;
89
86
  mediaDevices = [];
90
87
  issues = [];
91
88
  constructor(settings, call) {
@@ -107,7 +104,6 @@ class ObservedClient extends events_1.EventEmitter {
107
104
  return;
108
105
  this.closed = true;
109
106
  Array.from(this.observedPeerConnections.values()).forEach((peerConnection) => peerConnection.close());
110
- this.closedAt = Date.now();
111
107
  this.emit('close');
112
108
  }
113
109
  accept(sample) {
@@ -116,8 +112,6 @@ class ObservedClient extends events_1.EventEmitter {
116
112
  const now = Date.now();
117
113
  const elapsedInMs = now - this.updated;
118
114
  const elapsedInSeconds = elapsedInMs / 1000;
119
- let sumOfRtts = 0;
120
- let numberOfRttMeasurements = 0;
121
115
  ++this.acceptedSamples;
122
116
  this.availableIncomingBitrate = 0;
123
117
  this.availableOutgoingBitrate = 0;
@@ -134,6 +128,7 @@ class ObservedClient extends events_1.EventEmitter {
134
128
  this.deltaSentVideoBytes = 0;
135
129
  this.deltaTransportReceivedBytes = 0;
136
130
  this.deltaTransportSentBytes = 0;
131
+ this.deltaRttInMsMeasurements = [];
137
132
  this.deltaRttLt50Measurements = 0;
138
133
  this.deltaRttLt150Measurements = 0;
139
134
  this.deltaRttLt300Measurements = 0;
@@ -144,81 +139,12 @@ class ObservedClient extends events_1.EventEmitter {
144
139
  this.numberOfInbundTracks = 0;
145
140
  this.numberOfOutboundRtpStreams = 0;
146
141
  this.numberOfOutboundTracks = 0;
147
- this.usingTURN = false;
148
- this.usingTCP = false;
149
- this.currentMinRttInMs = undefined;
150
- this.currentMaxRttInMs = undefined;
151
- const clientEventsPostBuffer = [];
152
- for (const clientEvent of sample.clientEvents ?? []) {
153
- this._processClientEvent(clientEvent, clientEventsPostBuffer);
154
- this.call.observer.emit('client-event', this, clientEvent);
155
- }
156
- for (const metaData of sample.clientMetaItems ?? []) {
157
- this.addMetadata(metaData);
158
- }
159
- for (const issue of sample.clientIssues ?? []) {
160
- this.addIssue(issue);
161
- ++this.deltaNumberOfIssues;
162
- }
163
- for (const extensionStat of sample.extensionStats ?? []) {
164
- this.addExtensionStats(extensionStat);
165
- }
166
- for (const pcSample of sample.peerConnections ?? []) {
167
- const observedPeerConnection = this._updatePeerConnection(pcSample);
168
- if (!observedPeerConnection)
169
- continue;
170
- this.deltaDataChannelBytesReceived += observedPeerConnection.deltaDataChannelBytesReceived;
171
- this.deltaDataChannelBytesSent += observedPeerConnection.deltaDataChannelBytesSent;
172
- this.deltaDataChannelMessagesReceived += observedPeerConnection.deltaDataChannelMessagesReceived;
173
- this.deltaDataChannelMessagesSent += observedPeerConnection.deltaDataChannelMessagesSent;
174
- this.deltaInboundPacketsLost += observedPeerConnection.deltaInboundPacketsLost;
175
- this.deltaInboundPacketsReceived += observedPeerConnection.deltaInboundPacketsReceived;
176
- this.deltaOutboundPacketsSent += observedPeerConnection.deltaOutboundPacketsSent;
177
- this.deltaReceivedAudioBytes += observedPeerConnection.deltaReceivedAudioBytes;
178
- this.deltaReceivedVideoBytes += observedPeerConnection.deltaReceivedVideoBytes;
179
- this.deltaSentAudioBytes += observedPeerConnection.deltaSentAudioBytes;
180
- this.deltaSentVideoBytes += observedPeerConnection.deltaSentVideoBytes;
181
- this.deltaTransportReceivedBytes += observedPeerConnection.deltaTransportReceivedBytes;
182
- this.deltaTransportSentBytes += observedPeerConnection.deltaTransportSentBytes;
183
- this.availableIncomingBitrate += observedPeerConnection.availableIncomingBitrate;
184
- this.availableOutgoingBitrate += observedPeerConnection.availableOutgoingBitrate;
185
- this.numberOfDataChannels += observedPeerConnection.observedDataChannels.size;
186
- this.numberOfInbundTracks += observedPeerConnection.observedInboundTracks.size;
187
- this.numberOfOutboundRtpStreams += observedPeerConnection.observedOutboundRtps.size;
188
- this.numberOfOutboundTracks += observedPeerConnection.observedOutboundTracks.size;
189
- this.numberOfInboundRtpStreams += observedPeerConnection.observedInboundRtps.size;
190
- if (observedPeerConnection.usingTURN) {
191
- this.usingTURN = true;
192
- }
193
- if (observedPeerConnection.usingTCP) {
194
- this.usingTCP = true;
195
- }
196
- if (observedPeerConnection.currentRttInMs) {
197
- if (this.currentMinRttInMs === undefined || observedPeerConnection.currentRttInMs < this.currentMinRttInMs) {
198
- this.currentMinRttInMs = observedPeerConnection.currentRttInMs;
199
- }
200
- if (this.currentMaxRttInMs === undefined || observedPeerConnection.currentRttInMs > this.currentMaxRttInMs) {
201
- this.currentMaxRttInMs = observedPeerConnection.currentRttInMs;
202
- }
203
- if (observedPeerConnection.currentRttInMs < 50) {
204
- this.deltaRttLt50Measurements += 1;
205
- }
206
- else if (observedPeerConnection.currentRttInMs < 150) {
207
- this.deltaRttLt150Measurements += 1;
208
- }
209
- else if (observedPeerConnection.currentRttInMs < 300) {
210
- this.deltaRttLt300Measurements += 1;
211
- }
212
- else if (300 <= observedPeerConnection.currentRttInMs) {
213
- this.deltaRttGtOrEq300Measurements += 1;
214
- }
215
- sumOfRtts += observedPeerConnection.currentRttInMs;
216
- ++numberOfRttMeasurements;
217
- }
218
- }
219
- for (const clientEvent of clientEventsPostBuffer) {
220
- this._processClientEvent(clientEvent);
221
- }
142
+ sample.clientEvents?.forEach(this._processClientEvent.bind(this));
143
+ sample.clientMetaItems?.forEach(this.addMetadata.bind(this));
144
+ sample.clientIssues?.forEach(this.addIssue.bind(this));
145
+ sample.peerConnections?.forEach(this._updatePeerConnection.bind(this));
146
+ sample.extensionStats?.forEach(this.addExtensionStats.bind(this));
147
+ this._updateRttMeasurements();
222
148
  // emit new attachments?
223
149
  this.attachments = sample.attachments;
224
150
  this.totalDataChannelBytesReceived += this.deltaDataChannelBytesReceived;
@@ -238,12 +164,11 @@ class ObservedClient extends events_1.EventEmitter {
238
164
  this.totalRttLt150Measurements += this.deltaRttLt150Measurements;
239
165
  this.totalRttLt300Measurements += this.deltaRttLt300Measurements;
240
166
  this.totalRttGtOrEq300Measurements += this.deltaRttGtOrEq300Measurements;
241
- this.totalNumberOfIssues += this.deltaNumberOfIssues;
167
+ this.numberOfIssues += this.deltaNumberOfIssues;
242
168
  this.receivingAudioBitrate = (this.deltaReceivedAudioBytes * 8) / (elapsedInSeconds);
243
169
  this.receivingVideoBitrate = (this.totalReceivedVideoBytes * 8) / (elapsedInSeconds);
244
170
  this.sendingAudioBitrate = (this.deltaSentAudioBytes * 8) / (elapsedInSeconds);
245
171
  this.sendingVideoBitrate = (this.deltaSentVideoBytes * 8) / (elapsedInSeconds);
246
- this.currentAvgRttInMs = 0 < numberOfRttMeasurements ? sumOfRtts / numberOfRttMeasurements : undefined;
247
172
  this.calculatedScore.value = sample.score;
248
173
  this.detectors.update();
249
174
  // emit update
@@ -258,7 +183,7 @@ class ObservedClient extends events_1.EventEmitter {
258
183
  ++this.numberOfScoreMeasurements;
259
184
  }
260
185
  }
261
- _processClientEvent(event, postBuffer) {
186
+ _processClientEvent(event) {
262
187
  // eslint-disable-next-line no-console
263
188
  // console.warn('ClientEvent', event);
264
189
  switch (event.type) {
@@ -290,107 +215,8 @@ class ObservedClient extends events_1.EventEmitter {
290
215
  }
291
216
  break;
292
217
  }
293
- case ClientEventTypes_1.ClientEventTypes.PEER_CONNECTION_OPENED: {
294
- const payload = (0, utils_1.parseJsonAs)(event.payload);
295
- if (payload?.peerConnectionId && typeof payload.peerConnectionId === 'string') {
296
- const observedPeerConnection = this.observedPeerConnections.get(payload.peerConnectionId);
297
- if (observedPeerConnection) {
298
- observedPeerConnection.openedAt = event.timestamp;
299
- }
300
- else if (postBuffer) {
301
- postBuffer.push(event);
302
- }
303
- else {
304
- logger.warn('Received PEER_CONNECTION_OPENED event without a corresponding observedPeerConnection', event);
305
- }
306
- }
307
- break;
308
- }
309
- case ClientEventTypes_1.ClientEventTypes.PEER_CONNECTION_CLOSED: {
310
- const payload = (0, utils_1.parseJsonAs)(event.payload);
311
- if (payload?.peerConnectionId && typeof payload.peerConnectionId === 'string') {
312
- const observedPeerConnection = this.observedPeerConnections.get(payload.peerConnectionId);
313
- if (observedPeerConnection) {
314
- observedPeerConnection.closedAt = event.timestamp;
315
- }
316
- else if (postBuffer) {
317
- postBuffer.push(event);
318
- }
319
- else {
320
- logger.warn('Received PEER_CONNECTION_CLOSED event without a corresponding observedPeerConnection', event);
321
- }
322
- }
323
- break;
324
- }
325
- case ClientEventTypes_1.ClientEventTypes.MEDIA_TRACK_ADDED: {
326
- const payload = (0, utils_1.parseJsonAs)(event.payload);
327
- if (payload?.peerConnectionId && typeof payload.peerConnectionId === 'string' && payload?.trackId && typeof payload.trackId === 'string') {
328
- const observedPeerConnection = this.observedPeerConnections.get(payload.peerConnectionId);
329
- const observedTrack = observedPeerConnection?.observedInboundTracks.get(payload.trackId) ?? observedPeerConnection?.observedOutboundTracks.get(payload.trackId);
330
- if (observedTrack) {
331
- observedTrack.addedAt = event.timestamp;
332
- }
333
- else if (postBuffer) {
334
- postBuffer.push(event);
335
- }
336
- else {
337
- logger.warn('Received MEDIA_TRACK_ADDED event without a corresponding observedPeerConnection or observedTrack', event);
338
- }
339
- }
340
- break;
341
- }
342
- case ClientEventTypes_1.ClientEventTypes.MEDIA_TRACK_REMOVED: {
343
- const payload = (0, utils_1.parseJsonAs)(event.payload);
344
- if (payload?.peerConnectionId && typeof payload.peerConnectionId === 'string' && payload?.trackId && typeof payload.trackId === 'string') {
345
- const observedPeerConnection = this.observedPeerConnections.get(payload.peerConnectionId);
346
- const observedTrack = observedPeerConnection?.observedInboundTracks.get(payload.trackId) ?? observedPeerConnection?.observedOutboundTracks.get(payload.trackId);
347
- if (observedTrack) {
348
- observedTrack.removedAt = event.timestamp;
349
- }
350
- else if (postBuffer) {
351
- postBuffer.push(event);
352
- }
353
- else {
354
- logger.warn('Received MEDIA_TRACK_REMOVED event without a corresponding observedPeerConnection or observedTrack', event);
355
- }
356
- }
357
- break;
358
- }
359
- case ClientEventTypes_1.ClientEventTypes.DATA_CHANNEL_OPEN: {
360
- const payload = (0, utils_1.parseJsonAs)(event.payload);
361
- if (payload?.peerConnectionId && typeof payload.peerConnectionId === 'string' && payload?.dataChannelId && typeof payload.dataChannelId === 'string') {
362
- const observedPeerConnection = this.observedPeerConnections.get(payload.peerConnectionId);
363
- const observedDataChannel = observedPeerConnection?.observedDataChannels.get(payload.dataChannelId);
364
- if (observedDataChannel) {
365
- observedDataChannel.addedAt = event.timestamp;
366
- }
367
- else if (postBuffer) {
368
- postBuffer.push(event);
369
- }
370
- else {
371
- logger.warn('Received DATA_CHANNEL_OPENED event without a corresponding observedPeerConnection or observedDataChannel', event);
372
- }
373
- }
374
- break;
375
- }
376
- case ClientEventTypes_1.ClientEventTypes.DATA_CHANNEL_CLOSED: {
377
- const payload = (0, utils_1.parseJsonAs)(event.payload);
378
- if (payload?.peerConnectionId && typeof payload.peerConnectionId === 'string' && payload?.dataChannelId && typeof payload.dataChannelId === 'string') {
379
- const observedPeerConnection = this.observedPeerConnections.get(payload.peerConnectionId);
380
- const observedDataChannel = observedPeerConnection?.observedDataChannels.get(payload.dataChannelId);
381
- if (observedDataChannel) {
382
- observedDataChannel.removedAt = event.timestamp;
383
- }
384
- else if (postBuffer) {
385
- postBuffer.push(event);
386
- }
387
- else {
388
- logger.warn('Received DATA_CHANNEL_CLOSE event without a corresponding observedPeerConnection or observedDataChannel', event);
389
- }
390
- }
391
- break;
392
- }
393
218
  }
219
+ this.call.observer.emit('client-event', this, event);
394
220
  }
395
221
  addMetadata(metadata) {
396
222
  if (this.closed)
@@ -418,6 +244,7 @@ class ObservedClient extends events_1.EventEmitter {
418
244
  addIssue(issue) {
419
245
  if (this.closed)
420
246
  return;
247
+ ++this.deltaNumberOfIssues;
421
248
  this.emit('issue', issue);
422
249
  this.call.observer.emit('client-issue', this, issue);
423
250
  }
@@ -428,7 +255,7 @@ class ObservedClient extends events_1.EventEmitter {
428
255
  let observedPeerConnection = this.observedPeerConnections.get(sample.peerConnectionId);
429
256
  if (!observedPeerConnection) {
430
257
  if (!sample.peerConnectionId) {
431
- return (logger.warn(`ObservedClient received an invalid PeerConnectionSample (missing peerConnectionId field). ClientId: ${this.clientId}, CallId: ${this.call.callId}`, sample), void 0);
258
+ return logger.warn(`ObservedClient received an invalid PeerConnectionSample (missing peerConnectionId field). ClientId: ${this.clientId}, CallId: ${this.call.callId}`, sample);
432
259
  }
433
260
  observedPeerConnection = new ObservedPeerConnection_1.ObservedPeerConnection(sample.peerConnectionId, this);
434
261
  observedPeerConnection.once('close', () => {
@@ -438,7 +265,96 @@ class ObservedClient extends events_1.EventEmitter {
438
265
  this.emit('newpeerconnection', observedPeerConnection);
439
266
  }
440
267
  observedPeerConnection.accept(sample);
441
- return observedPeerConnection;
268
+ observedPeerConnection.currentRttInMs;
269
+ this.deltaDataChannelBytesReceived += observedPeerConnection.deltaDataChannelBytesReceived;
270
+ this.deltaDataChannelBytesSent += observedPeerConnection.deltaDataChannelBytesSent;
271
+ this.deltaDataChannelMessagesReceived += observedPeerConnection.deltaDataChannelMessagesReceived;
272
+ this.deltaDataChannelMessagesSent += observedPeerConnection.deltaDataChannelMessagesSent;
273
+ this.deltaInboundPacketsLost += observedPeerConnection.deltaInboundPacketsLost;
274
+ this.deltaInboundPacketsReceived += observedPeerConnection.deltaInboundPacketsReceived;
275
+ this.deltaOutboundPacketsSent += observedPeerConnection.deltaOutboundPacketsSent;
276
+ this.deltaReceivedAudioBytes += observedPeerConnection.deltaReceivedAudioBytes;
277
+ this.deltaReceivedVideoBytes += observedPeerConnection.deltaReceivedVideoBytes;
278
+ this.deltaSentAudioBytes += observedPeerConnection.deltaSentAudioBytes;
279
+ this.deltaSentVideoBytes += observedPeerConnection.deltaSentVideoBytes;
280
+ this.deltaTransportReceivedBytes += observedPeerConnection.deltaTransportReceivedBytes;
281
+ this.deltaTransportSentBytes += observedPeerConnection.deltaTransportSentBytes;
282
+ this.availableIncomingBitrate += observedPeerConnection.availableIncomingBitrate;
283
+ this.availableOutgoingBitrate += observedPeerConnection.availableOutgoingBitrate;
284
+ this.numberOfDataChannels += observedPeerConnection.observedDataChannels.size;
285
+ this.numberOfInbundTracks += observedPeerConnection.observedInboundTracks.size;
286
+ this.numberOfOutboundRtpStreams += observedPeerConnection.observedOutboundRtps.size;
287
+ this.numberOfOutboundTracks += observedPeerConnection.observedOutboundTracks.size;
288
+ this.numberOfInboundRtpStreams += observedPeerConnection.observedInboundRtps.size;
289
+ if (observedPeerConnection.currentRttInMs) {
290
+ this.deltaRttInMsMeasurements.push(observedPeerConnection.currentRttInMs);
291
+ }
292
+ }
293
+ resetSummaryMetrics() {
294
+ this.totalDataChannelBytesReceived = 0;
295
+ this.totalDataChannelBytesSent = 0;
296
+ this.totalDataChannelMessagesReceived = 0;
297
+ this.totalDataChannelMessagesSent = 0;
298
+ this.totalInboundPacketsLost = 0;
299
+ this.totalInboundPacketsReceived = 0;
300
+ this.totalOutboundPacketsSent = 0;
301
+ this.totalReceivedAudioBytes = 0;
302
+ this.totalReceivedVideoBytes = 0;
303
+ this.totalSentAudioBytes = 0;
304
+ this.totalSentVideoBytes = 0;
305
+ this.totalSentBytes = 0;
306
+ this.totalReceivedBytes = 0;
307
+ this.numberOfIssues = 0;
308
+ this.totalScoreSum = 0;
309
+ this.numberOfScoreMeasurements = 0;
310
+ }
311
+ createSummary() {
312
+ return {
313
+ totalRttLt50Measurements: this.totalRttLt50Measurements,
314
+ totalRttLt150Measurements: this.totalRttLt150Measurements,
315
+ totalRttLt300Measurements: this.totalRttLt300Measurements,
316
+ totalRttGtOrEq300Measurements: this.totalRttGtOrEq300Measurements,
317
+ totalDataChannelBytesReceived: this.totalDataChannelBytesReceived,
318
+ totalDataChannelBytesSent: this.totalDataChannelBytesSent,
319
+ totalDataChannelMessagesReceived: this.totalDataChannelMessagesReceived,
320
+ totalDataChannelMessagesSent: this.totalDataChannelMessagesSent,
321
+ totalInboundPacketsLost: this.totalInboundPacketsLost,
322
+ totalInboundPacketsReceived: this.totalInboundPacketsReceived,
323
+ totalOutboundPacketsSent: this.totalOutboundPacketsSent,
324
+ totalReceivedAudioBytes: this.totalReceivedAudioBytes,
325
+ totalReceivedVideoBytes: this.totalReceivedVideoBytes,
326
+ totalSentAudioBytes: this.totalSentAudioBytes,
327
+ totalSentVideoBytes: this.totalSentVideoBytes,
328
+ totalSentBytes: this.totalSentBytes,
329
+ totalReceivedBytes: this.totalReceivedBytes,
330
+ numberOfIssues: this.numberOfIssues,
331
+ totalScoreSum: this.totalScoreSum,
332
+ numberOfScoreMeasurements: this.numberOfScoreMeasurements,
333
+ };
334
+ }
335
+ _updateRttMeasurements() {
336
+ if (this.deltaRttInMsMeasurements.length < 1) {
337
+ this.currentRttInMs = undefined;
338
+ return;
339
+ }
340
+ this.currentRttInMs = (0, utils_1.getMedian)(this.deltaRttInMsMeasurements, false);
341
+ if (this.currentRttInMs < 0) {
342
+ logger.warn(`Current Rtt for client ${this.clientId} is smaller than 0`);
343
+ this.currentRttInMs = undefined;
344
+ return;
345
+ }
346
+ if (this.currentRttInMs < 50) {
347
+ this.deltaRttLt50Measurements += 1;
348
+ }
349
+ else if (this.currentRttInMs < 150) {
350
+ this.deltaRttLt150Measurements += 1;
351
+ }
352
+ else if (this.currentRttInMs < 300) {
353
+ this.deltaRttLt300Measurements += 1;
354
+ }
355
+ else if (300 <= this.currentRttInMs) {
356
+ this.deltaRttGtOrEq300Measurements += 1;
357
+ }
442
358
  }
443
359
  }
444
360
  exports.ObservedClient = ObservedClient;