@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
@@ -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 => {
@@ -1553,6 +1576,9 @@ class Contact {
1553
1576
  }
1554
1577
 
1555
1578
  static parseMany(response ) {
1579
+ if (!response || !response.results) {
1580
+ return [];
1581
+ }
1556
1582
  return response.results.map(r => Contact.parse(r, response.column_types));
1557
1583
  }
1558
1584
 
@@ -2659,11 +2685,27 @@ class Meeting {
2659
2685
  });
2660
2686
  }
2661
2687
 
2688
+ static parseMany(items ) {
2689
+ if (!items) {
2690
+ return [];
2691
+ }
2692
+ return items.map(plain => Meeting.parse(plain));
2693
+ }
2694
+
2662
2695
  static newFrom(meeting ) {
2663
2696
  return newFrom(meeting, Meeting);
2664
2697
  }
2665
2698
 
2666
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
2699
+ constructor({
2700
+ uuid,
2701
+ name,
2702
+ guestSipAuthorization,
2703
+ ownerUuids,
2704
+ port,
2705
+ uri,
2706
+ number,
2707
+ persistent,
2708
+ } = {}) {
2667
2709
  this.guestSipAuthorization = guestSipAuthorization;
2668
2710
  this.uri = uri;
2669
2711
  this.name = name;
@@ -2749,8 +2791,11 @@ var confdMethods = (client , baseUrl ) => ({
2749
2791
  }
2750
2792
  },
2751
2793
 
2752
- createMyMeeting: (name ) =>
2753
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2794
+ getMyMeetings: () =>
2795
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2796
+
2797
+ createMyMeeting: (name , persistent ) =>
2798
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2754
2799
 
2755
2800
  deleteMyMeeting: (meetingUuid ) =>
2756
2801
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2846,6 +2891,10 @@ class ChatMessage {
2846
2891
 
2847
2892
 
2848
2893
  static parseMany(plain ) {
2894
+ if (!plain || !plain.items) {
2895
+ return [];
2896
+ }
2897
+
2849
2898
  return plain.items.map(item => ChatMessage.parse(item));
2850
2899
  }
2851
2900
 
@@ -2955,6 +3004,9 @@ class Voicemail {
2955
3004
  }
2956
3005
 
2957
3006
  static parseMany(plain ) {
3007
+ if (!plain) {
3008
+ return [];
3009
+ }
2958
3010
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
2959
3011
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
2960
3012
 
@@ -3064,6 +3116,9 @@ class Call {
3064
3116
 
3065
3117
 
3066
3118
  static parseMany(plain ) {
3119
+ if (!plain) {
3120
+ return [];
3121
+ }
3067
3122
  return plain.map((plainCall ) => Call.parse(plainCall));
3068
3123
  }
3069
3124
 
@@ -3581,6 +3636,9 @@ class Recording {
3581
3636
 
3582
3637
 
3583
3638
  static parseMany(recordings = []) {
3639
+ if (!recordings) {
3640
+ return [];
3641
+ }
3584
3642
  return recordings.map(item => Recording.parse(item));
3585
3643
  }
3586
3644
 
@@ -3682,6 +3740,10 @@ class CallLog {
3682
3740
  }
3683
3741
 
3684
3742
  static parseMany(plain ) {
3743
+ if (!plain || !plain.items) {
3744
+ return [];
3745
+ }
3746
+
3685
3747
  return plain.items.map(item => CallLog.parse(item));
3686
3748
  }
3687
3749
 
@@ -4251,6 +4313,10 @@ class CTIPhone extends Emitter {
4251
4313
  return false;
4252
4314
  }
4253
4315
 
4316
+ hasAVideoTrack() {
4317
+ return false;
4318
+ }
4319
+
4254
4320
  getLocalStreamForCall() {
4255
4321
  return null;
4256
4322
  }
@@ -4644,6 +4710,9 @@ class ChatRoom {
4644
4710
 
4645
4711
 
4646
4712
  static parseMany(plain ) {
4713
+ if (!plain || !plain.items) {
4714
+ return [];
4715
+ }
4647
4716
  return plain.items.map(item => ChatRoom.parse(item));
4648
4717
  }
4649
4718
 
@@ -5889,10 +5958,6 @@ const getSrflxOrRelay = (candidates ) =>
5889
5958
  candidates
5890
5959
  .filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
5891
5960
 
5892
- const areCandidateValid = (candidates ) =>
5893
- getSrflxOrRelay(candidates)
5894
- .length > 0;
5895
-
5896
5961
  const getVideoDirection = (sdp ) => {
5897
5962
  const parsedSdp = sdpParser.parse(sdp);
5898
5963
  const videoMedia = parsedSdp.media.find(media => media.type === 'video');
@@ -5945,8 +6010,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
5945
6010
  /* global RTCSessionDescriptionInit, navigator */
5946
6011
 
5947
6012
  const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
5948
- const MAX_WAIT_FOR_ICE_TRIES = 20;
5949
- const WAIT_FOR_ICE_TIMEOUT = 500;
5950
6013
 
5951
6014
  // Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
5952
6015
  const wazoMediaStreamFactory = (constraints ) => {
@@ -6136,38 +6199,6 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
6136
6199
  this._peerConnection = undefined;
6137
6200
  }
6138
6201
 
6139
- async _waitForValidGatheredIce() {
6140
- let tries = 0;
6141
-
6142
- while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
6143
- wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
6144
- tries,
6145
- max: MAX_WAIT_FOR_ICE_TRIES,
6146
- });
6147
-
6148
- tries++;
6149
-
6150
- // eslint-disable-next-line no-await-in-loop
6151
- await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
6152
- }
6153
-
6154
- if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
6155
- const errorMsg = 'No valid candidates found, can\'t answer the call';
6156
- const error = new Error(errorMsg);
6157
- wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
6158
-
6159
- // Emit an error, because sip.js catches the exception and switch to status Terminated.
6160
- this.eventEmitter.emit('error', error);
6161
-
6162
- wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
6163
- }
6164
-
6165
- // eslint-disable-next-line
6166
- wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
6167
-
6168
- return this.getLocalSessionDescription();
6169
- }
6170
-
6171
6202
  // Overridden to send `inactive` in conference
6172
6203
  updateDirection(options , isConference = false,
6173
6204
  audioOnly = false) {
@@ -6960,7 +6991,9 @@ class WebRTCClient extends Emitter {
6960
6991
  const inviteOptions = {
6961
6992
  requestDelegate: {
6962
6993
  onAccept: (response ) => {
6963
- session.sessionDescriptionHandler.peerConnection.sfu = conference;
6994
+ if (session.sessionDescriptionHandler.peerConnection) {
6995
+ session.sessionDescriptionHandler.peerConnection.sfu = conference;
6996
+ }
6964
6997
  this._onAccepted(session, response.session, true);
6965
6998
  },
6966
6999
  onReject: (response ) => {
@@ -7832,6 +7865,16 @@ class WebRTCClient extends Emitter {
7832
7865
  return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
7833
7866
  }
7834
7867
 
7868
+ // Useful in a react-native environment when remoteMediaStream is not updated
7869
+ getRemoteVideoStreamFromPc(sessionId ) {
7870
+ const pc = this.getPeerConnection(sessionId);
7871
+ if (!pc) {
7872
+ return null;
7873
+ }
7874
+
7875
+ return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
7876
+ }
7877
+
7835
7878
  hasVideo(sessionId ) {
7836
7879
  return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
7837
7880
  }
@@ -8342,6 +8385,7 @@ class WebRTCClient extends Emitter {
8342
8385
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
8343
8386
 
8344
8387
  pc.oniceconnectionstatechange = () => {
8388
+ logger$8.info('on ice connection state changed', { state: pc.iceConnectionState });
8345
8389
  if (pc.iceConnectionState === 'disconnected') {
8346
8390
  this.eventEmitter.emit(ON_DISCONNECTED$1);
8347
8391
  }
@@ -8570,25 +8614,25 @@ class WebRTCClient extends Emitter {
8570
8614
 
8571
8615
  stats.forEach(report => {
8572
8616
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
8573
- audioBytesSent += report.bytesSent + report.headerBytesSent;
8617
+ audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8574
8618
  }
8575
8619
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
8576
- audioBytesSent += report.bytesSent;
8620
+ audioBytesSent += Number(report.bytesSent);
8577
8621
  }
8578
8622
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
8579
- videoBytesSent += report.bytesSent + report.headerBytesSent;
8623
+ videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8580
8624
  }
8581
8625
  if (report.type === 'inbound-rtp' && report.kind === 'audio') {
8582
- packetsLost += report.packetsLost;
8583
- networkStats.packetsReceived = report.packetsReceived;
8584
- audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
8626
+ packetsLost += Number(report.packetsLost);
8627
+ networkStats.packetsReceived = Number(report.packetsReceived);
8628
+ audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8585
8629
  }
8586
8630
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
8587
- videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
8631
+ videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8588
8632
  }
8589
8633
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
8590
8634
  if ('framesPerSecond' in report) {
8591
- networkStats.framesPerSecond = report.framesPerSecond;
8635
+ networkStats.framesPerSecond = Number(report.framesPerSecond);
8592
8636
  }
8593
8637
  if ('framerateMean' in report) {
8594
8638
  // framerateMean is only available in FF
@@ -8596,32 +8640,36 @@ class WebRTCClient extends Emitter {
8596
8640
  }
8597
8641
  }
8598
8642
  if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
8599
- packetsLost += report.packetsLost;
8600
- networkStats.roundTripTime = report.roundTripTime;
8601
- networkStats.jitter = report.jitter;
8643
+ packetsLost += Number(report.packetsLost);
8644
+ networkStats.roundTripTime = Number(report.roundTripTime);
8645
+ networkStats.jitter = Number(report.jitter);
8602
8646
  }
8603
8647
  if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
8604
- packetsLost += report.packetsLost;
8648
+ packetsLost += Number(report.packetsLost);
8605
8649
  }
8606
8650
  if (report.type === 'transport') {
8607
- transportSent += report.bytesSent;
8608
- transportReceived += report.bytesReceived;
8651
+ transportSent += Number(report.bytesSent);
8652
+ transportReceived += Number(report.bytesReceived);
8609
8653
  }
8610
8654
  });
8611
8655
 
8612
8656
  networkStats.packetsLost = packetsLost;
8613
- networkStats.audioBytesSent = audioBytesSent;
8657
+ networkStats.totalAudioBytesSent = audioBytesSent;
8658
+ networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8659
+ networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8614
8660
  networkStats.audioBytesReceived = audioBytesReceived;
8615
- networkStats.videoBytesSent = videoBytesSent;
8616
- networkStats.videoBytesReceived = videoBytesReceived;
8661
+ networkStats.totalVideoBytesSent = videoBytesSent;
8662
+ networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8663
+ networkStats.totalVideoBytesReceived = videoBytesReceived;
8664
+ networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
8665
+ networkStats.totalTransportSent = transportSent - lastTransportSent;
8617
8666
  networkStats.transportSent = transportSent;
8618
- networkStats.transportReceived = transportReceived;
8667
+ networkStats.totalTransportReceived = transportReceived;
8668
+ networkStats.transportReceived = transportReceived - lastTransportReceived;
8619
8669
 
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;
8670
+ networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
8671
+ + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8672
+ + networkStats.transportSent;
8625
8673
 
8626
8674
  this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8627
8675
  this.sessionNetworkStats[sessionId].push(networkStats);
@@ -9003,7 +9051,10 @@ class WebRTCPhone extends Emitter {
9003
9051
 
9004
9052
  onCancel(message);
9005
9053
  const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
9006
- this.eventEmitter.emit(ON_CALL_CANCELED, this._createCallSession(sipSession), elsewhere);
9054
+ const callSession = this._createCallSession(sipSession);
9055
+ delete this.callSessions[callSession.getId()];
9056
+
9057
+ this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
9007
9058
  };
9008
9059
  } else if (sipSession instanceof Invitation) {
9009
9060
  console.warn('sipSession._onCancel not found, please update the wazo SDK accordingly');
@@ -9032,9 +9083,11 @@ class WebRTCPhone extends Emitter {
9032
9083
  case SessionState.Terminated: {
9033
9084
  logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9034
9085
 
9086
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
9087
+ const callSession = this._createCallSession(sipSession);
9035
9088
  const wasCurrentSession = this._onCallTerminated(sipSession);
9036
9089
 
9037
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
9090
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
9038
9091
  }
9039
9092
  }
9040
9093
  });
@@ -9182,18 +9235,20 @@ class WebRTCPhone extends Emitter {
9182
9235
  screenTrack,
9183
9236
  });
9184
9237
 
9185
- screenTrack.onended = () => {
9186
- logger$7.info('WebRTC phone - on screenshare ended', {
9187
- hadVideo,
9188
- id: this.getSipSessionId(sipSession),
9189
- screenTrack,
9190
- });
9238
+ if (screenTrack) {
9239
+ screenTrack.onended = () => {
9240
+ logger$7.info('WebRTC phone - on screenshare ended', {
9241
+ hadVideo,
9242
+ id: this.getSipSessionId(sipSession),
9243
+ screenTrack,
9244
+ });
9191
9245
 
9192
- this.eventEmitter.emit(
9193
- ON_SHARE_SCREEN_ENDING,
9194
- this._createCallSession(sipSession, callSession),
9195
- );
9196
- };
9246
+ this.eventEmitter.emit(
9247
+ ON_SHARE_SCREEN_ENDING,
9248
+ this._createCallSession(sipSession, callSession),
9249
+ );
9250
+ };
9251
+ }
9197
9252
 
9198
9253
  this.currentScreenShare = {
9199
9254
  stream: screenStream,
@@ -9982,6 +10037,10 @@ class WebRTCPhone extends Emitter {
9982
10037
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
9983
10038
  }
9984
10039
 
10040
+ getRemoteVideoStreamFromPc(callSession ) {
10041
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
10042
+ }
10043
+
9985
10044
  hasRemoteVideo(callSession ) {
9986
10045
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
9987
10046
  }
@@ -10665,6 +10724,11 @@ class Phone extends Emitter {
10665
10724
  return this.getRemoteVideoStream(callSession);
10666
10725
  }
10667
10726
 
10727
+ // Useful in a react-native environment when remoteMediaStream is not updated
10728
+ getRemoteVideoStreamFromPc(callSession ) {
10729
+ return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
10730
+ }
10731
+
10668
10732
  hasVideo(callSession ) {
10669
10733
  return this.phone ? this.phone.hasVideo(callSession) : false;
10670
10734
  }
@@ -10824,6 +10888,7 @@ const AGENT_PAUSED = 'agent_paused';
10824
10888
  const AGENT_UNPAUSED = 'agent_unpaused';
10825
10889
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10826
10890
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10891
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
10827
10892
 
10828
10893
  const BLACKLIST_EVENTS = [
10829
10894
  CHAT_MESSAGE_SENT,
@@ -11174,6 +11239,7 @@ WebSocketClient.eventLists = [
11174
11239
  AGENT_UNPAUSED,
11175
11240
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11176
11241
  CONFERENCE_ADHOC_DELETED,
11242
+ MEETING_USER_PROGRESS,
11177
11243
  ];
11178
11244
 
11179
11245
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -11244,6 +11310,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11244
11310
  AGENT_UNPAUSED: AGENT_UNPAUSED,
11245
11311
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11246
11312
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11313
+ MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
11247
11314
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
11248
11315
  'default': WebSocketClient
11249
11316
  });