@observertc/observer-js 0.30.2-beta → 0.30.4-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ObservedClient.d.ts +34 -22
- package/lib/ObservedClient.d.ts.map +1 -1
- package/lib/ObservedClient.js +95 -13
- package/lib/ObservedInboundTrack.d.ts +20 -8
- package/lib/ObservedInboundTrack.d.ts.map +1 -1
- package/lib/ObservedInboundTrack.js +59 -26
- package/lib/ObservedOutboundTrack.d.ts +20 -3
- package/lib/ObservedOutboundTrack.d.ts.map +1 -1
- package/lib/ObservedOutboundTrack.js +53 -9
- package/lib/ObservedPeerConnection.d.ts +15 -10
- package/lib/ObservedPeerConnection.d.ts.map +1 -1
- package/lib/ObservedPeerConnection.js +113 -19
- package/package.json +1 -1
- package/src/ObservedClient.ts +119 -28
- package/src/ObservedInboundTrack.ts +62 -17
- package/src/ObservedOutboundTrack.ts +70 -9
- package/src/ObservedPeerConnection.ts +146 -23
- package/lib/common/ReportsCollector.d.ts +0 -23
- package/lib/common/ReportsCollector.d.ts.map +0 -1
- package/lib/common/ReportsCollector.js +0 -26
- package/src/common/ReportsCollector.ts +0 -71
package/lib/ObservedClient.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { ClientSample } from '@observertc/sample-schemas-js';
|
|
2
|
+
import { ClientSample, IceLocalCandidate, IceRemoteCandidate } from '@observertc/sample-schemas-js';
|
|
3
3
|
import { ObservedCall } from './ObservedCall';
|
|
4
4
|
import { StorageProvider } from './storages/StorageProvider';
|
|
5
5
|
import { EventEmitter } from 'events';
|
|
@@ -22,6 +22,31 @@ export type ObservedClientEvents = {
|
|
|
22
22
|
close: [];
|
|
23
23
|
'processing-sample-overflow': [];
|
|
24
24
|
newpeerconnection: [ObservedPeerConnection];
|
|
25
|
+
iceconnectionstatechange: [
|
|
26
|
+
{
|
|
27
|
+
peerConnection: ObservedPeerConnection;
|
|
28
|
+
state: string;
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
icegatheringstatechange: [
|
|
32
|
+
{
|
|
33
|
+
peerConnection: ObservedPeerConnection;
|
|
34
|
+
state: string;
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
connectionstatechange: [
|
|
38
|
+
{
|
|
39
|
+
peerConnection: ObservedPeerConnection;
|
|
40
|
+
state: string;
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
selectedcandidatepair: [
|
|
44
|
+
{
|
|
45
|
+
peerConnection: ObservedPeerConnection;
|
|
46
|
+
localCandidate: IceLocalCandidate;
|
|
47
|
+
remoteCandidate: IceRemoteCandidate;
|
|
48
|
+
}
|
|
49
|
+
];
|
|
25
50
|
};
|
|
26
51
|
export declare interface ObservedClient<AppData extends Record<string, unknown> = Record<string, unknown>> {
|
|
27
52
|
on<U extends keyof ObservedClientEvents>(event: U, listener: (...args: ObservedClientEvents[U]) => void): this;
|
|
@@ -36,6 +61,7 @@ export declare class ObservedClient<AppData extends Record<string, unknown> = Re
|
|
|
36
61
|
private readonly _storageProvider;
|
|
37
62
|
readonly appData: AppData;
|
|
38
63
|
static create<T extends Record<string, unknown> = Record<string, unknown>>(config: ObservedClientConfig<T>, call: ObservedCall, storageProvider: StorageProvider): Promise<ObservedClient<T>>;
|
|
64
|
+
created: number;
|
|
39
65
|
private readonly _peerConnections;
|
|
40
66
|
private readonly _execute;
|
|
41
67
|
private _overflowingProcessingThreshold;
|
|
@@ -47,34 +73,19 @@ export declare class ObservedClient<AppData extends Record<string, unknown> = Re
|
|
|
47
73
|
private _leaveReported;
|
|
48
74
|
totalInboundPacketsLost: number;
|
|
49
75
|
totalInboundPacketsReceived: number;
|
|
50
|
-
totalOutboundPacketsLost: number;
|
|
51
|
-
totalOutboundPacketsReceived: number;
|
|
52
76
|
totalOutboundPacketsSent: number;
|
|
53
77
|
totalDataChannelBytesSent: number;
|
|
54
78
|
totalDataChannelBytesReceived: number;
|
|
55
|
-
|
|
56
|
-
|
|
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;
|
|
79
|
+
totalSentBytes: number;
|
|
80
|
+
totalReceivedBytes: number;
|
|
70
81
|
avgRttInS?: number;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
receivingAudioBitrate?: number;
|
|
74
|
-
receivingVideoBitrate?: number;
|
|
82
|
+
sendingBitrate?: number;
|
|
83
|
+
receivingBitrate?: number;
|
|
75
84
|
readonly mediaDevices: string[];
|
|
76
85
|
readonly codecs: string[];
|
|
77
86
|
readonly userMediaErrors: string[];
|
|
87
|
+
readonly ωpendingCreatedTracksTimestamp: Map<string, number>;
|
|
88
|
+
readonly ωpendingCreatedPeerConnectionTimestamp: Map<string, number>;
|
|
78
89
|
private constructor();
|
|
79
90
|
get joined(): number;
|
|
80
91
|
get clientId(): string;
|
|
@@ -92,6 +103,7 @@ export declare class ObservedClient<AppData extends Record<string, unknown> = Re
|
|
|
92
103
|
get platform(): Samples_ClientSample_Platform | undefined;
|
|
93
104
|
get acceptedSample(): number;
|
|
94
105
|
get updated(): number;
|
|
106
|
+
get uptimeInMs(): number;
|
|
95
107
|
get closed(): boolean;
|
|
96
108
|
get peerConnections(): ReadonlyMap<string, ObservedPeerConnection>;
|
|
97
109
|
close(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservedClient.d.ts","sourceRoot":"","sources":["../src/ObservedClient.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"ObservedClient.d.ts","sourceRoot":"","sources":["../src/ObservedClient.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACpG,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAIlE,OAAO,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,oCAAoC,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AAOrK,MAAM,MAAM,oBAAoB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IACrG,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,8BAA8B,CAAC,EAAE,MAAM,CAAC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAClC,MAAM,EAAE,EAAE,CAAC;IACX,KAAK,EAAE,EAAE,CAAC;IACV,4BAA4B,EAAE,EAAE,CAAC;IACjC,iBAAiB,EAAE,CAAC,sBAAsB,CAAC,CAAC;IAC5C,wBAAwB,EAAE;QAAC;YAC1B,cAAc,EAAE,sBAAsB,CAAC;YACvC,KAAK,EAAE,MAAM,CAAC;SAC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IAEnF,OAAO;IASP,IAAW,MAAM,IAAI,MAAM,CAG1B;IAED,IAAW,QAAQ,IAAI,MAAM,CAG5B;IAED,IAAW,MAAM,WAGhB;IAED,IAAW,SAAS,WAGnB;IAED,IAAW,MAAM,WAGhB;IAED,IAAW,WAAW,WAGrB;IAED,IAAW,OAAO,kDAEjB;IAED,IAAW,MAAM,uBAEhB;IAED,IAAW,qBAAqB,uBAE/B;IAED,IAAW,MAAM,uBAEhB;IAED,IAAW,OAAO,6CAEjB;IAED,IAAW,MAAM,4CAEhB;IAED,IAAW,eAAe,qDAEzB;IAED,IAAW,QAAQ,8CAElB;IAED,IAAW,cAAc,WAExB;IAED,IAAW,OAAO,WAEjB;IAED,IAAW,UAAU,WAEpB;IAED,IAAW,MAAM,YAEhB;IAED,IAAW,eAAe,IAAI,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAExE;IAEM,KAAK;IAWC,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;YA6iB1C,qBAAqB;YAoCrB,KAAK;IAMnB,OAAO,CAAC,oBAAoB;CAe5B"}
|
package/lib/ObservedClient.js
CHANGED
|
@@ -88,6 +88,7 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
88
88
|
this.call = call;
|
|
89
89
|
this._storageProvider = _storageProvider;
|
|
90
90
|
this.appData = appData;
|
|
91
|
+
this.created = Date.now();
|
|
91
92
|
this._peerConnections = new Map();
|
|
92
93
|
this._execute = (0, SingleExecutor_1.createSingleExecutor)();
|
|
93
94
|
this._overflowingProcessingThreshold = 0;
|
|
@@ -98,18 +99,16 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
98
99
|
this._leaveReported = false;
|
|
99
100
|
this.totalInboundPacketsLost = 0;
|
|
100
101
|
this.totalInboundPacketsReceived = 0;
|
|
101
|
-
this.totalOutboundPacketsLost = 0;
|
|
102
|
-
this.totalOutboundPacketsReceived = 0;
|
|
103
102
|
this.totalOutboundPacketsSent = 0;
|
|
104
103
|
this.totalDataChannelBytesSent = 0;
|
|
105
104
|
this.totalDataChannelBytesReceived = 0;
|
|
106
|
-
this.
|
|
107
|
-
this.
|
|
108
|
-
this.totalReceivedAudioBytes = 0;
|
|
109
|
-
this.totalReceivedVideoBytes = 0;
|
|
105
|
+
this.totalSentBytes = 0;
|
|
106
|
+
this.totalReceivedBytes = 0;
|
|
110
107
|
this.mediaDevices = [];
|
|
111
108
|
this.codecs = [];
|
|
112
109
|
this.userMediaErrors = [];
|
|
110
|
+
this.ωpendingCreatedTracksTimestamp = new Map();
|
|
111
|
+
this.ωpendingCreatedPeerConnectionTimestamp = new Map();
|
|
113
112
|
}
|
|
114
113
|
get joined() {
|
|
115
114
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -165,6 +164,9 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
165
164
|
get updated() {
|
|
166
165
|
return this._updated;
|
|
167
166
|
}
|
|
167
|
+
get uptimeInMs() {
|
|
168
|
+
return this._updated - this.created;
|
|
169
|
+
}
|
|
168
170
|
get closed() {
|
|
169
171
|
return this._closed;
|
|
170
172
|
}
|
|
@@ -193,7 +195,12 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
193
195
|
this.emit('processing-sample-overflow');
|
|
194
196
|
}
|
|
195
197
|
return this._execute(() => __awaiter(this, void 0, void 0, function* () {
|
|
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;
|
|
198
|
+
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;
|
|
199
|
+
for (const peerConnection of this._peerConnections.values()) {
|
|
200
|
+
if (peerConnection.closed)
|
|
201
|
+
continue;
|
|
202
|
+
peerConnection.resetMetrics();
|
|
203
|
+
}
|
|
197
204
|
let executeSave = false;
|
|
198
205
|
if (this.userId !== sample.userId) {
|
|
199
206
|
this._model.userId = sample.userId;
|
|
@@ -276,24 +283,58 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
276
283
|
extensionType: extensionStats.type,
|
|
277
284
|
});
|
|
278
285
|
}
|
|
279
|
-
for (let
|
|
280
|
-
const { timestamp
|
|
286
|
+
for (let _17 of (_p = sample.customCallEvents) !== null && _p !== void 0 ? _p : []) {
|
|
287
|
+
const { timestamp } = _17, callEvent = __rest(_17, ["timestamp"]);
|
|
281
288
|
const peerConnection = this._peerConnections.get((_q = callEvent.peerConnectionId) !== null && _q !== void 0 ? _q : '');
|
|
282
289
|
switch (callEvent.name) {
|
|
290
|
+
case CallEventType_1.CallEventType.CLIENT_JOINED:
|
|
291
|
+
this.created = timestamp !== null && timestamp !== void 0 ? timestamp : this.created;
|
|
292
|
+
break;
|
|
283
293
|
case CallEventType_1.CallEventType.CLIENT_LEFT:
|
|
284
294
|
this._leaveReported = true;
|
|
285
295
|
break;
|
|
286
296
|
case CallEventType_1.CallEventType.ICE_CONNECTION_STATE_CHANGED:
|
|
287
|
-
peerConnection && callEvent.value &&
|
|
297
|
+
peerConnection && callEvent.value && this.emit('iceconnectionstatechange', {
|
|
298
|
+
peerConnection,
|
|
299
|
+
state: callEvent.value,
|
|
300
|
+
});
|
|
288
301
|
break;
|
|
289
302
|
case CallEventType_1.CallEventType.ICE_GATHERING_STATE_CHANGED:
|
|
290
|
-
peerConnection && callEvent.value &&
|
|
303
|
+
peerConnection && callEvent.value && this.emit('icegatheringstatechange', {
|
|
304
|
+
peerConnection,
|
|
305
|
+
state: callEvent.value,
|
|
306
|
+
});
|
|
291
307
|
break;
|
|
292
308
|
case CallEventType_1.CallEventType.PEER_CONNECTION_STATE_CHANGED:
|
|
293
|
-
peerConnection && callEvent.value &&
|
|
309
|
+
peerConnection && callEvent.value && this.emit('connectionstatechange', {
|
|
310
|
+
peerConnection,
|
|
311
|
+
state: callEvent.value,
|
|
312
|
+
});
|
|
313
|
+
break;
|
|
314
|
+
case CallEventType_1.CallEventType.PEER_CONNECTION_OPENED: {
|
|
315
|
+
if (!callEvent.peerConnectionId)
|
|
316
|
+
break;
|
|
317
|
+
if (peerConnection) {
|
|
318
|
+
peerConnection.created = timestamp !== null && timestamp !== void 0 ? timestamp : peerConnection.created;
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
this.ωpendingCreatedPeerConnectionTimestamp.set(callEvent.peerConnectionId, timestamp !== null && timestamp !== void 0 ? timestamp : Date.now());
|
|
322
|
+
}
|
|
294
323
|
break;
|
|
324
|
+
}
|
|
325
|
+
case CallEventType_1.CallEventType.MEDIA_TRACK_ADDED: {
|
|
326
|
+
if (!callEvent.mediaTrackId)
|
|
327
|
+
break;
|
|
328
|
+
const track = peerConnection === null || peerConnection === void 0 ? void 0 : peerConnection.getTrack(callEvent.mediaTrackId);
|
|
329
|
+
if (track) {
|
|
330
|
+
track.created = timestamp !== null && timestamp !== void 0 ? timestamp : track.created;
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
this.ωpendingCreatedTracksTimestamp.set(callEvent.mediaTrackId, timestamp !== null && timestamp !== void 0 ? timestamp : Date.now());
|
|
334
|
+
}
|
|
335
|
+
}
|
|
295
336
|
}
|
|
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));
|
|
337
|
+
this.reports.addCallEventReport(Object.assign({ serviceId: this.serviceId, mediaUnitId: this.mediaUnitId, roomId: this.roomId, callId: this.callId, clientId: this.clientId, userId: this.userId, timestamp: timestamp !== null && timestamp !== void 0 ? timestamp : Date.now() }, callEvent));
|
|
297
338
|
}
|
|
298
339
|
for (const userMediaError of (_r = sample.userMediaErrors) !== null && _r !== void 0 ? _r : []) {
|
|
299
340
|
const callMetaReport = (0, callMetaReports_1.createCallMetaReport)(this.serviceId, this.mediaUnitId, this.roomId, this.callId, this.clientId, {
|
|
@@ -502,6 +543,33 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
502
543
|
}
|
|
503
544
|
}
|
|
504
545
|
}
|
|
546
|
+
// update metrics
|
|
547
|
+
this.totalSentBytes = 0;
|
|
548
|
+
this.totalReceivedBytes = 0;
|
|
549
|
+
this.totalOutboundPacketsSent = 0;
|
|
550
|
+
this.totalInboundPacketsReceived = 0;
|
|
551
|
+
this.totalInboundPacketsLost = 0;
|
|
552
|
+
this.totalDataChannelBytesSent = 0;
|
|
553
|
+
this.totalDataChannelBytesReceived = 0;
|
|
554
|
+
this.sendingBitrate = 0;
|
|
555
|
+
this.receivingBitrate = 0;
|
|
556
|
+
let sumRttInS = 0;
|
|
557
|
+
for (const peerConnection of this._peerConnections.values()) {
|
|
558
|
+
if (peerConnection.closed)
|
|
559
|
+
continue;
|
|
560
|
+
peerConnection.updateMetrics();
|
|
561
|
+
this.totalSentBytes += peerConnection.totalSentAudioBytes + peerConnection.totalSentVideoBytes;
|
|
562
|
+
this.totalReceivedBytes += peerConnection.totalReceivedAudioBytes + peerConnection.totalReceivedVideoBytes;
|
|
563
|
+
this.totalOutboundPacketsSent += peerConnection.totalOutboundPacketsSent;
|
|
564
|
+
this.totalInboundPacketsReceived += peerConnection.totalInboundPacketsReceived;
|
|
565
|
+
this.totalInboundPacketsLost += peerConnection.totalInboundPacketsLost;
|
|
566
|
+
this.totalDataChannelBytesSent += peerConnection.totalDataChannelBytesSent;
|
|
567
|
+
this.totalDataChannelBytesReceived += peerConnection.totalDataChannelBytesReceived;
|
|
568
|
+
this.sendingBitrate += peerConnection.sendingAudioBitrate + peerConnection.sendingVideoBitrate;
|
|
569
|
+
this.receivingBitrate += peerConnection.receivingAudioBitrate + peerConnection.receivingVideoBitrate;
|
|
570
|
+
sumRttInS += (_16 = peerConnection.avgRttInS) !== null && _16 !== void 0 ? _16 : 0;
|
|
571
|
+
}
|
|
572
|
+
this.avgRttInS = this._peerConnections.size ? sumRttInS / this._peerConnections.size : -1;
|
|
505
573
|
if (executeSave)
|
|
506
574
|
yield this._save();
|
|
507
575
|
this._updated = sample.timestamp;
|
|
@@ -516,11 +584,25 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
516
584
|
const result = yield ObservedPeerConnection_1.ObservedPeerConnection.create({
|
|
517
585
|
peerConnectionId,
|
|
518
586
|
}, this, this._storageProvider);
|
|
587
|
+
const pendingTracksTimestamp = this.ωpendingCreatedTracksTimestamp.get(peerConnectionId);
|
|
588
|
+
if (pendingTracksTimestamp) {
|
|
589
|
+
result.created = pendingTracksTimestamp;
|
|
590
|
+
this.ωpendingCreatedTracksTimestamp.delete(peerConnectionId);
|
|
591
|
+
}
|
|
592
|
+
const onNewSelectedCandidatePair = ({ localCandidate, remoteCandidate }) => {
|
|
593
|
+
this.emit('selectedcandidatepair', {
|
|
594
|
+
peerConnection: result,
|
|
595
|
+
localCandidate,
|
|
596
|
+
remoteCandidate,
|
|
597
|
+
});
|
|
598
|
+
};
|
|
519
599
|
result.once('close', () => {
|
|
600
|
+
result.ICE.off('new-selected-candidate-pair', onNewSelectedCandidatePair);
|
|
520
601
|
this._peerConnections.delete(peerConnectionId);
|
|
521
602
|
this._model.peerConnectionIds = this._model.peerConnectionIds.filter((id) => id !== peerConnectionId);
|
|
522
603
|
this._save().catch(() => void 0);
|
|
523
604
|
});
|
|
605
|
+
result.ICE.on('new-selected-candidate-pair', onNewSelectedCandidatePair);
|
|
524
606
|
this._peerConnections.set(peerConnectionId, result);
|
|
525
607
|
this._model.peerConnectionIds.push(peerConnectionId);
|
|
526
608
|
yield this._save();
|
|
@@ -43,21 +43,31 @@ export declare class ObservedInboundTrack<Kind extends MediaKind> extends EventE
|
|
|
43
43
|
readonly peerConnection: ObservedPeerConnection;
|
|
44
44
|
private readonly _storageProvider;
|
|
45
45
|
static create<K extends MediaKind>(config: ObservedInboundTrackConfig<K>, peerConnection: ObservedPeerConnection, storageProvider: StorageProvider): Promise<ObservedInboundTrack<K>>;
|
|
46
|
+
created: number;
|
|
46
47
|
private readonly _stats;
|
|
47
48
|
private readonly _execute;
|
|
48
49
|
private _closed;
|
|
49
50
|
private _updated;
|
|
50
51
|
private _remoteOutboundTrack?;
|
|
51
52
|
bitrate: number;
|
|
52
|
-
rttInMs
|
|
53
|
-
lostPackets: number;
|
|
54
|
-
receivedPackets: number;
|
|
55
|
-
receivedFrames: number;
|
|
56
|
-
decodedFrames: number;
|
|
57
|
-
droppedFrames: number;
|
|
58
|
-
receivedSamples: number;
|
|
59
|
-
silentConcealedSamples: number;
|
|
53
|
+
rttInMs?: number;
|
|
60
54
|
fractionLoss: number;
|
|
55
|
+
totalLostPackets: number;
|
|
56
|
+
totalReceivedPackets: number;
|
|
57
|
+
totalBytesReceived: number;
|
|
58
|
+
totalReceivedFrames: number;
|
|
59
|
+
totalDecodedFrames: number;
|
|
60
|
+
totalDroppedFrames: number;
|
|
61
|
+
totalReceivedSamples: number;
|
|
62
|
+
totalSilentConcealedSamples: number;
|
|
63
|
+
deltaLostPackets: number;
|
|
64
|
+
deltaReceivedPackets: number;
|
|
65
|
+
deltaBytesReceived: number;
|
|
66
|
+
deltaReceivedFrames: number;
|
|
67
|
+
deltaDecodedFrames: number;
|
|
68
|
+
deltaDroppedFrames: number;
|
|
69
|
+
deltaReceivedSamples: number;
|
|
70
|
+
deltaSilentConcealedSamples: number;
|
|
61
71
|
private constructor();
|
|
62
72
|
get serviceId(): string;
|
|
63
73
|
get roomId(): string;
|
|
@@ -72,10 +82,12 @@ export declare class ObservedInboundTrack<Kind extends MediaKind> extends EventE
|
|
|
72
82
|
get updated(): number;
|
|
73
83
|
get stats(): ReadonlyMap<number, ObservedInboundTrackStats<Kind>>;
|
|
74
84
|
get reports(): import("./ReportsCollector").ReportsCollector;
|
|
85
|
+
get uptimeInMs(): number;
|
|
75
86
|
set remoteOutboundTrack(track: ObservedOutboundTrack<Kind> | undefined);
|
|
76
87
|
get remoteOutboundTrack(): ObservedOutboundTrack<Kind> | undefined;
|
|
77
88
|
get closed(): boolean;
|
|
78
89
|
close(): void;
|
|
90
|
+
resetMetrics(): void;
|
|
79
91
|
private _save;
|
|
80
92
|
}
|
|
81
93
|
//# sourceMappingURL=ObservedInboundTrack.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservedInboundTrack.d.ts","sourceRoot":"","sources":["../src/ObservedInboundTrack.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,MAAM,MAAM,0BAA0B,CAAC,CAAC,SAAS,SAAS,IAAI;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,CAAC,CAAC;IACR,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB,CAAA;AAED,MAAM,MAAM,0BAA0B,CAAC,CAAC,SAAS,SAAS,IAAI;IAC7D,MAAM,EAAE,EAAE,CAAC;IACX,KAAK,EAAE,EAAE,CAAC;IACV,mBAAmB,EAAE,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,+BAA+B,CAAC,CAAC,SAAS,SAAS,IAAI,CAAC,SAAS,OAAO,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;AAE7H,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,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IAAW,WAAW,WAGrB;IAED,IAAW,gBAAgB,WAG1B;IAED,IAAW,OAAO,WAGjB;IAED,IAAW,IAAI,IAAI,IAAI,CAGtB;IAED,IAAW,WAAW,uBAErB;IAED,IAAW,SAAS,uBAEnB;IAED,IAAW,OAAO,WAEjB;IAED,IAAW,KAAK,IAAI,WAAW,CAAC,MAAM,EAAE,yBAAyB,CAAC,IAAI,CAAC,CAAC,CAEvE;IAED,IAAW,OAAO,kDAEjB;IAED,IAAW,UAAU,WAEpB;IAED,IAAW,mBAAmB,CAAC,KAAK,EAAE,qBAAqB,CAAC,IAAI,CAAC,GAAG,SAAS,EAS5E;IAED,IAAW,mBAAmB,IAXQ,qBAAqB,CAAC,IAAI,CAAC,GAAG,SAAS,CAa5E;IAED,IAAW,MAAM,YAEhB;IAEM,KAAK;IAUL,YAAY;YAqHL,KAAK;CAKnB"}
|
|
@@ -62,20 +62,29 @@ class ObservedInboundTrack extends events_1.EventEmitter {
|
|
|
62
62
|
this._model = _model;
|
|
63
63
|
this.peerConnection = peerConnection;
|
|
64
64
|
this._storageProvider = _storageProvider;
|
|
65
|
+
this.created = Date.now();
|
|
65
66
|
this._stats = new Map();
|
|
66
67
|
this._execute = (0, SingleExecutor_1.createSingleExecutor)();
|
|
67
68
|
this._closed = false;
|
|
68
69
|
this._updated = Date.now();
|
|
69
|
-
this.bitrate =
|
|
70
|
-
this.rttInMs = -1;
|
|
71
|
-
this.lostPackets = 0;
|
|
72
|
-
this.receivedPackets = 0;
|
|
73
|
-
this.receivedFrames = 0;
|
|
74
|
-
this.decodedFrames = 0;
|
|
75
|
-
this.droppedFrames = 0;
|
|
76
|
-
this.receivedSamples = 0;
|
|
77
|
-
this.silentConcealedSamples = 0;
|
|
70
|
+
this.bitrate = 0;
|
|
78
71
|
this.fractionLoss = 0;
|
|
72
|
+
this.totalLostPackets = 0;
|
|
73
|
+
this.totalReceivedPackets = 0;
|
|
74
|
+
this.totalBytesReceived = 0;
|
|
75
|
+
this.totalReceivedFrames = 0;
|
|
76
|
+
this.totalDecodedFrames = 0;
|
|
77
|
+
this.totalDroppedFrames = 0;
|
|
78
|
+
this.totalReceivedSamples = 0;
|
|
79
|
+
this.totalSilentConcealedSamples = 0;
|
|
80
|
+
this.deltaLostPackets = 0;
|
|
81
|
+
this.deltaReceivedPackets = 0;
|
|
82
|
+
this.deltaBytesReceived = 0;
|
|
83
|
+
this.deltaReceivedFrames = 0;
|
|
84
|
+
this.deltaDecodedFrames = 0;
|
|
85
|
+
this.deltaDroppedFrames = 0;
|
|
86
|
+
this.deltaReceivedSamples = 0;
|
|
87
|
+
this.deltaSilentConcealedSamples = 0;
|
|
79
88
|
}
|
|
80
89
|
get serviceId() {
|
|
81
90
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -124,6 +133,9 @@ class ObservedInboundTrack extends events_1.EventEmitter {
|
|
|
124
133
|
get reports() {
|
|
125
134
|
return this.peerConnection.reports;
|
|
126
135
|
}
|
|
136
|
+
get uptimeInMs() {
|
|
137
|
+
return this._updated - this.created;
|
|
138
|
+
}
|
|
127
139
|
set remoteOutboundTrack(track) {
|
|
128
140
|
if (this._closed)
|
|
129
141
|
return;
|
|
@@ -151,13 +163,25 @@ class ObservedInboundTrack extends events_1.EventEmitter {
|
|
|
151
163
|
.catch(() => void 0)
|
|
152
164
|
.finally(() => this.emit('close'));
|
|
153
165
|
}
|
|
166
|
+
resetMetrics() {
|
|
167
|
+
this.bitrate = 0;
|
|
168
|
+
this.rttInMs = undefined;
|
|
169
|
+
this.deltaBytesReceived = 0;
|
|
170
|
+
this.deltaLostPackets = 0;
|
|
171
|
+
this.deltaReceivedFrames = 0;
|
|
172
|
+
this.deltaDecodedFrames = 0;
|
|
173
|
+
this.deltaDroppedFrames = 0;
|
|
174
|
+
this.deltaReceivedSamples = 0;
|
|
175
|
+
this.deltaSilentConcealedSamples = 0;
|
|
176
|
+
this.fractionLoss = 0;
|
|
177
|
+
}
|
|
154
178
|
update(sample, timestamp) {
|
|
155
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
179
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
156
180
|
return __awaiter(this, void 0, void 0, function* () {
|
|
157
181
|
if (this._closed)
|
|
158
182
|
return;
|
|
159
183
|
let executeSave = false;
|
|
160
|
-
const report = Object.assign(Object.assign({ serviceId: this.peerConnection.client.call.serviceId, roomId: this.peerConnection.client.call.roomId, callId: this.peerConnection.client.call.callId, clientId: this.peerConnection.client.clientId, userId: this.peerConnection.client.userId, mediaUnitId: this.peerConnection.client.mediaUnitId, peerConnectionId: this.peerConnection.peerConnectionId }, sample), { timestamp, sampleSeq: -1 });
|
|
184
|
+
const report = Object.assign(Object.assign({ serviceId: this.peerConnection.client.call.serviceId, roomId: this.peerConnection.client.call.roomId, callId: this.peerConnection.client.call.callId, clientId: this.peerConnection.client.clientId, userId: this.peerConnection.client.userId, mediaUnitId: this.peerConnection.client.mediaUnitId, peerConnectionId: this.peerConnection.peerConnectionId }, sample), { timestamp, sampleSeq: -1, remoteClientId: (_a = sample.remoteClientId) !== null && _a !== void 0 ? _a : (_b = this.remoteOutboundTrack) === null || _b === void 0 ? void 0 : _b.peerConnection.client.clientId, remoteUserId: (_c = this.remoteOutboundTrack) === null || _c === void 0 ? void 0 : _c.peerConnection.client.userId, remoteTrackId: (_d = this.remoteOutboundTrack) === null || _d === void 0 ? void 0 : _d.trackId, remotePeerConnectionId: (_e = this.remoteOutboundTrack) === null || _e === void 0 ? void 0 : _e.peerConnection.peerConnectionId });
|
|
161
185
|
if (this.kind === 'audio')
|
|
162
186
|
this.reports.addInboundAudioTrackReport(report);
|
|
163
187
|
else if (this.kind === 'video')
|
|
@@ -173,9 +197,9 @@ class ObservedInboundTrack extends events_1.EventEmitter {
|
|
|
173
197
|
const elapsedTimeInMs = Math.max(1, timestamp - this._updated);
|
|
174
198
|
const lastStat = this._stats.get(sample.ssrc);
|
|
175
199
|
const rttInMs = sample.roundTripTime ? sample.roundTripTime * 1000 : undefined;
|
|
176
|
-
const bitrate = (((
|
|
177
|
-
const lostPackets = ((
|
|
178
|
-
const receivedPackets = ((
|
|
200
|
+
const bitrate = (((_f = sample.bytesReceived) !== null && _f !== void 0 ? _f : 0) - ((_g = lastStat === null || lastStat === void 0 ? void 0 : lastStat.bytesReceived) !== null && _g !== void 0 ? _g : 0)) * 8 / (elapsedTimeInMs / 1000);
|
|
201
|
+
const lostPackets = ((_h = sample.packetsLost) !== null && _h !== void 0 ? _h : 0) - ((_j = lastStat === null || lastStat === void 0 ? void 0 : lastStat.packetsLost) !== null && _j !== void 0 ? _j : 0);
|
|
202
|
+
const receivedPackets = ((_k = sample.packetsReceived) !== null && _k !== void 0 ? _k : 0) - ((_l = lastStat === null || lastStat === void 0 ? void 0 : lastStat.packetsReceived) !== null && _l !== void 0 ? _l : 0);
|
|
179
203
|
const fractionLost = 0 < receivedPackets && 0 < lostPackets ? (lostPackets / (receivedPackets + lostPackets)) : 0;
|
|
180
204
|
let decodedFrames;
|
|
181
205
|
let droppedFrames;
|
|
@@ -184,14 +208,14 @@ class ObservedInboundTrack extends events_1.EventEmitter {
|
|
|
184
208
|
if (this.kind === 'video') {
|
|
185
209
|
const videoSample = sample;
|
|
186
210
|
const lastVideoStat = lastStat;
|
|
187
|
-
decodedFrames = ((
|
|
188
|
-
droppedFrames = ((
|
|
189
|
-
receivedFrames = ((
|
|
211
|
+
decodedFrames = ((_m = videoSample.framesDecoded) !== null && _m !== void 0 ? _m : 0) - ((_o = lastVideoStat === null || lastVideoStat === void 0 ? void 0 : lastVideoStat.framesDecoded) !== null && _o !== void 0 ? _o : 0);
|
|
212
|
+
droppedFrames = ((_p = videoSample.framesDropped) !== null && _p !== void 0 ? _p : 0) - ((_q = lastVideoStat === null || lastVideoStat === void 0 ? void 0 : lastVideoStat.framesDropped) !== null && _q !== void 0 ? _q : 0);
|
|
213
|
+
receivedFrames = ((_r = videoSample.framesReceived) !== null && _r !== void 0 ? _r : 0) - ((_s = lastVideoStat === null || lastVideoStat === void 0 ? void 0 : lastVideoStat.framesReceived) !== null && _s !== void 0 ? _s : 0);
|
|
190
214
|
}
|
|
191
215
|
else if (this.kind === 'audio') {
|
|
192
216
|
const audioSample = sample;
|
|
193
217
|
const lastAudioStat = lastStat;
|
|
194
|
-
silentConcealedSamples = ((
|
|
218
|
+
silentConcealedSamples = ((_t = audioSample.silentConcealedSamples) !== null && _t !== void 0 ? _t : 0) - ((_u = lastAudioStat === null || lastAudioStat === void 0 ? void 0 : lastAudioStat.silentConcealedSamples) !== null && _u !== void 0 ? _u : 0);
|
|
195
219
|
}
|
|
196
220
|
const stats = Object.assign(Object.assign({}, sample), { fractionLost,
|
|
197
221
|
rttInMs,
|
|
@@ -204,14 +228,23 @@ class ObservedInboundTrack extends events_1.EventEmitter {
|
|
|
204
228
|
this._stats.set(sample.ssrc, stats);
|
|
205
229
|
this.bitrate = [...this._stats.values()].reduce((acc, stat) => acc + stat.bitrate, 0);
|
|
206
230
|
this.rttInMs = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.rttInMs) !== null && _a !== void 0 ? _a : 0); }, 0) / (this._stats.size || 1);
|
|
207
|
-
this.
|
|
208
|
-
this.
|
|
209
|
-
this.
|
|
210
|
-
this.
|
|
211
|
-
this.
|
|
212
|
-
this.
|
|
213
|
-
this.
|
|
214
|
-
this.
|
|
231
|
+
this.totalLostPackets = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.lostPackets) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
232
|
+
this.totalReceivedPackets = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.receivedPackets) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
233
|
+
this.totalBytesReceived = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.bytesReceived) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
234
|
+
this.totalReceivedFrames = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.receivedFrames) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
235
|
+
this.totalDecodedFrames = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.decodedFrames) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
236
|
+
this.totalDroppedFrames = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.droppedFrames) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
237
|
+
this.totalReceivedSamples = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.receivedSamples) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
238
|
+
this.totalSilentConcealedSamples = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.silentConcealedSamples) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
239
|
+
this.deltaLostPackets = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.lostPackets) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
240
|
+
this.deltaReceivedPackets = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.receivedPackets) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
241
|
+
this.deltaBytesReceived = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.bytesReceived) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
242
|
+
this.deltaReceivedFrames = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.receivedFrames) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
243
|
+
this.deltaDecodedFrames = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.decodedFrames) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
244
|
+
this.deltaDroppedFrames = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.droppedFrames) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
245
|
+
this.deltaReceivedSamples = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.receivedSamples) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
246
|
+
this.deltaSilentConcealedSamples = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.silentConcealedSamples) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
247
|
+
this.fractionLoss = 0 < this.deltaReceivedPackets && 0 < this.deltaLostPackets ? (this.deltaLostPackets / (this.deltaReceivedPackets + this.deltaLostPackets)) : 0;
|
|
215
248
|
if (executeSave)
|
|
216
249
|
yield this._save();
|
|
217
250
|
this._updated = timestamp;
|
|
@@ -19,6 +19,11 @@ export type ObservedOutboundTrackStats<K extends MediaKind> = ObservedOutboundTr
|
|
|
19
19
|
ssrc: number;
|
|
20
20
|
bitrate: number;
|
|
21
21
|
rttInMs?: number;
|
|
22
|
+
deltaLostPackets: number;
|
|
23
|
+
deltaSentPackets: number;
|
|
24
|
+
deltaSentBytes: number;
|
|
25
|
+
deltaSentFrames?: number;
|
|
26
|
+
deltaEncodedFrames?: number;
|
|
22
27
|
};
|
|
23
28
|
export declare interface ObservedOutboundTrack<Kind extends MediaKind> {
|
|
24
29
|
on<U extends keyof ObservedOutboundTrackEvents>(event: U, listener: (...args: ObservedOutboundTrackEvents[U]) => void): this;
|
|
@@ -32,8 +37,18 @@ export declare class ObservedOutboundTrack<Kind extends MediaKind> extends Event
|
|
|
32
37
|
readonly peerConnection: ObservedPeerConnection;
|
|
33
38
|
private readonly _storageProvider;
|
|
34
39
|
static create<K extends MediaKind>(config: ObservedOutboundTrackConfig<K>, peerConnection: ObservedPeerConnection, storageProvider: StorageProvider): Promise<ObservedOutboundTrack<K>>;
|
|
35
|
-
bitrate
|
|
40
|
+
bitrate: number;
|
|
36
41
|
rttInMs?: number;
|
|
42
|
+
totalLostPackets: number;
|
|
43
|
+
totalSentPackets: number;
|
|
44
|
+
totalSentBytes: number;
|
|
45
|
+
totalSentFrames: number;
|
|
46
|
+
deltaLostPackets: number;
|
|
47
|
+
deltaSentPackets: number;
|
|
48
|
+
deltaSentBytes: number;
|
|
49
|
+
deltaSentFrames: number;
|
|
50
|
+
deltaEncodedFrames: number;
|
|
51
|
+
created: number;
|
|
37
52
|
private readonly _stats;
|
|
38
53
|
private readonly _execute;
|
|
39
54
|
private _closed;
|
|
@@ -43,12 +58,14 @@ export declare class ObservedOutboundTrack<Kind extends MediaKind> extends Event
|
|
|
43
58
|
get kind(): Kind;
|
|
44
59
|
get trackId(): string;
|
|
45
60
|
get sfuStreamId(): string | undefined;
|
|
46
|
-
get closed(): boolean;
|
|
47
61
|
get remoteInboundTracks(): ReadonlyMap<string, ObservedInboundTrack<Kind>>;
|
|
48
62
|
get reports(): import("./ReportsCollector").ReportsCollector;
|
|
49
63
|
get updated(): number;
|
|
50
|
-
close(): void;
|
|
51
64
|
get stats(): ReadonlyMap<number, ObservedOutboundTrackStats<Kind>>;
|
|
65
|
+
get uptimeInMs(): number;
|
|
66
|
+
get closed(): boolean;
|
|
67
|
+
close(): void;
|
|
68
|
+
resetMetrics(): void;
|
|
52
69
|
connectInboundTrack(track: ObservedInboundTrack<Kind>): void;
|
|
53
70
|
private _save;
|
|
54
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservedOutboundTrack.d.ts","sourceRoot":"","sources":["../src/ObservedOutboundTrack.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3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