@wazo/sdk 0.37.19 → 0.37.23
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 +5 -5
- package/esm/__tests__/api-client.test.js +70 -5
- package/esm/__tests__/web-rtc-client.test.js +111 -67
- package/esm/api/agentd.js +25 -2
- package/esm/api/amid.js +25 -2
- package/esm/api/application.js +25 -2
- package/esm/api/auth.js +25 -2
- package/esm/api/call-logd.js +32 -2
- package/esm/api/calld.js +35 -2
- package/esm/api/chatd.js +32 -2
- package/esm/api/confd.js +47 -5
- package/esm/api/ctid-ng.js +35 -2
- package/esm/api/dird.js +28 -2
- package/esm/api/webhookd.js +25 -2
- package/esm/api-client.js +70 -5
- package/esm/checker/Checker.js +113 -67
- package/esm/checker/checks/aor.js +70 -5
- package/esm/checker/checks/api.js +70 -5
- package/esm/checker/checks/index.js +113 -67
- package/esm/checker/checks/wazo-websocket.js +27 -2
- package/esm/checker/checks/webrtc-transport.js +111 -67
- package/esm/checker/checks/webrtc.js +111 -67
- package/esm/domain/AdHocAPIConference.js +70 -5
- package/esm/domain/Call.js +3 -0
- package/esm/domain/CallLog.js +7 -0
- package/esm/domain/ChatMessage.js +4 -0
- package/esm/domain/ChatRoom.js +3 -0
- package/esm/domain/Contact.js +3 -0
- package/esm/domain/Features.js +70 -5
- package/esm/domain/Meeting.js +17 -1
- package/esm/domain/Phone/CTIPhone.js +74 -5
- package/esm/domain/Phone/WebRTCPhone.js +50 -16
- 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 +7 -0
- package/esm/domain/__tests__/Contact.test.js +3 -0
- package/esm/domain/__tests__/Voicemail.test.js +3 -0
- package/esm/index.js +147 -80
- package/esm/lib/WazoSessionDescriptionHandler.js +25 -40
- package/esm/service/CallApi.js +70 -5
- package/esm/service/IssueReporter.js +25 -2
- package/esm/service/__tests__/IssueReporter.test.js +25 -2
- package/esm/service/getApiClient.js +70 -5
- package/esm/simple/Auth.js +147 -80
- package/esm/simple/Configuration.js +147 -80
- package/esm/simple/Directory.js +70 -5
- package/esm/simple/Phone.js +147 -80
- package/esm/simple/Websocket.js +28 -2
- package/esm/simple/index.js +147 -80
- package/esm/simple/room/LocalParticipant.js +147 -80
- package/esm/simple/room/Participant.js +147 -80
- package/esm/simple/room/RemoteParticipant.js +147 -80
- package/esm/simple/room/Room.js +147 -80
- package/esm/simple/room/SipRoom.js +147 -80
- package/esm/simple/room/Stream.js +147 -80
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +147 -80
- package/esm/simple/utils.js +147 -80
- package/esm/utils/__tests__/api-requester.test.js +25 -2
- package/esm/utils/api-requester.js +25 -2
- package/esm/web-rtc-client.js +111 -67
- package/esm/websocket-client.js +28 -3
- package/lib/__tests__/api-client.test.js +70 -5
- package/lib/__tests__/web-rtc-client.test.js +111 -67
- package/lib/api/agentd.js +25 -2
- package/lib/api/amid.js +25 -2
- package/lib/api/application.js +25 -2
- package/lib/api/auth.js +25 -2
- package/lib/api/call-logd.js +32 -2
- package/lib/api/calld.js +35 -2
- package/lib/api/chatd.js +32 -2
- package/lib/api/confd.js +47 -5
- package/lib/api/ctid-ng.js +35 -2
- package/lib/api/dird.js +28 -2
- package/lib/api/webhookd.js +25 -2
- package/lib/api-client.js +70 -5
- package/lib/checker/Checker.js +113 -67
- package/lib/checker/checks/aor.js +70 -5
- package/lib/checker/checks/api.js +70 -5
- package/lib/checker/checks/index.js +113 -67
- package/lib/checker/checks/wazo-websocket.js +27 -2
- package/lib/checker/checks/webrtc-transport.js +111 -67
- package/lib/checker/checks/webrtc.js +111 -67
- package/lib/domain/AdHocAPIConference.js +70 -5
- package/lib/domain/Call.js +3 -0
- package/lib/domain/CallLog.js +7 -0
- package/lib/domain/ChatMessage.js +4 -0
- package/lib/domain/ChatRoom.js +3 -0
- package/lib/domain/Contact.js +3 -0
- package/lib/domain/Features.js +70 -5
- package/lib/domain/Meeting.js +17 -1
- package/lib/domain/Phone/CTIPhone.js +74 -5
- package/lib/domain/Phone/WebRTCPhone.js +50 -16
- 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 +7 -0
- package/lib/domain/__tests__/Contact.test.js +3 -0
- package/lib/domain/__tests__/Voicemail.test.js +3 -0
- package/lib/index.js +147 -80
- package/lib/lib/WazoSessionDescriptionHandler.js +25 -40
- package/lib/service/CallApi.js +70 -5
- package/lib/service/IssueReporter.js +25 -2
- package/lib/service/__tests__/IssueReporter.test.js +25 -2
- package/lib/service/getApiClient.js +70 -5
- package/lib/simple/Auth.js +147 -80
- package/lib/simple/Configuration.js +147 -80
- package/lib/simple/Directory.js +70 -5
- package/lib/simple/Phone.js +147 -80
- package/lib/simple/Websocket.js +28 -2
- package/lib/simple/index.js +147 -80
- package/lib/simple/room/LocalParticipant.js +147 -80
- package/lib/simple/room/Participant.js +147 -80
- package/lib/simple/room/RemoteParticipant.js +147 -80
- package/lib/simple/room/Room.js +147 -80
- package/lib/simple/room/SipRoom.js +147 -80
- package/lib/simple/room/Stream.js +147 -80
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +147 -80
- package/lib/simple/utils.js +147 -80
- package/lib/utils/__tests__/api-requester.test.js +25 -2
- package/lib/utils/api-requester.js +25 -2
- package/lib/web-rtc-client.js +111 -67
- package/lib/websocket-client.js +28 -2
- package/package.json +2 -2
- 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 +17 -1
- package/src/domain/Phone/CTIPhone.js +4 -0
- package/src/domain/Phone/Phone.js +2 -0
- package/src/domain/Phone/WebRTCPhone.js +25 -14
- package/src/domain/Recording.js +3 -0
- package/src/domain/Voicemail.js +3 -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/index.js
CHANGED
|
@@ -161,6 +161,7 @@ class IssueReporter {
|
|
|
161
161
|
|
|
162
162
|
|
|
163
163
|
|
|
164
|
+
|
|
164
165
|
|
|
165
166
|
constructor() {
|
|
166
167
|
addLevelsTo(this);
|
|
@@ -172,12 +173,17 @@ class IssueReporter {
|
|
|
172
173
|
this.bufferTimeout = null;
|
|
173
174
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
174
175
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
176
|
+
this._callback = null;
|
|
175
177
|
}
|
|
176
178
|
|
|
177
179
|
init() {
|
|
178
180
|
this._catchConsole();
|
|
179
181
|
}
|
|
180
182
|
|
|
183
|
+
setCallback(cb ) {
|
|
184
|
+
this._callback = cb;
|
|
185
|
+
}
|
|
186
|
+
|
|
181
187
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
182
188
|
this.remoteClientConfiguration = configuration;
|
|
183
189
|
}
|
|
@@ -213,6 +219,7 @@ class IssueReporter {
|
|
|
213
219
|
|
|
214
220
|
// Handle category label
|
|
215
221
|
let category = null;
|
|
222
|
+
let skipSendToRemote = false;
|
|
216
223
|
let extra = {};
|
|
217
224
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
218
225
|
category = args[0].split('=')[1];
|
|
@@ -228,6 +235,7 @@ class IssueReporter {
|
|
|
228
235
|
errorMessage: lastArg.message,
|
|
229
236
|
errorStack: lastArg.stack,
|
|
230
237
|
errorType: lastArg.constructor.name,
|
|
238
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
231
239
|
};
|
|
232
240
|
} else {
|
|
233
241
|
extra = lastArg;
|
|
@@ -236,6 +244,11 @@ class IssueReporter {
|
|
|
236
244
|
args.splice(1, 1);
|
|
237
245
|
}
|
|
238
246
|
|
|
247
|
+
if (extra.skipSendToRemote) {
|
|
248
|
+
skipSendToRemote = true;
|
|
249
|
+
delete extra.skipSendToRemote;
|
|
250
|
+
}
|
|
251
|
+
|
|
239
252
|
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
240
253
|
const message = args.join(', ');
|
|
241
254
|
let consoleMessage = message;
|
|
@@ -256,7 +269,13 @@ class IssueReporter {
|
|
|
256
269
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
257
270
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
258
271
|
|
|
259
|
-
this.
|
|
272
|
+
if (this._callback) {
|
|
273
|
+
this._callback(level, consoleMessage);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (!skipSendToRemote) {
|
|
277
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
278
|
+
}
|
|
260
279
|
}
|
|
261
280
|
|
|
262
281
|
logRequest(url , options , response , start ) {
|
|
@@ -401,7 +420,11 @@ class IssueReporter {
|
|
|
401
420
|
},
|
|
402
421
|
// $FlowFixMe
|
|
403
422
|
body,
|
|
404
|
-
}).catch(() => {
|
|
423
|
+
}).catch((e ) => {
|
|
424
|
+
// $FlowFixMe
|
|
425
|
+
e.skipSendToRemote = true;
|
|
426
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
427
|
+
|
|
405
428
|
setTimeout(() => {
|
|
406
429
|
if (isArray) {
|
|
407
430
|
payload = payload.map(message => {
|
|
@@ -1539,6 +1562,9 @@ class Contact {
|
|
|
1539
1562
|
}
|
|
1540
1563
|
|
|
1541
1564
|
static parseMany(response ) {
|
|
1565
|
+
if (!response || !response.results) {
|
|
1566
|
+
return [];
|
|
1567
|
+
}
|
|
1542
1568
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
1543
1569
|
}
|
|
1544
1570
|
|
|
@@ -2645,11 +2671,27 @@ class Meeting {
|
|
|
2645
2671
|
});
|
|
2646
2672
|
}
|
|
2647
2673
|
|
|
2674
|
+
static parseMany(items ) {
|
|
2675
|
+
if (!items) {
|
|
2676
|
+
return [];
|
|
2677
|
+
}
|
|
2678
|
+
return items.map(plain => Meeting.parse(plain));
|
|
2679
|
+
}
|
|
2680
|
+
|
|
2648
2681
|
static newFrom(meeting ) {
|
|
2649
2682
|
return newFrom(meeting, Meeting);
|
|
2650
2683
|
}
|
|
2651
2684
|
|
|
2652
|
-
constructor({
|
|
2685
|
+
constructor({
|
|
2686
|
+
uuid,
|
|
2687
|
+
name,
|
|
2688
|
+
guestSipAuthorization,
|
|
2689
|
+
ownerUuids,
|
|
2690
|
+
port,
|
|
2691
|
+
uri,
|
|
2692
|
+
number,
|
|
2693
|
+
persistent,
|
|
2694
|
+
} = {}) {
|
|
2653
2695
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
2654
2696
|
this.uri = uri;
|
|
2655
2697
|
this.name = name;
|
|
@@ -2735,8 +2777,11 @@ var confdMethods = (client , baseUrl ) => ({
|
|
|
2735
2777
|
}
|
|
2736
2778
|
},
|
|
2737
2779
|
|
|
2738
|
-
|
|
2739
|
-
client.
|
|
2780
|
+
getMyMeetings: () =>
|
|
2781
|
+
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
2782
|
+
|
|
2783
|
+
createMyMeeting: (name , persistent ) =>
|
|
2784
|
+
client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
|
|
2740
2785
|
|
|
2741
2786
|
deleteMyMeeting: (meetingUuid ) =>
|
|
2742
2787
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
|
@@ -2832,6 +2877,10 @@ class ChatMessage {
|
|
|
2832
2877
|
|
|
2833
2878
|
|
|
2834
2879
|
static parseMany(plain ) {
|
|
2880
|
+
if (!plain || !plain.items) {
|
|
2881
|
+
return [];
|
|
2882
|
+
}
|
|
2883
|
+
|
|
2835
2884
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
2836
2885
|
}
|
|
2837
2886
|
|
|
@@ -2941,6 +2990,9 @@ class Voicemail {
|
|
|
2941
2990
|
}
|
|
2942
2991
|
|
|
2943
2992
|
static parseMany(plain ) {
|
|
2993
|
+
if (!plain) {
|
|
2994
|
+
return [];
|
|
2995
|
+
}
|
|
2944
2996
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
2945
2997
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
2946
2998
|
|
|
@@ -3050,6 +3102,9 @@ class Call {
|
|
|
3050
3102
|
|
|
3051
3103
|
|
|
3052
3104
|
static parseMany(plain ) {
|
|
3105
|
+
if (!plain) {
|
|
3106
|
+
return [];
|
|
3107
|
+
}
|
|
3053
3108
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
3054
3109
|
}
|
|
3055
3110
|
|
|
@@ -3593,6 +3648,9 @@ class Recording {
|
|
|
3593
3648
|
|
|
3594
3649
|
|
|
3595
3650
|
static parseMany(recordings = []) {
|
|
3651
|
+
if (!recordings) {
|
|
3652
|
+
return [];
|
|
3653
|
+
}
|
|
3596
3654
|
return recordings.map(item => Recording.parse(item));
|
|
3597
3655
|
}
|
|
3598
3656
|
|
|
@@ -3694,6 +3752,10 @@ class CallLog {
|
|
|
3694
3752
|
}
|
|
3695
3753
|
|
|
3696
3754
|
static parseMany(plain ) {
|
|
3755
|
+
if (!plain || !plain.items) {
|
|
3756
|
+
return [];
|
|
3757
|
+
}
|
|
3758
|
+
|
|
3697
3759
|
return plain.items.map(item => CallLog.parse(item));
|
|
3698
3760
|
}
|
|
3699
3761
|
|
|
@@ -4346,6 +4408,10 @@ class CTIPhone extends Emitter {
|
|
|
4346
4408
|
return false;
|
|
4347
4409
|
}
|
|
4348
4410
|
|
|
4411
|
+
hasAVideoTrack() {
|
|
4412
|
+
return false;
|
|
4413
|
+
}
|
|
4414
|
+
|
|
4349
4415
|
getLocalStreamForCall() {
|
|
4350
4416
|
return null;
|
|
4351
4417
|
}
|
|
@@ -4739,6 +4805,9 @@ class ChatRoom {
|
|
|
4739
4805
|
|
|
4740
4806
|
|
|
4741
4807
|
static parseMany(plain ) {
|
|
4808
|
+
if (!plain || !plain.items) {
|
|
4809
|
+
return [];
|
|
4810
|
+
}
|
|
4742
4811
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
4743
4812
|
}
|
|
4744
4813
|
|
|
@@ -5462,10 +5531,6 @@ const getSrflxOrRelay = (candidates ) =>
|
|
|
5462
5531
|
candidates
|
|
5463
5532
|
.filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
|
|
5464
5533
|
|
|
5465
|
-
const areCandidateValid = (candidates ) =>
|
|
5466
|
-
getSrflxOrRelay(candidates)
|
|
5467
|
-
.length > 0;
|
|
5468
|
-
|
|
5469
5534
|
const getVideoDirection = (sdp ) => {
|
|
5470
5535
|
const parsedSdp = sdpParser__default['default'].parse(sdp);
|
|
5471
5536
|
const videoMedia = parsedSdp.media.find(media => media.type === 'video');
|
|
@@ -5518,8 +5583,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
5518
5583
|
/* global RTCSessionDescriptionInit, navigator */
|
|
5519
5584
|
|
|
5520
5585
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
5521
|
-
const MAX_WAIT_FOR_ICE_TRIES = 20;
|
|
5522
|
-
const WAIT_FOR_ICE_TIMEOUT = 500;
|
|
5523
5586
|
|
|
5524
5587
|
// Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
|
|
5525
5588
|
const wazoMediaStreamFactory = (constraints ) => {
|
|
@@ -5709,38 +5772,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
5709
5772
|
this._peerConnection = undefined;
|
|
5710
5773
|
}
|
|
5711
5774
|
|
|
5712
|
-
async _waitForValidGatheredIce() {
|
|
5713
|
-
let tries = 0;
|
|
5714
|
-
|
|
5715
|
-
while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
|
|
5716
|
-
wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
|
|
5717
|
-
tries,
|
|
5718
|
-
max: MAX_WAIT_FOR_ICE_TRIES,
|
|
5719
|
-
});
|
|
5720
|
-
|
|
5721
|
-
tries++;
|
|
5722
|
-
|
|
5723
|
-
// eslint-disable-next-line no-await-in-loop
|
|
5724
|
-
await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
|
|
5725
|
-
}
|
|
5726
|
-
|
|
5727
|
-
if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
|
|
5728
|
-
const errorMsg = 'No valid candidates found, can\'t answer the call';
|
|
5729
|
-
const error = new Error(errorMsg);
|
|
5730
|
-
wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
|
|
5731
|
-
|
|
5732
|
-
// Emit an error, because sip.js catches the exception and switch to status Terminated.
|
|
5733
|
-
this.eventEmitter.emit('error', error);
|
|
5734
|
-
|
|
5735
|
-
wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
5736
|
-
}
|
|
5737
|
-
|
|
5738
|
-
// eslint-disable-next-line
|
|
5739
|
-
wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
5740
|
-
|
|
5741
|
-
return this.getLocalSessionDescription();
|
|
5742
|
-
}
|
|
5743
|
-
|
|
5744
5775
|
// Overridden to send `inactive` in conference
|
|
5745
5776
|
updateDirection(options , isConference = false,
|
|
5746
5777
|
audioOnly = false) {
|
|
@@ -6533,7 +6564,9 @@ class WebRTCClient extends Emitter {
|
|
|
6533
6564
|
const inviteOptions = {
|
|
6534
6565
|
requestDelegate: {
|
|
6535
6566
|
onAccept: (response ) => {
|
|
6536
|
-
session.sessionDescriptionHandler.peerConnection
|
|
6567
|
+
if (session.sessionDescriptionHandler.peerConnection) {
|
|
6568
|
+
session.sessionDescriptionHandler.peerConnection.sfu = conference;
|
|
6569
|
+
}
|
|
6537
6570
|
this._onAccepted(session, response.session, true);
|
|
6538
6571
|
},
|
|
6539
6572
|
onReject: (response ) => {
|
|
@@ -7405,6 +7438,16 @@ class WebRTCClient extends Emitter {
|
|
|
7405
7438
|
return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
|
|
7406
7439
|
}
|
|
7407
7440
|
|
|
7441
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
7442
|
+
getRemoteVideoStreamFromPc(sessionId ) {
|
|
7443
|
+
const pc = this.getPeerConnection(sessionId);
|
|
7444
|
+
if (!pc) {
|
|
7445
|
+
return null;
|
|
7446
|
+
}
|
|
7447
|
+
|
|
7448
|
+
return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
|
|
7449
|
+
}
|
|
7450
|
+
|
|
7408
7451
|
hasVideo(sessionId ) {
|
|
7409
7452
|
return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
|
|
7410
7453
|
}
|
|
@@ -7915,6 +7958,7 @@ class WebRTCClient extends Emitter {
|
|
|
7915
7958
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
7916
7959
|
|
|
7917
7960
|
pc.oniceconnectionstatechange = () => {
|
|
7961
|
+
logger$9.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
7918
7962
|
if (pc.iceConnectionState === 'disconnected') {
|
|
7919
7963
|
this.eventEmitter.emit(ON_DISCONNECTED$1);
|
|
7920
7964
|
}
|
|
@@ -8143,25 +8187,25 @@ class WebRTCClient extends Emitter {
|
|
|
8143
8187
|
|
|
8144
8188
|
stats.forEach(report => {
|
|
8145
8189
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
8146
|
-
audioBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8190
|
+
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8147
8191
|
}
|
|
8148
8192
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
8149
|
-
audioBytesSent += report.bytesSent;
|
|
8193
|
+
audioBytesSent += Number(report.bytesSent);
|
|
8150
8194
|
}
|
|
8151
8195
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8152
|
-
videoBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8196
|
+
videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8153
8197
|
}
|
|
8154
8198
|
if (report.type === 'inbound-rtp' && report.kind === 'audio') {
|
|
8155
|
-
packetsLost += report.packetsLost;
|
|
8156
|
-
networkStats.packetsReceived = report.packetsReceived;
|
|
8157
|
-
audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8199
|
+
packetsLost += Number(report.packetsLost);
|
|
8200
|
+
networkStats.packetsReceived = Number(report.packetsReceived);
|
|
8201
|
+
audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8158
8202
|
}
|
|
8159
8203
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
8160
|
-
videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8204
|
+
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8161
8205
|
}
|
|
8162
8206
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8163
8207
|
if ('framesPerSecond' in report) {
|
|
8164
|
-
networkStats.framesPerSecond = report.framesPerSecond;
|
|
8208
|
+
networkStats.framesPerSecond = Number(report.framesPerSecond);
|
|
8165
8209
|
}
|
|
8166
8210
|
if ('framerateMean' in report) {
|
|
8167
8211
|
// framerateMean is only available in FF
|
|
@@ -8169,32 +8213,36 @@ class WebRTCClient extends Emitter {
|
|
|
8169
8213
|
}
|
|
8170
8214
|
}
|
|
8171
8215
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
|
|
8172
|
-
packetsLost += report.packetsLost;
|
|
8173
|
-
networkStats.roundTripTime = report.roundTripTime;
|
|
8174
|
-
networkStats.jitter = report.jitter;
|
|
8216
|
+
packetsLost += Number(report.packetsLost);
|
|
8217
|
+
networkStats.roundTripTime = Number(report.roundTripTime);
|
|
8218
|
+
networkStats.jitter = Number(report.jitter);
|
|
8175
8219
|
}
|
|
8176
8220
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
|
|
8177
|
-
packetsLost += report.packetsLost;
|
|
8221
|
+
packetsLost += Number(report.packetsLost);
|
|
8178
8222
|
}
|
|
8179
8223
|
if (report.type === 'transport') {
|
|
8180
|
-
transportSent += report.bytesSent;
|
|
8181
|
-
transportReceived += report.bytesReceived;
|
|
8224
|
+
transportSent += Number(report.bytesSent);
|
|
8225
|
+
transportReceived += Number(report.bytesReceived);
|
|
8182
8226
|
}
|
|
8183
8227
|
});
|
|
8184
8228
|
|
|
8185
8229
|
networkStats.packetsLost = packetsLost;
|
|
8186
|
-
networkStats.
|
|
8230
|
+
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
8231
|
+
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
8232
|
+
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
8187
8233
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
8188
|
-
networkStats.
|
|
8189
|
-
networkStats.
|
|
8234
|
+
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
8235
|
+
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
8236
|
+
networkStats.totalVideoBytesReceived = videoBytesReceived;
|
|
8237
|
+
networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
|
|
8238
|
+
networkStats.totalTransportSent = transportSent - lastTransportSent;
|
|
8190
8239
|
networkStats.transportSent = transportSent;
|
|
8191
|
-
networkStats.
|
|
8240
|
+
networkStats.totalTransportReceived = transportReceived;
|
|
8241
|
+
networkStats.transportReceived = transportReceived - lastTransportReceived;
|
|
8192
8242
|
|
|
8193
|
-
|
|
8194
|
-
+
|
|
8195
|
-
+
|
|
8196
|
-
|
|
8197
|
-
networkStats.bandwidth = bandwidth;
|
|
8243
|
+
networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
|
|
8244
|
+
+ networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
|
|
8245
|
+
+ networkStats.transportSent;
|
|
8198
8246
|
|
|
8199
8247
|
this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
|
|
8200
8248
|
this.sessionNetworkStats[sessionId].push(networkStats);
|
|
@@ -8290,6 +8338,7 @@ const AGENT_PAUSED = 'agent_paused';
|
|
|
8290
8338
|
const AGENT_UNPAUSED = 'agent_unpaused';
|
|
8291
8339
|
const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
|
|
8292
8340
|
const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
|
|
8341
|
+
const MEETING_USER_PROGRESS = 'meeting_user_progress';
|
|
8293
8342
|
|
|
8294
8343
|
const BLACKLIST_EVENTS = [
|
|
8295
8344
|
CHAT_MESSAGE_SENT,
|
|
@@ -8640,6 +8689,7 @@ WebSocketClient.eventLists = [
|
|
|
8640
8689
|
AGENT_UNPAUSED,
|
|
8641
8690
|
CONFERENCE_ADHOC_PARTICIPANT_LEFT,
|
|
8642
8691
|
CONFERENCE_ADHOC_DELETED,
|
|
8692
|
+
MEETING_USER_PROGRESS,
|
|
8643
8693
|
];
|
|
8644
8694
|
|
|
8645
8695
|
var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
@@ -8710,6 +8760,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
|
|
|
8710
8760
|
AGENT_UNPAUSED: AGENT_UNPAUSED,
|
|
8711
8761
|
CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
|
|
8712
8762
|
CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
|
|
8763
|
+
MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
|
|
8713
8764
|
HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
|
|
8714
8765
|
'default': WebSocketClient
|
|
8715
8766
|
});
|
|
@@ -9466,7 +9517,10 @@ class WebRTCPhone extends Emitter {
|
|
|
9466
9517
|
|
|
9467
9518
|
onCancel(message);
|
|
9468
9519
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
9469
|
-
|
|
9520
|
+
const callSession = this._createCallSession(sipSession);
|
|
9521
|
+
delete this.callSessions[callSession.getId()];
|
|
9522
|
+
|
|
9523
|
+
this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
|
|
9470
9524
|
};
|
|
9471
9525
|
} else if (sipSession instanceof invitation.Invitation) {
|
|
9472
9526
|
console.warn('sipSession._onCancel not found, please update the wazo SDK accordingly');
|
|
@@ -9495,9 +9549,11 @@ class WebRTCPhone extends Emitter {
|
|
|
9495
9549
|
case sessionState.SessionState.Terminated: {
|
|
9496
9550
|
logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
|
|
9497
9551
|
|
|
9552
|
+
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
9553
|
+
const callSession = this._createCallSession(sipSession);
|
|
9498
9554
|
const wasCurrentSession = this._onCallTerminated(sipSession);
|
|
9499
9555
|
|
|
9500
|
-
return this.eventEmitter.emit(ON_CALL_ENDED,
|
|
9556
|
+
return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
|
|
9501
9557
|
}
|
|
9502
9558
|
}
|
|
9503
9559
|
});
|
|
@@ -9645,18 +9701,20 @@ class WebRTCPhone extends Emitter {
|
|
|
9645
9701
|
screenTrack,
|
|
9646
9702
|
});
|
|
9647
9703
|
|
|
9648
|
-
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
|
|
9653
|
-
|
|
9704
|
+
if (screenTrack) {
|
|
9705
|
+
screenTrack.onended = () => {
|
|
9706
|
+
logger$7.info('WebRTC phone - on screenshare ended', {
|
|
9707
|
+
hadVideo,
|
|
9708
|
+
id: this.getSipSessionId(sipSession),
|
|
9709
|
+
screenTrack,
|
|
9710
|
+
});
|
|
9654
9711
|
|
|
9655
|
-
|
|
9656
|
-
|
|
9657
|
-
|
|
9658
|
-
|
|
9659
|
-
|
|
9712
|
+
this.eventEmitter.emit(
|
|
9713
|
+
ON_SHARE_SCREEN_ENDING,
|
|
9714
|
+
this._createCallSession(sipSession, callSession),
|
|
9715
|
+
);
|
|
9716
|
+
};
|
|
9717
|
+
}
|
|
9660
9718
|
|
|
9661
9719
|
this.currentScreenShare = {
|
|
9662
9720
|
stream: screenStream,
|
|
@@ -10445,6 +10503,10 @@ class WebRTCPhone extends Emitter {
|
|
|
10445
10503
|
return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
|
|
10446
10504
|
}
|
|
10447
10505
|
|
|
10506
|
+
getRemoteVideoStreamFromPc(callSession ) {
|
|
10507
|
+
return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
|
|
10508
|
+
}
|
|
10509
|
+
|
|
10448
10510
|
hasRemoteVideo(callSession ) {
|
|
10449
10511
|
return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
|
|
10450
10512
|
}
|
|
@@ -12163,6 +12225,11 @@ class Phone extends Emitter {
|
|
|
12163
12225
|
return this.getRemoteVideoStream(callSession);
|
|
12164
12226
|
}
|
|
12165
12227
|
|
|
12228
|
+
// Useful in a react-native environment when remoteMediaStream is not updated
|
|
12229
|
+
getRemoteVideoStreamFromPc(callSession ) {
|
|
12230
|
+
return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
|
|
12231
|
+
}
|
|
12232
|
+
|
|
12166
12233
|
hasVideo(callSession ) {
|
|
12167
12234
|
return this.phone ? this.phone.hasVideo(callSession) : false;
|
|
12168
12235
|
}
|
|
@@ -107,6 +107,7 @@ class IssueReporter {
|
|
|
107
107
|
|
|
108
108
|
|
|
109
109
|
|
|
110
|
+
|
|
110
111
|
|
|
111
112
|
constructor() {
|
|
112
113
|
addLevelsTo(this);
|
|
@@ -118,12 +119,17 @@ class IssueReporter {
|
|
|
118
119
|
this.bufferTimeout = null;
|
|
119
120
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
120
121
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
122
|
+
this._callback = null;
|
|
121
123
|
}
|
|
122
124
|
|
|
123
125
|
init() {
|
|
124
126
|
this._catchConsole();
|
|
125
127
|
}
|
|
126
128
|
|
|
129
|
+
setCallback(cb ) {
|
|
130
|
+
this._callback = cb;
|
|
131
|
+
}
|
|
132
|
+
|
|
127
133
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
128
134
|
this.remoteClientConfiguration = configuration;
|
|
129
135
|
}
|
|
@@ -159,6 +165,7 @@ class IssueReporter {
|
|
|
159
165
|
|
|
160
166
|
// Handle category label
|
|
161
167
|
let category = null;
|
|
168
|
+
let skipSendToRemote = false;
|
|
162
169
|
let extra = {};
|
|
163
170
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
164
171
|
category = args[0].split('=')[1];
|
|
@@ -174,6 +181,7 @@ class IssueReporter {
|
|
|
174
181
|
errorMessage: lastArg.message,
|
|
175
182
|
errorStack: lastArg.stack,
|
|
176
183
|
errorType: lastArg.constructor.name,
|
|
184
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
177
185
|
};
|
|
178
186
|
} else {
|
|
179
187
|
extra = lastArg;
|
|
@@ -182,6 +190,11 @@ class IssueReporter {
|
|
|
182
190
|
args.splice(1, 1);
|
|
183
191
|
}
|
|
184
192
|
|
|
193
|
+
if (extra.skipSendToRemote) {
|
|
194
|
+
skipSendToRemote = true;
|
|
195
|
+
delete extra.skipSendToRemote;
|
|
196
|
+
}
|
|
197
|
+
|
|
185
198
|
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
186
199
|
const message = args.join(', ');
|
|
187
200
|
let consoleMessage = message;
|
|
@@ -202,7 +215,13 @@ class IssueReporter {
|
|
|
202
215
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
203
216
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
204
217
|
|
|
205
|
-
this.
|
|
218
|
+
if (this._callback) {
|
|
219
|
+
this._callback(level, consoleMessage);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (!skipSendToRemote) {
|
|
223
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
224
|
+
}
|
|
206
225
|
}
|
|
207
226
|
|
|
208
227
|
logRequest(url , options , response , start ) {
|
|
@@ -347,7 +366,11 @@ class IssueReporter {
|
|
|
347
366
|
},
|
|
348
367
|
// $FlowFixMe
|
|
349
368
|
body,
|
|
350
|
-
}).catch(() => {
|
|
369
|
+
}).catch((e ) => {
|
|
370
|
+
// $FlowFixMe
|
|
371
|
+
e.skipSendToRemote = true;
|
|
372
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
373
|
+
|
|
351
374
|
setTimeout(() => {
|
|
352
375
|
if (isArray) {
|
|
353
376
|
payload = payload.map(message => {
|
|
@@ -396,10 +419,6 @@ const getSrflxOrRelay = (candidates ) =>
|
|
|
396
419
|
candidates
|
|
397
420
|
.filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
|
|
398
421
|
|
|
399
|
-
const areCandidateValid = (candidates ) =>
|
|
400
|
-
getSrflxOrRelay(candidates)
|
|
401
|
-
.length > 0;
|
|
402
|
-
|
|
403
422
|
const fixSdp = (sdp , candidates , forcePort = true) => {
|
|
404
423
|
const parsedSdp = sdpParser__default['default'].parse(sdp);
|
|
405
424
|
const mainCandidate = getSrflxOrRelay(candidates)[0];
|
|
@@ -431,8 +450,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
431
450
|
/* global RTCSessionDescriptionInit, navigator */
|
|
432
451
|
|
|
433
452
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
434
|
-
const MAX_WAIT_FOR_ICE_TRIES = 20;
|
|
435
|
-
const WAIT_FOR_ICE_TIMEOUT = 500;
|
|
436
453
|
|
|
437
454
|
// Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
|
|
438
455
|
const wazoMediaStreamFactory = (constraints ) => {
|
|
@@ -622,38 +639,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
622
639
|
this._peerConnection = undefined;
|
|
623
640
|
}
|
|
624
641
|
|
|
625
|
-
async _waitForValidGatheredIce() {
|
|
626
|
-
let tries = 0;
|
|
627
|
-
|
|
628
|
-
while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
|
|
629
|
-
wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
|
|
630
|
-
tries,
|
|
631
|
-
max: MAX_WAIT_FOR_ICE_TRIES,
|
|
632
|
-
});
|
|
633
|
-
|
|
634
|
-
tries++;
|
|
635
|
-
|
|
636
|
-
// eslint-disable-next-line no-await-in-loop
|
|
637
|
-
await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
|
|
641
|
-
const errorMsg = 'No valid candidates found, can\'t answer the call';
|
|
642
|
-
const error = new Error(errorMsg);
|
|
643
|
-
wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
|
|
644
|
-
|
|
645
|
-
// Emit an error, because sip.js catches the exception and switch to status Terminated.
|
|
646
|
-
this.eventEmitter.emit('error', error);
|
|
647
|
-
|
|
648
|
-
wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
// eslint-disable-next-line
|
|
652
|
-
wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
653
|
-
|
|
654
|
-
return this.getLocalSessionDescription();
|
|
655
|
-
}
|
|
656
|
-
|
|
657
642
|
// Overridden to send `inactive` in conference
|
|
658
643
|
updateDirection(options , isConference = false,
|
|
659
644
|
audioOnly = false) {
|