@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
package/esm/web-rtc-client.js
CHANGED
|
@@ -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
|
|
@@ -5452,13 +5484,13 @@ class WebRTCClient extends Emitter {
|
|
|
5452
5484
|
|
|
5453
5485
|
createUserAgent(configOverrides ) {
|
|
5454
5486
|
const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
|
|
5455
|
-
logger.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
5487
|
+
logger$3.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
5456
5488
|
|
|
5457
5489
|
webRTCConfiguration.delegate = {
|
|
5458
5490
|
onConnect: this.onConnect.bind(this),
|
|
5459
5491
|
onDisconnect: this.onDisconnect.bind(this),
|
|
5460
5492
|
onInvite: (invitation ) => {
|
|
5461
|
-
logger.info('sdk webrtc on invite', {
|
|
5493
|
+
logger$3.info('sdk webrtc on invite', {
|
|
5462
5494
|
method: 'delegate.onInvite',
|
|
5463
5495
|
id: invitation.id,
|
|
5464
5496
|
remoteURI: invitation.remoteURI,
|
|
@@ -5501,7 +5533,7 @@ class WebRTCClient extends Emitter {
|
|
|
5501
5533
|
}
|
|
5502
5534
|
|
|
5503
5535
|
onConnect() {
|
|
5504
|
-
logger.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
5536
|
+
logger$3.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
5505
5537
|
this.eventEmitter.emit(CONNECTED);
|
|
5506
5538
|
if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
|
|
5507
5539
|
this.registerer.waitingToggle(false);
|
|
@@ -5510,7 +5542,7 @@ class WebRTCClient extends Emitter {
|
|
|
5510
5542
|
}
|
|
5511
5543
|
|
|
5512
5544
|
async onDisconnect(error ) {
|
|
5513
|
-
logger.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
5545
|
+
logger$3.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
5514
5546
|
this.connectionPromise = null;
|
|
5515
5547
|
// The UA will attempt to reconnect automatically when an error occurred
|
|
5516
5548
|
this.eventEmitter.emit(DISCONNECTED, error);
|
|
@@ -5535,37 +5567,37 @@ class WebRTCClient extends Emitter {
|
|
|
5535
5567
|
};
|
|
5536
5568
|
|
|
5537
5569
|
if (this.skipRegister) {
|
|
5538
|
-
logger.info('sdk webrtc skip register...', logInfo);
|
|
5570
|
+
logger$3.info('sdk webrtc skip register...', logInfo);
|
|
5539
5571
|
return Promise.resolve();
|
|
5540
5572
|
}
|
|
5541
5573
|
|
|
5542
|
-
logger.info('sdk webrtc registering...', logInfo);
|
|
5574
|
+
logger$3.info('sdk webrtc registering...', logInfo);
|
|
5543
5575
|
|
|
5544
5576
|
if (!this.userAgent) {
|
|
5545
|
-
logger.info('sdk webrtc recreating User Agent');
|
|
5577
|
+
logger$3.info('sdk webrtc recreating User Agent');
|
|
5546
5578
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
5547
5579
|
}
|
|
5548
5580
|
if (!this.userAgent || this.isRegistered()) {
|
|
5549
|
-
logger.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
5581
|
+
logger$3.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
5550
5582
|
return Promise.resolve();
|
|
5551
5583
|
}
|
|
5552
5584
|
|
|
5553
5585
|
if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
|
|
5554
|
-
logger.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
5586
|
+
logger$3.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
5555
5587
|
return Promise.resolve();
|
|
5556
5588
|
}
|
|
5557
5589
|
|
|
5558
5590
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
5559
5591
|
|
|
5560
5592
|
const onRegisterFailed = () => {
|
|
5561
|
-
logger.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
5593
|
+
logger$3.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
5562
5594
|
this.connectionPromise = null;
|
|
5563
5595
|
if (this.registerer && this.registerer.waiting) {
|
|
5564
5596
|
this.registerer.waitingToggle(false);
|
|
5565
5597
|
}
|
|
5566
5598
|
|
|
5567
5599
|
if (tries <= MAX_REGISTER_TRIES) {
|
|
5568
|
-
logger.info('sdk webrtc registering, retrying...', { tries });
|
|
5600
|
+
logger$3.info('sdk webrtc registering, retrying...', { tries });
|
|
5569
5601
|
setTimeout(() => this.register(tries + 1), 300);
|
|
5570
5602
|
}
|
|
5571
5603
|
};
|
|
@@ -5574,18 +5606,18 @@ class WebRTCClient extends Emitter {
|
|
|
5574
5606
|
// Avoid race condition with the close method called just before register and setting userAgent to null
|
|
5575
5607
|
// during the resolution of the primise.
|
|
5576
5608
|
if (!this.userAgent) {
|
|
5577
|
-
logger.info('sdk webrtc recreating User Agent after connection');
|
|
5609
|
+
logger$3.info('sdk webrtc recreating User Agent after connection');
|
|
5578
5610
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
5579
5611
|
}
|
|
5580
5612
|
|
|
5581
|
-
logger.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
5613
|
+
logger$3.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
5582
5614
|
this.registerer = new Registerer(this.userAgent, registerOptions);
|
|
5583
5615
|
this.connectionPromise = null;
|
|
5584
5616
|
this._monkeyPatchRegisterer(this.registerer);
|
|
5585
5617
|
|
|
5586
5618
|
// Bind registerer events
|
|
5587
5619
|
this.registerer.stateChange.addListener(newState => {
|
|
5588
|
-
logger.info('sdk webrtc registering, state changed', { newState });
|
|
5620
|
+
logger$3.info('sdk webrtc registering, state changed', { newState });
|
|
5589
5621
|
|
|
5590
5622
|
if (newState === RegistererState.Registered && this.registerer
|
|
5591
5623
|
&& this.registerer.state === RegistererState.Registered) {
|
|
@@ -5598,7 +5630,7 @@ class WebRTCClient extends Emitter {
|
|
|
5598
5630
|
const options = {
|
|
5599
5631
|
requestDelegate: {
|
|
5600
5632
|
onReject: response => {
|
|
5601
|
-
logger.error('sdk webrtc registering, rejected', { response });
|
|
5633
|
+
logger$3.error('sdk webrtc registering, rejected', { response });
|
|
5602
5634
|
|
|
5603
5635
|
onRegisterFailed();
|
|
5604
5636
|
},
|
|
@@ -5606,13 +5638,13 @@ class WebRTCClient extends Emitter {
|
|
|
5606
5638
|
};
|
|
5607
5639
|
|
|
5608
5640
|
return this.registerer.register(options).catch((e) => {
|
|
5609
|
-
logger.error('sdk webrtc registering, error', e);
|
|
5641
|
+
logger$3.error('sdk webrtc registering, error', e);
|
|
5610
5642
|
|
|
5611
5643
|
this.eventEmitter.emit(REGISTRATION_FAILED);
|
|
5612
5644
|
return e;
|
|
5613
5645
|
});
|
|
5614
5646
|
}).catch(error => {
|
|
5615
|
-
logger.error('sdk webrtc registering, transport error', error);
|
|
5647
|
+
logger$3.error('sdk webrtc registering, transport error', error);
|
|
5616
5648
|
onRegisterFailed();
|
|
5617
5649
|
});
|
|
5618
5650
|
}
|
|
@@ -5641,21 +5673,21 @@ class WebRTCClient extends Emitter {
|
|
|
5641
5673
|
}
|
|
5642
5674
|
|
|
5643
5675
|
unregister() {
|
|
5644
|
-
logger.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
5676
|
+
logger$3.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
5645
5677
|
if (!this.registerer) {
|
|
5646
5678
|
return Promise.resolve();
|
|
5647
5679
|
}
|
|
5648
5680
|
|
|
5649
5681
|
try {
|
|
5650
5682
|
return this.registerer.unregister().then(() => {
|
|
5651
|
-
logger.info('sdk webrtc unregistered');
|
|
5683
|
+
logger$3.info('sdk webrtc unregistered');
|
|
5652
5684
|
this._cleanupRegister();
|
|
5653
5685
|
}).catch(e => {
|
|
5654
|
-
logger.error('sdk webrtc unregistering, promise error', e);
|
|
5686
|
+
logger$3.error('sdk webrtc unregistering, promise error', e);
|
|
5655
5687
|
this._cleanupRegister();
|
|
5656
5688
|
});
|
|
5657
5689
|
} catch (e) {
|
|
5658
|
-
logger.error('sdk webrtc unregistering, error', e);
|
|
5690
|
+
logger$3.error('sdk webrtc unregistering, error', e);
|
|
5659
5691
|
// Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
|
|
5660
5692
|
// error when the registerer is in a bad state
|
|
5661
5693
|
this._cleanupRegister();
|
|
@@ -5663,7 +5695,7 @@ class WebRTCClient extends Emitter {
|
|
|
5663
5695
|
}
|
|
5664
5696
|
|
|
5665
5697
|
stop() {
|
|
5666
|
-
logger.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
5698
|
+
logger$3.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
5667
5699
|
if (!this.userAgent) {
|
|
5668
5700
|
return Promise.resolve();
|
|
5669
5701
|
}
|
|
@@ -5671,12 +5703,12 @@ class WebRTCClient extends Emitter {
|
|
|
5671
5703
|
return this.userAgent.stop().then(() => {
|
|
5672
5704
|
return this._cleanupRegister();
|
|
5673
5705
|
}).catch(e => {
|
|
5674
|
-
logger.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
5706
|
+
logger$3.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
5675
5707
|
});
|
|
5676
5708
|
}
|
|
5677
5709
|
|
|
5678
5710
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
5679
|
-
logger.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
5711
|
+
logger$3.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
5680
5712
|
const inviterOptions = {
|
|
5681
5713
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
5682
5714
|
conference,
|
|
@@ -5701,11 +5733,13 @@ class WebRTCClient extends Emitter {
|
|
|
5701
5733
|
const inviteOptions = {
|
|
5702
5734
|
requestDelegate: {
|
|
5703
5735
|
onAccept: (response ) => {
|
|
5704
|
-
session.sessionDescriptionHandler.peerConnection
|
|
5736
|
+
if (session.sessionDescriptionHandler.peerConnection) {
|
|
5737
|
+
session.sessionDescriptionHandler.peerConnection.sfu = conference;
|
|
5738
|
+
}
|
|
5705
5739
|
this._onAccepted(session, response.session, true);
|
|
5706
5740
|
},
|
|
5707
5741
|
onReject: (response ) => {
|
|
5708
|
-
logger.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
5742
|
+
logger$3.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
5709
5743
|
this._stopSendingStats(session);
|
|
5710
5744
|
this.stopNetworkMonitoring(session);
|
|
5711
5745
|
|
|
@@ -5728,11 +5762,11 @@ class WebRTCClient extends Emitter {
|
|
|
5728
5762
|
}
|
|
5729
5763
|
|
|
5730
5764
|
answer(session , enableVideo ) {
|
|
5731
|
-
logger.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
5765
|
+
logger$3.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
5732
5766
|
|
|
5733
5767
|
if (!session || !session.accept) {
|
|
5734
5768
|
const error = 'No session to answer, or not an invitation';
|
|
5735
|
-
logger.warn(error);
|
|
5769
|
+
logger$3.warn(error);
|
|
5736
5770
|
return Promise.reject(new Error(error));
|
|
5737
5771
|
}
|
|
5738
5772
|
const options = {
|
|
@@ -5742,15 +5776,15 @@ class WebRTCClient extends Emitter {
|
|
|
5742
5776
|
return session.accept(options).then(() => {
|
|
5743
5777
|
if (session.isCanceled) {
|
|
5744
5778
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
5745
|
-
logger.error(message, { id: session.id });
|
|
5779
|
+
logger$3.error(message, { id: session.id });
|
|
5746
5780
|
this.onCallEnded(session);
|
|
5747
5781
|
|
|
5748
5782
|
throw new CanceledCallError(message);
|
|
5749
5783
|
}
|
|
5750
|
-
logger.info('sdk webrtc answer, accepted.');
|
|
5784
|
+
logger$3.info('sdk webrtc answer, accepted.');
|
|
5751
5785
|
this._onAccepted(session);
|
|
5752
5786
|
}).catch(e => {
|
|
5753
|
-
logger.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
5787
|
+
logger$3.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
5754
5788
|
|
|
5755
5789
|
throw e;
|
|
5756
5790
|
});
|
|
@@ -5758,7 +5792,7 @@ class WebRTCClient extends Emitter {
|
|
|
5758
5792
|
|
|
5759
5793
|
hangup(session ) {
|
|
5760
5794
|
const { state, id } = session;
|
|
5761
|
-
logger.info('sdk webrtc hangup call', { id, state });
|
|
5795
|
+
logger$3.info('sdk webrtc hangup call', { id, state });
|
|
5762
5796
|
|
|
5763
5797
|
try {
|
|
5764
5798
|
this._stopSendingStats(session);
|
|
@@ -5787,7 +5821,7 @@ class WebRTCClient extends Emitter {
|
|
|
5787
5821
|
|
|
5788
5822
|
return bye();
|
|
5789
5823
|
} catch (error) {
|
|
5790
|
-
logger.warn('sdk webrtc hangup, error', error);
|
|
5824
|
+
logger$3.warn('sdk webrtc hangup, error', error);
|
|
5791
5825
|
}
|
|
5792
5826
|
|
|
5793
5827
|
return null;
|
|
@@ -5805,7 +5839,7 @@ class WebRTCClient extends Emitter {
|
|
|
5805
5839
|
// Fetch and emit an event at `interval` with session network stats
|
|
5806
5840
|
startNetworkMonitoring(session , interval = 1000) {
|
|
5807
5841
|
const sessionId = this.getSipSessionId(session);
|
|
5808
|
-
logger.info('starting network inspection', { id: sessionId });
|
|
5842
|
+
logger$3.info('starting network inspection', { id: sessionId });
|
|
5809
5843
|
|
|
5810
5844
|
this.sessionNetworkStats[sessionId] = [];
|
|
5811
5845
|
|
|
@@ -5815,7 +5849,7 @@ class WebRTCClient extends Emitter {
|
|
|
5815
5849
|
stopNetworkMonitoring(session ) {
|
|
5816
5850
|
const sessionId = this.getSipSessionId(session);
|
|
5817
5851
|
const exists = sessionId in this.networkMonitoringInterval;
|
|
5818
|
-
logger.info('stopping network inspection', { id: sessionId, exists });
|
|
5852
|
+
logger$3.info('stopping network inspection', { id: sessionId, exists });
|
|
5819
5853
|
|
|
5820
5854
|
if (exists) {
|
|
5821
5855
|
clearInterval(this.networkMonitoringInterval[sessionId]);
|
|
@@ -5825,17 +5859,17 @@ class WebRTCClient extends Emitter {
|
|
|
5825
5859
|
}
|
|
5826
5860
|
|
|
5827
5861
|
reject(session ) {
|
|
5828
|
-
logger.info('sdk webrtc reject call', { id: session.id });
|
|
5862
|
+
logger$3.info('sdk webrtc reject call', { id: session.id });
|
|
5829
5863
|
|
|
5830
5864
|
try {
|
|
5831
5865
|
return session.reject ? session.reject() : session.cancel();
|
|
5832
5866
|
} catch (e) {
|
|
5833
|
-
logger.warn('Error when rejecting call', e.message, e.stack);
|
|
5867
|
+
logger$3.warn('Error when rejecting call', e.message, e.stack);
|
|
5834
5868
|
}
|
|
5835
5869
|
}
|
|
5836
5870
|
|
|
5837
5871
|
async close() {
|
|
5838
|
-
logger.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
5872
|
+
logger$3.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
5839
5873
|
this._cleanupMedia();
|
|
5840
5874
|
this.connectionPromise = null;
|
|
5841
5875
|
|
|
@@ -5866,7 +5900,7 @@ class WebRTCClient extends Emitter {
|
|
|
5866
5900
|
// eg: "INVITE not rejectable in state Completed"
|
|
5867
5901
|
}
|
|
5868
5902
|
this.userAgent = null;
|
|
5869
|
-
logger.info('sdk webrtc client closed');
|
|
5903
|
+
logger$3.info('sdk webrtc client closed');
|
|
5870
5904
|
}
|
|
5871
5905
|
|
|
5872
5906
|
getNumber(session ) {
|
|
@@ -5879,13 +5913,13 @@ class WebRTCClient extends Emitter {
|
|
|
5879
5913
|
}
|
|
5880
5914
|
|
|
5881
5915
|
mute(session ) {
|
|
5882
|
-
logger.info('sdk webrtc mute', { id: session.id });
|
|
5916
|
+
logger$3.info('sdk webrtc mute', { id: session.id });
|
|
5883
5917
|
|
|
5884
5918
|
this._toggleAudio(session, true);
|
|
5885
5919
|
}
|
|
5886
5920
|
|
|
5887
5921
|
unmute(session ) {
|
|
5888
|
-
logger.info('sdk webrtc unmute', { id: session.id });
|
|
5922
|
+
logger$3.info('sdk webrtc unmute', { id: session.id });
|
|
5889
5923
|
|
|
5890
5924
|
this._toggleAudio(session, false);
|
|
5891
5925
|
}
|
|
@@ -5925,13 +5959,13 @@ class WebRTCClient extends Emitter {
|
|
|
5925
5959
|
}
|
|
5926
5960
|
|
|
5927
5961
|
toggleCameraOn(session ) {
|
|
5928
|
-
logger.info('sdk webrtc toggle camera on', { id: session.id });
|
|
5962
|
+
logger$3.info('sdk webrtc toggle camera on', { id: session.id });
|
|
5929
5963
|
|
|
5930
5964
|
this._toggleVideo(session, false);
|
|
5931
5965
|
}
|
|
5932
5966
|
|
|
5933
5967
|
toggleCameraOff(session ) {
|
|
5934
|
-
logger.info('sdk webrtc toggle camera off', { id: session.id });
|
|
5968
|
+
logger$3.info('sdk webrtc toggle camera off', { id: session.id });
|
|
5935
5969
|
|
|
5936
5970
|
this._toggleVideo(session, true);
|
|
5937
5971
|
}
|
|
@@ -5940,7 +5974,7 @@ class WebRTCClient extends Emitter {
|
|
|
5940
5974
|
const sessionId = this.getSipSessionId(session);
|
|
5941
5975
|
const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
|
|
5942
5976
|
|
|
5943
|
-
logger.info('sdk webrtc hold', {
|
|
5977
|
+
logger$3.info('sdk webrtc hold', {
|
|
5944
5978
|
sessionId,
|
|
5945
5979
|
keys: Object.keys(this.heldSessions),
|
|
5946
5980
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -5989,7 +6023,7 @@ class WebRTCClient extends Emitter {
|
|
|
5989
6023
|
const sessionId = this.getSipSessionId(session);
|
|
5990
6024
|
const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
|
|
5991
6025
|
|
|
5992
|
-
logger.info('sdk webrtc unhold', {
|
|
6026
|
+
logger$3.info('sdk webrtc unhold', {
|
|
5993
6027
|
sessionId,
|
|
5994
6028
|
keys: Object.keys(this.heldSessions),
|
|
5995
6029
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -6137,7 +6171,7 @@ class WebRTCClient extends Emitter {
|
|
|
6137
6171
|
if (!session.sessionDescriptionHandler) {
|
|
6138
6172
|
return;
|
|
6139
6173
|
}
|
|
6140
|
-
logger.info('Sending DTMF', {
|
|
6174
|
+
logger$3.info('Sending DTMF', {
|
|
6141
6175
|
id: this.getSipSessionId(session),
|
|
6142
6176
|
tone,
|
|
6143
6177
|
});
|
|
@@ -6153,7 +6187,7 @@ class WebRTCClient extends Emitter {
|
|
|
6153
6187
|
transfer(session , target ) {
|
|
6154
6188
|
this.hold(session);
|
|
6155
6189
|
|
|
6156
|
-
logger.info('Transfering a session', {
|
|
6190
|
+
logger$3.info('Transfering a session', {
|
|
6157
6191
|
id: this.getSipSessionId(session),
|
|
6158
6192
|
target,
|
|
6159
6193
|
});
|
|
@@ -6175,17 +6209,17 @@ class WebRTCClient extends Emitter {
|
|
|
6175
6209
|
atxfer(session ) {
|
|
6176
6210
|
this.hold(session);
|
|
6177
6211
|
|
|
6178
|
-
logger.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
6212
|
+
logger$3.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
6179
6213
|
|
|
6180
6214
|
const result = {
|
|
6181
6215
|
newSession: null,
|
|
6182
6216
|
init: async (target ) => {
|
|
6183
|
-
logger.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
6217
|
+
logger$3.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
6184
6218
|
|
|
6185
6219
|
result.newSession = await this.call(target);
|
|
6186
6220
|
},
|
|
6187
6221
|
complete: () => {
|
|
6188
|
-
logger.info('webrtc transfer completed', {
|
|
6222
|
+
logger$3.info('webrtc transfer completed', {
|
|
6189
6223
|
id: this.getSipSessionId(session),
|
|
6190
6224
|
referId: this.getSipSessionId(result.newSession),
|
|
6191
6225
|
});
|
|
@@ -6206,7 +6240,7 @@ class WebRTCClient extends Emitter {
|
|
|
6206
6240
|
return;
|
|
6207
6241
|
}
|
|
6208
6242
|
|
|
6209
|
-
logger.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
6243
|
+
logger$3.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
6210
6244
|
|
|
6211
6245
|
try {
|
|
6212
6246
|
sipSession.message({
|
|
@@ -6248,7 +6282,7 @@ class WebRTCClient extends Emitter {
|
|
|
6248
6282
|
}
|
|
6249
6283
|
|
|
6250
6284
|
changeAudioOutputVolume(volume ) {
|
|
6251
|
-
logger.info('Changing audio output volume', { volume });
|
|
6285
|
+
logger$3.info('Changing audio output volume', { volume });
|
|
6252
6286
|
|
|
6253
6287
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
6254
6288
|
if (audioElement instanceof HTMLAudioElement) {
|
|
@@ -6260,7 +6294,7 @@ class WebRTCClient extends Emitter {
|
|
|
6260
6294
|
}
|
|
6261
6295
|
|
|
6262
6296
|
changeAudioOutputDevice(id ) {
|
|
6263
|
-
logger.info('Changing audio output device', { id });
|
|
6297
|
+
logger$3.info('Changing audio output device', { id });
|
|
6264
6298
|
|
|
6265
6299
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
6266
6300
|
// `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
|
|
@@ -6277,7 +6311,7 @@ class WebRTCClient extends Emitter {
|
|
|
6277
6311
|
|
|
6278
6312
|
changeAudioInputDevice(id , session ) {
|
|
6279
6313
|
const currentId = this.getAudioDeviceId();
|
|
6280
|
-
logger.info('setting audio input device', { id, currentId, session: !!session });
|
|
6314
|
+
logger$3.info('setting audio input device', { id, currentId, session: !!session });
|
|
6281
6315
|
|
|
6282
6316
|
if (id === currentId) {
|
|
6283
6317
|
return null;
|
|
@@ -6323,7 +6357,7 @@ class WebRTCClient extends Emitter {
|
|
|
6323
6357
|
|
|
6324
6358
|
setVideoInputDevice(id ) {
|
|
6325
6359
|
const currentId = this.getVideoDeviceId();
|
|
6326
|
-
logger.info('setting video input device', { id, currentId });
|
|
6360
|
+
logger$3.info('setting video input device', { id, currentId });
|
|
6327
6361
|
|
|
6328
6362
|
if (id === currentId) {
|
|
6329
6363
|
return null;
|
|
@@ -6348,7 +6382,7 @@ class WebRTCClient extends Emitter {
|
|
|
6348
6382
|
const sessionId = this.getSipSessionId(session);
|
|
6349
6383
|
const localStream = this.getLocalStream(sessionId);
|
|
6350
6384
|
|
|
6351
|
-
logger.info('changing video input device', { id, sessionId });
|
|
6385
|
+
logger$3.info('changing video input device', { id, sessionId });
|
|
6352
6386
|
|
|
6353
6387
|
// Release old video stream
|
|
6354
6388
|
if (localStream) {
|
|
@@ -6416,7 +6450,7 @@ class WebRTCClient extends Emitter {
|
|
|
6416
6450
|
const shouldDoScreenSharing = newConstraints && newConstraints.screen;
|
|
6417
6451
|
const desktop = newConstraints && newConstraints.desktop;
|
|
6418
6452
|
|
|
6419
|
-
logger.info('Sending reinvite', {
|
|
6453
|
+
logger$3.info('Sending reinvite', {
|
|
6420
6454
|
id: this.getSipSessionId(sipSession),
|
|
6421
6455
|
newConstraints,
|
|
6422
6456
|
conference,
|
|
@@ -6454,7 +6488,7 @@ class WebRTCClient extends Emitter {
|
|
|
6454
6488
|
sipSession.incomingInviteRequest.message.body = response.message.body;
|
|
6455
6489
|
}
|
|
6456
6490
|
|
|
6457
|
-
logger.info('on re-INVITE accepted', {
|
|
6491
|
+
logger$3.info('on re-INVITE accepted', {
|
|
6458
6492
|
id: this.getSipSessionId(sipSession),
|
|
6459
6493
|
wasMuted,
|
|
6460
6494
|
shouldDoScreenSharing,
|
|
@@ -6573,6 +6607,16 @@ class WebRTCClient extends Emitter {
|
|
|
6573
6607
|
return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
|
|
6574
6608
|
}
|
|
6575
6609
|
|
|
6610
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
6611
|
+
getRemoteVideoStreamFromPc(sessionId ) {
|
|
6612
|
+
const pc = this.getPeerConnection(sessionId);
|
|
6613
|
+
if (!pc) {
|
|
6614
|
+
return null;
|
|
6615
|
+
}
|
|
6616
|
+
|
|
6617
|
+
return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
|
|
6618
|
+
}
|
|
6619
|
+
|
|
6576
6620
|
hasVideo(sessionId ) {
|
|
6577
6621
|
return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
|
|
6578
6622
|
}
|
|
@@ -6619,7 +6663,7 @@ class WebRTCClient extends Emitter {
|
|
|
6619
6663
|
}
|
|
6620
6664
|
|
|
6621
6665
|
startHeartbeat() {
|
|
6622
|
-
logger.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
6666
|
+
logger$3.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
6623
6667
|
if (!this.userAgent) {
|
|
6624
6668
|
this.heartbeat.stop();
|
|
6625
6669
|
return;
|
|
@@ -6632,7 +6676,7 @@ class WebRTCClient extends Emitter {
|
|
|
6632
6676
|
}
|
|
6633
6677
|
|
|
6634
6678
|
stopHeartbeat() {
|
|
6635
|
-
logger.info('sdk webrtc stop heartbeat');
|
|
6679
|
+
logger$3.info('sdk webrtc stop heartbeat');
|
|
6636
6680
|
this.heartbeat.stop();
|
|
6637
6681
|
}
|
|
6638
6682
|
|
|
@@ -6653,7 +6697,7 @@ class WebRTCClient extends Emitter {
|
|
|
6653
6697
|
}
|
|
6654
6698
|
|
|
6655
6699
|
attemptReconnection() {
|
|
6656
|
-
logger.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
6700
|
+
logger$3.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
6657
6701
|
if (!this.userAgent) {
|
|
6658
6702
|
return;
|
|
6659
6703
|
}
|
|
@@ -6678,7 +6722,7 @@ class WebRTCClient extends Emitter {
|
|
|
6678
6722
|
return;
|
|
6679
6723
|
}
|
|
6680
6724
|
|
|
6681
|
-
logger.info('setting local media stream', {
|
|
6725
|
+
logger$3.info('setting local media stream', {
|
|
6682
6726
|
sipSessionId,
|
|
6683
6727
|
tracks: newStream ? newStream.getTracks() : null,
|
|
6684
6728
|
});
|
|
@@ -6695,7 +6739,7 @@ class WebRTCClient extends Emitter {
|
|
|
6695
6739
|
|
|
6696
6740
|
const oldStream = this.getLocalStream(sipSessionId);
|
|
6697
6741
|
|
|
6698
|
-
logger.info('updating local stream', {
|
|
6742
|
+
logger$3.info('updating local stream', {
|
|
6699
6743
|
sipSessionId,
|
|
6700
6744
|
oldStream: !!oldStream,
|
|
6701
6745
|
tracks: newStream.getTracks(),
|
|
@@ -6715,7 +6759,7 @@ class WebRTCClient extends Emitter {
|
|
|
6715
6759
|
const remoteStream = this.getRemoteStream(sessionId);
|
|
6716
6760
|
const pc = this.getPeerConnection(sessionId);
|
|
6717
6761
|
|
|
6718
|
-
logger.info('Updating remote stream', {
|
|
6762
|
+
logger$3.info('Updating remote stream', {
|
|
6719
6763
|
sessionId,
|
|
6720
6764
|
tracks: remoteStream ? remoteStream.getTracks() : null,
|
|
6721
6765
|
receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
|
|
@@ -6741,7 +6785,7 @@ class WebRTCClient extends Emitter {
|
|
|
6741
6785
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
6742
6786
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
6743
6787
|
|
|
6744
|
-
logger.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
6788
|
+
logger$3.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
6745
6789
|
|
|
6746
6790
|
return {
|
|
6747
6791
|
constraints: {
|
|
@@ -6790,7 +6834,7 @@ class WebRTCClient extends Emitter {
|
|
|
6790
6834
|
}
|
|
6791
6835
|
|
|
6792
6836
|
_onTransportError() {
|
|
6793
|
-
logger.error('on transport error');
|
|
6837
|
+
logger$3.error('on transport error');
|
|
6794
6838
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
6795
6839
|
this.attemptReconnection();
|
|
6796
6840
|
}
|
|
@@ -6799,7 +6843,7 @@ class WebRTCClient extends Emitter {
|
|
|
6799
6843
|
const body = message && typeof message === 'object' ? message.data : message;
|
|
6800
6844
|
if (body && body.indexOf('200 OK') !== -1) {
|
|
6801
6845
|
if (this.hasHeartbeat()) {
|
|
6802
|
-
logger.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
6846
|
+
logger$3.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
6803
6847
|
|
|
6804
6848
|
this.heartbeat.onHeartbeat();
|
|
6805
6849
|
if (this.heartbeatCb) {
|
|
@@ -6810,7 +6854,7 @@ class WebRTCClient extends Emitter {
|
|
|
6810
6854
|
}
|
|
6811
6855
|
|
|
6812
6856
|
async _onHeartbeatTimeout() {
|
|
6813
|
-
logger.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
6857
|
+
logger$3.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
6814
6858
|
|
|
6815
6859
|
if (this.heartbeatTimeoutCb) {
|
|
6816
6860
|
this.heartbeatTimeoutCb();
|
|
@@ -6822,7 +6866,7 @@ class WebRTCClient extends Emitter {
|
|
|
6822
6866
|
try {
|
|
6823
6867
|
await this.userAgent.transport.disconnect();
|
|
6824
6868
|
} catch (e) {
|
|
6825
|
-
logger.error('Transport disconnection after heartbeat timeout, error', e);
|
|
6869
|
+
logger$3.error('Transport disconnection after heartbeat timeout, error', e);
|
|
6826
6870
|
}
|
|
6827
6871
|
}
|
|
6828
6872
|
|
|
@@ -6855,31 +6899,31 @@ class WebRTCClient extends Emitter {
|
|
|
6855
6899
|
}
|
|
6856
6900
|
|
|
6857
6901
|
_connectIfNeeded() {
|
|
6858
|
-
logger.info('connect if needed, checking', { connected: this.isConnected() });
|
|
6902
|
+
logger$3.info('connect if needed, checking', { connected: this.isConnected() });
|
|
6859
6903
|
if (!this.userAgent) {
|
|
6860
|
-
logger.info('need to recreate User Agent');
|
|
6904
|
+
logger$3.info('need to recreate User Agent');
|
|
6861
6905
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6862
6906
|
}
|
|
6863
6907
|
|
|
6864
6908
|
if (this.isConnected()) {
|
|
6865
|
-
logger.info('webrtc sdk, already connected');
|
|
6909
|
+
logger$3.info('webrtc sdk, already connected');
|
|
6866
6910
|
return Promise.resolve();
|
|
6867
6911
|
}
|
|
6868
6912
|
|
|
6869
6913
|
if (this.isConnecting()) {
|
|
6870
|
-
logger.info('webrtc sdk, already connecting...');
|
|
6914
|
+
logger$3.info('webrtc sdk, already connecting...');
|
|
6871
6915
|
|
|
6872
6916
|
this.connectionPromise = this.userAgent.transport.connectPromise;
|
|
6873
6917
|
return this.connectionPromise;
|
|
6874
6918
|
}
|
|
6875
6919
|
|
|
6876
6920
|
if (this.connectionPromise) {
|
|
6877
|
-
logger.info('webrtc sdk, connection promise connecting...');
|
|
6921
|
+
logger$3.info('webrtc sdk, connection promise connecting...');
|
|
6878
6922
|
// $FlowFixMe
|
|
6879
6923
|
return this.connectionPromise;
|
|
6880
6924
|
}
|
|
6881
6925
|
|
|
6882
|
-
logger.info('WebRTC UA needs to connect');
|
|
6926
|
+
logger$3.info('WebRTC UA needs to connect');
|
|
6883
6927
|
|
|
6884
6928
|
// Force UA to reconnect
|
|
6885
6929
|
if (this.userAgent && this.userAgent.state !== UserAgentState.Stopped) {
|
|
@@ -7004,7 +7048,7 @@ class WebRTCClient extends Emitter {
|
|
|
7004
7048
|
|
|
7005
7049
|
sdh.peerConnectionDelegate = {
|
|
7006
7050
|
onicecandidateerror: (error ) => {
|
|
7007
|
-
logger.error('on icecandidate error', {
|
|
7051
|
+
logger$3.error('on icecandidate error', {
|
|
7008
7052
|
address: error.address,
|
|
7009
7053
|
port: error.port,
|
|
7010
7054
|
errorCode: error.errorCode,
|
|
@@ -7033,7 +7077,7 @@ class WebRTCClient extends Emitter {
|
|
|
7033
7077
|
updatedNumber = session.assertedIdentity.uri.normal.user;
|
|
7034
7078
|
updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
|
|
7035
7079
|
}
|
|
7036
|
-
logger.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
7080
|
+
logger$3.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
7037
7081
|
|
|
7038
7082
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
7039
7083
|
|
|
@@ -7054,7 +7098,7 @@ class WebRTCClient extends Emitter {
|
|
|
7054
7098
|
}
|
|
7055
7099
|
|
|
7056
7100
|
_onAccepted(session , sessionDialog , withEvent = true) {
|
|
7057
|
-
logger.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
7101
|
+
logger$3.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
7058
7102
|
|
|
7059
7103
|
this.storeSipSession(session);
|
|
7060
7104
|
|
|
@@ -7066,7 +7110,7 @@ class WebRTCClient extends Emitter {
|
|
|
7066
7110
|
const onTrack = (event ) => {
|
|
7067
7111
|
const isAudioOnly = this._isAudioOnly(session);
|
|
7068
7112
|
const { kind, label, readyState, id, muted } = event.track;
|
|
7069
|
-
logger.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
7113
|
+
logger$3.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
7070
7114
|
|
|
7071
7115
|
// Stop video track in audio only mode
|
|
7072
7116
|
if (isAudioOnly && kind === 'video') {
|
|
@@ -7083,6 +7127,7 @@ class WebRTCClient extends Emitter {
|
|
|
7083
7127
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
7084
7128
|
|
|
7085
7129
|
pc.oniceconnectionstatechange = () => {
|
|
7130
|
+
logger$3.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
7086
7131
|
if (pc.iceConnectionState === 'disconnected') {
|
|
7087
7132
|
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
7088
7133
|
}
|
|
@@ -7255,10 +7300,10 @@ class WebRTCClient extends Emitter {
|
|
|
7255
7300
|
|
|
7256
7301
|
_stopSendingStats(session ) {
|
|
7257
7302
|
const sessionId = this.getSipSessionId(session);
|
|
7258
|
-
logger.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
7303
|
+
logger$3.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
7259
7304
|
|
|
7260
7305
|
if (sessionId in this.statsIntervals) {
|
|
7261
|
-
logger.trace('Stop sending stats for call', { sessionId });
|
|
7306
|
+
logger$3.trace('Stop sending stats for call', { sessionId });
|
|
7262
7307
|
this.statsIntervals[sessionId]();
|
|
7263
7308
|
delete this.statsIntervals[sessionId];
|
|
7264
7309
|
}
|
|
@@ -7274,7 +7319,7 @@ class WebRTCClient extends Emitter {
|
|
|
7274
7319
|
try {
|
|
7275
7320
|
await this.userAgent.transport.disconnect();
|
|
7276
7321
|
} catch (e) {
|
|
7277
|
-
logger.error('WebRTC transport disconnect, error', e);
|
|
7322
|
+
logger$3.error('WebRTC transport disconnect, error', e);
|
|
7278
7323
|
}
|
|
7279
7324
|
}
|
|
7280
7325
|
}
|
|
@@ -7311,25 +7356,25 @@ class WebRTCClient extends Emitter {
|
|
|
7311
7356
|
|
|
7312
7357
|
stats.forEach(report => {
|
|
7313
7358
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
7314
|
-
audioBytesSent += report.bytesSent + report.headerBytesSent;
|
|
7359
|
+
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
7315
7360
|
}
|
|
7316
7361
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
7317
|
-
audioBytesSent += report.bytesSent;
|
|
7362
|
+
audioBytesSent += Number(report.bytesSent);
|
|
7318
7363
|
}
|
|
7319
7364
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
7320
|
-
videoBytesSent += report.bytesSent + report.headerBytesSent;
|
|
7365
|
+
videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
7321
7366
|
}
|
|
7322
7367
|
if (report.type === 'inbound-rtp' && report.kind === 'audio') {
|
|
7323
|
-
packetsLost += report.packetsLost;
|
|
7324
|
-
networkStats.packetsReceived = report.packetsReceived;
|
|
7325
|
-
audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
7368
|
+
packetsLost += Number(report.packetsLost);
|
|
7369
|
+
networkStats.packetsReceived = Number(report.packetsReceived);
|
|
7370
|
+
audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
7326
7371
|
}
|
|
7327
7372
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
7328
|
-
videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
7373
|
+
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
7329
7374
|
}
|
|
7330
7375
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
7331
7376
|
if ('framesPerSecond' in report) {
|
|
7332
|
-
networkStats.framesPerSecond = report.framesPerSecond;
|
|
7377
|
+
networkStats.framesPerSecond = Number(report.framesPerSecond);
|
|
7333
7378
|
}
|
|
7334
7379
|
if ('framerateMean' in report) {
|
|
7335
7380
|
// framerateMean is only available in FF
|
|
@@ -7337,32 +7382,36 @@ class WebRTCClient extends Emitter {
|
|
|
7337
7382
|
}
|
|
7338
7383
|
}
|
|
7339
7384
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
|
|
7340
|
-
packetsLost += report.packetsLost;
|
|
7341
|
-
networkStats.roundTripTime = report.roundTripTime;
|
|
7342
|
-
networkStats.jitter = report.jitter;
|
|
7385
|
+
packetsLost += Number(report.packetsLost);
|
|
7386
|
+
networkStats.roundTripTime = Number(report.roundTripTime);
|
|
7387
|
+
networkStats.jitter = Number(report.jitter);
|
|
7343
7388
|
}
|
|
7344
7389
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
|
|
7345
|
-
packetsLost += report.packetsLost;
|
|
7390
|
+
packetsLost += Number(report.packetsLost);
|
|
7346
7391
|
}
|
|
7347
7392
|
if (report.type === 'transport') {
|
|
7348
|
-
transportSent += report.bytesSent;
|
|
7349
|
-
transportReceived += report.bytesReceived;
|
|
7393
|
+
transportSent += Number(report.bytesSent);
|
|
7394
|
+
transportReceived += Number(report.bytesReceived);
|
|
7350
7395
|
}
|
|
7351
7396
|
});
|
|
7352
7397
|
|
|
7353
7398
|
networkStats.packetsLost = packetsLost;
|
|
7354
|
-
networkStats.
|
|
7399
|
+
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
7400
|
+
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
7401
|
+
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
7355
7402
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
7356
|
-
networkStats.
|
|
7357
|
-
networkStats.
|
|
7403
|
+
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
7404
|
+
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
7405
|
+
networkStats.totalVideoBytesReceived = videoBytesReceived;
|
|
7406
|
+
networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
|
|
7407
|
+
networkStats.totalTransportSent = transportSent - lastTransportSent;
|
|
7358
7408
|
networkStats.transportSent = transportSent;
|
|
7359
|
-
networkStats.
|
|
7360
|
-
|
|
7361
|
-
const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
|
|
7362
|
-
+ (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
|
|
7363
|
-
+ (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
|
|
7409
|
+
networkStats.totalTransportReceived = transportReceived;
|
|
7410
|
+
networkStats.transportReceived = transportReceived - lastTransportReceived;
|
|
7364
7411
|
|
|
7365
|
-
networkStats.bandwidth =
|
|
7412
|
+
networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
|
|
7413
|
+
+ networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
|
|
7414
|
+
+ networkStats.transportSent;
|
|
7366
7415
|
|
|
7367
7416
|
this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
|
|
7368
7417
|
this.sessionNetworkStats[sessionId].push(networkStats);
|