@opentok/client 2.28.3 → 2.28.4-alpha.2

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.
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @license OpenTok.js 2.28.3 2898b53
2
+ * @license OpenTok.js 2.28.4 cc4f62d
3
3
  *
4
4
  * Copyright (c) 2010-2024 TokBox, Inc.
5
5
  * Subject to the applicable Software Development Kit (SDK) License Agreement:
6
6
  * https://www.vonage.com/legal/communications-apis/terms-of-use/
7
7
  *
8
- * Date: Fri, 20 Sep 2024 18:57:18 GMT
8
+ * Date: Thu, 03 Oct 2024 14:53:45 GMT
9
9
  */
10
10
 
11
11
  (function webpackUniversalModuleDefinition(root, factory) {
@@ -8045,7 +8045,7 @@ const logging = (0, _log.default)('StaticConfig');
8045
8045
  */
8046
8046
 
8047
8047
  /** @type builtInConfig */
8048
- const builtInConfig = (0, _cloneDeep.default)({"version":"v2.28.3","buildHash":"2898b53","minimumVersion":{"firefox":52,"chrome":49},"debug":false,"websiteURL":"http://www.tokbox.com","configURL":"https://config.opentok.com","ipWhitelistConfigURL":"","cdnURL":"","loggingURL":"https://hlg.tokbox.com/prod","apiURL":"https://anvil.opentok.com"});
8048
+ const builtInConfig = (0, _cloneDeep.default)({"version":"v2.28.4","buildHash":"cc4f62d","minimumVersion":{"firefox":52,"chrome":49},"debug":false,"websiteURL":"http://www.tokbox.com","configURL":"https://config.opentok.com","ipWhitelistConfigURL":"","cdnURL":"","loggingURL":"https://hlg.tokbox.com/prod","apiURL":"https://anvil.opentok.com"});
8049
8049
  const whitelistAllowedRuntimeProperties = (0, _pick.default)(['apiURL', 'assetURL', 'cdnURL', 'sessionInfoOverrides', 'loggingURL']);
8050
8050
  const liveConfigMap = {
8051
8051
  apiUrl: 'apiURL',
@@ -32422,7 +32422,11 @@ function PublisherPeerConnectionFactory(deps) {
32422
32422
  if (_cancelWatchAudioAcquisition) {
32423
32423
  _cancelWatchAudioAcquisition();
32424
32424
  }
32425
- _cancelWatchAudioAcquisition = watchAudioAcquisition(callback => _peerConnection.getStats(null, callback), () => this.trigger('audioAcquisitionProblem'));
32425
+ _cancelWatchAudioAcquisition = watchAudioAcquisition(callback => _peerConnection.getStats(null, callback), () => {
32426
+ if (_peerConnection.iceConnectionStateIsConnected()) {
32427
+ this.trigger('audioAcquisitionProblem');
32428
+ }
32429
+ });
32426
32430
  }
32427
32431
  this.trigger('connected');
32428
32432
  }
@@ -92412,8 +92416,8 @@ exports.default = watchAudioAcquisition;
92412
92416
  * Installs a watcher that will calls the given callback if the audio acquisition seems to not
92413
92417
  * work porperly.
92414
92418
  *
92415
- * It waits 3 seconds and poll getStats to find any sign of audio bytes sent. If it can't find any
92416
- * it signals the anomaly by executing the given function.
92419
+ * It runs every 3 seconds and poll getStats to find any sign of audio bytes sent. If it can't find
92420
+ * any it signals the anomaly by executing the given function.
92417
92421
  *
92418
92422
  * @param {function(cb: function(DOMError, Array<RTCStats>))} getStats
92419
92423
  * the function to call to get the stats
@@ -92421,24 +92425,45 @@ exports.default = watchAudioAcquisition;
92421
92425
  * @returns {function} cancel the watch
92422
92426
  */
92423
92427
  function watchAudioAcquisition(getStats, warningCb) {
92424
- // detection of Chrome failure to acquire audio
92425
- // inspired by https://medium.com/the-making-of-appear-in/working-around-webrtc-bugs-d4f6fdb763f
92426
- const to = setTimeout(() => {
92427
- getStats((error, stats) => {
92428
- if (error) {
92429
- return;
92430
- }
92431
- for (let idxStats = 0; idxStats < stats.length; idxStats += 1) {
92432
- const rtcStats = stats[idxStats];
92433
- if (rtcStats.id.indexOf('_send') !== -1 && rtcStats.type === 'ssrc' && (rtcStats.kind === 'audio' || rtcStats.mediaType === 'audio') && parseInt(rtcStats.bytesSent, 10) === 0) {
92434
- // abnormal condition detected
92428
+ let previousBytesSent = 0;
92429
+ let isCallbackNeeded = true;
92430
+ const isAudioStat = rtcStats => rtcStats.type === 'outbound-rtp' && rtcStats.ssrc && (rtcStats.kind === 'audio' || rtcStats.mediaType === 'audio');
92431
+ const isAnomalyDetected = currentBytesSent => currentBytesSent === previousBytesSent && isCallbackNeeded;
92432
+ const isAnomalyResolved = currentBytesSent => currentBytesSent !== previousBytesSent;
92433
+ const handleStats = (error, stats) => {
92434
+ if (error) return;
92435
+ stats.forEach(rtcStats => {
92436
+ if (isAudioStat(rtcStats)) {
92437
+ const statType = typeof rtcStats.bytesSent;
92438
+ let currentBytesSent;
92439
+ // Number.MAX_SAFE_INTEGER is a 16 digit number, but it is only 53 bits. We manually modulo
92440
+ // 15 digits to avoid big number problems.
92441
+ const maxDigit = 15;
92442
+ if (statType === 'number') {
92443
+ currentBytesSent = rtcStats.bytesSent % Math.pow(10, maxDigit);
92444
+ } else if (statType === 'string') {
92445
+ const safeIntegerBytesSent = rtcStats.bytesSent.slice(rtcStats.bytesSent.length - maxDigit);
92446
+ currentBytesSent = parseInt(safeIntegerBytesSent, 10);
92447
+ } else {
92448
+ return;
92449
+ }
92450
+ if (isAnomalyDetected(currentBytesSent)) {
92435
92451
  warningCb();
92452
+ // Execute the callback only once per audio loss
92453
+ isCallbackNeeded = false;
92454
+ } else if (isAnomalyResolved(currentBytesSent)) {
92455
+ // Once resolved, we may need to use the callback in future audio loss
92456
+ isCallbackNeeded = true;
92436
92457
  }
92458
+ previousBytesSent = currentBytesSent;
92437
92459
  }
92438
92460
  });
92461
+ };
92462
+ const audioMonitor = setInterval(() => {
92463
+ getStats(handleStats);
92439
92464
  }, 3000);
92440
92465
  return function cancel() {
92441
- clearTimeout(to);
92466
+ clearInterval(audioMonitor);
92442
92467
  };
92443
92468
  }
92444
92469