@wazo/sdk 0.37.22 → 0.37.26
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 +37 -6
- package/esm/__tests__/web-rtc-client.test.js +78 -68
- 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 +4 -1
- package/esm/api-client.js +37 -6
- package/esm/checker/Checker.js +78 -68
- package/esm/checker/checks/aor.js +37 -6
- package/esm/checker/checks/api.js +37 -6
- package/esm/checker/checks/index.js +78 -68
- package/esm/checker/checks/webrtc-transport.js +78 -68
- package/esm/checker/checks/webrtc.js +78 -68
- package/esm/domain/AdHocAPIConference.js +37 -6
- 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 +4 -1
- package/esm/domain/Features.js +37 -6
- package/esm/domain/Meeting.js +15 -5
- package/esm/domain/Phone/CTIPhone.js +41 -6
- package/esm/domain/Phone/WebRTCPhone.js +41 -15
- 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 +4 -1
- package/esm/domain/__tests__/Meeting.test.js +144 -0
- package/esm/domain/__tests__/Voicemail.test.js +3 -0
- package/esm/index.js +122 -82
- package/esm/lib/WazoSessionDescriptionHandler.js +0 -38
- package/esm/service/CallApi.js +37 -6
- package/esm/service/getApiClient.js +37 -6
- package/esm/simple/Auth.js +122 -82
- package/esm/simple/Configuration.js +122 -82
- package/esm/simple/Directory.js +37 -6
- package/esm/simple/Phone.js +122 -82
- package/esm/simple/index.js +122 -82
- package/esm/simple/room/LocalParticipant.js +122 -82
- package/esm/simple/room/Participant.js +122 -82
- package/esm/simple/room/RemoteParticipant.js +122 -82
- package/esm/simple/room/Room.js +122 -82
- package/esm/simple/room/SipRoom.js +122 -82
- package/esm/simple/room/Stream.js +122 -82
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +122 -82
- package/esm/simple/utils.js +122 -82
- package/esm/types/WebSocketMessage.js +1 -1
- package/esm/web-rtc-client.js +78 -68
- package/lib/__tests__/api-client.test.js +37 -6
- package/lib/__tests__/web-rtc-client.test.js +78 -68
- 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 +4 -1
- package/lib/api-client.js +37 -6
- package/lib/checker/Checker.js +78 -68
- package/lib/checker/checks/aor.js +37 -6
- package/lib/checker/checks/api.js +37 -6
- package/lib/checker/checks/index.js +78 -68
- package/lib/checker/checks/webrtc-transport.js +78 -68
- package/lib/checker/checks/webrtc.js +78 -68
- package/lib/domain/AdHocAPIConference.js +37 -6
- 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 +4 -1
- package/lib/domain/Features.js +37 -6
- package/lib/domain/Meeting.js +19 -5
- package/lib/domain/Phone/CTIPhone.js +41 -6
- package/lib/domain/Phone/WebRTCPhone.js +41 -15
- 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 +4 -1
- package/lib/domain/__tests__/Meeting.test.js +150 -0
- package/lib/domain/__tests__/Voicemail.test.js +3 -0
- package/lib/index.js +122 -82
- package/lib/lib/WazoSessionDescriptionHandler.js +0 -38
- package/lib/service/CallApi.js +37 -6
- package/lib/service/getApiClient.js +37 -6
- package/lib/simple/Auth.js +122 -82
- package/lib/simple/Configuration.js +122 -82
- package/lib/simple/Directory.js +37 -6
- package/lib/simple/Phone.js +122 -82
- package/lib/simple/index.js +122 -82
- package/lib/simple/room/LocalParticipant.js +122 -82
- package/lib/simple/room/Participant.js +122 -82
- package/lib/simple/room/RemoteParticipant.js +122 -82
- package/lib/simple/room/Room.js +122 -82
- package/lib/simple/room/SipRoom.js +122 -82
- package/lib/simple/room/Stream.js +122 -82
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +122 -82
- package/lib/simple/utils.js +122 -82
- package/lib/types/WebSocketMessage.js +2 -0
- package/lib/web-rtc-client.js +78 -68
- 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 +4 -1
- 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 +41 -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/web-rtc-client.js +41 -24
|
@@ -873,6 +873,9 @@ class Contact {
|
|
|
873
873
|
}
|
|
874
874
|
|
|
875
875
|
static parseMany(response ) {
|
|
876
|
+
if (!response || !response.results) {
|
|
877
|
+
return [];
|
|
878
|
+
}
|
|
876
879
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
877
880
|
}
|
|
878
881
|
|
|
@@ -1243,7 +1246,7 @@ class Contact {
|
|
|
1243
1246
|
this[key] = old[key] || this[key];
|
|
1244
1247
|
});
|
|
1245
1248
|
|
|
1246
|
-
if (old.lineState
|
|
1249
|
+
if (old.lineState) {
|
|
1247
1250
|
this.lineState = old.lineState;
|
|
1248
1251
|
}
|
|
1249
1252
|
|
|
@@ -2637,8 +2640,9 @@ class ExternalApp {
|
|
|
2637
2640
|
|
|
2638
2641
|
|
|
2639
2642
|
|
|
2640
|
-
|
|
2643
|
+
|
|
2641
2644
|
|
|
2645
|
+
|
|
2642
2646
|
|
|
2643
2647
|
|
|
2644
2648
|
class Meeting {
|
|
@@ -2649,9 +2653,10 @@ class Meeting {
|
|
|
2649
2653
|
|
|
2650
2654
|
|
|
2651
2655
|
|
|
2652
|
-
|
|
2656
|
+
|
|
2653
2657
|
|
|
2654
2658
|
|
|
2659
|
+
|
|
2655
2660
|
|
|
2656
2661
|
static parse(plain ) {
|
|
2657
2662
|
return new Meeting({
|
|
@@ -2661,12 +2666,16 @@ class Meeting {
|
|
|
2661
2666
|
ownerUuids: plain.owner_uuids,
|
|
2662
2667
|
port: plain.port,
|
|
2663
2668
|
uuid: plain.uuid,
|
|
2664
|
-
|
|
2669
|
+
extension: plain.exten,
|
|
2665
2670
|
persistent: plain.persistent,
|
|
2671
|
+
creationTime: moment__default['default'](plain.creation_time).toDate(),
|
|
2666
2672
|
});
|
|
2667
2673
|
}
|
|
2668
2674
|
|
|
2669
2675
|
static parseMany(items ) {
|
|
2676
|
+
if (!items) {
|
|
2677
|
+
return [];
|
|
2678
|
+
}
|
|
2670
2679
|
return items.map(plain => Meeting.parse(plain));
|
|
2671
2680
|
}
|
|
2672
2681
|
|
|
@@ -2681,8 +2690,9 @@ class Meeting {
|
|
|
2681
2690
|
ownerUuids,
|
|
2682
2691
|
port,
|
|
2683
2692
|
uri,
|
|
2684
|
-
|
|
2693
|
+
extension,
|
|
2685
2694
|
persistent,
|
|
2695
|
+
creationTime,
|
|
2686
2696
|
} = {}) {
|
|
2687
2697
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
2688
2698
|
this.uri = uri;
|
|
@@ -2690,8 +2700,9 @@ class Meeting {
|
|
|
2690
2700
|
this.ownerUuids = ownerUuids;
|
|
2691
2701
|
this.port = port;
|
|
2692
2702
|
this.uuid = uuid;
|
|
2693
|
-
this.
|
|
2703
|
+
this.extension = extension;
|
|
2694
2704
|
this.persistent = persistent;
|
|
2705
|
+
this.creationTime = creationTime;
|
|
2695
2706
|
|
|
2696
2707
|
// Useful to compare instead of instanceof with minified code
|
|
2697
2708
|
this.type = 'Meeting';
|
|
@@ -2869,6 +2880,10 @@ class ChatMessage {
|
|
|
2869
2880
|
|
|
2870
2881
|
|
|
2871
2882
|
static parseMany(plain ) {
|
|
2883
|
+
if (!plain || !plain.items) {
|
|
2884
|
+
return [];
|
|
2885
|
+
}
|
|
2886
|
+
|
|
2872
2887
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
2873
2888
|
}
|
|
2874
2889
|
|
|
@@ -2978,6 +2993,9 @@ class Voicemail {
|
|
|
2978
2993
|
}
|
|
2979
2994
|
|
|
2980
2995
|
static parseMany(plain ) {
|
|
2996
|
+
if (!plain) {
|
|
2997
|
+
return [];
|
|
2998
|
+
}
|
|
2981
2999
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
2982
3000
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
2983
3001
|
|
|
@@ -3087,6 +3105,9 @@ class Call {
|
|
|
3087
3105
|
|
|
3088
3106
|
|
|
3089
3107
|
static parseMany(plain ) {
|
|
3108
|
+
if (!plain) {
|
|
3109
|
+
return [];
|
|
3110
|
+
}
|
|
3090
3111
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
3091
3112
|
}
|
|
3092
3113
|
|
|
@@ -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,12 +8137,14 @@ class WebRTCClient extends Emitter {
|
|
|
8138
8137
|
|
|
8139
8138
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
8140
8139
|
|
|
8141
|
-
|
|
8142
|
-
|
|
8143
|
-
|
|
8144
|
-
|
|
8145
|
-
|
|
8146
|
-
|
|
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
|
+
}
|
|
8147
8148
|
|
|
8148
8149
|
if (withEvent) {
|
|
8149
8150
|
this.eventEmitter.emit(ACCEPTED, session, sessionDialog);
|
|
@@ -8353,13 +8354,17 @@ class WebRTCClient extends Emitter {
|
|
|
8353
8354
|
const nbStats = this.sessionNetworkStats[sessionId].length;
|
|
8354
8355
|
const lastNetworkStats = this.sessionNetworkStats[sessionId][nbStats - 1];
|
|
8355
8356
|
const lastAudioSent = lastNetworkStats ? lastNetworkStats.audioBytesSent : 0;
|
|
8357
|
+
const lastAudioContentSent = lastNetworkStats ? lastNetworkStats.audioContentSent : 0;
|
|
8356
8358
|
const lastVideoSent = lastNetworkStats ? lastNetworkStats.videoBytesSent : 0;
|
|
8357
8359
|
const lastAudioReceived = lastNetworkStats ? lastNetworkStats.audioBytesReceived : 0;
|
|
8360
|
+
const lastAudioContentReceived = lastNetworkStats ? lastNetworkStats.audioContentReceived : 0;
|
|
8358
8361
|
const lastVideoReceived = lastNetworkStats ? lastNetworkStats.videoBytesReceived : 0;
|
|
8359
8362
|
const lastTransportSent = lastNetworkStats ? lastNetworkStats.transportSent : 0;
|
|
8360
8363
|
const lastTransportReceived = lastNetworkStats ? lastNetworkStats.transportReceived : 0;
|
|
8361
|
-
let audioBytesSent = 0;
|
|
8362
|
-
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;
|
|
8363
8368
|
let videoBytesSent = 0;
|
|
8364
8369
|
let videoBytesReceived = 0;
|
|
8365
8370
|
let transportSent = 0;
|
|
@@ -8368,25 +8373,27 @@ class WebRTCClient extends Emitter {
|
|
|
8368
8373
|
|
|
8369
8374
|
stats.forEach(report => {
|
|
8370
8375
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
8371
|
-
audioBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8376
|
+
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8377
|
+
audioContentSent += Number(report.bytesSent);
|
|
8372
8378
|
}
|
|
8373
8379
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
8374
|
-
audioBytesSent += report.bytesSent;
|
|
8380
|
+
audioBytesSent += Number(report.bytesSent);
|
|
8375
8381
|
}
|
|
8376
8382
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8377
|
-
videoBytesSent += report.bytesSent + report.headerBytesSent;
|
|
8383
|
+
videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8378
8384
|
}
|
|
8379
8385
|
if (report.type === 'inbound-rtp' && report.kind === 'audio') {
|
|
8380
|
-
packetsLost += report.packetsLost;
|
|
8381
|
-
networkStats.packetsReceived = report.packetsReceived;
|
|
8382
|
-
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);
|
|
8383
8390
|
}
|
|
8384
8391
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
8385
|
-
videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
|
|
8392
|
+
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8386
8393
|
}
|
|
8387
8394
|
if (report.type === 'outbound-rtp' && report.kind === 'video') {
|
|
8388
8395
|
if ('framesPerSecond' in report) {
|
|
8389
|
-
networkStats.framesPerSecond = report.framesPerSecond;
|
|
8396
|
+
networkStats.framesPerSecond = Number(report.framesPerSecond);
|
|
8390
8397
|
}
|
|
8391
8398
|
if ('framerateMean' in report) {
|
|
8392
8399
|
// framerateMean is only available in FF
|
|
@@ -8394,24 +8401,31 @@ class WebRTCClient extends Emitter {
|
|
|
8394
8401
|
}
|
|
8395
8402
|
}
|
|
8396
8403
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
|
|
8397
|
-
packetsLost += report.packetsLost;
|
|
8398
|
-
networkStats.roundTripTime = report.roundTripTime;
|
|
8399
|
-
networkStats.jitter = report.jitter;
|
|
8404
|
+
packetsLost += Number(report.packetsLost);
|
|
8405
|
+
networkStats.roundTripTime = Number(report.roundTripTime);
|
|
8406
|
+
networkStats.jitter = Number(report.jitter);
|
|
8400
8407
|
}
|
|
8401
8408
|
if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
|
|
8402
|
-
packetsLost += report.packetsLost;
|
|
8409
|
+
packetsLost += Number(report.packetsLost);
|
|
8403
8410
|
}
|
|
8404
8411
|
if (report.type === 'transport') {
|
|
8405
|
-
transportSent += report.bytesSent;
|
|
8406
|
-
transportReceived += report.bytesReceived;
|
|
8412
|
+
transportSent += Number(report.bytesSent);
|
|
8413
|
+
transportReceived += Number(report.bytesReceived);
|
|
8407
8414
|
}
|
|
8408
8415
|
});
|
|
8409
8416
|
|
|
8410
8417
|
networkStats.packetsLost = packetsLost;
|
|
8418
|
+
|
|
8411
8419
|
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
8412
8420
|
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
8413
8421
|
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
8414
8422
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
8423
|
+
|
|
8424
|
+
networkStats.totalAudioContentSent = audioContentSent;
|
|
8425
|
+
networkStats.audioContentSent = audioContentSent - lastAudioContentSent;
|
|
8426
|
+
networkStats.totalAudioBytesReceived = audioContentReceived - lastAudioContentReceived;
|
|
8427
|
+
networkStats.audioContentReceived = audioContentReceived;
|
|
8428
|
+
|
|
8415
8429
|
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
8416
8430
|
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
8417
8431
|
networkStats.totalVideoBytesReceived = videoBytesReceived;
|
|
@@ -8623,6 +8637,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8623
8637
|
constraints,
|
|
8624
8638
|
audioOnly,
|
|
8625
8639
|
conference,
|
|
8640
|
+
iceRestart,
|
|
8626
8641
|
});
|
|
8627
8642
|
|
|
8628
8643
|
if (!sipSession) {
|
|
@@ -8726,6 +8741,11 @@ class WebRTCPhone extends Emitter {
|
|
|
8726
8741
|
|
|
8727
8742
|
this.client.downgradeToAudio(sipSession);
|
|
8728
8743
|
|
|
8744
|
+
if (callSession) {
|
|
8745
|
+
callSession.cameraEnabled = false;
|
|
8746
|
+
this._updateCallSession(callSession);
|
|
8747
|
+
}
|
|
8748
|
+
|
|
8729
8749
|
if (withMessage) {
|
|
8730
8750
|
this._sendReinviteMessage(callSession, false);
|
|
8731
8751
|
}
|
|
@@ -8753,6 +8773,11 @@ class WebRTCPhone extends Emitter {
|
|
|
8753
8773
|
|
|
8754
8774
|
const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
|
|
8755
8775
|
|
|
8776
|
+
if (callSession) {
|
|
8777
|
+
callSession.cameraEnabled = true;
|
|
8778
|
+
this._updateCallSession(callSession);
|
|
8779
|
+
}
|
|
8780
|
+
|
|
8756
8781
|
// If no stream is returned, it means we have to reinvite
|
|
8757
8782
|
if (!newStream) {
|
|
8758
8783
|
return true;
|
|
@@ -8989,18 +9014,20 @@ class WebRTCPhone extends Emitter {
|
|
|
8989
9014
|
screenTrack,
|
|
8990
9015
|
});
|
|
8991
9016
|
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
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
|
+
});
|
|
8998
9024
|
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
|
|
9003
|
-
|
|
9025
|
+
this.eventEmitter.emit(
|
|
9026
|
+
ON_SHARE_SCREEN_ENDING,
|
|
9027
|
+
this._createCallSession(sipSession, callSession),
|
|
9028
|
+
);
|
|
9029
|
+
};
|
|
9030
|
+
}
|
|
9004
9031
|
|
|
9005
9032
|
this.currentScreenShare = {
|
|
9006
9033
|
stream: screenStream,
|
|
@@ -9020,7 +9047,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9020
9047
|
}
|
|
9021
9048
|
|
|
9022
9049
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
9023
|
-
logger$8.info('WebRTC phone -
|
|
9050
|
+
logger$8.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
9024
9051
|
|
|
9025
9052
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
9026
9053
|
this.currentSipSession = sipSession;
|
|
@@ -9532,7 +9559,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9532
9559
|
// @TODO: line is not used here
|
|
9533
9560
|
async makeCall(number , line , cameraEnabled ,
|
|
9534
9561
|
audioOnly = false, conference = false) {
|
|
9535
|
-
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 });
|
|
9536
9563
|
if (!number) {
|
|
9537
9564
|
return Promise.resolve(null);
|
|
9538
9565
|
}
|
|
@@ -9893,9 +9920,13 @@ class WebRTCPhone extends Emitter {
|
|
|
9893
9920
|
if (this.shouldSendReinvite && this.currentSipSession
|
|
9894
9921
|
&& this.currentSipSession.state === sessionState.SessionState.Established) {
|
|
9895
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
|
+
|
|
9896
9927
|
try {
|
|
9897
9928
|
// Send reinvite with iceRestart
|
|
9898
|
-
this.sendReinvite(this.currentCallSession, null,
|
|
9929
|
+
this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
|
|
9899
9930
|
} catch (e) {
|
|
9900
9931
|
logger$8.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
9901
9932
|
}
|
|
@@ -9979,6 +10010,15 @@ class WebRTCPhone extends Emitter {
|
|
|
9979
10010
|
return this.client.getSipSessionId(sipSession);
|
|
9980
10011
|
}
|
|
9981
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
|
+
|
|
9982
10022
|
_onMessage(message ) {
|
|
9983
10023
|
if (!message || message.method !== 'MESSAGE') {
|
|
9984
10024
|
return;
|
package/lib/simple/Directory.js
CHANGED
|
@@ -1537,6 +1537,9 @@ class Contact {
|
|
|
1537
1537
|
}
|
|
1538
1538
|
|
|
1539
1539
|
static parseMany(response ) {
|
|
1540
|
+
if (!response || !response.results) {
|
|
1541
|
+
return [];
|
|
1542
|
+
}
|
|
1540
1543
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
1541
1544
|
}
|
|
1542
1545
|
|
|
@@ -1907,7 +1910,7 @@ class Contact {
|
|
|
1907
1910
|
this[key] = old[key] || this[key];
|
|
1908
1911
|
});
|
|
1909
1912
|
|
|
1910
|
-
if (old.lineState
|
|
1913
|
+
if (old.lineState) {
|
|
1911
1914
|
this.lineState = old.lineState;
|
|
1912
1915
|
}
|
|
1913
1916
|
|
|
@@ -2614,8 +2617,9 @@ class ExternalApp {
|
|
|
2614
2617
|
|
|
2615
2618
|
|
|
2616
2619
|
|
|
2617
|
-
|
|
2620
|
+
|
|
2618
2621
|
|
|
2622
|
+
|
|
2619
2623
|
|
|
2620
2624
|
|
|
2621
2625
|
class Meeting {
|
|
@@ -2626,9 +2630,10 @@ class Meeting {
|
|
|
2626
2630
|
|
|
2627
2631
|
|
|
2628
2632
|
|
|
2629
|
-
|
|
2633
|
+
|
|
2630
2634
|
|
|
2631
2635
|
|
|
2636
|
+
|
|
2632
2637
|
|
|
2633
2638
|
static parse(plain ) {
|
|
2634
2639
|
return new Meeting({
|
|
@@ -2638,12 +2643,16 @@ class Meeting {
|
|
|
2638
2643
|
ownerUuids: plain.owner_uuids,
|
|
2639
2644
|
port: plain.port,
|
|
2640
2645
|
uuid: plain.uuid,
|
|
2641
|
-
|
|
2646
|
+
extension: plain.exten,
|
|
2642
2647
|
persistent: plain.persistent,
|
|
2648
|
+
creationTime: moment__default['default'](plain.creation_time).toDate(),
|
|
2643
2649
|
});
|
|
2644
2650
|
}
|
|
2645
2651
|
|
|
2646
2652
|
static parseMany(items ) {
|
|
2653
|
+
if (!items) {
|
|
2654
|
+
return [];
|
|
2655
|
+
}
|
|
2647
2656
|
return items.map(plain => Meeting.parse(plain));
|
|
2648
2657
|
}
|
|
2649
2658
|
|
|
@@ -2658,8 +2667,9 @@ class Meeting {
|
|
|
2658
2667
|
ownerUuids,
|
|
2659
2668
|
port,
|
|
2660
2669
|
uri,
|
|
2661
|
-
|
|
2670
|
+
extension,
|
|
2662
2671
|
persistent,
|
|
2672
|
+
creationTime,
|
|
2663
2673
|
} = {}) {
|
|
2664
2674
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
2665
2675
|
this.uri = uri;
|
|
@@ -2667,8 +2677,9 @@ class Meeting {
|
|
|
2667
2677
|
this.ownerUuids = ownerUuids;
|
|
2668
2678
|
this.port = port;
|
|
2669
2679
|
this.uuid = uuid;
|
|
2670
|
-
this.
|
|
2680
|
+
this.extension = extension;
|
|
2671
2681
|
this.persistent = persistent;
|
|
2682
|
+
this.creationTime = creationTime;
|
|
2672
2683
|
|
|
2673
2684
|
// Useful to compare instead of instanceof with minified code
|
|
2674
2685
|
this.type = 'Meeting';
|
|
@@ -2846,6 +2857,10 @@ class ChatMessage {
|
|
|
2846
2857
|
|
|
2847
2858
|
|
|
2848
2859
|
static parseMany(plain ) {
|
|
2860
|
+
if (!plain || !plain.items) {
|
|
2861
|
+
return [];
|
|
2862
|
+
}
|
|
2863
|
+
|
|
2849
2864
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
2850
2865
|
}
|
|
2851
2866
|
|
|
@@ -2955,6 +2970,9 @@ class Voicemail {
|
|
|
2955
2970
|
}
|
|
2956
2971
|
|
|
2957
2972
|
static parseMany(plain ) {
|
|
2973
|
+
if (!plain) {
|
|
2974
|
+
return [];
|
|
2975
|
+
}
|
|
2958
2976
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
2959
2977
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
2960
2978
|
|
|
@@ -3064,6 +3082,9 @@ class Call {
|
|
|
3064
3082
|
|
|
3065
3083
|
|
|
3066
3084
|
static parseMany(plain ) {
|
|
3085
|
+
if (!plain) {
|
|
3086
|
+
return [];
|
|
3087
|
+
}
|
|
3067
3088
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
3068
3089
|
}
|
|
3069
3090
|
|
|
@@ -3236,6 +3257,9 @@ class Recording {
|
|
|
3236
3257
|
|
|
3237
3258
|
|
|
3238
3259
|
static parseMany(recordings = []) {
|
|
3260
|
+
if (!recordings) {
|
|
3261
|
+
return [];
|
|
3262
|
+
}
|
|
3239
3263
|
return recordings.map(item => Recording.parse(item));
|
|
3240
3264
|
}
|
|
3241
3265
|
|
|
@@ -3337,6 +3361,10 @@ class CallLog {
|
|
|
3337
3361
|
}
|
|
3338
3362
|
|
|
3339
3363
|
static parseMany(plain ) {
|
|
3364
|
+
if (!plain || !plain.items) {
|
|
3365
|
+
return [];
|
|
3366
|
+
}
|
|
3367
|
+
|
|
3340
3368
|
return plain.items.map(item => CallLog.parse(item));
|
|
3341
3369
|
}
|
|
3342
3370
|
|
|
@@ -3894,6 +3922,9 @@ class ChatRoom {
|
|
|
3894
3922
|
|
|
3895
3923
|
|
|
3896
3924
|
static parseMany(plain ) {
|
|
3925
|
+
if (!plain || !plain.items) {
|
|
3926
|
+
return [];
|
|
3927
|
+
}
|
|
3897
3928
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
3898
3929
|
}
|
|
3899
3930
|
|