@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
|
@@ -59,8 +59,10 @@ var updateFrom = (instance , from ) => {
|
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
|
|
62
|
+
|
|
62
63
|
|
|
63
64
|
|
|
65
|
+
|
|
64
66
|
|
|
65
67
|
|
|
66
68
|
|
|
@@ -77,6 +79,7 @@ var updateFrom = (instance , from ) => {
|
|
|
77
79
|
|
|
78
80
|
|
|
79
81
|
|
|
82
|
+
|
|
80
83
|
|
|
81
84
|
|
|
82
85
|
class CallSession {
|
|
@@ -96,8 +99,12 @@ class CallSession {
|
|
|
96
99
|
|
|
97
100
|
|
|
98
101
|
|
|
102
|
+
|
|
103
|
+
|
|
99
104
|
|
|
100
105
|
|
|
106
|
+
|
|
107
|
+
|
|
101
108
|
|
|
102
109
|
|
|
103
110
|
|
|
@@ -135,6 +142,8 @@ class CallSession {
|
|
|
135
142
|
|
|
136
143
|
|
|
137
144
|
|
|
145
|
+
|
|
146
|
+
|
|
138
147
|
|
|
139
148
|
constructor({
|
|
140
149
|
answered,
|
|
@@ -148,6 +157,8 @@ class CallSession {
|
|
|
148
157
|
paused,
|
|
149
158
|
ringing,
|
|
150
159
|
startTime,
|
|
160
|
+
creationTime,
|
|
161
|
+
endTime,
|
|
151
162
|
cameraEnabled,
|
|
152
163
|
dialedExtension,
|
|
153
164
|
sipCallId,
|
|
@@ -160,12 +171,15 @@ class CallSession {
|
|
|
160
171
|
recording,
|
|
161
172
|
recordingPaused,
|
|
162
173
|
videoRemotelyDowngraded,
|
|
174
|
+
sipSession,
|
|
163
175
|
} ) {
|
|
164
176
|
this.callId = callId;
|
|
165
177
|
this.sipCallId = sipCallId;
|
|
166
178
|
this.displayName = displayName;
|
|
167
179
|
this.number = number;
|
|
180
|
+
this.creationTime = creationTime;
|
|
168
181
|
this.startTime = startTime;
|
|
182
|
+
this.endTime = endTime;
|
|
169
183
|
this.isCaller = isCaller;
|
|
170
184
|
this.answered = answered;
|
|
171
185
|
this.answeredBySystem = answeredBySystem;
|
|
@@ -184,6 +198,7 @@ class CallSession {
|
|
|
184
198
|
this.recording = recording || false;
|
|
185
199
|
this.recordingPaused = recordingPaused || false;
|
|
186
200
|
this.videoRemotelyDowngraded = videoRemotelyDowngraded;
|
|
201
|
+
this.sipSession = sipSession;
|
|
187
202
|
|
|
188
203
|
// Useful to compare instead of instanceof with minified code
|
|
189
204
|
this.type = 'CallSession';
|
|
@@ -401,11 +416,11 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
|
|
|
401
416
|
|
|
402
417
|
/* */
|
|
403
418
|
|
|
404
|
-
|
|
419
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
405
420
|
|
|
406
421
|
// Use a function here to be able to mock it in tests
|
|
407
422
|
const realFetch = () => {
|
|
408
|
-
if (typeof document !== 'undefined') {
|
|
423
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
409
424
|
// Browser
|
|
410
425
|
return window.fetch;
|
|
411
426
|
}
|
|
@@ -786,7 +801,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
786
801
|
|
|
787
802
|
/* global RTCSessionDescriptionInit, navigator */
|
|
788
803
|
|
|
789
|
-
|
|
804
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
|
|
790
805
|
|
|
791
806
|
//
|
|
792
807
|
|
|
@@ -828,7 +843,7 @@ BwIDAQAB
|
|
|
828
843
|
|
|
829
844
|
//
|
|
830
845
|
|
|
831
|
-
|
|
846
|
+
KEYUTIL.getKey(swarmPublicKey);
|
|
832
847
|
|
|
833
848
|
/* eslint-disable dot-notation */
|
|
834
849
|
|
|
@@ -849,15 +864,15 @@ global.wazoFetchOptions = global.wazoFetchOptions || {};
|
|
|
849
864
|
|
|
850
865
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
851
866
|
|
|
852
|
-
|
|
867
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
853
868
|
|
|
854
869
|
/* */
|
|
855
870
|
|
|
856
|
-
|
|
871
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
857
872
|
|
|
858
873
|
//
|
|
859
|
-
|
|
860
|
-
|
|
874
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
|
|
875
|
+
IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
|
|
861
876
|
|
|
862
877
|
/* eslint-disable no-param-reassign */
|
|
863
878
|
|
|
@@ -878,6 +893,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
|
|
|
878
893
|
const ON_CAMERA_RESUMED = 'onCameraResumed';
|
|
879
894
|
const ON_CALL_CANCELED = 'onCallCanceled';
|
|
880
895
|
const ON_CALL_FAILED = 'onCallFailed';
|
|
896
|
+
const ON_CALL_REJECTED = 'onCallRejected';
|
|
881
897
|
const ON_CALL_ENDED = 'onCallEnded';
|
|
882
898
|
const ON_CALL_ENDING = 'onCallEnding';
|
|
883
899
|
const ON_MESSAGE = 'onMessage';
|
|
@@ -922,6 +938,7 @@ const events = [
|
|
|
922
938
|
ON_CAMERA_DISABLED,
|
|
923
939
|
ON_CALL_FAILED,
|
|
924
940
|
ON_CALL_ENDED,
|
|
941
|
+
ON_CALL_REJECTED,
|
|
925
942
|
ON_MESSAGE,
|
|
926
943
|
ON_REINVITE,
|
|
927
944
|
ON_TRACK,
|
|
@@ -943,7 +960,7 @@ const events = [
|
|
|
943
960
|
ON_DISCONNECTED,
|
|
944
961
|
];
|
|
945
962
|
|
|
946
|
-
const logger
|
|
963
|
+
const logger = IssueReporter$1.loggerFor('webrtc-phone');
|
|
947
964
|
|
|
948
965
|
class WebRTCPhone extends Emitter {
|
|
949
966
|
|
|
@@ -1016,7 +1033,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1016
1033
|
}).catch(error => {
|
|
1017
1034
|
// Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
|
|
1018
1035
|
console.error('register error', error, error.message, error.stack);
|
|
1019
|
-
logger
|
|
1036
|
+
logger.error('WebRTC register error', { message: error.message, stack: error.stack });
|
|
1020
1037
|
});
|
|
1021
1038
|
}
|
|
1022
1039
|
|
|
@@ -1031,7 +1048,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1031
1048
|
if (!this.client) {
|
|
1032
1049
|
return;
|
|
1033
1050
|
}
|
|
1034
|
-
logger
|
|
1051
|
+
logger.info('WebRTC phone stop');
|
|
1035
1052
|
this.client.stop();
|
|
1036
1053
|
}
|
|
1037
1054
|
|
|
@@ -1046,11 +1063,12 @@ class WebRTCPhone extends Emitter {
|
|
|
1046
1063
|
async sendReinvite(callSession , constraints = null, conference = false,
|
|
1047
1064
|
audioOnly = false, iceRestart = false) {
|
|
1048
1065
|
const sipSession = this.findSipSession(callSession);
|
|
1049
|
-
logger
|
|
1066
|
+
logger.info('WebRTC phone - send reinvite', {
|
|
1050
1067
|
sessionId: sipSession ? sipSession.id : null,
|
|
1051
1068
|
constraints,
|
|
1052
1069
|
audioOnly,
|
|
1053
1070
|
conference,
|
|
1071
|
+
iceRestart,
|
|
1054
1072
|
});
|
|
1055
1073
|
|
|
1056
1074
|
if (!sipSession) {
|
|
@@ -1083,7 +1101,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1083
1101
|
}
|
|
1084
1102
|
|
|
1085
1103
|
startHeartbeat() {
|
|
1086
|
-
logger
|
|
1104
|
+
logger.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
|
|
1087
1105
|
if (!this.client || this.client.hasHeartbeat()) {
|
|
1088
1106
|
return;
|
|
1089
1107
|
}
|
|
@@ -1092,7 +1110,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1092
1110
|
}
|
|
1093
1111
|
|
|
1094
1112
|
stopHeartbeat() {
|
|
1095
|
-
logger
|
|
1113
|
+
logger.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
|
|
1096
1114
|
if (!this.client) {
|
|
1097
1115
|
return;
|
|
1098
1116
|
}
|
|
@@ -1109,7 +1127,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1109
1127
|
}
|
|
1110
1128
|
|
|
1111
1129
|
reconnect() {
|
|
1112
|
-
logger
|
|
1130
|
+
logger.info('WebRTC phone - reconnect', { client: !!this.client });
|
|
1113
1131
|
if (!this.client) {
|
|
1114
1132
|
return;
|
|
1115
1133
|
}
|
|
@@ -1150,7 +1168,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1150
1168
|
return false;
|
|
1151
1169
|
}
|
|
1152
1170
|
|
|
1153
|
-
logger
|
|
1171
|
+
logger.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
|
|
1154
1172
|
|
|
1155
1173
|
this.client.downgradeToAudio(sipSession);
|
|
1156
1174
|
|
|
@@ -1173,7 +1191,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1173
1191
|
return Promise.resolve(false);
|
|
1174
1192
|
}
|
|
1175
1193
|
|
|
1176
|
-
logger
|
|
1194
|
+
logger.info('Upgrade to video', {
|
|
1177
1195
|
id: callSession ? callSession.getId() : null,
|
|
1178
1196
|
constraints,
|
|
1179
1197
|
isConference,
|
|
@@ -1213,7 +1231,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1213
1231
|
|
|
1214
1232
|
_sendReinviteMessage(callSession , isUpgrade ) {
|
|
1215
1233
|
const sipSession = this.findSipSession(callSession);
|
|
1216
|
-
logger
|
|
1234
|
+
logger.info('Sending reinvite message', {
|
|
1217
1235
|
id: callSession ? callSession.getId() : null,
|
|
1218
1236
|
isUpgrade,
|
|
1219
1237
|
});
|
|
@@ -1239,7 +1257,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1239
1257
|
// Monkey patch to know when canceled with the CANCEL message
|
|
1240
1258
|
const onCancel = sipSession._onCancel.bind(sipSession);
|
|
1241
1259
|
sipSession._onCancel = (message ) => {
|
|
1242
|
-
logger
|
|
1260
|
+
logger.trace('on sip session canceled', { callId: message.callId });
|
|
1243
1261
|
|
|
1244
1262
|
onCancel(message);
|
|
1245
1263
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
@@ -1267,16 +1285,17 @@ class WebRTCPhone extends Emitter {
|
|
|
1267
1285
|
this.audioOutputVolume,
|
|
1268
1286
|
);
|
|
1269
1287
|
case SessionState.Terminating:
|
|
1270
|
-
logger
|
|
1288
|
+
logger.info('WebRTC phone - call terminating', { sipId: sipSession.id });
|
|
1271
1289
|
|
|
1272
1290
|
this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
1273
1291
|
|
|
1274
1292
|
break;
|
|
1275
1293
|
case SessionState.Terminated: {
|
|
1276
|
-
logger
|
|
1294
|
+
logger.info('WebRTC phone - call terminated', { sipId: sipSession.id });
|
|
1277
1295
|
|
|
1278
1296
|
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
1279
1297
|
const callSession = this._createCallSession(sipSession);
|
|
1298
|
+
callSession.endTime = new Date();
|
|
1280
1299
|
const wasCurrentSession = this._onCallTerminated(sipSession);
|
|
1281
1300
|
|
|
1282
1301
|
return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
|
|
@@ -1295,7 +1314,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1295
1314
|
const [stream] = event.streams;
|
|
1296
1315
|
const kind = event && event.track && event.track.kind;
|
|
1297
1316
|
|
|
1298
|
-
logger
|
|
1317
|
+
logger.info('on track stream called on the peer connection', {
|
|
1299
1318
|
callId: this.getSipSessionId(sipSession),
|
|
1300
1319
|
streamId: stream ? stream.id : null,
|
|
1301
1320
|
tracks: stream ? stream.getTracks() : null,
|
|
@@ -1315,7 +1334,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1315
1334
|
};
|
|
1316
1335
|
|
|
1317
1336
|
peerConnection.onremovestream = event => {
|
|
1318
|
-
logger
|
|
1337
|
+
logger.info('on remove stream called on the peer connection', {
|
|
1319
1338
|
id: event.stream.id,
|
|
1320
1339
|
tracks: event.stream.getTracks(),
|
|
1321
1340
|
});
|
|
@@ -1325,7 +1344,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1325
1344
|
}
|
|
1326
1345
|
|
|
1327
1346
|
async startScreenSharing(constraints , callSession ) {
|
|
1328
|
-
logger
|
|
1347
|
+
logger.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
|
|
1329
1348
|
|
|
1330
1349
|
const screenShareStream = await this.client.getStreamFromConstraints(constraints);
|
|
1331
1350
|
if (!screenShareStream) {
|
|
@@ -1365,7 +1384,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1365
1384
|
return;
|
|
1366
1385
|
}
|
|
1367
1386
|
|
|
1368
|
-
logger
|
|
1387
|
+
logger.info('WebRTC phone - stop screen sharing', {
|
|
1369
1388
|
restoreLocalStream,
|
|
1370
1389
|
});
|
|
1371
1390
|
|
|
@@ -1421,7 +1440,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1421
1440
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
1422
1441
|
const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
|
|
1423
1442
|
|
|
1424
|
-
logger
|
|
1443
|
+
logger.info('WebRTC phone - on screensharing', {
|
|
1425
1444
|
hadVideo,
|
|
1426
1445
|
id: this.getSipSessionId(sipSession),
|
|
1427
1446
|
screenTrack,
|
|
@@ -1429,7 +1448,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1429
1448
|
|
|
1430
1449
|
if (screenTrack) {
|
|
1431
1450
|
screenTrack.onended = () => {
|
|
1432
|
-
logger
|
|
1451
|
+
logger.info('WebRTC phone - on screenshare ended', {
|
|
1433
1452
|
hadVideo,
|
|
1434
1453
|
id: this.getSipSessionId(sipSession),
|
|
1435
1454
|
screenTrack,
|
|
@@ -1460,7 +1479,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1460
1479
|
}
|
|
1461
1480
|
|
|
1462
1481
|
_onCallAccepted(sipSession , cameraEnabled ) {
|
|
1463
|
-
logger
|
|
1482
|
+
logger.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
|
|
1464
1483
|
|
|
1465
1484
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
1466
1485
|
this.currentSipSession = sipSession;
|
|
@@ -1478,7 +1497,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1478
1497
|
}
|
|
1479
1498
|
|
|
1480
1499
|
changeAudioDevice(id ) {
|
|
1481
|
-
logger
|
|
1500
|
+
logger.info('WebRTC phone - change audio device', { deviceId: id });
|
|
1482
1501
|
this.audioOutputDeviceId = id;
|
|
1483
1502
|
this.client.changeAudioOutputDevice(id);
|
|
1484
1503
|
}
|
|
@@ -1488,14 +1507,14 @@ class WebRTCPhone extends Emitter {
|
|
|
1488
1507
|
}
|
|
1489
1508
|
|
|
1490
1509
|
changeRingDevice(id ) {
|
|
1491
|
-
logger
|
|
1510
|
+
logger.info('WebRTC phone - changing ring device', { id });
|
|
1492
1511
|
|
|
1493
1512
|
this.audioRingDeviceId = id;
|
|
1494
1513
|
}
|
|
1495
1514
|
|
|
1496
1515
|
// volume is a value between 0 and 1
|
|
1497
1516
|
changeAudioVolume(volume ) {
|
|
1498
|
-
logger
|
|
1517
|
+
logger.info('WebRTC phone - changing audio volume', { volume });
|
|
1499
1518
|
|
|
1500
1519
|
this.audioOutputVolume = volume;
|
|
1501
1520
|
this.client.changeAudioOutputVolume(volume);
|
|
@@ -1503,32 +1522,33 @@ class WebRTCPhone extends Emitter {
|
|
|
1503
1522
|
|
|
1504
1523
|
// volume is a value between 0 and 1
|
|
1505
1524
|
changeRingVolume(volume ) {
|
|
1506
|
-
logger
|
|
1525
|
+
logger.info('WebRTC phone - changing ring volume', { volume });
|
|
1507
1526
|
|
|
1508
1527
|
this.audioRingVolume = volume;
|
|
1509
1528
|
}
|
|
1510
1529
|
|
|
1511
1530
|
changeAudioInputDevice(id ) {
|
|
1512
|
-
logger
|
|
1531
|
+
logger.info('WebRTC phone - changeAudio input device', { deviceId: id });
|
|
1513
1532
|
|
|
1514
1533
|
return this.client.changeAudioInputDevice(id, this.currentSipSession);
|
|
1515
1534
|
}
|
|
1516
1535
|
|
|
1517
1536
|
changeVideoInputDevice(id ) {
|
|
1518
|
-
logger
|
|
1537
|
+
logger.info('WebRTC phone - change video input device', { deviceId: id });
|
|
1519
1538
|
|
|
1520
1539
|
return this.client.changeVideoInputDevice(id, this.currentSipSession);
|
|
1521
1540
|
}
|
|
1522
1541
|
|
|
1523
1542
|
changeSessionVideoInputDevice(id ) {
|
|
1524
|
-
logger
|
|
1543
|
+
logger.info('WebRTC phone - change session video input device', { deviceId: id });
|
|
1525
1544
|
|
|
1526
1545
|
return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
1527
1546
|
}
|
|
1528
1547
|
|
|
1529
1548
|
_onCallTerminated(sipSession ) {
|
|
1530
|
-
logger
|
|
1549
|
+
logger.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
1531
1550
|
|
|
1551
|
+
const sipSessionId = this.getSipSessionId(sipSession);
|
|
1532
1552
|
const callSession = this._createCallSession(sipSession);
|
|
1533
1553
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
1534
1554
|
const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
|
|
@@ -1546,7 +1566,6 @@ class WebRTCPhone extends Emitter {
|
|
|
1546
1566
|
}, 5);
|
|
1547
1567
|
}
|
|
1548
1568
|
|
|
1549
|
-
const sipSessionId = this.getSipSessionId(sipSession);
|
|
1550
1569
|
if (sipSessionId) {
|
|
1551
1570
|
this.removeIncomingSessions(sipSessionId);
|
|
1552
1571
|
}
|
|
@@ -1561,7 +1580,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1561
1580
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
1562
1581
|
|
|
1563
1582
|
// Re-trigger incoming call event for remaining incoming calls
|
|
1564
|
-
logger
|
|
1583
|
+
logger.info('WebRTC phone - check to re-trigger incoming call', {
|
|
1565
1584
|
sipId: sipSession.id,
|
|
1566
1585
|
shouldRetrigger,
|
|
1567
1586
|
hasIncomingCallSession,
|
|
@@ -1652,37 +1671,37 @@ class WebRTCPhone extends Emitter {
|
|
|
1652
1671
|
|
|
1653
1672
|
// Deprecated
|
|
1654
1673
|
getLocalStreamForCall(callSession ) {
|
|
1655
|
-
logger
|
|
1674
|
+
logger.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
1656
1675
|
|
|
1657
1676
|
return this.getLocalStream(callSession);
|
|
1658
1677
|
}
|
|
1659
1678
|
|
|
1660
1679
|
// Deprecated
|
|
1661
1680
|
getRemoteStreamForCall(callSession ) {
|
|
1662
|
-
logger
|
|
1681
|
+
logger.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
|
|
1663
1682
|
|
|
1664
1683
|
return this.getRemoteVideoStream(callSession);
|
|
1665
1684
|
}
|
|
1666
1685
|
|
|
1667
1686
|
getRemoteStreamsForCall(callSession ) {
|
|
1668
|
-
logger
|
|
1687
|
+
logger.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
|
|
1669
1688
|
|
|
1670
1689
|
return this.getRemoteStream(callSession);
|
|
1671
1690
|
}
|
|
1672
1691
|
|
|
1673
1692
|
accept(callSession , cameraEnabled ) {
|
|
1674
|
-
logger
|
|
1693
|
+
logger.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
|
|
1675
1694
|
if (this.currentSipSession) {
|
|
1676
1695
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
|
|
1677
1696
|
}
|
|
1678
1697
|
|
|
1679
1698
|
if (!callSession) {
|
|
1680
|
-
logger
|
|
1699
|
+
logger.warn('no CallSession to accept.');
|
|
1681
1700
|
return Promise.resolve(null);
|
|
1682
1701
|
}
|
|
1683
1702
|
|
|
1684
1703
|
if (callSession.getId() in this.acceptedSessions) {
|
|
1685
|
-
logger
|
|
1704
|
+
logger.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
1686
1705
|
return Promise.resolve(callSession.sipCallId);
|
|
1687
1706
|
}
|
|
1688
1707
|
|
|
@@ -1694,24 +1713,24 @@ class WebRTCPhone extends Emitter {
|
|
|
1694
1713
|
const sipSession = this.client.getSipSession(callSession.getId());
|
|
1695
1714
|
if (sipSession) {
|
|
1696
1715
|
if (sipSession.state === SessionState.Terminated || sipSession.state === SessionState.Terminating) {
|
|
1697
|
-
logger
|
|
1716
|
+
logger.warn('Trying to answer a terminated sipSession.');
|
|
1698
1717
|
|
|
1699
1718
|
return Promise.resolve(null);
|
|
1700
1719
|
}
|
|
1701
1720
|
|
|
1702
|
-
logger
|
|
1721
|
+
logger.info('accept call, session found', { sipId: sipSession.id });
|
|
1703
1722
|
|
|
1704
1723
|
// $FlowFixMe
|
|
1705
1724
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
1706
1725
|
return callSession.sipCallId;
|
|
1707
1726
|
}).catch(e => {
|
|
1708
|
-
logger
|
|
1727
|
+
logger.error(e);
|
|
1709
1728
|
this.endCurrentCall(callSession);
|
|
1710
1729
|
throw e;
|
|
1711
1730
|
});
|
|
1712
1731
|
}
|
|
1713
1732
|
|
|
1714
|
-
logger
|
|
1733
|
+
logger.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
|
|
1715
1734
|
|
|
1716
1735
|
return Promise.resolve(null);
|
|
1717
1736
|
}
|
|
@@ -1721,7 +1740,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1721
1740
|
}
|
|
1722
1741
|
|
|
1723
1742
|
async reject(callSession ) {
|
|
1724
|
-
logger
|
|
1743
|
+
logger.info('reject WebRTC called', { id: callSession.getId() });
|
|
1725
1744
|
|
|
1726
1745
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
|
|
1727
1746
|
if (!callSession || callSession.getId() in this.rejectedSessions) {
|
|
@@ -1733,14 +1752,14 @@ class WebRTCPhone extends Emitter {
|
|
|
1733
1752
|
|
|
1734
1753
|
const sipSession = this.findSipSession(callSession);
|
|
1735
1754
|
if (sipSession) {
|
|
1736
|
-
logger
|
|
1755
|
+
logger.info('WebRTC rejecting', { sipId: sipSession.id });
|
|
1737
1756
|
|
|
1738
1757
|
this.client.hangup(sipSession);
|
|
1739
1758
|
}
|
|
1740
1759
|
}
|
|
1741
1760
|
|
|
1742
1761
|
async ignore(callSession ) {
|
|
1743
|
-
logger
|
|
1762
|
+
logger.info('WebRTC ignore', { id: callSession.getId() });
|
|
1744
1763
|
|
|
1745
1764
|
// kill the ring
|
|
1746
1765
|
this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
|
|
@@ -1752,14 +1771,14 @@ class WebRTCPhone extends Emitter {
|
|
|
1752
1771
|
const sipSession = this.findSipSession(callSession);
|
|
1753
1772
|
|
|
1754
1773
|
if (sipSession) {
|
|
1755
|
-
logger
|
|
1774
|
+
logger.info('WebRTC atxfer', { sipId: sipSession.id });
|
|
1756
1775
|
|
|
1757
1776
|
return this.client.atxfer(sipSession);
|
|
1758
1777
|
}
|
|
1759
1778
|
}
|
|
1760
1779
|
|
|
1761
1780
|
hold(callSession , withEvent = true, isConference = false) {
|
|
1762
|
-
logger
|
|
1781
|
+
logger.info('WebRTC hold', { id: callSession.getId() });
|
|
1763
1782
|
|
|
1764
1783
|
const sipSession = this.findSipSession(callSession);
|
|
1765
1784
|
|
|
@@ -1774,18 +1793,18 @@ class WebRTCPhone extends Emitter {
|
|
|
1774
1793
|
}
|
|
1775
1794
|
|
|
1776
1795
|
resume(callSession , isConference = false, withEvent = true) {
|
|
1777
|
-
logger
|
|
1796
|
+
logger.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
|
|
1778
1797
|
|
|
1779
1798
|
const sipSession = this.findSipSession(callSession);
|
|
1780
1799
|
if (!sipSession) {
|
|
1781
1800
|
return new Promise((resolve, reject) => reject(new Error('No session to resume')));
|
|
1782
1801
|
}
|
|
1783
1802
|
|
|
1784
|
-
logger
|
|
1803
|
+
logger.info('WebRTC resuming', { sipId: sipSession.id });
|
|
1785
1804
|
|
|
1786
1805
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
1787
1806
|
if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
|
|
1788
|
-
logger
|
|
1807
|
+
logger.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
|
|
1789
1808
|
this.holdSipSession(this.currentSipSession, callSession);
|
|
1790
1809
|
}
|
|
1791
1810
|
|
|
@@ -1810,7 +1829,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1810
1829
|
const sessionId = this.getSipSessionId(sipSession);
|
|
1811
1830
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
1812
1831
|
|
|
1813
|
-
logger
|
|
1832
|
+
logger.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
|
|
1814
1833
|
|
|
1815
1834
|
// Stop screenshre if needed
|
|
1816
1835
|
if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
|
|
@@ -1841,7 +1860,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1841
1860
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
1842
1861
|
}
|
|
1843
1862
|
const sessionId = this.getSipSessionId(sipSession);
|
|
1844
|
-
logger
|
|
1863
|
+
logger.info('WebRTC unhold sip session', { sessionId, isConference });
|
|
1845
1864
|
|
|
1846
1865
|
const { hasVideo } = this.client.getHeldSession(sessionId) || {};
|
|
1847
1866
|
const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
|
|
@@ -1885,14 +1904,14 @@ class WebRTCPhone extends Emitter {
|
|
|
1885
1904
|
}
|
|
1886
1905
|
|
|
1887
1906
|
mute(callSession , withEvent = true) {
|
|
1888
|
-
logger
|
|
1907
|
+
logger.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
|
|
1889
1908
|
|
|
1890
1909
|
const sipSession = this.findSipSession(callSession);
|
|
1891
1910
|
if (!sipSession) {
|
|
1892
1911
|
return;
|
|
1893
1912
|
}
|
|
1894
1913
|
|
|
1895
|
-
logger
|
|
1914
|
+
logger.info('WebRTC muting', { sipId: sipSession.id });
|
|
1896
1915
|
this.client.mute(sipSession);
|
|
1897
1916
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
|
|
1898
1917
|
|
|
@@ -1906,14 +1925,14 @@ class WebRTCPhone extends Emitter {
|
|
|
1906
1925
|
}
|
|
1907
1926
|
|
|
1908
1927
|
unmute(callSession , withEvent = true) {
|
|
1909
|
-
logger
|
|
1928
|
+
logger.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
|
|
1910
1929
|
|
|
1911
1930
|
const sipSession = this.findSipSession(callSession);
|
|
1912
1931
|
if (!sipSession) {
|
|
1913
1932
|
return;
|
|
1914
1933
|
}
|
|
1915
1934
|
|
|
1916
|
-
logger
|
|
1935
|
+
logger.info('WebRTC unmuting', { sipId: sipSession.id });
|
|
1917
1936
|
this.client.unmute(sipSession);
|
|
1918
1937
|
const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
|
|
1919
1938
|
|
|
@@ -1940,7 +1959,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1940
1959
|
if (!sipSession) {
|
|
1941
1960
|
return;
|
|
1942
1961
|
}
|
|
1943
|
-
logger
|
|
1962
|
+
logger.info('WebRTC turn camera on', { sipId: sipSession.id });
|
|
1944
1963
|
|
|
1945
1964
|
this.client.toggleCameraOn(sipSession);
|
|
1946
1965
|
|
|
@@ -1952,7 +1971,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1952
1971
|
if (!sipSession) {
|
|
1953
1972
|
return;
|
|
1954
1973
|
}
|
|
1955
|
-
logger
|
|
1974
|
+
logger.info('WebRTC turn camera off', { sipId: sipSession.id });
|
|
1956
1975
|
|
|
1957
1976
|
this.client.toggleCameraOff(sipSession);
|
|
1958
1977
|
this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -1964,7 +1983,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1964
1983
|
return;
|
|
1965
1984
|
}
|
|
1966
1985
|
|
|
1967
|
-
logger
|
|
1986
|
+
logger.info('WebRTC send key', { sipId: sipSession.id, tone });
|
|
1968
1987
|
this.client.sendDTMF(sipSession, tone);
|
|
1969
1988
|
}
|
|
1970
1989
|
|
|
@@ -1972,7 +1991,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1972
1991
|
// @TODO: line is not used here
|
|
1973
1992
|
async makeCall(number , line , cameraEnabled ,
|
|
1974
1993
|
audioOnly = false, conference = false) {
|
|
1975
|
-
logger
|
|
1994
|
+
logger.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled, audioOnly, conference });
|
|
1976
1995
|
if (!number) {
|
|
1977
1996
|
return Promise.resolve(null);
|
|
1978
1997
|
}
|
|
@@ -1982,7 +2001,7 @@ class WebRTCPhone extends Emitter {
|
|
|
1982
2001
|
}
|
|
1983
2002
|
if (this.currentSipSession) {
|
|
1984
2003
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
|
|
1985
|
-
logger
|
|
2004
|
+
logger.warn('Unable to hold current session when making another call', e);
|
|
1986
2005
|
});
|
|
1987
2006
|
}
|
|
1988
2007
|
|
|
@@ -1992,10 +2011,11 @@ class WebRTCPhone extends Emitter {
|
|
|
1992
2011
|
this._bindEvents(sipSession);
|
|
1993
2012
|
} catch (error) {
|
|
1994
2013
|
console.warn(error);
|
|
1995
|
-
logger
|
|
2014
|
+
logger.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
|
|
1996
2015
|
return Promise.resolve(null);
|
|
1997
2016
|
}
|
|
1998
2017
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
2018
|
+
callSession.creationTime = new Date();
|
|
1999
2019
|
|
|
2000
2020
|
this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
|
|
2001
2021
|
|
|
@@ -2020,7 +2040,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2020
2040
|
return;
|
|
2021
2041
|
}
|
|
2022
2042
|
|
|
2023
|
-
logger
|
|
2043
|
+
logger.info('WebRTC transfer', { sipId: sipSession.id, target });
|
|
2024
2044
|
|
|
2025
2045
|
this.client.transfer(sipSession, target);
|
|
2026
2046
|
}
|
|
@@ -2029,7 +2049,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2029
2049
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
2030
2050
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
2031
2051
|
|
|
2032
|
-
logger
|
|
2052
|
+
logger.info('WebRTC indirect transfer', {
|
|
2033
2053
|
sipId: sipSession ? sipSession.id : null,
|
|
2034
2054
|
target: sipSessionTarget ? sipSessionTarget.id : null,
|
|
2035
2055
|
});
|
|
@@ -2068,7 +2088,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2068
2088
|
return false;
|
|
2069
2089
|
}
|
|
2070
2090
|
|
|
2071
|
-
logger
|
|
2091
|
+
logger.info('WebRTC hangup', { sipId: sipSession.id });
|
|
2072
2092
|
|
|
2073
2093
|
const sipSessionId = this.getSipSessionId(sipSession);
|
|
2074
2094
|
|
|
@@ -2114,7 +2134,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2114
2134
|
endCurrentCall(callSession ) {
|
|
2115
2135
|
const isCurrent = this.isCurrentCallSipSession(callSession);
|
|
2116
2136
|
|
|
2117
|
-
logger
|
|
2137
|
+
logger.info('Ending current call', {
|
|
2118
2138
|
id: callSession ? callSession.getId() : null,
|
|
2119
2139
|
isCurrent,
|
|
2120
2140
|
});
|
|
@@ -2138,7 +2158,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2138
2158
|
}
|
|
2139
2159
|
|
|
2140
2160
|
async close() {
|
|
2141
|
-
logger
|
|
2161
|
+
logger.info('WebRTC close');
|
|
2142
2162
|
|
|
2143
2163
|
try {
|
|
2144
2164
|
await Promise.race([
|
|
@@ -2146,7 +2166,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2146
2166
|
new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
|
|
2147
2167
|
]);
|
|
2148
2168
|
} catch (e) {
|
|
2149
|
-
logger
|
|
2169
|
+
logger.error('WebRTC close, unregister error', e);
|
|
2150
2170
|
}
|
|
2151
2171
|
|
|
2152
2172
|
this.client.close();
|
|
@@ -2164,12 +2184,12 @@ class WebRTCPhone extends Emitter {
|
|
|
2164
2184
|
}
|
|
2165
2185
|
|
|
2166
2186
|
enableRinging() {
|
|
2167
|
-
logger
|
|
2187
|
+
logger.info('WebRTC enable ringing');
|
|
2168
2188
|
this.ringingEnabled = true;
|
|
2169
2189
|
}
|
|
2170
2190
|
|
|
2171
2191
|
disableRinging() {
|
|
2172
|
-
logger
|
|
2192
|
+
logger.info('WebRTC disable ringing');
|
|
2173
2193
|
this.ringingEnabled = false;
|
|
2174
2194
|
}
|
|
2175
2195
|
|
|
@@ -2191,8 +2211,12 @@ class WebRTCPhone extends Emitter {
|
|
|
2191
2211
|
}
|
|
2192
2212
|
|
|
2193
2213
|
const sessionId = this.incomingSessions[0];
|
|
2214
|
+
const sipSession = this.client.getSipSession(sessionId);
|
|
2215
|
+
if (!sipSession) {
|
|
2216
|
+
return null;
|
|
2217
|
+
}
|
|
2194
2218
|
|
|
2195
|
-
return this._createCallSession(
|
|
2219
|
+
return this._createCallSession(sipSession);
|
|
2196
2220
|
}
|
|
2197
2221
|
|
|
2198
2222
|
sendMessage(sipSession = null, body , contentType = 'text/plain') {
|
|
@@ -2209,7 +2233,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2209
2233
|
|
|
2210
2234
|
// Deprecated
|
|
2211
2235
|
getLocalMediaStream(callSession ) {
|
|
2212
|
-
logger
|
|
2236
|
+
logger.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
|
|
2213
2237
|
return this.getLocalStream(callSession);
|
|
2214
2238
|
}
|
|
2215
2239
|
|
|
@@ -2251,7 +2275,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2251
2275
|
this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
|
|
2252
2276
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
2253
2277
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
2254
|
-
logger
|
|
2278
|
+
logger.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
|
|
2255
2279
|
|
|
2256
2280
|
const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
|
|
2257
2281
|
this.incomingSessions.push(callSession.getId());
|
|
@@ -2270,11 +2294,12 @@ class WebRTCPhone extends Emitter {
|
|
|
2270
2294
|
callSession);
|
|
2271
2295
|
}
|
|
2272
2296
|
|
|
2297
|
+
callSession.creationTime = new Date();
|
|
2273
2298
|
this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
|
|
2274
2299
|
});
|
|
2275
2300
|
|
|
2276
2301
|
this.client.on(this.client.ON_REINVITE, (...args) => {
|
|
2277
|
-
logger
|
|
2302
|
+
logger.info('WebRTC on reinvite', {
|
|
2278
2303
|
sessionId: args[0].id,
|
|
2279
2304
|
inviteId: args[1].id,
|
|
2280
2305
|
updatedCalleeName: args[2],
|
|
@@ -2294,7 +2319,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2294
2319
|
});
|
|
2295
2320
|
|
|
2296
2321
|
this.client.on(this.client.ACCEPTED, (sipSession ) => {
|
|
2297
|
-
logger
|
|
2322
|
+
logger.info('WebRTC call accepted', { sipId: sipSession.id });
|
|
2298
2323
|
|
|
2299
2324
|
this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
|
|
2300
2325
|
|
|
@@ -2305,22 +2330,29 @@ class WebRTCPhone extends Emitter {
|
|
|
2305
2330
|
this.client.on('ended', () => {});
|
|
2306
2331
|
|
|
2307
2332
|
this.client.on(this.client.ON_ERROR, e => {
|
|
2308
|
-
logger
|
|
2333
|
+
logger.error('WebRTC error', e);
|
|
2309
2334
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
2310
2335
|
});
|
|
2311
2336
|
|
|
2337
|
+
this.client.on(this.client.REJECTED, session => {
|
|
2338
|
+
logger.info('WebRTC call rejected', session.id);
|
|
2339
|
+
const callSession = this._createCallSession(session);
|
|
2340
|
+
callSession.endTime = new Date();
|
|
2341
|
+
this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
|
|
2342
|
+
});
|
|
2343
|
+
|
|
2312
2344
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
2313
|
-
logger
|
|
2345
|
+
logger.info('WebRTC unregistered');
|
|
2314
2346
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
2315
2347
|
});
|
|
2316
2348
|
|
|
2317
2349
|
this.client.on(this.client.ON_DISCONNECTED, () => {
|
|
2318
|
-
logger
|
|
2350
|
+
logger.info('WebRTC disconnected');
|
|
2319
2351
|
this.eventEmitter.emit(ON_DISCONNECTED);
|
|
2320
2352
|
});
|
|
2321
2353
|
|
|
2322
2354
|
this.client.on(this.client.REGISTERED, () => {
|
|
2323
|
-
logger
|
|
2355
|
+
logger.info('WebRTC registered', {
|
|
2324
2356
|
shouldSendReinvite: this.shouldSendReinvite,
|
|
2325
2357
|
state: this.currentSipSession ? this.currentSipSession.state : null,
|
|
2326
2358
|
currentSipSession: !!this.currentSipSession,
|
|
@@ -2341,19 +2373,19 @@ class WebRTCPhone extends Emitter {
|
|
|
2341
2373
|
// Send reinvite with iceRestart
|
|
2342
2374
|
this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
|
|
2343
2375
|
} catch (e) {
|
|
2344
|
-
logger
|
|
2376
|
+
logger.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
|
|
2345
2377
|
}
|
|
2346
2378
|
}
|
|
2347
2379
|
});
|
|
2348
2380
|
|
|
2349
2381
|
this.client.on(this.client.CONNECTED, () => {
|
|
2350
|
-
logger
|
|
2382
|
+
logger.info('WebRTC client connected');
|
|
2351
2383
|
|
|
2352
2384
|
this.stopHeartbeat();
|
|
2353
2385
|
});
|
|
2354
2386
|
|
|
2355
2387
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
2356
|
-
logger
|
|
2388
|
+
logger.info('WebRTC client disconnected');
|
|
2357
2389
|
|
|
2358
2390
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
2359
2391
|
|
|
@@ -2391,7 +2423,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2391
2423
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
2392
2424
|
const callSession = this.callSessions[sipSessionId];
|
|
2393
2425
|
|
|
2394
|
-
logger
|
|
2426
|
+
logger.info('Updrading directly in screensharing mode', {
|
|
2395
2427
|
sipSessionId,
|
|
2396
2428
|
tracks: localStream ? localStream.getTracks() : null,
|
|
2397
2429
|
});
|
|
@@ -2521,6 +2553,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2521
2553
|
const number = identity ? identity.uri._normal.user : null;
|
|
2522
2554
|
const { state } = sipSession || {};
|
|
2523
2555
|
const sessionId = this.getSipSessionId(sipSession);
|
|
2556
|
+
fromSession = fromSession || this.callSessions[sessionId];
|
|
2524
2557
|
|
|
2525
2558
|
const callSession = new CallSession({
|
|
2526
2559
|
callId: fromSession && fromSession.callId,
|
|
@@ -2528,6 +2561,8 @@ class WebRTCPhone extends Emitter {
|
|
|
2528
2561
|
sipStatus: state,
|
|
2529
2562
|
displayName: identity ? identity.displayName || number : number,
|
|
2530
2563
|
startTime: fromSession ? fromSession.startTime : new Date(),
|
|
2564
|
+
creationTime: fromSession ? fromSession.creationTime : null,
|
|
2565
|
+
endTime: fromSession ? fromSession.endTime : null,
|
|
2531
2566
|
answered: state === SessionState.Established,
|
|
2532
2567
|
paused: this.client.isCallHeld(sipSession),
|
|
2533
2568
|
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
@@ -2538,6 +2573,7 @@ class WebRTCPhone extends Emitter {
|
|
|
2538
2573
|
videoMuted: fromSession ? fromSession.isVideoMuted() : false,
|
|
2539
2574
|
recording: fromSession ? fromSession.isRecording() : false,
|
|
2540
2575
|
recordingPaused: false, // @TODO
|
|
2576
|
+
sipSession,
|
|
2541
2577
|
...extra,
|
|
2542
2578
|
});
|
|
2543
2579
|
|
|
@@ -2548,4 +2584,4 @@ class WebRTCPhone extends Emitter {
|
|
|
2548
2584
|
}
|
|
2549
2585
|
|
|
2550
2586
|
export default WebRTCPhone;
|
|
2551
|
-
export { MESSAGE_TYPE_CHAT, MESSAGE_TYPE_SIGNAL, ON_AUDIO_STREAM, ON_CALL_ACCEPTED, ON_CALL_ANSWERED, ON_CALL_CANCELED, ON_CALL_ENDED, ON_CALL_ENDING, ON_CALL_ERROR, ON_CALL_FAILED, ON_CALL_HELD, ON_CALL_INCOMING, ON_CALL_MUTED, ON_CALL_OUTGOING, ON_CALL_RESUMED, ON_CALL_UNHELD, ON_CALL_UNMUTED, ON_CAMERA_DISABLED, ON_CAMERA_RESUMED, ON_CHAT, ON_DISCONNECTED, ON_MESSAGE, ON_MESSAGE_TRACK_UPDATED, ON_NETWORK_STATS, ON_PLAY_HANGUP_SOUND, ON_PLAY_INBOUND_CALL_SIGNAL_SOUND, ON_PLAY_PROGRESS_SOUND, ON_PLAY_RING_SOUND, ON_PROGRESS, ON_REGISTERED, ON_REINVITE, ON_REMOVE_STREAM, ON_SHARE_SCREEN_ENDED, ON_SHARE_SCREEN_ENDING, ON_SHARE_SCREEN_STARTED, ON_SIGNAL, ON_TERMINATE_SOUND, ON_TRACK, ON_UNREGISTERED, ON_USER_AGENT, ON_VIDEO_INPUT_CHANGE, ON_VIDEO_STREAM, events };
|
|
2587
|
+
export { MESSAGE_TYPE_CHAT, MESSAGE_TYPE_SIGNAL, ON_AUDIO_STREAM, ON_CALL_ACCEPTED, ON_CALL_ANSWERED, ON_CALL_CANCELED, ON_CALL_ENDED, ON_CALL_ENDING, ON_CALL_ERROR, ON_CALL_FAILED, ON_CALL_HELD, ON_CALL_INCOMING, ON_CALL_MUTED, ON_CALL_OUTGOING, ON_CALL_REJECTED, ON_CALL_RESUMED, ON_CALL_UNHELD, ON_CALL_UNMUTED, ON_CAMERA_DISABLED, ON_CAMERA_RESUMED, ON_CHAT, ON_DISCONNECTED, ON_MESSAGE, ON_MESSAGE_TRACK_UPDATED, ON_NETWORK_STATS, ON_PLAY_HANGUP_SOUND, ON_PLAY_INBOUND_CALL_SIGNAL_SOUND, ON_PLAY_PROGRESS_SOUND, ON_PLAY_RING_SOUND, ON_PROGRESS, ON_REGISTERED, ON_REINVITE, ON_REMOVE_STREAM, ON_SHARE_SCREEN_ENDED, ON_SHARE_SCREEN_ENDING, ON_SHARE_SCREEN_STARTED, ON_SIGNAL, ON_TERMINATE_SOUND, ON_TRACK, ON_UNREGISTERED, ON_USER_AGENT, ON_VIDEO_INPUT_CHANGE, ON_VIDEO_STREAM, events };
|