@wazo/sdk 0.37.20 → 0.37.21

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 (110) hide show
  1. package/dist/wazo-sdk.js +5 -5
  2. package/esm/__tests__/api-client.test.js +44 -5
  3. package/esm/__tests__/web-rtc-client.test.js +70 -15
  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 +25 -2
  9. package/esm/api/calld.js +25 -2
  10. package/esm/api/chatd.js +25 -2
  11. package/esm/api/confd.js +44 -5
  12. package/esm/api/ctid-ng.js +25 -2
  13. package/esm/api/dird.js +25 -2
  14. package/esm/api/webhookd.js +25 -2
  15. package/esm/api-client.js +44 -5
  16. package/esm/checker/Checker.js +72 -15
  17. package/esm/checker/checks/aor.js +44 -5
  18. package/esm/checker/checks/api.js +44 -5
  19. package/esm/checker/checks/index.js +72 -15
  20. package/esm/checker/checks/wazo-websocket.js +27 -2
  21. package/esm/checker/checks/webrtc-transport.js +70 -15
  22. package/esm/checker/checks/webrtc.js +70 -15
  23. package/esm/domain/AdHocAPIConference.js +44 -5
  24. package/esm/domain/Features.js +44 -5
  25. package/esm/domain/Meeting.js +14 -1
  26. package/esm/domain/Phone/CTIPhone.js +44 -5
  27. package/esm/domain/Phone/WebRTCPhone.js +32 -3
  28. package/esm/index.js +85 -16
  29. package/esm/lib/WazoSessionDescriptionHandler.js +25 -2
  30. package/esm/service/CallApi.js +44 -5
  31. package/esm/service/IssueReporter.js +25 -2
  32. package/esm/service/__tests__/IssueReporter.test.js +25 -2
  33. package/esm/service/getApiClient.js +44 -5
  34. package/esm/simple/Auth.js +85 -16
  35. package/esm/simple/Configuration.js +85 -16
  36. package/esm/simple/Directory.js +44 -5
  37. package/esm/simple/Phone.js +85 -16
  38. package/esm/simple/Websocket.js +28 -2
  39. package/esm/simple/index.js +85 -16
  40. package/esm/simple/room/LocalParticipant.js +85 -16
  41. package/esm/simple/room/Participant.js +85 -16
  42. package/esm/simple/room/RemoteParticipant.js +85 -16
  43. package/esm/simple/room/Room.js +85 -16
  44. package/esm/simple/room/SipRoom.js +85 -16
  45. package/esm/simple/room/Stream.js +85 -16
  46. package/esm/simple/room/__tests__/RemoteParticipant.test.js +85 -16
  47. package/esm/simple/utils.js +85 -16
  48. package/esm/utils/__tests__/api-requester.test.js +25 -2
  49. package/esm/utils/api-requester.js +25 -2
  50. package/esm/web-rtc-client.js +70 -15
  51. package/esm/websocket-client.js +28 -3
  52. package/lib/__tests__/api-client.test.js +44 -5
  53. package/lib/__tests__/web-rtc-client.test.js +70 -15
  54. package/lib/api/agentd.js +25 -2
  55. package/lib/api/amid.js +25 -2
  56. package/lib/api/application.js +25 -2
  57. package/lib/api/auth.js +25 -2
  58. package/lib/api/call-logd.js +25 -2
  59. package/lib/api/calld.js +25 -2
  60. package/lib/api/chatd.js +25 -2
  61. package/lib/api/confd.js +44 -5
  62. package/lib/api/ctid-ng.js +25 -2
  63. package/lib/api/dird.js +25 -2
  64. package/lib/api/webhookd.js +25 -2
  65. package/lib/api-client.js +44 -5
  66. package/lib/checker/Checker.js +72 -15
  67. package/lib/checker/checks/aor.js +44 -5
  68. package/lib/checker/checks/api.js +44 -5
  69. package/lib/checker/checks/index.js +72 -15
  70. package/lib/checker/checks/wazo-websocket.js +27 -2
  71. package/lib/checker/checks/webrtc-transport.js +70 -15
  72. package/lib/checker/checks/webrtc.js +70 -15
  73. package/lib/domain/AdHocAPIConference.js +44 -5
  74. package/lib/domain/Features.js +44 -5
  75. package/lib/domain/Meeting.js +14 -1
  76. package/lib/domain/Phone/CTIPhone.js +44 -5
  77. package/lib/domain/Phone/WebRTCPhone.js +32 -3
  78. package/lib/index.js +85 -16
  79. package/lib/lib/WazoSessionDescriptionHandler.js +25 -2
  80. package/lib/service/CallApi.js +44 -5
  81. package/lib/service/IssueReporter.js +25 -2
  82. package/lib/service/__tests__/IssueReporter.test.js +25 -2
  83. package/lib/service/getApiClient.js +44 -5
  84. package/lib/simple/Auth.js +85 -16
  85. package/lib/simple/Configuration.js +85 -16
  86. package/lib/simple/Directory.js +44 -5
  87. package/lib/simple/Phone.js +85 -16
  88. package/lib/simple/Websocket.js +28 -2
  89. package/lib/simple/index.js +85 -16
  90. package/lib/simple/room/LocalParticipant.js +85 -16
  91. package/lib/simple/room/Participant.js +85 -16
  92. package/lib/simple/room/RemoteParticipant.js +85 -16
  93. package/lib/simple/room/Room.js +85 -16
  94. package/lib/simple/room/SipRoom.js +85 -16
  95. package/lib/simple/room/Stream.js +85 -16
  96. package/lib/simple/room/__tests__/RemoteParticipant.test.js +85 -16
  97. package/lib/simple/utils.js +85 -16
  98. package/lib/utils/__tests__/api-requester.test.js +25 -2
  99. package/lib/utils/api-requester.js +25 -2
  100. package/lib/web-rtc-client.js +70 -15
  101. package/lib/websocket-client.js +28 -2
  102. package/package.json +1 -1
  103. package/src/api/confd.js +5 -2
  104. package/src/domain/Meeting.js +14 -1
  105. package/src/domain/Phone/WebRTCPhone.js +7 -1
  106. package/src/service/IssueReporter.js +25 -2
  107. package/src/simple/Phone.js +5 -0
  108. package/src/types/WebSocketMessage.js +5 -1
  109. package/src/web-rtc-client.js +26 -10
  110. package/src/websocket-client.js +2 -0
@@ -149,6 +149,7 @@ class IssueReporter {
149
149
 
150
150
 
151
151
 
152
+
152
153
 
153
154
  constructor() {
154
155
  addLevelsTo(this);
@@ -160,12 +161,17 @@ class IssueReporter {
160
161
  this.bufferTimeout = null;
161
162
  this._boundProcessBuffer = this._processBuffer.bind(this);
162
163
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
164
+ this._callback = null;
163
165
  }
164
166
 
165
167
  init() {
166
168
  this._catchConsole();
167
169
  }
168
170
 
171
+ setCallback(cb ) {
172
+ this._callback = cb;
173
+ }
174
+
169
175
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
170
176
  this.remoteClientConfiguration = configuration;
171
177
  }
@@ -201,6 +207,7 @@ class IssueReporter {
201
207
 
202
208
  // Handle category label
203
209
  let category = null;
210
+ let skipSendToRemote = false;
204
211
  let extra = {};
205
212
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
206
213
  category = args[0].split('=')[1];
@@ -216,6 +223,7 @@ class IssueReporter {
216
223
  errorMessage: lastArg.message,
217
224
  errorStack: lastArg.stack,
218
225
  errorType: lastArg.constructor.name,
226
+ skipSendToRemote: lastArg.skipSendToRemote,
219
227
  };
220
228
  } else {
221
229
  extra = lastArg;
@@ -224,6 +232,11 @@ class IssueReporter {
224
232
  args.splice(1, 1);
225
233
  }
226
234
 
235
+ if (extra.skipSendToRemote) {
236
+ skipSendToRemote = true;
237
+ delete extra.skipSendToRemote;
238
+ }
239
+
227
240
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
228
241
  const message = args.join(', ');
229
242
  let consoleMessage = message;
@@ -244,7 +257,13 @@ class IssueReporter {
244
257
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
245
258
  oldMethod.apply(oldMethod, [date, consoleMessage]);
246
259
 
247
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
260
+ if (this._callback) {
261
+ this._callback(level, consoleMessage);
262
+ }
263
+
264
+ if (!skipSendToRemote) {
265
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
266
+ }
248
267
  }
249
268
 
250
269
  logRequest(url , options , response , start ) {
@@ -389,7 +408,11 @@ class IssueReporter {
389
408
  },
390
409
  // $FlowFixMe
391
410
  body,
392
- }).catch(() => {
411
+ }).catch((e ) => {
412
+ // $FlowFixMe
413
+ e.skipSendToRemote = true;
414
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
415
+
393
416
  setTimeout(() => {
394
417
  if (isArray) {
395
418
  payload = payload.map(message => {
@@ -2633,11 +2656,24 @@ class Meeting {
2633
2656
  });
2634
2657
  }
2635
2658
 
2659
+ static parseMany(items ) {
2660
+ return items.map(plain => Meeting.parse(plain));
2661
+ }
2662
+
2636
2663
  static newFrom(meeting ) {
2637
2664
  return newFrom(meeting, Meeting);
2638
2665
  }
2639
2666
 
2640
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
2667
+ constructor({
2668
+ uuid,
2669
+ name,
2670
+ guestSipAuthorization,
2671
+ ownerUuids,
2672
+ port,
2673
+ uri,
2674
+ number,
2675
+ persistent,
2676
+ } = {}) {
2641
2677
  this.guestSipAuthorization = guestSipAuthorization;
2642
2678
  this.uri = uri;
2643
2679
  this.name = name;
@@ -2723,8 +2759,11 @@ var confdMethods = (client , baseUrl ) => ({
2723
2759
  }
2724
2760
  },
2725
2761
 
2726
- createMyMeeting: (name ) =>
2727
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2762
+ getMyMeetings: () =>
2763
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2764
+
2765
+ createMyMeeting: (name , persistent ) =>
2766
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2728
2767
 
2729
2768
  deleteMyMeeting: (meetingUuid ) =>
2730
2769
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -6960,7 +6999,9 @@ class WebRTCClient extends Emitter {
6960
6999
  const inviteOptions = {
6961
7000
  requestDelegate: {
6962
7001
  onAccept: (response ) => {
6963
- session.sessionDescriptionHandler.peerConnection.sfu = conference;
7002
+ if (session.sessionDescriptionHandler.peerConnection) {
7003
+ session.sessionDescriptionHandler.peerConnection.sfu = conference;
7004
+ }
6964
7005
  this._onAccepted(session, response.session, true);
6965
7006
  },
6966
7007
  onReject: (response ) => {
@@ -7832,6 +7873,16 @@ class WebRTCClient extends Emitter {
7832
7873
  return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
7833
7874
  }
7834
7875
 
7876
+ // Useful in a react-native environment when remoteMediaStream is not updated
7877
+ getRemoteVideoStreamFromPc(sessionId ) {
7878
+ const pc = this.getPeerConnection(sessionId);
7879
+ if (!pc) {
7880
+ return null;
7881
+ }
7882
+
7883
+ return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
7884
+ }
7885
+
7835
7886
  hasVideo(sessionId ) {
7836
7887
  return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
7837
7888
  }
@@ -8610,18 +8661,22 @@ class WebRTCClient extends Emitter {
8610
8661
  });
8611
8662
 
8612
8663
  networkStats.packetsLost = packetsLost;
8613
- networkStats.audioBytesSent = audioBytesSent;
8664
+ networkStats.totalAudioBytesSent = audioBytesSent;
8665
+ networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8666
+ networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8614
8667
  networkStats.audioBytesReceived = audioBytesReceived;
8615
- networkStats.videoBytesSent = videoBytesSent;
8616
- networkStats.videoBytesReceived = videoBytesReceived;
8668
+ networkStats.totalVideoBytesSent = videoBytesSent;
8669
+ networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8670
+ networkStats.totalVideoBytesReceived = videoBytesReceived;
8671
+ networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
8672
+ networkStats.totalTransportSent = transportSent - lastTransportSent;
8617
8673
  networkStats.transportSent = transportSent;
8618
- networkStats.transportReceived = transportReceived;
8674
+ networkStats.totalTransportReceived = transportReceived;
8675
+ networkStats.transportReceived = transportReceived - lastTransportReceived;
8619
8676
 
8620
- const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
8621
- + (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
8622
- + (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
8623
-
8624
- networkStats.bandwidth = bandwidth;
8677
+ networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
8678
+ + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8679
+ + networkStats.transportSent;
8625
8680
 
8626
8681
  this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8627
8682
  this.sessionNetworkStats[sessionId].push(networkStats);
@@ -9032,9 +9087,11 @@ class WebRTCPhone extends Emitter {
9032
9087
  case SessionState.Terminated: {
9033
9088
  logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9034
9089
 
9090
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
9091
+ const callSession = this._createCallSession(sipSession);
9035
9092
  const wasCurrentSession = this._onCallTerminated(sipSession);
9036
9093
 
9037
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
9094
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
9038
9095
  }
9039
9096
  }
9040
9097
  });
@@ -9982,6 +10039,10 @@ class WebRTCPhone extends Emitter {
9982
10039
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
9983
10040
  }
9984
10041
 
10042
+ getRemoteVideoStreamFromPc(callSession ) {
10043
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
10044
+ }
10045
+
9985
10046
  hasRemoteVideo(callSession ) {
9986
10047
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
9987
10048
  }
@@ -10665,6 +10726,11 @@ class Phone extends Emitter {
10665
10726
  return this.getRemoteVideoStream(callSession);
10666
10727
  }
10667
10728
 
10729
+ // Useful in a react-native environment when remoteMediaStream is not updated
10730
+ getRemoteVideoStreamFromPc(callSession ) {
10731
+ return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
10732
+ }
10733
+
10668
10734
  hasVideo(callSession ) {
10669
10735
  return this.phone ? this.phone.hasVideo(callSession) : false;
10670
10736
  }
@@ -10824,6 +10890,7 @@ const AGENT_PAUSED = 'agent_paused';
10824
10890
  const AGENT_UNPAUSED = 'agent_unpaused';
10825
10891
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10826
10892
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10893
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
10827
10894
 
10828
10895
  const BLACKLIST_EVENTS = [
10829
10896
  CHAT_MESSAGE_SENT,
@@ -11174,6 +11241,7 @@ WebSocketClient.eventLists = [
11174
11241
  AGENT_UNPAUSED,
11175
11242
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11176
11243
  CONFERENCE_ADHOC_DELETED,
11244
+ MEETING_USER_PROGRESS,
11177
11245
  ];
11178
11246
 
11179
11247
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -11244,6 +11312,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11244
11312
  AGENT_UNPAUSED: AGENT_UNPAUSED,
11245
11313
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11246
11314
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11315
+ MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
11247
11316
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
11248
11317
  'default': WebSocketClient
11249
11318
  });
@@ -414,6 +414,7 @@ class IssueReporter {
414
414
 
415
415
 
416
416
 
417
+
417
418
 
418
419
  constructor() {
419
420
  addLevelsTo(this);
@@ -425,12 +426,17 @@ class IssueReporter {
425
426
  this.bufferTimeout = null;
426
427
  this._boundProcessBuffer = this._processBuffer.bind(this);
427
428
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
429
+ this._callback = null;
428
430
  }
429
431
 
430
432
  init() {
431
433
  this._catchConsole();
432
434
  }
433
435
 
436
+ setCallback(cb ) {
437
+ this._callback = cb;
438
+ }
439
+
434
440
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
435
441
  this.remoteClientConfiguration = configuration;
436
442
  }
@@ -466,6 +472,7 @@ class IssueReporter {
466
472
 
467
473
  // Handle category label
468
474
  let category = null;
475
+ let skipSendToRemote = false;
469
476
  let extra = {};
470
477
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
471
478
  category = args[0].split('=')[1];
@@ -481,6 +488,7 @@ class IssueReporter {
481
488
  errorMessage: lastArg.message,
482
489
  errorStack: lastArg.stack,
483
490
  errorType: lastArg.constructor.name,
491
+ skipSendToRemote: lastArg.skipSendToRemote,
484
492
  };
485
493
  } else {
486
494
  extra = lastArg;
@@ -489,6 +497,11 @@ class IssueReporter {
489
497
  args.splice(1, 1);
490
498
  }
491
499
 
500
+ if (extra.skipSendToRemote) {
501
+ skipSendToRemote = true;
502
+ delete extra.skipSendToRemote;
503
+ }
504
+
492
505
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
493
506
  const message = args.join(', ');
494
507
  let consoleMessage = message;
@@ -509,7 +522,13 @@ class IssueReporter {
509
522
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
510
523
  oldMethod.apply(oldMethod, [date, consoleMessage]);
511
524
 
512
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
525
+ if (this._callback) {
526
+ this._callback(level, consoleMessage);
527
+ }
528
+
529
+ if (!skipSendToRemote) {
530
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
531
+ }
513
532
  }
514
533
 
515
534
  logRequest(url , options , response , start ) {
@@ -654,7 +673,11 @@ class IssueReporter {
654
673
  },
655
674
  // $FlowFixMe
656
675
  body,
657
- }).catch(() => {
676
+ }).catch((e ) => {
677
+ // $FlowFixMe
678
+ e.skipSendToRemote = true;
679
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
680
+
658
681
  setTimeout(() => {
659
682
  if (isArray) {
660
683
  payload = payload.map(message => {
@@ -2633,11 +2656,24 @@ class Meeting {
2633
2656
  });
2634
2657
  }
2635
2658
 
2659
+ static parseMany(items ) {
2660
+ return items.map(plain => Meeting.parse(plain));
2661
+ }
2662
+
2636
2663
  static newFrom(meeting ) {
2637
2664
  return newFrom(meeting, Meeting);
2638
2665
  }
2639
2666
 
2640
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
2667
+ constructor({
2668
+ uuid,
2669
+ name,
2670
+ guestSipAuthorization,
2671
+ ownerUuids,
2672
+ port,
2673
+ uri,
2674
+ number,
2675
+ persistent,
2676
+ } = {}) {
2641
2677
  this.guestSipAuthorization = guestSipAuthorization;
2642
2678
  this.uri = uri;
2643
2679
  this.name = name;
@@ -2723,8 +2759,11 @@ var confdMethods = (client , baseUrl ) => ({
2723
2759
  }
2724
2760
  },
2725
2761
 
2726
- createMyMeeting: (name ) =>
2727
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2762
+ getMyMeetings: () =>
2763
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2764
+
2765
+ createMyMeeting: (name , persistent ) =>
2766
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2728
2767
 
2729
2768
  deleteMyMeeting: (meetingUuid ) =>
2730
2769
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -6960,7 +6999,9 @@ class WebRTCClient extends Emitter {
6960
6999
  const inviteOptions = {
6961
7000
  requestDelegate: {
6962
7001
  onAccept: (response ) => {
6963
- session.sessionDescriptionHandler.peerConnection.sfu = conference;
7002
+ if (session.sessionDescriptionHandler.peerConnection) {
7003
+ session.sessionDescriptionHandler.peerConnection.sfu = conference;
7004
+ }
6964
7005
  this._onAccepted(session, response.session, true);
6965
7006
  },
6966
7007
  onReject: (response ) => {
@@ -7832,6 +7873,16 @@ class WebRTCClient extends Emitter {
7832
7873
  return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
7833
7874
  }
7834
7875
 
7876
+ // Useful in a react-native environment when remoteMediaStream is not updated
7877
+ getRemoteVideoStreamFromPc(sessionId ) {
7878
+ const pc = this.getPeerConnection(sessionId);
7879
+ if (!pc) {
7880
+ return null;
7881
+ }
7882
+
7883
+ return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
7884
+ }
7885
+
7835
7886
  hasVideo(sessionId ) {
7836
7887
  return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
7837
7888
  }
@@ -8610,18 +8661,22 @@ class WebRTCClient extends Emitter {
8610
8661
  });
8611
8662
 
8612
8663
  networkStats.packetsLost = packetsLost;
8613
- networkStats.audioBytesSent = audioBytesSent;
8664
+ networkStats.totalAudioBytesSent = audioBytesSent;
8665
+ networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8666
+ networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8614
8667
  networkStats.audioBytesReceived = audioBytesReceived;
8615
- networkStats.videoBytesSent = videoBytesSent;
8616
- networkStats.videoBytesReceived = videoBytesReceived;
8668
+ networkStats.totalVideoBytesSent = videoBytesSent;
8669
+ networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8670
+ networkStats.totalVideoBytesReceived = videoBytesReceived;
8671
+ networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
8672
+ networkStats.totalTransportSent = transportSent - lastTransportSent;
8617
8673
  networkStats.transportSent = transportSent;
8618
- networkStats.transportReceived = transportReceived;
8674
+ networkStats.totalTransportReceived = transportReceived;
8675
+ networkStats.transportReceived = transportReceived - lastTransportReceived;
8619
8676
 
8620
- const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
8621
- + (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
8622
- + (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
8623
-
8624
- networkStats.bandwidth = bandwidth;
8677
+ networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
8678
+ + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8679
+ + networkStats.transportSent;
8625
8680
 
8626
8681
  this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8627
8682
  this.sessionNetworkStats[sessionId].push(networkStats);
@@ -9032,9 +9087,11 @@ class WebRTCPhone extends Emitter {
9032
9087
  case SessionState.Terminated: {
9033
9088
  logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9034
9089
 
9090
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
9091
+ const callSession = this._createCallSession(sipSession);
9035
9092
  const wasCurrentSession = this._onCallTerminated(sipSession);
9036
9093
 
9037
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
9094
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
9038
9095
  }
9039
9096
  }
9040
9097
  });
@@ -9982,6 +10039,10 @@ class WebRTCPhone extends Emitter {
9982
10039
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
9983
10040
  }
9984
10041
 
10042
+ getRemoteVideoStreamFromPc(callSession ) {
10043
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
10044
+ }
10045
+
9985
10046
  hasRemoteVideo(callSession ) {
9986
10047
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
9987
10048
  }
@@ -10665,6 +10726,11 @@ class Phone extends Emitter {
10665
10726
  return this.getRemoteVideoStream(callSession);
10666
10727
  }
10667
10728
 
10729
+ // Useful in a react-native environment when remoteMediaStream is not updated
10730
+ getRemoteVideoStreamFromPc(callSession ) {
10731
+ return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
10732
+ }
10733
+
10668
10734
  hasVideo(callSession ) {
10669
10735
  return this.phone ? this.phone.hasVideo(callSession) : false;
10670
10736
  }
@@ -10824,6 +10890,7 @@ const AGENT_PAUSED = 'agent_paused';
10824
10890
  const AGENT_UNPAUSED = 'agent_unpaused';
10825
10891
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10826
10892
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10893
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
10827
10894
 
10828
10895
  const BLACKLIST_EVENTS = [
10829
10896
  CHAT_MESSAGE_SENT,
@@ -11174,6 +11241,7 @@ WebSocketClient.eventLists = [
11174
11241
  AGENT_UNPAUSED,
11175
11242
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11176
11243
  CONFERENCE_ADHOC_DELETED,
11244
+ MEETING_USER_PROGRESS,
11177
11245
  ];
11178
11246
 
11179
11247
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -11244,6 +11312,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11244
11312
  AGENT_UNPAUSED: AGENT_UNPAUSED,
11245
11313
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11246
11314
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11315
+ MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
11247
11316
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
11248
11317
  'default': WebSocketClient
11249
11318
  });