@observertc/observer-js 0.30.2-beta → 0.30.3-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 +8 -21
- package/lib/ObservedClient.d.ts.map +1 -1
- package/lib/ObservedClient.js +74 -10
- 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 -7
- package/lib/ObservedPeerConnection.d.ts.map +1 -1
- package/lib/ObservedPeerConnection.js +113 -19
- package/package.json +1 -1
- package/src/ObservedClient.ts +79 -24
- package/src/ObservedInboundTrack.ts +62 -17
- package/src/ObservedOutboundTrack.ts +70 -9
- package/src/ObservedPeerConnection.ts +146 -19
- 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
|
@@ -36,6 +36,7 @@ export declare class ObservedClient<AppData extends Record<string, unknown> = Re
|
|
|
36
36
|
private readonly _storageProvider;
|
|
37
37
|
readonly appData: AppData;
|
|
38
38
|
static create<T extends Record<string, unknown> = Record<string, unknown>>(config: ObservedClientConfig<T>, call: ObservedCall, storageProvider: StorageProvider): Promise<ObservedClient<T>>;
|
|
39
|
+
created: number;
|
|
39
40
|
private readonly _peerConnections;
|
|
40
41
|
private readonly _execute;
|
|
41
42
|
private _overflowingProcessingThreshold;
|
|
@@ -47,34 +48,19 @@ export declare class ObservedClient<AppData extends Record<string, unknown> = Re
|
|
|
47
48
|
private _leaveReported;
|
|
48
49
|
totalInboundPacketsLost: number;
|
|
49
50
|
totalInboundPacketsReceived: number;
|
|
50
|
-
totalOutboundPacketsLost: number;
|
|
51
|
-
totalOutboundPacketsReceived: number;
|
|
52
51
|
totalOutboundPacketsSent: number;
|
|
53
52
|
totalDataChannelBytesSent: number;
|
|
54
53
|
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;
|
|
54
|
+
totalSentBytes: number;
|
|
55
|
+
totalReceivedBytes: number;
|
|
70
56
|
avgRttInS?: number;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
receivingAudioBitrate?: number;
|
|
74
|
-
receivingVideoBitrate?: number;
|
|
57
|
+
sendingBitrate?: number;
|
|
58
|
+
receivingBitrate?: number;
|
|
75
59
|
readonly mediaDevices: string[];
|
|
76
60
|
readonly codecs: string[];
|
|
77
61
|
readonly userMediaErrors: string[];
|
|
62
|
+
readonly ωpendingCreatedTracksTimestamp: Map<string, number>;
|
|
63
|
+
readonly ωpendingCreatedPeerConnectionTimestamp: Map<string, number>;
|
|
78
64
|
private constructor();
|
|
79
65
|
get joined(): number;
|
|
80
66
|
get clientId(): string;
|
|
@@ -92,6 +78,7 @@ export declare class ObservedClient<AppData extends Record<string, unknown> = Re
|
|
|
92
78
|
get platform(): Samples_ClientSample_Platform | undefined;
|
|
93
79
|
get acceptedSample(): number;
|
|
94
80
|
get updated(): number;
|
|
81
|
+
get uptimeInMs(): number;
|
|
95
82
|
get closed(): boolean;
|
|
96
83
|
get peerConnections(): ReadonlyMap<string, ObservedPeerConnection>;
|
|
97
84
|
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;AAC7D,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;CAC5C,CAAC;AAEF,MAAM,CAAC,OAAO,WAAW,cAAc,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,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MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAEjC,SAAgB,YAAY,EAAE,MAAM,EAAE,CAAM;IAC5C,SAAgB,MAAM,EAAE,MAAM,EAAE,CAAM;IACtC,SAAgB,eAAe,EAAE,MAAM,EAAE,CAAM;IAE/C,SAAgB,8BAA8B,sBAA6B;IAC3E,SAAgB,sCAAsC,sBAA6B;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;YAoiB1C,qBAAqB;YA0BrB,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,10 +283,13 @@ 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;
|
|
@@ -292,8 +302,30 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
292
302
|
case CallEventType_1.CallEventType.PEER_CONNECTION_STATE_CHANGED:
|
|
293
303
|
peerConnection && callEvent.value && peerConnection.emit('connectionstatechange', callEvent.value);
|
|
294
304
|
break;
|
|
305
|
+
case CallEventType_1.CallEventType.PEER_CONNECTION_OPENED: {
|
|
306
|
+
if (!callEvent.peerConnectionId)
|
|
307
|
+
break;
|
|
308
|
+
if (peerConnection) {
|
|
309
|
+
peerConnection.created = timestamp !== null && timestamp !== void 0 ? timestamp : peerConnection.created;
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
this.ωpendingCreatedPeerConnectionTimestamp.set(callEvent.peerConnectionId, timestamp !== null && timestamp !== void 0 ? timestamp : Date.now());
|
|
313
|
+
}
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
case CallEventType_1.CallEventType.MEDIA_TRACK_ADDED: {
|
|
317
|
+
if (!callEvent.mediaTrackId)
|
|
318
|
+
break;
|
|
319
|
+
const track = peerConnection === null || peerConnection === void 0 ? void 0 : peerConnection.getTrack(callEvent.mediaTrackId);
|
|
320
|
+
if (track) {
|
|
321
|
+
track.created = timestamp !== null && timestamp !== void 0 ? timestamp : track.created;
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
this.ωpendingCreatedTracksTimestamp.set(callEvent.mediaTrackId, timestamp !== null && timestamp !== void 0 ? timestamp : Date.now());
|
|
325
|
+
}
|
|
326
|
+
}
|
|
295
327
|
}
|
|
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));
|
|
328
|
+
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
329
|
}
|
|
298
330
|
for (const userMediaError of (_r = sample.userMediaErrors) !== null && _r !== void 0 ? _r : []) {
|
|
299
331
|
const callMetaReport = (0, callMetaReports_1.createCallMetaReport)(this.serviceId, this.mediaUnitId, this.roomId, this.callId, this.clientId, {
|
|
@@ -502,6 +534,33 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
502
534
|
}
|
|
503
535
|
}
|
|
504
536
|
}
|
|
537
|
+
// update metrics
|
|
538
|
+
this.totalSentBytes = 0;
|
|
539
|
+
this.totalReceivedBytes = 0;
|
|
540
|
+
this.totalOutboundPacketsSent = 0;
|
|
541
|
+
this.totalInboundPacketsReceived = 0;
|
|
542
|
+
this.totalInboundPacketsLost = 0;
|
|
543
|
+
this.totalDataChannelBytesSent = 0;
|
|
544
|
+
this.totalDataChannelBytesReceived = 0;
|
|
545
|
+
this.sendingBitrate = 0;
|
|
546
|
+
this.receivingBitrate = 0;
|
|
547
|
+
let sumRttInS = 0;
|
|
548
|
+
for (const peerConnection of this._peerConnections.values()) {
|
|
549
|
+
if (peerConnection.closed)
|
|
550
|
+
continue;
|
|
551
|
+
peerConnection.updateMetrics();
|
|
552
|
+
this.totalSentBytes += peerConnection.totalSentAudioBytes + peerConnection.totalSentVideoBytes;
|
|
553
|
+
this.totalReceivedBytes += peerConnection.totalReceivedAudioBytes + peerConnection.totalReceivedVideoBytes;
|
|
554
|
+
this.totalOutboundPacketsSent += peerConnection.totalOutboundPacketsSent;
|
|
555
|
+
this.totalInboundPacketsReceived += peerConnection.totalInboundPacketsReceived;
|
|
556
|
+
this.totalInboundPacketsLost += peerConnection.totalInboundPacketsLost;
|
|
557
|
+
this.totalDataChannelBytesSent += peerConnection.totalDataChannelBytesSent;
|
|
558
|
+
this.totalDataChannelBytesReceived += peerConnection.totalDataChannelBytesReceived;
|
|
559
|
+
this.sendingBitrate += peerConnection.sendingAudioBitrate + peerConnection.sendingVideoBitrate;
|
|
560
|
+
this.receivingBitrate += peerConnection.receivingAudioBitrate + peerConnection.receivingVideoBitrate;
|
|
561
|
+
sumRttInS += (_16 = peerConnection.avgRttInS) !== null && _16 !== void 0 ? _16 : 0;
|
|
562
|
+
}
|
|
563
|
+
this.avgRttInS = this._peerConnections.size ? sumRttInS / this._peerConnections.size : -1;
|
|
505
564
|
if (executeSave)
|
|
506
565
|
yield this._save();
|
|
507
566
|
this._updated = sample.timestamp;
|
|
@@ -516,6 +575,11 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
516
575
|
const result = yield ObservedPeerConnection_1.ObservedPeerConnection.create({
|
|
517
576
|
peerConnectionId,
|
|
518
577
|
}, this, this._storageProvider);
|
|
578
|
+
const pendingTracksTimestamp = this.ωpendingCreatedTracksTimestamp.get(peerConnectionId);
|
|
579
|
+
if (pendingTracksTimestamp) {
|
|
580
|
+
result.created = pendingTracksTimestamp;
|
|
581
|
+
this.ωpendingCreatedTracksTimestamp.delete(peerConnectionId);
|
|
582
|
+
}
|
|
519
583
|
result.once('close', () => {
|
|
520
584
|
this._peerConnections.delete(peerConnectionId);
|
|
521
585
|
this._model.peerConnectionIds = this._model.peerConnectionIds.filter((id) => id !== peerConnectionId);
|
|
@@ -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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|
|
|
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;AAG3C,MAAM,MAAM,2BAA2B,CAAC,CAAC,SAAS,SAAS,IAAI;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,CAAC,CAAC;IACR,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACzC,MAAM,EAAE,EAAE,CAAC;IACX,KAAK,EAAE,EAAE,CAAC;CACV,CAAC;AAEF,MAAM,MAAM,gCAAgC,CAAC,CAAC,SAAS,SAAS,IAAI,CAAC,SAAS,OAAO,GAAG,kBAAkB,GAAG,kBAAkB,CAAC;AAEhI,MAAM,MAAM,0BAA0B,CAAC,CAAC,SAAS,SAAS,IAAI,gCAAgC,CAAC,CAAC,CAAC,GAAG;IACnG,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"ObservedOutboundTrack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B,kBAAkB,SAAK;IAEvB,OAAO,SAAc;IAE5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuD;IAC9E,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA0B;IAEnD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,oBAAoB,CAAiD;IAE7E,OAAO;IAQP,IAAW,IAAI,IAAI,IAAI,CAGtB;IAED,IAAW,OAAO,WAGjB;IAED,IAAW,WAAW,uBAErB;IAED,IAAW,mBAAmB,IAAI,WAAW,CAAC,MAAM,EAAE,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAEhF;IAED,IAAW,OAAO,kDAEjB;IAED,IAAW,OAAO,WAEjB;IAED,IAAW,KAAK,IAAI,WAAW,CAAC,MAAM,EAAE,0BAA0B,CAAC,IAAI,CAAC,CAAC,CAExE;IAED,IAAW,UAAU,WAEpB;IAED,IAAW,MAAM,YAEhB;IAEM,KAAK;IAUL,YAAY;IAkGZ,mBAAmB,CAAC,KAAK,EAAE,oBAAoB,CAAC,IAAI,CAAC;YAW9C,KAAK;CAKnB"}
|
|
@@ -61,6 +61,17 @@ class ObservedOutboundTrack extends events_1.EventEmitter {
|
|
|
61
61
|
this._model = _model;
|
|
62
62
|
this.peerConnection = peerConnection;
|
|
63
63
|
this._storageProvider = _storageProvider;
|
|
64
|
+
this.bitrate = 0;
|
|
65
|
+
this.totalLostPackets = 0;
|
|
66
|
+
this.totalSentPackets = 0;
|
|
67
|
+
this.totalSentBytes = 0;
|
|
68
|
+
this.totalSentFrames = 0;
|
|
69
|
+
this.deltaLostPackets = 0;
|
|
70
|
+
this.deltaSentPackets = 0;
|
|
71
|
+
this.deltaSentBytes = 0;
|
|
72
|
+
this.deltaSentFrames = 0;
|
|
73
|
+
this.deltaEncodedFrames = 0;
|
|
74
|
+
this.created = Date.now();
|
|
64
75
|
this._stats = new Map();
|
|
65
76
|
this._execute = (0, SingleExecutor_1.createSingleExecutor)();
|
|
66
77
|
this._closed = false;
|
|
@@ -78,9 +89,6 @@ class ObservedOutboundTrack extends events_1.EventEmitter {
|
|
|
78
89
|
get sfuStreamId() {
|
|
79
90
|
return this._model.sfuStreamId;
|
|
80
91
|
}
|
|
81
|
-
get closed() {
|
|
82
|
-
return this._closed;
|
|
83
|
-
}
|
|
84
92
|
get remoteInboundTracks() {
|
|
85
93
|
return this._remoteInboundTracks;
|
|
86
94
|
}
|
|
@@ -90,6 +98,15 @@ class ObservedOutboundTrack extends events_1.EventEmitter {
|
|
|
90
98
|
get updated() {
|
|
91
99
|
return this._updated;
|
|
92
100
|
}
|
|
101
|
+
get stats() {
|
|
102
|
+
return this._stats;
|
|
103
|
+
}
|
|
104
|
+
get uptimeInMs() {
|
|
105
|
+
return this._updated - this.created;
|
|
106
|
+
}
|
|
107
|
+
get closed() {
|
|
108
|
+
return this._closed;
|
|
109
|
+
}
|
|
93
110
|
close() {
|
|
94
111
|
if (this._closed)
|
|
95
112
|
return;
|
|
@@ -98,11 +115,17 @@ class ObservedOutboundTrack extends events_1.EventEmitter {
|
|
|
98
115
|
.catch(() => void 0)
|
|
99
116
|
.finally(() => this.emit('close'));
|
|
100
117
|
}
|
|
101
|
-
|
|
102
|
-
|
|
118
|
+
resetMetrics() {
|
|
119
|
+
this.bitrate = 0;
|
|
120
|
+
this.rttInMs = 0;
|
|
121
|
+
this.deltaLostPackets = 0;
|
|
122
|
+
this.deltaSentPackets = 0;
|
|
123
|
+
this.deltaSentBytes = 0;
|
|
124
|
+
this.deltaSentFrames = 0;
|
|
125
|
+
this.deltaEncodedFrames = 0;
|
|
103
126
|
}
|
|
104
127
|
update(sample, timestamp) {
|
|
105
|
-
var _a, _b;
|
|
128
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
106
129
|
return __awaiter(this, void 0, void 0, function* () {
|
|
107
130
|
if (this._closed)
|
|
108
131
|
return;
|
|
@@ -116,13 +139,34 @@ class ObservedOutboundTrack extends events_1.EventEmitter {
|
|
|
116
139
|
const lastStat = this._stats.get(sample.ssrc);
|
|
117
140
|
const rttInMs = sample.roundTripTime ? sample.roundTripTime * 1000 : undefined;
|
|
118
141
|
const bitrate = (((_a = sample.bytesSent) !== null && _a !== void 0 ? _a : 0) - ((_b = lastStat === null || lastStat === void 0 ? void 0 : lastStat.bytesSent) !== null && _b !== void 0 ? _b : 0)) * 8 / (elapsedTimeInMs / 1000);
|
|
119
|
-
|
|
120
|
-
|
|
142
|
+
const deltaLostPackets = ((_c = sample.packetsLost) !== null && _c !== void 0 ? _c : 0) - ((_d = lastStat === null || lastStat === void 0 ? void 0 : lastStat.packetsLost) !== null && _d !== void 0 ? _d : 0);
|
|
143
|
+
const deltaSentPackets = ((_e = sample.packetsSent) !== null && _e !== void 0 ? _e : 0) - ((_f = lastStat === null || lastStat === void 0 ? void 0 : lastStat.packetsSent) !== null && _f !== void 0 ? _f : 0);
|
|
144
|
+
const deltaSentBytes = ((_g = sample.bytesSent) !== null && _g !== void 0 ? _g : 0) - ((_h = lastStat === null || lastStat === void 0 ? void 0 : lastStat.bytesSent) !== null && _h !== void 0 ? _h : 0);
|
|
145
|
+
let deltaEncodedFrames;
|
|
146
|
+
let deltaSentFrames;
|
|
147
|
+
if (this.kind === 'video') {
|
|
148
|
+
const videoSample = sample;
|
|
149
|
+
const lastVideoStats = lastStat;
|
|
150
|
+
deltaEncodedFrames = ((_j = videoSample.framesEncoded) !== null && _j !== void 0 ? _j : 0) - ((_k = lastVideoStats === null || lastVideoStats === void 0 ? void 0 : lastVideoStats.framesEncoded) !== null && _k !== void 0 ? _k : 0);
|
|
151
|
+
deltaSentFrames = ((_l = videoSample.framesSent) !== null && _l !== void 0 ? _l : 0) - ((_m = lastVideoStats === null || lastVideoStats === void 0 ? void 0 : lastVideoStats.framesSent) !== null && _m !== void 0 ? _m : 0);
|
|
152
|
+
}
|
|
121
153
|
const stats = Object.assign(Object.assign({}, sample), { rttInMs,
|
|
122
|
-
bitrate, ssrc: sample.ssrc
|
|
154
|
+
bitrate, ssrc: sample.ssrc, deltaLostPackets,
|
|
155
|
+
deltaSentPackets,
|
|
156
|
+
deltaSentBytes,
|
|
157
|
+
deltaEncodedFrames,
|
|
158
|
+
deltaSentFrames });
|
|
123
159
|
this._stats.set(sample.ssrc, stats);
|
|
124
160
|
this.bitrate = [...this._stats.values()].reduce((acc, stat) => acc + stat.bitrate, 0);
|
|
125
161
|
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);
|
|
162
|
+
this.totalLostPackets = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.packetsLost) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
163
|
+
this.totalSentPackets = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.packetsSent) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
164
|
+
this.totalSentBytes = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.bytesSent) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
165
|
+
this.deltaEncodedFrames = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.deltaEncodedFrames) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
166
|
+
this.deltaSentFrames = [...this._stats.values()].reduce((acc, stat) => { var _a; return acc + ((_a = stat.deltaSentFrames) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
167
|
+
this.deltaLostPackets = [...this._stats.values()].reduce((acc, stat) => acc + stat.deltaLostPackets, 0);
|
|
168
|
+
this.deltaSentPackets = [...this._stats.values()].reduce((acc, stat) => acc + stat.deltaSentPackets, 0);
|
|
169
|
+
this.deltaSentBytes = [...this._stats.values()].reduce((acc, stat) => acc + stat.deltaSentBytes, 0);
|
|
126
170
|
// setting up sfu connection as it is not always available at the first sample
|
|
127
171
|
if (sample.sfuStreamId && !this._model.sfuStreamId) {
|
|
128
172
|
this._model.sfuStreamId = sample.sfuStreamId;
|