@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/lib/web-rtc-client.js
CHANGED
|
@@ -111,7 +111,7 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
|
|
|
111
111
|
|
|
112
112
|
const methods = ['head', 'get', 'post', 'put', 'delete'];
|
|
113
113
|
|
|
114
|
-
const logger
|
|
114
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
115
115
|
|
|
116
116
|
// Use a function here to be able to mock it in tests
|
|
117
117
|
const realFetch = () => {
|
|
@@ -250,7 +250,7 @@ class ApiRequester {
|
|
|
250
250
|
};
|
|
251
251
|
|
|
252
252
|
if (this.refreshTokenPromise) {
|
|
253
|
-
logger
|
|
253
|
+
logger.info('A token is already refreshing, waiting ...', { url });
|
|
254
254
|
await this.refreshTokenPromise;
|
|
255
255
|
}
|
|
256
256
|
|
|
@@ -270,7 +270,7 @@ class ApiRequester {
|
|
|
270
270
|
return promise.then(async (err ) => {
|
|
271
271
|
// Check if the token is still valid
|
|
272
272
|
if (firstCall && this._checkTokenExpired(response, err)) {
|
|
273
|
-
logger
|
|
273
|
+
logger.warn('token expired', { error: err.reason });
|
|
274
274
|
// Replay the call after refreshing the token
|
|
275
275
|
return this._replayWithNewToken(err, path, method, body, headers, parse);
|
|
276
276
|
}
|
|
@@ -280,7 +280,7 @@ class ApiRequester {
|
|
|
280
280
|
: exceptionClass.fromResponse(err, response.status);
|
|
281
281
|
|
|
282
282
|
if (this.shouldLogErrors) {
|
|
283
|
-
logger
|
|
283
|
+
logger.error('API error', error);
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
throw error;
|
|
@@ -290,7 +290,7 @@ class ApiRequester {
|
|
|
290
290
|
return newParse(response, isJson);
|
|
291
291
|
}).catch(error => {
|
|
292
292
|
if (this.shouldLogErrors) {
|
|
293
|
-
logger
|
|
293
|
+
logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
throw error;
|
|
@@ -318,13 +318,13 @@ class ApiRequester {
|
|
|
318
318
|
) {
|
|
319
319
|
const isTokenNotFound = this._isTokenNotFound(err);
|
|
320
320
|
let newPath = path;
|
|
321
|
-
logger
|
|
321
|
+
logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
|
|
322
322
|
|
|
323
323
|
this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
|
|
324
324
|
|
|
325
325
|
return this.refreshTokenPromise.then(() => {
|
|
326
326
|
this.refreshTokenPromise = null;
|
|
327
|
-
logger
|
|
327
|
+
logger.info('token refreshed', { isTokenNotFound });
|
|
328
328
|
if (isTokenNotFound) {
|
|
329
329
|
const pathParts = path.split('/');
|
|
330
330
|
pathParts.pop();
|
|
@@ -423,6 +423,7 @@ class IssueReporter {
|
|
|
423
423
|
|
|
424
424
|
|
|
425
425
|
|
|
426
|
+
|
|
426
427
|
|
|
427
428
|
constructor() {
|
|
428
429
|
addLevelsTo(this);
|
|
@@ -434,12 +435,17 @@ class IssueReporter {
|
|
|
434
435
|
this.bufferTimeout = null;
|
|
435
436
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
436
437
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
438
|
+
this._callback = null;
|
|
437
439
|
}
|
|
438
440
|
|
|
439
441
|
init() {
|
|
440
442
|
this._catchConsole();
|
|
441
443
|
}
|
|
442
444
|
|
|
445
|
+
setCallback(cb ) {
|
|
446
|
+
this._callback = cb;
|
|
447
|
+
}
|
|
448
|
+
|
|
443
449
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
444
450
|
this.remoteClientConfiguration = configuration;
|
|
445
451
|
}
|
|
@@ -475,6 +481,7 @@ class IssueReporter {
|
|
|
475
481
|
|
|
476
482
|
// Handle category label
|
|
477
483
|
let category = null;
|
|
484
|
+
let skipSendToRemote = false;
|
|
478
485
|
let extra = {};
|
|
479
486
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
480
487
|
category = args[0].split('=')[1];
|
|
@@ -490,6 +497,7 @@ class IssueReporter {
|
|
|
490
497
|
errorMessage: lastArg.message,
|
|
491
498
|
errorStack: lastArg.stack,
|
|
492
499
|
errorType: lastArg.constructor.name,
|
|
500
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
493
501
|
};
|
|
494
502
|
} else {
|
|
495
503
|
extra = lastArg;
|
|
@@ -498,6 +506,11 @@ class IssueReporter {
|
|
|
498
506
|
args.splice(1, 1);
|
|
499
507
|
}
|
|
500
508
|
|
|
509
|
+
if (extra.skipSendToRemote) {
|
|
510
|
+
skipSendToRemote = true;
|
|
511
|
+
delete extra.skipSendToRemote;
|
|
512
|
+
}
|
|
513
|
+
|
|
501
514
|
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
502
515
|
const message = args.join(', ');
|
|
503
516
|
let consoleMessage = message;
|
|
@@ -518,7 +531,13 @@ class IssueReporter {
|
|
|
518
531
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
519
532
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
520
533
|
|
|
521
|
-
this.
|
|
534
|
+
if (this._callback) {
|
|
535
|
+
this._callback(level, consoleMessage);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
if (!skipSendToRemote) {
|
|
539
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
540
|
+
}
|
|
522
541
|
}
|
|
523
542
|
|
|
524
543
|
logRequest(url , options , response , start ) {
|
|
@@ -663,7 +682,11 @@ class IssueReporter {
|
|
|
663
682
|
},
|
|
664
683
|
// $FlowFixMe
|
|
665
684
|
body,
|
|
666
|
-
}).catch(() => {
|
|
685
|
+
}).catch((e ) => {
|
|
686
|
+
// $FlowFixMe
|
|
687
|
+
e.skipSendToRemote = true;
|
|
688
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
689
|
+
|
|
667
690
|
setTimeout(() => {
|
|
668
691
|
if (isArray) {
|
|
669
692
|
payload = payload.map(message => {
|
|
@@ -712,10 +735,6 @@ const getSrflxOrRelay = (candidates ) =>
|
|
|
712
735
|
candidates
|
|
713
736
|
.filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
|
|
714
737
|
|
|
715
|
-
const areCandidateValid = (candidates ) =>
|
|
716
|
-
getSrflxOrRelay(candidates)
|
|
717
|
-
.length > 0;
|
|
718
|
-
|
|
719
738
|
const getVideoDirection = (sdp ) => {
|
|
720
739
|
const parsedSdp = sdpParser__default['default'].parse(sdp);
|
|
721
740
|
const videoMedia = parsedSdp.media.find(media => media.type === 'video');
|
|
@@ -768,8 +787,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
768
787
|
/* global RTCSessionDescriptionInit, navigator */
|
|
769
788
|
|
|
770
789
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
771
|
-
const MAX_WAIT_FOR_ICE_TRIES = 20;
|
|
772
|
-
const WAIT_FOR_ICE_TIMEOUT = 500;
|
|
773
790
|
|
|
774
791
|
// Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
|
|
775
792
|
const wazoMediaStreamFactory = (constraints ) => {
|
|
@@ -959,38 +976,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
959
976
|
this._peerConnection = undefined;
|
|
960
977
|
}
|
|
961
978
|
|
|
962
|
-
async _waitForValidGatheredIce() {
|
|
963
|
-
let tries = 0;
|
|
964
|
-
|
|
965
|
-
while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
|
|
966
|
-
wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
|
|
967
|
-
tries,
|
|
968
|
-
max: MAX_WAIT_FOR_ICE_TRIES,
|
|
969
|
-
});
|
|
970
|
-
|
|
971
|
-
tries++;
|
|
972
|
-
|
|
973
|
-
// eslint-disable-next-line no-await-in-loop
|
|
974
|
-
await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
|
|
978
|
-
const errorMsg = 'No valid candidates found, can\'t answer the call';
|
|
979
|
-
const error = new Error(errorMsg);
|
|
980
|
-
wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
|
|
981
|
-
|
|
982
|
-
// Emit an error, because sip.js catches the exception and switch to status Terminated.
|
|
983
|
-
this.eventEmitter.emit('error', error);
|
|
984
|
-
|
|
985
|
-
wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
// eslint-disable-next-line
|
|
989
|
-
wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
990
|
-
|
|
991
|
-
return this.getLocalSessionDescription();
|
|
992
|
-
}
|
|
993
|
-
|
|
994
979
|
// Overridden to send `inactive` in conference
|
|
995
980
|
updateDirection(options , isConference = false,
|
|
996
981
|
audioOnly = false) {
|
|
@@ -2100,6 +2085,9 @@ class Contact {
|
|
|
2100
2085
|
}
|
|
2101
2086
|
|
|
2102
2087
|
static parseMany(response ) {
|
|
2088
|
+
if (!response || !response.results) {
|
|
2089
|
+
return [];
|
|
2090
|
+
}
|
|
2103
2091
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
2104
2092
|
}
|
|
2105
2093
|
|
|
@@ -3177,8 +3165,9 @@ class ExternalApp {
|
|
|
3177
3165
|
|
|
3178
3166
|
|
|
3179
3167
|
|
|
3180
|
-
|
|
3168
|
+
|
|
3181
3169
|
|
|
3170
|
+
|
|
3182
3171
|
|
|
3183
3172
|
|
|
3184
3173
|
class Meeting {
|
|
@@ -3189,9 +3178,10 @@ class Meeting {
|
|
|
3189
3178
|
|
|
3190
3179
|
|
|
3191
3180
|
|
|
3192
|
-
|
|
3181
|
+
|
|
3193
3182
|
|
|
3194
3183
|
|
|
3184
|
+
|
|
3195
3185
|
|
|
3196
3186
|
static parse(plain ) {
|
|
3197
3187
|
return new Meeting({
|
|
@@ -3201,24 +3191,43 @@ class Meeting {
|
|
|
3201
3191
|
ownerUuids: plain.owner_uuids,
|
|
3202
3192
|
port: plain.port,
|
|
3203
3193
|
uuid: plain.uuid,
|
|
3204
|
-
|
|
3194
|
+
extension: plain.exten,
|
|
3205
3195
|
persistent: plain.persistent,
|
|
3196
|
+
creationTime: moment__default['default'](plain.creation_time).toDate(),
|
|
3206
3197
|
});
|
|
3207
3198
|
}
|
|
3208
3199
|
|
|
3200
|
+
static parseMany(items ) {
|
|
3201
|
+
if (!items) {
|
|
3202
|
+
return [];
|
|
3203
|
+
}
|
|
3204
|
+
return items.map(plain => Meeting.parse(plain));
|
|
3205
|
+
}
|
|
3206
|
+
|
|
3209
3207
|
static newFrom(meeting ) {
|
|
3210
3208
|
return newFrom(meeting, Meeting);
|
|
3211
3209
|
}
|
|
3212
3210
|
|
|
3213
|
-
constructor({
|
|
3211
|
+
constructor({
|
|
3212
|
+
uuid,
|
|
3213
|
+
name,
|
|
3214
|
+
guestSipAuthorization,
|
|
3215
|
+
ownerUuids,
|
|
3216
|
+
port,
|
|
3217
|
+
uri,
|
|
3218
|
+
extension,
|
|
3219
|
+
persistent,
|
|
3220
|
+
creationTime,
|
|
3221
|
+
} = {}) {
|
|
3214
3222
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
3215
3223
|
this.uri = uri;
|
|
3216
3224
|
this.name = name;
|
|
3217
3225
|
this.ownerUuids = ownerUuids;
|
|
3218
3226
|
this.port = port;
|
|
3219
3227
|
this.uuid = uuid;
|
|
3220
|
-
this.
|
|
3228
|
+
this.extension = extension;
|
|
3221
3229
|
this.persistent = persistent;
|
|
3230
|
+
this.creationTime = creationTime;
|
|
3222
3231
|
|
|
3223
3232
|
// Useful to compare instead of instanceof with minified code
|
|
3224
3233
|
this.type = 'Meeting';
|
|
@@ -3296,8 +3305,11 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
3296
3305
|
}
|
|
3297
3306
|
},
|
|
3298
3307
|
|
|
3299
|
-
|
|
3300
|
-
client.
|
|
3308
|
+
getMyMeetings: () =>
|
|
3309
|
+
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
3310
|
+
|
|
3311
|
+
createMyMeeting: (name , persistent ) =>
|
|
3312
|
+
client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
|
|
3301
3313
|
|
|
3302
3314
|
deleteMyMeeting: (meetingUuid ) =>
|
|
3303
3315
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -3393,6 +3405,10 @@ class ChatMessage {
|
|
|
3393
3405
|
|
|
3394
3406
|
|
|
3395
3407
|
static parseMany(plain ) {
|
|
3408
|
+
if (!plain || !plain.items) {
|
|
3409
|
+
return [];
|
|
3410
|
+
}
|
|
3411
|
+
|
|
3396
3412
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
3397
3413
|
}
|
|
3398
3414
|
|
|
@@ -3502,6 +3518,9 @@ class Voicemail {
|
|
|
3502
3518
|
}
|
|
3503
3519
|
|
|
3504
3520
|
static parseMany(plain ) {
|
|
3521
|
+
if (!plain) {
|
|
3522
|
+
return [];
|
|
3523
|
+
}
|
|
3505
3524
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
3506
3525
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
3507
3526
|
|
|
@@ -3611,6 +3630,9 @@ class Call {
|
|
|
3611
3630
|
|
|
3612
3631
|
|
|
3613
3632
|
static parseMany(plain ) {
|
|
3633
|
+
if (!plain) {
|
|
3634
|
+
return [];
|
|
3635
|
+
}
|
|
3614
3636
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
3615
3637
|
}
|
|
3616
3638
|
|
|
@@ -3783,6 +3805,9 @@ class Recording {
|
|
|
3783
3805
|
|
|
3784
3806
|
|
|
3785
3807
|
static parseMany(recordings = []) {
|
|
3808
|
+
if (!recordings) {
|
|
3809
|
+
return [];
|
|
3810
|
+
}
|
|
3786
3811
|
return recordings.map(item => Recording.parse(item));
|
|
3787
3812
|
}
|
|
3788
3813
|
|
|
@@ -3884,6 +3909,10 @@ class CallLog {
|
|
|
3884
3909
|
}
|
|
3885
3910
|
|
|
3886
3911
|
static parseMany(plain ) {
|
|
3912
|
+
if (!plain || !plain.items) {
|
|
3913
|
+
return [];
|
|
3914
|
+
}
|
|
3915
|
+
|
|
3887
3916
|
return plain.items.map(item => CallLog.parse(item));
|
|
3888
3917
|
}
|
|
3889
3918
|
|
|
@@ -4120,7 +4149,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
4120
4149
|
|
|
4121
4150
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
4122
4151
|
|
|
4123
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
4152
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
4124
4153
|
|
|
4125
4154
|
/* */
|
|
4126
4155
|
|
|
@@ -4456,6 +4485,9 @@ class ChatRoom {
|
|
|
4456
4485
|
|
|
4457
4486
|
|
|
4458
4487
|
static parseMany(plain ) {
|
|
4488
|
+
if (!plain || !plain.items) {
|
|
4489
|
+
return [];
|
|
4490
|
+
}
|
|
4459
4491
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
4460
4492
|
}
|
|
4461
4493
|
|
|
@@ -5036,7 +5068,7 @@ const AGENTD_VERSION = '1.0';
|
|
|
5036
5068
|
const WEBHOOKD_VERSION = '1.0';
|
|
5037
5069
|
const AMID_VERSION = '1.0';
|
|
5038
5070
|
|
|
5039
|
-
const logger$
|
|
5071
|
+
const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
5040
5072
|
|
|
5041
5073
|
class ApiClient {
|
|
5042
5074
|
|
|
@@ -5088,12 +5120,12 @@ class ApiClient {
|
|
|
5088
5120
|
}
|
|
5089
5121
|
|
|
5090
5122
|
async forceRefreshToken() {
|
|
5091
|
-
logger$
|
|
5123
|
+
logger$2.info('forcing refresh token, calling callback');
|
|
5092
5124
|
return this.refreshTokenCallback();
|
|
5093
5125
|
}
|
|
5094
5126
|
|
|
5095
5127
|
async refreshTokenCallback() {
|
|
5096
|
-
logger$
|
|
5128
|
+
logger$2.info('refresh token callback called', {
|
|
5097
5129
|
refreshToken: this.refreshToken,
|
|
5098
5130
|
refreshBackend: this.refreshBackend,
|
|
5099
5131
|
refreshExpiration: this.refreshExpiration,
|
|
@@ -5111,7 +5143,7 @@ class ApiClient {
|
|
|
5111
5143
|
this.isMobile,
|
|
5112
5144
|
);
|
|
5113
5145
|
|
|
5114
|
-
logger$
|
|
5146
|
+
logger$2.info('token refreshed', { token: session.token });
|
|
5115
5147
|
|
|
5116
5148
|
if (this.onRefreshToken) {
|
|
5117
5149
|
this.onRefreshToken(session.token, session);
|
|
@@ -5284,7 +5316,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
|
|
|
5284
5316
|
const SEND_STATS_DELAY = 5000;
|
|
5285
5317
|
|
|
5286
5318
|
const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
|
|
5287
|
-
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
5319
|
+
const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
5288
5320
|
const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
5289
5321
|
|
|
5290
5322
|
// events
|
|
@@ -5463,13 +5495,13 @@ class WebRTCClient extends Emitter {
|
|
|
5463
5495
|
|
|
5464
5496
|
createUserAgent(configOverrides ) {
|
|
5465
5497
|
const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
|
|
5466
|
-
logger.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
5498
|
+
logger$3.info('sdk webrtc, creating UA', { webRTCConfiguration });
|
|
5467
5499
|
|
|
5468
5500
|
webRTCConfiguration.delegate = {
|
|
5469
5501
|
onConnect: this.onConnect.bind(this),
|
|
5470
5502
|
onDisconnect: this.onDisconnect.bind(this),
|
|
5471
5503
|
onInvite: (invitation ) => {
|
|
5472
|
-
logger.info('sdk webrtc on invite', {
|
|
5504
|
+
logger$3.info('sdk webrtc on invite', {
|
|
5473
5505
|
method: 'delegate.onInvite',
|
|
5474
5506
|
id: invitation.id,
|
|
5475
5507
|
remoteURI: invitation.remoteURI,
|
|
@@ -5512,7 +5544,7 @@ class WebRTCClient extends Emitter {
|
|
|
5512
5544
|
}
|
|
5513
5545
|
|
|
5514
5546
|
onConnect() {
|
|
5515
|
-
logger.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
5547
|
+
logger$3.info('sdk webrtc connected', { method: 'delegate.onConnect' });
|
|
5516
5548
|
this.eventEmitter.emit(CONNECTED);
|
|
5517
5549
|
if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
|
|
5518
5550
|
this.registerer.waitingToggle(false);
|
|
@@ -5521,7 +5553,7 @@ class WebRTCClient extends Emitter {
|
|
|
5521
5553
|
}
|
|
5522
5554
|
|
|
5523
5555
|
async onDisconnect(error ) {
|
|
5524
|
-
logger.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
5556
|
+
logger$3.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
|
|
5525
5557
|
this.connectionPromise = null;
|
|
5526
5558
|
// The UA will attempt to reconnect automatically when an error occurred
|
|
5527
5559
|
this.eventEmitter.emit(DISCONNECTED, error);
|
|
@@ -5546,37 +5578,37 @@ class WebRTCClient extends Emitter {
|
|
|
5546
5578
|
};
|
|
5547
5579
|
|
|
5548
5580
|
if (this.skipRegister) {
|
|
5549
|
-
logger.info('sdk webrtc skip register...', logInfo);
|
|
5581
|
+
logger$3.info('sdk webrtc skip register...', logInfo);
|
|
5550
5582
|
return Promise.resolve();
|
|
5551
5583
|
}
|
|
5552
5584
|
|
|
5553
|
-
logger.info('sdk webrtc registering...', logInfo);
|
|
5585
|
+
logger$3.info('sdk webrtc registering...', logInfo);
|
|
5554
5586
|
|
|
5555
5587
|
if (!this.userAgent) {
|
|
5556
|
-
logger.info('sdk webrtc recreating User Agent');
|
|
5588
|
+
logger$3.info('sdk webrtc recreating User Agent');
|
|
5557
5589
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
5558
5590
|
}
|
|
5559
5591
|
if (!this.userAgent || this.isRegistered()) {
|
|
5560
|
-
logger.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
5592
|
+
logger$3.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
5561
5593
|
return Promise.resolve();
|
|
5562
5594
|
}
|
|
5563
5595
|
|
|
5564
5596
|
if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
|
|
5565
|
-
logger.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
5597
|
+
logger$3.info('sdk webrtc registering aborted due to a registration in progress.');
|
|
5566
5598
|
return Promise.resolve();
|
|
5567
5599
|
}
|
|
5568
5600
|
|
|
5569
5601
|
const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
|
|
5570
5602
|
|
|
5571
5603
|
const onRegisterFailed = () => {
|
|
5572
|
-
logger.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
5604
|
+
logger$3.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
|
|
5573
5605
|
this.connectionPromise = null;
|
|
5574
5606
|
if (this.registerer && this.registerer.waiting) {
|
|
5575
5607
|
this.registerer.waitingToggle(false);
|
|
5576
5608
|
}
|
|
5577
5609
|
|
|
5578
5610
|
if (tries <= MAX_REGISTER_TRIES) {
|
|
5579
|
-
logger.info('sdk webrtc registering, retrying...', { tries });
|
|
5611
|
+
logger$3.info('sdk webrtc registering, retrying...', { tries });
|
|
5580
5612
|
setTimeout(() => this.register(tries + 1), 300);
|
|
5581
5613
|
}
|
|
5582
5614
|
};
|
|
@@ -5585,18 +5617,18 @@ class WebRTCClient extends Emitter {
|
|
|
5585
5617
|
// Avoid race condition with the close method called just before register and setting userAgent to null
|
|
5586
5618
|
// during the resolution of the primise.
|
|
5587
5619
|
if (!this.userAgent) {
|
|
5588
|
-
logger.info('sdk webrtc recreating User Agent after connection');
|
|
5620
|
+
logger$3.info('sdk webrtc recreating User Agent after connection');
|
|
5589
5621
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
5590
5622
|
}
|
|
5591
5623
|
|
|
5592
|
-
logger.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
5624
|
+
logger$3.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
|
|
5593
5625
|
this.registerer = new registerer.Registerer(this.userAgent, registerOptions);
|
|
5594
5626
|
this.connectionPromise = null;
|
|
5595
5627
|
this._monkeyPatchRegisterer(this.registerer);
|
|
5596
5628
|
|
|
5597
5629
|
// Bind registerer events
|
|
5598
5630
|
this.registerer.stateChange.addListener(newState => {
|
|
5599
|
-
logger.info('sdk webrtc registering, state changed', { newState });
|
|
5631
|
+
logger$3.info('sdk webrtc registering, state changed', { newState });
|
|
5600
5632
|
|
|
5601
5633
|
if (newState === registererState.RegistererState.Registered && this.registerer
|
|
5602
5634
|
&& this.registerer.state === registererState.RegistererState.Registered) {
|
|
@@ -5609,7 +5641,7 @@ class WebRTCClient extends Emitter {
|
|
|
5609
5641
|
const options = {
|
|
5610
5642
|
requestDelegate: {
|
|
5611
5643
|
onReject: response => {
|
|
5612
|
-
logger.error('sdk webrtc registering, rejected', { response });
|
|
5644
|
+
logger$3.error('sdk webrtc registering, rejected', { response });
|
|
5613
5645
|
|
|
5614
5646
|
onRegisterFailed();
|
|
5615
5647
|
},
|
|
@@ -5617,13 +5649,13 @@ class WebRTCClient extends Emitter {
|
|
|
5617
5649
|
};
|
|
5618
5650
|
|
|
5619
5651
|
return this.registerer.register(options).catch((e) => {
|
|
5620
|
-
logger.error('sdk webrtc registering, error', e);
|
|
5652
|
+
logger$3.error('sdk webrtc registering, error', e);
|
|
5621
5653
|
|
|
5622
5654
|
this.eventEmitter.emit(REGISTRATION_FAILED);
|
|
5623
5655
|
return e;
|
|
5624
5656
|
});
|
|
5625
5657
|
}).catch(error => {
|
|
5626
|
-
logger.error('sdk webrtc registering, transport error', error);
|
|
5658
|
+
logger$3.error('sdk webrtc registering, transport error', error);
|
|
5627
5659
|
onRegisterFailed();
|
|
5628
5660
|
});
|
|
5629
5661
|
}
|
|
@@ -5652,21 +5684,21 @@ class WebRTCClient extends Emitter {
|
|
|
5652
5684
|
}
|
|
5653
5685
|
|
|
5654
5686
|
unregister() {
|
|
5655
|
-
logger.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
5687
|
+
logger$3.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
|
|
5656
5688
|
if (!this.registerer) {
|
|
5657
5689
|
return Promise.resolve();
|
|
5658
5690
|
}
|
|
5659
5691
|
|
|
5660
5692
|
try {
|
|
5661
5693
|
return this.registerer.unregister().then(() => {
|
|
5662
|
-
logger.info('sdk webrtc unregistered');
|
|
5694
|
+
logger$3.info('sdk webrtc unregistered');
|
|
5663
5695
|
this._cleanupRegister();
|
|
5664
5696
|
}).catch(e => {
|
|
5665
|
-
logger.error('sdk webrtc unregistering, promise error', e);
|
|
5697
|
+
logger$3.error('sdk webrtc unregistering, promise error', e);
|
|
5666
5698
|
this._cleanupRegister();
|
|
5667
5699
|
});
|
|
5668
5700
|
} catch (e) {
|
|
5669
|
-
logger.error('sdk webrtc unregistering, error', e);
|
|
5701
|
+
logger$3.error('sdk webrtc unregistering, error', e);
|
|
5670
5702
|
// Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
|
|
5671
5703
|
// error when the registerer is in a bad state
|
|
5672
5704
|
this._cleanupRegister();
|
|
@@ -5674,7 +5706,7 @@ class WebRTCClient extends Emitter {
|
|
|
5674
5706
|
}
|
|
5675
5707
|
|
|
5676
5708
|
stop() {
|
|
5677
|
-
logger.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
5709
|
+
logger$3.info('sdk webrtc stop', { userAgent: !!this.userAgent });
|
|
5678
5710
|
if (!this.userAgent) {
|
|
5679
5711
|
return Promise.resolve();
|
|
5680
5712
|
}
|
|
@@ -5682,12 +5714,12 @@ class WebRTCClient extends Emitter {
|
|
|
5682
5714
|
return this.userAgent.stop().then(() => {
|
|
5683
5715
|
return this._cleanupRegister();
|
|
5684
5716
|
}).catch(e => {
|
|
5685
|
-
logger.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
5717
|
+
logger$3.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
|
|
5686
5718
|
});
|
|
5687
5719
|
}
|
|
5688
5720
|
|
|
5689
5721
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
5690
|
-
logger.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
5722
|
+
logger$3.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
5691
5723
|
const inviterOptions = {
|
|
5692
5724
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
5693
5725
|
conference,
|
|
@@ -5712,11 +5744,13 @@ class WebRTCClient extends Emitter {
|
|
|
5712
5744
|
const inviteOptions = {
|
|
5713
5745
|
requestDelegate: {
|
|
5714
5746
|
onAccept: (response ) => {
|
|
5715
|
-
session.sessionDescriptionHandler.peerConnection
|
|
5747
|
+
if (session.sessionDescriptionHandler.peerConnection) {
|
|
5748
|
+
session.sessionDescriptionHandler.peerConnection.sfu = conference;
|
|
5749
|
+
}
|
|
5716
5750
|
this._onAccepted(session, response.session, true);
|
|
5717
5751
|
},
|
|
5718
5752
|
onReject: (response ) => {
|
|
5719
|
-
logger.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
5753
|
+
logger$3.info('on call rejected', { id: session.id, fromTag: session.fromTag });
|
|
5720
5754
|
this._stopSendingStats(session);
|
|
5721
5755
|
this.stopNetworkMonitoring(session);
|
|
5722
5756
|
|
|
@@ -5739,11 +5773,11 @@ class WebRTCClient extends Emitter {
|
|
|
5739
5773
|
}
|
|
5740
5774
|
|
|
5741
5775
|
answer(session , enableVideo ) {
|
|
5742
|
-
logger.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
5776
|
+
logger$3.info('sdk webrtc answer call', { id: session.id, enableVideo });
|
|
5743
5777
|
|
|
5744
5778
|
if (!session || !session.accept) {
|
|
5745
5779
|
const error = 'No session to answer, or not an invitation';
|
|
5746
|
-
logger.warn(error);
|
|
5780
|
+
logger$3.warn(error);
|
|
5747
5781
|
return Promise.reject(new Error(error));
|
|
5748
5782
|
}
|
|
5749
5783
|
const options = {
|
|
@@ -5753,15 +5787,15 @@ class WebRTCClient extends Emitter {
|
|
|
5753
5787
|
return session.accept(options).then(() => {
|
|
5754
5788
|
if (session.isCanceled) {
|
|
5755
5789
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
5756
|
-
logger.error(message, { id: session.id });
|
|
5790
|
+
logger$3.error(message, { id: session.id });
|
|
5757
5791
|
this.onCallEnded(session);
|
|
5758
5792
|
|
|
5759
5793
|
throw new CanceledCallError(message);
|
|
5760
5794
|
}
|
|
5761
|
-
logger.info('sdk webrtc answer, accepted.');
|
|
5795
|
+
logger$3.info('sdk webrtc answer, accepted.');
|
|
5762
5796
|
this._onAccepted(session);
|
|
5763
5797
|
}).catch(e => {
|
|
5764
|
-
logger.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
5798
|
+
logger$3.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
|
|
5765
5799
|
|
|
5766
5800
|
throw e;
|
|
5767
5801
|
});
|
|
@@ -5769,7 +5803,7 @@ class WebRTCClient extends Emitter {
|
|
|
5769
5803
|
|
|
5770
5804
|
hangup(session ) {
|
|
5771
5805
|
const { state, id } = session;
|
|
5772
|
-
logger.info('sdk webrtc hangup call', { id, state });
|
|
5806
|
+
logger$3.info('sdk webrtc hangup call', { id, state });
|
|
5773
5807
|
|
|
5774
5808
|
try {
|
|
5775
5809
|
this._stopSendingStats(session);
|
|
@@ -5798,7 +5832,7 @@ class WebRTCClient extends Emitter {
|
|
|
5798
5832
|
|
|
5799
5833
|
return bye();
|
|
5800
5834
|
} catch (error) {
|
|
5801
|
-
logger.warn('sdk webrtc hangup, error', error);
|
|
5835
|
+
logger$3.warn('sdk webrtc hangup, error', error);
|
|
5802
5836
|
}
|
|
5803
5837
|
|
|
5804
5838
|
return null;
|
|
@@ -5816,7 +5850,7 @@ class WebRTCClient extends Emitter {
|
|
|
5816
5850
|
// Fetch and emit an event at `interval` with session network stats
|
|
5817
5851
|
startNetworkMonitoring(session , interval = 1000) {
|
|
5818
5852
|
const sessionId = this.getSipSessionId(session);
|
|
5819
|
-
logger.info('starting network inspection', { id: sessionId });
|
|
5853
|
+
logger$3.info('starting network inspection', { id: sessionId });
|
|
5820
5854
|
|
|
5821
5855
|
this.sessionNetworkStats[sessionId] = [];
|
|
5822
5856
|
|
|
@@ -5826,7 +5860,7 @@ class WebRTCClient extends Emitter {
|
|
|
5826
5860
|
stopNetworkMonitoring(session ) {
|
|
5827
5861
|
const sessionId = this.getSipSessionId(session);
|
|
5828
5862
|
const exists = sessionId in this.networkMonitoringInterval;
|
|
5829
|
-
logger.info('stopping network inspection', { id: sessionId, exists });
|
|
5863
|
+
logger$3.info('stopping network inspection', { id: sessionId, exists });
|
|
5830
5864
|
|
|
5831
5865
|
if (exists) {
|
|
5832
5866
|
clearInterval(this.networkMonitoringInterval[sessionId]);
|
|
@@ -5836,17 +5870,17 @@ class WebRTCClient extends Emitter {
|
|
|
5836
5870
|
}
|
|
5837
5871
|
|
|
5838
5872
|
reject(session ) {
|
|
5839
|
-
logger.info('sdk webrtc reject call', { id: session.id });
|
|
5873
|
+
logger$3.info('sdk webrtc reject call', { id: session.id });
|
|
5840
5874
|
|
|
5841
5875
|
try {
|
|
5842
5876
|
return session.reject ? session.reject() : session.cancel();
|
|
5843
5877
|
} catch (e) {
|
|
5844
|
-
logger.warn('Error when rejecting call', e.message, e.stack);
|
|
5878
|
+
logger$3.warn('Error when rejecting call', e.message, e.stack);
|
|
5845
5879
|
}
|
|
5846
5880
|
}
|
|
5847
5881
|
|
|
5848
5882
|
async close() {
|
|
5849
|
-
logger.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
5883
|
+
logger$3.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
|
|
5850
5884
|
this._cleanupMedia();
|
|
5851
5885
|
this.connectionPromise = null;
|
|
5852
5886
|
|
|
@@ -5877,7 +5911,7 @@ class WebRTCClient extends Emitter {
|
|
|
5877
5911
|
// eg: "INVITE not rejectable in state Completed"
|
|
5878
5912
|
}
|
|
5879
5913
|
this.userAgent = null;
|
|
5880
|
-
logger.info('sdk webrtc client closed');
|
|
5914
|
+
logger$3.info('sdk webrtc client closed');
|
|
5881
5915
|
}
|
|
5882
5916
|
|
|
5883
5917
|
getNumber(session ) {
|
|
@@ -5890,13 +5924,13 @@ class WebRTCClient extends Emitter {
|
|
|
5890
5924
|
}
|
|
5891
5925
|
|
|
5892
5926
|
mute(session ) {
|
|
5893
|
-
logger.info('sdk webrtc mute', { id: session.id });
|
|
5927
|
+
logger$3.info('sdk webrtc mute', { id: session.id });
|
|
5894
5928
|
|
|
5895
5929
|
this._toggleAudio(session, true);
|
|
5896
5930
|
}
|
|
5897
5931
|
|
|
5898
5932
|
unmute(session ) {
|
|
5899
|
-
logger.info('sdk webrtc unmute', { id: session.id });
|
|
5933
|
+
logger$3.info('sdk webrtc unmute', { id: session.id });
|
|
5900
5934
|
|
|
5901
5935
|
this._toggleAudio(session, false);
|
|
5902
5936
|
}
|
|
@@ -5936,13 +5970,13 @@ class WebRTCClient extends Emitter {
|
|
|
5936
5970
|
}
|
|
5937
5971
|
|
|
5938
5972
|
toggleCameraOn(session ) {
|
|
5939
|
-
logger.info('sdk webrtc toggle camera on', { id: session.id });
|
|
5973
|
+
logger$3.info('sdk webrtc toggle camera on', { id: session.id });
|
|
5940
5974
|
|
|
5941
5975
|
this._toggleVideo(session, false);
|
|
5942
5976
|
}
|
|
5943
5977
|
|
|
5944
5978
|
toggleCameraOff(session ) {
|
|
5945
|
-
logger.info('sdk webrtc toggle camera off', { id: session.id });
|
|
5979
|
+
logger$3.info('sdk webrtc toggle camera off', { id: session.id });
|
|
5946
5980
|
|
|
5947
5981
|
this._toggleVideo(session, true);
|
|
5948
5982
|
}
|
|
@@ -5951,7 +5985,7 @@ class WebRTCClient extends Emitter {
|
|
|
5951
5985
|
const sessionId = this.getSipSessionId(session);
|
|
5952
5986
|
const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
|
|
5953
5987
|
|
|
5954
|
-
logger.info('sdk webrtc hold', {
|
|
5988
|
+
logger$3.info('sdk webrtc hold', {
|
|
5955
5989
|
sessionId,
|
|
5956
5990
|
keys: Object.keys(this.heldSessions),
|
|
5957
5991
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -6000,7 +6034,7 @@ class WebRTCClient extends Emitter {
|
|
|
6000
6034
|
const sessionId = this.getSipSessionId(session);
|
|
6001
6035
|
const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
|
|
6002
6036
|
|
|
6003
|
-
logger.info('sdk webrtc unhold', {
|
|
6037
|
+
logger$3.info('sdk webrtc unhold', {
|
|
6004
6038
|
sessionId,
|
|
6005
6039
|
keys: Object.keys(this.heldSessions),
|
|
6006
6040
|
pendingReinvite: !!session.pendingReinvite,
|
|
@@ -6148,7 +6182,7 @@ class WebRTCClient extends Emitter {
|
|
|
6148
6182
|
if (!session.sessionDescriptionHandler) {
|
|
6149
6183
|
return;
|
|
6150
6184
|
}
|
|
6151
|
-
logger.info('Sending DTMF', {
|
|
6185
|
+
logger$3.info('Sending DTMF', {
|
|
6152
6186
|
id: this.getSipSessionId(session),
|
|
6153
6187
|
tone,
|
|
6154
6188
|
});
|
|
@@ -6164,7 +6198,7 @@ class WebRTCClient extends Emitter {
|
|
|
6164
6198
|
transfer(session , target ) {
|
|
6165
6199
|
this.hold(session);
|
|
6166
6200
|
|
|
6167
|
-
logger.info('Transfering a session', {
|
|
6201
|
+
logger$3.info('Transfering a session', {
|
|
6168
6202
|
id: this.getSipSessionId(session),
|
|
6169
6203
|
target,
|
|
6170
6204
|
});
|
|
@@ -6186,17 +6220,17 @@ class WebRTCClient extends Emitter {
|
|
|
6186
6220
|
atxfer(session ) {
|
|
6187
6221
|
this.hold(session);
|
|
6188
6222
|
|
|
6189
|
-
logger.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
6223
|
+
logger$3.info('webrtc transfer started', { id: this.getSipSessionId(session) });
|
|
6190
6224
|
|
|
6191
6225
|
const result = {
|
|
6192
6226
|
newSession: null,
|
|
6193
6227
|
init: async (target ) => {
|
|
6194
|
-
logger.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
6228
|
+
logger$3.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
|
|
6195
6229
|
|
|
6196
6230
|
result.newSession = await this.call(target);
|
|
6197
6231
|
},
|
|
6198
6232
|
complete: () => {
|
|
6199
|
-
logger.info('webrtc transfer completed', {
|
|
6233
|
+
logger$3.info('webrtc transfer completed', {
|
|
6200
6234
|
id: this.getSipSessionId(session),
|
|
6201
6235
|
referId: this.getSipSessionId(result.newSession),
|
|
6202
6236
|
});
|
|
@@ -6217,7 +6251,7 @@ class WebRTCClient extends Emitter {
|
|
|
6217
6251
|
return;
|
|
6218
6252
|
}
|
|
6219
6253
|
|
|
6220
|
-
logger.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
6254
|
+
logger$3.info('send WebRTC message', { sipId: sipSession.id, contentType });
|
|
6221
6255
|
|
|
6222
6256
|
try {
|
|
6223
6257
|
sipSession.message({
|
|
@@ -6259,7 +6293,7 @@ class WebRTCClient extends Emitter {
|
|
|
6259
6293
|
}
|
|
6260
6294
|
|
|
6261
6295
|
changeAudioOutputVolume(volume ) {
|
|
6262
|
-
logger.info('Changing audio output volume', { volume });
|
|
6296
|
+
logger$3.info('Changing audio output volume', { volume });
|
|
6263
6297
|
|
|
6264
6298
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
6265
6299
|
if (audioElement instanceof HTMLAudioElement) {
|
|
@@ -6271,7 +6305,7 @@ class WebRTCClient extends Emitter {
|
|
|
6271
6305
|
}
|
|
6272
6306
|
|
|
6273
6307
|
changeAudioOutputDevice(id ) {
|
|
6274
|
-
logger.info('Changing audio output device', { id });
|
|
6308
|
+
logger$3.info('Changing audio output device', { id });
|
|
6275
6309
|
|
|
6276
6310
|
Object.values(this.audioElements).forEach(audioElement => {
|
|
6277
6311
|
// `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
|
|
@@ -6288,7 +6322,7 @@ class WebRTCClient extends Emitter {
|
|
|
6288
6322
|
|
|
6289
6323
|
changeAudioInputDevice(id , session ) {
|
|
6290
6324
|
const currentId = this.getAudioDeviceId();
|
|
6291
|
-
logger.info('setting audio input device', { id, currentId, session: !!session });
|
|
6325
|
+
logger$3.info('setting audio input device', { id, currentId, session: !!session });
|
|
6292
6326
|
|
|
6293
6327
|
if (id === currentId) {
|
|
6294
6328
|
return null;
|
|
@@ -6334,7 +6368,7 @@ class WebRTCClient extends Emitter {
|
|
|
6334
6368
|
|
|
6335
6369
|
setVideoInputDevice(id ) {
|
|
6336
6370
|
const currentId = this.getVideoDeviceId();
|
|
6337
|
-
logger.info('setting video input device', { id, currentId });
|
|
6371
|
+
logger$3.info('setting video input device', { id, currentId });
|
|
6338
6372
|
|
|
6339
6373
|
if (id === currentId) {
|
|
6340
6374
|
return null;
|
|
@@ -6359,7 +6393,7 @@ class WebRTCClient extends Emitter {
|
|
|
6359
6393
|
const sessionId = this.getSipSessionId(session);
|
|
6360
6394
|
const localStream = this.getLocalStream(sessionId);
|
|
6361
6395
|
|
|
6362
|
-
logger.info('changing video input device', { id, sessionId });
|
|
6396
|
+
logger$3.info('changing video input device', { id, sessionId });
|
|
6363
6397
|
|
|
6364
6398
|
// Release old video stream
|
|
6365
6399
|
if (localStream) {
|
|
@@ -6427,7 +6461,7 @@ class WebRTCClient extends Emitter {
|
|
|
6427
6461
|
const shouldDoScreenSharing = newConstraints && newConstraints.screen;
|
|
6428
6462
|
const desktop = newConstraints && newConstraints.desktop;
|
|
6429
6463
|
|
|
6430
|
-
logger.info('Sending reinvite', {
|
|
6464
|
+
logger$3.info('Sending reinvite', {
|
|
6431
6465
|
id: this.getSipSessionId(sipSession),
|
|
6432
6466
|
newConstraints,
|
|
6433
6467
|
conference,
|
|
@@ -6465,7 +6499,7 @@ class WebRTCClient extends Emitter {
|
|
|
6465
6499
|
sipSession.incomingInviteRequest.message.body = response.message.body;
|
|
6466
6500
|
}
|
|
6467
6501
|
|
|
6468
|
-
logger.info('on re-INVITE accepted', {
|
|
6502
|
+
logger$3.info('on re-INVITE accepted', {
|
|
6469
6503
|
id: this.getSipSessionId(sipSession),
|
|
6470
6504
|
wasMuted,
|
|
6471
6505
|
shouldDoScreenSharing,
|
|
@@ -6584,6 +6618,16 @@ class WebRTCClient extends Emitter {
|
|
|
6584
6618
|
return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
|
|
6585
6619
|
}
|
|
6586
6620
|
|
|
6621
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
6622
|
+
getRemoteVideoStreamFromPc(sessionId ) {
|
|
6623
|
+
const pc = this.getPeerConnection(sessionId);
|
|
6624
|
+
if (!pc) {
|
|
6625
|
+
return null;
|
|
6626
|
+
}
|
|
6627
|
+
|
|
6628
|
+
return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
|
|
6629
|
+
}
|
|
6630
|
+
|
|
6587
6631
|
hasVideo(sessionId ) {
|
|
6588
6632
|
return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
|
|
6589
6633
|
}
|
|
@@ -6630,7 +6674,7 @@ class WebRTCClient extends Emitter {
|
|
|
6630
6674
|
}
|
|
6631
6675
|
|
|
6632
6676
|
startHeartbeat() {
|
|
6633
|
-
logger.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
6677
|
+
logger$3.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
|
|
6634
6678
|
if (!this.userAgent) {
|
|
6635
6679
|
this.heartbeat.stop();
|
|
6636
6680
|
return;
|
|
@@ -6643,7 +6687,7 @@ class WebRTCClient extends Emitter {
|
|
|
6643
6687
|
}
|
|
6644
6688
|
|
|
6645
6689
|
stopHeartbeat() {
|
|
6646
|
-
logger.info('sdk webrtc stop heartbeat');
|
|
6690
|
+
logger$3.info('sdk webrtc stop heartbeat');
|
|
6647
6691
|
this.heartbeat.stop();
|
|
6648
6692
|
}
|
|
6649
6693
|
|
|
@@ -6664,7 +6708,7 @@ class WebRTCClient extends Emitter {
|
|
|
6664
6708
|
}
|
|
6665
6709
|
|
|
6666
6710
|
attemptReconnection() {
|
|
6667
|
-
logger.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
6711
|
+
logger$3.info('attempt reconnection', { userAgent: !!this.userAgent });
|
|
6668
6712
|
if (!this.userAgent) {
|
|
6669
6713
|
return;
|
|
6670
6714
|
}
|
|
@@ -6689,7 +6733,7 @@ class WebRTCClient extends Emitter {
|
|
|
6689
6733
|
return;
|
|
6690
6734
|
}
|
|
6691
6735
|
|
|
6692
|
-
logger.info('setting local media stream', {
|
|
6736
|
+
logger$3.info('setting local media stream', {
|
|
6693
6737
|
sipSessionId,
|
|
6694
6738
|
tracks: newStream ? newStream.getTracks() : null,
|
|
6695
6739
|
});
|
|
@@ -6706,7 +6750,7 @@ class WebRTCClient extends Emitter {
|
|
|
6706
6750
|
|
|
6707
6751
|
const oldStream = this.getLocalStream(sipSessionId);
|
|
6708
6752
|
|
|
6709
|
-
logger.info('updating local stream', {
|
|
6753
|
+
logger$3.info('updating local stream', {
|
|
6710
6754
|
sipSessionId,
|
|
6711
6755
|
oldStream: !!oldStream,
|
|
6712
6756
|
tracks: newStream.getTracks(),
|
|
@@ -6726,7 +6770,7 @@ class WebRTCClient extends Emitter {
|
|
|
6726
6770
|
const remoteStream = this.getRemoteStream(sessionId);
|
|
6727
6771
|
const pc = this.getPeerConnection(sessionId);
|
|
6728
6772
|
|
|
6729
|
-
logger.info('Updating remote stream', {
|
|
6773
|
+
logger$3.info('Updating remote stream', {
|
|
6730
6774
|
sessionId,
|
|
6731
6775
|
tracks: remoteStream ? remoteStream.getTracks() : null,
|
|
6732
6776
|
receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
|
|
@@ -6752,7 +6796,7 @@ class WebRTCClient extends Emitter {
|
|
|
6752
6796
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
6753
6797
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
6754
6798
|
|
|
6755
|
-
logger.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
6799
|
+
logger$3.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
6756
6800
|
|
|
6757
6801
|
return {
|
|
6758
6802
|
constraints: {
|
|
@@ -6801,7 +6845,7 @@ class WebRTCClient extends Emitter {
|
|
|
6801
6845
|
}
|
|
6802
6846
|
|
|
6803
6847
|
_onTransportError() {
|
|
6804
|
-
logger.error('on transport error');
|
|
6848
|
+
logger$3.error('on transport error');
|
|
6805
6849
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
6806
6850
|
this.attemptReconnection();
|
|
6807
6851
|
}
|
|
@@ -6810,7 +6854,7 @@ class WebRTCClient extends Emitter {
|
|
|
6810
6854
|
const body = message && typeof message === 'object' ? message.data : message;
|
|
6811
6855
|
if (body && body.indexOf('200 OK') !== -1) {
|
|
6812
6856
|
if (this.hasHeartbeat()) {
|
|
6813
|
-
logger.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
6857
|
+
logger$3.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
|
|
6814
6858
|
|
|
6815
6859
|
this.heartbeat.onHeartbeat();
|
|
6816
6860
|
if (this.heartbeatCb) {
|
|
@@ -6821,7 +6865,7 @@ class WebRTCClient extends Emitter {
|
|
|
6821
6865
|
}
|
|
6822
6866
|
|
|
6823
6867
|
async _onHeartbeatTimeout() {
|
|
6824
|
-
logger.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
6868
|
+
logger$3.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
|
|
6825
6869
|
|
|
6826
6870
|
if (this.heartbeatTimeoutCb) {
|
|
6827
6871
|
this.heartbeatTimeoutCb();
|
|
@@ -6833,7 +6877,7 @@ class WebRTCClient extends Emitter {
|
|
|
6833
6877
|
try {
|
|
6834
6878
|
await this.userAgent.transport.disconnect();
|
|
6835
6879
|
} catch (e) {
|
|
6836
|
-
logger.error('Transport disconnection after heartbeat timeout, error', e);
|
|
6880
|
+
logger$3.error('Transport disconnection after heartbeat timeout, error', e);
|
|
6837
6881
|
}
|
|
6838
6882
|
}
|
|
6839
6883
|
|
|
@@ -6866,31 +6910,31 @@ class WebRTCClient extends Emitter {
|
|
|
6866
6910
|
}
|
|
6867
6911
|
|
|
6868
6912
|
_connectIfNeeded() {
|
|
6869
|
-
logger.info('connect if needed, checking', { connected: this.isConnected() });
|
|
6913
|
+
logger$3.info('connect if needed, checking', { connected: this.isConnected() });
|
|
6870
6914
|
if (!this.userAgent) {
|
|
6871
|
-
logger.info('need to recreate User Agent');
|
|
6915
|
+
logger$3.info('need to recreate User Agent');
|
|
6872
6916
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
6873
6917
|
}
|
|
6874
6918
|
|
|
6875
6919
|
if (this.isConnected()) {
|
|
6876
|
-
logger.info('webrtc sdk, already connected');
|
|
6920
|
+
logger$3.info('webrtc sdk, already connected');
|
|
6877
6921
|
return Promise.resolve();
|
|
6878
6922
|
}
|
|
6879
6923
|
|
|
6880
6924
|
if (this.isConnecting()) {
|
|
6881
|
-
logger.info('webrtc sdk, already connecting...');
|
|
6925
|
+
logger$3.info('webrtc sdk, already connecting...');
|
|
6882
6926
|
|
|
6883
6927
|
this.connectionPromise = this.userAgent.transport.connectPromise;
|
|
6884
6928
|
return this.connectionPromise;
|
|
6885
6929
|
}
|
|
6886
6930
|
|
|
6887
6931
|
if (this.connectionPromise) {
|
|
6888
|
-
logger.info('webrtc sdk, connection promise connecting...');
|
|
6932
|
+
logger$3.info('webrtc sdk, connection promise connecting...');
|
|
6889
6933
|
// $FlowFixMe
|
|
6890
6934
|
return this.connectionPromise;
|
|
6891
6935
|
}
|
|
6892
6936
|
|
|
6893
|
-
logger.info('WebRTC UA needs to connect');
|
|
6937
|
+
logger$3.info('WebRTC UA needs to connect');
|
|
6894
6938
|
|
|
6895
6939
|
// Force UA to reconnect
|
|
6896
6940
|
if (this.userAgent && this.userAgent.state !== userAgentState.UserAgentState.Stopped) {
|
|
@@ -7015,7 +7059,7 @@ class WebRTCClient extends Emitter {
|
|
|
7015
7059
|
|
|
7016
7060
|
sdh.peerConnectionDelegate = {
|
|
7017
7061
|
onicecandidateerror: (error ) => {
|
|
7018
|
-
logger.error('on icecandidate error', {
|
|
7062
|
+
logger$3.error('on icecandidate error', {
|
|
7019
7063
|
address: error.address,
|
|
7020
7064
|
port: error.port,
|
|
7021
7065
|
errorCode: error.errorCode,
|
|
@@ -7044,7 +7088,7 @@ class WebRTCClient extends Emitter {
|
|
|
7044
7088
|
updatedNumber = session.assertedIdentity.uri.normal.user;
|
|
7045
7089
|
updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
|
|
7046
7090
|
}
|
|
7047
|
-
logger.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
7091
|
+
logger$3.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
|
|
7048
7092
|
|
|
7049
7093
|
// Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
|
|
7050
7094
|
|
|
@@ -7065,7 +7109,7 @@ class WebRTCClient extends Emitter {
|
|
|
7065
7109
|
}
|
|
7066
7110
|
|
|
7067
7111
|
_onAccepted(session , sessionDialog , withEvent = true) {
|
|
7068
|
-
logger.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
7112
|
+
logger$3.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
|
|
7069
7113
|
|
|
7070
7114
|
this.storeSipSession(session);
|
|
7071
7115
|
|
|
@@ -7077,7 +7121,7 @@ class WebRTCClient extends Emitter {
|
|
|
7077
7121
|
const onTrack = (event ) => {
|
|
7078
7122
|
const isAudioOnly = this._isAudioOnly(session);
|
|
7079
7123
|
const { kind, label, readyState, id, muted } = event.track;
|
|
7080
|
-
logger.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
7124
|
+
logger$3.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
|
|
7081
7125
|
|
|
7082
7126
|
// Stop video track in audio only mode
|
|
7083
7127
|
if (isAudioOnly && kind === 'video') {
|
|
@@ -7094,6 +7138,7 @@ class WebRTCClient extends Emitter {
|
|
|
7094
7138
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
7095
7139
|
|
|
7096
7140
|
pc.oniceconnectionstatechange = () => {
|
|
7141
|
+
logger$3.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
7097
7142
|
if (pc.iceConnectionState === 'disconnected') {
|
|
7098
7143
|
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
7099
7144
|
}
|
|
@@ -7266,10 +7311,10 @@ class WebRTCClient extends Emitter {
|
|
|
7266
7311
|
|
|
7267
7312
|
_stopSendingStats(session ) {
|
|
7268
7313
|
const sessionId = this.getSipSessionId(session);
|
|
7269
|
-
logger.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
7314
|
+
logger$3.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
|
|
7270
7315
|
|
|
7271
7316
|
if (sessionId in this.statsIntervals) {
|
|
7272
|
-
logger.trace('Stop sending stats for call', { sessionId });
|
|
7317
|
+
logger$3.trace('Stop sending stats for call', { sessionId });
|
|
7273
7318
|
this.statsIntervals[sessionId]();
|
|
7274
7319
|
delete this.statsIntervals[sessionId];
|
|
7275
7320
|
}
|
|
@@ -7285,7 +7330,7 @@ class WebRTCClient extends Emitter {
|
|
|
7285
7330
|
try {
|
|
7286
7331
|
await this.userAgent.transport.disconnect();
|
|
7287
7332
|
} catch (e) {
|
|
7288
|
-
logger.error('WebRTC transport disconnect, error', e);
|
|
7333
|
+
logger$3.error('WebRTC transport disconnect, error', e);
|
|
7289
7334
|
}
|
|
7290
7335
|
}
|
|
7291
7336
|
}
|
|
@@ -7322,25 +7367,25 @@ class WebRTCClient extends Emitter {
|
|
|
7322
7367
|
|
|
7323
7368
|
stats.forEach(report => {
|
|
7324
7369
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
7325
|
-
audioBytesSent += report.bytesSent + report.headerBytesSent;
|
|
7370
|
+
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
7326
7371
|
}
|
|
7327
7372
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
7328
|
-
audioBytesSent += report.bytesSent;
|
|
7373
|
+
audioBytesSent += Number(report.bytesSent);
|
|
7329
7374
|
}
|
|
7330
7375
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
7331
|
-
videoBytesSent += report.bytesSent + report.headerBytesSent;
|
|
7376
|
+
videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
7332
7377
|
}
|
|
7333
7378
|
if (report.type === 'inbound-rtp' && report.kind === 'audio') {
|
|
7334
|
-
packetsLost += report.packetsLost;
|
|
7335
|
-
networkStats.packetsReceived = report.packetsReceived;
|
|
7336
|
-
audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
7379
|
+
packetsLost += Number(report.packetsLost);
|
|
7380
|
+
networkStats.packetsReceived = Number(report.packetsReceived);
|
|
7381
|
+
audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
7337
7382
|
}
|
|
7338
7383
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
7339
|
-
videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
7384
|
+
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
7340
7385
|
}
|
|
7341
7386
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
7342
7387
|
if ('framesPerSecond' in report) {
|
|
7343
|
-
networkStats.framesPerSecond = report.framesPerSecond;
|
|
7388
|
+
networkStats.framesPerSecond = Number(report.framesPerSecond);
|
|
7344
7389
|
}
|
|
7345
7390
|
if ('framerateMean' in report) {
|
|
7346
7391
|
// framerateMean is only available in FF
|
|
@@ -7348,32 +7393,36 @@ class WebRTCClient extends Emitter {
|
|
|
7348
7393
|
}
|
|
7349
7394
|
}
|
|
7350
7395
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
|
|
7351
|
-
packetsLost += report.packetsLost;
|
|
7352
|
-
networkStats.roundTripTime = report.roundTripTime;
|
|
7353
|
-
networkStats.jitter = report.jitter;
|
|
7396
|
+
packetsLost += Number(report.packetsLost);
|
|
7397
|
+
networkStats.roundTripTime = Number(report.roundTripTime);
|
|
7398
|
+
networkStats.jitter = Number(report.jitter);
|
|
7354
7399
|
}
|
|
7355
7400
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
|
|
7356
|
-
packetsLost += report.packetsLost;
|
|
7401
|
+
packetsLost += Number(report.packetsLost);
|
|
7357
7402
|
}
|
|
7358
7403
|
if (report.type === 'transport') {
|
|
7359
|
-
transportSent += report.bytesSent;
|
|
7360
|
-
transportReceived += report.bytesReceived;
|
|
7404
|
+
transportSent += Number(report.bytesSent);
|
|
7405
|
+
transportReceived += Number(report.bytesReceived);
|
|
7361
7406
|
}
|
|
7362
7407
|
});
|
|
7363
7408
|
|
|
7364
7409
|
networkStats.packetsLost = packetsLost;
|
|
7365
|
-
networkStats.
|
|
7410
|
+
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
7411
|
+
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
7412
|
+
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
7366
7413
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
7367
|
-
networkStats.
|
|
7368
|
-
networkStats.
|
|
7414
|
+
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
7415
|
+
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
7416
|
+
networkStats.totalVideoBytesReceived = videoBytesReceived;
|
|
7417
|
+
networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
|
|
7418
|
+
networkStats.totalTransportSent = transportSent - lastTransportSent;
|
|
7369
7419
|
networkStats.transportSent = transportSent;
|
|
7370
|
-
networkStats.
|
|
7371
|
-
|
|
7372
|
-
const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
|
|
7373
|
-
+ (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
|
|
7374
|
-
+ (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
|
|
7420
|
+
networkStats.totalTransportReceived = transportReceived;
|
|
7421
|
+
networkStats.transportReceived = transportReceived - lastTransportReceived;
|
|
7375
7422
|
|
|
7376
|
-
networkStats.bandwidth =
|
|
7423
|
+
networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
|
|
7424
|
+
+ networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
|
|
7425
|
+
+ networkStats.transportSent;
|
|
7377
7426
|
|
|
7378
7427
|
this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
|
|
7379
7428
|
this.sessionNetworkStats[sessionId].push(networkStats);
|