@wazo/sdk 0.37.23 → 0.37.27

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 (118) hide show
  1. package/README.md +95 -57
  2. package/dist/wazo-sdk.js +3 -3
  3. package/esm/__tests__/api-client.test.js +12 -7
  4. package/esm/__tests__/web-rtc-client.test.js +47 -20
  5. package/esm/api/agentd.js +1 -1
  6. package/esm/api/amid.js +1 -1
  7. package/esm/api/application.js +1 -1
  8. package/esm/api/auth.js +1 -1
  9. package/esm/api/call-logd.js +1 -1
  10. package/esm/api/calld.js +1 -1
  11. package/esm/api/chatd.js +1 -1
  12. package/esm/api/confd.js +11 -6
  13. package/esm/api/ctid-ng.js +1 -1
  14. package/esm/api/dird.js +2 -2
  15. package/esm/api/webhookd.js +1 -1
  16. package/esm/api-client.js +12 -7
  17. package/esm/checker/Checker.js +47 -20
  18. package/esm/checker/checks/aor.js +12 -7
  19. package/esm/checker/checks/api.js +12 -7
  20. package/esm/checker/checks/index.js +47 -20
  21. package/esm/checker/checks/wazo-websocket.js +1 -1
  22. package/esm/checker/checks/webrtc-transport.js +47 -20
  23. package/esm/checker/checks/webrtc.js +47 -20
  24. package/esm/domain/AdHocAPIConference.js +12 -7
  25. package/esm/domain/Contact.js +1 -1
  26. package/esm/domain/Features.js +12 -7
  27. package/esm/domain/Meeting.js +12 -5
  28. package/esm/domain/Phone/CTIPhone.js +12 -7
  29. package/esm/domain/Phone/WebRTCPhone.js +34 -6
  30. package/esm/domain/__tests__/Contact.test.js +1 -1
  31. package/esm/domain/__tests__/Meeting.test.js +144 -0
  32. package/esm/index.js +80 -25
  33. package/esm/lib/WazoSessionDescriptionHandler.js +9 -4
  34. package/esm/service/CallApi.js +12 -7
  35. package/esm/service/IssueReporter.js +1 -1
  36. package/esm/service/__tests__/IssueReporter.test.js +1 -1
  37. package/esm/service/getApiClient.js +12 -7
  38. package/esm/simple/Auth.js +80 -25
  39. package/esm/simple/Configuration.js +80 -25
  40. package/esm/simple/Directory.js +12 -7
  41. package/esm/simple/Phone.js +80 -25
  42. package/esm/simple/Websocket.js +1 -1
  43. package/esm/simple/index.js +80 -25
  44. package/esm/simple/room/LocalParticipant.js +80 -25
  45. package/esm/simple/room/Participant.js +80 -25
  46. package/esm/simple/room/RemoteParticipant.js +80 -25
  47. package/esm/simple/room/Room.js +80 -25
  48. package/esm/simple/room/SipRoom.js +80 -25
  49. package/esm/simple/room/Stream.js +80 -25
  50. package/esm/simple/room/__tests__/RemoteParticipant.test.js +80 -25
  51. package/esm/simple/utils.js +80 -25
  52. package/esm/types/WebSocketMessage.js +1 -1
  53. package/esm/utils/__tests__/api-requester.test.js +1 -1
  54. package/esm/utils/api-requester.js +1 -1
  55. package/esm/web-rtc-client.js +47 -20
  56. package/esm/websocket-client.js +1 -1
  57. package/lib/__tests__/api-client.test.js +12 -7
  58. package/lib/__tests__/web-rtc-client.test.js +47 -20
  59. package/lib/api/agentd.js +1 -1
  60. package/lib/api/amid.js +1 -1
  61. package/lib/api/application.js +1 -1
  62. package/lib/api/auth.js +1 -1
  63. package/lib/api/call-logd.js +1 -1
  64. package/lib/api/calld.js +1 -1
  65. package/lib/api/chatd.js +1 -1
  66. package/lib/api/confd.js +11 -6
  67. package/lib/api/ctid-ng.js +1 -1
  68. package/lib/api/dird.js +2 -2
  69. package/lib/api/webhookd.js +1 -1
  70. package/lib/api-client.js +12 -7
  71. package/lib/checker/Checker.js +47 -20
  72. package/lib/checker/checks/aor.js +12 -7
  73. package/lib/checker/checks/api.js +12 -7
  74. package/lib/checker/checks/index.js +47 -20
  75. package/lib/checker/checks/wazo-websocket.js +1 -1
  76. package/lib/checker/checks/webrtc-transport.js +47 -20
  77. package/lib/checker/checks/webrtc.js +47 -20
  78. package/lib/domain/AdHocAPIConference.js +12 -7
  79. package/lib/domain/Contact.js +1 -1
  80. package/lib/domain/Features.js +12 -7
  81. package/lib/domain/Meeting.js +16 -5
  82. package/lib/domain/Phone/CTIPhone.js +12 -7
  83. package/lib/domain/Phone/WebRTCPhone.js +34 -6
  84. package/lib/domain/__tests__/Contact.test.js +1 -1
  85. package/lib/domain/__tests__/Meeting.test.js +150 -0
  86. package/lib/index.js +80 -25
  87. package/lib/lib/WazoSessionDescriptionHandler.js +9 -4
  88. package/lib/service/CallApi.js +12 -7
  89. package/lib/service/IssueReporter.js +1 -1
  90. package/lib/service/__tests__/IssueReporter.test.js +1 -1
  91. package/lib/service/getApiClient.js +12 -7
  92. package/lib/simple/Auth.js +80 -25
  93. package/lib/simple/Configuration.js +80 -25
  94. package/lib/simple/Directory.js +12 -7
  95. package/lib/simple/Phone.js +80 -25
  96. package/lib/simple/Websocket.js +1 -1
  97. package/lib/simple/index.js +80 -25
  98. package/lib/simple/room/LocalParticipant.js +80 -25
  99. package/lib/simple/room/Participant.js +80 -25
  100. package/lib/simple/room/RemoteParticipant.js +80 -25
  101. package/lib/simple/room/Room.js +80 -25
  102. package/lib/simple/room/SipRoom.js +80 -25
  103. package/lib/simple/room/Stream.js +80 -25
  104. package/lib/simple/room/__tests__/RemoteParticipant.test.js +80 -25
  105. package/lib/simple/utils.js +80 -25
  106. package/lib/types/WebSocketMessage.js +2 -0
  107. package/lib/utils/__tests__/api-requester.test.js +1 -1
  108. package/lib/utils/api-requester.js +1 -1
  109. package/lib/web-rtc-client.js +47 -20
  110. package/lib/websocket-client.js +1 -1
  111. package/package.json +1 -1
  112. package/src/domain/Contact.js +1 -1
  113. package/src/domain/Meeting.js +12 -5
  114. package/src/domain/Phone/WebRTCPhone.js +33 -5
  115. package/src/domain/__tests__/Meeting.test.js +50 -0
  116. package/src/lib/WazoSessionDescriptionHandler.js +8 -3
  117. package/src/utils/api-requester.js +1 -1
  118. package/src/web-rtc-client.js +27 -10
@@ -462,7 +462,7 @@ const logger$4 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
462
462
 
463
463
  // Use a function here to be able to mock it in tests
464
464
  const realFetch = () => {
465
- if (typeof document !== 'undefined') {
465
+ if (typeof document !== 'undefined' && window.fetch) {
466
466
  // Browser
467
467
  return window.fetch;
468
468
  }
@@ -1922,7 +1922,7 @@ class Contact {
1922
1922
  this[key] = old[key] || this[key];
1923
1923
  });
1924
1924
 
1925
- if (old.lineState && !this.lineState) {
1925
+ if (old.lineState) {
1926
1926
  this.lineState = old.lineState;
1927
1927
  }
1928
1928
 
@@ -2629,8 +2629,9 @@ class ExternalApp {
2629
2629
 
2630
2630
 
2631
2631
 
2632
-
2632
+
2633
2633
 
2634
+
2634
2635
 
2635
2636
 
2636
2637
  class Meeting {
@@ -2641,9 +2642,10 @@ class Meeting {
2641
2642
 
2642
2643
 
2643
2644
 
2644
-
2645
+
2645
2646
 
2646
2647
 
2648
+
2647
2649
 
2648
2650
  static parse(plain ) {
2649
2651
  return new Meeting({
@@ -2653,8 +2655,9 @@ class Meeting {
2653
2655
  ownerUuids: plain.owner_uuids,
2654
2656
  port: plain.port,
2655
2657
  uuid: plain.uuid,
2656
- number: plain.number,
2658
+ extension: plain.exten,
2657
2659
  persistent: plain.persistent,
2660
+ creationTime: moment(plain.creation_time).toDate(),
2658
2661
  });
2659
2662
  }
2660
2663
 
@@ -2676,8 +2679,9 @@ class Meeting {
2676
2679
  ownerUuids,
2677
2680
  port,
2678
2681
  uri,
2679
- number,
2682
+ extension,
2680
2683
  persistent,
2684
+ creationTime,
2681
2685
  } = {}) {
2682
2686
  this.guestSipAuthorization = guestSipAuthorization;
2683
2687
  this.uri = uri;
@@ -2685,8 +2689,9 @@ class Meeting {
2685
2689
  this.ownerUuids = ownerUuids;
2686
2690
  this.port = port;
2687
2691
  this.uuid = uuid;
2688
- this.number = number;
2692
+ this.extension = extension;
2689
2693
  this.persistent = persistent;
2694
+ this.creationTime = creationTime;
2690
2695
 
2691
2696
  // Useful to compare instead of instanceof with minified code
2692
2697
  this.type = 'Meeting';
@@ -5474,11 +5479,16 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5474
5479
 
5475
5480
  // $FlowFixMe
5476
5481
  setRemoteSessionDescription(sessionDescription ) {
5477
- const result = super.setRemoteSessionDescription(sessionDescription);
5482
+ try {
5483
+ const result = super.setRemoteSessionDescription(sessionDescription);
5478
5484
 
5479
- this.eventEmitter.emit('setDescription', sessionDescription);
5485
+ this.eventEmitter.emit('setDescription', sessionDescription);
5480
5486
 
5481
- return result;
5487
+ return result;
5488
+ } catch (error) {
5489
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
5490
+ throw error;
5491
+ }
5482
5492
  }
5483
5493
 
5484
5494
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -6285,7 +6295,7 @@ class WebRTCClient extends Emitter {
6285
6295
  }
6286
6296
 
6287
6297
  call(number , enableVideo , audioOnly = false, conference = false) {
6288
- logger$1.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
6298
+ logger$1.info('sdk webrtc creating call', { number, enableVideo, audioOnly, conference });
6289
6299
  const inviterOptions = {
6290
6300
  sessionDescriptionHandlerOptionsReInvite: {
6291
6301
  conference,
@@ -7361,6 +7371,7 @@ class WebRTCClient extends Emitter {
7361
7371
  const screenSharing = constraints && 'screen' in constraints ? constraints.screen : false;
7362
7372
  const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
7363
7373
  const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
7374
+ const mandatoryVideo = constraints && typeof constraints.video === 'object' ? constraints.video.mandatory : {};
7364
7375
 
7365
7376
  logger$1.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
7366
7377
 
@@ -7368,7 +7379,8 @@ class WebRTCClient extends Emitter {
7368
7379
  constraints: {
7369
7380
  // Exact constraint are not supported with `getDisplayMedia` and we must have a video=false in desktop screenshare
7370
7381
  audio: screenSharing ? !isDesktop : (withAudio ? this._getAudioConstraints() : false),
7371
- video: screenSharing ? (isDesktop ? ({ mandatory: { chromeMediaSource: 'desktop' } }) : { cursor: 'always' })
7382
+ video: screenSharing ? (isDesktop
7383
+ ? ({ mandatory: { chromeMediaSource: 'desktop', ...(mandatoryVideo || {}) } }) : { cursor: 'always' })
7372
7384
  : this._getVideoConstraints(enableVideo),
7373
7385
  screen: screenSharing,
7374
7386
  desktop: isDesktop,
@@ -7703,12 +7715,14 @@ class WebRTCClient extends Emitter {
7703
7715
 
7704
7716
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
7705
7717
 
7706
- pc.oniceconnectionstatechange = () => {
7707
- logger$1.info('on ice connection state changed', { state: pc.iceConnectionState });
7708
- if (pc.iceConnectionState === 'disconnected') {
7709
- this.eventEmitter.emit(ON_DISCONNECTED);
7710
- }
7711
- };
7718
+ if (pc) {
7719
+ pc.oniceconnectionstatechange = () => {
7720
+ logger$1.info('on ice connection state changed', { state: pc.iceConnectionState });
7721
+ if (pc.iceConnectionState === 'disconnected') {
7722
+ this.eventEmitter.emit(ON_DISCONNECTED);
7723
+ }
7724
+ };
7725
+ }
7712
7726
 
7713
7727
  if (withEvent) {
7714
7728
  this.eventEmitter.emit(ACCEPTED, session, sessionDialog);
@@ -7918,13 +7932,17 @@ class WebRTCClient extends Emitter {
7918
7932
  const nbStats = this.sessionNetworkStats[sessionId].length;
7919
7933
  const lastNetworkStats = this.sessionNetworkStats[sessionId][nbStats - 1];
7920
7934
  const lastAudioSent = lastNetworkStats ? lastNetworkStats.audioBytesSent : 0;
7935
+ const lastAudioContentSent = lastNetworkStats ? lastNetworkStats.audioContentSent : 0;
7921
7936
  const lastVideoSent = lastNetworkStats ? lastNetworkStats.videoBytesSent : 0;
7922
7937
  const lastAudioReceived = lastNetworkStats ? lastNetworkStats.audioBytesReceived : 0;
7938
+ const lastAudioContentReceived = lastNetworkStats ? lastNetworkStats.audioContentReceived : 0;
7923
7939
  const lastVideoReceived = lastNetworkStats ? lastNetworkStats.videoBytesReceived : 0;
7924
7940
  const lastTransportSent = lastNetworkStats ? lastNetworkStats.transportSent : 0;
7925
7941
  const lastTransportReceived = lastNetworkStats ? lastNetworkStats.transportReceived : 0;
7926
- let audioBytesSent = 0;
7927
- let audioBytesReceived = 0;
7942
+ let audioBytesSent = 0; // content + header
7943
+ let audioBytesReceived = 0; // content + header
7944
+ let audioContentSent = 0; // useful to detect blank call
7945
+ let audioContentReceived = 0;
7928
7946
  let videoBytesSent = 0;
7929
7947
  let videoBytesReceived = 0;
7930
7948
  let transportSent = 0;
@@ -7934,6 +7952,7 @@ class WebRTCClient extends Emitter {
7934
7952
  stats.forEach(report => {
7935
7953
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
7936
7954
  audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
7955
+ audioContentSent += Number(report.bytesSent);
7937
7956
  }
7938
7957
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
7939
7958
  audioBytesSent += Number(report.bytesSent);
@@ -7945,6 +7964,7 @@ class WebRTCClient extends Emitter {
7945
7964
  packetsLost += Number(report.packetsLost);
7946
7965
  networkStats.packetsReceived = Number(report.packetsReceived);
7947
7966
  audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
7967
+ audioContentReceived += Number(report.bytesReceived);
7948
7968
  }
7949
7969
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
7950
7970
  videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
@@ -7973,10 +7993,17 @@ class WebRTCClient extends Emitter {
7973
7993
  });
7974
7994
 
7975
7995
  networkStats.packetsLost = packetsLost;
7996
+
7976
7997
  networkStats.totalAudioBytesSent = audioBytesSent;
7977
7998
  networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
7978
7999
  networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
7979
8000
  networkStats.audioBytesReceived = audioBytesReceived;
8001
+
8002
+ networkStats.totalAudioContentSent = audioContentSent;
8003
+ networkStats.audioContentSent = audioContentSent - lastAudioContentSent;
8004
+ networkStats.totalAudioBytesReceived = audioContentReceived - lastAudioContentReceived;
8005
+ networkStats.audioContentReceived = audioContentReceived;
8006
+
7980
8007
  networkStats.totalVideoBytesSent = videoBytesSent;
7981
8008
  networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
7982
8009
  networkStats.totalVideoBytesReceived = videoBytesReceived;
@@ -444,7 +444,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
444
444
 
445
445
  // Use a function here to be able to mock it in tests
446
446
  const realFetch = () => {
447
- if (typeof document !== 'undefined') {
447
+ if (typeof document !== 'undefined' && window.fetch) {
448
448
  // Browser
449
449
  return window.fetch;
450
450
  }
@@ -1904,7 +1904,7 @@ class Contact {
1904
1904
  this[key] = old[key] || this[key];
1905
1905
  });
1906
1906
 
1907
- if (old.lineState && !this.lineState) {
1907
+ if (old.lineState) {
1908
1908
  this.lineState = old.lineState;
1909
1909
  }
1910
1910
 
@@ -2611,8 +2611,9 @@ class ExternalApp {
2611
2611
 
2612
2612
 
2613
2613
 
2614
-
2614
+
2615
2615
 
2616
+
2616
2617
 
2617
2618
 
2618
2619
  class Meeting {
@@ -2623,9 +2624,10 @@ class Meeting {
2623
2624
 
2624
2625
 
2625
2626
 
2626
-
2627
+
2627
2628
 
2628
2629
 
2630
+
2629
2631
 
2630
2632
  static parse(plain ) {
2631
2633
  return new Meeting({
@@ -2635,8 +2637,9 @@ class Meeting {
2635
2637
  ownerUuids: plain.owner_uuids,
2636
2638
  port: plain.port,
2637
2639
  uuid: plain.uuid,
2638
- number: plain.number,
2640
+ extension: plain.exten,
2639
2641
  persistent: plain.persistent,
2642
+ creationTime: moment(plain.creation_time).toDate(),
2640
2643
  });
2641
2644
  }
2642
2645
 
@@ -2658,8 +2661,9 @@ class Meeting {
2658
2661
  ownerUuids,
2659
2662
  port,
2660
2663
  uri,
2661
- number,
2664
+ extension,
2662
2665
  persistent,
2666
+ creationTime,
2663
2667
  } = {}) {
2664
2668
  this.guestSipAuthorization = guestSipAuthorization;
2665
2669
  this.uri = uri;
@@ -2667,8 +2671,9 @@ class Meeting {
2667
2671
  this.ownerUuids = ownerUuids;
2668
2672
  this.port = port;
2669
2673
  this.uuid = uuid;
2670
- this.number = number;
2674
+ this.extension = extension;
2671
2675
  this.persistent = persistent;
2676
+ this.creationTime = creationTime;
2672
2677
 
2673
2678
  // Useful to compare instead of instanceof with minified code
2674
2679
  this.type = 'Meeting';
@@ -444,7 +444,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
444
444
 
445
445
  // Use a function here to be able to mock it in tests
446
446
  const realFetch = () => {
447
- if (typeof document !== 'undefined') {
447
+ if (typeof document !== 'undefined' && window.fetch) {
448
448
  // Browser
449
449
  return window.fetch;
450
450
  }
@@ -1904,7 +1904,7 @@ class Contact {
1904
1904
  this[key] = old[key] || this[key];
1905
1905
  });
1906
1906
 
1907
- if (old.lineState && !this.lineState) {
1907
+ if (old.lineState) {
1908
1908
  this.lineState = old.lineState;
1909
1909
  }
1910
1910
 
@@ -2611,8 +2611,9 @@ class ExternalApp {
2611
2611
 
2612
2612
 
2613
2613
 
2614
-
2614
+
2615
2615
 
2616
+
2616
2617
 
2617
2618
 
2618
2619
  class Meeting {
@@ -2623,9 +2624,10 @@ class Meeting {
2623
2624
 
2624
2625
 
2625
2626
 
2626
-
2627
+
2627
2628
 
2628
2629
 
2630
+
2629
2631
 
2630
2632
  static parse(plain ) {
2631
2633
  return new Meeting({
@@ -2635,8 +2637,9 @@ class Meeting {
2635
2637
  ownerUuids: plain.owner_uuids,
2636
2638
  port: plain.port,
2637
2639
  uuid: plain.uuid,
2638
- number: plain.number,
2640
+ extension: plain.exten,
2639
2641
  persistent: plain.persistent,
2642
+ creationTime: moment(plain.creation_time).toDate(),
2640
2643
  });
2641
2644
  }
2642
2645
 
@@ -2658,8 +2661,9 @@ class Meeting {
2658
2661
  ownerUuids,
2659
2662
  port,
2660
2663
  uri,
2661
- number,
2664
+ extension,
2662
2665
  persistent,
2666
+ creationTime,
2663
2667
  } = {}) {
2664
2668
  this.guestSipAuthorization = guestSipAuthorization;
2665
2669
  this.uri = uri;
@@ -2667,8 +2671,9 @@ class Meeting {
2667
2671
  this.ownerUuids = ownerUuids;
2668
2672
  this.port = port;
2669
2673
  this.uuid = uuid;
2670
- this.number = number;
2674
+ this.extension = extension;
2671
2675
  this.persistent = persistent;
2676
+ this.creationTime = creationTime;
2672
2677
 
2673
2678
  // Useful to compare instead of instanceof with minified code
2674
2679
  this.type = 'Meeting';
@@ -462,7 +462,7 @@ const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
462
462
 
463
463
  // Use a function here to be able to mock it in tests
464
464
  const realFetch = () => {
465
- if (typeof document !== 'undefined') {
465
+ if (typeof document !== 'undefined' && window.fetch) {
466
466
  // Browser
467
467
  return window.fetch;
468
468
  }
@@ -1922,7 +1922,7 @@ class Contact {
1922
1922
  this[key] = old[key] || this[key];
1923
1923
  });
1924
1924
 
1925
- if (old.lineState && !this.lineState) {
1925
+ if (old.lineState) {
1926
1926
  this.lineState = old.lineState;
1927
1927
  }
1928
1928
 
@@ -2629,8 +2629,9 @@ class ExternalApp {
2629
2629
 
2630
2630
 
2631
2631
 
2632
-
2632
+
2633
2633
 
2634
+
2634
2635
 
2635
2636
 
2636
2637
  class Meeting {
@@ -2641,9 +2642,10 @@ class Meeting {
2641
2642
 
2642
2643
 
2643
2644
 
2644
-
2645
+
2645
2646
 
2646
2647
 
2648
+
2647
2649
 
2648
2650
  static parse(plain ) {
2649
2651
  return new Meeting({
@@ -2653,8 +2655,9 @@ class Meeting {
2653
2655
  ownerUuids: plain.owner_uuids,
2654
2656
  port: plain.port,
2655
2657
  uuid: plain.uuid,
2656
- number: plain.number,
2658
+ extension: plain.exten,
2657
2659
  persistent: plain.persistent,
2660
+ creationTime: moment(plain.creation_time).toDate(),
2658
2661
  });
2659
2662
  }
2660
2663
 
@@ -2676,8 +2679,9 @@ class Meeting {
2676
2679
  ownerUuids,
2677
2680
  port,
2678
2681
  uri,
2679
- number,
2682
+ extension,
2680
2683
  persistent,
2684
+ creationTime,
2681
2685
  } = {}) {
2682
2686
  this.guestSipAuthorization = guestSipAuthorization;
2683
2687
  this.uri = uri;
@@ -2685,8 +2689,9 @@ class Meeting {
2685
2689
  this.ownerUuids = ownerUuids;
2686
2690
  this.port = port;
2687
2691
  this.uuid = uuid;
2688
- this.number = number;
2692
+ this.extension = extension;
2689
2693
  this.persistent = persistent;
2694
+ this.creationTime = creationTime;
2690
2695
 
2691
2696
  // Useful to compare instead of instanceof with minified code
2692
2697
  this.type = 'Meeting';
@@ -5474,11 +5479,16 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5474
5479
 
5475
5480
  // $FlowFixMe
5476
5481
  setRemoteSessionDescription(sessionDescription ) {
5477
- const result = super.setRemoteSessionDescription(sessionDescription);
5482
+ try {
5483
+ const result = super.setRemoteSessionDescription(sessionDescription);
5478
5484
 
5479
- this.eventEmitter.emit('setDescription', sessionDescription);
5485
+ this.eventEmitter.emit('setDescription', sessionDescription);
5480
5486
 
5481
- return result;
5487
+ return result;
5488
+ } catch (error) {
5489
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
5490
+ throw error;
5491
+ }
5482
5492
  }
5483
5493
 
5484
5494
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -6285,7 +6295,7 @@ class WebRTCClient extends Emitter {
6285
6295
  }
6286
6296
 
6287
6297
  call(number , enableVideo , audioOnly = false, conference = false) {
6288
- logger.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
6298
+ logger.info('sdk webrtc creating call', { number, enableVideo, audioOnly, conference });
6289
6299
  const inviterOptions = {
6290
6300
  sessionDescriptionHandlerOptionsReInvite: {
6291
6301
  conference,
@@ -7361,6 +7371,7 @@ class WebRTCClient extends Emitter {
7361
7371
  const screenSharing = constraints && 'screen' in constraints ? constraints.screen : false;
7362
7372
  const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
7363
7373
  const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
7374
+ const mandatoryVideo = constraints && typeof constraints.video === 'object' ? constraints.video.mandatory : {};
7364
7375
 
7365
7376
  logger.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
7366
7377
 
@@ -7368,7 +7379,8 @@ class WebRTCClient extends Emitter {
7368
7379
  constraints: {
7369
7380
  // Exact constraint are not supported with `getDisplayMedia` and we must have a video=false in desktop screenshare
7370
7381
  audio: screenSharing ? !isDesktop : (withAudio ? this._getAudioConstraints() : false),
7371
- video: screenSharing ? (isDesktop ? ({ mandatory: { chromeMediaSource: 'desktop' } }) : { cursor: 'always' })
7382
+ video: screenSharing ? (isDesktop
7383
+ ? ({ mandatory: { chromeMediaSource: 'desktop', ...(mandatoryVideo || {}) } }) : { cursor: 'always' })
7372
7384
  : this._getVideoConstraints(enableVideo),
7373
7385
  screen: screenSharing,
7374
7386
  desktop: isDesktop,
@@ -7703,12 +7715,14 @@ class WebRTCClient extends Emitter {
7703
7715
 
7704
7716
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
7705
7717
 
7706
- pc.oniceconnectionstatechange = () => {
7707
- logger.info('on ice connection state changed', { state: pc.iceConnectionState });
7708
- if (pc.iceConnectionState === 'disconnected') {
7709
- this.eventEmitter.emit(ON_DISCONNECTED);
7710
- }
7711
- };
7718
+ if (pc) {
7719
+ pc.oniceconnectionstatechange = () => {
7720
+ logger.info('on ice connection state changed', { state: pc.iceConnectionState });
7721
+ if (pc.iceConnectionState === 'disconnected') {
7722
+ this.eventEmitter.emit(ON_DISCONNECTED);
7723
+ }
7724
+ };
7725
+ }
7712
7726
 
7713
7727
  if (withEvent) {
7714
7728
  this.eventEmitter.emit(ACCEPTED, session, sessionDialog);
@@ -7918,13 +7932,17 @@ class WebRTCClient extends Emitter {
7918
7932
  const nbStats = this.sessionNetworkStats[sessionId].length;
7919
7933
  const lastNetworkStats = this.sessionNetworkStats[sessionId][nbStats - 1];
7920
7934
  const lastAudioSent = lastNetworkStats ? lastNetworkStats.audioBytesSent : 0;
7935
+ const lastAudioContentSent = lastNetworkStats ? lastNetworkStats.audioContentSent : 0;
7921
7936
  const lastVideoSent = lastNetworkStats ? lastNetworkStats.videoBytesSent : 0;
7922
7937
  const lastAudioReceived = lastNetworkStats ? lastNetworkStats.audioBytesReceived : 0;
7938
+ const lastAudioContentReceived = lastNetworkStats ? lastNetworkStats.audioContentReceived : 0;
7923
7939
  const lastVideoReceived = lastNetworkStats ? lastNetworkStats.videoBytesReceived : 0;
7924
7940
  const lastTransportSent = lastNetworkStats ? lastNetworkStats.transportSent : 0;
7925
7941
  const lastTransportReceived = lastNetworkStats ? lastNetworkStats.transportReceived : 0;
7926
- let audioBytesSent = 0;
7927
- let audioBytesReceived = 0;
7942
+ let audioBytesSent = 0; // content + header
7943
+ let audioBytesReceived = 0; // content + header
7944
+ let audioContentSent = 0; // useful to detect blank call
7945
+ let audioContentReceived = 0;
7928
7946
  let videoBytesSent = 0;
7929
7947
  let videoBytesReceived = 0;
7930
7948
  let transportSent = 0;
@@ -7934,6 +7952,7 @@ class WebRTCClient extends Emitter {
7934
7952
  stats.forEach(report => {
7935
7953
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
7936
7954
  audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
7955
+ audioContentSent += Number(report.bytesSent);
7937
7956
  }
7938
7957
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
7939
7958
  audioBytesSent += Number(report.bytesSent);
@@ -7945,6 +7964,7 @@ class WebRTCClient extends Emitter {
7945
7964
  packetsLost += Number(report.packetsLost);
7946
7965
  networkStats.packetsReceived = Number(report.packetsReceived);
7947
7966
  audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
7967
+ audioContentReceived += Number(report.bytesReceived);
7948
7968
  }
7949
7969
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
7950
7970
  videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
@@ -7973,10 +7993,17 @@ class WebRTCClient extends Emitter {
7973
7993
  });
7974
7994
 
7975
7995
  networkStats.packetsLost = packetsLost;
7996
+
7976
7997
  networkStats.totalAudioBytesSent = audioBytesSent;
7977
7998
  networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
7978
7999
  networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
7979
8000
  networkStats.audioBytesReceived = audioBytesReceived;
8001
+
8002
+ networkStats.totalAudioContentSent = audioContentSent;
8003
+ networkStats.audioContentSent = audioContentSent - lastAudioContentSent;
8004
+ networkStats.totalAudioBytesReceived = audioContentReceived - lastAudioContentReceived;
8005
+ networkStats.audioContentReceived = audioContentReceived;
8006
+
7980
8007
  networkStats.totalVideoBytesSent = videoBytesSent;
7981
8008
  networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
7982
8009
  networkStats.totalVideoBytesReceived = videoBytesReceived;
@@ -39,7 +39,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
39
39
 
40
40
  // Use a function here to be able to mock it in tests
41
41
  const realFetch = () => {
42
- if (typeof document !== 'undefined') {
42
+ if (typeof document !== 'undefined' && window.fetch) {
43
43
  // Browser
44
44
  return window.fetch;
45
45
  }