@wazo/sdk 0.37.24 → 0.37.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/wazo-sdk.js +6 -6
- package/esm/__tests__/api-client.test.js +12 -12
- package/esm/__tests__/web-rtc-client.test.js +120 -103
- package/esm/api/amid.js +1 -1
- package/esm/api/call-logd.js +2 -2
- package/esm/api/ctid-ng.js +3 -3
- package/esm/api/dird.js +1 -1
- package/esm/api/webhookd.js +1 -1
- package/esm/api-client.js +12 -12
- package/esm/checker/Checker.js +145 -128
- package/esm/checker/checks/aor.js +12 -12
- package/esm/checker/checks/api.js +12 -12
- package/esm/checker/checks/index.js +135 -118
- package/esm/checker/checks/wazo-websocket.js +15 -15
- package/esm/checker/checks/webrtc-transport.js +120 -103
- package/esm/checker/checks/webrtc.js +120 -103
- package/esm/domain/AdHocAPIConference.js +12 -12
- package/esm/domain/CallLog.js +1 -1
- package/esm/domain/Contact.js +1 -1
- package/esm/domain/Features.js +12 -12
- package/esm/domain/Phone/CTIPhone.js +26 -26
- package/esm/domain/Phone/WebRTCPhone.js +87 -86
- package/esm/domain/__tests__/CallLog.test.js +1 -1
- package/esm/domain/__tests__/Contact.test.js +1 -1
- package/esm/index.js +356 -338
- package/esm/lib/WazoSessionDescriptionHandler.js +1 -1
- package/esm/service/CallApi.js +12 -12
- package/esm/service/IssueReporter.js +1 -1
- package/esm/service/__tests__/IssueReporter.test.js +1 -1
- package/esm/service/getApiClient.js +12 -12
- package/esm/simple/Auth.js +346 -328
- package/esm/simple/Configuration.js +346 -328
- package/esm/simple/Directory.js +12 -12
- package/esm/simple/Phone.js +346 -328
- package/esm/simple/Websocket.js +17 -17
- package/esm/simple/index.js +350 -332
- package/esm/simple/room/LocalParticipant.js +350 -332
- package/esm/simple/room/Participant.js +350 -332
- package/esm/simple/room/RemoteParticipant.js +350 -332
- package/esm/simple/room/Room.js +351 -333
- package/esm/simple/room/SipRoom.js +350 -332
- package/esm/simple/room/Stream.js +350 -332
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +350 -332
- package/esm/simple/utils.js +350 -332
- package/esm/web-rtc-client.js +120 -103
- package/esm/websocket-client.js +15 -15
- package/lib/__tests__/api-client.test.js +12 -12
- package/lib/__tests__/web-rtc-client.test.js +120 -103
- package/lib/api/amid.js +1 -1
- package/lib/api/call-logd.js +2 -2
- package/lib/api/ctid-ng.js +3 -3
- package/lib/api/dird.js +1 -1
- package/lib/api/webhookd.js +1 -1
- package/lib/api-client.js +12 -12
- package/lib/checker/Checker.js +145 -128
- package/lib/checker/checks/aor.js +12 -12
- package/lib/checker/checks/api.js +12 -12
- package/lib/checker/checks/index.js +135 -118
- package/lib/checker/checks/wazo-websocket.js +15 -15
- package/lib/checker/checks/webrtc-transport.js +120 -103
- package/lib/checker/checks/webrtc.js +120 -103
- package/lib/domain/AdHocAPIConference.js +12 -12
- package/lib/domain/CallLog.js +1 -1
- package/lib/domain/Contact.js +1 -1
- package/lib/domain/Features.js +12 -12
- package/lib/domain/Phone/CTIPhone.js +26 -26
- package/lib/domain/Phone/WebRTCPhone.js +87 -86
- package/lib/domain/__tests__/CallLog.test.js +1 -1
- package/lib/domain/__tests__/Contact.test.js +1 -1
- package/lib/index.js +356 -338
- package/lib/lib/WazoSessionDescriptionHandler.js +1 -1
- package/lib/service/CallApi.js +12 -12
- package/lib/service/IssueReporter.js +1 -1
- package/lib/service/__tests__/IssueReporter.test.js +1 -1
- package/lib/service/getApiClient.js +12 -12
- package/lib/simple/Auth.js +346 -328
- package/lib/simple/Configuration.js +346 -328
- package/lib/simple/Directory.js +12 -12
- package/lib/simple/Phone.js +346 -328
- package/lib/simple/Websocket.js +17 -17
- package/lib/simple/index.js +350 -332
- package/lib/simple/room/LocalParticipant.js +350 -332
- package/lib/simple/room/Participant.js +350 -332
- package/lib/simple/room/RemoteParticipant.js +350 -332
- package/lib/simple/room/Room.js +351 -333
- package/lib/simple/room/SipRoom.js +350 -332
- package/lib/simple/room/Stream.js +350 -332
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +350 -332
- package/lib/simple/utils.js +350 -332
- package/lib/web-rtc-client.js +120 -103
- package/lib/websocket-client.js +15 -15
- package/package.json +1 -1
- package/src/domain/Phone/WebRTCPhone.js +3 -2
- package/src/web-rtc-client.js +27 -10
|
@@ -410,7 +410,7 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
|
|
|
410
410
|
|
|
411
411
|
/* */
|
|
412
412
|
|
|
413
|
-
|
|
413
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
414
414
|
|
|
415
415
|
// Use a function here to be able to mock it in tests
|
|
416
416
|
const realFetch = () => {
|
|
@@ -795,7 +795,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
795
795
|
|
|
796
796
|
/* global RTCSessionDescriptionInit, navigator */
|
|
797
797
|
|
|
798
|
-
|
|
798
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
799
799
|
|
|
800
800
|
//
|
|
801
801
|
|
|
@@ -837,7 +837,7 @@ BwIDAQAB
|
|
|
837
837
|
|
|
838
838
|
//
|
|
839
839
|
|
|
840
|
-
|
|
840
|
+
jsrsasign.KEYUTIL.getKey(swarmPublicKey);
|
|
841
841
|
|
|
842
842
|
/* eslint-disable dot-notation */
|
|
843
843
|
|
|
@@ -858,15 +858,15 @@ global.wazoFetchOptions = global.wazoFetchOptions || {};
|
|
|
858
858
|
|
|
859
859
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
860
860
|
|
|
861
|
-
|
|
861
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
862
862
|
|
|
863
863
|
/* */
|
|
864
864
|
|
|
865
|
-
|
|
865
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
866
866
|
|
|
867
867
|
//
|
|
868
|
-
|
|
869
|
-
|
|
868
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
869
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
870
870
|
|
|
871
871
|
/* eslint-disable no-param-reassign */
|
|
872
872
|
|
|
@@ -952,7 +952,7 @@ const events = [
|
|
|
952
952
|
ON_DISCONNECTED,
|
|
953
953
|
];
|
|
954
954
|
|
|
955
|
-
const logger
|
|
955
|
+
const logger = IssueReporter$1.loggerFor('webrtc-phone');
|
|
956
956
|
|
|
957
957
|
class WebRTCPhone extends Emitter {
|
|
958
958
|
|
|
@@ -1025,7 +1025,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1025
1025
|
}).catch(error => {
|
|
1026
1026
|
// Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
|
|
1027
1027
|
console.error('register error', error, error.message, error.stack);
|
|
1028
|
-
logger
|
|
1028
|
+
logger.error('WebRTC register error', { message: error.message, stack: error.stack });
|
|
1029
1029
|
});
|
|
1030
1030
|
}
|
|
1031
1031
|
|
|
@@ -1040,7 +1040,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1040
1040
|
if (!this.client) {
|
|
1041
1041
|
return;
|
|
1042
1042
|
}
|
|
1043
|
-
logger
|
|
1043
|
+
logger.info('WebRTC phone stop');
|
|
1044
1044
|
this.client.stop();
|
|
1045
1045
|
}
|
|
1046
1046
|
|
|
@@ -1055,11 +1055,12 @@ class WebRTCPhone extends Emitter {
|
|
|
1055
1055
|
async sendReinvite(callSession , constraints = null, conference = false,
|
|
1056
1056
|
audioOnly = false, iceRestart = false) {
|
|
1057
1057
|
const sipSession = this.findSipSession(callSession);
|
|
1058
|
-
logger
|
|
1058
|
+
logger.info('WebRTC phone - send reinvite', {
|
|
1059
1059
|
sessionId: sipSession ? sipSession.id : null,
|
|
1060
1060
|
constraints,
|
|
1061
1061
|
audioOnly,
|
|
1062
1062
|
conference,
|
|
1063
|
+
iceRestart,
|
|
1063
1064
|
});
|
|
1064
1065
|
|
|
1065
1066
|
if (!sipSession) {
|
|
@@ -1092,7 +1093,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1092
1093
|
}
|
|
1093
1094
|
|
|
1094
1095
|
startHeartbeat() {
|
|
1095
|
-
logger
|
|
1096
|
+
logger.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
|
|
1096
1097
|
if (!this.client || this.client.hasHeartbeat()) {
|
|
1097
1098
|
return;
|
|
1098
1099
|
}
|
|
@@ -1101,7 +1102,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1101
1102
|
}
|
|
1102
1103
|
|
|
1103
1104
|
stopHeartbeat() {
|
|
1104
|
-
logger
|
|
1105
|
+
logger.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
|
|
1105
1106
|
if (!this.client) {
|
|
1106
1107
|
return;
|
|
1107
1108
|
}
|
|
@@ -1118,7 +1119,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1118
1119
|
}
|
|
1119
1120
|
|
|
1120
1121
|
reconnect() {
|
|
1121
|
-
logger
|
|
1122
|
+
logger.info('WebRTC phone - reconnect', { client: !!this.client });
|
|
1122
1123
|
if (!this.client) {
|
|
1123
1124
|
return;
|
|
1124
1125
|
}
|
|
@@ -1159,7 +1160,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1159
1160
|
return false;
|
|
1160
1161
|
}
|
|
1161
1162
|
|
|
1162
|
-
logger
|
|
1163
|
+
logger.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
|
|
1163
1164
|
|
|
1164
1165
|
this.client.downgradeToAudio(sipSession);
|
|
1165
1166
|
|
|
@@ -1182,7 +1183,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1182
1183
|
return Promise.resolve(false);
|
|
1183
1184
|
}
|
|
1184
1185
|
|
|
1185
|
-
logger
|
|
1186
|
+
logger.info('Upgrade to video', {
|
|
1186
1187
|
id: callSession ? callSession.getId() : null,
|
|
1187
1188
|
constraints,
|
|
1188
1189
|
isConference,
|
|
@@ -1222,7 +1223,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1222
1223
|
|
|
1223
1224
|
_sendReinviteMessage(callSession , isUpgrade ) {
|
|
1224
1225
|
const sipSession = this.findSipSession(callSession);
|
|
1225
|
-
logger
|
|
1226
|
+
logger.info('Sending reinvite message', {
|
|
1226
1227
|
id: callSession ? callSession.getId() : null,
|
|
1227
1228
|
isUpgrade,
|
|
1228
1229
|
});
|
|
@@ -1248,7 +1249,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1248
1249
|
// Monkey patch to know when canceled with the CANCEL message
|
|
1249
1250
|
const onCancel = sipSession._onCancel.bind(sipSession);
|
|
1250
1251
|
sipSession._onCancel = (message ) => {
|
|
1251
|
-
logger
|
|
1252
|
+
logger.trace('on sip session canceled', { callId: message.callId });
|
|
1252
1253
|
|
|
1253
1254
|
onCancel(message);
|
|
1254
1255
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
@@ -1276,13 +1277,13 @@ class WebRTCPhone extends Emitter {
|
|
|
1276
1277
|
this.audioOutputVolume,
|
|
1277
1278
|
);
|
|
1278
1279
|
case sessionState.SessionState.Terminating:
|
|
1279
|
-
logger
|
|
1280
|
+
logger.info('WebRTC phone - call terminating', { sipId: sipSession.id });
|
|
1280
1281
|
|
|
1281
1282
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
1282
1283
|
|
|
1283
1284
|
break;
|
|
1284
1285
|
case sessionState.SessionState.Terminated: {
|
|
1285
|
-
logger
|
|
1286
|
+
logger.info('WebRTC phone - call terminated', { sipId: sipSession.id });
|
|
1286
1287
|
|
|
1287
1288
|
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
1288
1289
|
const callSession = this._createCallSession(sipSession);
|
|
@@ -1304,7 +1305,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1304
1305
|
const [stream] = event.streams;
|
|
1305
1306
|
const kind = event && event.track && event.track.kind;
|
|
1306
1307
|
|
|
1307
|
-
logger
|
|
1308
|
+
logger.info('on track stream called on the peer connection', {
|
|
1308
1309
|
callId: this.getSipSessionId(sipSession),
|
|
1309
1310
|
streamId: stream ? stream.id : null,
|
|
1310
1311
|
tracks: stream ? stream.getTracks() : null,
|
|
@@ -1324,7 +1325,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1324
1325
|
};
|
|
1325
1326
|
|
|
1326
1327
|
peerConnection.onremovestream = event => {
|
|
1327
|
-
logger
|
|
1328
|
+
logger.info('on remove stream called on the peer connection', {
|
|
1328
1329
|
id: event.stream.id,
|
|
1329
1330
|
tracks: event.stream.getTracks(),
|
|
1330
1331
|
});
|
|
@@ -1334,7 +1335,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1334
1335
|
}
|
|
1335
1336
|
|
|
1336
1337
|
async startScreenSharing(constraints , callSession ) {
|
|
1337
|
-
logger
|
|
1338
|
+
logger.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
|
|
1338
1339
|
|
|
1339
1340
|
const screenShareStream = await this.client.getStreamFromConstraints(constraints);
|
|
1340
1341
|
if (!screenShareStream) {
|
|
@@ -1374,7 +1375,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1374
1375
|
return;
|
|
1375
1376
|
}
|
|
1376
1377
|
|
|
1377
|
-
logger
|
|
1378
|
+
logger.info('WebRTC phone - stop screen sharing', {
|
|
1378
1379
|
restoreLocalStream,
|
|
1379
1380
|
});
|
|
1380
1381
|
|
|
@@ -1430,7 +1431,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1430
1431
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
1431
1432
|
const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
1432
1433
|
|
|
1433
|
-
logger
|
|
1434
|
+
logger.info('WebRTC phone - on screensharing', {
|
|
1434
1435
|
hadVideo,
|
|
1435
1436
|
id: this.getSipSessionId(sipSession),
|
|
1436
1437
|
screenTrack,
|
|
@@ -1438,7 +1439,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1438
1439
|
|
|
1439
1440
|
if (screenTrack) {
|
|
1440
1441
|
screenTrack.onended = () => {
|
|
1441
|
-
logger
|
|
1442
|
+
logger.info('WebRTC phone - on screenshare ended', {
|
|
1442
1443
|
hadVideo,
|
|
1443
1444
|
id: this.getSipSessionId(sipSession),
|
|
1444
1445
|
screenTrack,
|
|
@@ -1469,7 +1470,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1469
1470
|
}
|
|
1470
1471
|
|
|
1471
1472
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
1472
|
-
logger
|
|
1473
|
+
logger.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
1473
1474
|
|
|
1474
1475
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
1475
1476
|
this.currentSipSession = sipSession;
|
|
@@ -1487,7 +1488,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1487
1488
|
}
|
|
1488
1489
|
|
|
1489
1490
|
changeAudioDevice(id ) {
|
|
1490
|
-
logger
|
|
1491
|
+
logger.info('WebRTC phone - change audio device', { deviceId: id });
|
|
1491
1492
|
this.audioOutputDeviceId = id;
|
|
1492
1493
|
this.client.changeAudioOutputDevice(id);
|
|
1493
1494
|
}
|
|
@@ -1497,14 +1498,14 @@ class WebRTCPhone extends Emitter {
|
|
|
1497
1498
|
}
|
|
1498
1499
|
|
|
1499
1500
|
changeRingDevice(id ) {
|
|
1500
|
-
logger
|
|
1501
|
+
logger.info('WebRTC phone - changing ring device', { id });
|
|
1501
1502
|
|
|
1502
1503
|
this.audioRingDeviceId = id;
|
|
1503
1504
|
}
|
|
1504
1505
|
|
|
1505
1506
|
// volume is a value between 0 and 1
|
|
1506
1507
|
changeAudioVolume(volume ) {
|
|
1507
|
-
logger
|
|
1508
|
+
logger.info('WebRTC phone - changing audio volume', { volume });
|
|
1508
1509
|
|
|
1509
1510
|
this.audioOutputVolume = volume;
|
|
1510
1511
|
this.client.changeAudioOutputVolume(volume);
|
|
@@ -1512,31 +1513,31 @@ class WebRTCPhone extends Emitter {
|
|
|
1512
1513
|
|
|
1513
1514
|
// volume is a value between 0 and 1
|
|
1514
1515
|
changeRingVolume(volume ) {
|
|
1515
|
-
logger
|
|
1516
|
+
logger.info('WebRTC phone - changing ring volume', { volume });
|
|
1516
1517
|
|
|
1517
1518
|
this.audioRingVolume = volume;
|
|
1518
1519
|
}
|
|
1519
1520
|
|
|
1520
1521
|
changeAudioInputDevice(id ) {
|
|
1521
|
-
logger
|
|
1522
|
+
logger.info('WebRTC phone - changeAudio input device', { deviceId: id });
|
|
1522
1523
|
|
|
1523
1524
|
return this.client.changeAudioInputDevice(id, this.currentSipSession);
|
|
1524
1525
|
}
|
|
1525
1526
|
|
|
1526
1527
|
changeVideoInputDevice(id ) {
|
|
1527
|
-
logger
|
|
1528
|
+
logger.info('WebRTC phone - change video input device', { deviceId: id });
|
|
1528
1529
|
|
|
1529
1530
|
return this.client.changeVideoInputDevice(id, this.currentSipSession);
|
|
1530
1531
|
}
|
|
1531
1532
|
|
|
1532
1533
|
changeSessionVideoInputDevice(id ) {
|
|
1533
|
-
logger
|
|
1534
|
+
logger.info('WebRTC phone - change session video input device', { deviceId: id });
|
|
1534
1535
|
|
|
1535
1536
|
return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
1536
1537
|
}
|
|
1537
1538
|
|
|
1538
1539
|
_onCallTerminated(sipSession ) {
|
|
1539
|
-
logger
|
|
1540
|
+
logger.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
1540
1541
|
|
|
1541
1542
|
const callSession = this._createCallSession(sipSession);
|
|
1542
1543
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
@@ -1570,7 +1571,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1570
1571
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
1571
1572
|
|
|
1572
1573
|
// Re-trigger incoming call event for remaining incoming calls
|
|
1573
|
-
logger
|
|
1574
|
+
logger.info('WebRTC phone - check to re-trigger incoming call', {
|
|
1574
1575
|
sipId: sipSession.id,
|
|
1575
1576
|
shouldRetrigger,
|
|
1576
1577
|
hasIncomingCallSession,
|
|
@@ -1661,37 +1662,37 @@ class WebRTCPhone extends Emitter {
|
|
|
1661
1662
|
|
|
1662
1663
|
// Deprecated
|
|
1663
1664
|
getLocalStreamForCall(callSession ) {
|
|
1664
|
-
logger
|
|
1665
|
+
logger.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
1665
1666
|
|
|
1666
1667
|
return this.getLocalStream(callSession);
|
|
1667
1668
|
}
|
|
1668
1669
|
|
|
1669
1670
|
// Deprecated
|
|
1670
1671
|
getRemoteStreamForCall(callSession ) {
|
|
1671
|
-
logger
|
|
1672
|
+
logger.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
|
|
1672
1673
|
|
|
1673
1674
|
return this.getRemoteVideoStream(callSession);
|
|
1674
1675
|
}
|
|
1675
1676
|
|
|
1676
1677
|
getRemoteStreamsForCall(callSession ) {
|
|
1677
|
-
logger
|
|
1678
|
+
logger.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
|
|
1678
1679
|
|
|
1679
1680
|
return this.getRemoteStream(callSession);
|
|
1680
1681
|
}
|
|
1681
1682
|
|
|
1682
1683
|
accept(callSession , cameraEnabled ) {
|
|
1683
|
-
logger
|
|
1684
|
+
logger.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
|
|
1684
1685
|
if (this.currentSipSession) {
|
|
1685
1686
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
|
|
1686
1687
|
}
|
|
1687
1688
|
|
|
1688
1689
|
if (!callSession) {
|
|
1689
|
-
logger
|
|
1690
|
+
logger.warn('no CallSession to accept.');
|
|
1690
1691
|
return Promise.resolve(null);
|
|
1691
1692
|
}
|
|
1692
1693
|
|
|
1693
1694
|
if (callSession.getId() in this.acceptedSessions) {
|
|
1694
|
-
logger
|
|
1695
|
+
logger.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
1695
1696
|
return Promise.resolve(callSession.sipCallId);
|
|
1696
1697
|
}
|
|
1697
1698
|
|
|
@@ -1703,24 +1704,24 @@ class WebRTCPhone extends Emitter {
|
|
|
1703
1704
|
const sipSession = this.client.getSipSession(callSession.getId());
|
|
1704
1705
|
if (sipSession) {
|
|
1705
1706
|
if (sipSession.state === sessionState.SessionState.Terminated || sipSession.state === sessionState.SessionState.Terminating) {
|
|
1706
|
-
logger
|
|
1707
|
+
logger.warn('Trying to answer a terminated sipSession.');
|
|
1707
1708
|
|
|
1708
1709
|
return Promise.resolve(null);
|
|
1709
1710
|
}
|
|
1710
1711
|
|
|
1711
|
-
logger
|
|
1712
|
+
logger.info('accept call, session found', { sipId: sipSession.id });
|
|
1712
1713
|
|
|
1713
1714
|
// $FlowFixMe
|
|
1714
1715
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
1715
1716
|
return callSession.sipCallId;
|
|
1716
1717
|
}).catch(e => {
|
|
1717
|
-
logger
|
|
1718
|
+
logger.error(e);
|
|
1718
1719
|
this.endCurrentCall(callSession);
|
|
1719
1720
|
throw e;
|
|
1720
1721
|
});
|
|
1721
1722
|
}
|
|
1722
1723
|
|
|
1723
|
-
logger
|
|
1724
|
+
logger.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
1724
1725
|
|
|
1725
1726
|
return Promise.resolve(null);
|
|
1726
1727
|
}
|
|
@@ -1730,7 +1731,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1730
1731
|
}
|
|
1731
1732
|
|
|
1732
1733
|
async reject(callSession ) {
|
|
1733
|
-
logger
|
|
1734
|
+
logger.info('reject WebRTC called', { id: callSession.getId() });
|
|
1734
1735
|
|
|
1735
1736
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
|
|
1736
1737
|
if (!callSession || callSession.getId() in this.rejectedSessions) {
|
|
@@ -1742,14 +1743,14 @@ class WebRTCPhone extends Emitter {
|
|
|
1742
1743
|
|
|
1743
1744
|
const sipSession = this.findSipSession(callSession);
|
|
1744
1745
|
if (sipSession) {
|
|
1745
|
-
logger
|
|
1746
|
+
logger.info('WebRTC rejecting', { sipId: sipSession.id });
|
|
1746
1747
|
|
|
1747
1748
|
this.client.hangup(sipSession);
|
|
1748
1749
|
}
|
|
1749
1750
|
}
|
|
1750
1751
|
|
|
1751
1752
|
async ignore(callSession ) {
|
|
1752
|
-
logger
|
|
1753
|
+
logger.info('WebRTC ignore', { id: callSession.getId() });
|
|
1753
1754
|
|
|
1754
1755
|
// kill the ring
|
|
1755
1756
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
|
|
@@ -1761,14 +1762,14 @@ class WebRTCPhone extends Emitter {
|
|
|
1761
1762
|
const sipSession = this.findSipSession(callSession);
|
|
1762
1763
|
|
|
1763
1764
|
if (sipSession) {
|
|
1764
|
-
logger
|
|
1765
|
+
logger.info('WebRTC atxfer', { sipId: sipSession.id });
|
|
1765
1766
|
|
|
1766
1767
|
return this.client.atxfer(sipSession);
|
|
1767
1768
|
}
|
|
1768
1769
|
}
|
|
1769
1770
|
|
|
1770
1771
|
hold(callSession , withEvent = true, isConference = false) {
|
|
1771
|
-
logger
|
|
1772
|
+
logger.info('WebRTC hold', { id: callSession.getId() });
|
|
1772
1773
|
|
|
1773
1774
|
const sipSession = this.findSipSession(callSession);
|
|
1774
1775
|
|
|
@@ -1783,18 +1784,18 @@ class WebRTCPhone extends Emitter {
|
|
|
1783
1784
|
}
|
|
1784
1785
|
|
|
1785
1786
|
resume(callSession , isConference = false, withEvent = true) {
|
|
1786
|
-
logger
|
|
1787
|
+
logger.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
|
|
1787
1788
|
|
|
1788
1789
|
const sipSession = this.findSipSession(callSession);
|
|
1789
1790
|
if (!sipSession) {
|
|
1790
1791
|
return new Promise((resolve, reject) => reject(new Error('No session to resume')));
|
|
1791
1792
|
}
|
|
1792
1793
|
|
|
1793
|
-
logger
|
|
1794
|
+
logger.info('WebRTC resuming', { sipId: sipSession.id });
|
|
1794
1795
|
|
|
1795
1796
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
1796
1797
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
1797
|
-
logger
|
|
1798
|
+
logger.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
1798
1799
|
this.holdSipSession(this.currentSipSession, callSession);
|
|
1799
1800
|
}
|
|
1800
1801
|
|
|
@@ -1819,7 +1820,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1819
1820
|
const sessionId = this.getSipSessionId(sipSession);
|
|
1820
1821
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
1821
1822
|
|
|
1822
|
-
logger
|
|
1823
|
+
logger.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
1823
1824
|
|
|
1824
1825
|
// Stop screenshre if needed
|
|
1825
1826
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
@@ -1850,7 +1851,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1850
1851
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
1851
1852
|
}
|
|
1852
1853
|
const sessionId = this.getSipSessionId(sipSession);
|
|
1853
|
-
logger
|
|
1854
|
+
logger.info('WebRTC unhold sip session', { sessionId, isConference });
|
|
1854
1855
|
|
|
1855
1856
|
const { hasVideo } = this.client.getHeldSession(sessionId) || {};
|
|
1856
1857
|
const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
|
|
@@ -1894,14 +1895,14 @@ class WebRTCPhone extends Emitter {
|
|
|
1894
1895
|
}
|
|
1895
1896
|
|
|
1896
1897
|
mute(callSession , withEvent = true) {
|
|
1897
|
-
logger
|
|
1898
|
+
logger.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
|
|
1898
1899
|
|
|
1899
1900
|
const sipSession = this.findSipSession(callSession);
|
|
1900
1901
|
if (!sipSession) {
|
|
1901
1902
|
return;
|
|
1902
1903
|
}
|
|
1903
1904
|
|
|
1904
|
-
logger
|
|
1905
|
+
logger.info('WebRTC muting', { sipId: sipSession.id });
|
|
1905
1906
|
this.client.mute(sipSession);
|
|
1906
1907
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
|
|
1907
1908
|
|
|
@@ -1915,14 +1916,14 @@ class WebRTCPhone extends Emitter {
|
|
|
1915
1916
|
}
|
|
1916
1917
|
|
|
1917
1918
|
unmute(callSession , withEvent = true) {
|
|
1918
|
-
logger
|
|
1919
|
+
logger.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
|
|
1919
1920
|
|
|
1920
1921
|
const sipSession = this.findSipSession(callSession);
|
|
1921
1922
|
if (!sipSession) {
|
|
1922
1923
|
return;
|
|
1923
1924
|
}
|
|
1924
1925
|
|
|
1925
|
-
logger
|
|
1926
|
+
logger.info('WebRTC unmuting', { sipId: sipSession.id });
|
|
1926
1927
|
this.client.unmute(sipSession);
|
|
1927
1928
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
|
|
1928
1929
|
|
|
@@ -1949,7 +1950,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1949
1950
|
if (!sipSession) {
|
|
1950
1951
|
return;
|
|
1951
1952
|
}
|
|
1952
|
-
logger
|
|
1953
|
+
logger.info('WebRTC turn camera on', { sipId: sipSession.id });
|
|
1953
1954
|
|
|
1954
1955
|
this.client.toggleCameraOn(sipSession);
|
|
1955
1956
|
|
|
@@ -1961,7 +1962,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1961
1962
|
if (!sipSession) {
|
|
1962
1963
|
return;
|
|
1963
1964
|
}
|
|
1964
|
-
logger
|
|
1965
|
+
logger.info('WebRTC turn camera off', { sipId: sipSession.id });
|
|
1965
1966
|
|
|
1966
1967
|
this.client.toggleCameraOff(sipSession);
|
|
1967
1968
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -1973,7 +1974,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1973
1974
|
return;
|
|
1974
1975
|
}
|
|
1975
1976
|
|
|
1976
|
-
logger
|
|
1977
|
+
logger.info('WebRTC send key', { sipId: sipSession.id, tone });
|
|
1977
1978
|
this.client.sendDTMF(sipSession, tone);
|
|
1978
1979
|
}
|
|
1979
1980
|
|
|
@@ -1981,7 +1982,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1981
1982
|
// @TODO: line is not used here
|
|
1982
1983
|
async makeCall(number , line , cameraEnabled ,
|
|
1983
1984
|
audioOnly = false, conference = false) {
|
|
1984
|
-
logger
|
|
1985
|
+
logger.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled, audioOnly, conference });
|
|
1985
1986
|
if (!number) {
|
|
1986
1987
|
return Promise.resolve(null);
|
|
1987
1988
|
}
|
|
@@ -1991,7 +1992,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1991
1992
|
}
|
|
1992
1993
|
if (this.currentSipSession) {
|
|
1993
1994
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
|
|
1994
|
-
logger
|
|
1995
|
+
logger.warn('Unable to hold current session when making another call', e);
|
|
1995
1996
|
});
|
|
1996
1997
|
}
|
|
1997
1998
|
|
|
@@ -2001,7 +2002,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2001
2002
|
this._bindEvents(sipSession);
|
|
2002
2003
|
} catch (error) {
|
|
2003
2004
|
console.warn(error);
|
|
2004
|
-
logger
|
|
2005
|
+
logger.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
|
|
2005
2006
|
return Promise.resolve(null);
|
|
2006
2007
|
}
|
|
2007
2008
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
@@ -2029,7 +2030,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2029
2030
|
return;
|
|
2030
2031
|
}
|
|
2031
2032
|
|
|
2032
|
-
logger
|
|
2033
|
+
logger.info('WebRTC transfer', { sipId: sipSession.id, target });
|
|
2033
2034
|
|
|
2034
2035
|
this.client.transfer(sipSession, target);
|
|
2035
2036
|
}
|
|
@@ -2038,7 +2039,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2038
2039
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
2039
2040
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
2040
2041
|
|
|
2041
|
-
logger
|
|
2042
|
+
logger.info('WebRTC indirect transfer', {
|
|
2042
2043
|
sipId: sipSession ? sipSession.id : null,
|
|
2043
2044
|
target: sipSessionTarget ? sipSessionTarget.id : null,
|
|
2044
2045
|
});
|
|
@@ -2077,7 +2078,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2077
2078
|
return false;
|
|
2078
2079
|
}
|
|
2079
2080
|
|
|
2080
|
-
logger
|
|
2081
|
+
logger.info('WebRTC hangup', { sipId: sipSession.id });
|
|
2081
2082
|
|
|
2082
2083
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
2083
2084
|
|
|
@@ -2123,7 +2124,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2123
2124
|
endCurrentCall(callSession ) {
|
|
2124
2125
|
const isCurrent = this.isCurrentCallSipSession(callSession);
|
|
2125
2126
|
|
|
2126
|
-
logger
|
|
2127
|
+
logger.info('Ending current call', {
|
|
2127
2128
|
id: callSession ? callSession.getId() : null,
|
|
2128
2129
|
isCurrent,
|
|
2129
2130
|
});
|
|
@@ -2147,7 +2148,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2147
2148
|
}
|
|
2148
2149
|
|
|
2149
2150
|
async close() {
|
|
2150
|
-
logger
|
|
2151
|
+
logger.info('WebRTC close');
|
|
2151
2152
|
|
|
2152
2153
|
try {
|
|
2153
2154
|
await Promise.race([
|
|
@@ -2155,7 +2156,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2155
2156
|
new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
|
|
2156
2157
|
]);
|
|
2157
2158
|
} catch (e) {
|
|
2158
|
-
logger
|
|
2159
|
+
logger.error('WebRTC close, unregister error', e);
|
|
2159
2160
|
}
|
|
2160
2161
|
|
|
2161
2162
|
this.client.close();
|
|
@@ -2173,12 +2174,12 @@ class WebRTCPhone extends Emitter {
|
|
|
2173
2174
|
}
|
|
2174
2175
|
|
|
2175
2176
|
enableRinging() {
|
|
2176
|
-
logger
|
|
2177
|
+
logger.info('WebRTC enable ringing');
|
|
2177
2178
|
this.ringingEnabled = true;
|
|
2178
2179
|
}
|
|
2179
2180
|
|
|
2180
2181
|
disableRinging() {
|
|
2181
|
-
logger
|
|
2182
|
+
logger.info('WebRTC disable ringing');
|
|
2182
2183
|
this.ringingEnabled = false;
|
|
2183
2184
|
}
|
|
2184
2185
|
|
|
@@ -2218,7 +2219,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2218
2219
|
|
|
2219
2220
|
// Deprecated
|
|
2220
2221
|
getLocalMediaStream(callSession ) {
|
|
2221
|
-
logger
|
|
2222
|
+
logger.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
2222
2223
|
return this.getLocalStream(callSession);
|
|
2223
2224
|
}
|
|
2224
2225
|
|
|
@@ -2260,7 +2261,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2260
2261
|
this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
|
|
2261
2262
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
2262
2263
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
2263
|
-
logger
|
|
2264
|
+
logger.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
|
|
2264
2265
|
|
|
2265
2266
|
const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
|
|
2266
2267
|
this.incomingSessions.push(callSession.getId());
|
|
@@ -2283,7 +2284,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2283
2284
|
});
|
|
2284
2285
|
|
|
2285
2286
|
this.client.on(this.client.ON_REINVITE, (...args) => {
|
|
2286
|
-
logger
|
|
2287
|
+
logger.info('WebRTC on reinvite', {
|
|
2287
2288
|
sessionId: args[0].id,
|
|
2288
2289
|
inviteId: args[1].id,
|
|
2289
2290
|
updatedCalleeName: args[2],
|
|
@@ -2303,7 +2304,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2303
2304
|
});
|
|
2304
2305
|
|
|
2305
2306
|
this.client.on(this.client.ACCEPTED, (sipSession ) => {
|
|
2306
|
-
logger
|
|
2307
|
+
logger.info('WebRTC call accepted', { sipId: sipSession.id });
|
|
2307
2308
|
|
|
2308
2309
|
this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
|
|
2309
2310
|
|
|
@@ -2314,22 +2315,22 @@ class WebRTCPhone extends Emitter {
|
|
|
2314
2315
|
this.client.on('ended', () => {});
|
|
2315
2316
|
|
|
2316
2317
|
this.client.on(this.client.ON_ERROR, e => {
|
|
2317
|
-
logger
|
|
2318
|
+
logger.error('WebRTC error', e);
|
|
2318
2319
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
2319
2320
|
});
|
|
2320
2321
|
|
|
2321
2322
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
2322
|
-
logger
|
|
2323
|
+
logger.info('WebRTC unregistered');
|
|
2323
2324
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
2324
2325
|
});
|
|
2325
2326
|
|
|
2326
2327
|
this.client.on(this.client.ON_DISCONNECTED, () => {
|
|
2327
|
-
logger
|
|
2328
|
+
logger.info('WebRTC disconnected');
|
|
2328
2329
|
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
2329
2330
|
});
|
|
2330
2331
|
|
|
2331
2332
|
this.client.on(this.client.REGISTERED, () => {
|
|
2332
|
-
logger
|
|
2333
|
+
logger.info('WebRTC registered', {
|
|
2333
2334
|
shouldSendReinvite: this.shouldSendReinvite,
|
|
2334
2335
|
state: this.currentSipSession ? this.currentSipSession.state : null,
|
|
2335
2336
|
currentSipSession: !!this.currentSipSession,
|
|
@@ -2350,19 +2351,19 @@ class WebRTCPhone extends Emitter {
|
|
|
2350
2351
|
// Send reinvite with iceRestart
|
|
2351
2352
|
this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
|
|
2352
2353
|
} catch (e) {
|
|
2353
|
-
logger
|
|
2354
|
+
logger.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
2354
2355
|
}
|
|
2355
2356
|
}
|
|
2356
2357
|
});
|
|
2357
2358
|
|
|
2358
2359
|
this.client.on(this.client.CONNECTED, () => {
|
|
2359
|
-
logger
|
|
2360
|
+
logger.info('WebRTC client connected');
|
|
2360
2361
|
|
|
2361
2362
|
this.stopHeartbeat();
|
|
2362
2363
|
});
|
|
2363
2364
|
|
|
2364
2365
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
2365
|
-
logger
|
|
2366
|
+
logger.info('WebRTC client disconnected');
|
|
2366
2367
|
|
|
2367
2368
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
2368
2369
|
|
|
@@ -2400,7 +2401,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2400
2401
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
2401
2402
|
const callSession = this.callSessions[sipSessionId];
|
|
2402
2403
|
|
|
2403
|
-
logger
|
|
2404
|
+
logger.info('Updrading directly in screensharing mode', {
|
|
2404
2405
|
sipSessionId,
|
|
2405
2406
|
tracks: localStream ? localStream.getTracks() : null,
|
|
2406
2407
|
});
|