@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
@@ -440,6 +440,7 @@ class IssueReporter {
440
440
 
441
441
 
442
442
 
443
+
443
444
 
444
445
  constructor() {
445
446
  addLevelsTo(this);
@@ -451,12 +452,17 @@ class IssueReporter {
451
452
  this.bufferTimeout = null;
452
453
  this._boundProcessBuffer = this._processBuffer.bind(this);
453
454
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
455
+ this._callback = null;
454
456
  }
455
457
 
456
458
  init() {
457
459
  this._catchConsole();
458
460
  }
459
461
 
462
+ setCallback(cb ) {
463
+ this._callback = cb;
464
+ }
465
+
460
466
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
461
467
  this.remoteClientConfiguration = configuration;
462
468
  }
@@ -492,6 +498,7 @@ class IssueReporter {
492
498
 
493
499
  // Handle category label
494
500
  let category = null;
501
+ let skipSendToRemote = false;
495
502
  let extra = {};
496
503
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
497
504
  category = args[0].split('=')[1];
@@ -507,6 +514,7 @@ class IssueReporter {
507
514
  errorMessage: lastArg.message,
508
515
  errorStack: lastArg.stack,
509
516
  errorType: lastArg.constructor.name,
517
+ skipSendToRemote: lastArg.skipSendToRemote,
510
518
  };
511
519
  } else {
512
520
  extra = lastArg;
@@ -515,6 +523,11 @@ class IssueReporter {
515
523
  args.splice(1, 1);
516
524
  }
517
525
 
526
+ if (extra.skipSendToRemote) {
527
+ skipSendToRemote = true;
528
+ delete extra.skipSendToRemote;
529
+ }
530
+
518
531
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
519
532
  const message = args.join(', ');
520
533
  let consoleMessage = message;
@@ -535,7 +548,13 @@ class IssueReporter {
535
548
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
536
549
  oldMethod.apply(oldMethod, [date, consoleMessage]);
537
550
 
538
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
551
+ if (this._callback) {
552
+ this._callback(level, consoleMessage);
553
+ }
554
+
555
+ if (!skipSendToRemote) {
556
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
557
+ }
539
558
  }
540
559
 
541
560
  logRequest(url , options , response , start ) {
@@ -680,7 +699,11 @@ class IssueReporter {
680
699
  },
681
700
  // $FlowFixMe
682
701
  body,
683
- }).catch(() => {
702
+ }).catch((e ) => {
703
+ // $FlowFixMe
704
+ e.skipSendToRemote = true;
705
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
706
+
684
707
  setTimeout(() => {
685
708
  if (isArray) {
686
709
  payload = payload.map(message => {
@@ -2659,11 +2682,24 @@ class Meeting {
2659
2682
  });
2660
2683
  }
2661
2684
 
2685
+ static parseMany(items ) {
2686
+ return items.map(plain => Meeting.parse(plain));
2687
+ }
2688
+
2662
2689
  static newFrom(meeting ) {
2663
2690
  return newFrom(meeting, Meeting);
2664
2691
  }
2665
2692
 
2666
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
2693
+ constructor({
2694
+ uuid,
2695
+ name,
2696
+ guestSipAuthorization,
2697
+ ownerUuids,
2698
+ port,
2699
+ uri,
2700
+ number,
2701
+ persistent,
2702
+ } = {}) {
2667
2703
  this.guestSipAuthorization = guestSipAuthorization;
2668
2704
  this.uri = uri;
2669
2705
  this.name = name;
@@ -2749,8 +2785,11 @@ var confdMethods = (client , baseUrl ) => ({
2749
2785
  }
2750
2786
  },
2751
2787
 
2752
- createMyMeeting: (name ) =>
2753
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2788
+ getMyMeetings: () =>
2789
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2790
+
2791
+ createMyMeeting: (name , persistent ) =>
2792
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2754
2793
 
2755
2794
  deleteMyMeeting: (meetingUuid ) =>
2756
2795
  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
  });
@@ -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
  });