@wazo/sdk 0.37.20 → 0.37.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/wazo-sdk.js +6 -6
- package/esm/__tests__/api-client.test.js +91 -21
- package/esm/__tests__/web-rtc-client.test.js +214 -165
- package/esm/api/agentd.js +25 -2
- package/esm/api/amid.js +26 -3
- package/esm/api/application.js +25 -2
- package/esm/api/auth.js +25 -2
- package/esm/api/call-logd.js +34 -4
- package/esm/api/calld.js +35 -2
- package/esm/api/chatd.js +32 -2
- package/esm/api/confd.js +56 -9
- package/esm/api/ctid-ng.js +38 -5
- package/esm/api/dird.js +29 -3
- package/esm/api/webhookd.js +26 -3
- package/esm/api-client.js +91 -21
- package/esm/checker/Checker.js +241 -190
- package/esm/checker/checks/aor.js +91 -21
- package/esm/checker/checks/api.js +91 -21
- package/esm/checker/checks/index.js +231 -180
- package/esm/checker/checks/wazo-websocket.js +42 -17
- package/esm/checker/checks/webrtc-transport.js +214 -165
- package/esm/checker/checks/webrtc.js +214 -165
- package/esm/domain/AdHocAPIConference.js +91 -21
- package/esm/domain/Call.js +3 -0
- package/esm/domain/CallLog.js +8 -1
- package/esm/domain/ChatMessage.js +4 -0
- package/esm/domain/ChatRoom.js +3 -0
- package/esm/domain/Contact.js +4 -1
- package/esm/domain/Features.js +91 -21
- package/esm/domain/Meeting.js +28 -5
- package/esm/domain/Phone/CTIPhone.js +109 -35
- package/esm/domain/Phone/WebRTCPhone.js +159 -102
- package/esm/domain/Recording.js +3 -0
- package/esm/domain/Voicemail.js +3 -0
- package/esm/domain/__tests__/Call.test.js +3 -0
- package/esm/domain/__tests__/CallLog.test.js +8 -1
- package/esm/domain/__tests__/Contact.test.js +4 -1
- package/esm/domain/__tests__/Meeting.test.js +144 -0
- package/esm/domain/__tests__/Voicemail.test.js +3 -0
- package/esm/index.js +509 -414
- package/esm/lib/WazoSessionDescriptionHandler.js +26 -41
- package/esm/service/CallApi.js +91 -21
- package/esm/service/IssueReporter.js +26 -3
- package/esm/service/__tests__/IssueReporter.test.js +26 -3
- package/esm/service/getApiClient.js +91 -21
- package/esm/simple/Auth.js +499 -404
- package/esm/simple/Configuration.js +499 -404
- package/esm/simple/Directory.js +91 -21
- package/esm/simple/Phone.js +499 -404
- package/esm/simple/Websocket.js +45 -19
- package/esm/simple/index.js +503 -408
- package/esm/simple/room/LocalParticipant.js +503 -408
- package/esm/simple/room/Participant.js +503 -408
- package/esm/simple/room/RemoteParticipant.js +503 -408
- package/esm/simple/room/Room.js +504 -409
- package/esm/simple/room/SipRoom.js +503 -408
- package/esm/simple/room/Stream.js +503 -408
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +503 -408
- package/esm/simple/utils.js +503 -408
- package/esm/types/WebSocketMessage.js +1 -1
- package/esm/utils/__tests__/api-requester.test.js +25 -2
- package/esm/utils/api-requester.js +25 -2
- package/esm/web-rtc-client.js +214 -165
- package/esm/websocket-client.js +43 -18
- package/lib/__tests__/api-client.test.js +91 -21
- package/lib/__tests__/web-rtc-client.test.js +214 -165
- package/lib/api/agentd.js +25 -2
- package/lib/api/amid.js +26 -3
- package/lib/api/application.js +25 -2
- package/lib/api/auth.js +25 -2
- package/lib/api/call-logd.js +34 -4
- package/lib/api/calld.js +35 -2
- package/lib/api/chatd.js +32 -2
- package/lib/api/confd.js +56 -9
- package/lib/api/ctid-ng.js +38 -5
- package/lib/api/dird.js +29 -3
- package/lib/api/webhookd.js +26 -3
- package/lib/api-client.js +91 -21
- package/lib/checker/Checker.js +241 -190
- package/lib/checker/checks/aor.js +91 -21
- package/lib/checker/checks/api.js +91 -21
- package/lib/checker/checks/index.js +231 -180
- package/lib/checker/checks/wazo-websocket.js +42 -17
- package/lib/checker/checks/webrtc-transport.js +214 -165
- package/lib/checker/checks/webrtc.js +214 -165
- package/lib/domain/AdHocAPIConference.js +91 -21
- package/lib/domain/Call.js +3 -0
- package/lib/domain/CallLog.js +8 -1
- package/lib/domain/ChatMessage.js +4 -0
- package/lib/domain/ChatRoom.js +3 -0
- package/lib/domain/Contact.js +4 -1
- package/lib/domain/Features.js +91 -21
- package/lib/domain/Meeting.js +32 -5
- package/lib/domain/Phone/CTIPhone.js +109 -35
- package/lib/domain/Phone/WebRTCPhone.js +159 -102
- package/lib/domain/Recording.js +3 -0
- package/lib/domain/Voicemail.js +3 -0
- package/lib/domain/__tests__/Call.test.js +3 -0
- package/lib/domain/__tests__/CallLog.test.js +8 -1
- package/lib/domain/__tests__/Contact.test.js +4 -1
- package/lib/domain/__tests__/Meeting.test.js +150 -0
- package/lib/domain/__tests__/Voicemail.test.js +3 -0
- package/lib/index.js +509 -414
- package/lib/lib/WazoSessionDescriptionHandler.js +26 -41
- package/lib/service/CallApi.js +91 -21
- package/lib/service/IssueReporter.js +26 -3
- package/lib/service/__tests__/IssueReporter.test.js +26 -3
- package/lib/service/getApiClient.js +91 -21
- package/lib/simple/Auth.js +499 -404
- package/lib/simple/Configuration.js +499 -404
- package/lib/simple/Directory.js +91 -21
- package/lib/simple/Phone.js +499 -404
- package/lib/simple/Websocket.js +45 -19
- package/lib/simple/index.js +503 -408
- package/lib/simple/room/LocalParticipant.js +503 -408
- package/lib/simple/room/Participant.js +503 -408
- package/lib/simple/room/RemoteParticipant.js +503 -408
- package/lib/simple/room/Room.js +504 -409
- package/lib/simple/room/SipRoom.js +503 -408
- package/lib/simple/room/Stream.js +503 -408
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +503 -408
- package/lib/simple/utils.js +503 -408
- package/lib/types/WebSocketMessage.js +2 -0
- package/lib/utils/__tests__/api-requester.test.js +25 -2
- package/lib/utils/api-requester.js +25 -2
- package/lib/web-rtc-client.js +214 -165
- package/lib/websocket-client.js +43 -17
- package/package.json +1 -1
- package/src/api/confd.js +5 -2
- package/src/domain/Call.js +3 -0
- package/src/domain/CallLog.js +4 -0
- package/src/domain/ChatMessage.js +4 -0
- package/src/domain/ChatRoom.js +3 -0
- package/src/domain/Contact.js +3 -0
- package/src/domain/Meeting.js +28 -5
- package/src/domain/Phone/CTIPhone.js +4 -0
- package/src/domain/Phone/Phone.js +2 -0
- package/src/domain/Phone/WebRTCPhone.js +49 -15
- package/src/domain/Recording.js +3 -0
- package/src/domain/Voicemail.js +3 -0
- package/src/domain/__tests__/Meeting.test.js +50 -0
- package/src/lib/WazoSessionDescriptionHandler.js +1 -35
- package/src/service/IssueReporter.js +25 -2
- package/src/simple/Phone.js +5 -0
- package/src/types/WebSocketMessage.js +5 -1
- package/src/web-rtc-client.js +41 -24
- package/src/websocket-client.js +2 -0
|
@@ -401,7 +401,7 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
|
|
|
401
401
|
|
|
402
402
|
/* */
|
|
403
403
|
|
|
404
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
404
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
405
405
|
|
|
406
406
|
// Use a function here to be able to mock it in tests
|
|
407
407
|
const realFetch = () => {
|
|
@@ -487,6 +487,7 @@ class IssueReporter {
|
|
|
487
487
|
|
|
488
488
|
|
|
489
489
|
|
|
490
|
+
|
|
490
491
|
|
|
491
492
|
constructor() {
|
|
492
493
|
addLevelsTo(this);
|
|
@@ -498,12 +499,17 @@ class IssueReporter {
|
|
|
498
499
|
this.bufferTimeout = null;
|
|
499
500
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
500
501
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
502
|
+
this._callback = null;
|
|
501
503
|
}
|
|
502
504
|
|
|
503
505
|
init() {
|
|
504
506
|
this._catchConsole();
|
|
505
507
|
}
|
|
506
508
|
|
|
509
|
+
setCallback(cb ) {
|
|
510
|
+
this._callback = cb;
|
|
511
|
+
}
|
|
512
|
+
|
|
507
513
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
508
514
|
this.remoteClientConfiguration = configuration;
|
|
509
515
|
}
|
|
@@ -539,6 +545,7 @@ class IssueReporter {
|
|
|
539
545
|
|
|
540
546
|
// Handle category label
|
|
541
547
|
let category = null;
|
|
548
|
+
let skipSendToRemote = false;
|
|
542
549
|
let extra = {};
|
|
543
550
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
544
551
|
category = args[0].split('=')[1];
|
|
@@ -554,6 +561,7 @@ class IssueReporter {
|
|
|
554
561
|
errorMessage: lastArg.message,
|
|
555
562
|
errorStack: lastArg.stack,
|
|
556
563
|
errorType: lastArg.constructor.name,
|
|
564
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
557
565
|
};
|
|
558
566
|
} else {
|
|
559
567
|
extra = lastArg;
|
|
@@ -562,6 +570,11 @@ class IssueReporter {
|
|
|
562
570
|
args.splice(1, 1);
|
|
563
571
|
}
|
|
564
572
|
|
|
573
|
+
if (extra.skipSendToRemote) {
|
|
574
|
+
skipSendToRemote = true;
|
|
575
|
+
delete extra.skipSendToRemote;
|
|
576
|
+
}
|
|
577
|
+
|
|
565
578
|
const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
566
579
|
const message = args.join(', ');
|
|
567
580
|
let consoleMessage = message;
|
|
@@ -582,7 +595,13 @@ class IssueReporter {
|
|
|
582
595
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
583
596
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
584
597
|
|
|
585
|
-
this.
|
|
598
|
+
if (this._callback) {
|
|
599
|
+
this._callback(level, consoleMessage);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
if (!skipSendToRemote) {
|
|
603
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
604
|
+
}
|
|
586
605
|
}
|
|
587
606
|
|
|
588
607
|
logRequest(url , options , response , start ) {
|
|
@@ -727,7 +746,11 @@ class IssueReporter {
|
|
|
727
746
|
},
|
|
728
747
|
// $FlowFixMe
|
|
729
748
|
body,
|
|
730
|
-
}).catch(() => {
|
|
749
|
+
}).catch((e ) => {
|
|
750
|
+
// $FlowFixMe
|
|
751
|
+
e.skipSendToRemote = true;
|
|
752
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
753
|
+
|
|
731
754
|
setTimeout(() => {
|
|
732
755
|
if (isArray) {
|
|
733
756
|
payload = payload.map(message => {
|
|
@@ -763,7 +786,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
763
786
|
|
|
764
787
|
/* global RTCSessionDescriptionInit, navigator */
|
|
765
788
|
|
|
766
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
789
|
+
const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
767
790
|
|
|
768
791
|
//
|
|
769
792
|
|
|
@@ -805,7 +828,7 @@ BwIDAQAB
|
|
|
805
828
|
|
|
806
829
|
//
|
|
807
830
|
|
|
808
|
-
KEYUTIL.getKey(swarmPublicKey);
|
|
831
|
+
const swarmKey = KEYUTIL.getKey(swarmPublicKey);
|
|
809
832
|
|
|
810
833
|
/* eslint-disable dot-notation */
|
|
811
834
|
|
|
@@ -826,15 +849,15 @@ global.wazoFetchOptions = global.wazoFetchOptions || {};
|
|
|
826
849
|
|
|
827
850
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
828
851
|
|
|
829
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
852
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
830
853
|
|
|
831
854
|
/* */
|
|
832
855
|
|
|
833
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
856
|
+
const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
834
857
|
|
|
835
858
|
//
|
|
836
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
837
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
859
|
+
const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
860
|
+
const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
838
861
|
|
|
839
862
|
/* eslint-disable no-param-reassign */
|
|
840
863
|
|
|
@@ -920,7 +943,7 @@ const events = [
|
|
|
920
943
|
ON_DISCONNECTED,
|
|
921
944
|
];
|
|
922
945
|
|
|
923
|
-
const logger = IssueReporter$1.loggerFor('webrtc-phone');
|
|
946
|
+
const logger$4 = IssueReporter$1.loggerFor('webrtc-phone');
|
|
924
947
|
|
|
925
948
|
class WebRTCPhone extends Emitter {
|
|
926
949
|
|
|
@@ -993,7 +1016,7 @@ class WebRTCPhone extends Emitter {
|
|
|
993
1016
|
}).catch(error => {
|
|
994
1017
|
// Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
|
|
995
1018
|
console.error('register error', error, error.message, error.stack);
|
|
996
|
-
logger.error('WebRTC register error', { message: error.message, stack: error.stack });
|
|
1019
|
+
logger$4.error('WebRTC register error', { message: error.message, stack: error.stack });
|
|
997
1020
|
});
|
|
998
1021
|
}
|
|
999
1022
|
|
|
@@ -1008,7 +1031,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1008
1031
|
if (!this.client) {
|
|
1009
1032
|
return;
|
|
1010
1033
|
}
|
|
1011
|
-
logger.info('WebRTC phone stop');
|
|
1034
|
+
logger$4.info('WebRTC phone stop');
|
|
1012
1035
|
this.client.stop();
|
|
1013
1036
|
}
|
|
1014
1037
|
|
|
@@ -1023,7 +1046,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1023
1046
|
async sendReinvite(callSession , constraints = null, conference = false,
|
|
1024
1047
|
audioOnly = false, iceRestart = false) {
|
|
1025
1048
|
const sipSession = this.findSipSession(callSession);
|
|
1026
|
-
logger.info('WebRTC phone - send reinvite', {
|
|
1049
|
+
logger$4.info('WebRTC phone - send reinvite', {
|
|
1027
1050
|
sessionId: sipSession ? sipSession.id : null,
|
|
1028
1051
|
constraints,
|
|
1029
1052
|
audioOnly,
|
|
@@ -1060,7 +1083,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1060
1083
|
}
|
|
1061
1084
|
|
|
1062
1085
|
startHeartbeat() {
|
|
1063
|
-
logger.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
|
|
1086
|
+
logger$4.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
|
|
1064
1087
|
if (!this.client || this.client.hasHeartbeat()) {
|
|
1065
1088
|
return;
|
|
1066
1089
|
}
|
|
@@ -1069,7 +1092,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1069
1092
|
}
|
|
1070
1093
|
|
|
1071
1094
|
stopHeartbeat() {
|
|
1072
|
-
logger.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
|
|
1095
|
+
logger$4.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
|
|
1073
1096
|
if (!this.client) {
|
|
1074
1097
|
return;
|
|
1075
1098
|
}
|
|
@@ -1086,7 +1109,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1086
1109
|
}
|
|
1087
1110
|
|
|
1088
1111
|
reconnect() {
|
|
1089
|
-
logger.info('WebRTC phone - reconnect', { client: !!this.client });
|
|
1112
|
+
logger$4.info('WebRTC phone - reconnect', { client: !!this.client });
|
|
1090
1113
|
if (!this.client) {
|
|
1091
1114
|
return;
|
|
1092
1115
|
}
|
|
@@ -1127,10 +1150,15 @@ class WebRTCPhone extends Emitter {
|
|
|
1127
1150
|
return false;
|
|
1128
1151
|
}
|
|
1129
1152
|
|
|
1130
|
-
logger.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
|
|
1153
|
+
logger$4.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
|
|
1131
1154
|
|
|
1132
1155
|
this.client.downgradeToAudio(sipSession);
|
|
1133
1156
|
|
|
1157
|
+
if (callSession) {
|
|
1158
|
+
callSession.cameraEnabled = false;
|
|
1159
|
+
this._updateCallSession(callSession);
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1134
1162
|
if (withMessage) {
|
|
1135
1163
|
this._sendReinviteMessage(callSession, false);
|
|
1136
1164
|
}
|
|
@@ -1145,7 +1173,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1145
1173
|
return Promise.resolve(false);
|
|
1146
1174
|
}
|
|
1147
1175
|
|
|
1148
|
-
logger.info('Upgrade to video', {
|
|
1176
|
+
logger$4.info('Upgrade to video', {
|
|
1149
1177
|
id: callSession ? callSession.getId() : null,
|
|
1150
1178
|
constraints,
|
|
1151
1179
|
isConference,
|
|
@@ -1158,6 +1186,11 @@ class WebRTCPhone extends Emitter {
|
|
|
1158
1186
|
|
|
1159
1187
|
const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
|
|
1160
1188
|
|
|
1189
|
+
if (callSession) {
|
|
1190
|
+
callSession.cameraEnabled = true;
|
|
1191
|
+
this._updateCallSession(callSession);
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1161
1194
|
// If no stream is returned, it means we have to reinvite
|
|
1162
1195
|
if (!newStream) {
|
|
1163
1196
|
return true;
|
|
@@ -1180,7 +1213,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1180
1213
|
|
|
1181
1214
|
_sendReinviteMessage(callSession , isUpgrade ) {
|
|
1182
1215
|
const sipSession = this.findSipSession(callSession);
|
|
1183
|
-
logger.info('Sending reinvite message', {
|
|
1216
|
+
logger$4.info('Sending reinvite message', {
|
|
1184
1217
|
id: callSession ? callSession.getId() : null,
|
|
1185
1218
|
isUpgrade,
|
|
1186
1219
|
});
|
|
@@ -1206,11 +1239,14 @@ class WebRTCPhone extends Emitter {
|
|
|
1206
1239
|
// Monkey patch to know when canceled with the CANCEL message
|
|
1207
1240
|
const onCancel = sipSession._onCancel.bind(sipSession);
|
|
1208
1241
|
sipSession._onCancel = (message ) => {
|
|
1209
|
-
logger.trace('on sip session canceled', { callId: message.callId });
|
|
1242
|
+
logger$4.trace('on sip session canceled', { callId: message.callId });
|
|
1210
1243
|
|
|
1211
1244
|
onCancel(message);
|
|
1212
1245
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
1213
|
-
|
|
1246
|
+
const callSession = this._createCallSession(sipSession);
|
|
1247
|
+
delete this.callSessions[callSession.getId()];
|
|
1248
|
+
|
|
1249
|
+
this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
|
|
1214
1250
|
};
|
|
1215
1251
|
} else if (sipSession instanceof Invitation) {
|
|
1216
1252
|
console.warn('sipSession._onCancel not found, please update the wazo SDK accordingly');
|
|
@@ -1231,17 +1267,19 @@ class WebRTCPhone extends Emitter {
|
|
|
1231
1267
|
this.audioOutputVolume,
|
|
1232
1268
|
);
|
|
1233
1269
|
case SessionState.Terminating:
|
|
1234
|
-
logger.info('WebRTC phone - call terminating', { sipId: sipSession.id });
|
|
1270
|
+
logger$4.info('WebRTC phone - call terminating', { sipId: sipSession.id });
|
|
1235
1271
|
|
|
1236
1272
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
1237
1273
|
|
|
1238
1274
|
break;
|
|
1239
1275
|
case SessionState.Terminated: {
|
|
1240
|
-
logger.info('WebRTC phone - call terminated', { sipId: sipSession.id });
|
|
1276
|
+
logger$4.info('WebRTC phone - call terminated', { sipId: sipSession.id });
|
|
1241
1277
|
|
|
1278
|
+
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
1279
|
+
const callSession = this._createCallSession(sipSession);
|
|
1242
1280
|
const wasCurrentSession = this._onCallTerminated(sipSession);
|
|
1243
1281
|
|
|
1244
|
-
return this.eventEmitter.emit(ON_CALL_ENDED,
|
|
1282
|
+
return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
|
|
1245
1283
|
}
|
|
1246
1284
|
}
|
|
1247
1285
|
});
|
|
@@ -1257,7 +1295,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1257
1295
|
const [stream] = event.streams;
|
|
1258
1296
|
const kind = event && event.track && event.track.kind;
|
|
1259
1297
|
|
|
1260
|
-
logger.info('on track stream called on the peer connection', {
|
|
1298
|
+
logger$4.info('on track stream called on the peer connection', {
|
|
1261
1299
|
callId: this.getSipSessionId(sipSession),
|
|
1262
1300
|
streamId: stream ? stream.id : null,
|
|
1263
1301
|
tracks: stream ? stream.getTracks() : null,
|
|
@@ -1277,7 +1315,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1277
1315
|
};
|
|
1278
1316
|
|
|
1279
1317
|
peerConnection.onremovestream = event => {
|
|
1280
|
-
logger.info('on remove stream called on the peer connection', {
|
|
1318
|
+
logger$4.info('on remove stream called on the peer connection', {
|
|
1281
1319
|
id: event.stream.id,
|
|
1282
1320
|
tracks: event.stream.getTracks(),
|
|
1283
1321
|
});
|
|
@@ -1287,7 +1325,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1287
1325
|
}
|
|
1288
1326
|
|
|
1289
1327
|
async startScreenSharing(constraints , callSession ) {
|
|
1290
|
-
logger.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
|
|
1328
|
+
logger$4.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
|
|
1291
1329
|
|
|
1292
1330
|
const screenShareStream = await this.client.getStreamFromConstraints(constraints);
|
|
1293
1331
|
if (!screenShareStream) {
|
|
@@ -1327,7 +1365,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1327
1365
|
return;
|
|
1328
1366
|
}
|
|
1329
1367
|
|
|
1330
|
-
logger.info('WebRTC phone - stop screen sharing', {
|
|
1368
|
+
logger$4.info('WebRTC phone - stop screen sharing', {
|
|
1331
1369
|
restoreLocalStream,
|
|
1332
1370
|
});
|
|
1333
1371
|
|
|
@@ -1383,24 +1421,26 @@ class WebRTCPhone extends Emitter {
|
|
|
1383
1421
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
1384
1422
|
const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
1385
1423
|
|
|
1386
|
-
logger.info('WebRTC phone - on screensharing', {
|
|
1424
|
+
logger$4.info('WebRTC phone - on screensharing', {
|
|
1387
1425
|
hadVideo,
|
|
1388
1426
|
id: this.getSipSessionId(sipSession),
|
|
1389
1427
|
screenTrack,
|
|
1390
1428
|
});
|
|
1391
1429
|
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1430
|
+
if (screenTrack) {
|
|
1431
|
+
screenTrack.onended = () => {
|
|
1432
|
+
logger$4.info('WebRTC phone - on screenshare ended', {
|
|
1433
|
+
hadVideo,
|
|
1434
|
+
id: this.getSipSessionId(sipSession),
|
|
1435
|
+
screenTrack,
|
|
1436
|
+
});
|
|
1437
|
+
|
|
1438
|
+
this.eventEmitter.emit(
|
|
1439
|
+
ON_SHARE_SCREEN_ENDING,
|
|
1440
|
+
this._createCallSession(sipSession, callSession),
|
|
1441
|
+
);
|
|
1442
|
+
};
|
|
1443
|
+
}
|
|
1404
1444
|
|
|
1405
1445
|
this.currentScreenShare = {
|
|
1406
1446
|
stream: screenStream,
|
|
@@ -1420,7 +1460,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1420
1460
|
}
|
|
1421
1461
|
|
|
1422
1462
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
1423
|
-
logger.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
1463
|
+
logger$4.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
1424
1464
|
|
|
1425
1465
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
1426
1466
|
this.currentSipSession = sipSession;
|
|
@@ -1438,7 +1478,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1438
1478
|
}
|
|
1439
1479
|
|
|
1440
1480
|
changeAudioDevice(id ) {
|
|
1441
|
-
logger.info('WebRTC phone - change audio device', { deviceId: id });
|
|
1481
|
+
logger$4.info('WebRTC phone - change audio device', { deviceId: id });
|
|
1442
1482
|
this.audioOutputDeviceId = id;
|
|
1443
1483
|
this.client.changeAudioOutputDevice(id);
|
|
1444
1484
|
}
|
|
@@ -1448,14 +1488,14 @@ class WebRTCPhone extends Emitter {
|
|
|
1448
1488
|
}
|
|
1449
1489
|
|
|
1450
1490
|
changeRingDevice(id ) {
|
|
1451
|
-
logger.info('WebRTC phone - changing ring device', { id });
|
|
1491
|
+
logger$4.info('WebRTC phone - changing ring device', { id });
|
|
1452
1492
|
|
|
1453
1493
|
this.audioRingDeviceId = id;
|
|
1454
1494
|
}
|
|
1455
1495
|
|
|
1456
1496
|
// volume is a value between 0 and 1
|
|
1457
1497
|
changeAudioVolume(volume ) {
|
|
1458
|
-
logger.info('WebRTC phone - changing audio volume', { volume });
|
|
1498
|
+
logger$4.info('WebRTC phone - changing audio volume', { volume });
|
|
1459
1499
|
|
|
1460
1500
|
this.audioOutputVolume = volume;
|
|
1461
1501
|
this.client.changeAudioOutputVolume(volume);
|
|
@@ -1463,31 +1503,31 @@ class WebRTCPhone extends Emitter {
|
|
|
1463
1503
|
|
|
1464
1504
|
// volume is a value between 0 and 1
|
|
1465
1505
|
changeRingVolume(volume ) {
|
|
1466
|
-
logger.info('WebRTC phone - changing ring volume', { volume });
|
|
1506
|
+
logger$4.info('WebRTC phone - changing ring volume', { volume });
|
|
1467
1507
|
|
|
1468
1508
|
this.audioRingVolume = volume;
|
|
1469
1509
|
}
|
|
1470
1510
|
|
|
1471
1511
|
changeAudioInputDevice(id ) {
|
|
1472
|
-
logger.info('WebRTC phone - changeAudio input device', { deviceId: id });
|
|
1512
|
+
logger$4.info('WebRTC phone - changeAudio input device', { deviceId: id });
|
|
1473
1513
|
|
|
1474
1514
|
return this.client.changeAudioInputDevice(id, this.currentSipSession);
|
|
1475
1515
|
}
|
|
1476
1516
|
|
|
1477
1517
|
changeVideoInputDevice(id ) {
|
|
1478
|
-
logger.info('WebRTC phone - change video input device', { deviceId: id });
|
|
1518
|
+
logger$4.info('WebRTC phone - change video input device', { deviceId: id });
|
|
1479
1519
|
|
|
1480
1520
|
return this.client.changeVideoInputDevice(id, this.currentSipSession);
|
|
1481
1521
|
}
|
|
1482
1522
|
|
|
1483
1523
|
changeSessionVideoInputDevice(id ) {
|
|
1484
|
-
logger.info('WebRTC phone - change session video input device', { deviceId: id });
|
|
1524
|
+
logger$4.info('WebRTC phone - change session video input device', { deviceId: id });
|
|
1485
1525
|
|
|
1486
1526
|
return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
1487
1527
|
}
|
|
1488
1528
|
|
|
1489
1529
|
_onCallTerminated(sipSession ) {
|
|
1490
|
-
logger.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
1530
|
+
logger$4.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
1491
1531
|
|
|
1492
1532
|
const callSession = this._createCallSession(sipSession);
|
|
1493
1533
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
@@ -1521,7 +1561,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1521
1561
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
1522
1562
|
|
|
1523
1563
|
// Re-trigger incoming call event for remaining incoming calls
|
|
1524
|
-
logger.info('WebRTC phone - check to re-trigger incoming call', {
|
|
1564
|
+
logger$4.info('WebRTC phone - check to re-trigger incoming call', {
|
|
1525
1565
|
sipId: sipSession.id,
|
|
1526
1566
|
shouldRetrigger,
|
|
1527
1567
|
hasIncomingCallSession,
|
|
@@ -1612,37 +1652,37 @@ class WebRTCPhone extends Emitter {
|
|
|
1612
1652
|
|
|
1613
1653
|
// Deprecated
|
|
1614
1654
|
getLocalStreamForCall(callSession ) {
|
|
1615
|
-
logger.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
1655
|
+
logger$4.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
1616
1656
|
|
|
1617
1657
|
return this.getLocalStream(callSession);
|
|
1618
1658
|
}
|
|
1619
1659
|
|
|
1620
1660
|
// Deprecated
|
|
1621
1661
|
getRemoteStreamForCall(callSession ) {
|
|
1622
|
-
logger.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
|
|
1662
|
+
logger$4.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
|
|
1623
1663
|
|
|
1624
1664
|
return this.getRemoteVideoStream(callSession);
|
|
1625
1665
|
}
|
|
1626
1666
|
|
|
1627
1667
|
getRemoteStreamsForCall(callSession ) {
|
|
1628
|
-
logger.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
|
|
1668
|
+
logger$4.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
|
|
1629
1669
|
|
|
1630
1670
|
return this.getRemoteStream(callSession);
|
|
1631
1671
|
}
|
|
1632
1672
|
|
|
1633
1673
|
accept(callSession , cameraEnabled ) {
|
|
1634
|
-
logger.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
|
|
1674
|
+
logger$4.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
|
|
1635
1675
|
if (this.currentSipSession) {
|
|
1636
1676
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
|
|
1637
1677
|
}
|
|
1638
1678
|
|
|
1639
1679
|
if (!callSession) {
|
|
1640
|
-
logger.warn('no CallSession to accept.');
|
|
1680
|
+
logger$4.warn('no CallSession to accept.');
|
|
1641
1681
|
return Promise.resolve(null);
|
|
1642
1682
|
}
|
|
1643
1683
|
|
|
1644
1684
|
if (callSession.getId() in this.acceptedSessions) {
|
|
1645
|
-
logger.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
1685
|
+
logger$4.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
1646
1686
|
return Promise.resolve(callSession.sipCallId);
|
|
1647
1687
|
}
|
|
1648
1688
|
|
|
@@ -1654,24 +1694,24 @@ class WebRTCPhone extends Emitter {
|
|
|
1654
1694
|
const sipSession = this.client.getSipSession(callSession.getId());
|
|
1655
1695
|
if (sipSession) {
|
|
1656
1696
|
if (sipSession.state === SessionState.Terminated || sipSession.state === SessionState.Terminating) {
|
|
1657
|
-
logger.warn('Trying to answer a terminated sipSession.');
|
|
1697
|
+
logger$4.warn('Trying to answer a terminated sipSession.');
|
|
1658
1698
|
|
|
1659
1699
|
return Promise.resolve(null);
|
|
1660
1700
|
}
|
|
1661
1701
|
|
|
1662
|
-
logger.info('accept call, session found', { sipId: sipSession.id });
|
|
1702
|
+
logger$4.info('accept call, session found', { sipId: sipSession.id });
|
|
1663
1703
|
|
|
1664
1704
|
// $FlowFixMe
|
|
1665
1705
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
1666
1706
|
return callSession.sipCallId;
|
|
1667
1707
|
}).catch(e => {
|
|
1668
|
-
logger.error(e);
|
|
1708
|
+
logger$4.error(e);
|
|
1669
1709
|
this.endCurrentCall(callSession);
|
|
1670
1710
|
throw e;
|
|
1671
1711
|
});
|
|
1672
1712
|
}
|
|
1673
1713
|
|
|
1674
|
-
logger.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
1714
|
+
logger$4.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
1675
1715
|
|
|
1676
1716
|
return Promise.resolve(null);
|
|
1677
1717
|
}
|
|
@@ -1681,7 +1721,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1681
1721
|
}
|
|
1682
1722
|
|
|
1683
1723
|
async reject(callSession ) {
|
|
1684
|
-
logger.info('reject WebRTC called', { id: callSession.getId() });
|
|
1724
|
+
logger$4.info('reject WebRTC called', { id: callSession.getId() });
|
|
1685
1725
|
|
|
1686
1726
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
|
|
1687
1727
|
if (!callSession || callSession.getId() in this.rejectedSessions) {
|
|
@@ -1693,14 +1733,14 @@ class WebRTCPhone extends Emitter {
|
|
|
1693
1733
|
|
|
1694
1734
|
const sipSession = this.findSipSession(callSession);
|
|
1695
1735
|
if (sipSession) {
|
|
1696
|
-
logger.info('WebRTC rejecting', { sipId: sipSession.id });
|
|
1736
|
+
logger$4.info('WebRTC rejecting', { sipId: sipSession.id });
|
|
1697
1737
|
|
|
1698
1738
|
this.client.hangup(sipSession);
|
|
1699
1739
|
}
|
|
1700
1740
|
}
|
|
1701
1741
|
|
|
1702
1742
|
async ignore(callSession ) {
|
|
1703
|
-
logger.info('WebRTC ignore', { id: callSession.getId() });
|
|
1743
|
+
logger$4.info('WebRTC ignore', { id: callSession.getId() });
|
|
1704
1744
|
|
|
1705
1745
|
// kill the ring
|
|
1706
1746
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
|
|
@@ -1712,14 +1752,14 @@ class WebRTCPhone extends Emitter {
|
|
|
1712
1752
|
const sipSession = this.findSipSession(callSession);
|
|
1713
1753
|
|
|
1714
1754
|
if (sipSession) {
|
|
1715
|
-
logger.info('WebRTC atxfer', { sipId: sipSession.id });
|
|
1755
|
+
logger$4.info('WebRTC atxfer', { sipId: sipSession.id });
|
|
1716
1756
|
|
|
1717
1757
|
return this.client.atxfer(sipSession);
|
|
1718
1758
|
}
|
|
1719
1759
|
}
|
|
1720
1760
|
|
|
1721
1761
|
hold(callSession , withEvent = true, isConference = false) {
|
|
1722
|
-
logger.info('WebRTC hold', { id: callSession.getId() });
|
|
1762
|
+
logger$4.info('WebRTC hold', { id: callSession.getId() });
|
|
1723
1763
|
|
|
1724
1764
|
const sipSession = this.findSipSession(callSession);
|
|
1725
1765
|
|
|
@@ -1734,18 +1774,18 @@ class WebRTCPhone extends Emitter {
|
|
|
1734
1774
|
}
|
|
1735
1775
|
|
|
1736
1776
|
resume(callSession , isConference = false, withEvent = true) {
|
|
1737
|
-
logger.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
|
|
1777
|
+
logger$4.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
|
|
1738
1778
|
|
|
1739
1779
|
const sipSession = this.findSipSession(callSession);
|
|
1740
1780
|
if (!sipSession) {
|
|
1741
1781
|
return new Promise((resolve, reject) => reject(new Error('No session to resume')));
|
|
1742
1782
|
}
|
|
1743
1783
|
|
|
1744
|
-
logger.info('WebRTC resuming', { sipId: sipSession.id });
|
|
1784
|
+
logger$4.info('WebRTC resuming', { sipId: sipSession.id });
|
|
1745
1785
|
|
|
1746
1786
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
1747
1787
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
1748
|
-
logger.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
1788
|
+
logger$4.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
1749
1789
|
this.holdSipSession(this.currentSipSession, callSession);
|
|
1750
1790
|
}
|
|
1751
1791
|
|
|
@@ -1770,7 +1810,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1770
1810
|
const sessionId = this.getSipSessionId(sipSession);
|
|
1771
1811
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
1772
1812
|
|
|
1773
|
-
logger.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
1813
|
+
logger$4.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
1774
1814
|
|
|
1775
1815
|
// Stop screenshre if needed
|
|
1776
1816
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
@@ -1801,7 +1841,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1801
1841
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
1802
1842
|
}
|
|
1803
1843
|
const sessionId = this.getSipSessionId(sipSession);
|
|
1804
|
-
logger.info('WebRTC unhold sip session', { sessionId, isConference });
|
|
1844
|
+
logger$4.info('WebRTC unhold sip session', { sessionId, isConference });
|
|
1805
1845
|
|
|
1806
1846
|
const { hasVideo } = this.client.getHeldSession(sessionId) || {};
|
|
1807
1847
|
const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
|
|
@@ -1845,14 +1885,14 @@ class WebRTCPhone extends Emitter {
|
|
|
1845
1885
|
}
|
|
1846
1886
|
|
|
1847
1887
|
mute(callSession , withEvent = true) {
|
|
1848
|
-
logger.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
|
|
1888
|
+
logger$4.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
|
|
1849
1889
|
|
|
1850
1890
|
const sipSession = this.findSipSession(callSession);
|
|
1851
1891
|
if (!sipSession) {
|
|
1852
1892
|
return;
|
|
1853
1893
|
}
|
|
1854
1894
|
|
|
1855
|
-
logger.info('WebRTC muting', { sipId: sipSession.id });
|
|
1895
|
+
logger$4.info('WebRTC muting', { sipId: sipSession.id });
|
|
1856
1896
|
this.client.mute(sipSession);
|
|
1857
1897
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
|
|
1858
1898
|
|
|
@@ -1866,14 +1906,14 @@ class WebRTCPhone extends Emitter {
|
|
|
1866
1906
|
}
|
|
1867
1907
|
|
|
1868
1908
|
unmute(callSession , withEvent = true) {
|
|
1869
|
-
logger.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
|
|
1909
|
+
logger$4.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
|
|
1870
1910
|
|
|
1871
1911
|
const sipSession = this.findSipSession(callSession);
|
|
1872
1912
|
if (!sipSession) {
|
|
1873
1913
|
return;
|
|
1874
1914
|
}
|
|
1875
1915
|
|
|
1876
|
-
logger.info('WebRTC unmuting', { sipId: sipSession.id });
|
|
1916
|
+
logger$4.info('WebRTC unmuting', { sipId: sipSession.id });
|
|
1877
1917
|
this.client.unmute(sipSession);
|
|
1878
1918
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
|
|
1879
1919
|
|
|
@@ -1900,7 +1940,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1900
1940
|
if (!sipSession) {
|
|
1901
1941
|
return;
|
|
1902
1942
|
}
|
|
1903
|
-
logger.info('WebRTC turn camera on', { sipId: sipSession.id });
|
|
1943
|
+
logger$4.info('WebRTC turn camera on', { sipId: sipSession.id });
|
|
1904
1944
|
|
|
1905
1945
|
this.client.toggleCameraOn(sipSession);
|
|
1906
1946
|
|
|
@@ -1912,7 +1952,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1912
1952
|
if (!sipSession) {
|
|
1913
1953
|
return;
|
|
1914
1954
|
}
|
|
1915
|
-
logger.info('WebRTC turn camera off', { sipId: sipSession.id });
|
|
1955
|
+
logger$4.info('WebRTC turn camera off', { sipId: sipSession.id });
|
|
1916
1956
|
|
|
1917
1957
|
this.client.toggleCameraOff(sipSession);
|
|
1918
1958
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -1924,7 +1964,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1924
1964
|
return;
|
|
1925
1965
|
}
|
|
1926
1966
|
|
|
1927
|
-
logger.info('WebRTC send key', { sipId: sipSession.id, tone });
|
|
1967
|
+
logger$4.info('WebRTC send key', { sipId: sipSession.id, tone });
|
|
1928
1968
|
this.client.sendDTMF(sipSession, tone);
|
|
1929
1969
|
}
|
|
1930
1970
|
|
|
@@ -1932,7 +1972,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1932
1972
|
// @TODO: line is not used here
|
|
1933
1973
|
async makeCall(number , line , cameraEnabled ,
|
|
1934
1974
|
audioOnly = false, conference = false) {
|
|
1935
|
-
logger.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
|
|
1975
|
+
logger$4.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
|
|
1936
1976
|
if (!number) {
|
|
1937
1977
|
return Promise.resolve(null);
|
|
1938
1978
|
}
|
|
@@ -1942,7 +1982,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1942
1982
|
}
|
|
1943
1983
|
if (this.currentSipSession) {
|
|
1944
1984
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
|
|
1945
|
-
logger.warn('Unable to hold current session when making another call', e);
|
|
1985
|
+
logger$4.warn('Unable to hold current session when making another call', e);
|
|
1946
1986
|
});
|
|
1947
1987
|
}
|
|
1948
1988
|
|
|
@@ -1952,7 +1992,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1952
1992
|
this._bindEvents(sipSession);
|
|
1953
1993
|
} catch (error) {
|
|
1954
1994
|
console.warn(error);
|
|
1955
|
-
logger.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
|
|
1995
|
+
logger$4.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
|
|
1956
1996
|
return Promise.resolve(null);
|
|
1957
1997
|
}
|
|
1958
1998
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
@@ -1980,7 +2020,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1980
2020
|
return;
|
|
1981
2021
|
}
|
|
1982
2022
|
|
|
1983
|
-
logger.info('WebRTC transfer', { sipId: sipSession.id, target });
|
|
2023
|
+
logger$4.info('WebRTC transfer', { sipId: sipSession.id, target });
|
|
1984
2024
|
|
|
1985
2025
|
this.client.transfer(sipSession, target);
|
|
1986
2026
|
}
|
|
@@ -1989,7 +2029,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1989
2029
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
1990
2030
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
1991
2031
|
|
|
1992
|
-
logger.info('WebRTC indirect transfer', {
|
|
2032
|
+
logger$4.info('WebRTC indirect transfer', {
|
|
1993
2033
|
sipId: sipSession ? sipSession.id : null,
|
|
1994
2034
|
target: sipSessionTarget ? sipSessionTarget.id : null,
|
|
1995
2035
|
});
|
|
@@ -2028,7 +2068,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2028
2068
|
return false;
|
|
2029
2069
|
}
|
|
2030
2070
|
|
|
2031
|
-
logger.info('WebRTC hangup', { sipId: sipSession.id });
|
|
2071
|
+
logger$4.info('WebRTC hangup', { sipId: sipSession.id });
|
|
2032
2072
|
|
|
2033
2073
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
2034
2074
|
|
|
@@ -2074,7 +2114,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2074
2114
|
endCurrentCall(callSession ) {
|
|
2075
2115
|
const isCurrent = this.isCurrentCallSipSession(callSession);
|
|
2076
2116
|
|
|
2077
|
-
logger.info('Ending current call', {
|
|
2117
|
+
logger$4.info('Ending current call', {
|
|
2078
2118
|
id: callSession ? callSession.getId() : null,
|
|
2079
2119
|
isCurrent,
|
|
2080
2120
|
});
|
|
@@ -2098,7 +2138,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2098
2138
|
}
|
|
2099
2139
|
|
|
2100
2140
|
async close() {
|
|
2101
|
-
logger.info('WebRTC close');
|
|
2141
|
+
logger$4.info('WebRTC close');
|
|
2102
2142
|
|
|
2103
2143
|
try {
|
|
2104
2144
|
await Promise.race([
|
|
@@ -2106,7 +2146,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2106
2146
|
new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
|
|
2107
2147
|
]);
|
|
2108
2148
|
} catch (e) {
|
|
2109
|
-
logger.error('WebRTC close, unregister error', e);
|
|
2149
|
+
logger$4.error('WebRTC close, unregister error', e);
|
|
2110
2150
|
}
|
|
2111
2151
|
|
|
2112
2152
|
this.client.close();
|
|
@@ -2124,12 +2164,12 @@ class WebRTCPhone extends Emitter {
|
|
|
2124
2164
|
}
|
|
2125
2165
|
|
|
2126
2166
|
enableRinging() {
|
|
2127
|
-
logger.info('WebRTC enable ringing');
|
|
2167
|
+
logger$4.info('WebRTC enable ringing');
|
|
2128
2168
|
this.ringingEnabled = true;
|
|
2129
2169
|
}
|
|
2130
2170
|
|
|
2131
2171
|
disableRinging() {
|
|
2132
|
-
logger.info('WebRTC disable ringing');
|
|
2172
|
+
logger$4.info('WebRTC disable ringing');
|
|
2133
2173
|
this.ringingEnabled = false;
|
|
2134
2174
|
}
|
|
2135
2175
|
|
|
@@ -2169,7 +2209,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2169
2209
|
|
|
2170
2210
|
// Deprecated
|
|
2171
2211
|
getLocalMediaStream(callSession ) {
|
|
2172
|
-
logger.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
2212
|
+
logger$4.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
2173
2213
|
return this.getLocalStream(callSession);
|
|
2174
2214
|
}
|
|
2175
2215
|
|
|
@@ -2189,6 +2229,10 @@ class WebRTCPhone extends Emitter {
|
|
|
2189
2229
|
return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
|
|
2190
2230
|
}
|
|
2191
2231
|
|
|
2232
|
+
getRemoteVideoStreamFromPc(callSession ) {
|
|
2233
|
+
return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2192
2236
|
hasRemoteVideo(callSession ) {
|
|
2193
2237
|
return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
|
|
2194
2238
|
}
|
|
@@ -2207,7 +2251,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2207
2251
|
this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
|
|
2208
2252
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
2209
2253
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
2210
|
-
logger.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
|
|
2254
|
+
logger$4.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
|
|
2211
2255
|
|
|
2212
2256
|
const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
|
|
2213
2257
|
this.incomingSessions.push(callSession.getId());
|
|
@@ -2230,7 +2274,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2230
2274
|
});
|
|
2231
2275
|
|
|
2232
2276
|
this.client.on(this.client.ON_REINVITE, (...args) => {
|
|
2233
|
-
logger.info('WebRTC on reinvite', {
|
|
2277
|
+
logger$4.info('WebRTC on reinvite', {
|
|
2234
2278
|
sessionId: args[0].id,
|
|
2235
2279
|
inviteId: args[1].id,
|
|
2236
2280
|
updatedCalleeName: args[2],
|
|
@@ -2250,7 +2294,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2250
2294
|
});
|
|
2251
2295
|
|
|
2252
2296
|
this.client.on(this.client.ACCEPTED, (sipSession ) => {
|
|
2253
|
-
logger.info('WebRTC call accepted', { sipId: sipSession.id });
|
|
2297
|
+
logger$4.info('WebRTC call accepted', { sipId: sipSession.id });
|
|
2254
2298
|
|
|
2255
2299
|
this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
|
|
2256
2300
|
|
|
@@ -2261,22 +2305,22 @@ class WebRTCPhone extends Emitter {
|
|
|
2261
2305
|
this.client.on('ended', () => {});
|
|
2262
2306
|
|
|
2263
2307
|
this.client.on(this.client.ON_ERROR, e => {
|
|
2264
|
-
logger.error('WebRTC error', e);
|
|
2308
|
+
logger$4.error('WebRTC error', e);
|
|
2265
2309
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
2266
2310
|
});
|
|
2267
2311
|
|
|
2268
2312
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
2269
|
-
logger.info('WebRTC unregistered');
|
|
2313
|
+
logger$4.info('WebRTC unregistered');
|
|
2270
2314
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
2271
2315
|
});
|
|
2272
2316
|
|
|
2273
2317
|
this.client.on(this.client.ON_DISCONNECTED, () => {
|
|
2274
|
-
logger.info('WebRTC disconnected');
|
|
2318
|
+
logger$4.info('WebRTC disconnected');
|
|
2275
2319
|
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
2276
2320
|
});
|
|
2277
2321
|
|
|
2278
2322
|
this.client.on(this.client.REGISTERED, () => {
|
|
2279
|
-
logger.info('WebRTC registered', {
|
|
2323
|
+
logger$4.info('WebRTC registered', {
|
|
2280
2324
|
shouldSendReinvite: this.shouldSendReinvite,
|
|
2281
2325
|
state: this.currentSipSession ? this.currentSipSession.state : null,
|
|
2282
2326
|
currentSipSession: !!this.currentSipSession,
|
|
@@ -2289,23 +2333,27 @@ class WebRTCPhone extends Emitter {
|
|
|
2289
2333
|
if (this.shouldSendReinvite && this.currentSipSession
|
|
2290
2334
|
&& this.currentSipSession.state === SessionState.Established) {
|
|
2291
2335
|
this.shouldSendReinvite = false;
|
|
2336
|
+
const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
|
|
2337
|
+
const isConference = pc ? pc.sfu : false;
|
|
2338
|
+
const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
|
|
2339
|
+
|
|
2292
2340
|
try {
|
|
2293
2341
|
// Send reinvite with iceRestart
|
|
2294
|
-
this.sendReinvite(this.currentCallSession, null,
|
|
2342
|
+
this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
|
|
2295
2343
|
} catch (e) {
|
|
2296
|
-
logger.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
2344
|
+
logger$4.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
2297
2345
|
}
|
|
2298
2346
|
}
|
|
2299
2347
|
});
|
|
2300
2348
|
|
|
2301
2349
|
this.client.on(this.client.CONNECTED, () => {
|
|
2302
|
-
logger.info('WebRTC client connected');
|
|
2350
|
+
logger$4.info('WebRTC client connected');
|
|
2303
2351
|
|
|
2304
2352
|
this.stopHeartbeat();
|
|
2305
2353
|
});
|
|
2306
2354
|
|
|
2307
2355
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
2308
|
-
logger.info('WebRTC client disconnected');
|
|
2356
|
+
logger$4.info('WebRTC client disconnected');
|
|
2309
2357
|
|
|
2310
2358
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
2311
2359
|
|
|
@@ -2343,7 +2391,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2343
2391
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
2344
2392
|
const callSession = this.callSessions[sipSessionId];
|
|
2345
2393
|
|
|
2346
|
-
logger.info('Updrading directly in screensharing mode', {
|
|
2394
|
+
logger$4.info('Updrading directly in screensharing mode', {
|
|
2347
2395
|
sipSessionId,
|
|
2348
2396
|
tracks: localStream ? localStream.getTracks() : null,
|
|
2349
2397
|
});
|
|
@@ -2375,6 +2423,15 @@ class WebRTCPhone extends Emitter {
|
|
|
2375
2423
|
return this.client.getSipSessionId(sipSession);
|
|
2376
2424
|
}
|
|
2377
2425
|
|
|
2426
|
+
_updateCallSession(callSession ) {
|
|
2427
|
+
const sipSession = this.findSipSession(callSession);
|
|
2428
|
+
const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
|
|
2429
|
+
|
|
2430
|
+
if (sipSessionId) {
|
|
2431
|
+
this.callSessions[sipSessionId] = callSession;
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2378
2435
|
_onMessage(message ) {
|
|
2379
2436
|
if (!message || message.method !== 'MESSAGE') {
|
|
2380
2437
|
return;
|