@wazo/sdk 0.37.20 → 0.37.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/dist/wazo-sdk.js +6 -6
  2. package/esm/__tests__/api-client.test.js +91 -21
  3. package/esm/__tests__/web-rtc-client.test.js +214 -165
  4. package/esm/api/agentd.js +25 -2
  5. package/esm/api/amid.js +26 -3
  6. package/esm/api/application.js +25 -2
  7. package/esm/api/auth.js +25 -2
  8. package/esm/api/call-logd.js +34 -4
  9. package/esm/api/calld.js +35 -2
  10. package/esm/api/chatd.js +32 -2
  11. package/esm/api/confd.js +56 -9
  12. package/esm/api/ctid-ng.js +38 -5
  13. package/esm/api/dird.js +29 -3
  14. package/esm/api/webhookd.js +26 -3
  15. package/esm/api-client.js +91 -21
  16. package/esm/checker/Checker.js +241 -190
  17. package/esm/checker/checks/aor.js +91 -21
  18. package/esm/checker/checks/api.js +91 -21
  19. package/esm/checker/checks/index.js +231 -180
  20. package/esm/checker/checks/wazo-websocket.js +42 -17
  21. package/esm/checker/checks/webrtc-transport.js +214 -165
  22. package/esm/checker/checks/webrtc.js +214 -165
  23. package/esm/domain/AdHocAPIConference.js +91 -21
  24. package/esm/domain/Call.js +3 -0
  25. package/esm/domain/CallLog.js +8 -1
  26. package/esm/domain/ChatMessage.js +4 -0
  27. package/esm/domain/ChatRoom.js +3 -0
  28. package/esm/domain/Contact.js +4 -1
  29. package/esm/domain/Features.js +91 -21
  30. package/esm/domain/Meeting.js +28 -5
  31. package/esm/domain/Phone/CTIPhone.js +109 -35
  32. package/esm/domain/Phone/WebRTCPhone.js +159 -102
  33. package/esm/domain/Recording.js +3 -0
  34. package/esm/domain/Voicemail.js +3 -0
  35. package/esm/domain/__tests__/Call.test.js +3 -0
  36. package/esm/domain/__tests__/CallLog.test.js +8 -1
  37. package/esm/domain/__tests__/Contact.test.js +4 -1
  38. package/esm/domain/__tests__/Meeting.test.js +144 -0
  39. package/esm/domain/__tests__/Voicemail.test.js +3 -0
  40. package/esm/index.js +509 -414
  41. package/esm/lib/WazoSessionDescriptionHandler.js +26 -41
  42. package/esm/service/CallApi.js +91 -21
  43. package/esm/service/IssueReporter.js +26 -3
  44. package/esm/service/__tests__/IssueReporter.test.js +26 -3
  45. package/esm/service/getApiClient.js +91 -21
  46. package/esm/simple/Auth.js +499 -404
  47. package/esm/simple/Configuration.js +499 -404
  48. package/esm/simple/Directory.js +91 -21
  49. package/esm/simple/Phone.js +499 -404
  50. package/esm/simple/Websocket.js +45 -19
  51. package/esm/simple/index.js +503 -408
  52. package/esm/simple/room/LocalParticipant.js +503 -408
  53. package/esm/simple/room/Participant.js +503 -408
  54. package/esm/simple/room/RemoteParticipant.js +503 -408
  55. package/esm/simple/room/Room.js +504 -409
  56. package/esm/simple/room/SipRoom.js +503 -408
  57. package/esm/simple/room/Stream.js +503 -408
  58. package/esm/simple/room/__tests__/RemoteParticipant.test.js +503 -408
  59. package/esm/simple/utils.js +503 -408
  60. package/esm/types/WebSocketMessage.js +1 -1
  61. package/esm/utils/__tests__/api-requester.test.js +25 -2
  62. package/esm/utils/api-requester.js +25 -2
  63. package/esm/web-rtc-client.js +214 -165
  64. package/esm/websocket-client.js +43 -18
  65. package/lib/__tests__/api-client.test.js +91 -21
  66. package/lib/__tests__/web-rtc-client.test.js +214 -165
  67. package/lib/api/agentd.js +25 -2
  68. package/lib/api/amid.js +26 -3
  69. package/lib/api/application.js +25 -2
  70. package/lib/api/auth.js +25 -2
  71. package/lib/api/call-logd.js +34 -4
  72. package/lib/api/calld.js +35 -2
  73. package/lib/api/chatd.js +32 -2
  74. package/lib/api/confd.js +56 -9
  75. package/lib/api/ctid-ng.js +38 -5
  76. package/lib/api/dird.js +29 -3
  77. package/lib/api/webhookd.js +26 -3
  78. package/lib/api-client.js +91 -21
  79. package/lib/checker/Checker.js +241 -190
  80. package/lib/checker/checks/aor.js +91 -21
  81. package/lib/checker/checks/api.js +91 -21
  82. package/lib/checker/checks/index.js +231 -180
  83. package/lib/checker/checks/wazo-websocket.js +42 -17
  84. package/lib/checker/checks/webrtc-transport.js +214 -165
  85. package/lib/checker/checks/webrtc.js +214 -165
  86. package/lib/domain/AdHocAPIConference.js +91 -21
  87. package/lib/domain/Call.js +3 -0
  88. package/lib/domain/CallLog.js +8 -1
  89. package/lib/domain/ChatMessage.js +4 -0
  90. package/lib/domain/ChatRoom.js +3 -0
  91. package/lib/domain/Contact.js +4 -1
  92. package/lib/domain/Features.js +91 -21
  93. package/lib/domain/Meeting.js +32 -5
  94. package/lib/domain/Phone/CTIPhone.js +109 -35
  95. package/lib/domain/Phone/WebRTCPhone.js +159 -102
  96. package/lib/domain/Recording.js +3 -0
  97. package/lib/domain/Voicemail.js +3 -0
  98. package/lib/domain/__tests__/Call.test.js +3 -0
  99. package/lib/domain/__tests__/CallLog.test.js +8 -1
  100. package/lib/domain/__tests__/Contact.test.js +4 -1
  101. package/lib/domain/__tests__/Meeting.test.js +150 -0
  102. package/lib/domain/__tests__/Voicemail.test.js +3 -0
  103. package/lib/index.js +509 -414
  104. package/lib/lib/WazoSessionDescriptionHandler.js +26 -41
  105. package/lib/service/CallApi.js +91 -21
  106. package/lib/service/IssueReporter.js +26 -3
  107. package/lib/service/__tests__/IssueReporter.test.js +26 -3
  108. package/lib/service/getApiClient.js +91 -21
  109. package/lib/simple/Auth.js +499 -404
  110. package/lib/simple/Configuration.js +499 -404
  111. package/lib/simple/Directory.js +91 -21
  112. package/lib/simple/Phone.js +499 -404
  113. package/lib/simple/Websocket.js +45 -19
  114. package/lib/simple/index.js +503 -408
  115. package/lib/simple/room/LocalParticipant.js +503 -408
  116. package/lib/simple/room/Participant.js +503 -408
  117. package/lib/simple/room/RemoteParticipant.js +503 -408
  118. package/lib/simple/room/Room.js +504 -409
  119. package/lib/simple/room/SipRoom.js +503 -408
  120. package/lib/simple/room/Stream.js +503 -408
  121. package/lib/simple/room/__tests__/RemoteParticipant.test.js +503 -408
  122. package/lib/simple/utils.js +503 -408
  123. package/lib/types/WebSocketMessage.js +2 -0
  124. package/lib/utils/__tests__/api-requester.test.js +25 -2
  125. package/lib/utils/api-requester.js +25 -2
  126. package/lib/web-rtc-client.js +214 -165
  127. package/lib/websocket-client.js +43 -17
  128. package/package.json +1 -1
  129. package/src/api/confd.js +5 -2
  130. package/src/domain/Call.js +3 -0
  131. package/src/domain/CallLog.js +4 -0
  132. package/src/domain/ChatMessage.js +4 -0
  133. package/src/domain/ChatRoom.js +3 -0
  134. package/src/domain/Contact.js +3 -0
  135. package/src/domain/Meeting.js +28 -5
  136. package/src/domain/Phone/CTIPhone.js +4 -0
  137. package/src/domain/Phone/Phone.js +2 -0
  138. package/src/domain/Phone/WebRTCPhone.js +49 -15
  139. package/src/domain/Recording.js +3 -0
  140. package/src/domain/Voicemail.js +3 -0
  141. package/src/domain/__tests__/Meeting.test.js +50 -0
  142. package/src/lib/WazoSessionDescriptionHandler.js +1 -35
  143. package/src/service/IssueReporter.js +25 -2
  144. package/src/simple/Phone.js +5 -0
  145. package/src/types/WebSocketMessage.js +5 -1
  146. package/src/web-rtc-client.js +41 -24
  147. package/src/websocket-client.js +2 -0
@@ -410,7 +410,7 @@ const isMobile = () => typeof navigator !== 'undefined' && navigator.product ===
410
410
 
411
411
  /* */
412
412
 
413
- IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
413
+ const logger = 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 = () => {
@@ -496,6 +496,7 @@ class IssueReporter {
496
496
 
497
497
 
498
498
 
499
+
499
500
 
500
501
  constructor() {
501
502
  addLevelsTo(this);
@@ -507,12 +508,17 @@ class IssueReporter {
507
508
  this.bufferTimeout = null;
508
509
  this._boundProcessBuffer = this._processBuffer.bind(this);
509
510
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
511
+ this._callback = null;
510
512
  }
511
513
 
512
514
  init() {
513
515
  this._catchConsole();
514
516
  }
515
517
 
518
+ setCallback(cb ) {
519
+ this._callback = cb;
520
+ }
521
+
516
522
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
517
523
  this.remoteClientConfiguration = configuration;
518
524
  }
@@ -548,6 +554,7 @@ class IssueReporter {
548
554
 
549
555
  // Handle category label
550
556
  let category = null;
557
+ let skipSendToRemote = false;
551
558
  let extra = {};
552
559
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
553
560
  category = args[0].split('=')[1];
@@ -563,6 +570,7 @@ class IssueReporter {
563
570
  errorMessage: lastArg.message,
564
571
  errorStack: lastArg.stack,
565
572
  errorType: lastArg.constructor.name,
573
+ skipSendToRemote: lastArg.skipSendToRemote,
566
574
  };
567
575
  } else {
568
576
  extra = lastArg;
@@ -571,6 +579,11 @@ class IssueReporter {
571
579
  args.splice(1, 1);
572
580
  }
573
581
 
582
+ if (extra.skipSendToRemote) {
583
+ skipSendToRemote = true;
584
+ delete extra.skipSendToRemote;
585
+ }
586
+
574
587
  const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
575
588
  const message = args.join(', ');
576
589
  let consoleMessage = message;
@@ -591,7 +604,13 @@ class IssueReporter {
591
604
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
592
605
  oldMethod.apply(oldMethod, [date, consoleMessage]);
593
606
 
594
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
607
+ if (this._callback) {
608
+ this._callback(level, consoleMessage);
609
+ }
610
+
611
+ if (!skipSendToRemote) {
612
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
613
+ }
595
614
  }
596
615
 
597
616
  logRequest(url , options , response , start ) {
@@ -736,7 +755,11 @@ class IssueReporter {
736
755
  },
737
756
  // $FlowFixMe
738
757
  body,
739
- }).catch(() => {
758
+ }).catch((e ) => {
759
+ // $FlowFixMe
760
+ e.skipSendToRemote = true;
761
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
762
+
740
763
  setTimeout(() => {
741
764
  if (isArray) {
742
765
  payload = payload.map(message => {
@@ -772,7 +795,7 @@ var IssueReporter$1 = new IssueReporter();
772
795
 
773
796
  /* global RTCSessionDescriptionInit, navigator */
774
797
 
775
- IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
798
+ const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
776
799
 
777
800
  //
778
801
 
@@ -814,7 +837,7 @@ BwIDAQAB
814
837
 
815
838
  //
816
839
 
817
- jsrsasign.KEYUTIL.getKey(swarmPublicKey);
840
+ const swarmKey = jsrsasign.KEYUTIL.getKey(swarmPublicKey);
818
841
 
819
842
  /* eslint-disable dot-notation */
820
843
 
@@ -835,15 +858,15 @@ global.wazoFetchOptions = global.wazoFetchOptions || {};
835
858
 
836
859
  // const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
837
860
 
838
- IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
861
+ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
839
862
 
840
863
  /* */
841
864
 
842
- IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
865
+ const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
843
866
 
844
867
  //
845
- IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
846
- IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
868
+ const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
869
+ const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
847
870
 
848
871
  /* eslint-disable no-param-reassign */
849
872
 
@@ -929,7 +952,7 @@ const events = [
929
952
  ON_DISCONNECTED,
930
953
  ];
931
954
 
932
- const logger = IssueReporter$1.loggerFor('webrtc-phone');
955
+ const logger$4 = IssueReporter$1.loggerFor('webrtc-phone');
933
956
 
934
957
  class WebRTCPhone extends Emitter {
935
958
 
@@ -1002,7 +1025,7 @@ class WebRTCPhone extends Emitter {
1002
1025
  }).catch(error => {
1003
1026
  // Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
1004
1027
  console.error('register error', error, error.message, error.stack);
1005
- logger.error('WebRTC register error', { message: error.message, stack: error.stack });
1028
+ logger$4.error('WebRTC register error', { message: error.message, stack: error.stack });
1006
1029
  });
1007
1030
  }
1008
1031
 
@@ -1017,7 +1040,7 @@ class WebRTCPhone extends Emitter {
1017
1040
  if (!this.client) {
1018
1041
  return;
1019
1042
  }
1020
- logger.info('WebRTC phone stop');
1043
+ logger$4.info('WebRTC phone stop');
1021
1044
  this.client.stop();
1022
1045
  }
1023
1046
 
@@ -1032,7 +1055,7 @@ class WebRTCPhone extends Emitter {
1032
1055
  async sendReinvite(callSession , constraints = null, conference = false,
1033
1056
  audioOnly = false, iceRestart = false) {
1034
1057
  const sipSession = this.findSipSession(callSession);
1035
- logger.info('WebRTC phone - send reinvite', {
1058
+ logger$4.info('WebRTC phone - send reinvite', {
1036
1059
  sessionId: sipSession ? sipSession.id : null,
1037
1060
  constraints,
1038
1061
  audioOnly,
@@ -1069,7 +1092,7 @@ class WebRTCPhone extends Emitter {
1069
1092
  }
1070
1093
 
1071
1094
  startHeartbeat() {
1072
- logger.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
1095
+ logger$4.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
1073
1096
  if (!this.client || this.client.hasHeartbeat()) {
1074
1097
  return;
1075
1098
  }
@@ -1078,7 +1101,7 @@ class WebRTCPhone extends Emitter {
1078
1101
  }
1079
1102
 
1080
1103
  stopHeartbeat() {
1081
- logger.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
1104
+ logger$4.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
1082
1105
  if (!this.client) {
1083
1106
  return;
1084
1107
  }
@@ -1095,7 +1118,7 @@ class WebRTCPhone extends Emitter {
1095
1118
  }
1096
1119
 
1097
1120
  reconnect() {
1098
- logger.info('WebRTC phone - reconnect', { client: !!this.client });
1121
+ logger$4.info('WebRTC phone - reconnect', { client: !!this.client });
1099
1122
  if (!this.client) {
1100
1123
  return;
1101
1124
  }
@@ -1136,10 +1159,15 @@ class WebRTCPhone extends Emitter {
1136
1159
  return false;
1137
1160
  }
1138
1161
 
1139
- logger.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
1162
+ logger$4.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
1140
1163
 
1141
1164
  this.client.downgradeToAudio(sipSession);
1142
1165
 
1166
+ if (callSession) {
1167
+ callSession.cameraEnabled = false;
1168
+ this._updateCallSession(callSession);
1169
+ }
1170
+
1143
1171
  if (withMessage) {
1144
1172
  this._sendReinviteMessage(callSession, false);
1145
1173
  }
@@ -1154,7 +1182,7 @@ class WebRTCPhone extends Emitter {
1154
1182
  return Promise.resolve(false);
1155
1183
  }
1156
1184
 
1157
- logger.info('Upgrade to video', {
1185
+ logger$4.info('Upgrade to video', {
1158
1186
  id: callSession ? callSession.getId() : null,
1159
1187
  constraints,
1160
1188
  isConference,
@@ -1167,6 +1195,11 @@ class WebRTCPhone extends Emitter {
1167
1195
 
1168
1196
  const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
1169
1197
 
1198
+ if (callSession) {
1199
+ callSession.cameraEnabled = true;
1200
+ this._updateCallSession(callSession);
1201
+ }
1202
+
1170
1203
  // If no stream is returned, it means we have to reinvite
1171
1204
  if (!newStream) {
1172
1205
  return true;
@@ -1189,7 +1222,7 @@ class WebRTCPhone extends Emitter {
1189
1222
 
1190
1223
  _sendReinviteMessage(callSession , isUpgrade ) {
1191
1224
  const sipSession = this.findSipSession(callSession);
1192
- logger.info('Sending reinvite message', {
1225
+ logger$4.info('Sending reinvite message', {
1193
1226
  id: callSession ? callSession.getId() : null,
1194
1227
  isUpgrade,
1195
1228
  });
@@ -1215,11 +1248,14 @@ class WebRTCPhone extends Emitter {
1215
1248
  // Monkey patch to know when canceled with the CANCEL message
1216
1249
  const onCancel = sipSession._onCancel.bind(sipSession);
1217
1250
  sipSession._onCancel = (message ) => {
1218
- logger.trace('on sip session canceled', { callId: message.callId });
1251
+ logger$4.trace('on sip session canceled', { callId: message.callId });
1219
1252
 
1220
1253
  onCancel(message);
1221
1254
  const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
1222
- this.eventEmitter.emit(ON_CALL_CANCELED, this._createCallSession(sipSession), elsewhere);
1255
+ const callSession = this._createCallSession(sipSession);
1256
+ delete this.callSessions[callSession.getId()];
1257
+
1258
+ this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
1223
1259
  };
1224
1260
  } else if (sipSession instanceof invitation.Invitation) {
1225
1261
  console.warn('sipSession._onCancel not found, please update the wazo SDK accordingly');
@@ -1240,17 +1276,19 @@ class WebRTCPhone extends Emitter {
1240
1276
  this.audioOutputVolume,
1241
1277
  );
1242
1278
  case sessionState.SessionState.Terminating:
1243
- logger.info('WebRTC phone - call terminating', { sipId: sipSession.id });
1279
+ logger$4.info('WebRTC phone - call terminating', { sipId: sipSession.id });
1244
1280
 
1245
1281
  this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
1246
1282
 
1247
1283
  break;
1248
1284
  case sessionState.SessionState.Terminated: {
1249
- logger.info('WebRTC phone - call terminated', { sipId: sipSession.id });
1285
+ logger$4.info('WebRTC phone - call terminated', { sipId: sipSession.id });
1250
1286
 
1287
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
1288
+ const callSession = this._createCallSession(sipSession);
1251
1289
  const wasCurrentSession = this._onCallTerminated(sipSession);
1252
1290
 
1253
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
1291
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
1254
1292
  }
1255
1293
  }
1256
1294
  });
@@ -1266,7 +1304,7 @@ class WebRTCPhone extends Emitter {
1266
1304
  const [stream] = event.streams;
1267
1305
  const kind = event && event.track && event.track.kind;
1268
1306
 
1269
- logger.info('on track stream called on the peer connection', {
1307
+ logger$4.info('on track stream called on the peer connection', {
1270
1308
  callId: this.getSipSessionId(sipSession),
1271
1309
  streamId: stream ? stream.id : null,
1272
1310
  tracks: stream ? stream.getTracks() : null,
@@ -1286,7 +1324,7 @@ class WebRTCPhone extends Emitter {
1286
1324
  };
1287
1325
 
1288
1326
  peerConnection.onremovestream = event => {
1289
- logger.info('on remove stream called on the peer connection', {
1327
+ logger$4.info('on remove stream called on the peer connection', {
1290
1328
  id: event.stream.id,
1291
1329
  tracks: event.stream.getTracks(),
1292
1330
  });
@@ -1296,7 +1334,7 @@ class WebRTCPhone extends Emitter {
1296
1334
  }
1297
1335
 
1298
1336
  async startScreenSharing(constraints , callSession ) {
1299
- logger.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
1337
+ logger$4.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
1300
1338
 
1301
1339
  const screenShareStream = await this.client.getStreamFromConstraints(constraints);
1302
1340
  if (!screenShareStream) {
@@ -1336,7 +1374,7 @@ class WebRTCPhone extends Emitter {
1336
1374
  return;
1337
1375
  }
1338
1376
 
1339
- logger.info('WebRTC phone - stop screen sharing', {
1377
+ logger$4.info('WebRTC phone - stop screen sharing', {
1340
1378
  restoreLocalStream,
1341
1379
  });
1342
1380
 
@@ -1392,24 +1430,26 @@ class WebRTCPhone extends Emitter {
1392
1430
  const pc = this.client.getPeerConnection(sipSessionId);
1393
1431
  const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
1394
1432
 
1395
- logger.info('WebRTC phone - on screensharing', {
1433
+ logger$4.info('WebRTC phone - on screensharing', {
1396
1434
  hadVideo,
1397
1435
  id: this.getSipSessionId(sipSession),
1398
1436
  screenTrack,
1399
1437
  });
1400
1438
 
1401
- screenTrack.onended = () => {
1402
- logger.info('WebRTC phone - on screenshare ended', {
1403
- hadVideo,
1404
- id: this.getSipSessionId(sipSession),
1405
- screenTrack,
1406
- });
1407
-
1408
- this.eventEmitter.emit(
1409
- ON_SHARE_SCREEN_ENDING,
1410
- this._createCallSession(sipSession, callSession),
1411
- );
1412
- };
1439
+ if (screenTrack) {
1440
+ screenTrack.onended = () => {
1441
+ logger$4.info('WebRTC phone - on screenshare ended', {
1442
+ hadVideo,
1443
+ id: this.getSipSessionId(sipSession),
1444
+ screenTrack,
1445
+ });
1446
+
1447
+ this.eventEmitter.emit(
1448
+ ON_SHARE_SCREEN_ENDING,
1449
+ this._createCallSession(sipSession, callSession),
1450
+ );
1451
+ };
1452
+ }
1413
1453
 
1414
1454
  this.currentScreenShare = {
1415
1455
  stream: screenStream,
@@ -1429,7 +1469,7 @@ class WebRTCPhone extends Emitter {
1429
1469
  }
1430
1470
 
1431
1471
  _onCallAccepted(sipSession , cameraEnabled ) {
1432
- logger.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
1472
+ logger$4.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
1433
1473
 
1434
1474
  const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
1435
1475
  this.currentSipSession = sipSession;
@@ -1447,7 +1487,7 @@ class WebRTCPhone extends Emitter {
1447
1487
  }
1448
1488
 
1449
1489
  changeAudioDevice(id ) {
1450
- logger.info('WebRTC phone - change audio device', { deviceId: id });
1490
+ logger$4.info('WebRTC phone - change audio device', { deviceId: id });
1451
1491
  this.audioOutputDeviceId = id;
1452
1492
  this.client.changeAudioOutputDevice(id);
1453
1493
  }
@@ -1457,14 +1497,14 @@ class WebRTCPhone extends Emitter {
1457
1497
  }
1458
1498
 
1459
1499
  changeRingDevice(id ) {
1460
- logger.info('WebRTC phone - changing ring device', { id });
1500
+ logger$4.info('WebRTC phone - changing ring device', { id });
1461
1501
 
1462
1502
  this.audioRingDeviceId = id;
1463
1503
  }
1464
1504
 
1465
1505
  // volume is a value between 0 and 1
1466
1506
  changeAudioVolume(volume ) {
1467
- logger.info('WebRTC phone - changing audio volume', { volume });
1507
+ logger$4.info('WebRTC phone - changing audio volume', { volume });
1468
1508
 
1469
1509
  this.audioOutputVolume = volume;
1470
1510
  this.client.changeAudioOutputVolume(volume);
@@ -1472,31 +1512,31 @@ class WebRTCPhone extends Emitter {
1472
1512
 
1473
1513
  // volume is a value between 0 and 1
1474
1514
  changeRingVolume(volume ) {
1475
- logger.info('WebRTC phone - changing ring volume', { volume });
1515
+ logger$4.info('WebRTC phone - changing ring volume', { volume });
1476
1516
 
1477
1517
  this.audioRingVolume = volume;
1478
1518
  }
1479
1519
 
1480
1520
  changeAudioInputDevice(id ) {
1481
- logger.info('WebRTC phone - changeAudio input device', { deviceId: id });
1521
+ logger$4.info('WebRTC phone - changeAudio input device', { deviceId: id });
1482
1522
 
1483
1523
  return this.client.changeAudioInputDevice(id, this.currentSipSession);
1484
1524
  }
1485
1525
 
1486
1526
  changeVideoInputDevice(id ) {
1487
- logger.info('WebRTC phone - change video input device', { deviceId: id });
1527
+ logger$4.info('WebRTC phone - change video input device', { deviceId: id });
1488
1528
 
1489
1529
  return this.client.changeVideoInputDevice(id, this.currentSipSession);
1490
1530
  }
1491
1531
 
1492
1532
  changeSessionVideoInputDevice(id ) {
1493
- logger.info('WebRTC phone - change session video input device', { deviceId: id });
1533
+ logger$4.info('WebRTC phone - change session video input device', { deviceId: id });
1494
1534
 
1495
1535
  return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
1496
1536
  }
1497
1537
 
1498
1538
  _onCallTerminated(sipSession ) {
1499
- logger.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
1539
+ logger$4.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
1500
1540
 
1501
1541
  const callSession = this._createCallSession(sipSession);
1502
1542
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
@@ -1530,7 +1570,7 @@ class WebRTCPhone extends Emitter {
1530
1570
  const hasIncomingCallSession = this.hasIncomingCallSession();
1531
1571
 
1532
1572
  // Re-trigger incoming call event for remaining incoming calls
1533
- logger.info('WebRTC phone - check to re-trigger incoming call', {
1573
+ logger$4.info('WebRTC phone - check to re-trigger incoming call', {
1534
1574
  sipId: sipSession.id,
1535
1575
  shouldRetrigger,
1536
1576
  hasIncomingCallSession,
@@ -1621,37 +1661,37 @@ class WebRTCPhone extends Emitter {
1621
1661
 
1622
1662
  // Deprecated
1623
1663
  getLocalStreamForCall(callSession ) {
1624
- logger.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
1664
+ logger$4.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
1625
1665
 
1626
1666
  return this.getLocalStream(callSession);
1627
1667
  }
1628
1668
 
1629
1669
  // Deprecated
1630
1670
  getRemoteStreamForCall(callSession ) {
1631
- logger.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
1671
+ logger$4.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
1632
1672
 
1633
1673
  return this.getRemoteVideoStream(callSession);
1634
1674
  }
1635
1675
 
1636
1676
  getRemoteStreamsForCall(callSession ) {
1637
- logger.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
1677
+ logger$4.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
1638
1678
 
1639
1679
  return this.getRemoteStream(callSession);
1640
1680
  }
1641
1681
 
1642
1682
  accept(callSession , cameraEnabled ) {
1643
- logger.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
1683
+ logger$4.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
1644
1684
  if (this.currentSipSession) {
1645
1685
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
1646
1686
  }
1647
1687
 
1648
1688
  if (!callSession) {
1649
- logger.warn('no CallSession to accept.');
1689
+ logger$4.warn('no CallSession to accept.');
1650
1690
  return Promise.resolve(null);
1651
1691
  }
1652
1692
 
1653
1693
  if (callSession.getId() in this.acceptedSessions) {
1654
- logger.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
1694
+ logger$4.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
1655
1695
  return Promise.resolve(callSession.sipCallId);
1656
1696
  }
1657
1697
 
@@ -1663,24 +1703,24 @@ class WebRTCPhone extends Emitter {
1663
1703
  const sipSession = this.client.getSipSession(callSession.getId());
1664
1704
  if (sipSession) {
1665
1705
  if (sipSession.state === sessionState.SessionState.Terminated || sipSession.state === sessionState.SessionState.Terminating) {
1666
- logger.warn('Trying to answer a terminated sipSession.');
1706
+ logger$4.warn('Trying to answer a terminated sipSession.');
1667
1707
 
1668
1708
  return Promise.resolve(null);
1669
1709
  }
1670
1710
 
1671
- logger.info('accept call, session found', { sipId: sipSession.id });
1711
+ logger$4.info('accept call, session found', { sipId: sipSession.id });
1672
1712
 
1673
1713
  // $FlowFixMe
1674
1714
  return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
1675
1715
  return callSession.sipCallId;
1676
1716
  }).catch(e => {
1677
- logger.error(e);
1717
+ logger$4.error(e);
1678
1718
  this.endCurrentCall(callSession);
1679
1719
  throw e;
1680
1720
  });
1681
1721
  }
1682
1722
 
1683
- logger.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
1723
+ logger$4.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
1684
1724
 
1685
1725
  return Promise.resolve(null);
1686
1726
  }
@@ -1690,7 +1730,7 @@ class WebRTCPhone extends Emitter {
1690
1730
  }
1691
1731
 
1692
1732
  async reject(callSession ) {
1693
- logger.info('reject WebRTC called', { id: callSession.getId() });
1733
+ logger$4.info('reject WebRTC called', { id: callSession.getId() });
1694
1734
 
1695
1735
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
1696
1736
  if (!callSession || callSession.getId() in this.rejectedSessions) {
@@ -1702,14 +1742,14 @@ class WebRTCPhone extends Emitter {
1702
1742
 
1703
1743
  const sipSession = this.findSipSession(callSession);
1704
1744
  if (sipSession) {
1705
- logger.info('WebRTC rejecting', { sipId: sipSession.id });
1745
+ logger$4.info('WebRTC rejecting', { sipId: sipSession.id });
1706
1746
 
1707
1747
  this.client.hangup(sipSession);
1708
1748
  }
1709
1749
  }
1710
1750
 
1711
1751
  async ignore(callSession ) {
1712
- logger.info('WebRTC ignore', { id: callSession.getId() });
1752
+ logger$4.info('WebRTC ignore', { id: callSession.getId() });
1713
1753
 
1714
1754
  // kill the ring
1715
1755
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
@@ -1721,14 +1761,14 @@ class WebRTCPhone extends Emitter {
1721
1761
  const sipSession = this.findSipSession(callSession);
1722
1762
 
1723
1763
  if (sipSession) {
1724
- logger.info('WebRTC atxfer', { sipId: sipSession.id });
1764
+ logger$4.info('WebRTC atxfer', { sipId: sipSession.id });
1725
1765
 
1726
1766
  return this.client.atxfer(sipSession);
1727
1767
  }
1728
1768
  }
1729
1769
 
1730
1770
  hold(callSession , withEvent = true, isConference = false) {
1731
- logger.info('WebRTC hold', { id: callSession.getId() });
1771
+ logger$4.info('WebRTC hold', { id: callSession.getId() });
1732
1772
 
1733
1773
  const sipSession = this.findSipSession(callSession);
1734
1774
 
@@ -1743,18 +1783,18 @@ class WebRTCPhone extends Emitter {
1743
1783
  }
1744
1784
 
1745
1785
  resume(callSession , isConference = false, withEvent = true) {
1746
- logger.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
1786
+ logger$4.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
1747
1787
 
1748
1788
  const sipSession = this.findSipSession(callSession);
1749
1789
  if (!sipSession) {
1750
1790
  return new Promise((resolve, reject) => reject(new Error('No session to resume')));
1751
1791
  }
1752
1792
 
1753
- logger.info('WebRTC resuming', { sipId: sipSession.id });
1793
+ logger$4.info('WebRTC resuming', { sipId: sipSession.id });
1754
1794
 
1755
1795
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
1756
1796
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
1757
- logger.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
1797
+ logger$4.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
1758
1798
  this.holdSipSession(this.currentSipSession, callSession);
1759
1799
  }
1760
1800
 
@@ -1779,7 +1819,7 @@ class WebRTCPhone extends Emitter {
1779
1819
  const sessionId = this.getSipSessionId(sipSession);
1780
1820
  const hasVideo = this.client.hasLocalVideo(sessionId);
1781
1821
 
1782
- logger.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
1822
+ logger$4.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
1783
1823
 
1784
1824
  // Stop screenshre if needed
1785
1825
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
@@ -1810,7 +1850,7 @@ class WebRTCPhone extends Emitter {
1810
1850
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
1811
1851
  }
1812
1852
  const sessionId = this.getSipSessionId(sipSession);
1813
- logger.info('WebRTC unhold sip session', { sessionId, isConference });
1853
+ logger$4.info('WebRTC unhold sip session', { sessionId, isConference });
1814
1854
 
1815
1855
  const { hasVideo } = this.client.getHeldSession(sessionId) || {};
1816
1856
  const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
@@ -1854,14 +1894,14 @@ class WebRTCPhone extends Emitter {
1854
1894
  }
1855
1895
 
1856
1896
  mute(callSession , withEvent = true) {
1857
- logger.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
1897
+ logger$4.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
1858
1898
 
1859
1899
  const sipSession = this.findSipSession(callSession);
1860
1900
  if (!sipSession) {
1861
1901
  return;
1862
1902
  }
1863
1903
 
1864
- logger.info('WebRTC muting', { sipId: sipSession.id });
1904
+ logger$4.info('WebRTC muting', { sipId: sipSession.id });
1865
1905
  this.client.mute(sipSession);
1866
1906
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
1867
1907
 
@@ -1875,14 +1915,14 @@ class WebRTCPhone extends Emitter {
1875
1915
  }
1876
1916
 
1877
1917
  unmute(callSession , withEvent = true) {
1878
- logger.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
1918
+ logger$4.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
1879
1919
 
1880
1920
  const sipSession = this.findSipSession(callSession);
1881
1921
  if (!sipSession) {
1882
1922
  return;
1883
1923
  }
1884
1924
 
1885
- logger.info('WebRTC unmuting', { sipId: sipSession.id });
1925
+ logger$4.info('WebRTC unmuting', { sipId: sipSession.id });
1886
1926
  this.client.unmute(sipSession);
1887
1927
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
1888
1928
 
@@ -1909,7 +1949,7 @@ class WebRTCPhone extends Emitter {
1909
1949
  if (!sipSession) {
1910
1950
  return;
1911
1951
  }
1912
- logger.info('WebRTC turn camera on', { sipId: sipSession.id });
1952
+ logger$4.info('WebRTC turn camera on', { sipId: sipSession.id });
1913
1953
 
1914
1954
  this.client.toggleCameraOn(sipSession);
1915
1955
 
@@ -1921,7 +1961,7 @@ class WebRTCPhone extends Emitter {
1921
1961
  if (!sipSession) {
1922
1962
  return;
1923
1963
  }
1924
- logger.info('WebRTC turn camera off', { sipId: sipSession.id });
1964
+ logger$4.info('WebRTC turn camera off', { sipId: sipSession.id });
1925
1965
 
1926
1966
  this.client.toggleCameraOff(sipSession);
1927
1967
  this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
@@ -1933,7 +1973,7 @@ class WebRTCPhone extends Emitter {
1933
1973
  return;
1934
1974
  }
1935
1975
 
1936
- logger.info('WebRTC send key', { sipId: sipSession.id, tone });
1976
+ logger$4.info('WebRTC send key', { sipId: sipSession.id, tone });
1937
1977
  this.client.sendDTMF(sipSession, tone);
1938
1978
  }
1939
1979
 
@@ -1941,7 +1981,7 @@ class WebRTCPhone extends Emitter {
1941
1981
  // @TODO: line is not used here
1942
1982
  async makeCall(number , line , cameraEnabled ,
1943
1983
  audioOnly = false, conference = false) {
1944
- logger.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
1984
+ logger$4.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
1945
1985
  if (!number) {
1946
1986
  return Promise.resolve(null);
1947
1987
  }
@@ -1951,7 +1991,7 @@ class WebRTCPhone extends Emitter {
1951
1991
  }
1952
1992
  if (this.currentSipSession) {
1953
1993
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
1954
- logger.warn('Unable to hold current session when making another call', e);
1994
+ logger$4.warn('Unable to hold current session when making another call', e);
1955
1995
  });
1956
1996
  }
1957
1997
 
@@ -1961,7 +2001,7 @@ class WebRTCPhone extends Emitter {
1961
2001
  this._bindEvents(sipSession);
1962
2002
  } catch (error) {
1963
2003
  console.warn(error);
1964
- logger.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
2004
+ logger$4.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
1965
2005
  return Promise.resolve(null);
1966
2006
  }
1967
2007
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
@@ -1989,7 +2029,7 @@ class WebRTCPhone extends Emitter {
1989
2029
  return;
1990
2030
  }
1991
2031
 
1992
- logger.info('WebRTC transfer', { sipId: sipSession.id, target });
2032
+ logger$4.info('WebRTC transfer', { sipId: sipSession.id, target });
1993
2033
 
1994
2034
  this.client.transfer(sipSession, target);
1995
2035
  }
@@ -1998,7 +2038,7 @@ class WebRTCPhone extends Emitter {
1998
2038
  const sipSession = this.client.getSipSession(source.sipCallId);
1999
2039
  const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
2000
2040
 
2001
- logger.info('WebRTC indirect transfer', {
2041
+ logger$4.info('WebRTC indirect transfer', {
2002
2042
  sipId: sipSession ? sipSession.id : null,
2003
2043
  target: sipSessionTarget ? sipSessionTarget.id : null,
2004
2044
  });
@@ -2037,7 +2077,7 @@ class WebRTCPhone extends Emitter {
2037
2077
  return false;
2038
2078
  }
2039
2079
 
2040
- logger.info('WebRTC hangup', { sipId: sipSession.id });
2080
+ logger$4.info('WebRTC hangup', { sipId: sipSession.id });
2041
2081
 
2042
2082
  const sipSessionId = this.getSipSessionId(sipSession);
2043
2083
 
@@ -2083,7 +2123,7 @@ class WebRTCPhone extends Emitter {
2083
2123
  endCurrentCall(callSession ) {
2084
2124
  const isCurrent = this.isCurrentCallSipSession(callSession);
2085
2125
 
2086
- logger.info('Ending current call', {
2126
+ logger$4.info('Ending current call', {
2087
2127
  id: callSession ? callSession.getId() : null,
2088
2128
  isCurrent,
2089
2129
  });
@@ -2107,7 +2147,7 @@ class WebRTCPhone extends Emitter {
2107
2147
  }
2108
2148
 
2109
2149
  async close() {
2110
- logger.info('WebRTC close');
2150
+ logger$4.info('WebRTC close');
2111
2151
 
2112
2152
  try {
2113
2153
  await Promise.race([
@@ -2115,7 +2155,7 @@ class WebRTCPhone extends Emitter {
2115
2155
  new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
2116
2156
  ]);
2117
2157
  } catch (e) {
2118
- logger.error('WebRTC close, unregister error', e);
2158
+ logger$4.error('WebRTC close, unregister error', e);
2119
2159
  }
2120
2160
 
2121
2161
  this.client.close();
@@ -2133,12 +2173,12 @@ class WebRTCPhone extends Emitter {
2133
2173
  }
2134
2174
 
2135
2175
  enableRinging() {
2136
- logger.info('WebRTC enable ringing');
2176
+ logger$4.info('WebRTC enable ringing');
2137
2177
  this.ringingEnabled = true;
2138
2178
  }
2139
2179
 
2140
2180
  disableRinging() {
2141
- logger.info('WebRTC disable ringing');
2181
+ logger$4.info('WebRTC disable ringing');
2142
2182
  this.ringingEnabled = false;
2143
2183
  }
2144
2184
 
@@ -2178,7 +2218,7 @@ class WebRTCPhone extends Emitter {
2178
2218
 
2179
2219
  // Deprecated
2180
2220
  getLocalMediaStream(callSession ) {
2181
- logger.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
2221
+ logger$4.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
2182
2222
  return this.getLocalStream(callSession);
2183
2223
  }
2184
2224
 
@@ -2198,6 +2238,10 @@ class WebRTCPhone extends Emitter {
2198
2238
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
2199
2239
  }
2200
2240
 
2241
+ getRemoteVideoStreamFromPc(callSession ) {
2242
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
2243
+ }
2244
+
2201
2245
  hasRemoteVideo(callSession ) {
2202
2246
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
2203
2247
  }
@@ -2216,7 +2260,7 @@ class WebRTCPhone extends Emitter {
2216
2260
  this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
2217
2261
  const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
2218
2262
  const withVideo = this.allowVideo ? wantsToDoVideo : false;
2219
- logger.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
2263
+ logger$4.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
2220
2264
 
2221
2265
  const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
2222
2266
  this.incomingSessions.push(callSession.getId());
@@ -2239,7 +2283,7 @@ class WebRTCPhone extends Emitter {
2239
2283
  });
2240
2284
 
2241
2285
  this.client.on(this.client.ON_REINVITE, (...args) => {
2242
- logger.info('WebRTC on reinvite', {
2286
+ logger$4.info('WebRTC on reinvite', {
2243
2287
  sessionId: args[0].id,
2244
2288
  inviteId: args[1].id,
2245
2289
  updatedCalleeName: args[2],
@@ -2259,7 +2303,7 @@ class WebRTCPhone extends Emitter {
2259
2303
  });
2260
2304
 
2261
2305
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
2262
- logger.info('WebRTC call accepted', { sipId: sipSession.id });
2306
+ logger$4.info('WebRTC call accepted', { sipId: sipSession.id });
2263
2307
 
2264
2308
  this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
2265
2309
 
@@ -2270,22 +2314,22 @@ class WebRTCPhone extends Emitter {
2270
2314
  this.client.on('ended', () => {});
2271
2315
 
2272
2316
  this.client.on(this.client.ON_ERROR, e => {
2273
- logger.error('WebRTC error', e);
2317
+ logger$4.error('WebRTC error', e);
2274
2318
  this.eventEmitter.emit(ON_CALL_ERROR, e);
2275
2319
  });
2276
2320
 
2277
2321
  this.client.on(this.client.UNREGISTERED, () => {
2278
- logger.info('WebRTC unregistered');
2322
+ logger$4.info('WebRTC unregistered');
2279
2323
  this.eventEmitter.emit(ON_UNREGISTERED);
2280
2324
  });
2281
2325
 
2282
2326
  this.client.on(this.client.ON_DISCONNECTED, () => {
2283
- logger.info('WebRTC disconnected');
2327
+ logger$4.info('WebRTC disconnected');
2284
2328
  this.eventEmitter.emit(ON_DISCONNECTED);
2285
2329
  });
2286
2330
 
2287
2331
  this.client.on(this.client.REGISTERED, () => {
2288
- logger.info('WebRTC registered', {
2332
+ logger$4.info('WebRTC registered', {
2289
2333
  shouldSendReinvite: this.shouldSendReinvite,
2290
2334
  state: this.currentSipSession ? this.currentSipSession.state : null,
2291
2335
  currentSipSession: !!this.currentSipSession,
@@ -2298,23 +2342,27 @@ class WebRTCPhone extends Emitter {
2298
2342
  if (this.shouldSendReinvite && this.currentSipSession
2299
2343
  && this.currentSipSession.state === sessionState.SessionState.Established) {
2300
2344
  this.shouldSendReinvite = false;
2345
+ const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
2346
+ const isConference = pc ? pc.sfu : false;
2347
+ const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
2348
+
2301
2349
  try {
2302
2350
  // Send reinvite with iceRestart
2303
- this.sendReinvite(this.currentCallSession, null, false, false, true);
2351
+ this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
2304
2352
  } catch (e) {
2305
- logger.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
2353
+ logger$4.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
2306
2354
  }
2307
2355
  }
2308
2356
  });
2309
2357
 
2310
2358
  this.client.on(this.client.CONNECTED, () => {
2311
- logger.info('WebRTC client connected');
2359
+ logger$4.info('WebRTC client connected');
2312
2360
 
2313
2361
  this.stopHeartbeat();
2314
2362
  });
2315
2363
 
2316
2364
  this.client.on(this.client.DISCONNECTED, () => {
2317
- logger.info('WebRTC client disconnected');
2365
+ logger$4.info('WebRTC client disconnected');
2318
2366
 
2319
2367
  this.eventEmitter.emit(ON_UNREGISTERED);
2320
2368
 
@@ -2352,7 +2400,7 @@ class WebRTCPhone extends Emitter {
2352
2400
  const localStream = this.client.getLocalStream(sipSessionId);
2353
2401
  const callSession = this.callSessions[sipSessionId];
2354
2402
 
2355
- logger.info('Updrading directly in screensharing mode', {
2403
+ logger$4.info('Updrading directly in screensharing mode', {
2356
2404
  sipSessionId,
2357
2405
  tracks: localStream ? localStream.getTracks() : null,
2358
2406
  });
@@ -2384,6 +2432,15 @@ class WebRTCPhone extends Emitter {
2384
2432
  return this.client.getSipSessionId(sipSession);
2385
2433
  }
2386
2434
 
2435
+ _updateCallSession(callSession ) {
2436
+ const sipSession = this.findSipSession(callSession);
2437
+ const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
2438
+
2439
+ if (sipSessionId) {
2440
+ this.callSessions[sipSessionId] = callSession;
2441
+ }
2442
+ }
2443
+
2387
2444
  _onMessage(message ) {
2388
2445
  if (!message || message.method !== 'MESSAGE') {
2389
2446
  return;