@wazo/sdk 0.37.23 → 0.37.27
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/README.md +95 -57
- package/dist/wazo-sdk.js +3 -3
- package/esm/__tests__/api-client.test.js +12 -7
- package/esm/__tests__/web-rtc-client.test.js +47 -20
- package/esm/api/agentd.js +1 -1
- package/esm/api/amid.js +1 -1
- package/esm/api/application.js +1 -1
- package/esm/api/auth.js +1 -1
- package/esm/api/call-logd.js +1 -1
- package/esm/api/calld.js +1 -1
- package/esm/api/chatd.js +1 -1
- package/esm/api/confd.js +11 -6
- package/esm/api/ctid-ng.js +1 -1
- package/esm/api/dird.js +2 -2
- package/esm/api/webhookd.js +1 -1
- package/esm/api-client.js +12 -7
- package/esm/checker/Checker.js +47 -20
- package/esm/checker/checks/aor.js +12 -7
- package/esm/checker/checks/api.js +12 -7
- package/esm/checker/checks/index.js +47 -20
- package/esm/checker/checks/wazo-websocket.js +1 -1
- package/esm/checker/checks/webrtc-transport.js +47 -20
- package/esm/checker/checks/webrtc.js +47 -20
- package/esm/domain/AdHocAPIConference.js +12 -7
- package/esm/domain/Contact.js +1 -1
- package/esm/domain/Features.js +12 -7
- package/esm/domain/Meeting.js +12 -5
- package/esm/domain/Phone/CTIPhone.js +12 -7
- package/esm/domain/Phone/WebRTCPhone.js +34 -6
- package/esm/domain/__tests__/Contact.test.js +1 -1
- package/esm/domain/__tests__/Meeting.test.js +144 -0
- package/esm/index.js +80 -25
- package/esm/lib/WazoSessionDescriptionHandler.js +9 -4
- package/esm/service/CallApi.js +12 -7
- package/esm/service/IssueReporter.js +1 -1
- package/esm/service/__tests__/IssueReporter.test.js +1 -1
- package/esm/service/getApiClient.js +12 -7
- package/esm/simple/Auth.js +80 -25
- package/esm/simple/Configuration.js +80 -25
- package/esm/simple/Directory.js +12 -7
- package/esm/simple/Phone.js +80 -25
- package/esm/simple/Websocket.js +1 -1
- package/esm/simple/index.js +80 -25
- package/esm/simple/room/LocalParticipant.js +80 -25
- package/esm/simple/room/Participant.js +80 -25
- package/esm/simple/room/RemoteParticipant.js +80 -25
- package/esm/simple/room/Room.js +80 -25
- package/esm/simple/room/SipRoom.js +80 -25
- package/esm/simple/room/Stream.js +80 -25
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +80 -25
- package/esm/simple/utils.js +80 -25
- package/esm/types/WebSocketMessage.js +1 -1
- package/esm/utils/__tests__/api-requester.test.js +1 -1
- package/esm/utils/api-requester.js +1 -1
- package/esm/web-rtc-client.js +47 -20
- package/esm/websocket-client.js +1 -1
- package/lib/__tests__/api-client.test.js +12 -7
- package/lib/__tests__/web-rtc-client.test.js +47 -20
- package/lib/api/agentd.js +1 -1
- package/lib/api/amid.js +1 -1
- package/lib/api/application.js +1 -1
- package/lib/api/auth.js +1 -1
- package/lib/api/call-logd.js +1 -1
- package/lib/api/calld.js +1 -1
- package/lib/api/chatd.js +1 -1
- package/lib/api/confd.js +11 -6
- package/lib/api/ctid-ng.js +1 -1
- package/lib/api/dird.js +2 -2
- package/lib/api/webhookd.js +1 -1
- package/lib/api-client.js +12 -7
- package/lib/checker/Checker.js +47 -20
- package/lib/checker/checks/aor.js +12 -7
- package/lib/checker/checks/api.js +12 -7
- package/lib/checker/checks/index.js +47 -20
- package/lib/checker/checks/wazo-websocket.js +1 -1
- package/lib/checker/checks/webrtc-transport.js +47 -20
- package/lib/checker/checks/webrtc.js +47 -20
- package/lib/domain/AdHocAPIConference.js +12 -7
- package/lib/domain/Contact.js +1 -1
- package/lib/domain/Features.js +12 -7
- package/lib/domain/Meeting.js +16 -5
- package/lib/domain/Phone/CTIPhone.js +12 -7
- package/lib/domain/Phone/WebRTCPhone.js +34 -6
- package/lib/domain/__tests__/Contact.test.js +1 -1
- package/lib/domain/__tests__/Meeting.test.js +150 -0
- package/lib/index.js +80 -25
- package/lib/lib/WazoSessionDescriptionHandler.js +9 -4
- package/lib/service/CallApi.js +12 -7
- package/lib/service/IssueReporter.js +1 -1
- package/lib/service/__tests__/IssueReporter.test.js +1 -1
- package/lib/service/getApiClient.js +12 -7
- package/lib/simple/Auth.js +80 -25
- package/lib/simple/Configuration.js +80 -25
- package/lib/simple/Directory.js +12 -7
- package/lib/simple/Phone.js +80 -25
- package/lib/simple/Websocket.js +1 -1
- package/lib/simple/index.js +80 -25
- package/lib/simple/room/LocalParticipant.js +80 -25
- package/lib/simple/room/Participant.js +80 -25
- package/lib/simple/room/RemoteParticipant.js +80 -25
- package/lib/simple/room/Room.js +80 -25
- package/lib/simple/room/SipRoom.js +80 -25
- package/lib/simple/room/Stream.js +80 -25
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +80 -25
- package/lib/simple/utils.js +80 -25
- package/lib/types/WebSocketMessage.js +2 -0
- package/lib/utils/__tests__/api-requester.test.js +1 -1
- package/lib/utils/api-requester.js +1 -1
- package/lib/web-rtc-client.js +47 -20
- package/lib/websocket-client.js +1 -1
- package/package.json +1 -1
- package/src/domain/Contact.js +1 -1
- package/src/domain/Meeting.js +12 -5
- package/src/domain/Phone/WebRTCPhone.js +33 -5
- package/src/domain/__tests__/Meeting.test.js +50 -0
- package/src/lib/WazoSessionDescriptionHandler.js +8 -3
- package/src/utils/api-requester.js +1 -1
- package/src/web-rtc-client.js +27 -10
|
@@ -116,7 +116,7 @@ const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
|
116
116
|
|
|
117
117
|
// Use a function here to be able to mock it in tests
|
|
118
118
|
const realFetch = () => {
|
|
119
|
-
if (typeof document !== 'undefined') {
|
|
119
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
120
120
|
// Browser
|
|
121
121
|
return window.fetch;
|
|
122
122
|
}
|
|
@@ -1933,7 +1933,7 @@ class Contact {
|
|
|
1933
1933
|
this[key] = old[key] || this[key];
|
|
1934
1934
|
});
|
|
1935
1935
|
|
|
1936
|
-
if (old.lineState
|
|
1936
|
+
if (old.lineState) {
|
|
1937
1937
|
this.lineState = old.lineState;
|
|
1938
1938
|
}
|
|
1939
1939
|
|
|
@@ -2640,8 +2640,9 @@ class ExternalApp {
|
|
|
2640
2640
|
|
|
2641
2641
|
|
|
2642
2642
|
|
|
2643
|
-
|
|
2643
|
+
|
|
2644
2644
|
|
|
2645
|
+
|
|
2645
2646
|
|
|
2646
2647
|
|
|
2647
2648
|
class Meeting {
|
|
@@ -2652,9 +2653,10 @@ class Meeting {
|
|
|
2652
2653
|
|
|
2653
2654
|
|
|
2654
2655
|
|
|
2655
|
-
|
|
2656
|
+
|
|
2656
2657
|
|
|
2657
2658
|
|
|
2659
|
+
|
|
2658
2660
|
|
|
2659
2661
|
static parse(plain ) {
|
|
2660
2662
|
return new Meeting({
|
|
@@ -2664,8 +2666,9 @@ class Meeting {
|
|
|
2664
2666
|
ownerUuids: plain.owner_uuids,
|
|
2665
2667
|
port: plain.port,
|
|
2666
2668
|
uuid: plain.uuid,
|
|
2667
|
-
|
|
2669
|
+
extension: plain.exten,
|
|
2668
2670
|
persistent: plain.persistent,
|
|
2671
|
+
creationTime: moment__default['default'](plain.creation_time).toDate(),
|
|
2669
2672
|
});
|
|
2670
2673
|
}
|
|
2671
2674
|
|
|
@@ -2687,8 +2690,9 @@ class Meeting {
|
|
|
2687
2690
|
ownerUuids,
|
|
2688
2691
|
port,
|
|
2689
2692
|
uri,
|
|
2690
|
-
|
|
2693
|
+
extension,
|
|
2691
2694
|
persistent,
|
|
2695
|
+
creationTime,
|
|
2692
2696
|
} = {}) {
|
|
2693
2697
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
2694
2698
|
this.uri = uri;
|
|
@@ -2696,8 +2700,9 @@ class Meeting {
|
|
|
2696
2700
|
this.ownerUuids = ownerUuids;
|
|
2697
2701
|
this.port = port;
|
|
2698
2702
|
this.uuid = uuid;
|
|
2699
|
-
this.
|
|
2703
|
+
this.extension = extension;
|
|
2700
2704
|
this.persistent = persistent;
|
|
2705
|
+
this.creationTime = creationTime;
|
|
2701
2706
|
|
|
2702
2707
|
// Useful to compare instead of instanceof with minified code
|
|
2703
2708
|
this.type = 'Meeting';
|
|
@@ -6067,11 +6072,16 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
6067
6072
|
|
|
6068
6073
|
// $FlowFixMe
|
|
6069
6074
|
setRemoteSessionDescription(sessionDescription ) {
|
|
6070
|
-
|
|
6075
|
+
try {
|
|
6076
|
+
const result = super.setRemoteSessionDescription(sessionDescription);
|
|
6071
6077
|
|
|
6072
|
-
|
|
6078
|
+
this.eventEmitter.emit('setDescription', sessionDescription);
|
|
6073
6079
|
|
|
6074
|
-
|
|
6080
|
+
return result;
|
|
6081
|
+
} catch (error) {
|
|
6082
|
+
this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
|
|
6083
|
+
throw error;
|
|
6084
|
+
}
|
|
6075
6085
|
}
|
|
6076
6086
|
|
|
6077
6087
|
// Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
|
|
@@ -6976,7 +6986,7 @@ class WebRTCClient extends Emitter {
|
|
|
6976
6986
|
}
|
|
6977
6987
|
|
|
6978
6988
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
6979
|
-
logger$8.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
6989
|
+
logger$8.info('sdk webrtc creating call', { number, enableVideo, audioOnly, conference });
|
|
6980
6990
|
const inviterOptions = {
|
|
6981
6991
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
6982
6992
|
conference,
|
|
@@ -8052,6 +8062,7 @@ class WebRTCClient extends Emitter {
|
|
|
8052
8062
|
const screenSharing = constraints && 'screen' in constraints ? constraints.screen : false;
|
|
8053
8063
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
8054
8064
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
8065
|
+
const mandatoryVideo = constraints && typeof constraints.video === 'object' ? constraints.video.mandatory : {};
|
|
8055
8066
|
|
|
8056
8067
|
logger$8.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
8057
8068
|
|
|
@@ -8059,7 +8070,8 @@ class WebRTCClient extends Emitter {
|
|
|
8059
8070
|
constraints: {
|
|
8060
8071
|
// Exact constraint are not supported with `getDisplayMedia` and we must have a video=false in desktop screenshare
|
|
8061
8072
|
audio: screenSharing ? !isDesktop : (withAudio ? this._getAudioConstraints() : false),
|
|
8062
|
-
video: screenSharing ? (isDesktop
|
|
8073
|
+
video: screenSharing ? (isDesktop
|
|
8074
|
+
? ({ mandatory: { chromeMediaSource: 'desktop', ...(mandatoryVideo || {}) } }) : { cursor: 'always' })
|
|
8063
8075
|
: this._getVideoConstraints(enableVideo),
|
|
8064
8076
|
screen: screenSharing,
|
|
8065
8077
|
desktop: isDesktop,
|
|
@@ -8394,12 +8406,14 @@ class WebRTCClient extends Emitter {
|
|
|
8394
8406
|
|
|
8395
8407
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
8396
8408
|
|
|
8397
|
-
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
|
|
8401
|
-
|
|
8402
|
-
|
|
8409
|
+
if (pc) {
|
|
8410
|
+
pc.oniceconnectionstatechange = () => {
|
|
8411
|
+
logger$8.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
8412
|
+
if (pc.iceConnectionState === 'disconnected') {
|
|
8413
|
+
this.eventEmitter.emit(ON_DISCONNECTED$1);
|
|
8414
|
+
}
|
|
8415
|
+
};
|
|
8416
|
+
}
|
|
8403
8417
|
|
|
8404
8418
|
if (withEvent) {
|
|
8405
8419
|
this.eventEmitter.emit(ACCEPTED, session, sessionDialog);
|
|
@@ -8609,13 +8623,17 @@ class WebRTCClient extends Emitter {
|
|
|
8609
8623
|
const nbStats = this.sessionNetworkStats[sessionId].length;
|
|
8610
8624
|
const lastNetworkStats = this.sessionNetworkStats[sessionId][nbStats - 1];
|
|
8611
8625
|
const lastAudioSent = lastNetworkStats ? lastNetworkStats.audioBytesSent : 0;
|
|
8626
|
+
const lastAudioContentSent = lastNetworkStats ? lastNetworkStats.audioContentSent : 0;
|
|
8612
8627
|
const lastVideoSent = lastNetworkStats ? lastNetworkStats.videoBytesSent : 0;
|
|
8613
8628
|
const lastAudioReceived = lastNetworkStats ? lastNetworkStats.audioBytesReceived : 0;
|
|
8629
|
+
const lastAudioContentReceived = lastNetworkStats ? lastNetworkStats.audioContentReceived : 0;
|
|
8614
8630
|
const lastVideoReceived = lastNetworkStats ? lastNetworkStats.videoBytesReceived : 0;
|
|
8615
8631
|
const lastTransportSent = lastNetworkStats ? lastNetworkStats.transportSent : 0;
|
|
8616
8632
|
const lastTransportReceived = lastNetworkStats ? lastNetworkStats.transportReceived : 0;
|
|
8617
|
-
let audioBytesSent = 0;
|
|
8618
|
-
let audioBytesReceived = 0;
|
|
8633
|
+
let audioBytesSent = 0; // content + header
|
|
8634
|
+
let audioBytesReceived = 0; // content + header
|
|
8635
|
+
let audioContentSent = 0; // useful to detect blank call
|
|
8636
|
+
let audioContentReceived = 0;
|
|
8619
8637
|
let videoBytesSent = 0;
|
|
8620
8638
|
let videoBytesReceived = 0;
|
|
8621
8639
|
let transportSent = 0;
|
|
@@ -8625,6 +8643,7 @@ class WebRTCClient extends Emitter {
|
|
|
8625
8643
|
stats.forEach(report => {
|
|
8626
8644
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
8627
8645
|
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8646
|
+
audioContentSent += Number(report.bytesSent);
|
|
8628
8647
|
}
|
|
8629
8648
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
8630
8649
|
audioBytesSent += Number(report.bytesSent);
|
|
@@ -8636,6 +8655,7 @@ class WebRTCClient extends Emitter {
|
|
|
8636
8655
|
packetsLost += Number(report.packetsLost);
|
|
8637
8656
|
networkStats.packetsReceived = Number(report.packetsReceived);
|
|
8638
8657
|
audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8658
|
+
audioContentReceived += Number(report.bytesReceived);
|
|
8639
8659
|
}
|
|
8640
8660
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
8641
8661
|
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
@@ -8664,10 +8684,17 @@ class WebRTCClient extends Emitter {
|
|
|
8664
8684
|
});
|
|
8665
8685
|
|
|
8666
8686
|
networkStats.packetsLost = packetsLost;
|
|
8687
|
+
|
|
8667
8688
|
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
8668
8689
|
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
8669
8690
|
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
8670
8691
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
8692
|
+
|
|
8693
|
+
networkStats.totalAudioContentSent = audioContentSent;
|
|
8694
|
+
networkStats.audioContentSent = audioContentSent - lastAudioContentSent;
|
|
8695
|
+
networkStats.totalAudioBytesReceived = audioContentReceived - lastAudioContentReceived;
|
|
8696
|
+
networkStats.audioContentReceived = audioContentReceived;
|
|
8697
|
+
|
|
8671
8698
|
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
8672
8699
|
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
8673
8700
|
networkStats.totalVideoBytesReceived = videoBytesReceived;
|
|
@@ -8879,6 +8906,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8879
8906
|
constraints,
|
|
8880
8907
|
audioOnly,
|
|
8881
8908
|
conference,
|
|
8909
|
+
iceRestart,
|
|
8882
8910
|
});
|
|
8883
8911
|
|
|
8884
8912
|
if (!sipSession) {
|
|
@@ -8982,6 +9010,11 @@ class WebRTCPhone extends Emitter {
|
|
|
8982
9010
|
|
|
8983
9011
|
this.client.downgradeToAudio(sipSession);
|
|
8984
9012
|
|
|
9013
|
+
if (callSession) {
|
|
9014
|
+
callSession.cameraEnabled = false;
|
|
9015
|
+
this._updateCallSession(callSession);
|
|
9016
|
+
}
|
|
9017
|
+
|
|
8985
9018
|
if (withMessage) {
|
|
8986
9019
|
this._sendReinviteMessage(callSession, false);
|
|
8987
9020
|
}
|
|
@@ -9009,6 +9042,11 @@ class WebRTCPhone extends Emitter {
|
|
|
9009
9042
|
|
|
9010
9043
|
const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
|
|
9011
9044
|
|
|
9045
|
+
if (callSession) {
|
|
9046
|
+
callSession.cameraEnabled = true;
|
|
9047
|
+
this._updateCallSession(callSession);
|
|
9048
|
+
}
|
|
9049
|
+
|
|
9012
9050
|
// If no stream is returned, it means we have to reinvite
|
|
9013
9051
|
if (!newStream) {
|
|
9014
9052
|
return true;
|
|
@@ -9278,7 +9316,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9278
9316
|
}
|
|
9279
9317
|
|
|
9280
9318
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
9281
|
-
logger$7.info('WebRTC phone -
|
|
9319
|
+
logger$7.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
9282
9320
|
|
|
9283
9321
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
9284
9322
|
this.currentSipSession = sipSession;
|
|
@@ -9347,6 +9385,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9347
9385
|
_onCallTerminated(sipSession ) {
|
|
9348
9386
|
logger$7.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
9349
9387
|
|
|
9388
|
+
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9350
9389
|
const callSession = this._createCallSession(sipSession);
|
|
9351
9390
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
9352
9391
|
const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
|
|
@@ -9364,7 +9403,6 @@ class WebRTCPhone extends Emitter {
|
|
|
9364
9403
|
}, 5);
|
|
9365
9404
|
}
|
|
9366
9405
|
|
|
9367
|
-
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9368
9406
|
if (sipSessionId) {
|
|
9369
9407
|
this.removeIncomingSessions(sipSessionId);
|
|
9370
9408
|
}
|
|
@@ -9790,7 +9828,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9790
9828
|
// @TODO: line is not used here
|
|
9791
9829
|
async makeCall(number , line , cameraEnabled ,
|
|
9792
9830
|
audioOnly = false, conference = false) {
|
|
9793
|
-
logger$7.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
|
|
9831
|
+
logger$7.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled, audioOnly, conference });
|
|
9794
9832
|
if (!number) {
|
|
9795
9833
|
return Promise.resolve(null);
|
|
9796
9834
|
}
|
|
@@ -10009,8 +10047,12 @@ class WebRTCPhone extends Emitter {
|
|
|
10009
10047
|
}
|
|
10010
10048
|
|
|
10011
10049
|
const sessionId = this.incomingSessions[0];
|
|
10050
|
+
const sipSession = this.client.getSipSession(sessionId);
|
|
10051
|
+
if (!sipSession) {
|
|
10052
|
+
return null;
|
|
10053
|
+
}
|
|
10012
10054
|
|
|
10013
|
-
return this._createCallSession(
|
|
10055
|
+
return this._createCallSession(sipSession);
|
|
10014
10056
|
}
|
|
10015
10057
|
|
|
10016
10058
|
sendMessage(sipSession = null, body , contentType = 'text/plain') {
|
|
@@ -10151,9 +10193,13 @@ class WebRTCPhone extends Emitter {
|
|
|
10151
10193
|
if (this.shouldSendReinvite && this.currentSipSession
|
|
10152
10194
|
&& this.currentSipSession.state === sessionState.SessionState.Established) {
|
|
10153
10195
|
this.shouldSendReinvite = false;
|
|
10196
|
+
const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
|
|
10197
|
+
const isConference = pc ? pc.sfu : false;
|
|
10198
|
+
const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
|
|
10199
|
+
|
|
10154
10200
|
try {
|
|
10155
10201
|
// Send reinvite with iceRestart
|
|
10156
|
-
this.sendReinvite(this.currentCallSession, null,
|
|
10202
|
+
this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
|
|
10157
10203
|
} catch (e) {
|
|
10158
10204
|
logger$7.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
10159
10205
|
}
|
|
@@ -10237,6 +10283,15 @@ class WebRTCPhone extends Emitter {
|
|
|
10237
10283
|
return this.client.getSipSessionId(sipSession);
|
|
10238
10284
|
}
|
|
10239
10285
|
|
|
10286
|
+
_updateCallSession(callSession ) {
|
|
10287
|
+
const sipSession = this.findSipSession(callSession);
|
|
10288
|
+
const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
|
|
10289
|
+
|
|
10290
|
+
if (sipSessionId) {
|
|
10291
|
+
this.callSessions[sipSessionId] = callSession;
|
|
10292
|
+
}
|
|
10293
|
+
}
|
|
10294
|
+
|
|
10240
10295
|
_onMessage(message ) {
|
|
10241
10296
|
if (!message || message.method !== 'MESSAGE') {
|
|
10242
10297
|
return;
|
|
@@ -1246,7 +1246,7 @@ class Contact {
|
|
|
1246
1246
|
this[key] = old[key] || this[key];
|
|
1247
1247
|
});
|
|
1248
1248
|
|
|
1249
|
-
if (old.lineState
|
|
1249
|
+
if (old.lineState) {
|
|
1250
1250
|
this.lineState = old.lineState;
|
|
1251
1251
|
}
|
|
1252
1252
|
|
|
@@ -1961,7 +1961,7 @@ const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
|
1961
1961
|
|
|
1962
1962
|
// Use a function here to be able to mock it in tests
|
|
1963
1963
|
const realFetch = () => {
|
|
1964
|
-
if (typeof document !== 'undefined') {
|
|
1964
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
1965
1965
|
// Browser
|
|
1966
1966
|
return window.fetch;
|
|
1967
1967
|
}
|
|
@@ -2640,8 +2640,9 @@ class ExternalApp {
|
|
|
2640
2640
|
|
|
2641
2641
|
|
|
2642
2642
|
|
|
2643
|
-
|
|
2643
|
+
|
|
2644
2644
|
|
|
2645
|
+
|
|
2645
2646
|
|
|
2646
2647
|
|
|
2647
2648
|
class Meeting {
|
|
@@ -2652,9 +2653,10 @@ class Meeting {
|
|
|
2652
2653
|
|
|
2653
2654
|
|
|
2654
2655
|
|
|
2655
|
-
|
|
2656
|
+
|
|
2656
2657
|
|
|
2657
2658
|
|
|
2659
|
+
|
|
2658
2660
|
|
|
2659
2661
|
static parse(plain ) {
|
|
2660
2662
|
return new Meeting({
|
|
@@ -2664,8 +2666,9 @@ class Meeting {
|
|
|
2664
2666
|
ownerUuids: plain.owner_uuids,
|
|
2665
2667
|
port: plain.port,
|
|
2666
2668
|
uuid: plain.uuid,
|
|
2667
|
-
|
|
2669
|
+
extension: plain.exten,
|
|
2668
2670
|
persistent: plain.persistent,
|
|
2671
|
+
creationTime: moment__default['default'](plain.creation_time).toDate(),
|
|
2669
2672
|
});
|
|
2670
2673
|
}
|
|
2671
2674
|
|
|
@@ -2687,8 +2690,9 @@ class Meeting {
|
|
|
2687
2690
|
ownerUuids,
|
|
2688
2691
|
port,
|
|
2689
2692
|
uri,
|
|
2690
|
-
|
|
2693
|
+
extension,
|
|
2691
2694
|
persistent,
|
|
2695
|
+
creationTime,
|
|
2692
2696
|
} = {}) {
|
|
2693
2697
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
2694
2698
|
this.uri = uri;
|
|
@@ -2696,8 +2700,9 @@ class Meeting {
|
|
|
2696
2700
|
this.ownerUuids = ownerUuids;
|
|
2697
2701
|
this.port = port;
|
|
2698
2702
|
this.uuid = uuid;
|
|
2699
|
-
this.
|
|
2703
|
+
this.extension = extension;
|
|
2700
2704
|
this.persistent = persistent;
|
|
2705
|
+
this.creationTime = creationTime;
|
|
2701
2706
|
|
|
2702
2707
|
// Useful to compare instead of instanceof with minified code
|
|
2703
2708
|
this.type = 'Meeting';
|
|
@@ -6067,11 +6072,16 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
6067
6072
|
|
|
6068
6073
|
// $FlowFixMe
|
|
6069
6074
|
setRemoteSessionDescription(sessionDescription ) {
|
|
6070
|
-
|
|
6075
|
+
try {
|
|
6076
|
+
const result = super.setRemoteSessionDescription(sessionDescription);
|
|
6071
6077
|
|
|
6072
|
-
|
|
6078
|
+
this.eventEmitter.emit('setDescription', sessionDescription);
|
|
6073
6079
|
|
|
6074
|
-
|
|
6080
|
+
return result;
|
|
6081
|
+
} catch (error) {
|
|
6082
|
+
this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
|
|
6083
|
+
throw error;
|
|
6084
|
+
}
|
|
6075
6085
|
}
|
|
6076
6086
|
|
|
6077
6087
|
// Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
|
|
@@ -6976,7 +6986,7 @@ class WebRTCClient extends Emitter {
|
|
|
6976
6986
|
}
|
|
6977
6987
|
|
|
6978
6988
|
call(number , enableVideo , audioOnly = false, conference = false) {
|
|
6979
|
-
logger$8.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
|
|
6989
|
+
logger$8.info('sdk webrtc creating call', { number, enableVideo, audioOnly, conference });
|
|
6980
6990
|
const inviterOptions = {
|
|
6981
6991
|
sessionDescriptionHandlerOptionsReInvite: {
|
|
6982
6992
|
conference,
|
|
@@ -8052,6 +8062,7 @@ class WebRTCClient extends Emitter {
|
|
|
8052
8062
|
const screenSharing = constraints && 'screen' in constraints ? constraints.screen : false;
|
|
8053
8063
|
const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
|
|
8054
8064
|
const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
|
|
8065
|
+
const mandatoryVideo = constraints && typeof constraints.video === 'object' ? constraints.video.mandatory : {};
|
|
8055
8066
|
|
|
8056
8067
|
logger$8.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
|
|
8057
8068
|
|
|
@@ -8059,7 +8070,8 @@ class WebRTCClient extends Emitter {
|
|
|
8059
8070
|
constraints: {
|
|
8060
8071
|
// Exact constraint are not supported with `getDisplayMedia` and we must have a video=false in desktop screenshare
|
|
8061
8072
|
audio: screenSharing ? !isDesktop : (withAudio ? this._getAudioConstraints() : false),
|
|
8062
|
-
video: screenSharing ? (isDesktop
|
|
8073
|
+
video: screenSharing ? (isDesktop
|
|
8074
|
+
? ({ mandatory: { chromeMediaSource: 'desktop', ...(mandatoryVideo || {}) } }) : { cursor: 'always' })
|
|
8063
8075
|
: this._getVideoConstraints(enableVideo),
|
|
8064
8076
|
screen: screenSharing,
|
|
8065
8077
|
desktop: isDesktop,
|
|
@@ -8394,12 +8406,14 @@ class WebRTCClient extends Emitter {
|
|
|
8394
8406
|
|
|
8395
8407
|
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
8396
8408
|
|
|
8397
|
-
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
|
|
8401
|
-
|
|
8402
|
-
|
|
8409
|
+
if (pc) {
|
|
8410
|
+
pc.oniceconnectionstatechange = () => {
|
|
8411
|
+
logger$8.info('on ice connection state changed', { state: pc.iceConnectionState });
|
|
8412
|
+
if (pc.iceConnectionState === 'disconnected') {
|
|
8413
|
+
this.eventEmitter.emit(ON_DISCONNECTED$1);
|
|
8414
|
+
}
|
|
8415
|
+
};
|
|
8416
|
+
}
|
|
8403
8417
|
|
|
8404
8418
|
if (withEvent) {
|
|
8405
8419
|
this.eventEmitter.emit(ACCEPTED, session, sessionDialog);
|
|
@@ -8609,13 +8623,17 @@ class WebRTCClient extends Emitter {
|
|
|
8609
8623
|
const nbStats = this.sessionNetworkStats[sessionId].length;
|
|
8610
8624
|
const lastNetworkStats = this.sessionNetworkStats[sessionId][nbStats - 1];
|
|
8611
8625
|
const lastAudioSent = lastNetworkStats ? lastNetworkStats.audioBytesSent : 0;
|
|
8626
|
+
const lastAudioContentSent = lastNetworkStats ? lastNetworkStats.audioContentSent : 0;
|
|
8612
8627
|
const lastVideoSent = lastNetworkStats ? lastNetworkStats.videoBytesSent : 0;
|
|
8613
8628
|
const lastAudioReceived = lastNetworkStats ? lastNetworkStats.audioBytesReceived : 0;
|
|
8629
|
+
const lastAudioContentReceived = lastNetworkStats ? lastNetworkStats.audioContentReceived : 0;
|
|
8614
8630
|
const lastVideoReceived = lastNetworkStats ? lastNetworkStats.videoBytesReceived : 0;
|
|
8615
8631
|
const lastTransportSent = lastNetworkStats ? lastNetworkStats.transportSent : 0;
|
|
8616
8632
|
const lastTransportReceived = lastNetworkStats ? lastNetworkStats.transportReceived : 0;
|
|
8617
|
-
let audioBytesSent = 0;
|
|
8618
|
-
let audioBytesReceived = 0;
|
|
8633
|
+
let audioBytesSent = 0; // content + header
|
|
8634
|
+
let audioBytesReceived = 0; // content + header
|
|
8635
|
+
let audioContentSent = 0; // useful to detect blank call
|
|
8636
|
+
let audioContentReceived = 0;
|
|
8619
8637
|
let videoBytesSent = 0;
|
|
8620
8638
|
let videoBytesReceived = 0;
|
|
8621
8639
|
let transportSent = 0;
|
|
@@ -8625,6 +8643,7 @@ class WebRTCClient extends Emitter {
|
|
|
8625
8643
|
stats.forEach(report => {
|
|
8626
8644
|
if (report.type === 'outbound-rtp' && report.kind === 'audio') {
|
|
8627
8645
|
audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
|
|
8646
|
+
audioContentSent += Number(report.bytesSent);
|
|
8628
8647
|
}
|
|
8629
8648
|
if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
|
|
8630
8649
|
audioBytesSent += Number(report.bytesSent);
|
|
@@ -8636,6 +8655,7 @@ class WebRTCClient extends Emitter {
|
|
|
8636
8655
|
packetsLost += Number(report.packetsLost);
|
|
8637
8656
|
networkStats.packetsReceived = Number(report.packetsReceived);
|
|
8638
8657
|
audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
8658
|
+
audioContentReceived += Number(report.bytesReceived);
|
|
8639
8659
|
}
|
|
8640
8660
|
if (report.type === 'inbound-rtp' && report.kind === 'video') {
|
|
8641
8661
|
videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
|
|
@@ -8664,10 +8684,17 @@ class WebRTCClient extends Emitter {
|
|
|
8664
8684
|
});
|
|
8665
8685
|
|
|
8666
8686
|
networkStats.packetsLost = packetsLost;
|
|
8687
|
+
|
|
8667
8688
|
networkStats.totalAudioBytesSent = audioBytesSent;
|
|
8668
8689
|
networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
|
|
8669
8690
|
networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
|
|
8670
8691
|
networkStats.audioBytesReceived = audioBytesReceived;
|
|
8692
|
+
|
|
8693
|
+
networkStats.totalAudioContentSent = audioContentSent;
|
|
8694
|
+
networkStats.audioContentSent = audioContentSent - lastAudioContentSent;
|
|
8695
|
+
networkStats.totalAudioBytesReceived = audioContentReceived - lastAudioContentReceived;
|
|
8696
|
+
networkStats.audioContentReceived = audioContentReceived;
|
|
8697
|
+
|
|
8671
8698
|
networkStats.totalVideoBytesSent = videoBytesSent;
|
|
8672
8699
|
networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
|
|
8673
8700
|
networkStats.totalVideoBytesReceived = videoBytesReceived;
|
|
@@ -8879,6 +8906,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8879
8906
|
constraints,
|
|
8880
8907
|
audioOnly,
|
|
8881
8908
|
conference,
|
|
8909
|
+
iceRestart,
|
|
8882
8910
|
});
|
|
8883
8911
|
|
|
8884
8912
|
if (!sipSession) {
|
|
@@ -8982,6 +9010,11 @@ class WebRTCPhone extends Emitter {
|
|
|
8982
9010
|
|
|
8983
9011
|
this.client.downgradeToAudio(sipSession);
|
|
8984
9012
|
|
|
9013
|
+
if (callSession) {
|
|
9014
|
+
callSession.cameraEnabled = false;
|
|
9015
|
+
this._updateCallSession(callSession);
|
|
9016
|
+
}
|
|
9017
|
+
|
|
8985
9018
|
if (withMessage) {
|
|
8986
9019
|
this._sendReinviteMessage(callSession, false);
|
|
8987
9020
|
}
|
|
@@ -9009,6 +9042,11 @@ class WebRTCPhone extends Emitter {
|
|
|
9009
9042
|
|
|
9010
9043
|
const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
|
|
9011
9044
|
|
|
9045
|
+
if (callSession) {
|
|
9046
|
+
callSession.cameraEnabled = true;
|
|
9047
|
+
this._updateCallSession(callSession);
|
|
9048
|
+
}
|
|
9049
|
+
|
|
9012
9050
|
// If no stream is returned, it means we have to reinvite
|
|
9013
9051
|
if (!newStream) {
|
|
9014
9052
|
return true;
|
|
@@ -9278,7 +9316,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9278
9316
|
}
|
|
9279
9317
|
|
|
9280
9318
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
9281
|
-
logger$7.info('WebRTC phone -
|
|
9319
|
+
logger$7.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
9282
9320
|
|
|
9283
9321
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
9284
9322
|
this.currentSipSession = sipSession;
|
|
@@ -9347,6 +9385,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9347
9385
|
_onCallTerminated(sipSession ) {
|
|
9348
9386
|
logger$7.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
9349
9387
|
|
|
9388
|
+
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9350
9389
|
const callSession = this._createCallSession(sipSession);
|
|
9351
9390
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
9352
9391
|
const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
|
|
@@ -9364,7 +9403,6 @@ class WebRTCPhone extends Emitter {
|
|
|
9364
9403
|
}, 5);
|
|
9365
9404
|
}
|
|
9366
9405
|
|
|
9367
|
-
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9368
9406
|
if (sipSessionId) {
|
|
9369
9407
|
this.removeIncomingSessions(sipSessionId);
|
|
9370
9408
|
}
|
|
@@ -9790,7 +9828,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9790
9828
|
// @TODO: line is not used here
|
|
9791
9829
|
async makeCall(number , line , cameraEnabled ,
|
|
9792
9830
|
audioOnly = false, conference = false) {
|
|
9793
|
-
logger$7.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
|
|
9831
|
+
logger$7.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled, audioOnly, conference });
|
|
9794
9832
|
if (!number) {
|
|
9795
9833
|
return Promise.resolve(null);
|
|
9796
9834
|
}
|
|
@@ -10009,8 +10047,12 @@ class WebRTCPhone extends Emitter {
|
|
|
10009
10047
|
}
|
|
10010
10048
|
|
|
10011
10049
|
const sessionId = this.incomingSessions[0];
|
|
10050
|
+
const sipSession = this.client.getSipSession(sessionId);
|
|
10051
|
+
if (!sipSession) {
|
|
10052
|
+
return null;
|
|
10053
|
+
}
|
|
10012
10054
|
|
|
10013
|
-
return this._createCallSession(
|
|
10055
|
+
return this._createCallSession(sipSession);
|
|
10014
10056
|
}
|
|
10015
10057
|
|
|
10016
10058
|
sendMessage(sipSession = null, body , contentType = 'text/plain') {
|
|
@@ -10151,9 +10193,13 @@ class WebRTCPhone extends Emitter {
|
|
|
10151
10193
|
if (this.shouldSendReinvite && this.currentSipSession
|
|
10152
10194
|
&& this.currentSipSession.state === sessionState.SessionState.Established) {
|
|
10153
10195
|
this.shouldSendReinvite = false;
|
|
10196
|
+
const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
|
|
10197
|
+
const isConference = pc ? pc.sfu : false;
|
|
10198
|
+
const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
|
|
10199
|
+
|
|
10154
10200
|
try {
|
|
10155
10201
|
// Send reinvite with iceRestart
|
|
10156
|
-
this.sendReinvite(this.currentCallSession, null,
|
|
10202
|
+
this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
|
|
10157
10203
|
} catch (e) {
|
|
10158
10204
|
logger$7.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
10159
10205
|
}
|
|
@@ -10237,6 +10283,15 @@ class WebRTCPhone extends Emitter {
|
|
|
10237
10283
|
return this.client.getSipSessionId(sipSession);
|
|
10238
10284
|
}
|
|
10239
10285
|
|
|
10286
|
+
_updateCallSession(callSession ) {
|
|
10287
|
+
const sipSession = this.findSipSession(callSession);
|
|
10288
|
+
const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
|
|
10289
|
+
|
|
10290
|
+
if (sipSessionId) {
|
|
10291
|
+
this.callSessions[sipSessionId] = callSession;
|
|
10292
|
+
}
|
|
10293
|
+
}
|
|
10294
|
+
|
|
10240
10295
|
_onMessage(message ) {
|
|
10241
10296
|
if (!message || message.method !== 'MESSAGE') {
|
|
10242
10297
|
return;
|