@wazo/sdk 0.37.19 → 0.37.23

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 (142) hide show
  1. package/dist/wazo-sdk.js +5 -5
  2. package/esm/__tests__/api-client.test.js +70 -5
  3. package/esm/__tests__/web-rtc-client.test.js +111 -67
  4. package/esm/api/agentd.js +25 -2
  5. package/esm/api/amid.js +25 -2
  6. package/esm/api/application.js +25 -2
  7. package/esm/api/auth.js +25 -2
  8. package/esm/api/call-logd.js +32 -2
  9. package/esm/api/calld.js +35 -2
  10. package/esm/api/chatd.js +32 -2
  11. package/esm/api/confd.js +47 -5
  12. package/esm/api/ctid-ng.js +35 -2
  13. package/esm/api/dird.js +28 -2
  14. package/esm/api/webhookd.js +25 -2
  15. package/esm/api-client.js +70 -5
  16. package/esm/checker/Checker.js +113 -67
  17. package/esm/checker/checks/aor.js +70 -5
  18. package/esm/checker/checks/api.js +70 -5
  19. package/esm/checker/checks/index.js +113 -67
  20. package/esm/checker/checks/wazo-websocket.js +27 -2
  21. package/esm/checker/checks/webrtc-transport.js +111 -67
  22. package/esm/checker/checks/webrtc.js +111 -67
  23. package/esm/domain/AdHocAPIConference.js +70 -5
  24. package/esm/domain/Call.js +3 -0
  25. package/esm/domain/CallLog.js +7 -0
  26. package/esm/domain/ChatMessage.js +4 -0
  27. package/esm/domain/ChatRoom.js +3 -0
  28. package/esm/domain/Contact.js +3 -0
  29. package/esm/domain/Features.js +70 -5
  30. package/esm/domain/Meeting.js +17 -1
  31. package/esm/domain/Phone/CTIPhone.js +74 -5
  32. package/esm/domain/Phone/WebRTCPhone.js +50 -16
  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 +7 -0
  37. package/esm/domain/__tests__/Contact.test.js +3 -0
  38. package/esm/domain/__tests__/Voicemail.test.js +3 -0
  39. package/esm/index.js +147 -80
  40. package/esm/lib/WazoSessionDescriptionHandler.js +25 -40
  41. package/esm/service/CallApi.js +70 -5
  42. package/esm/service/IssueReporter.js +25 -2
  43. package/esm/service/__tests__/IssueReporter.test.js +25 -2
  44. package/esm/service/getApiClient.js +70 -5
  45. package/esm/simple/Auth.js +147 -80
  46. package/esm/simple/Configuration.js +147 -80
  47. package/esm/simple/Directory.js +70 -5
  48. package/esm/simple/Phone.js +147 -80
  49. package/esm/simple/Websocket.js +28 -2
  50. package/esm/simple/index.js +147 -80
  51. package/esm/simple/room/LocalParticipant.js +147 -80
  52. package/esm/simple/room/Participant.js +147 -80
  53. package/esm/simple/room/RemoteParticipant.js +147 -80
  54. package/esm/simple/room/Room.js +147 -80
  55. package/esm/simple/room/SipRoom.js +147 -80
  56. package/esm/simple/room/Stream.js +147 -80
  57. package/esm/simple/room/__tests__/RemoteParticipant.test.js +147 -80
  58. package/esm/simple/utils.js +147 -80
  59. package/esm/utils/__tests__/api-requester.test.js +25 -2
  60. package/esm/utils/api-requester.js +25 -2
  61. package/esm/web-rtc-client.js +111 -67
  62. package/esm/websocket-client.js +28 -3
  63. package/lib/__tests__/api-client.test.js +70 -5
  64. package/lib/__tests__/web-rtc-client.test.js +111 -67
  65. package/lib/api/agentd.js +25 -2
  66. package/lib/api/amid.js +25 -2
  67. package/lib/api/application.js +25 -2
  68. package/lib/api/auth.js +25 -2
  69. package/lib/api/call-logd.js +32 -2
  70. package/lib/api/calld.js +35 -2
  71. package/lib/api/chatd.js +32 -2
  72. package/lib/api/confd.js +47 -5
  73. package/lib/api/ctid-ng.js +35 -2
  74. package/lib/api/dird.js +28 -2
  75. package/lib/api/webhookd.js +25 -2
  76. package/lib/api-client.js +70 -5
  77. package/lib/checker/Checker.js +113 -67
  78. package/lib/checker/checks/aor.js +70 -5
  79. package/lib/checker/checks/api.js +70 -5
  80. package/lib/checker/checks/index.js +113 -67
  81. package/lib/checker/checks/wazo-websocket.js +27 -2
  82. package/lib/checker/checks/webrtc-transport.js +111 -67
  83. package/lib/checker/checks/webrtc.js +111 -67
  84. package/lib/domain/AdHocAPIConference.js +70 -5
  85. package/lib/domain/Call.js +3 -0
  86. package/lib/domain/CallLog.js +7 -0
  87. package/lib/domain/ChatMessage.js +4 -0
  88. package/lib/domain/ChatRoom.js +3 -0
  89. package/lib/domain/Contact.js +3 -0
  90. package/lib/domain/Features.js +70 -5
  91. package/lib/domain/Meeting.js +17 -1
  92. package/lib/domain/Phone/CTIPhone.js +74 -5
  93. package/lib/domain/Phone/WebRTCPhone.js +50 -16
  94. package/lib/domain/Recording.js +3 -0
  95. package/lib/domain/Voicemail.js +3 -0
  96. package/lib/domain/__tests__/Call.test.js +3 -0
  97. package/lib/domain/__tests__/CallLog.test.js +7 -0
  98. package/lib/domain/__tests__/Contact.test.js +3 -0
  99. package/lib/domain/__tests__/Voicemail.test.js +3 -0
  100. package/lib/index.js +147 -80
  101. package/lib/lib/WazoSessionDescriptionHandler.js +25 -40
  102. package/lib/service/CallApi.js +70 -5
  103. package/lib/service/IssueReporter.js +25 -2
  104. package/lib/service/__tests__/IssueReporter.test.js +25 -2
  105. package/lib/service/getApiClient.js +70 -5
  106. package/lib/simple/Auth.js +147 -80
  107. package/lib/simple/Configuration.js +147 -80
  108. package/lib/simple/Directory.js +70 -5
  109. package/lib/simple/Phone.js +147 -80
  110. package/lib/simple/Websocket.js +28 -2
  111. package/lib/simple/index.js +147 -80
  112. package/lib/simple/room/LocalParticipant.js +147 -80
  113. package/lib/simple/room/Participant.js +147 -80
  114. package/lib/simple/room/RemoteParticipant.js +147 -80
  115. package/lib/simple/room/Room.js +147 -80
  116. package/lib/simple/room/SipRoom.js +147 -80
  117. package/lib/simple/room/Stream.js +147 -80
  118. package/lib/simple/room/__tests__/RemoteParticipant.test.js +147 -80
  119. package/lib/simple/utils.js +147 -80
  120. package/lib/utils/__tests__/api-requester.test.js +25 -2
  121. package/lib/utils/api-requester.js +25 -2
  122. package/lib/web-rtc-client.js +111 -67
  123. package/lib/websocket-client.js +28 -2
  124. package/package.json +2 -2
  125. package/src/api/confd.js +5 -2
  126. package/src/domain/Call.js +3 -0
  127. package/src/domain/CallLog.js +4 -0
  128. package/src/domain/ChatMessage.js +4 -0
  129. package/src/domain/ChatRoom.js +3 -0
  130. package/src/domain/Contact.js +3 -0
  131. package/src/domain/Meeting.js +17 -1
  132. package/src/domain/Phone/CTIPhone.js +4 -0
  133. package/src/domain/Phone/Phone.js +2 -0
  134. package/src/domain/Phone/WebRTCPhone.js +25 -14
  135. package/src/domain/Recording.js +3 -0
  136. package/src/domain/Voicemail.js +3 -0
  137. package/src/lib/WazoSessionDescriptionHandler.js +1 -35
  138. package/src/service/IssueReporter.js +25 -2
  139. package/src/simple/Phone.js +5 -0
  140. package/src/types/WebSocketMessage.js +5 -1
  141. package/src/web-rtc-client.js +41 -24
  142. package/src/websocket-client.js +2 -0
@@ -159,6 +159,7 @@ class IssueReporter {
159
159
 
160
160
 
161
161
 
162
+
162
163
 
163
164
  constructor() {
164
165
  addLevelsTo(this);
@@ -170,12 +171,17 @@ class IssueReporter {
170
171
  this.bufferTimeout = null;
171
172
  this._boundProcessBuffer = this._processBuffer.bind(this);
172
173
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
174
+ this._callback = null;
173
175
  }
174
176
 
175
177
  init() {
176
178
  this._catchConsole();
177
179
  }
178
180
 
181
+ setCallback(cb ) {
182
+ this._callback = cb;
183
+ }
184
+
179
185
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
180
186
  this.remoteClientConfiguration = configuration;
181
187
  }
@@ -211,6 +217,7 @@ class IssueReporter {
211
217
 
212
218
  // Handle category label
213
219
  let category = null;
220
+ let skipSendToRemote = false;
214
221
  let extra = {};
215
222
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
216
223
  category = args[0].split('=')[1];
@@ -226,6 +233,7 @@ class IssueReporter {
226
233
  errorMessage: lastArg.message,
227
234
  errorStack: lastArg.stack,
228
235
  errorType: lastArg.constructor.name,
236
+ skipSendToRemote: lastArg.skipSendToRemote,
229
237
  };
230
238
  } else {
231
239
  extra = lastArg;
@@ -234,6 +242,11 @@ class IssueReporter {
234
242
  args.splice(1, 1);
235
243
  }
236
244
 
245
+ if (extra.skipSendToRemote) {
246
+ skipSendToRemote = true;
247
+ delete extra.skipSendToRemote;
248
+ }
249
+
237
250
  const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
238
251
  const message = args.join(', ');
239
252
  let consoleMessage = message;
@@ -254,7 +267,13 @@ class IssueReporter {
254
267
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
255
268
  oldMethod.apply(oldMethod, [date, consoleMessage]);
256
269
 
257
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
270
+ if (this._callback) {
271
+ this._callback(level, consoleMessage);
272
+ }
273
+
274
+ if (!skipSendToRemote) {
275
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
276
+ }
258
277
  }
259
278
 
260
279
  logRequest(url , options , response , start ) {
@@ -399,7 +418,11 @@ class IssueReporter {
399
418
  },
400
419
  // $FlowFixMe
401
420
  body,
402
- }).catch(() => {
421
+ }).catch((e ) => {
422
+ // $FlowFixMe
423
+ e.skipSendToRemote = true;
424
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
425
+
403
426
  setTimeout(() => {
404
427
  if (isArray) {
405
428
  payload = payload.map(message => {
@@ -1537,6 +1560,9 @@ class Contact {
1537
1560
  }
1538
1561
 
1539
1562
  static parseMany(response ) {
1563
+ if (!response || !response.results) {
1564
+ return [];
1565
+ }
1540
1566
  return response.results.map(r => Contact.parse(r, response.column_types));
1541
1567
  }
1542
1568
 
@@ -2643,11 +2669,27 @@ class Meeting {
2643
2669
  });
2644
2670
  }
2645
2671
 
2672
+ static parseMany(items ) {
2673
+ if (!items) {
2674
+ return [];
2675
+ }
2676
+ return items.map(plain => Meeting.parse(plain));
2677
+ }
2678
+
2646
2679
  static newFrom(meeting ) {
2647
2680
  return newFrom(meeting, Meeting);
2648
2681
  }
2649
2682
 
2650
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
2683
+ constructor({
2684
+ uuid,
2685
+ name,
2686
+ guestSipAuthorization,
2687
+ ownerUuids,
2688
+ port,
2689
+ uri,
2690
+ number,
2691
+ persistent,
2692
+ } = {}) {
2651
2693
  this.guestSipAuthorization = guestSipAuthorization;
2652
2694
  this.uri = uri;
2653
2695
  this.name = name;
@@ -2733,8 +2775,11 @@ var confdMethods = (client , baseUrl ) => ({
2733
2775
  }
2734
2776
  },
2735
2777
 
2736
- createMyMeeting: (name ) =>
2737
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2778
+ getMyMeetings: () =>
2779
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2780
+
2781
+ createMyMeeting: (name , persistent ) =>
2782
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2738
2783
 
2739
2784
  deleteMyMeeting: (meetingUuid ) =>
2740
2785
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2830,6 +2875,10 @@ class ChatMessage {
2830
2875
 
2831
2876
 
2832
2877
  static parseMany(plain ) {
2878
+ if (!plain || !plain.items) {
2879
+ return [];
2880
+ }
2881
+
2833
2882
  return plain.items.map(item => ChatMessage.parse(item));
2834
2883
  }
2835
2884
 
@@ -2939,6 +2988,9 @@ class Voicemail {
2939
2988
  }
2940
2989
 
2941
2990
  static parseMany(plain ) {
2991
+ if (!plain) {
2992
+ return [];
2993
+ }
2942
2994
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
2943
2995
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
2944
2996
 
@@ -3048,6 +3100,9 @@ class Call {
3048
3100
 
3049
3101
 
3050
3102
  static parseMany(plain ) {
3103
+ if (!plain) {
3104
+ return [];
3105
+ }
3051
3106
  return plain.map((plainCall ) => Call.parse(plainCall));
3052
3107
  }
3053
3108
 
@@ -3591,6 +3646,9 @@ class Recording {
3591
3646
 
3592
3647
 
3593
3648
  static parseMany(recordings = []) {
3649
+ if (!recordings) {
3650
+ return [];
3651
+ }
3594
3652
  return recordings.map(item => Recording.parse(item));
3595
3653
  }
3596
3654
 
@@ -3692,6 +3750,10 @@ class CallLog {
3692
3750
  }
3693
3751
 
3694
3752
  static parseMany(plain ) {
3753
+ if (!plain || !plain.items) {
3754
+ return [];
3755
+ }
3756
+
3695
3757
  return plain.items.map(item => CallLog.parse(item));
3696
3758
  }
3697
3759
 
@@ -4261,6 +4323,10 @@ class CTIPhone extends Emitter {
4261
4323
  return false;
4262
4324
  }
4263
4325
 
4326
+ hasAVideoTrack() {
4327
+ return false;
4328
+ }
4329
+
4264
4330
  getLocalStreamForCall() {
4265
4331
  return null;
4266
4332
  }
@@ -4654,6 +4720,9 @@ class ChatRoom {
4654
4720
 
4655
4721
 
4656
4722
  static parseMany(plain ) {
4723
+ if (!plain || !plain.items) {
4724
+ return [];
4725
+ }
4657
4726
  return plain.items.map(item => ChatRoom.parse(item));
4658
4727
  }
4659
4728
 
@@ -5899,10 +5968,6 @@ const getSrflxOrRelay = (candidates ) =>
5899
5968
  candidates
5900
5969
  .filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
5901
5970
 
5902
- const areCandidateValid = (candidates ) =>
5903
- getSrflxOrRelay(candidates)
5904
- .length > 0;
5905
-
5906
5971
  const getVideoDirection = (sdp ) => {
5907
5972
  const parsedSdp = sdpParser__default['default'].parse(sdp);
5908
5973
  const videoMedia = parsedSdp.media.find(media => media.type === 'video');
@@ -5955,8 +6020,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
5955
6020
  /* global RTCSessionDescriptionInit, navigator */
5956
6021
 
5957
6022
  const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
5958
- const MAX_WAIT_FOR_ICE_TRIES = 20;
5959
- const WAIT_FOR_ICE_TIMEOUT = 500;
5960
6023
 
5961
6024
  // Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
5962
6025
  const wazoMediaStreamFactory = (constraints ) => {
@@ -6146,38 +6209,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6146
6209
  this._peerConnection = undefined;
6147
6210
  }
6148
6211
 
6149
- async _waitForValidGatheredIce() {
6150
- let tries = 0;
6151
-
6152
- while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
6153
- wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
6154
- tries,
6155
- max: MAX_WAIT_FOR_ICE_TRIES,
6156
- });
6157
-
6158
- tries++;
6159
-
6160
- // eslint-disable-next-line no-await-in-loop
6161
- await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
6162
- }
6163
-
6164
- if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
6165
- const errorMsg = 'No valid candidates found, can\'t answer the call';
6166
- const error = new Error(errorMsg);
6167
- wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
6168
-
6169
- // Emit an error, because sip.js catches the exception and switch to status Terminated.
6170
- this.eventEmitter.emit('error', error);
6171
-
6172
- wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
6173
- }
6174
-
6175
- // eslint-disable-next-line
6176
- wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
6177
-
6178
- return this.getLocalSessionDescription();
6179
- }
6180
-
6181
6212
  // Overridden to send `inactive` in conference
6182
6213
  updateDirection(options , isConference = false,
6183
6214
  audioOnly = false) {
@@ -6970,7 +7001,9 @@ class WebRTCClient extends Emitter {
6970
7001
  const inviteOptions = {
6971
7002
  requestDelegate: {
6972
7003
  onAccept: (response ) => {
6973
- session.sessionDescriptionHandler.peerConnection.sfu = conference;
7004
+ if (session.sessionDescriptionHandler.peerConnection) {
7005
+ session.sessionDescriptionHandler.peerConnection.sfu = conference;
7006
+ }
6974
7007
  this._onAccepted(session, response.session, true);
6975
7008
  },
6976
7009
  onReject: (response ) => {
@@ -7842,6 +7875,16 @@ class WebRTCClient extends Emitter {
7842
7875
  return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
7843
7876
  }
7844
7877
 
7878
+ // Useful in a react-native environment when remoteMediaStream is not updated
7879
+ getRemoteVideoStreamFromPc(sessionId ) {
7880
+ const pc = this.getPeerConnection(sessionId);
7881
+ if (!pc) {
7882
+ return null;
7883
+ }
7884
+
7885
+ return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
7886
+ }
7887
+
7845
7888
  hasVideo(sessionId ) {
7846
7889
  return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
7847
7890
  }
@@ -8352,6 +8395,7 @@ class WebRTCClient extends Emitter {
8352
8395
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
8353
8396
 
8354
8397
  pc.oniceconnectionstatechange = () => {
8398
+ logger$8.info('on ice connection state changed', { state: pc.iceConnectionState });
8355
8399
  if (pc.iceConnectionState === 'disconnected') {
8356
8400
  this.eventEmitter.emit(ON_DISCONNECTED$1);
8357
8401
  }
@@ -8580,25 +8624,25 @@ class WebRTCClient extends Emitter {
8580
8624
 
8581
8625
  stats.forEach(report => {
8582
8626
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
8583
- audioBytesSent += report.bytesSent + report.headerBytesSent;
8627
+ audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8584
8628
  }
8585
8629
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
8586
- audioBytesSent += report.bytesSent;
8630
+ audioBytesSent += Number(report.bytesSent);
8587
8631
  }
8588
8632
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
8589
- videoBytesSent += report.bytesSent + report.headerBytesSent;
8633
+ videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8590
8634
  }
8591
8635
  if (report.type === 'inbound-rtp' && report.kind === 'audio') {
8592
- packetsLost += report.packetsLost;
8593
- networkStats.packetsReceived = report.packetsReceived;
8594
- audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
8636
+ packetsLost += Number(report.packetsLost);
8637
+ networkStats.packetsReceived = Number(report.packetsReceived);
8638
+ audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8595
8639
  }
8596
8640
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
8597
- videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
8641
+ videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8598
8642
  }
8599
8643
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
8600
8644
  if ('framesPerSecond' in report) {
8601
- networkStats.framesPerSecond = report.framesPerSecond;
8645
+ networkStats.framesPerSecond = Number(report.framesPerSecond);
8602
8646
  }
8603
8647
  if ('framerateMean' in report) {
8604
8648
  // framerateMean is only available in FF
@@ -8606,32 +8650,36 @@ class WebRTCClient extends Emitter {
8606
8650
  }
8607
8651
  }
8608
8652
  if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
8609
- packetsLost += report.packetsLost;
8610
- networkStats.roundTripTime = report.roundTripTime;
8611
- networkStats.jitter = report.jitter;
8653
+ packetsLost += Number(report.packetsLost);
8654
+ networkStats.roundTripTime = Number(report.roundTripTime);
8655
+ networkStats.jitter = Number(report.jitter);
8612
8656
  }
8613
8657
  if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
8614
- packetsLost += report.packetsLost;
8658
+ packetsLost += Number(report.packetsLost);
8615
8659
  }
8616
8660
  if (report.type === 'transport') {
8617
- transportSent += report.bytesSent;
8618
- transportReceived += report.bytesReceived;
8661
+ transportSent += Number(report.bytesSent);
8662
+ transportReceived += Number(report.bytesReceived);
8619
8663
  }
8620
8664
  });
8621
8665
 
8622
8666
  networkStats.packetsLost = packetsLost;
8623
- networkStats.audioBytesSent = audioBytesSent;
8667
+ networkStats.totalAudioBytesSent = audioBytesSent;
8668
+ networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8669
+ networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8624
8670
  networkStats.audioBytesReceived = audioBytesReceived;
8625
- networkStats.videoBytesSent = videoBytesSent;
8626
- networkStats.videoBytesReceived = videoBytesReceived;
8671
+ networkStats.totalVideoBytesSent = videoBytesSent;
8672
+ networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8673
+ networkStats.totalVideoBytesReceived = videoBytesReceived;
8674
+ networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
8675
+ networkStats.totalTransportSent = transportSent - lastTransportSent;
8627
8676
  networkStats.transportSent = transportSent;
8628
- networkStats.transportReceived = transportReceived;
8677
+ networkStats.totalTransportReceived = transportReceived;
8678
+ networkStats.transportReceived = transportReceived - lastTransportReceived;
8629
8679
 
8630
- const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
8631
- + (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
8632
- + (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
8633
-
8634
- networkStats.bandwidth = bandwidth;
8680
+ networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
8681
+ + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8682
+ + networkStats.transportSent;
8635
8683
 
8636
8684
  this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8637
8685
  this.sessionNetworkStats[sessionId].push(networkStats);
@@ -9013,7 +9061,10 @@ class WebRTCPhone extends Emitter {
9013
9061
 
9014
9062
  onCancel(message);
9015
9063
  const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
9016
- this.eventEmitter.emit(ON_CALL_CANCELED, this._createCallSession(sipSession), elsewhere);
9064
+ const callSession = this._createCallSession(sipSession);
9065
+ delete this.callSessions[callSession.getId()];
9066
+
9067
+ this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
9017
9068
  };
9018
9069
  } else if (sipSession instanceof invitation.Invitation) {
9019
9070
  console.warn('sipSession._onCancel not found, please update the wazo SDK accordingly');
@@ -9042,9 +9093,11 @@ class WebRTCPhone extends Emitter {
9042
9093
  case sessionState.SessionState.Terminated: {
9043
9094
  logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9044
9095
 
9096
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
9097
+ const callSession = this._createCallSession(sipSession);
9045
9098
  const wasCurrentSession = this._onCallTerminated(sipSession);
9046
9099
 
9047
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
9100
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
9048
9101
  }
9049
9102
  }
9050
9103
  });
@@ -9192,18 +9245,20 @@ class WebRTCPhone extends Emitter {
9192
9245
  screenTrack,
9193
9246
  });
9194
9247
 
9195
- screenTrack.onended = () => {
9196
- logger$7.info('WebRTC phone - on screenshare ended', {
9197
- hadVideo,
9198
- id: this.getSipSessionId(sipSession),
9199
- screenTrack,
9200
- });
9248
+ if (screenTrack) {
9249
+ screenTrack.onended = () => {
9250
+ logger$7.info('WebRTC phone - on screenshare ended', {
9251
+ hadVideo,
9252
+ id: this.getSipSessionId(sipSession),
9253
+ screenTrack,
9254
+ });
9201
9255
 
9202
- this.eventEmitter.emit(
9203
- ON_SHARE_SCREEN_ENDING,
9204
- this._createCallSession(sipSession, callSession),
9205
- );
9206
- };
9256
+ this.eventEmitter.emit(
9257
+ ON_SHARE_SCREEN_ENDING,
9258
+ this._createCallSession(sipSession, callSession),
9259
+ );
9260
+ };
9261
+ }
9207
9262
 
9208
9263
  this.currentScreenShare = {
9209
9264
  stream: screenStream,
@@ -9992,6 +10047,10 @@ class WebRTCPhone extends Emitter {
9992
10047
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
9993
10048
  }
9994
10049
 
10050
+ getRemoteVideoStreamFromPc(callSession ) {
10051
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
10052
+ }
10053
+
9995
10054
  hasRemoteVideo(callSession ) {
9996
10055
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
9997
10056
  }
@@ -10675,6 +10734,11 @@ class Phone extends Emitter {
10675
10734
  return this.getRemoteVideoStream(callSession);
10676
10735
  }
10677
10736
 
10737
+ // Useful in a react-native environment when remoteMediaStream is not updated
10738
+ getRemoteVideoStreamFromPc(callSession ) {
10739
+ return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
10740
+ }
10741
+
10678
10742
  hasVideo(callSession ) {
10679
10743
  return this.phone ? this.phone.hasVideo(callSession) : false;
10680
10744
  }
@@ -10834,6 +10898,7 @@ const AGENT_PAUSED = 'agent_paused';
10834
10898
  const AGENT_UNPAUSED = 'agent_unpaused';
10835
10899
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10836
10900
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10901
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
10837
10902
 
10838
10903
  const BLACKLIST_EVENTS = [
10839
10904
  CHAT_MESSAGE_SENT,
@@ -11184,6 +11249,7 @@ WebSocketClient.eventLists = [
11184
11249
  AGENT_UNPAUSED,
11185
11250
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11186
11251
  CONFERENCE_ADHOC_DELETED,
11252
+ MEETING_USER_PROGRESS,
11187
11253
  ];
11188
11254
 
11189
11255
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -11254,6 +11320,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11254
11320
  AGENT_UNPAUSED: AGENT_UNPAUSED,
11255
11321
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11256
11322
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11323
+ MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
11257
11324
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
11258
11325
  'default': WebSocketClient
11259
11326
  });