@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
@@ -161,6 +161,7 @@ class IssueReporter {
161
161
 
162
162
 
163
163
 
164
+
164
165
 
165
166
  constructor() {
166
167
  addLevelsTo(this);
@@ -172,12 +173,17 @@ class IssueReporter {
172
173
  this.bufferTimeout = null;
173
174
  this._boundProcessBuffer = this._processBuffer.bind(this);
174
175
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
176
+ this._callback = null;
175
177
  }
176
178
 
177
179
  init() {
178
180
  this._catchConsole();
179
181
  }
180
182
 
183
+ setCallback(cb ) {
184
+ this._callback = cb;
185
+ }
186
+
181
187
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
182
188
  this.remoteClientConfiguration = configuration;
183
189
  }
@@ -213,6 +219,7 @@ class IssueReporter {
213
219
 
214
220
  // Handle category label
215
221
  let category = null;
222
+ let skipSendToRemote = false;
216
223
  let extra = {};
217
224
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
218
225
  category = args[0].split('=')[1];
@@ -228,6 +235,7 @@ class IssueReporter {
228
235
  errorMessage: lastArg.message,
229
236
  errorStack: lastArg.stack,
230
237
  errorType: lastArg.constructor.name,
238
+ skipSendToRemote: lastArg.skipSendToRemote,
231
239
  };
232
240
  } else {
233
241
  extra = lastArg;
@@ -236,6 +244,11 @@ class IssueReporter {
236
244
  args.splice(1, 1);
237
245
  }
238
246
 
247
+ if (extra.skipSendToRemote) {
248
+ skipSendToRemote = true;
249
+ delete extra.skipSendToRemote;
250
+ }
251
+
239
252
  const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
240
253
  const message = args.join(', ');
241
254
  let consoleMessage = message;
@@ -256,7 +269,13 @@ class IssueReporter {
256
269
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
257
270
  oldMethod.apply(oldMethod, [date, consoleMessage]);
258
271
 
259
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
272
+ if (this._callback) {
273
+ this._callback(level, consoleMessage);
274
+ }
275
+
276
+ if (!skipSendToRemote) {
277
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
278
+ }
260
279
  }
261
280
 
262
281
  logRequest(url , options , response , start ) {
@@ -401,7 +420,11 @@ class IssueReporter {
401
420
  },
402
421
  // $FlowFixMe
403
422
  body,
404
- }).catch(() => {
423
+ }).catch((e ) => {
424
+ // $FlowFixMe
425
+ e.skipSendToRemote = true;
426
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
427
+
405
428
  setTimeout(() => {
406
429
  if (isArray) {
407
430
  payload = payload.map(message => {
@@ -1539,6 +1562,9 @@ class Contact {
1539
1562
  }
1540
1563
 
1541
1564
  static parseMany(response ) {
1565
+ if (!response || !response.results) {
1566
+ return [];
1567
+ }
1542
1568
  return response.results.map(r => Contact.parse(r, response.column_types));
1543
1569
  }
1544
1570
 
@@ -2645,11 +2671,27 @@ class Meeting {
2645
2671
  });
2646
2672
  }
2647
2673
 
2674
+ static parseMany(items ) {
2675
+ if (!items) {
2676
+ return [];
2677
+ }
2678
+ return items.map(plain => Meeting.parse(plain));
2679
+ }
2680
+
2648
2681
  static newFrom(meeting ) {
2649
2682
  return newFrom(meeting, Meeting);
2650
2683
  }
2651
2684
 
2652
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
2685
+ constructor({
2686
+ uuid,
2687
+ name,
2688
+ guestSipAuthorization,
2689
+ ownerUuids,
2690
+ port,
2691
+ uri,
2692
+ number,
2693
+ persistent,
2694
+ } = {}) {
2653
2695
  this.guestSipAuthorization = guestSipAuthorization;
2654
2696
  this.uri = uri;
2655
2697
  this.name = name;
@@ -2735,8 +2777,11 @@ var confdMethods = (client , baseUrl ) => ({
2735
2777
  }
2736
2778
  },
2737
2779
 
2738
- createMyMeeting: (name ) =>
2739
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2780
+ getMyMeetings: () =>
2781
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2782
+
2783
+ createMyMeeting: (name , persistent ) =>
2784
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2740
2785
 
2741
2786
  deleteMyMeeting: (meetingUuid ) =>
2742
2787
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2832,6 +2877,10 @@ class ChatMessage {
2832
2877
 
2833
2878
 
2834
2879
  static parseMany(plain ) {
2880
+ if (!plain || !plain.items) {
2881
+ return [];
2882
+ }
2883
+
2835
2884
  return plain.items.map(item => ChatMessage.parse(item));
2836
2885
  }
2837
2886
 
@@ -2941,6 +2990,9 @@ class Voicemail {
2941
2990
  }
2942
2991
 
2943
2992
  static parseMany(plain ) {
2993
+ if (!plain) {
2994
+ return [];
2995
+ }
2944
2996
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
2945
2997
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
2946
2998
 
@@ -3050,6 +3102,9 @@ class Call {
3050
3102
 
3051
3103
 
3052
3104
  static parseMany(plain ) {
3105
+ if (!plain) {
3106
+ return [];
3107
+ }
3053
3108
  return plain.map((plainCall ) => Call.parse(plainCall));
3054
3109
  }
3055
3110
 
@@ -3593,6 +3648,9 @@ class Recording {
3593
3648
 
3594
3649
 
3595
3650
  static parseMany(recordings = []) {
3651
+ if (!recordings) {
3652
+ return [];
3653
+ }
3596
3654
  return recordings.map(item => Recording.parse(item));
3597
3655
  }
3598
3656
 
@@ -3694,6 +3752,10 @@ class CallLog {
3694
3752
  }
3695
3753
 
3696
3754
  static parseMany(plain ) {
3755
+ if (!plain || !plain.items) {
3756
+ return [];
3757
+ }
3758
+
3697
3759
  return plain.items.map(item => CallLog.parse(item));
3698
3760
  }
3699
3761
 
@@ -4263,6 +4325,10 @@ class CTIPhone extends Emitter {
4263
4325
  return false;
4264
4326
  }
4265
4327
 
4328
+ hasAVideoTrack() {
4329
+ return false;
4330
+ }
4331
+
4266
4332
  getLocalStreamForCall() {
4267
4333
  return null;
4268
4334
  }
@@ -4656,6 +4722,9 @@ class ChatRoom {
4656
4722
 
4657
4723
 
4658
4724
  static parseMany(plain ) {
4725
+ if (!plain || !plain.items) {
4726
+ return [];
4727
+ }
4659
4728
  return plain.items.map(item => ChatRoom.parse(item));
4660
4729
  }
4661
4730
 
@@ -5901,10 +5970,6 @@ const getSrflxOrRelay = (candidates ) =>
5901
5970
  candidates
5902
5971
  .filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
5903
5972
 
5904
- const areCandidateValid = (candidates ) =>
5905
- getSrflxOrRelay(candidates)
5906
- .length > 0;
5907
-
5908
5973
  const getVideoDirection = (sdp ) => {
5909
5974
  const parsedSdp = sdpParser__default['default'].parse(sdp);
5910
5975
  const videoMedia = parsedSdp.media.find(media => media.type === 'video');
@@ -5957,8 +6022,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
5957
6022
  /* global RTCSessionDescriptionInit, navigator */
5958
6023
 
5959
6024
  const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
5960
- const MAX_WAIT_FOR_ICE_TRIES = 20;
5961
- const WAIT_FOR_ICE_TIMEOUT = 500;
5962
6025
 
5963
6026
  // Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
5964
6027
  const wazoMediaStreamFactory = (constraints ) => {
@@ -6148,38 +6211,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6148
6211
  this._peerConnection = undefined;
6149
6212
  }
6150
6213
 
6151
- async _waitForValidGatheredIce() {
6152
- let tries = 0;
6153
-
6154
- while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
6155
- wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
6156
- tries,
6157
- max: MAX_WAIT_FOR_ICE_TRIES,
6158
- });
6159
-
6160
- tries++;
6161
-
6162
- // eslint-disable-next-line no-await-in-loop
6163
- await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
6164
- }
6165
-
6166
- if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
6167
- const errorMsg = 'No valid candidates found, can\'t answer the call';
6168
- const error = new Error(errorMsg);
6169
- wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
6170
-
6171
- // Emit an error, because sip.js catches the exception and switch to status Terminated.
6172
- this.eventEmitter.emit('error', error);
6173
-
6174
- wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
6175
- }
6176
-
6177
- // eslint-disable-next-line
6178
- wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
6179
-
6180
- return this.getLocalSessionDescription();
6181
- }
6182
-
6183
6214
  // Overridden to send `inactive` in conference
6184
6215
  updateDirection(options , isConference = false,
6185
6216
  audioOnly = false) {
@@ -6972,7 +7003,9 @@ class WebRTCClient extends Emitter {
6972
7003
  const inviteOptions = {
6973
7004
  requestDelegate: {
6974
7005
  onAccept: (response ) => {
6975
- session.sessionDescriptionHandler.peerConnection.sfu = conference;
7006
+ if (session.sessionDescriptionHandler.peerConnection) {
7007
+ session.sessionDescriptionHandler.peerConnection.sfu = conference;
7008
+ }
6976
7009
  this._onAccepted(session, response.session, true);
6977
7010
  },
6978
7011
  onReject: (response ) => {
@@ -7844,6 +7877,16 @@ class WebRTCClient extends Emitter {
7844
7877
  return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
7845
7878
  }
7846
7879
 
7880
+ // Useful in a react-native environment when remoteMediaStream is not updated
7881
+ getRemoteVideoStreamFromPc(sessionId ) {
7882
+ const pc = this.getPeerConnection(sessionId);
7883
+ if (!pc) {
7884
+ return null;
7885
+ }
7886
+
7887
+ return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
7888
+ }
7889
+
7847
7890
  hasVideo(sessionId ) {
7848
7891
  return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
7849
7892
  }
@@ -8354,6 +8397,7 @@ class WebRTCClient extends Emitter {
8354
8397
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
8355
8398
 
8356
8399
  pc.oniceconnectionstatechange = () => {
8400
+ logger$8.info('on ice connection state changed', { state: pc.iceConnectionState });
8357
8401
  if (pc.iceConnectionState === 'disconnected') {
8358
8402
  this.eventEmitter.emit(ON_DISCONNECTED$1);
8359
8403
  }
@@ -8582,25 +8626,25 @@ class WebRTCClient extends Emitter {
8582
8626
 
8583
8627
  stats.forEach(report => {
8584
8628
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
8585
- audioBytesSent += report.bytesSent + report.headerBytesSent;
8629
+ audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8586
8630
  }
8587
8631
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
8588
- audioBytesSent += report.bytesSent;
8632
+ audioBytesSent += Number(report.bytesSent);
8589
8633
  }
8590
8634
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
8591
- videoBytesSent += report.bytesSent + report.headerBytesSent;
8635
+ videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8592
8636
  }
8593
8637
  if (report.type === 'inbound-rtp' && report.kind === 'audio') {
8594
- packetsLost += report.packetsLost;
8595
- networkStats.packetsReceived = report.packetsReceived;
8596
- audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
8638
+ packetsLost += Number(report.packetsLost);
8639
+ networkStats.packetsReceived = Number(report.packetsReceived);
8640
+ audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8597
8641
  }
8598
8642
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
8599
- videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
8643
+ videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8600
8644
  }
8601
8645
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
8602
8646
  if ('framesPerSecond' in report) {
8603
- networkStats.framesPerSecond = report.framesPerSecond;
8647
+ networkStats.framesPerSecond = Number(report.framesPerSecond);
8604
8648
  }
8605
8649
  if ('framerateMean' in report) {
8606
8650
  // framerateMean is only available in FF
@@ -8608,32 +8652,36 @@ class WebRTCClient extends Emitter {
8608
8652
  }
8609
8653
  }
8610
8654
  if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
8611
- packetsLost += report.packetsLost;
8612
- networkStats.roundTripTime = report.roundTripTime;
8613
- networkStats.jitter = report.jitter;
8655
+ packetsLost += Number(report.packetsLost);
8656
+ networkStats.roundTripTime = Number(report.roundTripTime);
8657
+ networkStats.jitter = Number(report.jitter);
8614
8658
  }
8615
8659
  if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
8616
- packetsLost += report.packetsLost;
8660
+ packetsLost += Number(report.packetsLost);
8617
8661
  }
8618
8662
  if (report.type === 'transport') {
8619
- transportSent += report.bytesSent;
8620
- transportReceived += report.bytesReceived;
8663
+ transportSent += Number(report.bytesSent);
8664
+ transportReceived += Number(report.bytesReceived);
8621
8665
  }
8622
8666
  });
8623
8667
 
8624
8668
  networkStats.packetsLost = packetsLost;
8625
- networkStats.audioBytesSent = audioBytesSent;
8669
+ networkStats.totalAudioBytesSent = audioBytesSent;
8670
+ networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8671
+ networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8626
8672
  networkStats.audioBytesReceived = audioBytesReceived;
8627
- networkStats.videoBytesSent = videoBytesSent;
8628
- networkStats.videoBytesReceived = videoBytesReceived;
8673
+ networkStats.totalVideoBytesSent = videoBytesSent;
8674
+ networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8675
+ networkStats.totalVideoBytesReceived = videoBytesReceived;
8676
+ networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
8677
+ networkStats.totalTransportSent = transportSent - lastTransportSent;
8629
8678
  networkStats.transportSent = transportSent;
8630
- networkStats.transportReceived = transportReceived;
8679
+ networkStats.totalTransportReceived = transportReceived;
8680
+ networkStats.transportReceived = transportReceived - lastTransportReceived;
8631
8681
 
8632
- const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
8633
- + (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
8634
- + (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
8635
-
8636
- networkStats.bandwidth = bandwidth;
8682
+ networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
8683
+ + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8684
+ + networkStats.transportSent;
8637
8685
 
8638
8686
  this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8639
8687
  this.sessionNetworkStats[sessionId].push(networkStats);
@@ -9015,7 +9063,10 @@ class WebRTCPhone extends Emitter {
9015
9063
 
9016
9064
  onCancel(message);
9017
9065
  const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
9018
- this.eventEmitter.emit(ON_CALL_CANCELED, this._createCallSession(sipSession), elsewhere);
9066
+ const callSession = this._createCallSession(sipSession);
9067
+ delete this.callSessions[callSession.getId()];
9068
+
9069
+ this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
9019
9070
  };
9020
9071
  } else if (sipSession instanceof invitation.Invitation) {
9021
9072
  console.warn('sipSession._onCancel not found, please update the wazo SDK accordingly');
@@ -9044,9 +9095,11 @@ class WebRTCPhone extends Emitter {
9044
9095
  case sessionState.SessionState.Terminated: {
9045
9096
  logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9046
9097
 
9098
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
9099
+ const callSession = this._createCallSession(sipSession);
9047
9100
  const wasCurrentSession = this._onCallTerminated(sipSession);
9048
9101
 
9049
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
9102
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
9050
9103
  }
9051
9104
  }
9052
9105
  });
@@ -9194,18 +9247,20 @@ class WebRTCPhone extends Emitter {
9194
9247
  screenTrack,
9195
9248
  });
9196
9249
 
9197
- screenTrack.onended = () => {
9198
- logger$7.info('WebRTC phone - on screenshare ended', {
9199
- hadVideo,
9200
- id: this.getSipSessionId(sipSession),
9201
- screenTrack,
9202
- });
9250
+ if (screenTrack) {
9251
+ screenTrack.onended = () => {
9252
+ logger$7.info('WebRTC phone - on screenshare ended', {
9253
+ hadVideo,
9254
+ id: this.getSipSessionId(sipSession),
9255
+ screenTrack,
9256
+ });
9203
9257
 
9204
- this.eventEmitter.emit(
9205
- ON_SHARE_SCREEN_ENDING,
9206
- this._createCallSession(sipSession, callSession),
9207
- );
9208
- };
9258
+ this.eventEmitter.emit(
9259
+ ON_SHARE_SCREEN_ENDING,
9260
+ this._createCallSession(sipSession, callSession),
9261
+ );
9262
+ };
9263
+ }
9209
9264
 
9210
9265
  this.currentScreenShare = {
9211
9266
  stream: screenStream,
@@ -9994,6 +10049,10 @@ class WebRTCPhone extends Emitter {
9994
10049
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
9995
10050
  }
9996
10051
 
10052
+ getRemoteVideoStreamFromPc(callSession ) {
10053
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
10054
+ }
10055
+
9997
10056
  hasRemoteVideo(callSession ) {
9998
10057
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
9999
10058
  }
@@ -10677,6 +10736,11 @@ class Phone extends Emitter {
10677
10736
  return this.getRemoteVideoStream(callSession);
10678
10737
  }
10679
10738
 
10739
+ // Useful in a react-native environment when remoteMediaStream is not updated
10740
+ getRemoteVideoStreamFromPc(callSession ) {
10741
+ return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
10742
+ }
10743
+
10680
10744
  hasVideo(callSession ) {
10681
10745
  return this.phone ? this.phone.hasVideo(callSession) : false;
10682
10746
  }
@@ -10836,6 +10900,7 @@ const AGENT_PAUSED = 'agent_paused';
10836
10900
  const AGENT_UNPAUSED = 'agent_unpaused';
10837
10901
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10838
10902
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10903
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
10839
10904
 
10840
10905
  const BLACKLIST_EVENTS = [
10841
10906
  CHAT_MESSAGE_SENT,
@@ -11186,6 +11251,7 @@ WebSocketClient.eventLists = [
11186
11251
  AGENT_UNPAUSED,
11187
11252
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11188
11253
  CONFERENCE_ADHOC_DELETED,
11254
+ MEETING_USER_PROGRESS,
11189
11255
  ];
11190
11256
 
11191
11257
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -11256,6 +11322,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11256
11322
  AGENT_UNPAUSED: AGENT_UNPAUSED,
11257
11323
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11258
11324
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11325
+ MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
11259
11326
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
11260
11327
  'default': WebSocketClient
11261
11328
  });