@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
@@ -104,7 +104,7 @@ const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
104
104
 
105
105
  // Use a function here to be able to mock it in tests
106
106
  const realFetch = () => {
107
- if (typeof document !== 'undefined') {
107
+ if (typeof document !== 'undefined' && window.fetch) {
108
108
  // Browser
109
109
  return window.fetch;
110
110
  }
@@ -823,11 +823,16 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
823
823
 
824
824
  // $FlowFixMe
825
825
  setRemoteSessionDescription(sessionDescription ) {
826
- const result = super.setRemoteSessionDescription(sessionDescription);
826
+ try {
827
+ const result = super.setRemoteSessionDescription(sessionDescription);
827
828
 
828
- this.eventEmitter.emit('setDescription', sessionDescription);
829
+ this.eventEmitter.emit('setDescription', sessionDescription);
829
830
 
830
- return result;
831
+ return result;
832
+ } catch (error) {
833
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
834
+ throw error;
835
+ }
831
836
  }
832
837
 
833
838
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -2447,7 +2452,7 @@ class Contact {
2447
2452
  this[key] = old[key] || this[key];
2448
2453
  });
2449
2454
 
2450
- if (old.lineState && !this.lineState) {
2455
+ if (old.lineState) {
2451
2456
  this.lineState = old.lineState;
2452
2457
  }
2453
2458
 
@@ -3154,8 +3159,9 @@ class ExternalApp {
3154
3159
 
3155
3160
 
3156
3161
 
3157
-
3162
+
3158
3163
 
3164
+
3159
3165
 
3160
3166
 
3161
3167
  class Meeting {
@@ -3166,9 +3172,10 @@ class Meeting {
3166
3172
 
3167
3173
 
3168
3174
 
3169
-
3175
+
3170
3176
 
3171
3177
 
3178
+
3172
3179
 
3173
3180
  static parse(plain ) {
3174
3181
  return new Meeting({
@@ -3178,8 +3185,9 @@ class Meeting {
3178
3185
  ownerUuids: plain.owner_uuids,
3179
3186
  port: plain.port,
3180
3187
  uuid: plain.uuid,
3181
- number: plain.number,
3188
+ extension: plain.exten,
3182
3189
  persistent: plain.persistent,
3190
+ creationTime: moment(plain.creation_time).toDate(),
3183
3191
  });
3184
3192
  }
3185
3193
 
@@ -3201,8 +3209,9 @@ class Meeting {
3201
3209
  ownerUuids,
3202
3210
  port,
3203
3211
  uri,
3204
- number,
3212
+ extension,
3205
3213
  persistent,
3214
+ creationTime,
3206
3215
  } = {}) {
3207
3216
  this.guestSipAuthorization = guestSipAuthorization;
3208
3217
  this.uri = uri;
@@ -3210,8 +3219,9 @@ class Meeting {
3210
3219
  this.ownerUuids = ownerUuids;
3211
3220
  this.port = port;
3212
3221
  this.uuid = uuid;
3213
- this.number = number;
3222
+ this.extension = extension;
3214
3223
  this.persistent = persistent;
3224
+ this.creationTime = creationTime;
3215
3225
 
3216
3226
  // Useful to compare instead of instanceof with minified code
3217
3227
  this.type = 'Meeting';
@@ -5700,7 +5710,7 @@ class WebRTCClient extends Emitter {
5700
5710
  }
5701
5711
 
5702
5712
  call(number , enableVideo , audioOnly = false, conference = false) {
5703
- logger.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
5713
+ logger.info('sdk webrtc creating call', { number, enableVideo, audioOnly, conference });
5704
5714
  const inviterOptions = {
5705
5715
  sessionDescriptionHandlerOptionsReInvite: {
5706
5716
  conference,
@@ -6776,6 +6786,7 @@ class WebRTCClient extends Emitter {
6776
6786
  const screenSharing = constraints && 'screen' in constraints ? constraints.screen : false;
6777
6787
  const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
6778
6788
  const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
6789
+ const mandatoryVideo = constraints && typeof constraints.video === 'object' ? constraints.video.mandatory : {};
6779
6790
 
6780
6791
  logger.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
6781
6792
 
@@ -6783,7 +6794,8 @@ class WebRTCClient extends Emitter {
6783
6794
  constraints: {
6784
6795
  // Exact constraint are not supported with `getDisplayMedia` and we must have a video=false in desktop screenshare
6785
6796
  audio: screenSharing ? !isDesktop : (withAudio ? this._getAudioConstraints() : false),
6786
- video: screenSharing ? (isDesktop ? ({ mandatory: { chromeMediaSource: 'desktop' } }) : { cursor: 'always' })
6797
+ video: screenSharing ? (isDesktop
6798
+ ? ({ mandatory: { chromeMediaSource: 'desktop', ...(mandatoryVideo || {}) } }) : { cursor: 'always' })
6787
6799
  : this._getVideoConstraints(enableVideo),
6788
6800
  screen: screenSharing,
6789
6801
  desktop: isDesktop,
@@ -7118,12 +7130,14 @@ class WebRTCClient extends Emitter {
7118
7130
 
7119
7131
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
7120
7132
 
7121
- pc.oniceconnectionstatechange = () => {
7122
- logger.info('on ice connection state changed', { state: pc.iceConnectionState });
7123
- if (pc.iceConnectionState === 'disconnected') {
7124
- this.eventEmitter.emit(ON_DISCONNECTED);
7125
- }
7126
- };
7133
+ if (pc) {
7134
+ pc.oniceconnectionstatechange = () => {
7135
+ logger.info('on ice connection state changed', { state: pc.iceConnectionState });
7136
+ if (pc.iceConnectionState === 'disconnected') {
7137
+ this.eventEmitter.emit(ON_DISCONNECTED);
7138
+ }
7139
+ };
7140
+ }
7127
7141
 
7128
7142
  if (withEvent) {
7129
7143
  this.eventEmitter.emit(ACCEPTED, session, sessionDialog);
@@ -7333,13 +7347,17 @@ class WebRTCClient extends Emitter {
7333
7347
  const nbStats = this.sessionNetworkStats[sessionId].length;
7334
7348
  const lastNetworkStats = this.sessionNetworkStats[sessionId][nbStats - 1];
7335
7349
  const lastAudioSent = lastNetworkStats ? lastNetworkStats.audioBytesSent : 0;
7350
+ const lastAudioContentSent = lastNetworkStats ? lastNetworkStats.audioContentSent : 0;
7336
7351
  const lastVideoSent = lastNetworkStats ? lastNetworkStats.videoBytesSent : 0;
7337
7352
  const lastAudioReceived = lastNetworkStats ? lastNetworkStats.audioBytesReceived : 0;
7353
+ const lastAudioContentReceived = lastNetworkStats ? lastNetworkStats.audioContentReceived : 0;
7338
7354
  const lastVideoReceived = lastNetworkStats ? lastNetworkStats.videoBytesReceived : 0;
7339
7355
  const lastTransportSent = lastNetworkStats ? lastNetworkStats.transportSent : 0;
7340
7356
  const lastTransportReceived = lastNetworkStats ? lastNetworkStats.transportReceived : 0;
7341
- let audioBytesSent = 0;
7342
- let audioBytesReceived = 0;
7357
+ let audioBytesSent = 0; // content + header
7358
+ let audioBytesReceived = 0; // content + header
7359
+ let audioContentSent = 0; // useful to detect blank call
7360
+ let audioContentReceived = 0;
7343
7361
  let videoBytesSent = 0;
7344
7362
  let videoBytesReceived = 0;
7345
7363
  let transportSent = 0;
@@ -7349,6 +7367,7 @@ class WebRTCClient extends Emitter {
7349
7367
  stats.forEach(report => {
7350
7368
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
7351
7369
  audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
7370
+ audioContentSent += Number(report.bytesSent);
7352
7371
  }
7353
7372
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
7354
7373
  audioBytesSent += Number(report.bytesSent);
@@ -7360,6 +7379,7 @@ class WebRTCClient extends Emitter {
7360
7379
  packetsLost += Number(report.packetsLost);
7361
7380
  networkStats.packetsReceived = Number(report.packetsReceived);
7362
7381
  audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
7382
+ audioContentReceived += Number(report.bytesReceived);
7363
7383
  }
7364
7384
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
7365
7385
  videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
@@ -7388,10 +7408,17 @@ class WebRTCClient extends Emitter {
7388
7408
  });
7389
7409
 
7390
7410
  networkStats.packetsLost = packetsLost;
7411
+
7391
7412
  networkStats.totalAudioBytesSent = audioBytesSent;
7392
7413
  networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
7393
7414
  networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
7394
7415
  networkStats.audioBytesReceived = audioBytesReceived;
7416
+
7417
+ networkStats.totalAudioContentSent = audioContentSent;
7418
+ networkStats.audioContentSent = audioContentSent - lastAudioContentSent;
7419
+ networkStats.totalAudioBytesReceived = audioContentReceived - lastAudioContentReceived;
7420
+ networkStats.audioContentReceived = audioContentReceived;
7421
+
7395
7422
  networkStats.totalVideoBytesSent = videoBytesSent;
7396
7423
  networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
7397
7424
  networkStats.totalVideoBytesReceived = videoBytesReceived;
@@ -104,7 +104,7 @@ const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
104
104
 
105
105
  // Use a function here to be able to mock it in tests
106
106
  const realFetch = () => {
107
- if (typeof document !== 'undefined') {
107
+ if (typeof document !== 'undefined' && window.fetch) {
108
108
  // Browser
109
109
  return window.fetch;
110
110
  }
@@ -823,11 +823,16 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
823
823
 
824
824
  // $FlowFixMe
825
825
  setRemoteSessionDescription(sessionDescription ) {
826
- const result = super.setRemoteSessionDescription(sessionDescription);
826
+ try {
827
+ const result = super.setRemoteSessionDescription(sessionDescription);
827
828
 
828
- this.eventEmitter.emit('setDescription', sessionDescription);
829
+ this.eventEmitter.emit('setDescription', sessionDescription);
829
830
 
830
- return result;
831
+ return result;
832
+ } catch (error) {
833
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
834
+ throw error;
835
+ }
831
836
  }
832
837
 
833
838
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -2447,7 +2452,7 @@ class Contact {
2447
2452
  this[key] = old[key] || this[key];
2448
2453
  });
2449
2454
 
2450
- if (old.lineState && !this.lineState) {
2455
+ if (old.lineState) {
2451
2456
  this.lineState = old.lineState;
2452
2457
  }
2453
2458
 
@@ -3154,8 +3159,9 @@ class ExternalApp {
3154
3159
 
3155
3160
 
3156
3161
 
3157
-
3162
+
3158
3163
 
3164
+
3159
3165
 
3160
3166
 
3161
3167
  class Meeting {
@@ -3166,9 +3172,10 @@ class Meeting {
3166
3172
 
3167
3173
 
3168
3174
 
3169
-
3175
+
3170
3176
 
3171
3177
 
3178
+
3172
3179
 
3173
3180
  static parse(plain ) {
3174
3181
  return new Meeting({
@@ -3178,8 +3185,9 @@ class Meeting {
3178
3185
  ownerUuids: plain.owner_uuids,
3179
3186
  port: plain.port,
3180
3187
  uuid: plain.uuid,
3181
- number: plain.number,
3188
+ extension: plain.exten,
3182
3189
  persistent: plain.persistent,
3190
+ creationTime: moment(plain.creation_time).toDate(),
3183
3191
  });
3184
3192
  }
3185
3193
 
@@ -3201,8 +3209,9 @@ class Meeting {
3201
3209
  ownerUuids,
3202
3210
  port,
3203
3211
  uri,
3204
- number,
3212
+ extension,
3205
3213
  persistent,
3214
+ creationTime,
3206
3215
  } = {}) {
3207
3216
  this.guestSipAuthorization = guestSipAuthorization;
3208
3217
  this.uri = uri;
@@ -3210,8 +3219,9 @@ class Meeting {
3210
3219
  this.ownerUuids = ownerUuids;
3211
3220
  this.port = port;
3212
3221
  this.uuid = uuid;
3213
- this.number = number;
3222
+ this.extension = extension;
3214
3223
  this.persistent = persistent;
3224
+ this.creationTime = creationTime;
3215
3225
 
3216
3226
  // Useful to compare instead of instanceof with minified code
3217
3227
  this.type = 'Meeting';
@@ -5700,7 +5710,7 @@ class WebRTCClient extends Emitter {
5700
5710
  }
5701
5711
 
5702
5712
  call(number , enableVideo , audioOnly = false, conference = false) {
5703
- logger.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
5713
+ logger.info('sdk webrtc creating call', { number, enableVideo, audioOnly, conference });
5704
5714
  const inviterOptions = {
5705
5715
  sessionDescriptionHandlerOptionsReInvite: {
5706
5716
  conference,
@@ -6776,6 +6786,7 @@ class WebRTCClient extends Emitter {
6776
6786
  const screenSharing = constraints && 'screen' in constraints ? constraints.screen : false;
6777
6787
  const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
6778
6788
  const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
6789
+ const mandatoryVideo = constraints && typeof constraints.video === 'object' ? constraints.video.mandatory : {};
6779
6790
 
6780
6791
  logger.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
6781
6792
 
@@ -6783,7 +6794,8 @@ class WebRTCClient extends Emitter {
6783
6794
  constraints: {
6784
6795
  // Exact constraint are not supported with `getDisplayMedia` and we must have a video=false in desktop screenshare
6785
6796
  audio: screenSharing ? !isDesktop : (withAudio ? this._getAudioConstraints() : false),
6786
- video: screenSharing ? (isDesktop ? ({ mandatory: { chromeMediaSource: 'desktop' } }) : { cursor: 'always' })
6797
+ video: screenSharing ? (isDesktop
6798
+ ? ({ mandatory: { chromeMediaSource: 'desktop', ...(mandatoryVideo || {}) } }) : { cursor: 'always' })
6787
6799
  : this._getVideoConstraints(enableVideo),
6788
6800
  screen: screenSharing,
6789
6801
  desktop: isDesktop,
@@ -7118,12 +7130,14 @@ class WebRTCClient extends Emitter {
7118
7130
 
7119
7131
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
7120
7132
 
7121
- pc.oniceconnectionstatechange = () => {
7122
- logger.info('on ice connection state changed', { state: pc.iceConnectionState });
7123
- if (pc.iceConnectionState === 'disconnected') {
7124
- this.eventEmitter.emit(ON_DISCONNECTED);
7125
- }
7126
- };
7133
+ if (pc) {
7134
+ pc.oniceconnectionstatechange = () => {
7135
+ logger.info('on ice connection state changed', { state: pc.iceConnectionState });
7136
+ if (pc.iceConnectionState === 'disconnected') {
7137
+ this.eventEmitter.emit(ON_DISCONNECTED);
7138
+ }
7139
+ };
7140
+ }
7127
7141
 
7128
7142
  if (withEvent) {
7129
7143
  this.eventEmitter.emit(ACCEPTED, session, sessionDialog);
@@ -7333,13 +7347,17 @@ class WebRTCClient extends Emitter {
7333
7347
  const nbStats = this.sessionNetworkStats[sessionId].length;
7334
7348
  const lastNetworkStats = this.sessionNetworkStats[sessionId][nbStats - 1];
7335
7349
  const lastAudioSent = lastNetworkStats ? lastNetworkStats.audioBytesSent : 0;
7350
+ const lastAudioContentSent = lastNetworkStats ? lastNetworkStats.audioContentSent : 0;
7336
7351
  const lastVideoSent = lastNetworkStats ? lastNetworkStats.videoBytesSent : 0;
7337
7352
  const lastAudioReceived = lastNetworkStats ? lastNetworkStats.audioBytesReceived : 0;
7353
+ const lastAudioContentReceived = lastNetworkStats ? lastNetworkStats.audioContentReceived : 0;
7338
7354
  const lastVideoReceived = lastNetworkStats ? lastNetworkStats.videoBytesReceived : 0;
7339
7355
  const lastTransportSent = lastNetworkStats ? lastNetworkStats.transportSent : 0;
7340
7356
  const lastTransportReceived = lastNetworkStats ? lastNetworkStats.transportReceived : 0;
7341
- let audioBytesSent = 0;
7342
- let audioBytesReceived = 0;
7357
+ let audioBytesSent = 0; // content + header
7358
+ let audioBytesReceived = 0; // content + header
7359
+ let audioContentSent = 0; // useful to detect blank call
7360
+ let audioContentReceived = 0;
7343
7361
  let videoBytesSent = 0;
7344
7362
  let videoBytesReceived = 0;
7345
7363
  let transportSent = 0;
@@ -7349,6 +7367,7 @@ class WebRTCClient extends Emitter {
7349
7367
  stats.forEach(report => {
7350
7368
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
7351
7369
  audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
7370
+ audioContentSent += Number(report.bytesSent);
7352
7371
  }
7353
7372
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
7354
7373
  audioBytesSent += Number(report.bytesSent);
@@ -7360,6 +7379,7 @@ class WebRTCClient extends Emitter {
7360
7379
  packetsLost += Number(report.packetsLost);
7361
7380
  networkStats.packetsReceived = Number(report.packetsReceived);
7362
7381
  audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
7382
+ audioContentReceived += Number(report.bytesReceived);
7363
7383
  }
7364
7384
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
7365
7385
  videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
@@ -7388,10 +7408,17 @@ class WebRTCClient extends Emitter {
7388
7408
  });
7389
7409
 
7390
7410
  networkStats.packetsLost = packetsLost;
7411
+
7391
7412
  networkStats.totalAudioBytesSent = audioBytesSent;
7392
7413
  networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
7393
7414
  networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
7394
7415
  networkStats.audioBytesReceived = audioBytesReceived;
7416
+
7417
+ networkStats.totalAudioContentSent = audioContentSent;
7418
+ networkStats.audioContentSent = audioContentSent - lastAudioContentSent;
7419
+ networkStats.totalAudioBytesReceived = audioContentReceived - lastAudioContentReceived;
7420
+ networkStats.audioContentReceived = audioContentReceived;
7421
+
7395
7422
  networkStats.totalVideoBytesSent = videoBytesSent;
7396
7423
  networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
7397
7424
  networkStats.totalVideoBytesReceived = videoBytesReceived;
@@ -664,7 +664,7 @@ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
664
664
 
665
665
  // Use a function here to be able to mock it in tests
666
666
  const realFetch = () => {
667
- if (typeof document !== 'undefined') {
667
+ if (typeof document !== 'undefined' && window.fetch) {
668
668
  // Browser
669
669
  return window.fetch;
670
670
  }
@@ -2113,7 +2113,7 @@ class Contact {
2113
2113
  this[key] = old[key] || this[key];
2114
2114
  });
2115
2115
 
2116
- if (old.lineState && !this.lineState) {
2116
+ if (old.lineState) {
2117
2117
  this.lineState = old.lineState;
2118
2118
  }
2119
2119
 
@@ -2820,8 +2820,9 @@ class ExternalApp {
2820
2820
 
2821
2821
 
2822
2822
 
2823
-
2823
+
2824
2824
 
2825
+
2825
2826
 
2826
2827
 
2827
2828
  class Meeting {
@@ -2832,9 +2833,10 @@ class Meeting {
2832
2833
 
2833
2834
 
2834
2835
 
2835
-
2836
+
2836
2837
 
2837
2838
 
2839
+
2838
2840
 
2839
2841
  static parse(plain ) {
2840
2842
  return new Meeting({
@@ -2844,8 +2846,9 @@ class Meeting {
2844
2846
  ownerUuids: plain.owner_uuids,
2845
2847
  port: plain.port,
2846
2848
  uuid: plain.uuid,
2847
- number: plain.number,
2849
+ extension: plain.exten,
2848
2850
  persistent: plain.persistent,
2851
+ creationTime: moment(plain.creation_time).toDate(),
2849
2852
  });
2850
2853
  }
2851
2854
 
@@ -2867,8 +2870,9 @@ class Meeting {
2867
2870
  ownerUuids,
2868
2871
  port,
2869
2872
  uri,
2870
- number,
2873
+ extension,
2871
2874
  persistent,
2875
+ creationTime,
2872
2876
  } = {}) {
2873
2877
  this.guestSipAuthorization = guestSipAuthorization;
2874
2878
  this.uri = uri;
@@ -2876,8 +2880,9 @@ class Meeting {
2876
2880
  this.ownerUuids = ownerUuids;
2877
2881
  this.port = port;
2878
2882
  this.uuid = uuid;
2879
- this.number = number;
2883
+ this.extension = extension;
2880
2884
  this.persistent = persistent;
2885
+ this.creationTime = creationTime;
2881
2886
 
2882
2887
  // Useful to compare instead of instanceof with minified code
2883
2888
  this.type = 'Meeting';
@@ -698,7 +698,7 @@ class Contact {
698
698
  this[key] = old[key] || this[key];
699
699
  });
700
700
 
701
- if (old.lineState && !this.lineState) {
701
+ if (old.lineState) {
702
702
  this.lineState = old.lineState;
703
703
  }
704
704
 
@@ -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';
@@ -1,3 +1,5 @@
1
+ import moment from 'moment';
2
+
1
3
  //
2
4
 
3
5
  var newFrom = (instance , ToClass ) => {
@@ -18,8 +20,9 @@ var newFrom = (instance , ToClass ) => {
18
20
 
19
21
 
20
22
 
21
-
23
+
22
24
 
25
+
23
26
 
24
27
 
25
28
  class Meeting {
@@ -30,9 +33,10 @@ class Meeting {
30
33
 
31
34
 
32
35
 
33
-
36
+
34
37
 
35
38
 
39
+
36
40
 
37
41
  static parse(plain ) {
38
42
  return new Meeting({
@@ -42,8 +46,9 @@ class Meeting {
42
46
  ownerUuids: plain.owner_uuids,
43
47
  port: plain.port,
44
48
  uuid: plain.uuid,
45
- number: plain.number,
49
+ extension: plain.exten,
46
50
  persistent: plain.persistent,
51
+ creationTime: moment(plain.creation_time).toDate(),
47
52
  });
48
53
  }
49
54
 
@@ -65,8 +70,9 @@ class Meeting {
65
70
  ownerUuids,
66
71
  port,
67
72
  uri,
68
- number,
73
+ extension,
69
74
  persistent,
75
+ creationTime,
70
76
  } = {}) {
71
77
  this.guestSipAuthorization = guestSipAuthorization;
72
78
  this.uri = uri;
@@ -74,8 +80,9 @@ class Meeting {
74
80
  this.ownerUuids = ownerUuids;
75
81
  this.port = port;
76
82
  this.uuid = uuid;
77
- this.number = number;
83
+ this.extension = extension;
78
84
  this.persistent = persistent;
85
+ this.creationTime = creationTime;
79
86
 
80
87
  // Useful to compare instead of instanceof with minified code
81
88
  this.type = 'Meeting';
@@ -1217,7 +1217,7 @@ class Contact {
1217
1217
  this[key] = old[key] || this[key];
1218
1218
  });
1219
1219
 
1220
- if (old.lineState && !this.lineState) {
1220
+ if (old.lineState) {
1221
1221
  this.lineState = old.lineState;
1222
1222
  }
1223
1223
 
@@ -2837,7 +2837,7 @@ const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
2837
2837
 
2838
2838
  // Use a function here to be able to mock it in tests
2839
2839
  const realFetch = () => {
2840
- if (typeof document !== 'undefined') {
2840
+ if (typeof document !== 'undefined' && window.fetch) {
2841
2841
  // Browser
2842
2842
  return window.fetch;
2843
2843
  }
@@ -3516,8 +3516,9 @@ class ExternalApp {
3516
3516
 
3517
3517
 
3518
3518
 
3519
-
3519
+
3520
3520
 
3521
+
3521
3522
 
3522
3523
 
3523
3524
  class Meeting {
@@ -3528,9 +3529,10 @@ class Meeting {
3528
3529
 
3529
3530
 
3530
3531
 
3531
-
3532
+
3532
3533
 
3533
3534
 
3535
+
3534
3536
 
3535
3537
  static parse(plain ) {
3536
3538
  return new Meeting({
@@ -3540,8 +3542,9 @@ class Meeting {
3540
3542
  ownerUuids: plain.owner_uuids,
3541
3543
  port: plain.port,
3542
3544
  uuid: plain.uuid,
3543
- number: plain.number,
3545
+ extension: plain.exten,
3544
3546
  persistent: plain.persistent,
3547
+ creationTime: moment(plain.creation_time).toDate(),
3545
3548
  });
3546
3549
  }
3547
3550
 
@@ -3563,8 +3566,9 @@ class Meeting {
3563
3566
  ownerUuids,
3564
3567
  port,
3565
3568
  uri,
3566
- number,
3569
+ extension,
3567
3570
  persistent,
3571
+ creationTime,
3568
3572
  } = {}) {
3569
3573
  this.guestSipAuthorization = guestSipAuthorization;
3570
3574
  this.uri = uri;
@@ -3572,8 +3576,9 @@ class Meeting {
3572
3576
  this.ownerUuids = ownerUuids;
3573
3577
  this.port = port;
3574
3578
  this.uuid = uuid;
3575
- this.number = number;
3579
+ this.extension = extension;
3576
3580
  this.persistent = persistent;
3581
+ this.creationTime = creationTime;
3577
3582
 
3578
3583
  // Useful to compare instead of instanceof with minified code
3579
3584
  this.type = 'Meeting';