@wazo/sdk 0.37.21 → 0.37.25
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 +36 -5
- package/esm/__tests__/web-rtc-client.test.js +77 -66
- package/esm/api/call-logd.js +7 -0
- package/esm/api/calld.js +10 -0
- package/esm/api/chatd.js +7 -0
- package/esm/api/confd.js +13 -5
- package/esm/api/ctid-ng.js +10 -0
- package/esm/api/dird.js +3 -0
- package/esm/api-client.js +36 -5
- package/esm/checker/Checker.js +77 -66
- package/esm/checker/checks/aor.js +36 -5
- package/esm/checker/checks/api.js +36 -5
- package/esm/checker/checks/index.js +77 -66
- package/esm/checker/checks/webrtc-transport.js +77 -66
- package/esm/checker/checks/webrtc.js +77 -66
- package/esm/domain/AdHocAPIConference.js +36 -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 +36 -5
- package/esm/domain/Meeting.js +15 -5
- package/esm/domain/Phone/CTIPhone.js +40 -5
- package/esm/domain/Phone/WebRTCPhone.js +45 -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__/Meeting.test.js +144 -0
- package/esm/domain/__tests__/Voicemail.test.js +3 -0
- package/esm/index.js +125 -81
- package/esm/lib/WazoSessionDescriptionHandler.js +0 -38
- package/esm/service/CallApi.js +36 -5
- package/esm/service/getApiClient.js +36 -5
- package/esm/simple/Auth.js +125 -81
- package/esm/simple/Configuration.js +125 -81
- package/esm/simple/Directory.js +36 -5
- package/esm/simple/Phone.js +125 -81
- package/esm/simple/index.js +125 -81
- package/esm/simple/room/LocalParticipant.js +125 -81
- package/esm/simple/room/Participant.js +125 -81
- package/esm/simple/room/RemoteParticipant.js +125 -81
- package/esm/simple/room/Room.js +125 -81
- package/esm/simple/room/SipRoom.js +125 -81
- package/esm/simple/room/Stream.js +125 -81
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +125 -81
- package/esm/simple/utils.js +125 -81
- package/esm/types/WebSocketMessage.js +1 -1
- package/esm/web-rtc-client.js +77 -66
- package/lib/__tests__/api-client.test.js +36 -5
- package/lib/__tests__/web-rtc-client.test.js +77 -66
- package/lib/api/call-logd.js +7 -0
- package/lib/api/calld.js +10 -0
- package/lib/api/chatd.js +7 -0
- package/lib/api/confd.js +13 -5
- package/lib/api/ctid-ng.js +10 -0
- package/lib/api/dird.js +3 -0
- package/lib/api-client.js +36 -5
- package/lib/checker/Checker.js +77 -66
- package/lib/checker/checks/aor.js +36 -5
- package/lib/checker/checks/api.js +36 -5
- package/lib/checker/checks/index.js +77 -66
- package/lib/checker/checks/webrtc-transport.js +77 -66
- package/lib/checker/checks/webrtc.js +77 -66
- package/lib/domain/AdHocAPIConference.js +36 -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 +36 -5
- package/lib/domain/Meeting.js +19 -5
- package/lib/domain/Phone/CTIPhone.js +40 -5
- package/lib/domain/Phone/WebRTCPhone.js +45 -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__/Meeting.test.js +150 -0
- package/lib/domain/__tests__/Voicemail.test.js +3 -0
- package/lib/index.js +125 -81
- package/lib/lib/WazoSessionDescriptionHandler.js +0 -38
- package/lib/service/CallApi.js +36 -5
- package/lib/service/getApiClient.js +36 -5
- package/lib/simple/Auth.js +125 -81
- package/lib/simple/Configuration.js +125 -81
- package/lib/simple/Directory.js +36 -5
- package/lib/simple/Phone.js +125 -81
- package/lib/simple/index.js +125 -81
- package/lib/simple/room/LocalParticipant.js +125 -81
- package/lib/simple/room/Participant.js +125 -81
- package/lib/simple/room/RemoteParticipant.js +125 -81
- package/lib/simple/room/Room.js +125 -81
- package/lib/simple/room/SipRoom.js +125 -81
- package/lib/simple/room/Stream.js +125 -81
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +125 -81
- package/lib/simple/utils.js +125 -81
- package/lib/types/WebSocketMessage.js +2 -0
- package/lib/web-rtc-client.js +77 -66
- package/package.json +1 -1
- 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 +15 -5
- package/src/domain/Phone/CTIPhone.js +4 -0
- package/src/domain/Phone/Phone.js +2 -0
- package/src/domain/Phone/WebRTCPhone.js +45 -16
- 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/web-rtc-client.js +41 -23
package/lib/simple/Phone.js
CHANGED
|
@@ -105,6 +105,9 @@ class Call {
|
|
|
105
105
|
|
|
106
106
|
|
|
107
107
|
static parseMany(plain ) {
|
|
108
|
+
if (!plain) {
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
108
111
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
109
112
|
}
|
|
110
113
|
|
|
@@ -2111,6 +2114,9 @@ class Contact {
|
|
|
2111
2114
|
}
|
|
2112
2115
|
|
|
2113
2116
|
static parseMany(response ) {
|
|
2117
|
+
if (!response || !response.results) {
|
|
2118
|
+
return [];
|
|
2119
|
+
}
|
|
2114
2120
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
2115
2121
|
}
|
|
2116
2122
|
|
|
@@ -3188,8 +3194,9 @@ class ExternalApp {
|
|
|
3188
3194
|
|
|
3189
3195
|
|
|
3190
3196
|
|
|
3191
|
-
|
|
3197
|
+
|
|
3192
3198
|
|
|
3199
|
+
|
|
3193
3200
|
|
|
3194
3201
|
|
|
3195
3202
|
class Meeting {
|
|
@@ -3200,9 +3207,10 @@ class Meeting {
|
|
|
3200
3207
|
|
|
3201
3208
|
|
|
3202
3209
|
|
|
3203
|
-
|
|
3210
|
+
|
|
3204
3211
|
|
|
3205
3212
|
|
|
3213
|
+
|
|
3206
3214
|
|
|
3207
3215
|
static parse(plain ) {
|
|
3208
3216
|
return new Meeting({
|
|
@@ -3212,12 +3220,16 @@ class Meeting {
|
|
|
3212
3220
|
ownerUuids: plain.owner_uuids,
|
|
3213
3221
|
port: plain.port,
|
|
3214
3222
|
uuid: plain.uuid,
|
|
3215
|
-
|
|
3223
|
+
extension: plain.exten,
|
|
3216
3224
|
persistent: plain.persistent,
|
|
3225
|
+
creationTime: moment__default['default'](plain.creation_time).toDate(),
|
|
3217
3226
|
});
|
|
3218
3227
|
}
|
|
3219
3228
|
|
|
3220
3229
|
static parseMany(items ) {
|
|
3230
|
+
if (!items) {
|
|
3231
|
+
return [];
|
|
3232
|
+
}
|
|
3221
3233
|
return items.map(plain => Meeting.parse(plain));
|
|
3222
3234
|
}
|
|
3223
3235
|
|
|
@@ -3232,8 +3244,9 @@ class Meeting {
|
|
|
3232
3244
|
ownerUuids,
|
|
3233
3245
|
port,
|
|
3234
3246
|
uri,
|
|
3235
|
-
|
|
3247
|
+
extension,
|
|
3236
3248
|
persistent,
|
|
3249
|
+
creationTime,
|
|
3237
3250
|
} = {}) {
|
|
3238
3251
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
3239
3252
|
this.uri = uri;
|
|
@@ -3241,8 +3254,9 @@ class Meeting {
|
|
|
3241
3254
|
this.ownerUuids = ownerUuids;
|
|
3242
3255
|
this.port = port;
|
|
3243
3256
|
this.uuid = uuid;
|
|
3244
|
-
this.
|
|
3257
|
+
this.extension = extension;
|
|
3245
3258
|
this.persistent = persistent;
|
|
3259
|
+
this.creationTime = creationTime;
|
|
3246
3260
|
|
|
3247
3261
|
// Useful to compare instead of instanceof with minified code
|
|
3248
3262
|
this.type = 'Meeting';
|
|
@@ -3420,6 +3434,10 @@ class ChatMessage {
|
|
|
3420
3434
|
|
|
3421
3435
|
|
|
3422
3436
|
static parseMany(plain ) {
|
|
3437
|
+
if (!plain || !plain.items) {
|
|
3438
|
+
return [];
|
|
3439
|
+
}
|
|
3440
|
+
|
|
3423
3441
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
3424
3442
|
}
|
|
3425
3443
|
|
|
@@ -3529,6 +3547,9 @@ class Voicemail {
|
|
|
3529
3547
|
}
|
|
3530
3548
|
|
|
3531
3549
|
static parseMany(plain ) {
|
|
3550
|
+
if (!plain) {
|
|
3551
|
+
return [];
|
|
3552
|
+
}
|
|
3532
3553
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
3533
3554
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
3534
3555
|
|
|
@@ -3630,6 +3651,9 @@ class Recording {
|
|
|
3630
3651
|
|
|
3631
3652
|
|
|
3632
3653
|
static parseMany(recordings = []) {
|
|
3654
|
+
if (!recordings) {
|
|
3655
|
+
return [];
|
|
3656
|
+
}
|
|
3633
3657
|
return recordings.map(item => Recording.parse(item));
|
|
3634
3658
|
}
|
|
3635
3659
|
|
|
@@ -3731,6 +3755,10 @@ class CallLog {
|
|
|
3731
3755
|
}
|
|
3732
3756
|
|
|
3733
3757
|
static parseMany(plain ) {
|
|
3758
|
+
if (!plain || !plain.items) {
|
|
3759
|
+
return [];
|
|
3760
|
+
}
|
|
3761
|
+
|
|
3734
3762
|
return plain.items.map(item => CallLog.parse(item));
|
|
3735
3763
|
}
|
|
3736
3764
|
|
|
@@ -4300,6 +4328,10 @@ class CTIPhone extends Emitter {
|
|
|
4300
4328
|
return false;
|
|
4301
4329
|
}
|
|
4302
4330
|
|
|
4331
|
+
hasAVideoTrack() {
|
|
4332
|
+
return false;
|
|
4333
|
+
}
|
|
4334
|
+
|
|
4303
4335
|
getLocalStreamForCall() {
|
|
4304
4336
|
return null;
|
|
4305
4337
|
}
|
|
@@ -4693,6 +4725,9 @@ class ChatRoom {
|
|
|
4693
4725
|
|
|
4694
4726
|
|
|
4695
4727
|
static parseMany(plain ) {
|
|
4728
|
+
if (!plain || !plain.items) {
|
|
4729
|
+
return [];
|
|
4730
|
+
}
|
|
4696
4731
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
4697
4732
|
}
|
|
4698
4733
|
|
|
@@ -5674,10 +5709,6 @@ const getSrflxOrRelay = (candidates ) =>
|
|
|
5674
5709
|
candidates
|
|
5675
5710
|
.filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
|
|
5676
5711
|
|
|
5677
|
-
const areCandidateValid = (candidates ) =>
|
|
5678
|
-
getSrflxOrRelay(candidates)
|
|
5679
|
-
.length > 0;
|
|
5680
|
-
|
|
5681
5712
|
const getVideoDirection = (sdp ) => {
|
|
5682
5713
|
const parsedSdp = sdpParser__default['default'].parse(sdp);
|
|
5683
5714
|
const videoMedia = parsedSdp.media.find(media => media.type === 'video');
|
|
@@ -5730,8 +5761,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
|
|
|
5730
5761
|
/* global RTCSessionDescriptionInit, navigator */
|
|
5731
5762
|
|
|
5732
5763
|
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
5733
|
-
const MAX_WAIT_FOR_ICE_TRIES = 20;
|
|
5734
|
-
const WAIT_FOR_ICE_TIMEOUT = 500;
|
|
5735
5764
|
|
|
5736
5765
|
// Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
|
|
5737
5766
|
const wazoMediaStreamFactory = (constraints ) => {
|
|
@@ -5921,38 +5950,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
5921
5950
|
this._peerConnection = undefined;
|
|
5922
5951
|
}
|
|
5923
5952
|
|
|
5924
|
-
async _waitForValidGatheredIce() {
|
|
5925
|
-
let tries = 0;
|
|
5926
|
-
|
|
5927
|
-
while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
|
|
5928
|
-
wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
|
|
5929
|
-
tries,
|
|
5930
|
-
max: MAX_WAIT_FOR_ICE_TRIES,
|
|
5931
|
-
});
|
|
5932
|
-
|
|
5933
|
-
tries++;
|
|
5934
|
-
|
|
5935
|
-
// eslint-disable-next-line no-await-in-loop
|
|
5936
|
-
await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
|
|
5937
|
-
}
|
|
5938
|
-
|
|
5939
|
-
if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
|
|
5940
|
-
const errorMsg = 'No valid candidates found, can\'t answer the call';
|
|
5941
|
-
const error = new Error(errorMsg);
|
|
5942
|
-
wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
|
|
5943
|
-
|
|
5944
|
-
// Emit an error, because sip.js catches the exception and switch to status Terminated.
|
|
5945
|
-
this.eventEmitter.emit('error', error);
|
|
5946
|
-
|
|
5947
|
-
wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
5948
|
-
}
|
|
5949
|
-
|
|
5950
|
-
// eslint-disable-next-line
|
|
5951
|
-
wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
|
|
5952
|
-
|
|
5953
|
-
return this.getLocalSessionDescription();
|
|
5954
|
-
}
|
|
5955
|
-
|
|
5956
5953
|
// Overridden to send `inactive` in conference
|
|
5957
5954
|
updateDirection(options , isConference = false,
|
|
5958
5955
|
audioOnly = false) {
|
|
@@ -6720,7 +6717,7 @@ class WebRTCClient extends Emitter {
|
|
|
6720
6717
|
}
|
|
6721
6718
|
|
|
6722
6719
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
6723
|
-
logger$9.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
6720
|
+
logger$9.info('sdk webrtc creating call', { number, enableVideo, audioOnly, conference });
|
|
6724
6721
|
const inviterOptions = {
|
|
6725
6722
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
6726
6723
|
conference,
|
|
@@ -7796,6 +7793,7 @@ class WebRTCClient extends Emitter {
|
|
|
7796
7793
|
const screenSharing = constraints && 'screen' in constraints ? constraints.screen : false;
|
|
7797
7794
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
7798
7795
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
7796
|
+
const mandatoryVideo = constraints && typeof constraints.video === 'object' ? constraints.video.mandatory : {};
|
|
7799
7797
|
|
|
7800
7798
|
logger$9.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
7801
7799
|
|
|
@@ -7803,7 +7801,8 @@ class WebRTCClient extends Emitter {
|
|
|
7803
7801
|
constraints: {
|
|
7804
7802
|
// Exact constraint are not supported with `getDisplayMedia` and we must have a video=false in desktop screenshare
|
|
7805
7803
|
audio: screenSharing ? !isDesktop : (withAudio ? this._getAudioConstraints() : false),
|
|
7806
|
-
video: screenSharing ? (isDesktop
|
|
7804
|
+
video: screenSharing ? (isDesktop
|
|
7805
|
+
? ({ mandatory: { chromeMediaSource: 'desktop', ...(mandatoryVideo || {}) } }) : { cursor: 'always' })
|
|
7807
7806
|
: this._getVideoConstraints(enableVideo),
|
|
7808
7807
|
screen: screenSharing,
|
|
7809
7808
|
desktop: isDesktop,
|
|
@@ -8138,11 +8137,14 @@ class WebRTCClient extends Emitter {
|
|
|
8138
8137
|
|
|
8139
8138
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
8140
8139
|
|
|
8141
|
-
|
|
8142
|
-
|
|
8143
|
-
|
|
8144
|
-
|
|
8145
|
-
|
|
8140
|
+
if (pc) {
|
|
8141
|
+
pc.oniceconnectionstatechange = () => {
|
|
8142
|
+
logger$9.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
8143
|
+
if (pc.iceConnectionState === 'disconnected') {
|
|
8144
|
+
this.eventEmitter.emit(ON_DISCONNECTED$1);
|
|
8145
|
+
}
|
|
8146
|
+
};
|
|
8147
|
+
}
|
|
8146
8148
|
|
|
8147
8149
|
if (withEvent) {
|
|
8148
8150
|
this.eventEmitter.emit(ACCEPTED, session, sessionDialog);
|
|
@@ -8352,13 +8354,17 @@ class WebRTCClient extends Emitter {
|
|
|
8352
8354
|
const nbStats = this.sessionNetworkStats[sessionId].length;
|
|
8353
8355
|
const lastNetworkStats = this.sessionNetworkStats[sessionId][nbStats - 1];
|
|
8354
8356
|
const lastAudioSent = lastNetworkStats ? lastNetworkStats.audioBytesSent : 0;
|
|
8357
|
+
const lastAudioContentSent = lastNetworkStats ? lastNetworkStats.audioContentSent : 0;
|
|
8355
8358
|
const lastVideoSent = lastNetworkStats ? lastNetworkStats.videoBytesSent : 0;
|
|
8356
8359
|
const lastAudioReceived = lastNetworkStats ? lastNetworkStats.audioBytesReceived : 0;
|
|
8360
|
+
const lastAudioContentReceived = lastNetworkStats ? lastNetworkStats.audioContentReceived : 0;
|
|
8357
8361
|
const lastVideoReceived = lastNetworkStats ? lastNetworkStats.videoBytesReceived : 0;
|
|
8358
8362
|
const lastTransportSent = lastNetworkStats ? lastNetworkStats.transportSent : 0;
|
|
8359
8363
|
const lastTransportReceived = lastNetworkStats ? lastNetworkStats.transportReceived : 0;
|
|
8360
|
-
let audioBytesSent = 0;
|
|
8361
|
-
let audioBytesReceived = 0;
|
|
8364
|
+
let audioBytesSent = 0; // content + header
|
|
8365
|
+
let audioBytesReceived = 0; // content + header
|
|
8366
|
+
let audioContentSent = 0; // useful to detect blank call
|
|
8367
|
+
let audioContentReceived = 0;
|
|
8362
8368
|
let videoBytesSent = 0;
|
|
8363
8369
|
let videoBytesReceived = 0;
|
|
8364
8370
|
let transportSent = 0;
|
|
@@ -8367,25 +8373,27 @@ class WebRTCClient extends Emitter {
|
|
|
8367
8373
|
|
|
8368
8374
|
stats.forEach(report => {
|
|
8369
8375
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
8370
|
-
audioBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8376
|
+
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8377
|
+
audioContentSent += Number(report.bytesSent);
|
|
8371
8378
|
}
|
|
8372
8379
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
8373
|
-
audioBytesSent += report.bytesSent;
|
|
8380
|
+
audioBytesSent += Number(report.bytesSent);
|
|
8374
8381
|
}
|
|
8375
8382
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8376
|
-
videoBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8383
|
+
videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8377
8384
|
}
|
|
8378
8385
|
if (report.type === 'inbound-rtp' && report.kind === 'audio') {
|
|
8379
|
-
packetsLost += report.packetsLost;
|
|
8380
|
-
networkStats.packetsReceived = report.packetsReceived;
|
|
8381
|
-
audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8386
|
+
packetsLost += Number(report.packetsLost);
|
|
8387
|
+
networkStats.packetsReceived = Number(report.packetsReceived);
|
|
8388
|
+
audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8389
|
+
audioContentReceived += Number(report.bytesReceived);
|
|
8382
8390
|
}
|
|
8383
8391
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
8384
|
-
videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8392
|
+
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8385
8393
|
}
|
|
8386
8394
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8387
8395
|
if ('framesPerSecond' in report) {
|
|
8388
|
-
networkStats.framesPerSecond = report.framesPerSecond;
|
|
8396
|
+
networkStats.framesPerSecond = Number(report.framesPerSecond);
|
|
8389
8397
|
}
|
|
8390
8398
|
if ('framerateMean' in report) {
|
|
8391
8399
|
// framerateMean is only available in FF
|
|
@@ -8393,24 +8401,31 @@ class WebRTCClient extends Emitter {
|
|
|
8393
8401
|
}
|
|
8394
8402
|
}
|
|
8395
8403
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
|
|
8396
|
-
packetsLost += report.packetsLost;
|
|
8397
|
-
networkStats.roundTripTime = report.roundTripTime;
|
|
8398
|
-
networkStats.jitter = report.jitter;
|
|
8404
|
+
packetsLost += Number(report.packetsLost);
|
|
8405
|
+
networkStats.roundTripTime = Number(report.roundTripTime);
|
|
8406
|
+
networkStats.jitter = Number(report.jitter);
|
|
8399
8407
|
}
|
|
8400
8408
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
|
|
8401
|
-
packetsLost += report.packetsLost;
|
|
8409
|
+
packetsLost += Number(report.packetsLost);
|
|
8402
8410
|
}
|
|
8403
8411
|
if (report.type === 'transport') {
|
|
8404
|
-
transportSent += report.bytesSent;
|
|
8405
|
-
transportReceived += report.bytesReceived;
|
|
8412
|
+
transportSent += Number(report.bytesSent);
|
|
8413
|
+
transportReceived += Number(report.bytesReceived);
|
|
8406
8414
|
}
|
|
8407
8415
|
});
|
|
8408
8416
|
|
|
8409
8417
|
networkStats.packetsLost = packetsLost;
|
|
8418
|
+
|
|
8410
8419
|
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
8411
8420
|
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
8412
8421
|
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
8413
8422
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
8423
|
+
|
|
8424
|
+
networkStats.totalAudioContentSent = audioContentSent;
|
|
8425
|
+
networkStats.audioContentSent = audioContentSent - lastAudioContentSent;
|
|
8426
|
+
networkStats.totalAudioBytesReceived = audioContentReceived - lastAudioContentReceived;
|
|
8427
|
+
networkStats.audioContentReceived = audioContentReceived;
|
|
8428
|
+
|
|
8414
8429
|
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
8415
8430
|
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
8416
8431
|
networkStats.totalVideoBytesReceived = videoBytesReceived;
|
|
@@ -8622,6 +8637,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8622
8637
|
constraints,
|
|
8623
8638
|
audioOnly,
|
|
8624
8639
|
conference,
|
|
8640
|
+
iceRestart,
|
|
8625
8641
|
});
|
|
8626
8642
|
|
|
8627
8643
|
if (!sipSession) {
|
|
@@ -8725,6 +8741,11 @@ class WebRTCPhone extends Emitter {
|
|
|
8725
8741
|
|
|
8726
8742
|
this.client.downgradeToAudio(sipSession);
|
|
8727
8743
|
|
|
8744
|
+
if (callSession) {
|
|
8745
|
+
callSession.cameraEnabled = false;
|
|
8746
|
+
this._updateCallSession(callSession);
|
|
8747
|
+
}
|
|
8748
|
+
|
|
8728
8749
|
if (withMessage) {
|
|
8729
8750
|
this._sendReinviteMessage(callSession, false);
|
|
8730
8751
|
}
|
|
@@ -8752,6 +8773,11 @@ class WebRTCPhone extends Emitter {
|
|
|
8752
8773
|
|
|
8753
8774
|
const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
|
|
8754
8775
|
|
|
8776
|
+
if (callSession) {
|
|
8777
|
+
callSession.cameraEnabled = true;
|
|
8778
|
+
this._updateCallSession(callSession);
|
|
8779
|
+
}
|
|
8780
|
+
|
|
8755
8781
|
// If no stream is returned, it means we have to reinvite
|
|
8756
8782
|
if (!newStream) {
|
|
8757
8783
|
return true;
|
|
@@ -8804,7 +8830,10 @@ class WebRTCPhone extends Emitter {
|
|
|
8804
8830
|
|
|
8805
8831
|
onCancel(message);
|
|
8806
8832
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
8807
|
-
|
|
8833
|
+
const callSession = this._createCallSession(sipSession);
|
|
8834
|
+
delete this.callSessions[callSession.getId()];
|
|
8835
|
+
|
|
8836
|
+
this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
|
|
8808
8837
|
};
|
|
8809
8838
|
} else if (sipSession instanceof invitation.Invitation) {
|
|
8810
8839
|
console.warn('sipSession._onCancel not found, please update the wazo SDK accordingly');
|
|
@@ -8985,18 +9014,20 @@ class WebRTCPhone extends Emitter {
|
|
|
8985
9014
|
screenTrack,
|
|
8986
9015
|
});
|
|
8987
9016
|
|
|
8988
|
-
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
|
|
9017
|
+
if (screenTrack) {
|
|
9018
|
+
screenTrack.onended = () => {
|
|
9019
|
+
logger$8.info('WebRTC phone - on screenshare ended', {
|
|
9020
|
+
hadVideo,
|
|
9021
|
+
id: this.getSipSessionId(sipSession),
|
|
9022
|
+
screenTrack,
|
|
9023
|
+
});
|
|
8994
9024
|
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9025
|
+
this.eventEmitter.emit(
|
|
9026
|
+
ON_SHARE_SCREEN_ENDING,
|
|
9027
|
+
this._createCallSession(sipSession, callSession),
|
|
9028
|
+
);
|
|
9029
|
+
};
|
|
9030
|
+
}
|
|
9000
9031
|
|
|
9001
9032
|
this.currentScreenShare = {
|
|
9002
9033
|
stream: screenStream,
|
|
@@ -9016,7 +9047,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9016
9047
|
}
|
|
9017
9048
|
|
|
9018
9049
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
9019
|
-
logger$8.info('WebRTC phone -
|
|
9050
|
+
logger$8.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
9020
9051
|
|
|
9021
9052
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
9022
9053
|
this.currentSipSession = sipSession;
|
|
@@ -9528,7 +9559,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9528
9559
|
// @TODO: line is not used here
|
|
9529
9560
|
async makeCall(number , line , cameraEnabled ,
|
|
9530
9561
|
audioOnly = false, conference = false) {
|
|
9531
|
-
logger$8.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
|
|
9562
|
+
logger$8.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled, audioOnly, conference });
|
|
9532
9563
|
if (!number) {
|
|
9533
9564
|
return Promise.resolve(null);
|
|
9534
9565
|
}
|
|
@@ -9889,9 +9920,13 @@ class WebRTCPhone extends Emitter {
|
|
|
9889
9920
|
if (this.shouldSendReinvite && this.currentSipSession
|
|
9890
9921
|
&& this.currentSipSession.state === sessionState.SessionState.Established) {
|
|
9891
9922
|
this.shouldSendReinvite = false;
|
|
9923
|
+
const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
|
|
9924
|
+
const isConference = pc ? pc.sfu : false;
|
|
9925
|
+
const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
|
|
9926
|
+
|
|
9892
9927
|
try {
|
|
9893
9928
|
// Send reinvite with iceRestart
|
|
9894
|
-
this.sendReinvite(this.currentCallSession, null,
|
|
9929
|
+
this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
|
|
9895
9930
|
} catch (e) {
|
|
9896
9931
|
logger$8.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
9897
9932
|
}
|
|
@@ -9975,6 +10010,15 @@ class WebRTCPhone extends Emitter {
|
|
|
9975
10010
|
return this.client.getSipSessionId(sipSession);
|
|
9976
10011
|
}
|
|
9977
10012
|
|
|
10013
|
+
_updateCallSession(callSession ) {
|
|
10014
|
+
const sipSession = this.findSipSession(callSession);
|
|
10015
|
+
const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
|
|
10016
|
+
|
|
10017
|
+
if (sipSessionId) {
|
|
10018
|
+
this.callSessions[sipSessionId] = callSession;
|
|
10019
|
+
}
|
|
10020
|
+
}
|
|
10021
|
+
|
|
9978
10022
|
_onMessage(message ) {
|
|
9979
10023
|
if (!message || message.method !== 'MESSAGE') {
|
|
9980
10024
|
return;
|