@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
|
@@ -109,7 +109,7 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
|
|
|
109
109
|
|
|
110
110
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
111
111
|
|
|
112
|
-
const logger
|
|
112
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
113
113
|
|
|
114
114
|
// Use a function here to be able to mock it in tests
|
|
115
115
|
const realFetch = () => {
|
|
@@ -248,7 +248,7 @@ class ApiRequester {
|
|
|
248
248
|
};
|
|
249
249
|
|
|
250
250
|
if (this.refreshTokenPromise) {
|
|
251
|
-
logger
|
|
251
|
+
logger.info('A token is already refreshing, waiting ...', { url });
|
|
252
252
|
await this.refreshTokenPromise;
|
|
253
253
|
}
|
|
254
254
|
|
|
@@ -268,7 +268,7 @@ class ApiRequester {
|
|
|
268
268
|
return promise.then(async (err ) => {
|
|
269
269
|
// Check if the token is still valid
|
|
270
270
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
271
|
-
logger
|
|
271
|
+
logger.warn('token expired', { error: err.reason });
|
|
272
272
|
// Replay the call after refreshing the token
|
|
273
273
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
274
274
|
}
|
|
@@ -278,7 +278,7 @@ class ApiRequester {
|
|
|
278
278
|
: exceptionClass.fromResponse(err, response.status);
|
|
279
279
|
|
|
280
280
|
if (this.shouldLogErrors) {
|
|
281
|
-
logger
|
|
281
|
+
logger.error('API error', error);
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
throw error;
|
|
@@ -288,7 +288,7 @@ class ApiRequester {
|
|
|
288
288
|
return newParse(response, isJson);
|
|
289
289
|
}).catch(error => {
|
|
290
290
|
if (this.shouldLogErrors) {
|
|
291
|
-
logger
|
|
291
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
throw error;
|
|
@@ -316,13 +316,13 @@ class ApiRequester {
|
|
|
316
316
|
) {
|
|
317
317
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
318
318
|
let newPath = path;
|
|
319
|
-
logger
|
|
319
|
+
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
320
320
|
|
|
321
321
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
322
322
|
|
|
323
323
|
return this.refreshTokenPromise.then(() => {
|
|
324
324
|
this.refreshTokenPromise = null;
|
|
325
|
-
logger
|
|
325
|
+
logger.info('token refreshed', { isTokenNotFound });
|
|
326
326
|
if (isTokenNotFound) {
|
|
327
327
|
const pathParts = path.split('/');
|
|
328
328
|
pathParts.pop();
|
|
@@ -421,6 +421,7 @@ class IssueReporter {
|
|
|
421
421
|
|
|
422
422
|
|
|
423
423
|
|
|
424
|
+
|
|
424
425
|
|
|
425
426
|
constructor() {
|
|
426
427
|
addLevelsTo(this);
|
|
@@ -432,12 +433,17 @@ class IssueReporter {
|
|
|
432
433
|
this.bufferTimeout = null;
|
|
433
434
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
434
435
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
436
|
+
this._callback = null;
|
|
435
437
|
}
|
|
436
438
|
|
|
437
439
|
init() {
|
|
438
440
|
this._catchConsole();
|
|
439
441
|
}
|
|
440
442
|
|
|
443
|
+
setCallback(cb ) {
|
|
444
|
+
this._callback = cb;
|
|
445
|
+
}
|
|
446
|
+
|
|
441
447
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
442
448
|
this.remoteClientConfiguration = configuration;
|
|
443
449
|
}
|
|
@@ -473,6 +479,7 @@ class IssueReporter {
|
|
|
473
479
|
|
|
474
480
|
// Handle category label
|
|
475
481
|
let category = null;
|
|
482
|
+
let skipSendToRemote = false;
|
|
476
483
|
let extra = {};
|
|
477
484
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
478
485
|
category = args[0].split('=')[1];
|
|
@@ -488,6 +495,7 @@ class IssueReporter {
|
|
|
488
495
|
errorMessage: lastArg.message,
|
|
489
496
|
errorStack: lastArg.stack,
|
|
490
497
|
errorType: lastArg.constructor.name,
|
|
498
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
491
499
|
};
|
|
492
500
|
} else {
|
|
493
501
|
extra = lastArg;
|
|
@@ -496,6 +504,11 @@ class IssueReporter {
|
|
|
496
504
|
args.splice(1, 1);
|
|
497
505
|
}
|
|
498
506
|
|
|
507
|
+
if (extra.skipSendToRemote) {
|
|
508
|
+
skipSendToRemote = true;
|
|
509
|
+
delete extra.skipSendToRemote;
|
|
510
|
+
}
|
|
511
|
+
|
|
499
512
|
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
500
513
|
const message = args.join(', ');
|
|
501
514
|
let consoleMessage = message;
|
|
@@ -516,7 +529,13 @@ class IssueReporter {
|
|
|
516
529
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
517
530
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
518
531
|
|
|
519
|
-
this.
|
|
532
|
+
if (this._callback) {
|
|
533
|
+
this._callback(level, consoleMessage);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
if (!skipSendToRemote) {
|
|
537
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
538
|
+
}
|
|
520
539
|
}
|
|
521
540
|
|
|
522
541
|
logRequest(url , options , response , start ) {
|
|
@@ -661,7 +680,11 @@ class IssueReporter {
|
|
|
661
680
|
},
|
|
662
681
|
// $FlowFixMe
|
|
663
682
|
body,
|
|
664
|
-
}).catch(() => {
|
|
683
|
+
}).catch((e ) => {
|
|
684
|
+
// $FlowFixMe
|
|
685
|
+
e.skipSendToRemote = true;
|
|
686
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
687
|
+
|
|
665
688
|
setTimeout(() => {
|
|
666
689
|
if (isArray) {
|
|
667
690
|
payload = payload.map(message => {
|
|
@@ -710,10 +733,6 @@ const getSrflxOrRelay = (candidates ) =>
|
|
|
710
733
|
candidates
|
|
711
734
|
.filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
|
|
712
735
|
|
|
713
|
-
const areCandidateValid = (candidates ) =>
|
|
714
|
-
getSrflxOrRelay(candidates)
|
|
715
|
-
.length > 0;
|
|
716
|
-
|
|
717
736
|
const getVideoDirection = (sdp ) => {
|
|
718
737
|
const parsedSdp = sdpParser__default['default'].parse(sdp);
|
|
719
738
|
const videoMedia = parsedSdp.media.find(media => media.type === 'video');
|
|
@@ -766,8 +785,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
766
785
|
/* global RTCSessionDescriptionInit, navigator */
|
|
767
786
|
|
|
768
787
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
769
|
-
const MAX_WAIT_FOR_ICE_TRIES = 20;
|
|
770
|
-
const WAIT_FOR_ICE_TIMEOUT = 500;
|
|
771
788
|
|
|
772
789
|
// Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
|
|
773
790
|
const wazoMediaStreamFactory = (constraints ) => {
|
|
@@ -957,38 +974,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
957
974
|
this._peerConnection = undefined;
|
|
958
975
|
}
|
|
959
976
|
|
|
960
|
-
async _waitForValidGatheredIce() {
|
|
961
|
-
let tries = 0;
|
|
962
|
-
|
|
963
|
-
while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
|
|
964
|
-
wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
|
|
965
|
-
tries,
|
|
966
|
-
max: MAX_WAIT_FOR_ICE_TRIES,
|
|
967
|
-
});
|
|
968
|
-
|
|
969
|
-
tries++;
|
|
970
|
-
|
|
971
|
-
// eslint-disable-next-line no-await-in-loop
|
|
972
|
-
await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
|
|
976
|
-
const errorMsg = 'No valid candidates found, can\'t answer the call';
|
|
977
|
-
const error = new Error(errorMsg);
|
|
978
|
-
wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
|
|
979
|
-
|
|
980
|
-
// Emit an error, because sip.js catches the exception and switch to status Terminated.
|
|
981
|
-
this.eventEmitter.emit('error', error);
|
|
982
|
-
|
|
983
|
-
wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
// eslint-disable-next-line
|
|
987
|
-
wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
988
|
-
|
|
989
|
-
return this.getLocalSessionDescription();
|
|
990
|
-
}
|
|
991
|
-
|
|
992
977
|
// Overridden to send `inactive` in conference
|
|
993
978
|
updateDirection(options , isConference = false,
|
|
994
979
|
audioOnly = false) {
|
|
@@ -2098,6 +2083,9 @@ class Contact {
|
|
|
2098
2083
|
}
|
|
2099
2084
|
|
|
2100
2085
|
static parseMany(response ) {
|
|
2086
|
+
if (!response || !response.results) {
|
|
2087
|
+
return [];
|
|
2088
|
+
}
|
|
2101
2089
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
2102
2090
|
}
|
|
2103
2091
|
|
|
@@ -3175,8 +3163,9 @@ class ExternalApp {
|
|
|
3175
3163
|
|
|
3176
3164
|
|
|
3177
3165
|
|
|
3178
|
-
|
|
3166
|
+
|
|
3179
3167
|
|
|
3168
|
+
|
|
3180
3169
|
|
|
3181
3170
|
|
|
3182
3171
|
class Meeting {
|
|
@@ -3187,9 +3176,10 @@ class Meeting {
|
|
|
3187
3176
|
|
|
3188
3177
|
|
|
3189
3178
|
|
|
3190
|
-
|
|
3179
|
+
|
|
3191
3180
|
|
|
3192
3181
|
|
|
3182
|
+
|
|
3193
3183
|
|
|
3194
3184
|
static parse(plain ) {
|
|
3195
3185
|
return new Meeting({
|
|
@@ -3199,24 +3189,43 @@ class Meeting {
|
|
|
3199
3189
|
ownerUuids: plain.owner_uuids,
|
|
3200
3190
|
port: plain.port,
|
|
3201
3191
|
uuid: plain.uuid,
|
|
3202
|
-
|
|
3192
|
+
extension: plain.exten,
|
|
3203
3193
|
persistent: plain.persistent,
|
|
3194
|
+
creationTime: moment__default['default'](plain.creation_time).toDate(),
|
|
3204
3195
|
});
|
|
3205
3196
|
}
|
|
3206
3197
|
|
|
3198
|
+
static parseMany(items ) {
|
|
3199
|
+
if (!items) {
|
|
3200
|
+
return [];
|
|
3201
|
+
}
|
|
3202
|
+
return items.map(plain => Meeting.parse(plain));
|
|
3203
|
+
}
|
|
3204
|
+
|
|
3207
3205
|
static newFrom(meeting ) {
|
|
3208
3206
|
return newFrom(meeting, Meeting);
|
|
3209
3207
|
}
|
|
3210
3208
|
|
|
3211
|
-
constructor({
|
|
3209
|
+
constructor({
|
|
3210
|
+
uuid,
|
|
3211
|
+
name,
|
|
3212
|
+
guestSipAuthorization,
|
|
3213
|
+
ownerUuids,
|
|
3214
|
+
port,
|
|
3215
|
+
uri,
|
|
3216
|
+
extension,
|
|
3217
|
+
persistent,
|
|
3218
|
+
creationTime,
|
|
3219
|
+
} = {}) {
|
|
3212
3220
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
3213
3221
|
this.uri = uri;
|
|
3214
3222
|
this.name = name;
|
|
3215
3223
|
this.ownerUuids = ownerUuids;
|
|
3216
3224
|
this.port = port;
|
|
3217
3225
|
this.uuid = uuid;
|
|
3218
|
-
this.
|
|
3226
|
+
this.extension = extension;
|
|
3219
3227
|
this.persistent = persistent;
|
|
3228
|
+
this.creationTime = creationTime;
|
|
3220
3229
|
|
|
3221
3230
|
// Useful to compare instead of instanceof with minified code
|
|
3222
3231
|
this.type = 'Meeting';
|
|
@@ -3294,8 +3303,11 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
3294
3303
|
}
|
|
3295
3304
|
},
|
|
3296
3305
|
|
|
3297
|
-
|
|
3298
|
-
client.
|
|
3306
|
+
getMyMeetings: () =>
|
|
3307
|
+
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
3308
|
+
|
|
3309
|
+
createMyMeeting: (name , persistent ) =>
|
|
3310
|
+
client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
|
|
3299
3311
|
|
|
3300
3312
|
deleteMyMeeting: (meetingUuid ) =>
|
|
3301
3313
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -3391,6 +3403,10 @@ class ChatMessage {
|
|
|
3391
3403
|
|
|
3392
3404
|
|
|
3393
3405
|
static parseMany(plain ) {
|
|
3406
|
+
if (!plain || !plain.items) {
|
|
3407
|
+
return [];
|
|
3408
|
+
}
|
|
3409
|
+
|
|
3394
3410
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
3395
3411
|
}
|
|
3396
3412
|
|
|
@@ -3500,6 +3516,9 @@ class Voicemail {
|
|
|
3500
3516
|
}
|
|
3501
3517
|
|
|
3502
3518
|
static parseMany(plain ) {
|
|
3519
|
+
if (!plain) {
|
|
3520
|
+
return [];
|
|
3521
|
+
}
|
|
3503
3522
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
3504
3523
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
3505
3524
|
|
|
@@ -3609,6 +3628,9 @@ class Call {
|
|
|
3609
3628
|
|
|
3610
3629
|
|
|
3611
3630
|
static parseMany(plain ) {
|
|
3631
|
+
if (!plain) {
|
|
3632
|
+
return [];
|
|
3633
|
+
}
|
|
3612
3634
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
3613
3635
|
}
|
|
3614
3636
|
|
|
@@ -3781,6 +3803,9 @@ class Recording {
|
|
|
3781
3803
|
|
|
3782
3804
|
|
|
3783
3805
|
static parseMany(recordings = []) {
|
|
3806
|
+
if (!recordings) {
|
|
3807
|
+
return [];
|
|
3808
|
+
}
|
|
3784
3809
|
return recordings.map(item => Recording.parse(item));
|
|
3785
3810
|
}
|
|
3786
3811
|
|
|
@@ -3882,6 +3907,10 @@ class CallLog {
|
|
|
3882
3907
|
}
|
|
3883
3908
|
|
|
3884
3909
|
static parseMany(plain ) {
|
|
3910
|
+
if (!plain || !plain.items) {
|
|
3911
|
+
return [];
|
|
3912
|
+
}
|
|
3913
|
+
|
|
3885
3914
|
return plain.items.map(item => CallLog.parse(item));
|
|
3886
3915
|
}
|
|
3887
3916
|
|
|
@@ -4118,7 +4147,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
4118
4147
|
|
|
4119
4148
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
4120
4149
|
|
|
4121
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
4150
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
4122
4151
|
|
|
4123
4152
|
/* */
|
|
4124
4153
|
|
|
@@ -4454,6 +4483,9 @@ class ChatRoom {
|
|
|
4454
4483
|
|
|
4455
4484
|
|
|
4456
4485
|
static parseMany(plain ) {
|
|
4486
|
+
if (!plain || !plain.items) {
|
|
4487
|
+
return [];
|
|
4488
|
+
}
|
|
4457
4489
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
4458
4490
|
}
|
|
4459
4491
|
|
|
@@ -5034,7 +5066,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
5034
5066
|
const WEBHOOKD_VERSION = '1.0';
|
|
5035
5067
|
const AMID_VERSION = '1.0';
|
|
5036
5068
|
|
|
5037
|
-
const logger$
|
|
5069
|
+
const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
5038
5070
|
|
|
5039
5071
|
class ApiClient {
|
|
5040
5072
|
|
|
@@ -5086,12 +5118,12 @@ class ApiClient {
|
|
|
5086
5118
|
}
|
|
5087
5119
|
|
|
5088
5120
|
async forceRefreshToken() {
|
|
5089
|
-
logger$
|
|
5121
|
+
logger$2.info('forcing refresh token, calling callback');
|
|
5090
5122
|
return this.refreshTokenCallback();
|
|
5091
5123
|
}
|
|
5092
5124
|
|
|
5093
5125
|
async refreshTokenCallback() {
|
|
5094
|
-
logger$
|
|
5126
|
+
logger$2.info('refresh token callback called', {
|
|
5095
5127
|
refreshToken: this.refreshToken,
|
|
5096
5128
|
refreshBackend: this.refreshBackend,
|
|
5097
5129
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -5109,7 +5141,7 @@ class ApiClient {
|
|
|
5109
5141
|
this.isMobile,
|
|
5110
5142
|
);
|
|
5111
5143
|
|
|
5112
|
-
logger$
|
|
5144
|
+
logger$2.info('token refreshed', { token: session.token });
|
|
5113
5145
|
|
|
5114
5146
|
if (this.onRefreshToken) {
|
|
5115
5147
|
this.onRefreshToken(session.token, session);
|
|
@@ -5282,7 +5314,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
|
|
|
5282
5314
|
const SEND_STATS_DELAY = 5000;
|
|
5283
5315
|
|
|
5284
5316
|
const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
|
|
5285
|
-
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
5317
|
+
const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
5286
5318
|
const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
5287
5319
|
|
|
5288
5320
|
// events
|
|
@@ -5458,13 +5490,13 @@ class WebRTCClient extends Emitter {
|
|
|
5458
5490
|
|
|
5459
5491
|
createUserAgent(configOverrides ) {
|
|
5460
5492
|
const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
|
|
5461
|
-
logger.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
5493
|
+
logger$3.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
5462
5494
|
|
|
5463
5495
|
webRTCConfiguration.delegate = {
|
|
5464
5496
|
onConnect: this.onConnect.bind(this),
|
|
5465
5497
|
onDisconnect: this.onDisconnect.bind(this),
|
|
5466
5498
|
onInvite: (invitation ) => {
|
|
5467
|
-
logger.info('sdk webrtc on invite', {
|
|
5499
|
+
logger$3.info('sdk webrtc on invite', {
|
|
5468
5500
|
method: 'delegate.onInvite',
|
|
5469
5501
|
id: invitation.id,
|
|
5470
5502
|
remoteURI: invitation.remoteURI,
|
|
@@ -5507,7 +5539,7 @@ class WebRTCClient extends Emitter {
|
|
|
5507
5539
|
}
|
|
5508
5540
|
|
|
5509
5541
|
onConnect() {
|
|
5510
|
-
logger.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
5542
|
+
logger$3.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
5511
5543
|
this.eventEmitter.emit(CONNECTED);
|
|
5512
5544
|
if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
|
|
5513
5545
|
this.registerer.waitingToggle(false);
|
|
@@ -5516,7 +5548,7 @@ class WebRTCClient extends Emitter {
|
|
|
5516
5548
|
}
|
|
5517
5549
|
|
|
5518
5550
|
async onDisconnect(error ) {
|
|
5519
|
-
logger.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
5551
|
+
logger$3.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
5520
5552
|
this.connectionPromise = null;
|
|
5521
5553
|
// The UA will attempt to reconnect automatically when an error occurred
|
|
5522
5554
|
this.eventEmitter.emit(DISCONNECTED, error);
|
|
@@ -5541,37 +5573,37 @@ class WebRTCClient extends Emitter {
|
|
|
5541
5573
|
};
|
|
5542
5574
|
|
|
5543
5575
|
if (this.skipRegister) {
|
|
5544
|
-
logger.info('sdk webrtc skip register...', logInfo);
|
|
5576
|
+
logger$3.info('sdk webrtc skip register...', logInfo);
|
|
5545
5577
|
return Promise.resolve();
|
|
5546
5578
|
}
|
|
5547
5579
|
|
|
5548
|
-
logger.info('sdk webrtc registering...', logInfo);
|
|
5580
|
+
logger$3.info('sdk webrtc registering...', logInfo);
|
|
5549
5581
|
|
|
5550
5582
|
if (!this.userAgent) {
|
|
5551
|
-
logger.info('sdk webrtc recreating User Agent');
|
|
5583
|
+
logger$3.info('sdk webrtc recreating User Agent');
|
|
5552
5584
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
5553
5585
|
}
|
|
5554
5586
|
if (!this.userAgent || this.isRegistered()) {
|
|
5555
|
-
logger.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
5587
|
+
logger$3.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
5556
5588
|
return Promise.resolve();
|
|
5557
5589
|
}
|
|
5558
5590
|
|
|
5559
5591
|
if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
|
|
5560
|
-
logger.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
5592
|
+
logger$3.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
5561
5593
|
return Promise.resolve();
|
|
5562
5594
|
}
|
|
5563
5595
|
|
|
5564
5596
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
5565
5597
|
|
|
5566
5598
|
const onRegisterFailed = () => {
|
|
5567
|
-
logger.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
5599
|
+
logger$3.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
5568
5600
|
this.connectionPromise = null;
|
|
5569
5601
|
if (this.registerer && this.registerer.waiting) {
|
|
5570
5602
|
this.registerer.waitingToggle(false);
|
|
5571
5603
|
}
|
|
5572
5604
|
|
|
5573
5605
|
if (tries <= MAX_REGISTER_TRIES) {
|
|
5574
|
-
logger.info('sdk webrtc registering, retrying...', { tries });
|
|
5606
|
+
logger$3.info('sdk webrtc registering, retrying...', { tries });
|
|
5575
5607
|
setTimeout(() => this.register(tries + 1), 300);
|
|
5576
5608
|
}
|
|
5577
5609
|
};
|
|
@@ -5580,18 +5612,18 @@ class WebRTCClient extends Emitter {
|
|
|
5580
5612
|
// Avoid race condition with the close method called just before register and setting userAgent to null
|
|
5581
5613
|
// during the resolution of the primise.
|
|
5582
5614
|
if (!this.userAgent) {
|
|
5583
|
-
logger.info('sdk webrtc recreating User Agent after connection');
|
|
5615
|
+
logger$3.info('sdk webrtc recreating User Agent after connection');
|
|
5584
5616
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
5585
5617
|
}
|
|
5586
5618
|
|
|
5587
|
-
logger.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
5619
|
+
logger$3.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
5588
5620
|
this.registerer = new registerer.Registerer(this.userAgent, registerOptions);
|
|
5589
5621
|
this.connectionPromise = null;
|
|
5590
5622
|
this._monkeyPatchRegisterer(this.registerer);
|
|
5591
5623
|
|
|
5592
5624
|
// Bind registerer events
|
|
5593
5625
|
this.registerer.stateChange.addListener(newState => {
|
|
5594
|
-
logger.info('sdk webrtc registering, state changed', { newState });
|
|
5626
|
+
logger$3.info('sdk webrtc registering, state changed', { newState });
|
|
5595
5627
|
|
|
5596
5628
|
if (newState === registererState.RegistererState.Registered && this.registerer
|
|
5597
5629
|
&& this.registerer.state === registererState.RegistererState.Registered) {
|
|
@@ -5604,7 +5636,7 @@ class WebRTCClient extends Emitter {
|
|
|
5604
5636
|
const options = {
|
|
5605
5637
|
requestDelegate: {
|
|
5606
5638
|
onReject: response => {
|
|
5607
|
-
logger.error('sdk webrtc registering, rejected', { response });
|
|
5639
|
+
logger$3.error('sdk webrtc registering, rejected', { response });
|
|
5608
5640
|
|
|
5609
5641
|
onRegisterFailed();
|
|
5610
5642
|
},
|
|
@@ -5612,13 +5644,13 @@ class WebRTCClient extends Emitter {
|
|
|
5612
5644
|
};
|
|
5613
5645
|
|
|
5614
5646
|
return this.registerer.register(options).catch((e) => {
|
|
5615
|
-
logger.error('sdk webrtc registering, error', e);
|
|
5647
|
+
logger$3.error('sdk webrtc registering, error', e);
|
|
5616
5648
|
|
|
5617
5649
|
this.eventEmitter.emit(REGISTRATION_FAILED);
|
|
5618
5650
|
return e;
|
|
5619
5651
|
});
|
|
5620
5652
|
}).catch(error => {
|
|
5621
|
-
logger.error('sdk webrtc registering, transport error', error);
|
|
5653
|
+
logger$3.error('sdk webrtc registering, transport error', error);
|
|
5622
5654
|
onRegisterFailed();
|
|
5623
5655
|
});
|
|
5624
5656
|
}
|
|
@@ -5647,21 +5679,21 @@ class WebRTCClient extends Emitter {
|
|
|
5647
5679
|
}
|
|
5648
5680
|
|
|
5649
5681
|
unregister() {
|
|
5650
|
-
logger.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
5682
|
+
logger$3.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
5651
5683
|
if (!this.registerer) {
|
|
5652
5684
|
return Promise.resolve();
|
|
5653
5685
|
}
|
|
5654
5686
|
|
|
5655
5687
|
try {
|
|
5656
5688
|
return this.registerer.unregister().then(() => {
|
|
5657
|
-
logger.info('sdk webrtc unregistered');
|
|
5689
|
+
logger$3.info('sdk webrtc unregistered');
|
|
5658
5690
|
this._cleanupRegister();
|
|
5659
5691
|
}).catch(e => {
|
|
5660
|
-
logger.error('sdk webrtc unregistering, promise error', e);
|
|
5692
|
+
logger$3.error('sdk webrtc unregistering, promise error', e);
|
|
5661
5693
|
this._cleanupRegister();
|
|
5662
5694
|
});
|
|
5663
5695
|
} catch (e) {
|
|
5664
|
-
logger.error('sdk webrtc unregistering, error', e);
|
|
5696
|
+
logger$3.error('sdk webrtc unregistering, error', e);
|
|
5665
5697
|
// Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
|
|
5666
5698
|
// error when the registerer is in a bad state
|
|
5667
5699
|
this._cleanupRegister();
|
|
@@ -5669,7 +5701,7 @@ class WebRTCClient extends Emitter {
|
|
|
5669
5701
|
}
|
|
5670
5702
|
|
|
5671
5703
|
stop() {
|
|
5672
|
-
logger.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
5704
|
+
logger$3.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
5673
5705
|
if (!this.userAgent) {
|
|
5674
5706
|
return Promise.resolve();
|
|
5675
5707
|
}
|
|
@@ -5677,12 +5709,12 @@ class WebRTCClient extends Emitter {
|
|
|
5677
5709
|
return this.userAgent.stop().then(() => {
|
|
5678
5710
|
return this._cleanupRegister();
|
|
5679
5711
|
}).catch(e => {
|
|
5680
|
-
logger.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
5712
|
+
logger$3.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
5681
5713
|
});
|
|
5682
5714
|
}
|
|
5683
5715
|
|
|
5684
5716
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
5685
|
-
logger.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
5717
|
+
logger$3.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
5686
5718
|
const inviterOptions = {
|
|
5687
5719
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
5688
5720
|
conference,
|
|
@@ -5707,11 +5739,13 @@ class WebRTCClient extends Emitter {
|
|
|
5707
5739
|
const inviteOptions = {
|
|
5708
5740
|
requestDelegate: {
|
|
5709
5741
|
onAccept: (response ) => {
|
|
5710
|
-
session.sessionDescriptionHandler.peerConnection
|
|
5742
|
+
if (session.sessionDescriptionHandler.peerConnection) {
|
|
5743
|
+
session.sessionDescriptionHandler.peerConnection.sfu = conference;
|
|
5744
|
+
}
|
|
5711
5745
|
this._onAccepted(session, response.session, true);
|
|
5712
5746
|
},
|
|
5713
5747
|
onReject: (response ) => {
|
|
5714
|
-
logger.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
5748
|
+
logger$3.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
5715
5749
|
this._stopSendingStats(session);
|
|
5716
5750
|
this.stopNetworkMonitoring(session);
|
|
5717
5751
|
|
|
@@ -5734,11 +5768,11 @@ class WebRTCClient extends Emitter {
|
|
|
5734
5768
|
}
|
|
5735
5769
|
|
|
5736
5770
|
answer(session , enableVideo ) {
|
|
5737
|
-
logger.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
5771
|
+
logger$3.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
5738
5772
|
|
|
5739
5773
|
if (!session || !session.accept) {
|
|
5740
5774
|
const error = 'No session to answer, or not an invitation';
|
|
5741
|
-
logger.warn(error);
|
|
5775
|
+
logger$3.warn(error);
|
|
5742
5776
|
return Promise.reject(new Error(error));
|
|
5743
5777
|
}
|
|
5744
5778
|
const options = {
|
|
@@ -5748,15 +5782,15 @@ class WebRTCClient extends Emitter {
|
|
|
5748
5782
|
return session.accept(options).then(() => {
|
|
5749
5783
|
if (session.isCanceled) {
|
|
5750
5784
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
5751
|
-
logger.error(message, { id: session.id });
|
|
5785
|
+
logger$3.error(message, { id: session.id });
|
|
5752
5786
|
this.onCallEnded(session);
|
|
5753
5787
|
|
|
5754
5788
|
throw new CanceledCallError(message);
|
|
5755
5789
|
}
|
|
5756
|
-
logger.info('sdk webrtc answer, accepted.');
|
|
5790
|
+
logger$3.info('sdk webrtc answer, accepted.');
|
|
5757
5791
|
this._onAccepted(session);
|
|
5758
5792
|
}).catch(e => {
|
|
5759
|
-
logger.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
5793
|
+
logger$3.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
5760
5794
|
|
|
5761
5795
|
throw e;
|
|
5762
5796
|
});
|
|
@@ -5764,7 +5798,7 @@ class WebRTCClient extends Emitter {
|
|
|
5764
5798
|
|
|
5765
5799
|
hangup(session ) {
|
|
5766
5800
|
const { state, id } = session;
|
|
5767
|
-
logger.info('sdk webrtc hangup call', { id, state });
|
|
5801
|
+
logger$3.info('sdk webrtc hangup call', { id, state });
|
|
5768
5802
|
|
|
5769
5803
|
try {
|
|
5770
5804
|
this._stopSendingStats(session);
|
|
@@ -5793,7 +5827,7 @@ class WebRTCClient extends Emitter {
|
|
|
5793
5827
|
|
|
5794
5828
|
return bye();
|
|
5795
5829
|
} catch (error) {
|
|
5796
|
-
logger.warn('sdk webrtc hangup, error', error);
|
|
5830
|
+
logger$3.warn('sdk webrtc hangup, error', error);
|
|
5797
5831
|
}
|
|
5798
5832
|
|
|
5799
5833
|
return null;
|
|
@@ -5811,7 +5845,7 @@ class WebRTCClient extends Emitter {
|
|
|
5811
5845
|
// Fetch and emit an event at `interval` with session network stats
|
|
5812
5846
|
startNetworkMonitoring(session , interval = 1000) {
|
|
5813
5847
|
const sessionId = this.getSipSessionId(session);
|
|
5814
|
-
logger.info('starting network inspection', { id: sessionId });
|
|
5848
|
+
logger$3.info('starting network inspection', { id: sessionId });
|
|
5815
5849
|
|
|
5816
5850
|
this.sessionNetworkStats[sessionId] = [];
|
|
5817
5851
|
|
|
@@ -5821,7 +5855,7 @@ class WebRTCClient extends Emitter {
|
|
|
5821
5855
|
stopNetworkMonitoring(session ) {
|
|
5822
5856
|
const sessionId = this.getSipSessionId(session);
|
|
5823
5857
|
const exists = sessionId in this.networkMonitoringInterval;
|
|
5824
|
-
logger.info('stopping network inspection', { id: sessionId, exists });
|
|
5858
|
+
logger$3.info('stopping network inspection', { id: sessionId, exists });
|
|
5825
5859
|
|
|
5826
5860
|
if (exists) {
|
|
5827
5861
|
clearInterval(this.networkMonitoringInterval[sessionId]);
|
|
@@ -5831,17 +5865,17 @@ class WebRTCClient extends Emitter {
|
|
|
5831
5865
|
}
|
|
5832
5866
|
|
|
5833
5867
|
reject(session ) {
|
|
5834
|
-
logger.info('sdk webrtc reject call', { id: session.id });
|
|
5868
|
+
logger$3.info('sdk webrtc reject call', { id: session.id });
|
|
5835
5869
|
|
|
5836
5870
|
try {
|
|
5837
5871
|
return session.reject ? session.reject() : session.cancel();
|
|
5838
5872
|
} catch (e) {
|
|
5839
|
-
logger.warn('Error when rejecting call', e.message, e.stack);
|
|
5873
|
+
logger$3.warn('Error when rejecting call', e.message, e.stack);
|
|
5840
5874
|
}
|
|
5841
5875
|
}
|
|
5842
5876
|
|
|
5843
5877
|
async close() {
|
|
5844
|
-
logger.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
5878
|
+
logger$3.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
5845
5879
|
this._cleanupMedia();
|
|
5846
5880
|
this.connectionPromise = null;
|
|
5847
5881
|
|
|
@@ -5872,7 +5906,7 @@ class WebRTCClient extends Emitter {
|
|
|
5872
5906
|
// eg: "INVITE not rejectable in state Completed"
|
|
5873
5907
|
}
|
|
5874
5908
|
this.userAgent = null;
|
|
5875
|
-
logger.info('sdk webrtc client closed');
|
|
5909
|
+
logger$3.info('sdk webrtc client closed');
|
|
5876
5910
|
}
|
|
5877
5911
|
|
|
5878
5912
|
getNumber(session ) {
|
|
@@ -5885,13 +5919,13 @@ class WebRTCClient extends Emitter {
|
|
|
5885
5919
|
}
|
|
5886
5920
|
|
|
5887
5921
|
mute(session ) {
|
|
5888
|
-
logger.info('sdk webrtc mute', { id: session.id });
|
|
5922
|
+
logger$3.info('sdk webrtc mute', { id: session.id });
|
|
5889
5923
|
|
|
5890
5924
|
this._toggleAudio(session, true);
|
|
5891
5925
|
}
|
|
5892
5926
|
|
|
5893
5927
|
unmute(session ) {
|
|
5894
|
-
logger.info('sdk webrtc unmute', { id: session.id });
|
|
5928
|
+
logger$3.info('sdk webrtc unmute', { id: session.id });
|
|
5895
5929
|
|
|
5896
5930
|
this._toggleAudio(session, false);
|
|
5897
5931
|
}
|
|
@@ -5931,13 +5965,13 @@ class WebRTCClient extends Emitter {
|
|
|
5931
5965
|
}
|
|
5932
5966
|
|
|
5933
5967
|
toggleCameraOn(session ) {
|
|
5934
|
-
logger.info('sdk webrtc toggle camera on', { id: session.id });
|
|
5968
|
+
logger$3.info('sdk webrtc toggle camera on', { id: session.id });
|
|
5935
5969
|
|
|
5936
5970
|
this._toggleVideo(session, false);
|
|
5937
5971
|
}
|
|
5938
5972
|
|
|
5939
5973
|
toggleCameraOff(session ) {
|
|
5940
|
-
logger.info('sdk webrtc toggle camera off', { id: session.id });
|
|
5974
|
+
logger$3.info('sdk webrtc toggle camera off', { id: session.id });
|
|
5941
5975
|
|
|
5942
5976
|
this._toggleVideo(session, true);
|
|
5943
5977
|
}
|
|
@@ -5946,7 +5980,7 @@ class WebRTCClient extends Emitter {
|
|
|
5946
5980
|
const sessionId = this.getSipSessionId(session);
|
|
5947
5981
|
const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
|
|
5948
5982
|
|
|
5949
|
-
logger.info('sdk webrtc hold', {
|
|
5983
|
+
logger$3.info('sdk webrtc hold', {
|
|
5950
5984
|
sessionId,
|
|
5951
5985
|
keys: Object.keys(this.heldSessions),
|
|
5952
5986
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -5995,7 +6029,7 @@ class WebRTCClient extends Emitter {
|
|
|
5995
6029
|
const sessionId = this.getSipSessionId(session);
|
|
5996
6030
|
const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
|
|
5997
6031
|
|
|
5998
|
-
logger.info('sdk webrtc unhold', {
|
|
6032
|
+
logger$3.info('sdk webrtc unhold', {
|
|
5999
6033
|
sessionId,
|
|
6000
6034
|
keys: Object.keys(this.heldSessions),
|
|
6001
6035
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -6143,7 +6177,7 @@ class WebRTCClient extends Emitter {
|
|
|
6143
6177
|
if (!session.sessionDescriptionHandler) {
|
|
6144
6178
|
return;
|
|
6145
6179
|
}
|
|
6146
|
-
logger.info('Sending DTMF', {
|
|
6180
|
+
logger$3.info('Sending DTMF', {
|
|
6147
6181
|
id: this.getSipSessionId(session),
|
|
6148
6182
|
tone,
|
|
6149
6183
|
});
|
|
@@ -6159,7 +6193,7 @@ class WebRTCClient extends Emitter {
|
|
|
6159
6193
|
transfer(session , target ) {
|
|
6160
6194
|
this.hold(session);
|
|
6161
6195
|
|
|
6162
|
-
logger.info('Transfering a session', {
|
|
6196
|
+
logger$3.info('Transfering a session', {
|
|
6163
6197
|
id: this.getSipSessionId(session),
|
|
6164
6198
|
target,
|
|
6165
6199
|
});
|
|
@@ -6181,17 +6215,17 @@ class WebRTCClient extends Emitter {
|
|
|
6181
6215
|
atxfer(session ) {
|
|
6182
6216
|
this.hold(session);
|
|
6183
6217
|
|
|
6184
|
-
logger.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
6218
|
+
logger$3.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
6185
6219
|
|
|
6186
6220
|
const result = {
|
|
6187
6221
|
newSession: null,
|
|
6188
6222
|
init: async (target ) => {
|
|
6189
|
-
logger.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
6223
|
+
logger$3.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
6190
6224
|
|
|
6191
6225
|
result.newSession = await this.call(target);
|
|
6192
6226
|
},
|
|
6193
6227
|
complete: () => {
|
|
6194
|
-
logger.info('webrtc transfer completed', {
|
|
6228
|
+
logger$3.info('webrtc transfer completed', {
|
|
6195
6229
|
id: this.getSipSessionId(session),
|
|
6196
6230
|
referId: this.getSipSessionId(result.newSession),
|
|
6197
6231
|
});
|
|
@@ -6212,7 +6246,7 @@ class WebRTCClient extends Emitter {
|
|
|
6212
6246
|
return;
|
|
6213
6247
|
}
|
|
6214
6248
|
|
|
6215
|
-
logger.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
6249
|
+
logger$3.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
6216
6250
|
|
|
6217
6251
|
try {
|
|
6218
6252
|
sipSession.message({
|
|
@@ -6254,7 +6288,7 @@ class WebRTCClient extends Emitter {
|
|
|
6254
6288
|
}
|
|
6255
6289
|
|
|
6256
6290
|
changeAudioOutputVolume(volume ) {
|
|
6257
|
-
logger.info('Changing audio output volume', { volume });
|
|
6291
|
+
logger$3.info('Changing audio output volume', { volume });
|
|
6258
6292
|
|
|
6259
6293
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
6260
6294
|
if (audioElement instanceof HTMLAudioElement) {
|
|
@@ -6266,7 +6300,7 @@ class WebRTCClient extends Emitter {
|
|
|
6266
6300
|
}
|
|
6267
6301
|
|
|
6268
6302
|
changeAudioOutputDevice(id ) {
|
|
6269
|
-
logger.info('Changing audio output device', { id });
|
|
6303
|
+
logger$3.info('Changing audio output device', { id });
|
|
6270
6304
|
|
|
6271
6305
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
6272
6306
|
// `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
|
|
@@ -6283,7 +6317,7 @@ class WebRTCClient extends Emitter {
|
|
|
6283
6317
|
|
|
6284
6318
|
changeAudioInputDevice(id , session ) {
|
|
6285
6319
|
const currentId = this.getAudioDeviceId();
|
|
6286
|
-
logger.info('setting audio input device', { id, currentId, session: !!session });
|
|
6320
|
+
logger$3.info('setting audio input device', { id, currentId, session: !!session });
|
|
6287
6321
|
|
|
6288
6322
|
if (id === currentId) {
|
|
6289
6323
|
return null;
|
|
@@ -6329,7 +6363,7 @@ class WebRTCClient extends Emitter {
|
|
|
6329
6363
|
|
|
6330
6364
|
setVideoInputDevice(id ) {
|
|
6331
6365
|
const currentId = this.getVideoDeviceId();
|
|
6332
|
-
logger.info('setting video input device', { id, currentId });
|
|
6366
|
+
logger$3.info('setting video input device', { id, currentId });
|
|
6333
6367
|
|
|
6334
6368
|
if (id === currentId) {
|
|
6335
6369
|
return null;
|
|
@@ -6354,7 +6388,7 @@ class WebRTCClient extends Emitter {
|
|
|
6354
6388
|
const sessionId = this.getSipSessionId(session);
|
|
6355
6389
|
const localStream = this.getLocalStream(sessionId);
|
|
6356
6390
|
|
|
6357
|
-
logger.info('changing video input device', { id, sessionId });
|
|
6391
|
+
logger$3.info('changing video input device', { id, sessionId });
|
|
6358
6392
|
|
|
6359
6393
|
// Release old video stream
|
|
6360
6394
|
if (localStream) {
|
|
@@ -6422,7 +6456,7 @@ class WebRTCClient extends Emitter {
|
|
|
6422
6456
|
const shouldDoScreenSharing = newConstraints && newConstraints.screen;
|
|
6423
6457
|
const desktop = newConstraints && newConstraints.desktop;
|
|
6424
6458
|
|
|
6425
|
-
logger.info('Sending reinvite', {
|
|
6459
|
+
logger$3.info('Sending reinvite', {
|
|
6426
6460
|
id: this.getSipSessionId(sipSession),
|
|
6427
6461
|
newConstraints,
|
|
6428
6462
|
conference,
|
|
@@ -6460,7 +6494,7 @@ class WebRTCClient extends Emitter {
|
|
|
6460
6494
|
sipSession.incomingInviteRequest.message.body = response.message.body;
|
|
6461
6495
|
}
|
|
6462
6496
|
|
|
6463
|
-
logger.info('on re-INVITE accepted', {
|
|
6497
|
+
logger$3.info('on re-INVITE accepted', {
|
|
6464
6498
|
id: this.getSipSessionId(sipSession),
|
|
6465
6499
|
wasMuted,
|
|
6466
6500
|
shouldDoScreenSharing,
|
|
@@ -6579,6 +6613,16 @@ class WebRTCClient extends Emitter {
|
|
|
6579
6613
|
return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
|
|
6580
6614
|
}
|
|
6581
6615
|
|
|
6616
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
6617
|
+
getRemoteVideoStreamFromPc(sessionId ) {
|
|
6618
|
+
const pc = this.getPeerConnection(sessionId);
|
|
6619
|
+
if (!pc) {
|
|
6620
|
+
return null;
|
|
6621
|
+
}
|
|
6622
|
+
|
|
6623
|
+
return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
|
|
6624
|
+
}
|
|
6625
|
+
|
|
6582
6626
|
hasVideo(sessionId ) {
|
|
6583
6627
|
return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
|
|
6584
6628
|
}
|
|
@@ -6625,7 +6669,7 @@ class WebRTCClient extends Emitter {
|
|
|
6625
6669
|
}
|
|
6626
6670
|
|
|
6627
6671
|
startHeartbeat() {
|
|
6628
|
-
logger.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
6672
|
+
logger$3.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
6629
6673
|
if (!this.userAgent) {
|
|
6630
6674
|
this.heartbeat.stop();
|
|
6631
6675
|
return;
|
|
@@ -6638,7 +6682,7 @@ class WebRTCClient extends Emitter {
|
|
|
6638
6682
|
}
|
|
6639
6683
|
|
|
6640
6684
|
stopHeartbeat() {
|
|
6641
|
-
logger.info('sdk webrtc stop heartbeat');
|
|
6685
|
+
logger$3.info('sdk webrtc stop heartbeat');
|
|
6642
6686
|
this.heartbeat.stop();
|
|
6643
6687
|
}
|
|
6644
6688
|
|
|
@@ -6659,7 +6703,7 @@ class WebRTCClient extends Emitter {
|
|
|
6659
6703
|
}
|
|
6660
6704
|
|
|
6661
6705
|
attemptReconnection() {
|
|
6662
|
-
logger.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
6706
|
+
logger$3.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
6663
6707
|
if (!this.userAgent) {
|
|
6664
6708
|
return;
|
|
6665
6709
|
}
|
|
@@ -6684,7 +6728,7 @@ class WebRTCClient extends Emitter {
|
|
|
6684
6728
|
return;
|
|
6685
6729
|
}
|
|
6686
6730
|
|
|
6687
|
-
logger.info('setting local media stream', {
|
|
6731
|
+
logger$3.info('setting local media stream', {
|
|
6688
6732
|
sipSessionId,
|
|
6689
6733
|
tracks: newStream ? newStream.getTracks() : null,
|
|
6690
6734
|
});
|
|
@@ -6701,7 +6745,7 @@ class WebRTCClient extends Emitter {
|
|
|
6701
6745
|
|
|
6702
6746
|
const oldStream = this.getLocalStream(sipSessionId);
|
|
6703
6747
|
|
|
6704
|
-
logger.info('updating local stream', {
|
|
6748
|
+
logger$3.info('updating local stream', {
|
|
6705
6749
|
sipSessionId,
|
|
6706
6750
|
oldStream: !!oldStream,
|
|
6707
6751
|
tracks: newStream.getTracks(),
|
|
@@ -6721,7 +6765,7 @@ class WebRTCClient extends Emitter {
|
|
|
6721
6765
|
const remoteStream = this.getRemoteStream(sessionId);
|
|
6722
6766
|
const pc = this.getPeerConnection(sessionId);
|
|
6723
6767
|
|
|
6724
|
-
logger.info('Updating remote stream', {
|
|
6768
|
+
logger$3.info('Updating remote stream', {
|
|
6725
6769
|
sessionId,
|
|
6726
6770
|
tracks: remoteStream ? remoteStream.getTracks() : null,
|
|
6727
6771
|
receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
|
|
@@ -6747,7 +6791,7 @@ class WebRTCClient extends Emitter {
|
|
|
6747
6791
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
6748
6792
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
6749
6793
|
|
|
6750
|
-
logger.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
6794
|
+
logger$3.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
6751
6795
|
|
|
6752
6796
|
return {
|
|
6753
6797
|
constraints: {
|
|
@@ -6796,7 +6840,7 @@ class WebRTCClient extends Emitter {
|
|
|
6796
6840
|
}
|
|
6797
6841
|
|
|
6798
6842
|
_onTransportError() {
|
|
6799
|
-
logger.error('on transport error');
|
|
6843
|
+
logger$3.error('on transport error');
|
|
6800
6844
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
6801
6845
|
this.attemptReconnection();
|
|
6802
6846
|
}
|
|
@@ -6805,7 +6849,7 @@ class WebRTCClient extends Emitter {
|
|
|
6805
6849
|
const body = message && typeof message === 'object' ? message.data : message;
|
|
6806
6850
|
if (body && body.indexOf('200 OK') !== -1) {
|
|
6807
6851
|
if (this.hasHeartbeat()) {
|
|
6808
|
-
logger.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
6852
|
+
logger$3.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
6809
6853
|
|
|
6810
6854
|
this.heartbeat.onHeartbeat();
|
|
6811
6855
|
if (this.heartbeatCb) {
|
|
@@ -6816,7 +6860,7 @@ class WebRTCClient extends Emitter {
|
|
|
6816
6860
|
}
|
|
6817
6861
|
|
|
6818
6862
|
async _onHeartbeatTimeout() {
|
|
6819
|
-
logger.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
6863
|
+
logger$3.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
6820
6864
|
|
|
6821
6865
|
if (this.heartbeatTimeoutCb) {
|
|
6822
6866
|
this.heartbeatTimeoutCb();
|
|
@@ -6828,7 +6872,7 @@ class WebRTCClient extends Emitter {
|
|
|
6828
6872
|
try {
|
|
6829
6873
|
await this.userAgent.transport.disconnect();
|
|
6830
6874
|
} catch (e) {
|
|
6831
|
-
logger.error('Transport disconnection after heartbeat timeout, error', e);
|
|
6875
|
+
logger$3.error('Transport disconnection after heartbeat timeout, error', e);
|
|
6832
6876
|
}
|
|
6833
6877
|
}
|
|
6834
6878
|
|
|
@@ -6861,31 +6905,31 @@ class WebRTCClient extends Emitter {
|
|
|
6861
6905
|
}
|
|
6862
6906
|
|
|
6863
6907
|
_connectIfNeeded() {
|
|
6864
|
-
logger.info('connect if needed, checking', { connected: this.isConnected() });
|
|
6908
|
+
logger$3.info('connect if needed, checking', { connected: this.isConnected() });
|
|
6865
6909
|
if (!this.userAgent) {
|
|
6866
|
-
logger.info('need to recreate User Agent');
|
|
6910
|
+
logger$3.info('need to recreate User Agent');
|
|
6867
6911
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6868
6912
|
}
|
|
6869
6913
|
|
|
6870
6914
|
if (this.isConnected()) {
|
|
6871
|
-
logger.info('webrtc sdk, already connected');
|
|
6915
|
+
logger$3.info('webrtc sdk, already connected');
|
|
6872
6916
|
return Promise.resolve();
|
|
6873
6917
|
}
|
|
6874
6918
|
|
|
6875
6919
|
if (this.isConnecting()) {
|
|
6876
|
-
logger.info('webrtc sdk, already connecting...');
|
|
6920
|
+
logger$3.info('webrtc sdk, already connecting...');
|
|
6877
6921
|
|
|
6878
6922
|
this.connectionPromise = this.userAgent.transport.connectPromise;
|
|
6879
6923
|
return this.connectionPromise;
|
|
6880
6924
|
}
|
|
6881
6925
|
|
|
6882
6926
|
if (this.connectionPromise) {
|
|
6883
|
-
logger.info('webrtc sdk, connection promise connecting...');
|
|
6927
|
+
logger$3.info('webrtc sdk, connection promise connecting...');
|
|
6884
6928
|
// $FlowFixMe
|
|
6885
6929
|
return this.connectionPromise;
|
|
6886
6930
|
}
|
|
6887
6931
|
|
|
6888
|
-
logger.info('WebRTC UA needs to connect');
|
|
6932
|
+
logger$3.info('WebRTC UA needs to connect');
|
|
6889
6933
|
|
|
6890
6934
|
// Force UA to reconnect
|
|
6891
6935
|
if (this.userAgent && this.userAgent.state !== userAgentState.UserAgentState.Stopped) {
|
|
@@ -7010,7 +7054,7 @@ class WebRTCClient extends Emitter {
|
|
|
7010
7054
|
|
|
7011
7055
|
sdh.peerConnectionDelegate = {
|
|
7012
7056
|
onicecandidateerror: (error ) => {
|
|
7013
|
-
logger.error('on icecandidate error', {
|
|
7057
|
+
logger$3.error('on icecandidate error', {
|
|
7014
7058
|
address: error.address,
|
|
7015
7059
|
port: error.port,
|
|
7016
7060
|
errorCode: error.errorCode,
|
|
@@ -7039,7 +7083,7 @@ class WebRTCClient extends Emitter {
|
|
|
7039
7083
|
updatedNumber = session.assertedIdentity.uri.normal.user;
|
|
7040
7084
|
updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
|
|
7041
7085
|
}
|
|
7042
|
-
logger.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
7086
|
+
logger$3.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
7043
7087
|
|
|
7044
7088
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
7045
7089
|
|
|
@@ -7060,7 +7104,7 @@ class WebRTCClient extends Emitter {
|
|
|
7060
7104
|
}
|
|
7061
7105
|
|
|
7062
7106
|
_onAccepted(session , sessionDialog , withEvent = true) {
|
|
7063
|
-
logger.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
7107
|
+
logger$3.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
7064
7108
|
|
|
7065
7109
|
this.storeSipSession(session);
|
|
7066
7110
|
|
|
@@ -7072,7 +7116,7 @@ class WebRTCClient extends Emitter {
|
|
|
7072
7116
|
const onTrack = (event ) => {
|
|
7073
7117
|
const isAudioOnly = this._isAudioOnly(session);
|
|
7074
7118
|
const { kind, label, readyState, id, muted } = event.track;
|
|
7075
|
-
logger.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
7119
|
+
logger$3.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
7076
7120
|
|
|
7077
7121
|
// Stop video track in audio only mode
|
|
7078
7122
|
if (isAudioOnly && kind === 'video') {
|
|
@@ -7089,6 +7133,7 @@ class WebRTCClient extends Emitter {
|
|
|
7089
7133
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
7090
7134
|
|
|
7091
7135
|
pc.oniceconnectionstatechange = () => {
|
|
7136
|
+
logger$3.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
7092
7137
|
if (pc.iceConnectionState === 'disconnected') {
|
|
7093
7138
|
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
7094
7139
|
}
|
|
@@ -7261,10 +7306,10 @@ class WebRTCClient extends Emitter {
|
|
|
7261
7306
|
|
|
7262
7307
|
_stopSendingStats(session ) {
|
|
7263
7308
|
const sessionId = this.getSipSessionId(session);
|
|
7264
|
-
logger.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
7309
|
+
logger$3.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
7265
7310
|
|
|
7266
7311
|
if (sessionId in this.statsIntervals) {
|
|
7267
|
-
logger.trace('Stop sending stats for call', { sessionId });
|
|
7312
|
+
logger$3.trace('Stop sending stats for call', { sessionId });
|
|
7268
7313
|
this.statsIntervals[sessionId]();
|
|
7269
7314
|
delete this.statsIntervals[sessionId];
|
|
7270
7315
|
}
|
|
@@ -7280,7 +7325,7 @@ class WebRTCClient extends Emitter {
|
|
|
7280
7325
|
try {
|
|
7281
7326
|
await this.userAgent.transport.disconnect();
|
|
7282
7327
|
} catch (e) {
|
|
7283
|
-
logger.error('WebRTC transport disconnect, error', e);
|
|
7328
|
+
logger$3.error('WebRTC transport disconnect, error', e);
|
|
7284
7329
|
}
|
|
7285
7330
|
}
|
|
7286
7331
|
}
|
|
@@ -7317,25 +7362,25 @@ class WebRTCClient extends Emitter {
|
|
|
7317
7362
|
|
|
7318
7363
|
stats.forEach(report => {
|
|
7319
7364
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
7320
|
-
audioBytesSent += report.bytesSent + report.headerBytesSent;
|
|
7365
|
+
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
7321
7366
|
}
|
|
7322
7367
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
7323
|
-
audioBytesSent += report.bytesSent;
|
|
7368
|
+
audioBytesSent += Number(report.bytesSent);
|
|
7324
7369
|
}
|
|
7325
7370
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
7326
|
-
videoBytesSent += report.bytesSent + report.headerBytesSent;
|
|
7371
|
+
videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
7327
7372
|
}
|
|
7328
7373
|
if (report.type === 'inbound-rtp' && report.kind === 'audio') {
|
|
7329
|
-
packetsLost += report.packetsLost;
|
|
7330
|
-
networkStats.packetsReceived = report.packetsReceived;
|
|
7331
|
-
audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
7374
|
+
packetsLost += Number(report.packetsLost);
|
|
7375
|
+
networkStats.packetsReceived = Number(report.packetsReceived);
|
|
7376
|
+
audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
7332
7377
|
}
|
|
7333
7378
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
7334
|
-
videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
7379
|
+
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
7335
7380
|
}
|
|
7336
7381
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
7337
7382
|
if ('framesPerSecond' in report) {
|
|
7338
|
-
networkStats.framesPerSecond = report.framesPerSecond;
|
|
7383
|
+
networkStats.framesPerSecond = Number(report.framesPerSecond);
|
|
7339
7384
|
}
|
|
7340
7385
|
if ('framerateMean' in report) {
|
|
7341
7386
|
// framerateMean is only available in FF
|
|
@@ -7343,32 +7388,36 @@ class WebRTCClient extends Emitter {
|
|
|
7343
7388
|
}
|
|
7344
7389
|
}
|
|
7345
7390
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
|
|
7346
|
-
packetsLost += report.packetsLost;
|
|
7347
|
-
networkStats.roundTripTime = report.roundTripTime;
|
|
7348
|
-
networkStats.jitter = report.jitter;
|
|
7391
|
+
packetsLost += Number(report.packetsLost);
|
|
7392
|
+
networkStats.roundTripTime = Number(report.roundTripTime);
|
|
7393
|
+
networkStats.jitter = Number(report.jitter);
|
|
7349
7394
|
}
|
|
7350
7395
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
|
|
7351
|
-
packetsLost += report.packetsLost;
|
|
7396
|
+
packetsLost += Number(report.packetsLost);
|
|
7352
7397
|
}
|
|
7353
7398
|
if (report.type === 'transport') {
|
|
7354
|
-
transportSent += report.bytesSent;
|
|
7355
|
-
transportReceived += report.bytesReceived;
|
|
7399
|
+
transportSent += Number(report.bytesSent);
|
|
7400
|
+
transportReceived += Number(report.bytesReceived);
|
|
7356
7401
|
}
|
|
7357
7402
|
});
|
|
7358
7403
|
|
|
7359
7404
|
networkStats.packetsLost = packetsLost;
|
|
7360
|
-
networkStats.
|
|
7405
|
+
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
7406
|
+
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
7407
|
+
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
7361
7408
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
7362
|
-
networkStats.
|
|
7363
|
-
networkStats.
|
|
7409
|
+
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
7410
|
+
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
7411
|
+
networkStats.totalVideoBytesReceived = videoBytesReceived;
|
|
7412
|
+
networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
|
|
7413
|
+
networkStats.totalTransportSent = transportSent - lastTransportSent;
|
|
7364
7414
|
networkStats.transportSent = transportSent;
|
|
7365
|
-
networkStats.
|
|
7366
|
-
|
|
7367
|
-
const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
|
|
7368
|
-
+ (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
|
|
7369
|
-
+ (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
|
|
7415
|
+
networkStats.totalTransportReceived = transportReceived;
|
|
7416
|
+
networkStats.transportReceived = transportReceived - lastTransportReceived;
|
|
7370
7417
|
|
|
7371
|
-
networkStats.bandwidth =
|
|
7418
|
+
networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
|
|
7419
|
+
+ networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
|
|
7420
|
+
+ networkStats.transportSent;
|
|
7372
7421
|
|
|
7373
7422
|
this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
|
|
7374
7423
|
this.sessionNetworkStats[sessionId].push(networkStats);
|