@observertc/observer-js 0.30.1-beta → 0.30.2-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ObservedClient.d.ts +28 -6
- package/lib/ObservedClient.d.ts.map +1 -1
- package/lib/ObservedClient.js +84 -75
- package/lib/ObservedICE.d.ts +47 -0
- package/lib/ObservedICE.d.ts.map +1 -0
- package/lib/ObservedICE.js +105 -0
- package/lib/ObservedInboundTrack.d.ts +16 -0
- package/lib/ObservedInboundTrack.d.ts.map +1 -1
- package/lib/ObservedInboundTrack.js +39 -2
- package/lib/ObservedPeerConnection.d.ts +39 -1
- package/lib/ObservedPeerConnection.d.ts.map +1 -1
- package/lib/ObservedPeerConnection.js +61 -0
- package/lib/common/CallEventType.d.ts +22 -0
- package/lib/common/CallEventType.d.ts.map +1 -0
- package/lib/common/CallEventType.js +26 -0
- package/lib/common/callEventReports.d.ts +0 -10
- package/lib/common/callEventReports.d.ts.map +1 -1
- package/lib/common/callEventReports.js +10 -21
- package/lib/models/Models.d.ts +3 -70
- package/lib/models/Models.d.ts.map +1 -1
- package/lib/models/Models.js +2 -72
- package/lib/models/samples_pb.js +1 -1
- package/package.json +1 -1
- package/src/ObservedClient.ts +90 -88
- package/src/ObservedICE.ts +176 -0
- package/src/ObservedInboundTrack.ts +50 -1
- package/src/ObservedPeerConnection.ts +79 -2
- package/src/common/CallEventType.ts +23 -0
- package/src/common/callEventReports.ts +1 -11
- package/src/models/Models.ts +4 -113
- package/src/models/samples_pb.ts +1 -1
package/lib/ObservedClient.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { ClientSample
|
|
2
|
+
import { ClientSample } from '@observertc/sample-schemas-js';
|
|
3
3
|
import { ObservedCall } from './ObservedCall';
|
|
4
4
|
import { StorageProvider } from './storages/StorageProvider';
|
|
5
5
|
import { EventEmitter } from 'events';
|
|
@@ -21,7 +21,6 @@ export type ObservedClientEvents = {
|
|
|
21
21
|
update: [];
|
|
22
22
|
close: [];
|
|
23
23
|
'processing-sample-overflow': [];
|
|
24
|
-
'candidate-pair-change': [];
|
|
25
24
|
newpeerconnection: [ObservedPeerConnection];
|
|
26
25
|
};
|
|
27
26
|
export declare interface ObservedClient<AppData extends Record<string, unknown> = Record<string, unknown>> {
|
|
@@ -44,10 +43,35 @@ export declare class ObservedClient<AppData extends Record<string, unknown> = Re
|
|
|
44
43
|
private _updated;
|
|
45
44
|
private _acceptedSample;
|
|
46
45
|
private _processingSample;
|
|
47
|
-
private _selectedLocalIceCandidate?;
|
|
48
|
-
private _selectedRemoteIceCandidate?;
|
|
49
46
|
private _timeZoneOffsetInHours?;
|
|
50
47
|
private _leaveReported;
|
|
48
|
+
totalInboundPacketsLost: number;
|
|
49
|
+
totalInboundPacketsReceived: number;
|
|
50
|
+
totalOutboundPacketsLost: number;
|
|
51
|
+
totalOutboundPacketsReceived: number;
|
|
52
|
+
totalOutboundPacketsSent: number;
|
|
53
|
+
totalDataChannelBytesSent: number;
|
|
54
|
+
totalDataChannelBytesReceived: number;
|
|
55
|
+
totalSentAudioBytes: number;
|
|
56
|
+
totalSentVideoBytes: number;
|
|
57
|
+
totalReceivedAudioBytes: number;
|
|
58
|
+
totalReceivedVideoBytes: number;
|
|
59
|
+
deltaInboundPacketsLost?: number;
|
|
60
|
+
deltaInboundPacketsReceived?: number;
|
|
61
|
+
deltaOutboundPacketsLost?: number;
|
|
62
|
+
deltaOutboundPacketsReceived?: number;
|
|
63
|
+
deltaOutboundPacketsSent?: number;
|
|
64
|
+
deltaDataChannelBytesSent?: number;
|
|
65
|
+
deltaDataChannelBytesReceived?: number;
|
|
66
|
+
deltaReceivedAudioBytes?: number;
|
|
67
|
+
deltaReceivedVideoBytes?: number;
|
|
68
|
+
deltaSentAudioBytes?: number;
|
|
69
|
+
deltaSentVideoBytes?: number;
|
|
70
|
+
avgRttInS?: number;
|
|
71
|
+
sendingAudioBitrate?: number;
|
|
72
|
+
sendingVideoBitrate?: number;
|
|
73
|
+
receivingAudioBitrate?: number;
|
|
74
|
+
receivingVideoBitrate?: number;
|
|
51
75
|
readonly mediaDevices: string[];
|
|
52
76
|
readonly codecs: string[];
|
|
53
77
|
readonly userMediaErrors: string[];
|
|
@@ -60,8 +84,6 @@ export declare class ObservedClient<AppData extends Record<string, unknown> = Re
|
|
|
60
84
|
get mediaUnitId(): string;
|
|
61
85
|
get reports(): import("./ReportsCollector").ReportsCollector;
|
|
62
86
|
get userId(): string | undefined;
|
|
63
|
-
get selectedLocalIceCandidate(): IceLocalCandidate | undefined;
|
|
64
|
-
get selectedRemoteIceCandidate(): IceLocalCandidate | undefined;
|
|
65
87
|
get timeZoneOffsetInHours(): number | undefined;
|
|
66
88
|
get marker(): string | undefined;
|
|
67
89
|
get browser(): Samples_ClientSample_Browser | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservedClient.d.ts","sourceRoot":"","sources":["../src/ObservedClient.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,
|
|
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,C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,OAAO,CAAC,oBAAoB;CAe5B"}
|
package/lib/ObservedClient.js
CHANGED
|
@@ -54,6 +54,7 @@ const callMetaReports_1 = require("./common/callMetaReports");
|
|
|
54
54
|
const samples_pb_1 = require("./models/samples_pb");
|
|
55
55
|
const utils_1 = require("./common/utils");
|
|
56
56
|
const callEventReports_1 = require("./common/callEventReports");
|
|
57
|
+
const CallEventType_1 = require("./common/CallEventType");
|
|
57
58
|
const logger = (0, logger_1.createLogger)('ObservedClient');
|
|
58
59
|
class ObservedClient extends events_1.EventEmitter {
|
|
59
60
|
static create(config, call, storageProvider) {
|
|
@@ -95,6 +96,17 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
95
96
|
this._acceptedSample = 0;
|
|
96
97
|
this._processingSample = 0;
|
|
97
98
|
this._leaveReported = false;
|
|
99
|
+
this.totalInboundPacketsLost = 0;
|
|
100
|
+
this.totalInboundPacketsReceived = 0;
|
|
101
|
+
this.totalOutboundPacketsLost = 0;
|
|
102
|
+
this.totalOutboundPacketsReceived = 0;
|
|
103
|
+
this.totalOutboundPacketsSent = 0;
|
|
104
|
+
this.totalDataChannelBytesSent = 0;
|
|
105
|
+
this.totalDataChannelBytesReceived = 0;
|
|
106
|
+
this.totalSentAudioBytes = 0;
|
|
107
|
+
this.totalSentVideoBytes = 0;
|
|
108
|
+
this.totalReceivedAudioBytes = 0;
|
|
109
|
+
this.totalReceivedVideoBytes = 0;
|
|
98
110
|
this.mediaDevices = [];
|
|
99
111
|
this.codecs = [];
|
|
100
112
|
this.userMediaErrors = [];
|
|
@@ -129,12 +141,6 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
129
141
|
get userId() {
|
|
130
142
|
return this._model.userId;
|
|
131
143
|
}
|
|
132
|
-
get selectedLocalIceCandidate() {
|
|
133
|
-
return this._selectedLocalIceCandidate;
|
|
134
|
-
}
|
|
135
|
-
get selectedRemoteIceCandidate() {
|
|
136
|
-
return this._selectedRemoteIceCandidate;
|
|
137
|
-
}
|
|
138
144
|
get timeZoneOffsetInHours() {
|
|
139
145
|
return this._timeZoneOffsetInHours;
|
|
140
146
|
}
|
|
@@ -187,7 +193,7 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
187
193
|
this.emit('processing-sample-overflow');
|
|
188
194
|
}
|
|
189
195
|
return this._execute(() => __awaiter(this, void 0, void 0, function* () {
|
|
190
|
-
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
|
|
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;
|
|
191
197
|
let executeSave = false;
|
|
192
198
|
if (this.userId !== sample.userId) {
|
|
193
199
|
this._model.userId = sample.userId;
|
|
@@ -270,13 +276,26 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
270
276
|
extensionType: extensionStats.type,
|
|
271
277
|
});
|
|
272
278
|
}
|
|
273
|
-
for (let
|
|
274
|
-
const { timestamp = Date.now() } =
|
|
275
|
-
|
|
276
|
-
|
|
279
|
+
for (let _16 of (_p = sample.customCallEvents) !== null && _p !== void 0 ? _p : []) {
|
|
280
|
+
const { timestamp = Date.now() } = _16, callEvent = __rest(_16, ["timestamp"]);
|
|
281
|
+
const peerConnection = this._peerConnections.get((_q = callEvent.peerConnectionId) !== null && _q !== void 0 ? _q : '');
|
|
282
|
+
switch (callEvent.name) {
|
|
283
|
+
case CallEventType_1.CallEventType.CLIENT_LEFT:
|
|
284
|
+
this._leaveReported = true;
|
|
285
|
+
break;
|
|
286
|
+
case CallEventType_1.CallEventType.ICE_CONNECTION_STATE_CHANGED:
|
|
287
|
+
peerConnection && callEvent.value && peerConnection.emit('iceconnectionstatechange', callEvent.value);
|
|
288
|
+
break;
|
|
289
|
+
case CallEventType_1.CallEventType.ICE_GATHERING_STATE_CHANGED:
|
|
290
|
+
peerConnection && callEvent.value && peerConnection.emit('icegatheringstatechange', callEvent.value);
|
|
291
|
+
break;
|
|
292
|
+
case CallEventType_1.CallEventType.PEER_CONNECTION_STATE_CHANGED:
|
|
293
|
+
peerConnection && callEvent.value && peerConnection.emit('connectionstatechange', callEvent.value);
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
277
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));
|
|
278
297
|
}
|
|
279
|
-
for (const userMediaError of (
|
|
298
|
+
for (const userMediaError of (_r = sample.userMediaErrors) !== null && _r !== void 0 ? _r : []) {
|
|
280
299
|
const callMetaReport = (0, callMetaReports_1.createCallMetaReport)(this.serviceId, this.mediaUnitId, this.roomId, this.callId, this.clientId, {
|
|
281
300
|
type: callMetaReports_1.CallMetaType.USER_MEDIA_ERROR,
|
|
282
301
|
payload: userMediaError,
|
|
@@ -284,14 +303,14 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
284
303
|
this.reports.addCallMetaReport(callMetaReport);
|
|
285
304
|
this.userMediaErrors.push(userMediaError);
|
|
286
305
|
}
|
|
287
|
-
for (const certificate of (
|
|
306
|
+
for (const certificate of (_s = sample.certificates) !== null && _s !== void 0 ? _s : []) {
|
|
288
307
|
const callMetaReport = (0, callMetaReports_1.createCallMetaReport)(this.serviceId, this.mediaUnitId, this.roomId, this.callId, this.clientId, {
|
|
289
308
|
type: callMetaReports_1.CallMetaType.CERTIFICATE,
|
|
290
309
|
payload: certificate,
|
|
291
310
|
}, this.userId);
|
|
292
311
|
this.reports.addCallMetaReport(callMetaReport);
|
|
293
312
|
}
|
|
294
|
-
for (const codec of (
|
|
313
|
+
for (const codec of (_t = sample.codecs) !== null && _t !== void 0 ? _t : []) {
|
|
295
314
|
const callMetaReport = (0, callMetaReports_1.createCallMetaReport)(this.serviceId, this.mediaUnitId, this.roomId, this.callId, this.clientId, {
|
|
296
315
|
type: callMetaReports_1.CallMetaType.CODEC,
|
|
297
316
|
payload: codec,
|
|
@@ -299,14 +318,14 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
299
318
|
this.reports.addCallMetaReport(callMetaReport);
|
|
300
319
|
codec.mimeType && this.codecs.push(codec.mimeType);
|
|
301
320
|
}
|
|
302
|
-
for (const iceServer of (
|
|
321
|
+
for (const iceServer of (_u = sample.iceServers) !== null && _u !== void 0 ? _u : []) {
|
|
303
322
|
const callMetaReport = (0, callMetaReports_1.createCallMetaReport)(this.serviceId, this.mediaUnitId, this.roomId, this.callId, this.clientId, {
|
|
304
323
|
type: callMetaReports_1.CallMetaType.ICE_SERVER,
|
|
305
324
|
payload: iceServer,
|
|
306
325
|
}, this.userId);
|
|
307
326
|
this.reports.addCallMetaReport(callMetaReport);
|
|
308
327
|
}
|
|
309
|
-
for (const mediaDevice of (
|
|
328
|
+
for (const mediaDevice of (_v = sample.mediaDevices) !== null && _v !== void 0 ? _v : []) {
|
|
310
329
|
const callMetaReport = (0, callMetaReports_1.createCallMetaReport)(this.serviceId, this.mediaUnitId, this.roomId, this.callId, this.clientId, {
|
|
311
330
|
type: callMetaReports_1.CallMetaType.MEDIA_DEVICE,
|
|
312
331
|
payload: mediaDevice,
|
|
@@ -314,77 +333,38 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
314
333
|
this.reports.addCallMetaReport(callMetaReport);
|
|
315
334
|
mediaDevice.label && this.mediaDevices.push(mediaDevice.label);
|
|
316
335
|
}
|
|
317
|
-
for (const mediaSource of (
|
|
336
|
+
for (const mediaSource of (_w = sample.mediaSources) !== null && _w !== void 0 ? _w : []) {
|
|
318
337
|
const callMetaReport = (0, callMetaReports_1.createCallMetaReport)(this.serviceId, this.mediaUnitId, this.roomId, this.callId, this.clientId, {
|
|
319
338
|
type: callMetaReports_1.CallMetaType.MEDIA_SOURCE,
|
|
320
339
|
payload: mediaSource,
|
|
321
340
|
}, this.userId);
|
|
322
341
|
this.reports.addCallMetaReport(callMetaReport);
|
|
323
342
|
}
|
|
324
|
-
|
|
325
|
-
let selectedRemoteCandidateId;
|
|
326
|
-
for (const candidatePair of (_w = sample.iceCandidatePairs) !== null && _w !== void 0 ? _w : []) {
|
|
327
|
-
if (candidatePair.nominated) {
|
|
328
|
-
if (!selectedLocalCandidateId)
|
|
329
|
-
selectedLocalCandidateId = candidatePair.localCandidateId;
|
|
330
|
-
if (!selectedRemoteCandidateId)
|
|
331
|
-
selectedRemoteCandidateId = candidatePair.remoteCandidateId;
|
|
332
|
-
}
|
|
333
|
-
const report = Object.assign(Object.assign({ serviceId: this.serviceId, mediaUnitId: this.mediaUnitId, roomId: this.roomId, callId: this.callId, clientId: this.clientId, userId: this.userId, timestamp: sample.timestamp }, candidatePair), { sampleSeq: -1 });
|
|
334
|
-
this.reports.addIceCandidatePairReport(report);
|
|
335
|
-
}
|
|
336
|
-
let changeIceCandidatePair = false;
|
|
337
|
-
for (const iceLocalCandidate of (_x = sample.iceLocalCandidates) !== null && _x !== void 0 ? _x : []) {
|
|
338
|
-
if (iceLocalCandidate.id && selectedLocalCandidateId &&
|
|
339
|
-
iceLocalCandidate.id === selectedLocalCandidateId &&
|
|
340
|
-
((_y = this._selectedLocalIceCandidate) === null || _y === void 0 ? void 0 : _y.id) !== iceLocalCandidate.id) {
|
|
341
|
-
this._selectedLocalIceCandidate = iceLocalCandidate;
|
|
342
|
-
changeIceCandidatePair = true;
|
|
343
|
-
}
|
|
344
|
-
const callMetaReport = (0, callMetaReports_1.createCallMetaReport)(this.serviceId, this.mediaUnitId, this.roomId, this.callId, this.clientId, {
|
|
345
|
-
type: callMetaReports_1.CallMetaType.ICE_LOCAL_CANDIDATE,
|
|
346
|
-
payload: iceLocalCandidate,
|
|
347
|
-
}, this.userId);
|
|
348
|
-
this.reports.addCallMetaReport(callMetaReport);
|
|
349
|
-
}
|
|
350
|
-
for (const iceRemoteCandidate of (_z = sample.iceRemoteCandidates) !== null && _z !== void 0 ? _z : []) {
|
|
351
|
-
if (iceRemoteCandidate.id && selectedRemoteCandidateId &&
|
|
352
|
-
iceRemoteCandidate.id === selectedRemoteCandidateId &&
|
|
353
|
-
((_0 = this._selectedRemoteIceCandidate) === null || _0 === void 0 ? void 0 : _0.id) !== iceRemoteCandidate.id) {
|
|
354
|
-
this._selectedRemoteIceCandidate = iceRemoteCandidate;
|
|
355
|
-
changeIceCandidatePair = true;
|
|
356
|
-
}
|
|
357
|
-
const callMetaReport = (0, callMetaReports_1.createCallMetaReport)(this.serviceId, this.mediaUnitId, this.roomId, this.callId, this.clientId, {
|
|
358
|
-
type: callMetaReports_1.CallMetaType.ICE_REMOTE_CANDIDATE,
|
|
359
|
-
payload: iceRemoteCandidate,
|
|
360
|
-
}, this.userId);
|
|
361
|
-
this.reports.addCallMetaReport(callMetaReport);
|
|
362
|
-
}
|
|
363
|
-
for (const transport of (_1 = sample.pcTransports) !== null && _1 !== void 0 ? _1 : []) {
|
|
343
|
+
for (const transport of (_x = sample.pcTransports) !== null && _x !== void 0 ? _x : []) {
|
|
364
344
|
try {
|
|
365
|
-
const peerConnection = (
|
|
345
|
+
const peerConnection = (_y = this._peerConnections.get(transport.transportId)) !== null && _y !== void 0 ? _y : yield this._createPeerConnection(transport.peerConnectionId);
|
|
366
346
|
peerConnection.update(transport, sample.timestamp);
|
|
367
347
|
}
|
|
368
348
|
catch (err) {
|
|
369
349
|
logger.error(`Error creating peer connection: ${err === null || err === void 0 ? void 0 : err.message}`);
|
|
370
350
|
}
|
|
371
351
|
}
|
|
372
|
-
for (const track of (
|
|
352
|
+
for (const track of (_z = sample.inboundAudioTracks) !== null && _z !== void 0 ? _z : []) {
|
|
373
353
|
if (!track.peerConnectionId || !track.trackId) {
|
|
374
354
|
logger.warn(`InboundAudioTrack without peerConnectionId or trackId: ${JSON.stringify(track)}`);
|
|
375
355
|
continue;
|
|
376
356
|
}
|
|
377
357
|
try {
|
|
378
|
-
const peerConnection = (
|
|
358
|
+
const peerConnection = (_0 = this._peerConnections.get(track.peerConnectionId)) !== null && _0 !== void 0 ? _0 : yield this._createPeerConnection(track.peerConnectionId);
|
|
379
359
|
if (!peerConnection)
|
|
380
360
|
continue;
|
|
381
|
-
const inboundAudioTrack = (
|
|
361
|
+
const inboundAudioTrack = (_1 = peerConnection.inboundAudioTracks.get(track.trackId)) !== null && _1 !== void 0 ? _1 : yield peerConnection.createInboundAudioTrack({
|
|
382
362
|
trackId: track.trackId,
|
|
383
363
|
sfuStreamId: track.sfuStreamId,
|
|
384
364
|
sfuSinkId: track.sfuSinkId,
|
|
385
365
|
});
|
|
386
366
|
yield inboundAudioTrack.update(track, sample.timestamp);
|
|
387
|
-
const remoteOutboundTrack = this.call.sfuStreamIdToOutboundAudioTrack.get((
|
|
367
|
+
const remoteOutboundTrack = this.call.sfuStreamIdToOutboundAudioTrack.get((_2 = track.sfuStreamId) !== null && _2 !== void 0 ? _2 : '');
|
|
388
368
|
if (remoteOutboundTrack && inboundAudioTrack.sfuStreamId && !remoteOutboundTrack.remoteInboundTracks.has(inboundAudioTrack.sfuStreamId)) {
|
|
389
369
|
remoteOutboundTrack.connectInboundTrack(inboundAudioTrack);
|
|
390
370
|
}
|
|
@@ -393,7 +373,7 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
393
373
|
logger.error(`Error creating inbound audio track: ${err === null || err === void 0 ? void 0 : err.message}`);
|
|
394
374
|
}
|
|
395
375
|
}
|
|
396
|
-
for (const track of (
|
|
376
|
+
for (const track of (_3 = sample.inboundVideoTracks) !== null && _3 !== void 0 ? _3 : []) {
|
|
397
377
|
if (!track.peerConnectionId || !track.trackId) {
|
|
398
378
|
logger.warn(`InboundVideoTrack without peerConnectionId or trackId: ${JSON.stringify(track)}`);
|
|
399
379
|
continue;
|
|
@@ -406,16 +386,16 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
406
386
|
continue;
|
|
407
387
|
}
|
|
408
388
|
try {
|
|
409
|
-
const peerConnection = (
|
|
389
|
+
const peerConnection = (_4 = this._peerConnections.get(track.peerConnectionId)) !== null && _4 !== void 0 ? _4 : yield this._createPeerConnection(track.peerConnectionId);
|
|
410
390
|
if (!peerConnection)
|
|
411
391
|
continue;
|
|
412
|
-
const inboundVideoTrack = (
|
|
392
|
+
const inboundVideoTrack = (_5 = peerConnection.inboundVideoTracks.get(track.trackId)) !== null && _5 !== void 0 ? _5 : yield peerConnection.createInboundVideoTrack({
|
|
413
393
|
trackId: track.trackId,
|
|
414
394
|
sfuStreamId: track.sfuStreamId,
|
|
415
395
|
sfuSinkId: track.sfuSinkId,
|
|
416
396
|
});
|
|
417
397
|
yield inboundVideoTrack.update(track, sample.timestamp);
|
|
418
|
-
const remoteOutboundTrack = this.call.sfuStreamIdToOutboundVideoTrack.get((
|
|
398
|
+
const remoteOutboundTrack = this.call.sfuStreamIdToOutboundVideoTrack.get((_6 = inboundVideoTrack.sfuStreamId) !== null && _6 !== void 0 ? _6 : '');
|
|
419
399
|
if (remoteOutboundTrack && inboundVideoTrack.sfuStreamId && !remoteOutboundTrack.remoteInboundTracks.has(inboundVideoTrack.sfuStreamId)) {
|
|
420
400
|
remoteOutboundTrack.connectInboundTrack(inboundVideoTrack);
|
|
421
401
|
}
|
|
@@ -424,16 +404,16 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
424
404
|
logger.error(`Error creating inbound video track: ${err === null || err === void 0 ? void 0 : err.message}`);
|
|
425
405
|
}
|
|
426
406
|
}
|
|
427
|
-
for (const track of (
|
|
407
|
+
for (const track of (_7 = sample.outboundAudioTracks) !== null && _7 !== void 0 ? _7 : []) {
|
|
428
408
|
if (!track.peerConnectionId || !track.trackId) {
|
|
429
409
|
logger.warn(`OutboundAudioTrack without peerConnectionId or trackId: ${JSON.stringify(track)}`);
|
|
430
410
|
continue;
|
|
431
411
|
}
|
|
432
412
|
try {
|
|
433
|
-
const peerConnection = (
|
|
413
|
+
const peerConnection = (_8 = this._peerConnections.get(track.peerConnectionId)) !== null && _8 !== void 0 ? _8 : yield this._createPeerConnection(track.peerConnectionId);
|
|
434
414
|
if (!peerConnection)
|
|
435
415
|
continue;
|
|
436
|
-
const outboundAudioTrack = (
|
|
416
|
+
const outboundAudioTrack = (_9 = peerConnection.outboundAudioTracks.get(track.trackId)) !== null && _9 !== void 0 ? _9 : yield peerConnection.createOutboundAudioTrack({
|
|
437
417
|
trackId: track.trackId,
|
|
438
418
|
sfuStreamId: track.sfuStreamId,
|
|
439
419
|
});
|
|
@@ -443,16 +423,16 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
443
423
|
logger.error(`Error creating outbound audio track: ${err === null || err === void 0 ? void 0 : err.message}`);
|
|
444
424
|
}
|
|
445
425
|
}
|
|
446
|
-
for (const track of (
|
|
426
|
+
for (const track of (_10 = sample.outboundVideoTracks) !== null && _10 !== void 0 ? _10 : []) {
|
|
447
427
|
if (!track.peerConnectionId || !track.trackId) {
|
|
448
428
|
logger.warn(`OutboundVideoTrack without peerConnectionId or trackId: ${JSON.stringify(track)}`);
|
|
449
429
|
continue;
|
|
450
430
|
}
|
|
451
431
|
try {
|
|
452
|
-
const peerConnection = (
|
|
432
|
+
const peerConnection = (_11 = this._peerConnections.get(track.peerConnectionId)) !== null && _11 !== void 0 ? _11 : yield this._createPeerConnection(track.peerConnectionId);
|
|
453
433
|
if (!peerConnection)
|
|
454
434
|
continue;
|
|
455
|
-
const outboundVideoTrack = (
|
|
435
|
+
const outboundVideoTrack = (_12 = peerConnection.outboundVideoTracks.get(track.trackId)) !== null && _12 !== void 0 ? _12 : yield peerConnection.createOutboundVideoTrack({
|
|
456
436
|
trackId: track.trackId,
|
|
457
437
|
sfuStreamId: track.sfuStreamId,
|
|
458
438
|
});
|
|
@@ -462,6 +442,38 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
462
442
|
logger.error(`Error creating outbound video track: ${err === null || err === void 0 ? void 0 : err.message}`);
|
|
463
443
|
}
|
|
464
444
|
}
|
|
445
|
+
for (const iceLocalCandidate of (_13 = sample.iceLocalCandidates) !== null && _13 !== void 0 ? _13 : []) {
|
|
446
|
+
if (!iceLocalCandidate.peerConnectionId) {
|
|
447
|
+
logger.warn(`Local ice candidate without peerConnectionId: ${JSON.stringify(iceLocalCandidate)}`);
|
|
448
|
+
continue;
|
|
449
|
+
}
|
|
450
|
+
const peerConnection = this._peerConnections.get(iceLocalCandidate.peerConnectionId);
|
|
451
|
+
if (!peerConnection) {
|
|
452
|
+
logger.debug(`Peer connection ${iceLocalCandidate.peerConnectionId} not found for ice local candidate ${iceLocalCandidate.id}`);
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
peerConnection.ICE.addLocalCandidate(iceLocalCandidate);
|
|
456
|
+
}
|
|
457
|
+
for (const iceRemoteCandidate of (_14 = sample.iceRemoteCandidates) !== null && _14 !== void 0 ? _14 : []) {
|
|
458
|
+
if (!iceRemoteCandidate.peerConnectionId) {
|
|
459
|
+
logger.warn(`Remote ice candidate without peerConnectionId: ${JSON.stringify(iceRemoteCandidate)}`);
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
const peerConnection = this._peerConnections.get(iceRemoteCandidate.peerConnectionId);
|
|
463
|
+
if (!peerConnection) {
|
|
464
|
+
logger.debug(`Peer connection ${iceRemoteCandidate.peerConnectionId} not found for ice remote candidate ${iceRemoteCandidate.id}`);
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
peerConnection.ICE.addRemoteCandidate(iceRemoteCandidate);
|
|
468
|
+
}
|
|
469
|
+
for (const candidatePair of (_15 = sample.iceCandidatePairs) !== null && _15 !== void 0 ? _15 : []) {
|
|
470
|
+
const peerConnection = this._peerConnections.get(candidatePair.peerConnectionId);
|
|
471
|
+
if (!peerConnection) {
|
|
472
|
+
logger.debug(`Peer connection ${candidatePair.peerConnectionId} not found for ice candidate pair ${candidatePair.localCandidateId}, ${candidatePair.remoteCandidateId}`);
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
peerConnection.ICE.update(candidatePair, sample.timestamp);
|
|
476
|
+
}
|
|
465
477
|
// close entries that are idle for too long
|
|
466
478
|
if (this.call.observer.config.maxEntryIdleTimeInMs && this._updated < sample.timestamp) {
|
|
467
479
|
for (const peerConnection of this._peerConnections.values()) {
|
|
@@ -490,9 +502,6 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
490
502
|
}
|
|
491
503
|
}
|
|
492
504
|
}
|
|
493
|
-
if (changeIceCandidatePair) {
|
|
494
|
-
this.emit('candidate-pair-change');
|
|
495
|
-
}
|
|
496
505
|
if (executeSave)
|
|
497
506
|
yield this._save();
|
|
498
507
|
this._updated = sample.timestamp;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IceCandidatePair, IceLocalCandidate, IceRemoteCandidate } from '@observertc/sample-schemas-js';
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
4
|
+
import { ObservedPeerConnection } from './ObservedPeerConnection';
|
|
5
|
+
export type ObservedICEEvents = {
|
|
6
|
+
update: [];
|
|
7
|
+
'new-local-candidate': [IceLocalCandidate];
|
|
8
|
+
'new-remote-candidate': [IceRemoteCandidate];
|
|
9
|
+
'new-selected-candidate-pair': [
|
|
10
|
+
{
|
|
11
|
+
localCandidate: IceLocalCandidate;
|
|
12
|
+
remoteCandidate: IceRemoteCandidate;
|
|
13
|
+
}
|
|
14
|
+
];
|
|
15
|
+
close: [];
|
|
16
|
+
};
|
|
17
|
+
export declare interface ObservedICE {
|
|
18
|
+
on<U extends keyof ObservedICEEvents>(event: U, listener: (...args: ObservedICEEvents[U]) => void): this;
|
|
19
|
+
off<U extends keyof ObservedICEEvents>(event: U, listener: (...args: ObservedICEEvents[U]) => void): this;
|
|
20
|
+
once<U extends keyof ObservedICEEvents>(event: U, listener: (...args: ObservedICEEvents[U]) => void): this;
|
|
21
|
+
emit<U extends keyof ObservedICEEvents>(event: U, ...args: ObservedICEEvents[U]): boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare class ObservedICE extends EventEmitter {
|
|
24
|
+
readonly peerConnection: ObservedPeerConnection;
|
|
25
|
+
static create(peerConnection: ObservedPeerConnection): ObservedICE;
|
|
26
|
+
private readonly _localCandidates;
|
|
27
|
+
private readonly _remoteCandidates;
|
|
28
|
+
private _selectedLocalCandidateId?;
|
|
29
|
+
private _selectedRemoteCandidateId?;
|
|
30
|
+
private _updated;
|
|
31
|
+
private _stats?;
|
|
32
|
+
private _closed;
|
|
33
|
+
private constructor();
|
|
34
|
+
get reports(): import("./ReportsCollector").ReportsCollector;
|
|
35
|
+
get localCandidates(): ReadonlyMap<string, IceLocalCandidate>;
|
|
36
|
+
get remoteCandidates(): ReadonlyMap<string, IceRemoteCandidate>;
|
|
37
|
+
get selectedLocalCandidate(): IceLocalCandidate | undefined;
|
|
38
|
+
get selectedRemoteCandidate(): IceLocalCandidate | undefined;
|
|
39
|
+
get stats(): IceCandidatePair | undefined;
|
|
40
|
+
get updated(): number;
|
|
41
|
+
get closed(): boolean;
|
|
42
|
+
close(): void;
|
|
43
|
+
addLocalCandidate(candidate: IceLocalCandidate): void;
|
|
44
|
+
addRemoteCandidate(candidate: IceRemoteCandidate): void;
|
|
45
|
+
update(candidatePair: IceCandidatePair, timestamp: number): void;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=ObservedICE.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObservedICE.d.ts","sourceRoot":"","sources":["../src/ObservedICE.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxG,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAIlE,MAAM,MAAM,iBAAiB,GAAG;IAC/B,MAAM,EAAE,EAAE,CA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AQ,CAAc;IAC9B,OAAO,CAAC,MAAM,CAAC,CAAmB;IAClC,OAAO,CAAC,OAAO,CAAS;IAExB,OAAO;IAMP,IAAW,OAAO,kDAEjB;IAED,IAAW,eAAe,IAAI,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAEnE;IAED,IAAW,gBAAgB,IAAI,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAErE;IAED,IAAW,sBAAsB,kCAEhC;IAED,IAAW,uBAAuB,kCAEjC;IAED,IAAW,KAAK,iCAEf;IAED,IAAW,OAAO,WAEjB;IAED,IAAW,MAAM,YAEhB;IAEM,KAAK;IAML,iBAAiB,CAAC,SAAS,EAAE,iBAAiB;IAwB9C,kBAAkB,CAAC,SAAS,EAAE,kBAAkB;IAwBhD,MAAM,CAAC,aAAa,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM;CA6ChE"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObservedICE = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
const callMetaReports_1 = require("./common/callMetaReports");
|
|
6
|
+
class ObservedICE extends events_1.EventEmitter {
|
|
7
|
+
static create(peerConnection) {
|
|
8
|
+
return new ObservedICE(peerConnection);
|
|
9
|
+
}
|
|
10
|
+
constructor(peerConnection) {
|
|
11
|
+
super();
|
|
12
|
+
this.peerConnection = peerConnection;
|
|
13
|
+
this._localCandidates = new Map();
|
|
14
|
+
this._remoteCandidates = new Map();
|
|
15
|
+
this._updated = Date.now();
|
|
16
|
+
this._closed = false;
|
|
17
|
+
}
|
|
18
|
+
get reports() {
|
|
19
|
+
return this.peerConnection.reports;
|
|
20
|
+
}
|
|
21
|
+
get localCandidates() {
|
|
22
|
+
return this._localCandidates;
|
|
23
|
+
}
|
|
24
|
+
get remoteCandidates() {
|
|
25
|
+
return this._remoteCandidates;
|
|
26
|
+
}
|
|
27
|
+
get selectedLocalCandidate() {
|
|
28
|
+
var _a;
|
|
29
|
+
return this._localCandidates.get((_a = this._selectedLocalCandidateId) !== null && _a !== void 0 ? _a : '');
|
|
30
|
+
}
|
|
31
|
+
get selectedRemoteCandidate() {
|
|
32
|
+
var _a;
|
|
33
|
+
return this._remoteCandidates.get((_a = this._selectedRemoteCandidateId) !== null && _a !== void 0 ? _a : '');
|
|
34
|
+
}
|
|
35
|
+
get stats() {
|
|
36
|
+
return this._stats;
|
|
37
|
+
}
|
|
38
|
+
get updated() {
|
|
39
|
+
return this._updated;
|
|
40
|
+
}
|
|
41
|
+
get closed() {
|
|
42
|
+
return this._closed;
|
|
43
|
+
}
|
|
44
|
+
close() {
|
|
45
|
+
if (this._closed)
|
|
46
|
+
return;
|
|
47
|
+
this._closed = true;
|
|
48
|
+
this.emit('close');
|
|
49
|
+
}
|
|
50
|
+
addLocalCandidate(candidate) {
|
|
51
|
+
if (!candidate.id)
|
|
52
|
+
return;
|
|
53
|
+
const newCandidate = !this._localCandidates.has(candidate.id);
|
|
54
|
+
this._localCandidates.set(candidate.id, candidate);
|
|
55
|
+
if (newCandidate) {
|
|
56
|
+
const callMetaReport = (0, callMetaReports_1.createCallMetaReport)(this.peerConnection.client.serviceId, this.peerConnection.client.mediaUnitId, this.peerConnection.client.roomId, this.peerConnection.client.callId, this.peerConnection.client.clientId, {
|
|
57
|
+
type: callMetaReports_1.CallMetaType.ICE_LOCAL_CANDIDATE,
|
|
58
|
+
payload: candidate,
|
|
59
|
+
}, this.peerConnection.client.userId);
|
|
60
|
+
this.reports.addCallMetaReport(callMetaReport);
|
|
61
|
+
this.emit('new-local-candidate', candidate);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
addRemoteCandidate(candidate) {
|
|
65
|
+
if (!candidate.id)
|
|
66
|
+
return;
|
|
67
|
+
const newCandidate = !this._remoteCandidates.has(candidate.id);
|
|
68
|
+
this._remoteCandidates.set(candidate.id, candidate);
|
|
69
|
+
if (newCandidate) {
|
|
70
|
+
const callMetaReport = (0, callMetaReports_1.createCallMetaReport)(this.peerConnection.client.serviceId, this.peerConnection.client.mediaUnitId, this.peerConnection.client.roomId, this.peerConnection.client.callId, this.peerConnection.client.clientId, {
|
|
71
|
+
type: callMetaReports_1.CallMetaType.ICE_REMOTE_CANDIDATE,
|
|
72
|
+
payload: candidate,
|
|
73
|
+
}, this.peerConnection.client.userId);
|
|
74
|
+
this.reports.addCallMetaReport(callMetaReport);
|
|
75
|
+
this.emit('new-remote-candidate', candidate);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
update(candidatePair, timestamp) {
|
|
79
|
+
const report = Object.assign(Object.assign({ serviceId: this.peerConnection.client.serviceId, mediaUnitId: this.peerConnection.client.mediaUnitId, roomId: this.peerConnection.client.roomId, callId: this.peerConnection.client.callId, clientId: this.peerConnection.client.clientId, userId: this.peerConnection.client.userId, timestamp }, candidatePair), { sampleSeq: -1 });
|
|
80
|
+
this.reports.addIceCandidatePairReport(report);
|
|
81
|
+
if (!candidatePair.nominated)
|
|
82
|
+
return;
|
|
83
|
+
this._stats = candidatePair;
|
|
84
|
+
if (candidatePair.localCandidateId &&
|
|
85
|
+
candidatePair.localCandidateId !== this._selectedLocalCandidateId &&
|
|
86
|
+
this._localCandidates.has(candidatePair.localCandidateId) &&
|
|
87
|
+
candidatePair.remoteCandidateId &&
|
|
88
|
+
candidatePair.remoteCandidateId !== this._selectedRemoteCandidateId &&
|
|
89
|
+
this._remoteCandidates.has(candidatePair.remoteCandidateId)) {
|
|
90
|
+
this._selectedLocalCandidateId = candidatePair.localCandidateId;
|
|
91
|
+
this._selectedRemoteCandidateId = candidatePair.remoteCandidateId;
|
|
92
|
+
const localCandidate = this._localCandidates.get(candidatePair.localCandidateId);
|
|
93
|
+
const remoteCandidate = this._remoteCandidates.get(candidatePair.remoteCandidateId);
|
|
94
|
+
if (localCandidate && remoteCandidate) {
|
|
95
|
+
this.emit('new-selected-candidate-pair', {
|
|
96
|
+
localCandidate,
|
|
97
|
+
remoteCandidate,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
this._updated = timestamp;
|
|
102
|
+
this.emit('update');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.ObservedICE = ObservedICE;
|
|
@@ -22,6 +22,14 @@ export type ObservedInboundTrackStats<K extends MediaKind> = ObservedInboundTrac
|
|
|
22
22
|
bitrate: number;
|
|
23
23
|
fractionLost: number;
|
|
24
24
|
rttInMs?: number;
|
|
25
|
+
lostPackets?: number;
|
|
26
|
+
receivedPackets?: number;
|
|
27
|
+
receivedFrames?: number;
|
|
28
|
+
decodedFrames?: number;
|
|
29
|
+
droppedFrames?: number;
|
|
30
|
+
receivedSamples?: number;
|
|
31
|
+
silentConcealedSamples?: number;
|
|
32
|
+
fractionLoss?: number;
|
|
25
33
|
};
|
|
26
34
|
export declare interface ObservedInboundTrack<Kind extends MediaKind> {
|
|
27
35
|
on<U extends keyof ObservedInboundTrackEvents<Kind>>(event: U, listener: (...args: ObservedInboundTrackEvents<Kind>[U]) => void): this;
|
|
@@ -42,6 +50,14 @@ export declare class ObservedInboundTrack<Kind extends MediaKind> extends EventE
|
|
|
42
50
|
private _remoteOutboundTrack?;
|
|
43
51
|
bitrate: number;
|
|
44
52
|
rttInMs: number;
|
|
53
|
+
lostPackets: number;
|
|
54
|
+
receivedPackets: number;
|
|
55
|
+
receivedFrames: number;
|
|
56
|
+
decodedFrames: number;
|
|
57
|
+
droppedFrames: number;
|
|
58
|
+
receivedSamples: number;
|
|
59
|
+
silentConcealedSamples: number;
|
|
60
|
+
fractionLoss: number;
|
|
45
61
|
private constructor();
|
|
46
62
|
get serviceId(): string;
|
|
47
63
|
get roomId(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservedInboundTrack.d.ts","sourceRoot":"","sources":["../src/ObservedInboundTrack.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,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