@wazo/sdk 0.37.20 → 0.37.24
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/dist/wazo-sdk.js +6 -6
- package/esm/__tests__/api-client.test.js +91 -21
- package/esm/__tests__/web-rtc-client.test.js +214 -165
- package/esm/api/agentd.js +25 -2
- package/esm/api/amid.js +26 -3
- package/esm/api/application.js +25 -2
- package/esm/api/auth.js +25 -2
- package/esm/api/call-logd.js +34 -4
- package/esm/api/calld.js +35 -2
- package/esm/api/chatd.js +32 -2
- package/esm/api/confd.js +56 -9
- package/esm/api/ctid-ng.js +38 -5
- package/esm/api/dird.js +29 -3
- package/esm/api/webhookd.js +26 -3
- package/esm/api-client.js +91 -21
- package/esm/checker/Checker.js +241 -190
- package/esm/checker/checks/aor.js +91 -21
- package/esm/checker/checks/api.js +91 -21
- package/esm/checker/checks/index.js +231 -180
- package/esm/checker/checks/wazo-websocket.js +42 -17
- package/esm/checker/checks/webrtc-transport.js +214 -165
- package/esm/checker/checks/webrtc.js +214 -165
- package/esm/domain/AdHocAPIConference.js +91 -21
- package/esm/domain/Call.js +3 -0
- package/esm/domain/CallLog.js +8 -1
- package/esm/domain/ChatMessage.js +4 -0
- package/esm/domain/ChatRoom.js +3 -0
- package/esm/domain/Contact.js +4 -1
- package/esm/domain/Features.js +91 -21
- package/esm/domain/Meeting.js +28 -5
- package/esm/domain/Phone/CTIPhone.js +109 -35
- package/esm/domain/Phone/WebRTCPhone.js +159 -102
- package/esm/domain/Recording.js +3 -0
- package/esm/domain/Voicemail.js +3 -0
- package/esm/domain/__tests__/Call.test.js +3 -0
- package/esm/domain/__tests__/CallLog.test.js +8 -1
- package/esm/domain/__tests__/Contact.test.js +4 -1
- package/esm/domain/__tests__/Meeting.test.js +144 -0
- package/esm/domain/__tests__/Voicemail.test.js +3 -0
- package/esm/index.js +509 -414
- package/esm/lib/WazoSessionDescriptionHandler.js +26 -41
- package/esm/service/CallApi.js +91 -21
- package/esm/service/IssueReporter.js +26 -3
- package/esm/service/__tests__/IssueReporter.test.js +26 -3
- package/esm/service/getApiClient.js +91 -21
- package/esm/simple/Auth.js +499 -404
- package/esm/simple/Configuration.js +499 -404
- package/esm/simple/Directory.js +91 -21
- package/esm/simple/Phone.js +499 -404
- package/esm/simple/Websocket.js +45 -19
- package/esm/simple/index.js +503 -408
- package/esm/simple/room/LocalParticipant.js +503 -408
- package/esm/simple/room/Participant.js +503 -408
- package/esm/simple/room/RemoteParticipant.js +503 -408
- package/esm/simple/room/Room.js +504 -409
- package/esm/simple/room/SipRoom.js +503 -408
- package/esm/simple/room/Stream.js +503 -408
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +503 -408
- package/esm/simple/utils.js +503 -408
- package/esm/types/WebSocketMessage.js +1 -1
- package/esm/utils/__tests__/api-requester.test.js +25 -2
- package/esm/utils/api-requester.js +25 -2
- package/esm/web-rtc-client.js +214 -165
- package/esm/websocket-client.js +43 -18
- package/lib/__tests__/api-client.test.js +91 -21
- package/lib/__tests__/web-rtc-client.test.js +214 -165
- package/lib/api/agentd.js +25 -2
- package/lib/api/amid.js +26 -3
- package/lib/api/application.js +25 -2
- package/lib/api/auth.js +25 -2
- package/lib/api/call-logd.js +34 -4
- package/lib/api/calld.js +35 -2
- package/lib/api/chatd.js +32 -2
- package/lib/api/confd.js +56 -9
- package/lib/api/ctid-ng.js +38 -5
- package/lib/api/dird.js +29 -3
- package/lib/api/webhookd.js +26 -3
- package/lib/api-client.js +91 -21
- package/lib/checker/Checker.js +241 -190
- package/lib/checker/checks/aor.js +91 -21
- package/lib/checker/checks/api.js +91 -21
- package/lib/checker/checks/index.js +231 -180
- package/lib/checker/checks/wazo-websocket.js +42 -17
- package/lib/checker/checks/webrtc-transport.js +214 -165
- package/lib/checker/checks/webrtc.js +214 -165
- package/lib/domain/AdHocAPIConference.js +91 -21
- package/lib/domain/Call.js +3 -0
- package/lib/domain/CallLog.js +8 -1
- package/lib/domain/ChatMessage.js +4 -0
- package/lib/domain/ChatRoom.js +3 -0
- package/lib/domain/Contact.js +4 -1
- package/lib/domain/Features.js +91 -21
- package/lib/domain/Meeting.js +32 -5
- package/lib/domain/Phone/CTIPhone.js +109 -35
- package/lib/domain/Phone/WebRTCPhone.js +159 -102
- package/lib/domain/Recording.js +3 -0
- package/lib/domain/Voicemail.js +3 -0
- package/lib/domain/__tests__/Call.test.js +3 -0
- package/lib/domain/__tests__/CallLog.test.js +8 -1
- package/lib/domain/__tests__/Contact.test.js +4 -1
- package/lib/domain/__tests__/Meeting.test.js +150 -0
- package/lib/domain/__tests__/Voicemail.test.js +3 -0
- package/lib/index.js +509 -414
- package/lib/lib/WazoSessionDescriptionHandler.js +26 -41
- package/lib/service/CallApi.js +91 -21
- package/lib/service/IssueReporter.js +26 -3
- package/lib/service/__tests__/IssueReporter.test.js +26 -3
- package/lib/service/getApiClient.js +91 -21
- package/lib/simple/Auth.js +499 -404
- package/lib/simple/Configuration.js +499 -404
- package/lib/simple/Directory.js +91 -21
- package/lib/simple/Phone.js +499 -404
- package/lib/simple/Websocket.js +45 -19
- package/lib/simple/index.js +503 -408
- package/lib/simple/room/LocalParticipant.js +503 -408
- package/lib/simple/room/Participant.js +503 -408
- package/lib/simple/room/RemoteParticipant.js +503 -408
- package/lib/simple/room/Room.js +504 -409
- package/lib/simple/room/SipRoom.js +503 -408
- package/lib/simple/room/Stream.js +503 -408
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +503 -408
- package/lib/simple/utils.js +503 -408
- package/lib/types/WebSocketMessage.js +2 -0
- package/lib/utils/__tests__/api-requester.test.js +25 -2
- package/lib/utils/api-requester.js +25 -2
- package/lib/web-rtc-client.js +214 -165
- package/lib/websocket-client.js +43 -17
- package/package.json +1 -1
- package/src/api/confd.js +5 -2
- package/src/domain/Call.js +3 -0
- package/src/domain/CallLog.js +4 -0
- package/src/domain/ChatMessage.js +4 -0
- package/src/domain/ChatRoom.js +3 -0
- package/src/domain/Contact.js +3 -0
- package/src/domain/Meeting.js +28 -5
- package/src/domain/Phone/CTIPhone.js +4 -0
- package/src/domain/Phone/Phone.js +2 -0
- package/src/domain/Phone/WebRTCPhone.js +49 -15
- package/src/domain/Recording.js +3 -0
- package/src/domain/Voicemail.js +3 -0
- package/src/domain/__tests__/Meeting.test.js +50 -0
- package/src/lib/WazoSessionDescriptionHandler.js +1 -35
- package/src/service/IssueReporter.js +25 -2
- package/src/simple/Phone.js +5 -0
- package/src/types/WebSocketMessage.js +5 -1
- package/src/web-rtc-client.js +41 -24
- package/src/websocket-client.js +2 -0
|
@@ -100,7 +100,7 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
|
|
|
100
100
|
|
|
101
101
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
102
102
|
|
|
103
|
-
const logger
|
|
103
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
104
104
|
|
|
105
105
|
// Use a function here to be able to mock it in tests
|
|
106
106
|
const realFetch = () => {
|
|
@@ -239,7 +239,7 @@ class ApiRequester {
|
|
|
239
239
|
};
|
|
240
240
|
|
|
241
241
|
if (this.refreshTokenPromise) {
|
|
242
|
-
logger
|
|
242
|
+
logger.info('A token is already refreshing, waiting ...', { url });
|
|
243
243
|
await this.refreshTokenPromise;
|
|
244
244
|
}
|
|
245
245
|
|
|
@@ -259,7 +259,7 @@ class ApiRequester {
|
|
|
259
259
|
return promise.then(async (err ) => {
|
|
260
260
|
// Check if the token is still valid
|
|
261
261
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
262
|
-
logger
|
|
262
|
+
logger.warn('token expired', { error: err.reason });
|
|
263
263
|
// Replay the call after refreshing the token
|
|
264
264
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
265
265
|
}
|
|
@@ -269,7 +269,7 @@ class ApiRequester {
|
|
|
269
269
|
: exceptionClass.fromResponse(err, response.status);
|
|
270
270
|
|
|
271
271
|
if (this.shouldLogErrors) {
|
|
272
|
-
logger
|
|
272
|
+
logger.error('API error', error);
|
|
273
273
|
}
|
|
274
274
|
|
|
275
275
|
throw error;
|
|
@@ -279,7 +279,7 @@ class ApiRequester {
|
|
|
279
279
|
return newParse(response, isJson);
|
|
280
280
|
}).catch(error => {
|
|
281
281
|
if (this.shouldLogErrors) {
|
|
282
|
-
logger
|
|
282
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
throw error;
|
|
@@ -307,13 +307,13 @@ class ApiRequester {
|
|
|
307
307
|
) {
|
|
308
308
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
309
309
|
let newPath = path;
|
|
310
|
-
logger
|
|
310
|
+
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
311
311
|
|
|
312
312
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
313
313
|
|
|
314
314
|
return this.refreshTokenPromise.then(() => {
|
|
315
315
|
this.refreshTokenPromise = null;
|
|
316
|
-
logger
|
|
316
|
+
logger.info('token refreshed', { isTokenNotFound });
|
|
317
317
|
if (isTokenNotFound) {
|
|
318
318
|
const pathParts = path.split('/');
|
|
319
319
|
pathParts.pop();
|
|
@@ -412,6 +412,7 @@ class IssueReporter {
|
|
|
412
412
|
|
|
413
413
|
|
|
414
414
|
|
|
415
|
+
|
|
415
416
|
|
|
416
417
|
constructor() {
|
|
417
418
|
addLevelsTo(this);
|
|
@@ -423,12 +424,17 @@ class IssueReporter {
|
|
|
423
424
|
this.bufferTimeout = null;
|
|
424
425
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
425
426
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
427
|
+
this._callback = null;
|
|
426
428
|
}
|
|
427
429
|
|
|
428
430
|
init() {
|
|
429
431
|
this._catchConsole();
|
|
430
432
|
}
|
|
431
433
|
|
|
434
|
+
setCallback(cb ) {
|
|
435
|
+
this._callback = cb;
|
|
436
|
+
}
|
|
437
|
+
|
|
432
438
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
433
439
|
this.remoteClientConfiguration = configuration;
|
|
434
440
|
}
|
|
@@ -464,6 +470,7 @@ class IssueReporter {
|
|
|
464
470
|
|
|
465
471
|
// Handle category label
|
|
466
472
|
let category = null;
|
|
473
|
+
let skipSendToRemote = false;
|
|
467
474
|
let extra = {};
|
|
468
475
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
469
476
|
category = args[0].split('=')[1];
|
|
@@ -479,6 +486,7 @@ class IssueReporter {
|
|
|
479
486
|
errorMessage: lastArg.message,
|
|
480
487
|
errorStack: lastArg.stack,
|
|
481
488
|
errorType: lastArg.constructor.name,
|
|
489
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
482
490
|
};
|
|
483
491
|
} else {
|
|
484
492
|
extra = lastArg;
|
|
@@ -487,6 +495,11 @@ class IssueReporter {
|
|
|
487
495
|
args.splice(1, 1);
|
|
488
496
|
}
|
|
489
497
|
|
|
498
|
+
if (extra.skipSendToRemote) {
|
|
499
|
+
skipSendToRemote = true;
|
|
500
|
+
delete extra.skipSendToRemote;
|
|
501
|
+
}
|
|
502
|
+
|
|
490
503
|
const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
491
504
|
const message = args.join(', ');
|
|
492
505
|
let consoleMessage = message;
|
|
@@ -507,7 +520,13 @@ class IssueReporter {
|
|
|
507
520
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
508
521
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
509
522
|
|
|
510
|
-
this.
|
|
523
|
+
if (this._callback) {
|
|
524
|
+
this._callback(level, consoleMessage);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
if (!skipSendToRemote) {
|
|
528
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
529
|
+
}
|
|
511
530
|
}
|
|
512
531
|
|
|
513
532
|
logRequest(url , options , response , start ) {
|
|
@@ -652,7 +671,11 @@ class IssueReporter {
|
|
|
652
671
|
},
|
|
653
672
|
// $FlowFixMe
|
|
654
673
|
body,
|
|
655
|
-
}).catch(() => {
|
|
674
|
+
}).catch((e ) => {
|
|
675
|
+
// $FlowFixMe
|
|
676
|
+
e.skipSendToRemote = true;
|
|
677
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
678
|
+
|
|
656
679
|
setTimeout(() => {
|
|
657
680
|
if (isArray) {
|
|
658
681
|
payload = payload.map(message => {
|
|
@@ -701,10 +724,6 @@ const getSrflxOrRelay = (candidates ) =>
|
|
|
701
724
|
candidates
|
|
702
725
|
.filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
|
|
703
726
|
|
|
704
|
-
const areCandidateValid = (candidates ) =>
|
|
705
|
-
getSrflxOrRelay(candidates)
|
|
706
|
-
.length > 0;
|
|
707
|
-
|
|
708
727
|
const getVideoDirection = (sdp ) => {
|
|
709
728
|
const parsedSdp = sdpParser.parse(sdp);
|
|
710
729
|
const videoMedia = parsedSdp.media.find(media => media.type === 'video');
|
|
@@ -757,8 +776,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
757
776
|
/* global RTCSessionDescriptionInit, navigator */
|
|
758
777
|
|
|
759
778
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
760
|
-
const MAX_WAIT_FOR_ICE_TRIES = 20;
|
|
761
|
-
const WAIT_FOR_ICE_TIMEOUT = 500;
|
|
762
779
|
|
|
763
780
|
// Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
|
|
764
781
|
const wazoMediaStreamFactory = (constraints ) => {
|
|
@@ -948,38 +965,6 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
|
|
|
948
965
|
this._peerConnection = undefined;
|
|
949
966
|
}
|
|
950
967
|
|
|
951
|
-
async _waitForValidGatheredIce() {
|
|
952
|
-
let tries = 0;
|
|
953
|
-
|
|
954
|
-
while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
|
|
955
|
-
wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
|
|
956
|
-
tries,
|
|
957
|
-
max: MAX_WAIT_FOR_ICE_TRIES,
|
|
958
|
-
});
|
|
959
|
-
|
|
960
|
-
tries++;
|
|
961
|
-
|
|
962
|
-
// eslint-disable-next-line no-await-in-loop
|
|
963
|
-
await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
|
|
967
|
-
const errorMsg = 'No valid candidates found, can\'t answer the call';
|
|
968
|
-
const error = new Error(errorMsg);
|
|
969
|
-
wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
|
|
970
|
-
|
|
971
|
-
// Emit an error, because sip.js catches the exception and switch to status Terminated.
|
|
972
|
-
this.eventEmitter.emit('error', error);
|
|
973
|
-
|
|
974
|
-
wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
// eslint-disable-next-line
|
|
978
|
-
wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
979
|
-
|
|
980
|
-
return this.getLocalSessionDescription();
|
|
981
|
-
}
|
|
982
|
-
|
|
983
968
|
// Overridden to send `inactive` in conference
|
|
984
969
|
updateDirection(options , isConference = false,
|
|
985
970
|
audioOnly = false) {
|
|
@@ -2089,6 +2074,9 @@ class Contact {
|
|
|
2089
2074
|
}
|
|
2090
2075
|
|
|
2091
2076
|
static parseMany(response ) {
|
|
2077
|
+
if (!response || !response.results) {
|
|
2078
|
+
return [];
|
|
2079
|
+
}
|
|
2092
2080
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
2093
2081
|
}
|
|
2094
2082
|
|
|
@@ -3166,8 +3154,9 @@ class ExternalApp {
|
|
|
3166
3154
|
|
|
3167
3155
|
|
|
3168
3156
|
|
|
3169
|
-
|
|
3157
|
+
|
|
3170
3158
|
|
|
3159
|
+
|
|
3171
3160
|
|
|
3172
3161
|
|
|
3173
3162
|
class Meeting {
|
|
@@ -3178,9 +3167,10 @@ class Meeting {
|
|
|
3178
3167
|
|
|
3179
3168
|
|
|
3180
3169
|
|
|
3181
|
-
|
|
3170
|
+
|
|
3182
3171
|
|
|
3183
3172
|
|
|
3173
|
+
|
|
3184
3174
|
|
|
3185
3175
|
static parse(plain ) {
|
|
3186
3176
|
return new Meeting({
|
|
@@ -3190,24 +3180,43 @@ class Meeting {
|
|
|
3190
3180
|
ownerUuids: plain.owner_uuids,
|
|
3191
3181
|
port: plain.port,
|
|
3192
3182
|
uuid: plain.uuid,
|
|
3193
|
-
|
|
3183
|
+
extension: plain.exten,
|
|
3194
3184
|
persistent: plain.persistent,
|
|
3185
|
+
creationTime: moment(plain.creation_time).toDate(),
|
|
3195
3186
|
});
|
|
3196
3187
|
}
|
|
3197
3188
|
|
|
3189
|
+
static parseMany(items ) {
|
|
3190
|
+
if (!items) {
|
|
3191
|
+
return [];
|
|
3192
|
+
}
|
|
3193
|
+
return items.map(plain => Meeting.parse(plain));
|
|
3194
|
+
}
|
|
3195
|
+
|
|
3198
3196
|
static newFrom(meeting ) {
|
|
3199
3197
|
return newFrom(meeting, Meeting);
|
|
3200
3198
|
}
|
|
3201
3199
|
|
|
3202
|
-
constructor({
|
|
3200
|
+
constructor({
|
|
3201
|
+
uuid,
|
|
3202
|
+
name,
|
|
3203
|
+
guestSipAuthorization,
|
|
3204
|
+
ownerUuids,
|
|
3205
|
+
port,
|
|
3206
|
+
uri,
|
|
3207
|
+
extension,
|
|
3208
|
+
persistent,
|
|
3209
|
+
creationTime,
|
|
3210
|
+
} = {}) {
|
|
3203
3211
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
3204
3212
|
this.uri = uri;
|
|
3205
3213
|
this.name = name;
|
|
3206
3214
|
this.ownerUuids = ownerUuids;
|
|
3207
3215
|
this.port = port;
|
|
3208
3216
|
this.uuid = uuid;
|
|
3209
|
-
this.
|
|
3217
|
+
this.extension = extension;
|
|
3210
3218
|
this.persistent = persistent;
|
|
3219
|
+
this.creationTime = creationTime;
|
|
3211
3220
|
|
|
3212
3221
|
// Useful to compare instead of instanceof with minified code
|
|
3213
3222
|
this.type = 'Meeting';
|
|
@@ -3285,8 +3294,11 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
3285
3294
|
}
|
|
3286
3295
|
},
|
|
3287
3296
|
|
|
3288
|
-
|
|
3289
|
-
client.
|
|
3297
|
+
getMyMeetings: () =>
|
|
3298
|
+
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
3299
|
+
|
|
3300
|
+
createMyMeeting: (name , persistent ) =>
|
|
3301
|
+
client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
|
|
3290
3302
|
|
|
3291
3303
|
deleteMyMeeting: (meetingUuid ) =>
|
|
3292
3304
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -3382,6 +3394,10 @@ class ChatMessage {
|
|
|
3382
3394
|
|
|
3383
3395
|
|
|
3384
3396
|
static parseMany(plain ) {
|
|
3397
|
+
if (!plain || !plain.items) {
|
|
3398
|
+
return [];
|
|
3399
|
+
}
|
|
3400
|
+
|
|
3385
3401
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
3386
3402
|
}
|
|
3387
3403
|
|
|
@@ -3491,6 +3507,9 @@ class Voicemail {
|
|
|
3491
3507
|
}
|
|
3492
3508
|
|
|
3493
3509
|
static parseMany(plain ) {
|
|
3510
|
+
if (!plain) {
|
|
3511
|
+
return [];
|
|
3512
|
+
}
|
|
3494
3513
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
3495
3514
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
3496
3515
|
|
|
@@ -3600,6 +3619,9 @@ class Call {
|
|
|
3600
3619
|
|
|
3601
3620
|
|
|
3602
3621
|
static parseMany(plain ) {
|
|
3622
|
+
if (!plain) {
|
|
3623
|
+
return [];
|
|
3624
|
+
}
|
|
3603
3625
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
3604
3626
|
}
|
|
3605
3627
|
|
|
@@ -3772,6 +3794,9 @@ class Recording {
|
|
|
3772
3794
|
|
|
3773
3795
|
|
|
3774
3796
|
static parseMany(recordings = []) {
|
|
3797
|
+
if (!recordings) {
|
|
3798
|
+
return [];
|
|
3799
|
+
}
|
|
3775
3800
|
return recordings.map(item => Recording.parse(item));
|
|
3776
3801
|
}
|
|
3777
3802
|
|
|
@@ -3873,6 +3898,10 @@ class CallLog {
|
|
|
3873
3898
|
}
|
|
3874
3899
|
|
|
3875
3900
|
static parseMany(plain ) {
|
|
3901
|
+
if (!plain || !plain.items) {
|
|
3902
|
+
return [];
|
|
3903
|
+
}
|
|
3904
|
+
|
|
3876
3905
|
return plain.items.map(item => CallLog.parse(item));
|
|
3877
3906
|
}
|
|
3878
3907
|
|
|
@@ -4109,7 +4138,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
4109
4138
|
|
|
4110
4139
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
4111
4140
|
|
|
4112
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
4141
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
4113
4142
|
|
|
4114
4143
|
/* */
|
|
4115
4144
|
|
|
@@ -4445,6 +4474,9 @@ class ChatRoom {
|
|
|
4445
4474
|
|
|
4446
4475
|
|
|
4447
4476
|
static parseMany(plain ) {
|
|
4477
|
+
if (!plain || !plain.items) {
|
|
4478
|
+
return [];
|
|
4479
|
+
}
|
|
4448
4480
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
4449
4481
|
}
|
|
4450
4482
|
|
|
@@ -5025,7 +5057,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
5025
5057
|
const WEBHOOKD_VERSION = '1.0';
|
|
5026
5058
|
const AMID_VERSION = '1.0';
|
|
5027
5059
|
|
|
5028
|
-
const logger$
|
|
5060
|
+
const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
5029
5061
|
|
|
5030
5062
|
class ApiClient {
|
|
5031
5063
|
|
|
@@ -5077,12 +5109,12 @@ class ApiClient {
|
|
|
5077
5109
|
}
|
|
5078
5110
|
|
|
5079
5111
|
async forceRefreshToken() {
|
|
5080
|
-
logger$
|
|
5112
|
+
logger$2.info('forcing refresh token, calling callback');
|
|
5081
5113
|
return this.refreshTokenCallback();
|
|
5082
5114
|
}
|
|
5083
5115
|
|
|
5084
5116
|
async refreshTokenCallback() {
|
|
5085
|
-
logger$
|
|
5117
|
+
logger$2.info('refresh token callback called', {
|
|
5086
5118
|
refreshToken: this.refreshToken,
|
|
5087
5119
|
refreshBackend: this.refreshBackend,
|
|
5088
5120
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -5100,7 +5132,7 @@ class ApiClient {
|
|
|
5100
5132
|
this.isMobile,
|
|
5101
5133
|
);
|
|
5102
5134
|
|
|
5103
|
-
logger$
|
|
5135
|
+
logger$2.info('token refreshed', { token: session.token });
|
|
5104
5136
|
|
|
5105
5137
|
if (this.onRefreshToken) {
|
|
5106
5138
|
this.onRefreshToken(session.token, session);
|
|
@@ -5273,7 +5305,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
|
|
|
5273
5305
|
const SEND_STATS_DELAY = 5000;
|
|
5274
5306
|
|
|
5275
5307
|
const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
|
|
5276
|
-
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
5308
|
+
const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
5277
5309
|
const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
5278
5310
|
|
|
5279
5311
|
// events
|
|
@@ -5449,13 +5481,13 @@ class WebRTCClient extends Emitter {
|
|
|
5449
5481
|
|
|
5450
5482
|
createUserAgent(configOverrides ) {
|
|
5451
5483
|
const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
|
|
5452
|
-
logger.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
5484
|
+
logger$3.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
5453
5485
|
|
|
5454
5486
|
webRTCConfiguration.delegate = {
|
|
5455
5487
|
onConnect: this.onConnect.bind(this),
|
|
5456
5488
|
onDisconnect: this.onDisconnect.bind(this),
|
|
5457
5489
|
onInvite: (invitation ) => {
|
|
5458
|
-
logger.info('sdk webrtc on invite', {
|
|
5490
|
+
logger$3.info('sdk webrtc on invite', {
|
|
5459
5491
|
method: 'delegate.onInvite',
|
|
5460
5492
|
id: invitation.id,
|
|
5461
5493
|
remoteURI: invitation.remoteURI,
|
|
@@ -5498,7 +5530,7 @@ class WebRTCClient extends Emitter {
|
|
|
5498
5530
|
}
|
|
5499
5531
|
|
|
5500
5532
|
onConnect() {
|
|
5501
|
-
logger.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
5533
|
+
logger$3.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
5502
5534
|
this.eventEmitter.emit(CONNECTED);
|
|
5503
5535
|
if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
|
|
5504
5536
|
this.registerer.waitingToggle(false);
|
|
@@ -5507,7 +5539,7 @@ class WebRTCClient extends Emitter {
|
|
|
5507
5539
|
}
|
|
5508
5540
|
|
|
5509
5541
|
async onDisconnect(error ) {
|
|
5510
|
-
logger.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
5542
|
+
logger$3.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
5511
5543
|
this.connectionPromise = null;
|
|
5512
5544
|
// The UA will attempt to reconnect automatically when an error occurred
|
|
5513
5545
|
this.eventEmitter.emit(DISCONNECTED, error);
|
|
@@ -5532,37 +5564,37 @@ class WebRTCClient extends Emitter {
|
|
|
5532
5564
|
};
|
|
5533
5565
|
|
|
5534
5566
|
if (this.skipRegister) {
|
|
5535
|
-
logger.info('sdk webrtc skip register...', logInfo);
|
|
5567
|
+
logger$3.info('sdk webrtc skip register...', logInfo);
|
|
5536
5568
|
return Promise.resolve();
|
|
5537
5569
|
}
|
|
5538
5570
|
|
|
5539
|
-
logger.info('sdk webrtc registering...', logInfo);
|
|
5571
|
+
logger$3.info('sdk webrtc registering...', logInfo);
|
|
5540
5572
|
|
|
5541
5573
|
if (!this.userAgent) {
|
|
5542
|
-
logger.info('sdk webrtc recreating User Agent');
|
|
5574
|
+
logger$3.info('sdk webrtc recreating User Agent');
|
|
5543
5575
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
5544
5576
|
}
|
|
5545
5577
|
if (!this.userAgent || this.isRegistered()) {
|
|
5546
|
-
logger.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
5578
|
+
logger$3.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
5547
5579
|
return Promise.resolve();
|
|
5548
5580
|
}
|
|
5549
5581
|
|
|
5550
5582
|
if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
|
|
5551
|
-
logger.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
5583
|
+
logger$3.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
5552
5584
|
return Promise.resolve();
|
|
5553
5585
|
}
|
|
5554
5586
|
|
|
5555
5587
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
5556
5588
|
|
|
5557
5589
|
const onRegisterFailed = () => {
|
|
5558
|
-
logger.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
5590
|
+
logger$3.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
5559
5591
|
this.connectionPromise = null;
|
|
5560
5592
|
if (this.registerer && this.registerer.waiting) {
|
|
5561
5593
|
this.registerer.waitingToggle(false);
|
|
5562
5594
|
}
|
|
5563
5595
|
|
|
5564
5596
|
if (tries <= MAX_REGISTER_TRIES) {
|
|
5565
|
-
logger.info('sdk webrtc registering, retrying...', { tries });
|
|
5597
|
+
logger$3.info('sdk webrtc registering, retrying...', { tries });
|
|
5566
5598
|
setTimeout(() => this.register(tries + 1), 300);
|
|
5567
5599
|
}
|
|
5568
5600
|
};
|
|
@@ -5571,18 +5603,18 @@ class WebRTCClient extends Emitter {
|
|
|
5571
5603
|
// Avoid race condition with the close method called just before register and setting userAgent to null
|
|
5572
5604
|
// during the resolution of the primise.
|
|
5573
5605
|
if (!this.userAgent) {
|
|
5574
|
-
logger.info('sdk webrtc recreating User Agent after connection');
|
|
5606
|
+
logger$3.info('sdk webrtc recreating User Agent after connection');
|
|
5575
5607
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
5576
5608
|
}
|
|
5577
5609
|
|
|
5578
|
-
logger.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
5610
|
+
logger$3.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
5579
5611
|
this.registerer = new Registerer(this.userAgent, registerOptions);
|
|
5580
5612
|
this.connectionPromise = null;
|
|
5581
5613
|
this._monkeyPatchRegisterer(this.registerer);
|
|
5582
5614
|
|
|
5583
5615
|
// Bind registerer events
|
|
5584
5616
|
this.registerer.stateChange.addListener(newState => {
|
|
5585
|
-
logger.info('sdk webrtc registering, state changed', { newState });
|
|
5617
|
+
logger$3.info('sdk webrtc registering, state changed', { newState });
|
|
5586
5618
|
|
|
5587
5619
|
if (newState === RegistererState.Registered && this.registerer
|
|
5588
5620
|
&& this.registerer.state === RegistererState.Registered) {
|
|
@@ -5595,7 +5627,7 @@ class WebRTCClient extends Emitter {
|
|
|
5595
5627
|
const options = {
|
|
5596
5628
|
requestDelegate: {
|
|
5597
5629
|
onReject: response => {
|
|
5598
|
-
logger.error('sdk webrtc registering, rejected', { response });
|
|
5630
|
+
logger$3.error('sdk webrtc registering, rejected', { response });
|
|
5599
5631
|
|
|
5600
5632
|
onRegisterFailed();
|
|
5601
5633
|
},
|
|
@@ -5603,13 +5635,13 @@ class WebRTCClient extends Emitter {
|
|
|
5603
5635
|
};
|
|
5604
5636
|
|
|
5605
5637
|
return this.registerer.register(options).catch((e) => {
|
|
5606
|
-
logger.error('sdk webrtc registering, error', e);
|
|
5638
|
+
logger$3.error('sdk webrtc registering, error', e);
|
|
5607
5639
|
|
|
5608
5640
|
this.eventEmitter.emit(REGISTRATION_FAILED);
|
|
5609
5641
|
return e;
|
|
5610
5642
|
});
|
|
5611
5643
|
}).catch(error => {
|
|
5612
|
-
logger.error('sdk webrtc registering, transport error', error);
|
|
5644
|
+
logger$3.error('sdk webrtc registering, transport error', error);
|
|
5613
5645
|
onRegisterFailed();
|
|
5614
5646
|
});
|
|
5615
5647
|
}
|
|
@@ -5638,21 +5670,21 @@ class WebRTCClient extends Emitter {
|
|
|
5638
5670
|
}
|
|
5639
5671
|
|
|
5640
5672
|
unregister() {
|
|
5641
|
-
logger.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
5673
|
+
logger$3.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
5642
5674
|
if (!this.registerer) {
|
|
5643
5675
|
return Promise.resolve();
|
|
5644
5676
|
}
|
|
5645
5677
|
|
|
5646
5678
|
try {
|
|
5647
5679
|
return this.registerer.unregister().then(() => {
|
|
5648
|
-
logger.info('sdk webrtc unregistered');
|
|
5680
|
+
logger$3.info('sdk webrtc unregistered');
|
|
5649
5681
|
this._cleanupRegister();
|
|
5650
5682
|
}).catch(e => {
|
|
5651
|
-
logger.error('sdk webrtc unregistering, promise error', e);
|
|
5683
|
+
logger$3.error('sdk webrtc unregistering, promise error', e);
|
|
5652
5684
|
this._cleanupRegister();
|
|
5653
5685
|
});
|
|
5654
5686
|
} catch (e) {
|
|
5655
|
-
logger.error('sdk webrtc unregistering, error', e);
|
|
5687
|
+
logger$3.error('sdk webrtc unregistering, error', e);
|
|
5656
5688
|
// Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
|
|
5657
5689
|
// error when the registerer is in a bad state
|
|
5658
5690
|
this._cleanupRegister();
|
|
@@ -5660,7 +5692,7 @@ class WebRTCClient extends Emitter {
|
|
|
5660
5692
|
}
|
|
5661
5693
|
|
|
5662
5694
|
stop() {
|
|
5663
|
-
logger.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
5695
|
+
logger$3.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
5664
5696
|
if (!this.userAgent) {
|
|
5665
5697
|
return Promise.resolve();
|
|
5666
5698
|
}
|
|
@@ -5668,12 +5700,12 @@ class WebRTCClient extends Emitter {
|
|
|
5668
5700
|
return this.userAgent.stop().then(() => {
|
|
5669
5701
|
return this._cleanupRegister();
|
|
5670
5702
|
}).catch(e => {
|
|
5671
|
-
logger.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
5703
|
+
logger$3.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
5672
5704
|
});
|
|
5673
5705
|
}
|
|
5674
5706
|
|
|
5675
5707
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
5676
|
-
logger.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
5708
|
+
logger$3.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
5677
5709
|
const inviterOptions = {
|
|
5678
5710
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
5679
5711
|
conference,
|
|
@@ -5698,11 +5730,13 @@ class WebRTCClient extends Emitter {
|
|
|
5698
5730
|
const inviteOptions = {
|
|
5699
5731
|
requestDelegate: {
|
|
5700
5732
|
onAccept: (response ) => {
|
|
5701
|
-
session.sessionDescriptionHandler.peerConnection
|
|
5733
|
+
if (session.sessionDescriptionHandler.peerConnection) {
|
|
5734
|
+
session.sessionDescriptionHandler.peerConnection.sfu = conference;
|
|
5735
|
+
}
|
|
5702
5736
|
this._onAccepted(session, response.session, true);
|
|
5703
5737
|
},
|
|
5704
5738
|
onReject: (response ) => {
|
|
5705
|
-
logger.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
5739
|
+
logger$3.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
5706
5740
|
this._stopSendingStats(session);
|
|
5707
5741
|
this.stopNetworkMonitoring(session);
|
|
5708
5742
|
|
|
@@ -5725,11 +5759,11 @@ class WebRTCClient extends Emitter {
|
|
|
5725
5759
|
}
|
|
5726
5760
|
|
|
5727
5761
|
answer(session , enableVideo ) {
|
|
5728
|
-
logger.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
5762
|
+
logger$3.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
5729
5763
|
|
|
5730
5764
|
if (!session || !session.accept) {
|
|
5731
5765
|
const error = 'No session to answer, or not an invitation';
|
|
5732
|
-
logger.warn(error);
|
|
5766
|
+
logger$3.warn(error);
|
|
5733
5767
|
return Promise.reject(new Error(error));
|
|
5734
5768
|
}
|
|
5735
5769
|
const options = {
|
|
@@ -5739,15 +5773,15 @@ class WebRTCClient extends Emitter {
|
|
|
5739
5773
|
return session.accept(options).then(() => {
|
|
5740
5774
|
if (session.isCanceled) {
|
|
5741
5775
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
5742
|
-
logger.error(message, { id: session.id });
|
|
5776
|
+
logger$3.error(message, { id: session.id });
|
|
5743
5777
|
this.onCallEnded(session);
|
|
5744
5778
|
|
|
5745
5779
|
throw new CanceledCallError(message);
|
|
5746
5780
|
}
|
|
5747
|
-
logger.info('sdk webrtc answer, accepted.');
|
|
5781
|
+
logger$3.info('sdk webrtc answer, accepted.');
|
|
5748
5782
|
this._onAccepted(session);
|
|
5749
5783
|
}).catch(e => {
|
|
5750
|
-
logger.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
5784
|
+
logger$3.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
5751
5785
|
|
|
5752
5786
|
throw e;
|
|
5753
5787
|
});
|
|
@@ -5755,7 +5789,7 @@ class WebRTCClient extends Emitter {
|
|
|
5755
5789
|
|
|
5756
5790
|
hangup(session ) {
|
|
5757
5791
|
const { state, id } = session;
|
|
5758
|
-
logger.info('sdk webrtc hangup call', { id, state });
|
|
5792
|
+
logger$3.info('sdk webrtc hangup call', { id, state });
|
|
5759
5793
|
|
|
5760
5794
|
try {
|
|
5761
5795
|
this._stopSendingStats(session);
|
|
@@ -5784,7 +5818,7 @@ class WebRTCClient extends Emitter {
|
|
|
5784
5818
|
|
|
5785
5819
|
return bye();
|
|
5786
5820
|
} catch (error) {
|
|
5787
|
-
logger.warn('sdk webrtc hangup, error', error);
|
|
5821
|
+
logger$3.warn('sdk webrtc hangup, error', error);
|
|
5788
5822
|
}
|
|
5789
5823
|
|
|
5790
5824
|
return null;
|
|
@@ -5802,7 +5836,7 @@ class WebRTCClient extends Emitter {
|
|
|
5802
5836
|
// Fetch and emit an event at `interval` with session network stats
|
|
5803
5837
|
startNetworkMonitoring(session , interval = 1000) {
|
|
5804
5838
|
const sessionId = this.getSipSessionId(session);
|
|
5805
|
-
logger.info('starting network inspection', { id: sessionId });
|
|
5839
|
+
logger$3.info('starting network inspection', { id: sessionId });
|
|
5806
5840
|
|
|
5807
5841
|
this.sessionNetworkStats[sessionId] = [];
|
|
5808
5842
|
|
|
@@ -5812,7 +5846,7 @@ class WebRTCClient extends Emitter {
|
|
|
5812
5846
|
stopNetworkMonitoring(session ) {
|
|
5813
5847
|
const sessionId = this.getSipSessionId(session);
|
|
5814
5848
|
const exists = sessionId in this.networkMonitoringInterval;
|
|
5815
|
-
logger.info('stopping network inspection', { id: sessionId, exists });
|
|
5849
|
+
logger$3.info('stopping network inspection', { id: sessionId, exists });
|
|
5816
5850
|
|
|
5817
5851
|
if (exists) {
|
|
5818
5852
|
clearInterval(this.networkMonitoringInterval[sessionId]);
|
|
@@ -5822,17 +5856,17 @@ class WebRTCClient extends Emitter {
|
|
|
5822
5856
|
}
|
|
5823
5857
|
|
|
5824
5858
|
reject(session ) {
|
|
5825
|
-
logger.info('sdk webrtc reject call', { id: session.id });
|
|
5859
|
+
logger$3.info('sdk webrtc reject call', { id: session.id });
|
|
5826
5860
|
|
|
5827
5861
|
try {
|
|
5828
5862
|
return session.reject ? session.reject() : session.cancel();
|
|
5829
5863
|
} catch (e) {
|
|
5830
|
-
logger.warn('Error when rejecting call', e.message, e.stack);
|
|
5864
|
+
logger$3.warn('Error when rejecting call', e.message, e.stack);
|
|
5831
5865
|
}
|
|
5832
5866
|
}
|
|
5833
5867
|
|
|
5834
5868
|
async close() {
|
|
5835
|
-
logger.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
5869
|
+
logger$3.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
5836
5870
|
this._cleanupMedia();
|
|
5837
5871
|
this.connectionPromise = null;
|
|
5838
5872
|
|
|
@@ -5863,7 +5897,7 @@ class WebRTCClient extends Emitter {
|
|
|
5863
5897
|
// eg: "INVITE not rejectable in state Completed"
|
|
5864
5898
|
}
|
|
5865
5899
|
this.userAgent = null;
|
|
5866
|
-
logger.info('sdk webrtc client closed');
|
|
5900
|
+
logger$3.info('sdk webrtc client closed');
|
|
5867
5901
|
}
|
|
5868
5902
|
|
|
5869
5903
|
getNumber(session ) {
|
|
@@ -5876,13 +5910,13 @@ class WebRTCClient extends Emitter {
|
|
|
5876
5910
|
}
|
|
5877
5911
|
|
|
5878
5912
|
mute(session ) {
|
|
5879
|
-
logger.info('sdk webrtc mute', { id: session.id });
|
|
5913
|
+
logger$3.info('sdk webrtc mute', { id: session.id });
|
|
5880
5914
|
|
|
5881
5915
|
this._toggleAudio(session, true);
|
|
5882
5916
|
}
|
|
5883
5917
|
|
|
5884
5918
|
unmute(session ) {
|
|
5885
|
-
logger.info('sdk webrtc unmute', { id: session.id });
|
|
5919
|
+
logger$3.info('sdk webrtc unmute', { id: session.id });
|
|
5886
5920
|
|
|
5887
5921
|
this._toggleAudio(session, false);
|
|
5888
5922
|
}
|
|
@@ -5922,13 +5956,13 @@ class WebRTCClient extends Emitter {
|
|
|
5922
5956
|
}
|
|
5923
5957
|
|
|
5924
5958
|
toggleCameraOn(session ) {
|
|
5925
|
-
logger.info('sdk webrtc toggle camera on', { id: session.id });
|
|
5959
|
+
logger$3.info('sdk webrtc toggle camera on', { id: session.id });
|
|
5926
5960
|
|
|
5927
5961
|
this._toggleVideo(session, false);
|
|
5928
5962
|
}
|
|
5929
5963
|
|
|
5930
5964
|
toggleCameraOff(session ) {
|
|
5931
|
-
logger.info('sdk webrtc toggle camera off', { id: session.id });
|
|
5965
|
+
logger$3.info('sdk webrtc toggle camera off', { id: session.id });
|
|
5932
5966
|
|
|
5933
5967
|
this._toggleVideo(session, true);
|
|
5934
5968
|
}
|
|
@@ -5937,7 +5971,7 @@ class WebRTCClient extends Emitter {
|
|
|
5937
5971
|
const sessionId = this.getSipSessionId(session);
|
|
5938
5972
|
const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
|
|
5939
5973
|
|
|
5940
|
-
logger.info('sdk webrtc hold', {
|
|
5974
|
+
logger$3.info('sdk webrtc hold', {
|
|
5941
5975
|
sessionId,
|
|
5942
5976
|
keys: Object.keys(this.heldSessions),
|
|
5943
5977
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -5986,7 +6020,7 @@ class WebRTCClient extends Emitter {
|
|
|
5986
6020
|
const sessionId = this.getSipSessionId(session);
|
|
5987
6021
|
const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
|
|
5988
6022
|
|
|
5989
|
-
logger.info('sdk webrtc unhold', {
|
|
6023
|
+
logger$3.info('sdk webrtc unhold', {
|
|
5990
6024
|
sessionId,
|
|
5991
6025
|
keys: Object.keys(this.heldSessions),
|
|
5992
6026
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -6134,7 +6168,7 @@ class WebRTCClient extends Emitter {
|
|
|
6134
6168
|
if (!session.sessionDescriptionHandler) {
|
|
6135
6169
|
return;
|
|
6136
6170
|
}
|
|
6137
|
-
logger.info('Sending DTMF', {
|
|
6171
|
+
logger$3.info('Sending DTMF', {
|
|
6138
6172
|
id: this.getSipSessionId(session),
|
|
6139
6173
|
tone,
|
|
6140
6174
|
});
|
|
@@ -6150,7 +6184,7 @@ class WebRTCClient extends Emitter {
|
|
|
6150
6184
|
transfer(session , target ) {
|
|
6151
6185
|
this.hold(session);
|
|
6152
6186
|
|
|
6153
|
-
logger.info('Transfering a session', {
|
|
6187
|
+
logger$3.info('Transfering a session', {
|
|
6154
6188
|
id: this.getSipSessionId(session),
|
|
6155
6189
|
target,
|
|
6156
6190
|
});
|
|
@@ -6172,17 +6206,17 @@ class WebRTCClient extends Emitter {
|
|
|
6172
6206
|
atxfer(session ) {
|
|
6173
6207
|
this.hold(session);
|
|
6174
6208
|
|
|
6175
|
-
logger.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
6209
|
+
logger$3.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
6176
6210
|
|
|
6177
6211
|
const result = {
|
|
6178
6212
|
newSession: null,
|
|
6179
6213
|
init: async (target ) => {
|
|
6180
|
-
logger.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
6214
|
+
logger$3.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
6181
6215
|
|
|
6182
6216
|
result.newSession = await this.call(target);
|
|
6183
6217
|
},
|
|
6184
6218
|
complete: () => {
|
|
6185
|
-
logger.info('webrtc transfer completed', {
|
|
6219
|
+
logger$3.info('webrtc transfer completed', {
|
|
6186
6220
|
id: this.getSipSessionId(session),
|
|
6187
6221
|
referId: this.getSipSessionId(result.newSession),
|
|
6188
6222
|
});
|
|
@@ -6203,7 +6237,7 @@ class WebRTCClient extends Emitter {
|
|
|
6203
6237
|
return;
|
|
6204
6238
|
}
|
|
6205
6239
|
|
|
6206
|
-
logger.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
6240
|
+
logger$3.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
6207
6241
|
|
|
6208
6242
|
try {
|
|
6209
6243
|
sipSession.message({
|
|
@@ -6245,7 +6279,7 @@ class WebRTCClient extends Emitter {
|
|
|
6245
6279
|
}
|
|
6246
6280
|
|
|
6247
6281
|
changeAudioOutputVolume(volume ) {
|
|
6248
|
-
logger.info('Changing audio output volume', { volume });
|
|
6282
|
+
logger$3.info('Changing audio output volume', { volume });
|
|
6249
6283
|
|
|
6250
6284
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
6251
6285
|
if (audioElement instanceof HTMLAudioElement) {
|
|
@@ -6257,7 +6291,7 @@ class WebRTCClient extends Emitter {
|
|
|
6257
6291
|
}
|
|
6258
6292
|
|
|
6259
6293
|
changeAudioOutputDevice(id ) {
|
|
6260
|
-
logger.info('Changing audio output device', { id });
|
|
6294
|
+
logger$3.info('Changing audio output device', { id });
|
|
6261
6295
|
|
|
6262
6296
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
6263
6297
|
// `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
|
|
@@ -6274,7 +6308,7 @@ class WebRTCClient extends Emitter {
|
|
|
6274
6308
|
|
|
6275
6309
|
changeAudioInputDevice(id , session ) {
|
|
6276
6310
|
const currentId = this.getAudioDeviceId();
|
|
6277
|
-
logger.info('setting audio input device', { id, currentId, session: !!session });
|
|
6311
|
+
logger$3.info('setting audio input device', { id, currentId, session: !!session });
|
|
6278
6312
|
|
|
6279
6313
|
if (id === currentId) {
|
|
6280
6314
|
return null;
|
|
@@ -6320,7 +6354,7 @@ class WebRTCClient extends Emitter {
|
|
|
6320
6354
|
|
|
6321
6355
|
setVideoInputDevice(id ) {
|
|
6322
6356
|
const currentId = this.getVideoDeviceId();
|
|
6323
|
-
logger.info('setting video input device', { id, currentId });
|
|
6357
|
+
logger$3.info('setting video input device', { id, currentId });
|
|
6324
6358
|
|
|
6325
6359
|
if (id === currentId) {
|
|
6326
6360
|
return null;
|
|
@@ -6345,7 +6379,7 @@ class WebRTCClient extends Emitter {
|
|
|
6345
6379
|
const sessionId = this.getSipSessionId(session);
|
|
6346
6380
|
const localStream = this.getLocalStream(sessionId);
|
|
6347
6381
|
|
|
6348
|
-
logger.info('changing video input device', { id, sessionId });
|
|
6382
|
+
logger$3.info('changing video input device', { id, sessionId });
|
|
6349
6383
|
|
|
6350
6384
|
// Release old video stream
|
|
6351
6385
|
if (localStream) {
|
|
@@ -6413,7 +6447,7 @@ class WebRTCClient extends Emitter {
|
|
|
6413
6447
|
const shouldDoScreenSharing = newConstraints && newConstraints.screen;
|
|
6414
6448
|
const desktop = newConstraints && newConstraints.desktop;
|
|
6415
6449
|
|
|
6416
|
-
logger.info('Sending reinvite', {
|
|
6450
|
+
logger$3.info('Sending reinvite', {
|
|
6417
6451
|
id: this.getSipSessionId(sipSession),
|
|
6418
6452
|
newConstraints,
|
|
6419
6453
|
conference,
|
|
@@ -6451,7 +6485,7 @@ class WebRTCClient extends Emitter {
|
|
|
6451
6485
|
sipSession.incomingInviteRequest.message.body = response.message.body;
|
|
6452
6486
|
}
|
|
6453
6487
|
|
|
6454
|
-
logger.info('on re-INVITE accepted', {
|
|
6488
|
+
logger$3.info('on re-INVITE accepted', {
|
|
6455
6489
|
id: this.getSipSessionId(sipSession),
|
|
6456
6490
|
wasMuted,
|
|
6457
6491
|
shouldDoScreenSharing,
|
|
@@ -6570,6 +6604,16 @@ class WebRTCClient extends Emitter {
|
|
|
6570
6604
|
return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
|
|
6571
6605
|
}
|
|
6572
6606
|
|
|
6607
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
6608
|
+
getRemoteVideoStreamFromPc(sessionId ) {
|
|
6609
|
+
const pc = this.getPeerConnection(sessionId);
|
|
6610
|
+
if (!pc) {
|
|
6611
|
+
return null;
|
|
6612
|
+
}
|
|
6613
|
+
|
|
6614
|
+
return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
|
|
6615
|
+
}
|
|
6616
|
+
|
|
6573
6617
|
hasVideo(sessionId ) {
|
|
6574
6618
|
return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
|
|
6575
6619
|
}
|
|
@@ -6616,7 +6660,7 @@ class WebRTCClient extends Emitter {
|
|
|
6616
6660
|
}
|
|
6617
6661
|
|
|
6618
6662
|
startHeartbeat() {
|
|
6619
|
-
logger.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
6663
|
+
logger$3.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
6620
6664
|
if (!this.userAgent) {
|
|
6621
6665
|
this.heartbeat.stop();
|
|
6622
6666
|
return;
|
|
@@ -6629,7 +6673,7 @@ class WebRTCClient extends Emitter {
|
|
|
6629
6673
|
}
|
|
6630
6674
|
|
|
6631
6675
|
stopHeartbeat() {
|
|
6632
|
-
logger.info('sdk webrtc stop heartbeat');
|
|
6676
|
+
logger$3.info('sdk webrtc stop heartbeat');
|
|
6633
6677
|
this.heartbeat.stop();
|
|
6634
6678
|
}
|
|
6635
6679
|
|
|
@@ -6650,7 +6694,7 @@ class WebRTCClient extends Emitter {
|
|
|
6650
6694
|
}
|
|
6651
6695
|
|
|
6652
6696
|
attemptReconnection() {
|
|
6653
|
-
logger.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
6697
|
+
logger$3.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
6654
6698
|
if (!this.userAgent) {
|
|
6655
6699
|
return;
|
|
6656
6700
|
}
|
|
@@ -6675,7 +6719,7 @@ class WebRTCClient extends Emitter {
|
|
|
6675
6719
|
return;
|
|
6676
6720
|
}
|
|
6677
6721
|
|
|
6678
|
-
logger.info('setting local media stream', {
|
|
6722
|
+
logger$3.info('setting local media stream', {
|
|
6679
6723
|
sipSessionId,
|
|
6680
6724
|
tracks: newStream ? newStream.getTracks() : null,
|
|
6681
6725
|
});
|
|
@@ -6692,7 +6736,7 @@ class WebRTCClient extends Emitter {
|
|
|
6692
6736
|
|
|
6693
6737
|
const oldStream = this.getLocalStream(sipSessionId);
|
|
6694
6738
|
|
|
6695
|
-
logger.info('updating local stream', {
|
|
6739
|
+
logger$3.info('updating local stream', {
|
|
6696
6740
|
sipSessionId,
|
|
6697
6741
|
oldStream: !!oldStream,
|
|
6698
6742
|
tracks: newStream.getTracks(),
|
|
@@ -6712,7 +6756,7 @@ class WebRTCClient extends Emitter {
|
|
|
6712
6756
|
const remoteStream = this.getRemoteStream(sessionId);
|
|
6713
6757
|
const pc = this.getPeerConnection(sessionId);
|
|
6714
6758
|
|
|
6715
|
-
logger.info('Updating remote stream', {
|
|
6759
|
+
logger$3.info('Updating remote stream', {
|
|
6716
6760
|
sessionId,
|
|
6717
6761
|
tracks: remoteStream ? remoteStream.getTracks() : null,
|
|
6718
6762
|
receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
|
|
@@ -6738,7 +6782,7 @@ class WebRTCClient extends Emitter {
|
|
|
6738
6782
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
6739
6783
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
6740
6784
|
|
|
6741
|
-
logger.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
6785
|
+
logger$3.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
6742
6786
|
|
|
6743
6787
|
return {
|
|
6744
6788
|
constraints: {
|
|
@@ -6787,7 +6831,7 @@ class WebRTCClient extends Emitter {
|
|
|
6787
6831
|
}
|
|
6788
6832
|
|
|
6789
6833
|
_onTransportError() {
|
|
6790
|
-
logger.error('on transport error');
|
|
6834
|
+
logger$3.error('on transport error');
|
|
6791
6835
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
6792
6836
|
this.attemptReconnection();
|
|
6793
6837
|
}
|
|
@@ -6796,7 +6840,7 @@ class WebRTCClient extends Emitter {
|
|
|
6796
6840
|
const body = message && typeof message === 'object' ? message.data : message;
|
|
6797
6841
|
if (body && body.indexOf('200 OK') !== -1) {
|
|
6798
6842
|
if (this.hasHeartbeat()) {
|
|
6799
|
-
logger.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
6843
|
+
logger$3.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
6800
6844
|
|
|
6801
6845
|
this.heartbeat.onHeartbeat();
|
|
6802
6846
|
if (this.heartbeatCb) {
|
|
@@ -6807,7 +6851,7 @@ class WebRTCClient extends Emitter {
|
|
|
6807
6851
|
}
|
|
6808
6852
|
|
|
6809
6853
|
async _onHeartbeatTimeout() {
|
|
6810
|
-
logger.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
6854
|
+
logger$3.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
6811
6855
|
|
|
6812
6856
|
if (this.heartbeatTimeoutCb) {
|
|
6813
6857
|
this.heartbeatTimeoutCb();
|
|
@@ -6819,7 +6863,7 @@ class WebRTCClient extends Emitter {
|
|
|
6819
6863
|
try {
|
|
6820
6864
|
await this.userAgent.transport.disconnect();
|
|
6821
6865
|
} catch (e) {
|
|
6822
|
-
logger.error('Transport disconnection after heartbeat timeout, error', e);
|
|
6866
|
+
logger$3.error('Transport disconnection after heartbeat timeout, error', e);
|
|
6823
6867
|
}
|
|
6824
6868
|
}
|
|
6825
6869
|
|
|
@@ -6852,31 +6896,31 @@ class WebRTCClient extends Emitter {
|
|
|
6852
6896
|
}
|
|
6853
6897
|
|
|
6854
6898
|
_connectIfNeeded() {
|
|
6855
|
-
logger.info('connect if needed, checking', { connected: this.isConnected() });
|
|
6899
|
+
logger$3.info('connect if needed, checking', { connected: this.isConnected() });
|
|
6856
6900
|
if (!this.userAgent) {
|
|
6857
|
-
logger.info('need to recreate User Agent');
|
|
6901
|
+
logger$3.info('need to recreate User Agent');
|
|
6858
6902
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6859
6903
|
}
|
|
6860
6904
|
|
|
6861
6905
|
if (this.isConnected()) {
|
|
6862
|
-
logger.info('webrtc sdk, already connected');
|
|
6906
|
+
logger$3.info('webrtc sdk, already connected');
|
|
6863
6907
|
return Promise.resolve();
|
|
6864
6908
|
}
|
|
6865
6909
|
|
|
6866
6910
|
if (this.isConnecting()) {
|
|
6867
|
-
logger.info('webrtc sdk, already connecting...');
|
|
6911
|
+
logger$3.info('webrtc sdk, already connecting...');
|
|
6868
6912
|
|
|
6869
6913
|
this.connectionPromise = this.userAgent.transport.connectPromise;
|
|
6870
6914
|
return this.connectionPromise;
|
|
6871
6915
|
}
|
|
6872
6916
|
|
|
6873
6917
|
if (this.connectionPromise) {
|
|
6874
|
-
logger.info('webrtc sdk, connection promise connecting...');
|
|
6918
|
+
logger$3.info('webrtc sdk, connection promise connecting...');
|
|
6875
6919
|
// $FlowFixMe
|
|
6876
6920
|
return this.connectionPromise;
|
|
6877
6921
|
}
|
|
6878
6922
|
|
|
6879
|
-
logger.info('WebRTC UA needs to connect');
|
|
6923
|
+
logger$3.info('WebRTC UA needs to connect');
|
|
6880
6924
|
|
|
6881
6925
|
// Force UA to reconnect
|
|
6882
6926
|
if (this.userAgent && this.userAgent.state !== UserAgentState.Stopped) {
|
|
@@ -7001,7 +7045,7 @@ class WebRTCClient extends Emitter {
|
|
|
7001
7045
|
|
|
7002
7046
|
sdh.peerConnectionDelegate = {
|
|
7003
7047
|
onicecandidateerror: (error ) => {
|
|
7004
|
-
logger.error('on icecandidate error', {
|
|
7048
|
+
logger$3.error('on icecandidate error', {
|
|
7005
7049
|
address: error.address,
|
|
7006
7050
|
port: error.port,
|
|
7007
7051
|
errorCode: error.errorCode,
|
|
@@ -7030,7 +7074,7 @@ class WebRTCClient extends Emitter {
|
|
|
7030
7074
|
updatedNumber = session.assertedIdentity.uri.normal.user;
|
|
7031
7075
|
updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
|
|
7032
7076
|
}
|
|
7033
|
-
logger.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
7077
|
+
logger$3.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
7034
7078
|
|
|
7035
7079
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
7036
7080
|
|
|
@@ -7051,7 +7095,7 @@ class WebRTCClient extends Emitter {
|
|
|
7051
7095
|
}
|
|
7052
7096
|
|
|
7053
7097
|
_onAccepted(session , sessionDialog , withEvent = true) {
|
|
7054
|
-
logger.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
7098
|
+
logger$3.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
7055
7099
|
|
|
7056
7100
|
this.storeSipSession(session);
|
|
7057
7101
|
|
|
@@ -7063,7 +7107,7 @@ class WebRTCClient extends Emitter {
|
|
|
7063
7107
|
const onTrack = (event ) => {
|
|
7064
7108
|
const isAudioOnly = this._isAudioOnly(session);
|
|
7065
7109
|
const { kind, label, readyState, id, muted } = event.track;
|
|
7066
|
-
logger.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
7110
|
+
logger$3.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
7067
7111
|
|
|
7068
7112
|
// Stop video track in audio only mode
|
|
7069
7113
|
if (isAudioOnly && kind === 'video') {
|
|
@@ -7080,6 +7124,7 @@ class WebRTCClient extends Emitter {
|
|
|
7080
7124
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
7081
7125
|
|
|
7082
7126
|
pc.oniceconnectionstatechange = () => {
|
|
7127
|
+
logger$3.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
7083
7128
|
if (pc.iceConnectionState === 'disconnected') {
|
|
7084
7129
|
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
7085
7130
|
}
|
|
@@ -7252,10 +7297,10 @@ class WebRTCClient extends Emitter {
|
|
|
7252
7297
|
|
|
7253
7298
|
_stopSendingStats(session ) {
|
|
7254
7299
|
const sessionId = this.getSipSessionId(session);
|
|
7255
|
-
logger.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
7300
|
+
logger$3.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
7256
7301
|
|
|
7257
7302
|
if (sessionId in this.statsIntervals) {
|
|
7258
|
-
logger.trace('Stop sending stats for call', { sessionId });
|
|
7303
|
+
logger$3.trace('Stop sending stats for call', { sessionId });
|
|
7259
7304
|
this.statsIntervals[sessionId]();
|
|
7260
7305
|
delete this.statsIntervals[sessionId];
|
|
7261
7306
|
}
|
|
@@ -7271,7 +7316,7 @@ class WebRTCClient extends Emitter {
|
|
|
7271
7316
|
try {
|
|
7272
7317
|
await this.userAgent.transport.disconnect();
|
|
7273
7318
|
} catch (e) {
|
|
7274
|
-
logger.error('WebRTC transport disconnect, error', e);
|
|
7319
|
+
logger$3.error('WebRTC transport disconnect, error', e);
|
|
7275
7320
|
}
|
|
7276
7321
|
}
|
|
7277
7322
|
}
|
|
@@ -7308,25 +7353,25 @@ class WebRTCClient extends Emitter {
|
|
|
7308
7353
|
|
|
7309
7354
|
stats.forEach(report => {
|
|
7310
7355
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
7311
|
-
audioBytesSent += report.bytesSent + report.headerBytesSent;
|
|
7356
|
+
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
7312
7357
|
}
|
|
7313
7358
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
7314
|
-
audioBytesSent += report.bytesSent;
|
|
7359
|
+
audioBytesSent += Number(report.bytesSent);
|
|
7315
7360
|
}
|
|
7316
7361
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
7317
|
-
videoBytesSent += report.bytesSent + report.headerBytesSent;
|
|
7362
|
+
videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
7318
7363
|
}
|
|
7319
7364
|
if (report.type === 'inbound-rtp' && report.kind === 'audio') {
|
|
7320
|
-
packetsLost += report.packetsLost;
|
|
7321
|
-
networkStats.packetsReceived = report.packetsReceived;
|
|
7322
|
-
audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
7365
|
+
packetsLost += Number(report.packetsLost);
|
|
7366
|
+
networkStats.packetsReceived = Number(report.packetsReceived);
|
|
7367
|
+
audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
7323
7368
|
}
|
|
7324
7369
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
7325
|
-
videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
7370
|
+
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
7326
7371
|
}
|
|
7327
7372
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
7328
7373
|
if ('framesPerSecond' in report) {
|
|
7329
|
-
networkStats.framesPerSecond = report.framesPerSecond;
|
|
7374
|
+
networkStats.framesPerSecond = Number(report.framesPerSecond);
|
|
7330
7375
|
}
|
|
7331
7376
|
if ('framerateMean' in report) {
|
|
7332
7377
|
// framerateMean is only available in FF
|
|
@@ -7334,32 +7379,36 @@ class WebRTCClient extends Emitter {
|
|
|
7334
7379
|
}
|
|
7335
7380
|
}
|
|
7336
7381
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
|
|
7337
|
-
packetsLost += report.packetsLost;
|
|
7338
|
-
networkStats.roundTripTime = report.roundTripTime;
|
|
7339
|
-
networkStats.jitter = report.jitter;
|
|
7382
|
+
packetsLost += Number(report.packetsLost);
|
|
7383
|
+
networkStats.roundTripTime = Number(report.roundTripTime);
|
|
7384
|
+
networkStats.jitter = Number(report.jitter);
|
|
7340
7385
|
}
|
|
7341
7386
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
|
|
7342
|
-
packetsLost += report.packetsLost;
|
|
7387
|
+
packetsLost += Number(report.packetsLost);
|
|
7343
7388
|
}
|
|
7344
7389
|
if (report.type === 'transport') {
|
|
7345
|
-
transportSent += report.bytesSent;
|
|
7346
|
-
transportReceived += report.bytesReceived;
|
|
7390
|
+
transportSent += Number(report.bytesSent);
|
|
7391
|
+
transportReceived += Number(report.bytesReceived);
|
|
7347
7392
|
}
|
|
7348
7393
|
});
|
|
7349
7394
|
|
|
7350
7395
|
networkStats.packetsLost = packetsLost;
|
|
7351
|
-
networkStats.
|
|
7396
|
+
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
7397
|
+
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
7398
|
+
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
7352
7399
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
7353
|
-
networkStats.
|
|
7354
|
-
networkStats.
|
|
7400
|
+
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
7401
|
+
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
7402
|
+
networkStats.totalVideoBytesReceived = videoBytesReceived;
|
|
7403
|
+
networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
|
|
7404
|
+
networkStats.totalTransportSent = transportSent - lastTransportSent;
|
|
7355
7405
|
networkStats.transportSent = transportSent;
|
|
7356
|
-
networkStats.
|
|
7357
|
-
|
|
7358
|
-
const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
|
|
7359
|
-
+ (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
|
|
7360
|
-
+ (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
|
|
7406
|
+
networkStats.totalTransportReceived = transportReceived;
|
|
7407
|
+
networkStats.transportReceived = transportReceived - lastTransportReceived;
|
|
7361
7408
|
|
|
7362
|
-
networkStats.bandwidth =
|
|
7409
|
+
networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
|
|
7410
|
+
+ networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
|
|
7411
|
+
+ networkStats.transportSent;
|
|
7363
7412
|
|
|
7364
7413
|
this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
|
|
7365
7414
|
this.sessionNetworkStats[sessionId].push(networkStats);
|