@wazo/sdk 0.37.24 → 0.37.28
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 +96 -58
- package/dist/wazo-sdk.js +6 -6
- package/esm/__tests__/api-client.test.js +14 -14
- package/esm/__tests__/web-rtc-client.test.js +130 -108
- package/esm/api/agentd.js +1 -1
- package/esm/api/amid.js +2 -2
- package/esm/api/application.js +1 -1
- package/esm/api/auth.js +1 -1
- package/esm/api/call-logd.js +3 -3
- package/esm/api/calld.js +1 -1
- package/esm/api/chatd.js +1 -1
- package/esm/api/confd.js +1 -1
- package/esm/api/ctid-ng.js +4 -4
- package/esm/api/dird.js +3 -3
- package/esm/api/webhookd.js +2 -2
- package/esm/api-client.js +14 -14
- package/esm/checker/Checker.js +155 -133
- package/esm/checker/checks/aor.js +14 -14
- package/esm/checker/checks/api.js +14 -14
- package/esm/checker/checks/index.js +145 -123
- package/esm/checker/checks/wazo-websocket.js +16 -16
- package/esm/checker/checks/webrtc-transport.js +130 -108
- package/esm/checker/checks/webrtc.js +130 -108
- package/esm/domain/AdHocAPIConference.js +14 -14
- package/esm/domain/CallLog.js +1 -1
- package/esm/domain/CallSession.js +15 -0
- package/esm/domain/Contact.js +2 -2
- package/esm/domain/Features.js +14 -14
- package/esm/domain/Phone/CTIPhone.js +43 -28
- package/esm/domain/Phone/WebRTCPhone.js +126 -90
- package/esm/domain/SFUNotAvailableError.js +9 -0
- package/esm/domain/__tests__/CallLog.test.js +1 -1
- package/esm/domain/__tests__/CallSession.test.js +15 -0
- package/esm/domain/__tests__/Contact.test.js +2 -2
- package/esm/domain/__tests__/IndirectTransfer.test.js +15 -0
- package/esm/domain/__tests__/Room.test.js +15 -0
- package/esm/index.js +415 -346
- package/esm/lib/WazoSessionDescriptionHandler.js +10 -5
- package/esm/service/CallApi.js +14 -14
- package/esm/service/IssueReporter.js +2 -2
- package/esm/service/__tests__/IssueReporter.test.js +2 -2
- package/esm/service/getApiClient.js +14 -14
- package/esm/simple/Auth.js +404 -336
- package/esm/simple/Configuration.js +404 -336
- package/esm/simple/Directory.js +14 -14
- package/esm/simple/Phone.js +404 -336
- package/esm/simple/Websocket.js +18 -18
- package/esm/simple/index.js +408 -340
- package/esm/simple/room/LocalParticipant.js +408 -340
- package/esm/simple/room/Participant.js +408 -340
- package/esm/simple/room/RemoteParticipant.js +408 -340
- package/esm/simple/room/Room.js +409 -341
- package/esm/simple/room/SipRoom.js +408 -340
- package/esm/simple/room/Stream.js +408 -340
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +408 -340
- package/esm/simple/utils.js +408 -340
- package/esm/utils/__tests__/api-requester.test.js +1 -1
- package/esm/utils/api-requester.js +1 -1
- package/esm/web-rtc-client.js +130 -108
- package/esm/websocket-client.js +16 -16
- package/lib/__tests__/api-client.test.js +14 -14
- package/lib/__tests__/web-rtc-client.test.js +130 -108
- package/lib/api/agentd.js +1 -1
- package/lib/api/amid.js +2 -2
- package/lib/api/application.js +1 -1
- package/lib/api/auth.js +1 -1
- package/lib/api/call-logd.js +3 -3
- package/lib/api/calld.js +1 -1
- package/lib/api/chatd.js +1 -1
- package/lib/api/confd.js +1 -1
- package/lib/api/ctid-ng.js +4 -4
- package/lib/api/dird.js +3 -3
- package/lib/api/webhookd.js +2 -2
- package/lib/api-client.js +14 -14
- package/lib/checker/Checker.js +155 -133
- package/lib/checker/checks/aor.js +14 -14
- package/lib/checker/checks/api.js +14 -14
- package/lib/checker/checks/index.js +145 -123
- package/lib/checker/checks/wazo-websocket.js +16 -16
- package/lib/checker/checks/webrtc-transport.js +130 -108
- package/lib/checker/checks/webrtc.js +130 -108
- package/lib/domain/AdHocAPIConference.js +14 -14
- package/lib/domain/CallLog.js +1 -1
- package/lib/domain/CallSession.js +15 -0
- package/lib/domain/Contact.js +2 -2
- package/lib/domain/Features.js +14 -14
- package/lib/domain/Phone/CTIPhone.js +43 -28
- package/lib/domain/Phone/WebRTCPhone.js +126 -89
- package/lib/domain/SFUNotAvailableError.js +11 -0
- package/lib/domain/__tests__/CallLog.test.js +1 -1
- package/lib/domain/__tests__/CallSession.test.js +15 -0
- package/lib/domain/__tests__/Contact.test.js +2 -2
- package/lib/domain/__tests__/IndirectTransfer.test.js +15 -0
- package/lib/domain/__tests__/Room.test.js +15 -0
- package/lib/index.js +415 -346
- package/lib/lib/WazoSessionDescriptionHandler.js +10 -5
- package/lib/service/CallApi.js +14 -14
- package/lib/service/IssueReporter.js +2 -2
- package/lib/service/__tests__/IssueReporter.test.js +2 -2
- package/lib/service/getApiClient.js +14 -14
- package/lib/simple/Auth.js +404 -336
- package/lib/simple/Configuration.js +404 -336
- package/lib/simple/Directory.js +14 -14
- package/lib/simple/Phone.js +404 -336
- package/lib/simple/Websocket.js +18 -18
- package/lib/simple/index.js +408 -340
- package/lib/simple/room/LocalParticipant.js +408 -340
- package/lib/simple/room/Participant.js +408 -340
- package/lib/simple/room/RemoteParticipant.js +408 -340
- package/lib/simple/room/Room.js +409 -341
- package/lib/simple/room/SipRoom.js +408 -340
- package/lib/simple/room/Stream.js +408 -340
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +408 -340
- package/lib/simple/utils.js +408 -340
- package/lib/utils/__tests__/api-requester.test.js +1 -1
- package/lib/utils/api-requester.js +1 -1
- package/lib/web-rtc-client.js +130 -108
- package/lib/websocket-client.js +16 -16
- package/package.json +1 -1
- package/src/domain/CallSession.js +16 -0
- package/src/domain/Contact.js +1 -1
- package/src/domain/Phone/WebRTCPhone.js +25 -4
- package/src/domain/SFUNotAvailableError.js +7 -0
- package/src/index.js +2 -0
- package/src/lib/WazoSessionDescriptionHandler.js +8 -3
- package/src/simple/Phone.js +2 -1
- package/src/simple/index.js +2 -0
- package/src/utils/api-requester.js +1 -1
- package/src/web-rtc-client.js +27 -10
|
@@ -68,8 +68,10 @@ var updateFrom = (instance , from ) => {
|
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
|
|
71
|
+
|
|
71
72
|
|
|
72
73
|
|
|
74
|
+
|
|
73
75
|
|
|
74
76
|
|
|
75
77
|
|
|
@@ -86,6 +88,7 @@ var updateFrom = (instance , from ) => {
|
|
|
86
88
|
|
|
87
89
|
|
|
88
90
|
|
|
91
|
+
|
|
89
92
|
|
|
90
93
|
|
|
91
94
|
class CallSession {
|
|
@@ -105,8 +108,12 @@ class CallSession {
|
|
|
105
108
|
|
|
106
109
|
|
|
107
110
|
|
|
111
|
+
|
|
112
|
+
|
|
108
113
|
|
|
109
114
|
|
|
115
|
+
|
|
116
|
+
|
|
110
117
|
|
|
111
118
|
|
|
112
119
|
|
|
@@ -144,6 +151,8 @@ class CallSession {
|
|
|
144
151
|
|
|
145
152
|
|
|
146
153
|
|
|
154
|
+
|
|
155
|
+
|
|
147
156
|
|
|
148
157
|
constructor({
|
|
149
158
|
answered,
|
|
@@ -157,6 +166,8 @@ class CallSession {
|
|
|
157
166
|
paused,
|
|
158
167
|
ringing,
|
|
159
168
|
startTime,
|
|
169
|
+
creationTime,
|
|
170
|
+
endTime,
|
|
160
171
|
cameraEnabled,
|
|
161
172
|
dialedExtension,
|
|
162
173
|
sipCallId,
|
|
@@ -169,12 +180,15 @@ class CallSession {
|
|
|
169
180
|
recording,
|
|
170
181
|
recordingPaused,
|
|
171
182
|
videoRemotelyDowngraded,
|
|
183
|
+
sipSession,
|
|
172
184
|
} ) {
|
|
173
185
|
this.callId = callId;
|
|
174
186
|
this.sipCallId = sipCallId;
|
|
175
187
|
this.displayName = displayName;
|
|
176
188
|
this.number = number;
|
|
189
|
+
this.creationTime = creationTime;
|
|
177
190
|
this.startTime = startTime;
|
|
191
|
+
this.endTime = endTime;
|
|
178
192
|
this.isCaller = isCaller;
|
|
179
193
|
this.answered = answered;
|
|
180
194
|
this.answeredBySystem = answeredBySystem;
|
|
@@ -193,6 +207,7 @@ class CallSession {
|
|
|
193
207
|
this.recording = recording || false;
|
|
194
208
|
this.recordingPaused = recordingPaused || false;
|
|
195
209
|
this.videoRemotelyDowngraded = videoRemotelyDowngraded;
|
|
210
|
+
this.sipSession = sipSession;
|
|
196
211
|
|
|
197
212
|
// Useful to compare instead of instanceof with minified code
|
|
198
213
|
this.type = 'CallSession';
|
|
@@ -410,11 +425,11 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
|
|
|
410
425
|
|
|
411
426
|
/* */
|
|
412
427
|
|
|
413
|
-
|
|
428
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
414
429
|
|
|
415
430
|
// Use a function here to be able to mock it in tests
|
|
416
431
|
const realFetch = () => {
|
|
417
|
-
if (typeof document !== 'undefined') {
|
|
432
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
418
433
|
// Browser
|
|
419
434
|
return window.fetch;
|
|
420
435
|
}
|
|
@@ -795,7 +810,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
795
810
|
|
|
796
811
|
/* global RTCSessionDescriptionInit, navigator */
|
|
797
812
|
|
|
798
|
-
|
|
813
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
799
814
|
|
|
800
815
|
//
|
|
801
816
|
|
|
@@ -837,7 +852,7 @@ BwIDAQAB
|
|
|
837
852
|
|
|
838
853
|
//
|
|
839
854
|
|
|
840
|
-
|
|
855
|
+
jsrsasign.KEYUTIL.getKey(swarmPublicKey);
|
|
841
856
|
|
|
842
857
|
/* eslint-disable dot-notation */
|
|
843
858
|
|
|
@@ -858,15 +873,15 @@ global.wazoFetchOptions = global.wazoFetchOptions || {};
|
|
|
858
873
|
|
|
859
874
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
860
875
|
|
|
861
|
-
|
|
876
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
862
877
|
|
|
863
878
|
/* */
|
|
864
879
|
|
|
865
|
-
|
|
880
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
866
881
|
|
|
867
882
|
//
|
|
868
|
-
|
|
869
|
-
|
|
883
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
884
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
870
885
|
|
|
871
886
|
/* eslint-disable no-param-reassign */
|
|
872
887
|
|
|
@@ -887,6 +902,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
|
|
|
887
902
|
const ON_CAMERA_RESUMED = 'onCameraResumed';
|
|
888
903
|
const ON_CALL_CANCELED = 'onCallCanceled';
|
|
889
904
|
const ON_CALL_FAILED = 'onCallFailed';
|
|
905
|
+
const ON_CALL_REJECTED = 'onCallRejected';
|
|
890
906
|
const ON_CALL_ENDED = 'onCallEnded';
|
|
891
907
|
const ON_CALL_ENDING = 'onCallEnding';
|
|
892
908
|
const ON_MESSAGE = 'onMessage';
|
|
@@ -931,6 +947,7 @@ const events = [
|
|
|
931
947
|
ON_CAMERA_DISABLED,
|
|
932
948
|
ON_CALL_FAILED,
|
|
933
949
|
ON_CALL_ENDED,
|
|
950
|
+
ON_CALL_REJECTED,
|
|
934
951
|
ON_MESSAGE,
|
|
935
952
|
ON_REINVITE,
|
|
936
953
|
ON_TRACK,
|
|
@@ -952,7 +969,7 @@ const events = [
|
|
|
952
969
|
ON_DISCONNECTED,
|
|
953
970
|
];
|
|
954
971
|
|
|
955
|
-
const logger
|
|
972
|
+
const logger = IssueReporter$1.loggerFor('webrtc-phone');
|
|
956
973
|
|
|
957
974
|
class WebRTCPhone extends Emitter {
|
|
958
975
|
|
|
@@ -1025,7 +1042,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1025
1042
|
}).catch(error => {
|
|
1026
1043
|
// Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
|
|
1027
1044
|
console.error('register error', error, error.message, error.stack);
|
|
1028
|
-
logger
|
|
1045
|
+
logger.error('WebRTC register error', { message: error.message, stack: error.stack });
|
|
1029
1046
|
});
|
|
1030
1047
|
}
|
|
1031
1048
|
|
|
@@ -1040,7 +1057,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1040
1057
|
if (!this.client) {
|
|
1041
1058
|
return;
|
|
1042
1059
|
}
|
|
1043
|
-
logger
|
|
1060
|
+
logger.info('WebRTC phone stop');
|
|
1044
1061
|
this.client.stop();
|
|
1045
1062
|
}
|
|
1046
1063
|
|
|
@@ -1055,11 +1072,12 @@ class WebRTCPhone extends Emitter {
|
|
|
1055
1072
|
async sendReinvite(callSession , constraints = null, conference = false,
|
|
1056
1073
|
audioOnly = false, iceRestart = false) {
|
|
1057
1074
|
const sipSession = this.findSipSession(callSession);
|
|
1058
|
-
logger
|
|
1075
|
+
logger.info('WebRTC phone - send reinvite', {
|
|
1059
1076
|
sessionId: sipSession ? sipSession.id : null,
|
|
1060
1077
|
constraints,
|
|
1061
1078
|
audioOnly,
|
|
1062
1079
|
conference,
|
|
1080
|
+
iceRestart,
|
|
1063
1081
|
});
|
|
1064
1082
|
|
|
1065
1083
|
if (!sipSession) {
|
|
@@ -1092,7 +1110,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1092
1110
|
}
|
|
1093
1111
|
|
|
1094
1112
|
startHeartbeat() {
|
|
1095
|
-
logger
|
|
1113
|
+
logger.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
|
|
1096
1114
|
if (!this.client || this.client.hasHeartbeat()) {
|
|
1097
1115
|
return;
|
|
1098
1116
|
}
|
|
@@ -1101,7 +1119,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1101
1119
|
}
|
|
1102
1120
|
|
|
1103
1121
|
stopHeartbeat() {
|
|
1104
|
-
logger
|
|
1122
|
+
logger.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
|
|
1105
1123
|
if (!this.client) {
|
|
1106
1124
|
return;
|
|
1107
1125
|
}
|
|
@@ -1118,7 +1136,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1118
1136
|
}
|
|
1119
1137
|
|
|
1120
1138
|
reconnect() {
|
|
1121
|
-
logger
|
|
1139
|
+
logger.info('WebRTC phone - reconnect', { client: !!this.client });
|
|
1122
1140
|
if (!this.client) {
|
|
1123
1141
|
return;
|
|
1124
1142
|
}
|
|
@@ -1159,7 +1177,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1159
1177
|
return false;
|
|
1160
1178
|
}
|
|
1161
1179
|
|
|
1162
|
-
logger
|
|
1180
|
+
logger.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
|
|
1163
1181
|
|
|
1164
1182
|
this.client.downgradeToAudio(sipSession);
|
|
1165
1183
|
|
|
@@ -1182,7 +1200,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1182
1200
|
return Promise.resolve(false);
|
|
1183
1201
|
}
|
|
1184
1202
|
|
|
1185
|
-
logger
|
|
1203
|
+
logger.info('Upgrade to video', {
|
|
1186
1204
|
id: callSession ? callSession.getId() : null,
|
|
1187
1205
|
constraints,
|
|
1188
1206
|
isConference,
|
|
@@ -1222,7 +1240,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1222
1240
|
|
|
1223
1241
|
_sendReinviteMessage(callSession , isUpgrade ) {
|
|
1224
1242
|
const sipSession = this.findSipSession(callSession);
|
|
1225
|
-
logger
|
|
1243
|
+
logger.info('Sending reinvite message', {
|
|
1226
1244
|
id: callSession ? callSession.getId() : null,
|
|
1227
1245
|
isUpgrade,
|
|
1228
1246
|
});
|
|
@@ -1248,7 +1266,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1248
1266
|
// Monkey patch to know when canceled with the CANCEL message
|
|
1249
1267
|
const onCancel = sipSession._onCancel.bind(sipSession);
|
|
1250
1268
|
sipSession._onCancel = (message ) => {
|
|
1251
|
-
logger
|
|
1269
|
+
logger.trace('on sip session canceled', { callId: message.callId });
|
|
1252
1270
|
|
|
1253
1271
|
onCancel(message);
|
|
1254
1272
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
@@ -1276,16 +1294,17 @@ class WebRTCPhone extends Emitter {
|
|
|
1276
1294
|
this.audioOutputVolume,
|
|
1277
1295
|
);
|
|
1278
1296
|
case sessionState.SessionState.Terminating:
|
|
1279
|
-
logger
|
|
1297
|
+
logger.info('WebRTC phone - call terminating', { sipId: sipSession.id });
|
|
1280
1298
|
|
|
1281
1299
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
1282
1300
|
|
|
1283
1301
|
break;
|
|
1284
1302
|
case sessionState.SessionState.Terminated: {
|
|
1285
|
-
logger
|
|
1303
|
+
logger.info('WebRTC phone - call terminated', { sipId: sipSession.id });
|
|
1286
1304
|
|
|
1287
1305
|
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
1288
1306
|
const callSession = this._createCallSession(sipSession);
|
|
1307
|
+
callSession.endTime = new Date();
|
|
1289
1308
|
const wasCurrentSession = this._onCallTerminated(sipSession);
|
|
1290
1309
|
|
|
1291
1310
|
return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
|
|
@@ -1304,7 +1323,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1304
1323
|
const [stream] = event.streams;
|
|
1305
1324
|
const kind = event && event.track && event.track.kind;
|
|
1306
1325
|
|
|
1307
|
-
logger
|
|
1326
|
+
logger.info('on track stream called on the peer connection', {
|
|
1308
1327
|
callId: this.getSipSessionId(sipSession),
|
|
1309
1328
|
streamId: stream ? stream.id : null,
|
|
1310
1329
|
tracks: stream ? stream.getTracks() : null,
|
|
@@ -1324,7 +1343,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1324
1343
|
};
|
|
1325
1344
|
|
|
1326
1345
|
peerConnection.onremovestream = event => {
|
|
1327
|
-
logger
|
|
1346
|
+
logger.info('on remove stream called on the peer connection', {
|
|
1328
1347
|
id: event.stream.id,
|
|
1329
1348
|
tracks: event.stream.getTracks(),
|
|
1330
1349
|
});
|
|
@@ -1334,7 +1353,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1334
1353
|
}
|
|
1335
1354
|
|
|
1336
1355
|
async startScreenSharing(constraints , callSession ) {
|
|
1337
|
-
logger
|
|
1356
|
+
logger.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
|
|
1338
1357
|
|
|
1339
1358
|
const screenShareStream = await this.client.getStreamFromConstraints(constraints);
|
|
1340
1359
|
if (!screenShareStream) {
|
|
@@ -1374,7 +1393,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1374
1393
|
return;
|
|
1375
1394
|
}
|
|
1376
1395
|
|
|
1377
|
-
logger
|
|
1396
|
+
logger.info('WebRTC phone - stop screen sharing', {
|
|
1378
1397
|
restoreLocalStream,
|
|
1379
1398
|
});
|
|
1380
1399
|
|
|
@@ -1430,7 +1449,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1430
1449
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
1431
1450
|
const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
1432
1451
|
|
|
1433
|
-
logger
|
|
1452
|
+
logger.info('WebRTC phone - on screensharing', {
|
|
1434
1453
|
hadVideo,
|
|
1435
1454
|
id: this.getSipSessionId(sipSession),
|
|
1436
1455
|
screenTrack,
|
|
@@ -1438,7 +1457,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1438
1457
|
|
|
1439
1458
|
if (screenTrack) {
|
|
1440
1459
|
screenTrack.onended = () => {
|
|
1441
|
-
logger
|
|
1460
|
+
logger.info('WebRTC phone - on screenshare ended', {
|
|
1442
1461
|
hadVideo,
|
|
1443
1462
|
id: this.getSipSessionId(sipSession),
|
|
1444
1463
|
screenTrack,
|
|
@@ -1469,7 +1488,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1469
1488
|
}
|
|
1470
1489
|
|
|
1471
1490
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
1472
|
-
logger
|
|
1491
|
+
logger.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
1473
1492
|
|
|
1474
1493
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
1475
1494
|
this.currentSipSession = sipSession;
|
|
@@ -1487,7 +1506,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1487
1506
|
}
|
|
1488
1507
|
|
|
1489
1508
|
changeAudioDevice(id ) {
|
|
1490
|
-
logger
|
|
1509
|
+
logger.info('WebRTC phone - change audio device', { deviceId: id });
|
|
1491
1510
|
this.audioOutputDeviceId = id;
|
|
1492
1511
|
this.client.changeAudioOutputDevice(id);
|
|
1493
1512
|
}
|
|
@@ -1497,14 +1516,14 @@ class WebRTCPhone extends Emitter {
|
|
|
1497
1516
|
}
|
|
1498
1517
|
|
|
1499
1518
|
changeRingDevice(id ) {
|
|
1500
|
-
logger
|
|
1519
|
+
logger.info('WebRTC phone - changing ring device', { id });
|
|
1501
1520
|
|
|
1502
1521
|
this.audioRingDeviceId = id;
|
|
1503
1522
|
}
|
|
1504
1523
|
|
|
1505
1524
|
// volume is a value between 0 and 1
|
|
1506
1525
|
changeAudioVolume(volume ) {
|
|
1507
|
-
logger
|
|
1526
|
+
logger.info('WebRTC phone - changing audio volume', { volume });
|
|
1508
1527
|
|
|
1509
1528
|
this.audioOutputVolume = volume;
|
|
1510
1529
|
this.client.changeAudioOutputVolume(volume);
|
|
@@ -1512,32 +1531,33 @@ class WebRTCPhone extends Emitter {
|
|
|
1512
1531
|
|
|
1513
1532
|
// volume is a value between 0 and 1
|
|
1514
1533
|
changeRingVolume(volume ) {
|
|
1515
|
-
logger
|
|
1534
|
+
logger.info('WebRTC phone - changing ring volume', { volume });
|
|
1516
1535
|
|
|
1517
1536
|
this.audioRingVolume = volume;
|
|
1518
1537
|
}
|
|
1519
1538
|
|
|
1520
1539
|
changeAudioInputDevice(id ) {
|
|
1521
|
-
logger
|
|
1540
|
+
logger.info('WebRTC phone - changeAudio input device', { deviceId: id });
|
|
1522
1541
|
|
|
1523
1542
|
return this.client.changeAudioInputDevice(id, this.currentSipSession);
|
|
1524
1543
|
}
|
|
1525
1544
|
|
|
1526
1545
|
changeVideoInputDevice(id ) {
|
|
1527
|
-
logger
|
|
1546
|
+
logger.info('WebRTC phone - change video input device', { deviceId: id });
|
|
1528
1547
|
|
|
1529
1548
|
return this.client.changeVideoInputDevice(id, this.currentSipSession);
|
|
1530
1549
|
}
|
|
1531
1550
|
|
|
1532
1551
|
changeSessionVideoInputDevice(id ) {
|
|
1533
|
-
logger
|
|
1552
|
+
logger.info('WebRTC phone - change session video input device', { deviceId: id });
|
|
1534
1553
|
|
|
1535
1554
|
return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
1536
1555
|
}
|
|
1537
1556
|
|
|
1538
1557
|
_onCallTerminated(sipSession ) {
|
|
1539
|
-
logger
|
|
1558
|
+
logger.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
1540
1559
|
|
|
1560
|
+
const sipSessionId = this.getSipSessionId(sipSession);
|
|
1541
1561
|
const callSession = this._createCallSession(sipSession);
|
|
1542
1562
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
1543
1563
|
const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
|
|
@@ -1555,7 +1575,6 @@ class WebRTCPhone extends Emitter {
|
|
|
1555
1575
|
}, 5);
|
|
1556
1576
|
}
|
|
1557
1577
|
|
|
1558
|
-
const sipSessionId = this.getSipSessionId(sipSession);
|
|
1559
1578
|
if (sipSessionId) {
|
|
1560
1579
|
this.removeIncomingSessions(sipSessionId);
|
|
1561
1580
|
}
|
|
@@ -1570,7 +1589,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1570
1589
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
1571
1590
|
|
|
1572
1591
|
// Re-trigger incoming call event for remaining incoming calls
|
|
1573
|
-
logger
|
|
1592
|
+
logger.info('WebRTC phone - check to re-trigger incoming call', {
|
|
1574
1593
|
sipId: sipSession.id,
|
|
1575
1594
|
shouldRetrigger,
|
|
1576
1595
|
hasIncomingCallSession,
|
|
@@ -1661,37 +1680,37 @@ class WebRTCPhone extends Emitter {
|
|
|
1661
1680
|
|
|
1662
1681
|
// Deprecated
|
|
1663
1682
|
getLocalStreamForCall(callSession ) {
|
|
1664
|
-
logger
|
|
1683
|
+
logger.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
1665
1684
|
|
|
1666
1685
|
return this.getLocalStream(callSession);
|
|
1667
1686
|
}
|
|
1668
1687
|
|
|
1669
1688
|
// Deprecated
|
|
1670
1689
|
getRemoteStreamForCall(callSession ) {
|
|
1671
|
-
logger
|
|
1690
|
+
logger.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
|
|
1672
1691
|
|
|
1673
1692
|
return this.getRemoteVideoStream(callSession);
|
|
1674
1693
|
}
|
|
1675
1694
|
|
|
1676
1695
|
getRemoteStreamsForCall(callSession ) {
|
|
1677
|
-
logger
|
|
1696
|
+
logger.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
|
|
1678
1697
|
|
|
1679
1698
|
return this.getRemoteStream(callSession);
|
|
1680
1699
|
}
|
|
1681
1700
|
|
|
1682
1701
|
accept(callSession , cameraEnabled ) {
|
|
1683
|
-
logger
|
|
1702
|
+
logger.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
|
|
1684
1703
|
if (this.currentSipSession) {
|
|
1685
1704
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
|
|
1686
1705
|
}
|
|
1687
1706
|
|
|
1688
1707
|
if (!callSession) {
|
|
1689
|
-
logger
|
|
1708
|
+
logger.warn('no CallSession to accept.');
|
|
1690
1709
|
return Promise.resolve(null);
|
|
1691
1710
|
}
|
|
1692
1711
|
|
|
1693
1712
|
if (callSession.getId() in this.acceptedSessions) {
|
|
1694
|
-
logger
|
|
1713
|
+
logger.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
1695
1714
|
return Promise.resolve(callSession.sipCallId);
|
|
1696
1715
|
}
|
|
1697
1716
|
|
|
@@ -1703,24 +1722,24 @@ class WebRTCPhone extends Emitter {
|
|
|
1703
1722
|
const sipSession = this.client.getSipSession(callSession.getId());
|
|
1704
1723
|
if (sipSession) {
|
|
1705
1724
|
if (sipSession.state === sessionState.SessionState.Terminated || sipSession.state === sessionState.SessionState.Terminating) {
|
|
1706
|
-
logger
|
|
1725
|
+
logger.warn('Trying to answer a terminated sipSession.');
|
|
1707
1726
|
|
|
1708
1727
|
return Promise.resolve(null);
|
|
1709
1728
|
}
|
|
1710
1729
|
|
|
1711
|
-
logger
|
|
1730
|
+
logger.info('accept call, session found', { sipId: sipSession.id });
|
|
1712
1731
|
|
|
1713
1732
|
// $FlowFixMe
|
|
1714
1733
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
1715
1734
|
return callSession.sipCallId;
|
|
1716
1735
|
}).catch(e => {
|
|
1717
|
-
logger
|
|
1736
|
+
logger.error(e);
|
|
1718
1737
|
this.endCurrentCall(callSession);
|
|
1719
1738
|
throw e;
|
|
1720
1739
|
});
|
|
1721
1740
|
}
|
|
1722
1741
|
|
|
1723
|
-
logger
|
|
1742
|
+
logger.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
1724
1743
|
|
|
1725
1744
|
return Promise.resolve(null);
|
|
1726
1745
|
}
|
|
@@ -1730,7 +1749,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1730
1749
|
}
|
|
1731
1750
|
|
|
1732
1751
|
async reject(callSession ) {
|
|
1733
|
-
logger
|
|
1752
|
+
logger.info('reject WebRTC called', { id: callSession.getId() });
|
|
1734
1753
|
|
|
1735
1754
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
|
|
1736
1755
|
if (!callSession || callSession.getId() in this.rejectedSessions) {
|
|
@@ -1742,14 +1761,14 @@ class WebRTCPhone extends Emitter {
|
|
|
1742
1761
|
|
|
1743
1762
|
const sipSession = this.findSipSession(callSession);
|
|
1744
1763
|
if (sipSession) {
|
|
1745
|
-
logger
|
|
1764
|
+
logger.info('WebRTC rejecting', { sipId: sipSession.id });
|
|
1746
1765
|
|
|
1747
1766
|
this.client.hangup(sipSession);
|
|
1748
1767
|
}
|
|
1749
1768
|
}
|
|
1750
1769
|
|
|
1751
1770
|
async ignore(callSession ) {
|
|
1752
|
-
logger
|
|
1771
|
+
logger.info('WebRTC ignore', { id: callSession.getId() });
|
|
1753
1772
|
|
|
1754
1773
|
// kill the ring
|
|
1755
1774
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
|
|
@@ -1761,14 +1780,14 @@ class WebRTCPhone extends Emitter {
|
|
|
1761
1780
|
const sipSession = this.findSipSession(callSession);
|
|
1762
1781
|
|
|
1763
1782
|
if (sipSession) {
|
|
1764
|
-
logger
|
|
1783
|
+
logger.info('WebRTC atxfer', { sipId: sipSession.id });
|
|
1765
1784
|
|
|
1766
1785
|
return this.client.atxfer(sipSession);
|
|
1767
1786
|
}
|
|
1768
1787
|
}
|
|
1769
1788
|
|
|
1770
1789
|
hold(callSession , withEvent = true, isConference = false) {
|
|
1771
|
-
logger
|
|
1790
|
+
logger.info('WebRTC hold', { id: callSession.getId() });
|
|
1772
1791
|
|
|
1773
1792
|
const sipSession = this.findSipSession(callSession);
|
|
1774
1793
|
|
|
@@ -1783,18 +1802,18 @@ class WebRTCPhone extends Emitter {
|
|
|
1783
1802
|
}
|
|
1784
1803
|
|
|
1785
1804
|
resume(callSession , isConference = false, withEvent = true) {
|
|
1786
|
-
logger
|
|
1805
|
+
logger.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
|
|
1787
1806
|
|
|
1788
1807
|
const sipSession = this.findSipSession(callSession);
|
|
1789
1808
|
if (!sipSession) {
|
|
1790
1809
|
return new Promise((resolve, reject) => reject(new Error('No session to resume')));
|
|
1791
1810
|
}
|
|
1792
1811
|
|
|
1793
|
-
logger
|
|
1812
|
+
logger.info('WebRTC resuming', { sipId: sipSession.id });
|
|
1794
1813
|
|
|
1795
1814
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
1796
1815
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
1797
|
-
logger
|
|
1816
|
+
logger.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
1798
1817
|
this.holdSipSession(this.currentSipSession, callSession);
|
|
1799
1818
|
}
|
|
1800
1819
|
|
|
@@ -1819,7 +1838,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1819
1838
|
const sessionId = this.getSipSessionId(sipSession);
|
|
1820
1839
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
1821
1840
|
|
|
1822
|
-
logger
|
|
1841
|
+
logger.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
1823
1842
|
|
|
1824
1843
|
// Stop screenshre if needed
|
|
1825
1844
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
@@ -1850,7 +1869,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1850
1869
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
1851
1870
|
}
|
|
1852
1871
|
const sessionId = this.getSipSessionId(sipSession);
|
|
1853
|
-
logger
|
|
1872
|
+
logger.info('WebRTC unhold sip session', { sessionId, isConference });
|
|
1854
1873
|
|
|
1855
1874
|
const { hasVideo } = this.client.getHeldSession(sessionId) || {};
|
|
1856
1875
|
const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
|
|
@@ -1894,14 +1913,14 @@ class WebRTCPhone extends Emitter {
|
|
|
1894
1913
|
}
|
|
1895
1914
|
|
|
1896
1915
|
mute(callSession , withEvent = true) {
|
|
1897
|
-
logger
|
|
1916
|
+
logger.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
|
|
1898
1917
|
|
|
1899
1918
|
const sipSession = this.findSipSession(callSession);
|
|
1900
1919
|
if (!sipSession) {
|
|
1901
1920
|
return;
|
|
1902
1921
|
}
|
|
1903
1922
|
|
|
1904
|
-
logger
|
|
1923
|
+
logger.info('WebRTC muting', { sipId: sipSession.id });
|
|
1905
1924
|
this.client.mute(sipSession);
|
|
1906
1925
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
|
|
1907
1926
|
|
|
@@ -1915,14 +1934,14 @@ class WebRTCPhone extends Emitter {
|
|
|
1915
1934
|
}
|
|
1916
1935
|
|
|
1917
1936
|
unmute(callSession , withEvent = true) {
|
|
1918
|
-
logger
|
|
1937
|
+
logger.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
|
|
1919
1938
|
|
|
1920
1939
|
const sipSession = this.findSipSession(callSession);
|
|
1921
1940
|
if (!sipSession) {
|
|
1922
1941
|
return;
|
|
1923
1942
|
}
|
|
1924
1943
|
|
|
1925
|
-
logger
|
|
1944
|
+
logger.info('WebRTC unmuting', { sipId: sipSession.id });
|
|
1926
1945
|
this.client.unmute(sipSession);
|
|
1927
1946
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
|
|
1928
1947
|
|
|
@@ -1949,7 +1968,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1949
1968
|
if (!sipSession) {
|
|
1950
1969
|
return;
|
|
1951
1970
|
}
|
|
1952
|
-
logger
|
|
1971
|
+
logger.info('WebRTC turn camera on', { sipId: sipSession.id });
|
|
1953
1972
|
|
|
1954
1973
|
this.client.toggleCameraOn(sipSession);
|
|
1955
1974
|
|
|
@@ -1961,7 +1980,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1961
1980
|
if (!sipSession) {
|
|
1962
1981
|
return;
|
|
1963
1982
|
}
|
|
1964
|
-
logger
|
|
1983
|
+
logger.info('WebRTC turn camera off', { sipId: sipSession.id });
|
|
1965
1984
|
|
|
1966
1985
|
this.client.toggleCameraOff(sipSession);
|
|
1967
1986
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -1973,7 +1992,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1973
1992
|
return;
|
|
1974
1993
|
}
|
|
1975
1994
|
|
|
1976
|
-
logger
|
|
1995
|
+
logger.info('WebRTC send key', { sipId: sipSession.id, tone });
|
|
1977
1996
|
this.client.sendDTMF(sipSession, tone);
|
|
1978
1997
|
}
|
|
1979
1998
|
|
|
@@ -1981,7 +2000,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1981
2000
|
// @TODO: line is not used here
|
|
1982
2001
|
async makeCall(number , line , cameraEnabled ,
|
|
1983
2002
|
audioOnly = false, conference = false) {
|
|
1984
|
-
logger
|
|
2003
|
+
logger.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled, audioOnly, conference });
|
|
1985
2004
|
if (!number) {
|
|
1986
2005
|
return Promise.resolve(null);
|
|
1987
2006
|
}
|
|
@@ -1991,7 +2010,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1991
2010
|
}
|
|
1992
2011
|
if (this.currentSipSession) {
|
|
1993
2012
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
|
|
1994
|
-
logger
|
|
2013
|
+
logger.warn('Unable to hold current session when making another call', e);
|
|
1995
2014
|
});
|
|
1996
2015
|
}
|
|
1997
2016
|
|
|
@@ -2001,10 +2020,11 @@ class WebRTCPhone extends Emitter {
|
|
|
2001
2020
|
this._bindEvents(sipSession);
|
|
2002
2021
|
} catch (error) {
|
|
2003
2022
|
console.warn(error);
|
|
2004
|
-
logger
|
|
2023
|
+
logger.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
|
|
2005
2024
|
return Promise.resolve(null);
|
|
2006
2025
|
}
|
|
2007
2026
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
2027
|
+
callSession.creationTime = new Date();
|
|
2008
2028
|
|
|
2009
2029
|
this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
|
|
2010
2030
|
|
|
@@ -2029,7 +2049,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2029
2049
|
return;
|
|
2030
2050
|
}
|
|
2031
2051
|
|
|
2032
|
-
logger
|
|
2052
|
+
logger.info('WebRTC transfer', { sipId: sipSession.id, target });
|
|
2033
2053
|
|
|
2034
2054
|
this.client.transfer(sipSession, target);
|
|
2035
2055
|
}
|
|
@@ -2038,7 +2058,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2038
2058
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
2039
2059
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
2040
2060
|
|
|
2041
|
-
logger
|
|
2061
|
+
logger.info('WebRTC indirect transfer', {
|
|
2042
2062
|
sipId: sipSession ? sipSession.id : null,
|
|
2043
2063
|
target: sipSessionTarget ? sipSessionTarget.id : null,
|
|
2044
2064
|
});
|
|
@@ -2077,7 +2097,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2077
2097
|
return false;
|
|
2078
2098
|
}
|
|
2079
2099
|
|
|
2080
|
-
logger
|
|
2100
|
+
logger.info('WebRTC hangup', { sipId: sipSession.id });
|
|
2081
2101
|
|
|
2082
2102
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
2083
2103
|
|
|
@@ -2123,7 +2143,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2123
2143
|
endCurrentCall(callSession ) {
|
|
2124
2144
|
const isCurrent = this.isCurrentCallSipSession(callSession);
|
|
2125
2145
|
|
|
2126
|
-
logger
|
|
2146
|
+
logger.info('Ending current call', {
|
|
2127
2147
|
id: callSession ? callSession.getId() : null,
|
|
2128
2148
|
isCurrent,
|
|
2129
2149
|
});
|
|
@@ -2147,7 +2167,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2147
2167
|
}
|
|
2148
2168
|
|
|
2149
2169
|
async close() {
|
|
2150
|
-
logger
|
|
2170
|
+
logger.info('WebRTC close');
|
|
2151
2171
|
|
|
2152
2172
|
try {
|
|
2153
2173
|
await Promise.race([
|
|
@@ -2155,7 +2175,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2155
2175
|
new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
|
|
2156
2176
|
]);
|
|
2157
2177
|
} catch (e) {
|
|
2158
|
-
logger
|
|
2178
|
+
logger.error('WebRTC close, unregister error', e);
|
|
2159
2179
|
}
|
|
2160
2180
|
|
|
2161
2181
|
this.client.close();
|
|
@@ -2173,12 +2193,12 @@ class WebRTCPhone extends Emitter {
|
|
|
2173
2193
|
}
|
|
2174
2194
|
|
|
2175
2195
|
enableRinging() {
|
|
2176
|
-
logger
|
|
2196
|
+
logger.info('WebRTC enable ringing');
|
|
2177
2197
|
this.ringingEnabled = true;
|
|
2178
2198
|
}
|
|
2179
2199
|
|
|
2180
2200
|
disableRinging() {
|
|
2181
|
-
logger
|
|
2201
|
+
logger.info('WebRTC disable ringing');
|
|
2182
2202
|
this.ringingEnabled = false;
|
|
2183
2203
|
}
|
|
2184
2204
|
|
|
@@ -2200,8 +2220,12 @@ class WebRTCPhone extends Emitter {
|
|
|
2200
2220
|
}
|
|
2201
2221
|
|
|
2202
2222
|
const sessionId = this.incomingSessions[0];
|
|
2223
|
+
const sipSession = this.client.getSipSession(sessionId);
|
|
2224
|
+
if (!sipSession) {
|
|
2225
|
+
return null;
|
|
2226
|
+
}
|
|
2203
2227
|
|
|
2204
|
-
return this._createCallSession(
|
|
2228
|
+
return this._createCallSession(sipSession);
|
|
2205
2229
|
}
|
|
2206
2230
|
|
|
2207
2231
|
sendMessage(sipSession = null, body , contentType = 'text/plain') {
|
|
@@ -2218,7 +2242,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2218
2242
|
|
|
2219
2243
|
// Deprecated
|
|
2220
2244
|
getLocalMediaStream(callSession ) {
|
|
2221
|
-
logger
|
|
2245
|
+
logger.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
2222
2246
|
return this.getLocalStream(callSession);
|
|
2223
2247
|
}
|
|
2224
2248
|
|
|
@@ -2260,7 +2284,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2260
2284
|
this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
|
|
2261
2285
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
2262
2286
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
2263
|
-
logger
|
|
2287
|
+
logger.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
|
|
2264
2288
|
|
|
2265
2289
|
const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
|
|
2266
2290
|
this.incomingSessions.push(callSession.getId());
|
|
@@ -2279,11 +2303,12 @@ class WebRTCPhone extends Emitter {
|
|
|
2279
2303
|
callSession);
|
|
2280
2304
|
}
|
|
2281
2305
|
|
|
2306
|
+
callSession.creationTime = new Date();
|
|
2282
2307
|
this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
|
|
2283
2308
|
});
|
|
2284
2309
|
|
|
2285
2310
|
this.client.on(this.client.ON_REINVITE, (...args) => {
|
|
2286
|
-
logger
|
|
2311
|
+
logger.info('WebRTC on reinvite', {
|
|
2287
2312
|
sessionId: args[0].id,
|
|
2288
2313
|
inviteId: args[1].id,
|
|
2289
2314
|
updatedCalleeName: args[2],
|
|
@@ -2303,7 +2328,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2303
2328
|
});
|
|
2304
2329
|
|
|
2305
2330
|
this.client.on(this.client.ACCEPTED, (sipSession ) => {
|
|
2306
|
-
logger
|
|
2331
|
+
logger.info('WebRTC call accepted', { sipId: sipSession.id });
|
|
2307
2332
|
|
|
2308
2333
|
this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
|
|
2309
2334
|
|
|
@@ -2314,22 +2339,29 @@ class WebRTCPhone extends Emitter {
|
|
|
2314
2339
|
this.client.on('ended', () => {});
|
|
2315
2340
|
|
|
2316
2341
|
this.client.on(this.client.ON_ERROR, e => {
|
|
2317
|
-
logger
|
|
2342
|
+
logger.error('WebRTC error', e);
|
|
2318
2343
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
2319
2344
|
});
|
|
2320
2345
|
|
|
2346
|
+
this.client.on(this.client.REJECTED, session => {
|
|
2347
|
+
logger.info('WebRTC call rejected', session.id);
|
|
2348
|
+
const callSession = this._createCallSession(session);
|
|
2349
|
+
callSession.endTime = new Date();
|
|
2350
|
+
this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
|
|
2351
|
+
});
|
|
2352
|
+
|
|
2321
2353
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
2322
|
-
logger
|
|
2354
|
+
logger.info('WebRTC unregistered');
|
|
2323
2355
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
2324
2356
|
});
|
|
2325
2357
|
|
|
2326
2358
|
this.client.on(this.client.ON_DISCONNECTED, () => {
|
|
2327
|
-
logger
|
|
2359
|
+
logger.info('WebRTC disconnected');
|
|
2328
2360
|
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
2329
2361
|
});
|
|
2330
2362
|
|
|
2331
2363
|
this.client.on(this.client.REGISTERED, () => {
|
|
2332
|
-
logger
|
|
2364
|
+
logger.info('WebRTC registered', {
|
|
2333
2365
|
shouldSendReinvite: this.shouldSendReinvite,
|
|
2334
2366
|
state: this.currentSipSession ? this.currentSipSession.state : null,
|
|
2335
2367
|
currentSipSession: !!this.currentSipSession,
|
|
@@ -2350,19 +2382,19 @@ class WebRTCPhone extends Emitter {
|
|
|
2350
2382
|
// Send reinvite with iceRestart
|
|
2351
2383
|
this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
|
|
2352
2384
|
} catch (e) {
|
|
2353
|
-
logger
|
|
2385
|
+
logger.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
2354
2386
|
}
|
|
2355
2387
|
}
|
|
2356
2388
|
});
|
|
2357
2389
|
|
|
2358
2390
|
this.client.on(this.client.CONNECTED, () => {
|
|
2359
|
-
logger
|
|
2391
|
+
logger.info('WebRTC client connected');
|
|
2360
2392
|
|
|
2361
2393
|
this.stopHeartbeat();
|
|
2362
2394
|
});
|
|
2363
2395
|
|
|
2364
2396
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
2365
|
-
logger
|
|
2397
|
+
logger.info('WebRTC client disconnected');
|
|
2366
2398
|
|
|
2367
2399
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
2368
2400
|
|
|
@@ -2400,7 +2432,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2400
2432
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
2401
2433
|
const callSession = this.callSessions[sipSessionId];
|
|
2402
2434
|
|
|
2403
|
-
logger
|
|
2435
|
+
logger.info('Updrading directly in screensharing mode', {
|
|
2404
2436
|
sipSessionId,
|
|
2405
2437
|
tracks: localStream ? localStream.getTracks() : null,
|
|
2406
2438
|
});
|
|
@@ -2530,6 +2562,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2530
2562
|
const number = identity ? identity.uri._normal.user : null;
|
|
2531
2563
|
const { state } = sipSession || {};
|
|
2532
2564
|
const sessionId = this.getSipSessionId(sipSession);
|
|
2565
|
+
fromSession = fromSession || this.callSessions[sessionId];
|
|
2533
2566
|
|
|
2534
2567
|
const callSession = new CallSession({
|
|
2535
2568
|
callId: fromSession && fromSession.callId,
|
|
@@ -2537,6 +2570,8 @@ class WebRTCPhone extends Emitter {
|
|
|
2537
2570
|
sipStatus: state,
|
|
2538
2571
|
displayName: identity ? identity.displayName || number : number,
|
|
2539
2572
|
startTime: fromSession ? fromSession.startTime : new Date(),
|
|
2573
|
+
creationTime: fromSession ? fromSession.creationTime : null,
|
|
2574
|
+
endTime: fromSession ? fromSession.endTime : null,
|
|
2540
2575
|
answered: state === sessionState.SessionState.Established,
|
|
2541
2576
|
paused: this.client.isCallHeld(sipSession),
|
|
2542
2577
|
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
@@ -2547,6 +2582,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2547
2582
|
videoMuted: fromSession ? fromSession.isVideoMuted() : false,
|
|
2548
2583
|
recording: fromSession ? fromSession.isRecording() : false,
|
|
2549
2584
|
recordingPaused: false, // @TODO
|
|
2585
|
+
sipSession,
|
|
2550
2586
|
...extra,
|
|
2551
2587
|
});
|
|
2552
2588
|
|
|
@@ -2570,6 +2606,7 @@ exports.ON_CALL_HELD = ON_CALL_HELD;
|
|
|
2570
2606
|
exports.ON_CALL_INCOMING = ON_CALL_INCOMING;
|
|
2571
2607
|
exports.ON_CALL_MUTED = ON_CALL_MUTED;
|
|
2572
2608
|
exports.ON_CALL_OUTGOING = ON_CALL_OUTGOING;
|
|
2609
|
+
exports.ON_CALL_REJECTED = ON_CALL_REJECTED;
|
|
2573
2610
|
exports.ON_CALL_RESUMED = ON_CALL_RESUMED;
|
|
2574
2611
|
exports.ON_CALL_UNHELD = ON_CALL_UNHELD;
|
|
2575
2612
|
exports.ON_CALL_UNMUTED = ON_CALL_UNMUTED;
|