@opentok/client 2.27.6 → 2.27.7

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.
@@ -277,6 +277,10 @@ declare namespace OT {
277
277
  track: MediaStreamTrack | undefined
278
278
  };
279
279
 
280
+ mediaStreamAvailable: Event<'mediaStreamAvailable', Publisher> & {
281
+ mediaStream: MediaStream;
282
+ };
283
+
280
284
  streamCreated: Event<'streamCreated', Publisher> & {
281
285
  stream: Stream;
282
286
  };
@@ -549,6 +553,10 @@ declare namespace OT {
549
553
 
550
554
  encryptionSecretMatch: Event<'encryptionSecretMatch', Subscriber>;
551
555
 
556
+ mediaStreamAvailable: Event<'mediaStreamAvailable', Subscriber> & {
557
+ mediaStream: MediaStream;
558
+ };
559
+
552
560
  videoDimensionsChanged: VideoDimensionsChangedEvent<Subscriber>;
553
561
 
554
562
  videoDisabled: Event<'videoDisabled', Subscriber> & {
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @license OpenTok.js 2.27.6 cf306f8
2
+ * @license OpenTok.js 2.27.7 7bb2355
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: Wed, 05 Jun 2024 14:03:04 GMT
8
+ * Date: Fri, 21 Jun 2024 17:32:09 GMT
9
9
  */
10
10
 
11
11
  (function webpackUniversalModuleDefinition(root, factory) {
@@ -6753,6 +6753,13 @@ function EventsFactory(deps) {
6753
6753
  captionsEnabled
6754
6754
  });
6755
6755
  };
6756
+
6757
+ // WILL NEED TO DOCUMENT THIS FOR BOTH SUB AND PUB
6758
+ Events.MediaStreamAvailable = function MediaStreamAvailable(mediaStream) {
6759
+ return new _Event4.default('mediaStreamAvailable', false, {
6760
+ mediaStream
6761
+ });
6762
+ };
6756
6763
  Events.StreamUpdatedEvent = function StreamUpdatedEvent(stream, key, oldValue, newValue) {
6757
6764
  return new _Event4.default('updated', false, {
6758
6765
  target: stream,
@@ -7922,7 +7929,7 @@ const logging = (0, _log.default)('StaticConfig');
7922
7929
  */
7923
7930
 
7924
7931
  /** @type builtInConfig */
7925
- const builtInConfig = (0, _cloneDeep.default)({"version":"v2.27.6","buildHash":"cf306f8","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"});
7932
+ const builtInConfig = (0, _cloneDeep.default)({"version":"v2.27.7","buildHash":"7bb2355","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"});
7926
7933
  const whitelistAllowedRuntimeProperties = (0, _pick.default)(['apiURL', 'assetURL', 'cdnURL', 'sessionInfoOverrides', 'loggingURL']);
7927
7934
  const liveConfigMap = {
7928
7935
  apiUrl: 'apiURL',
@@ -18472,6 +18479,7 @@ function PublisherFactory(_ref) {
18472
18479
  }
18473
18480
  });
18474
18481
  widgetView.on('videoElementCreated', element => {
18482
+ this.dispatchEvent(new Events.MediaStreamAvailable(webRTCStream));
18475
18483
  const event = new Events.VideoElementCreatedEvent(element);
18476
18484
  this.dispatchEvent(event);
18477
18485
  });
@@ -33380,7 +33388,7 @@ var _amrVideoBufferError = __webpack_require__(322);
33380
33388
  var _updateTrackOnStream = _interopRequireDefault(__webpack_require__(331));
33381
33389
  var _time = _interopRequireDefault(__webpack_require__(110));
33382
33390
  var _amrStates = _interopRequireDefault(__webpack_require__(325));
33383
- const _excluded = ["AudioLevelMeter", "AudioLevelTransformer", "BackingBar", "Chrome", "env", "Errors", "Events", "ExceptionCodes", "audioLevelSamplerFactory", "getStatsHelpers", "hasAudioOutputLevelStatCapability", "hasRemoteStreamsWithWebAudio", "interpretPeerConnectionError", "logging", "MuteButton", "NamePanel", "otError", "OTErrorClass", "OTHelpers", "StylableComponent", "SubscriberPeerConnection", "SubscribingState", "VideoDisabledIndicator", "AudioBlockedIndicator", "VideoUnsupportedIndicator", "watchFrameRate", "createSendMethod", "parseIceServers", "document", "WidgetView", "createAudioConnector", "ResizeObserverPolyfill", "AMRStateDurations"];
33391
+ const _excluded = ["AudioLevelMeter", "AudioLevelTransformer", "BackingBar", "Chrome", "env", "Errors", "Events", "ExceptionCodes", "audioLevelSamplerFactory", "getStatsHelpers", "hasAudioOutputLevelStatCapability", "hasRemoteStreamsWithWebAudio", "interpretPeerConnectionError", "logging", "MuteButton", "NamePanel", "otError", "OTErrorClass", "OTHelpers", "StylableComponent", "SubscriberPeerConnection", "SubscribingState", "VideoDisabledIndicator", "AudioBlockedIndicator", "VideoUnsupportedIndicator", "watchFrameRate", "createSendMethod", "parseIceServers", "document", "WidgetView", "createAudioConnector", "ResizeObserverPolyfill", "MediaStream", "AMRStateDurations"];
33384
33392
  const defaultWidgetView = (0, _widget_view.default)();
33385
33393
  const EventsDefault = (0, _events2.default)();
33386
33394
  const errorsDefault = _Errors.default;
@@ -33485,6 +33493,8 @@ function SubscriberFactory(_ref2) {
33485
33493
  createAudioConnector = _ref3$createAudioConn === void 0 ? _audioConnector2.default : _ref3$createAudioConn,
33486
33494
  _ref3$ResizeObserverP = _ref3.ResizeObserverPolyfill,
33487
33495
  ResizeObserverPolyfill = _ref3$ResizeObserverP === void 0 ? _resizeObserverPolyfill.default : _ref3$ResizeObserverP,
33496
+ _ref3$MediaStream = _ref3.MediaStream,
33497
+ MediaStream = _ref3$MediaStream === void 0 ? (typeof window !== undefined ? window : global).MediaStream : _ref3$MediaStream,
33488
33498
  AMRStateDurations = _ref3.AMRStateDurations,
33489
33499
  deps = (0, _objectWithoutPropertiesLoose2.default)(_ref3, _excluded);
33490
33500
  const BIND_VIDEO_DELAY_MAX = 30000;
@@ -33530,7 +33540,15 @@ function SubscriberFactory(_ref2) {
33530
33540
  const webRTCStreams = {};
33531
33541
  const hybridSessionTransitionStartTimes = {};
33532
33542
  const _peerConnectionEvents = {};
33533
- const _audioConnector = createAudioConnector(webRTCStreams);
33543
+ const updateTrackOnStream = (mediaStream, oldTrack, newTrack) => {
33544
+ if (_exposedWebRTCStream) {
33545
+ (0, _updateTrackOnStream.default)(_exposedWebRTCStream, oldTrack, newTrack);
33546
+ }
33547
+ (0, _updateTrackOnStream.default)(mediaStream, oldTrack, newTrack);
33548
+ };
33549
+ const _audioConnector = createAudioConnector(webRTCStreams, {
33550
+ updateTrackOnStream
33551
+ });
33534
33552
 
33535
33553
  /** @type {defaultWidgetView|null} */
33536
33554
  let _widgetView;
@@ -33582,6 +33600,7 @@ function SubscriberFactory(_ref2) {
33582
33600
  let _originalVideoTrack;
33583
33601
  let _senderStats;
33584
33602
  let _resizeObserver;
33603
+ let _exposedWebRTCStream;
33585
33604
 
33586
33605
  // The audio stats watcher is only supported on chromium-based browsers that supports
33587
33606
  // the standard version of the getStats API.
@@ -33655,6 +33674,10 @@ function SubscriberFactory(_ref2) {
33655
33674
  isSubscriber: true
33656
33675
  }));
33657
33676
  };
33677
+ const syncUpMediaStreams = (targetStream, originalStream) => {
33678
+ (0, _updateTrackOnStream.default)(targetStream, targetStream.getAudioTracks()[0], originalStream.getAudioTracks()[0]);
33679
+ (0, _updateTrackOnStream.default)(targetStream, targetStream.getVideoTracks()[0], originalStream.getVideoTracks()[0]);
33680
+ };
33658
33681
  const bindWebRTCStream = /*#__PURE__*/function () {
33659
33682
  var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(webRTCStream) {
33660
33683
  var _stream2;
@@ -33668,6 +33691,10 @@ function SubscriberFactory(_ref2) {
33668
33691
  }
33669
33692
  return _context3.abrupt("return");
33670
33693
  case 2:
33694
+ // Sync the track state of the exposed stream with our current stream
33695
+ if (_exposedWebRTCStream) {
33696
+ syncUpMediaStreams(_exposedWebRTCStream, webRTCStream);
33697
+ }
33671
33698
  videoContainerOptions = {
33672
33699
  error: onVideoError,
33673
33700
  audioVolume: _audioVolume,
@@ -33675,28 +33702,28 @@ function SubscriberFactory(_ref2) {
33675
33702
  }; // We want to catch any error in the prebuffering when transition to P2P.
33676
33703
  // Otherwise, we ignore it.
33677
33704
  throwIfBufferFails = _isAdaptiveEnabled && _activeSourceStreamId === 'P2P';
33678
- _context3.prev = 4;
33679
- _context3.next = 7;
33705
+ _context3.prev = 5;
33706
+ _context3.next = 8;
33680
33707
  return _widgetView.bindVideo(webRTCStream, videoContainerOptions, throwIfBufferFails);
33681
- case 7:
33682
- _context3.next = 15;
33708
+ case 8:
33709
+ _context3.next = 16;
33683
33710
  break;
33684
- case 9:
33685
- _context3.prev = 9;
33686
- _context3.t0 = _context3["catch"](4);
33711
+ case 10:
33712
+ _context3.prev = 10;
33713
+ _context3.t0 = _context3["catch"](5);
33687
33714
  if (!(_context3.t0 instanceof _cancel.CancellationError || _state.isDestroyed())) {
33688
- _context3.next = 13;
33715
+ _context3.next = 14;
33689
33716
  break;
33690
33717
  }
33691
33718
  return _context3.abrupt("return");
33692
- case 13:
33719
+ case 14:
33693
33720
  onVideoError(_context3.t0);
33694
33721
  throw _context3.t0;
33695
- case 15:
33722
+ case 16:
33696
33723
  case "end":
33697
33724
  return _context3.stop();
33698
33725
  }
33699
- }, _callee3, null, [[4, 9]]);
33726
+ }, _callee3, null, [[5, 10]]);
33700
33727
  }));
33701
33728
  return function bindWebRTCStream(_x3) {
33702
33729
  return _ref6.apply(this, arguments);
@@ -34296,6 +34323,10 @@ function SubscriberFactory(_ref2) {
34296
34323
  isSwappingStreams = Object.keys(webRTCStreams).length === 1;
34297
34324
  sourceStreamId = peerConnection == null ? void 0 : peerConnection.getSourceStreamId();
34298
34325
  _session2 = _session, sessionInfo = _session2.sessionInfo;
34326
+ if (!_exposedWebRTCStream) {
34327
+ _exposedWebRTCStream = new MediaStream(webRTCStream);
34328
+ _this.dispatchEvent(new Events.MediaStreamAvailable(_exposedWebRTCStream));
34329
+ }
34299
34330
  _webRTCStream = webRTCStream;
34300
34331
 
34301
34332
  // save a copy of the WebRTCStream
@@ -34305,21 +34336,21 @@ function SubscriberFactory(_ref2) {
34305
34336
  logging.debug('OT.Subscriber.onRemoteStreamAdded with sourceStreamId', sourceStreamId);
34306
34337
  _state.set('BindingRemoteStream');
34307
34338
  if (!_videoMediaProcessorConnector) {
34308
- _context7.next = 14;
34339
+ _context7.next = 15;
34309
34340
  break;
34310
34341
  }
34311
34342
  if (!_videoEnabled) {
34312
- _context7.next = 13;
34343
+ _context7.next = 14;
34313
34344
  break;
34314
34345
  }
34315
- _context7.next = 11;
34346
+ _context7.next = 12;
34316
34347
  return applyVideoConnectorOnStream(sourceStreamId);
34317
- case 11:
34318
- _context7.next = 14;
34348
+ case 12:
34349
+ _context7.next = 15;
34319
34350
  break;
34320
- case 13:
34321
- _videoMediaProcessorConnector.destroy();
34322
34351
  case 14:
34352
+ _videoMediaProcessorConnector.destroy();
34353
+ case 15:
34323
34354
  // Disable the audio/video, if needed
34324
34355
  _this.subscribeToAudio(_isSubscribingToAudio);
34325
34356
  if (!(_lastSubscribeToVideoReason === 'auto' && !_properties.subscribeToVideo)) {
@@ -34351,17 +34382,17 @@ function SubscriberFactory(_ref2) {
34351
34382
  }
34352
34383
  });
34353
34384
  }
34354
- _context7.prev = 18;
34355
- _context7.next = 21;
34385
+ _context7.prev = 19;
34386
+ _context7.next = 22;
34356
34387
  return bindWebRTCStream(_webRTCStream);
34357
- case 21:
34358
- _context7.next = 32;
34388
+ case 22:
34389
+ _context7.next = 33;
34359
34390
  break;
34360
- case 23:
34361
- _context7.prev = 23;
34362
- _context7.t0 = _context7["catch"](18);
34391
+ case 24:
34392
+ _context7.prev = 24;
34393
+ _context7.t0 = _context7["catch"](19);
34363
34394
  if (!(0, _amrVideoBufferError.isAmrVideoBufferError)(_context7.t0)) {
34364
- _context7.next = 31;
34395
+ _context7.next = 32;
34365
34396
  break;
34366
34397
  }
34367
34398
  logging.error(`OT.Subscriber: ${_context7.t0.message}`);
@@ -34374,17 +34405,17 @@ function SubscriberFactory(_ref2) {
34374
34405
  socket.subscriberDestroy(_stream.id, _this.widgetId, _activeSourceStreamId);
34375
34406
  }
34376
34407
  return _context7.abrupt("return");
34377
- case 31:
34378
- throw _context7.t0;
34379
34408
  case 32:
34409
+ throw _context7.t0;
34410
+ case 33:
34380
34411
  startAudioStatsWatcher();
34381
34412
  if (!_state.isDestroyed()) {
34382
- _context7.next = 36;
34413
+ _context7.next = 37;
34383
34414
  break;
34384
34415
  }
34385
34416
  logging.error('Subscriber destroyed');
34386
34417
  return _context7.abrupt("return");
34387
- case 36:
34418
+ case 37:
34388
34419
  if (peerConnection && (typeof window !== undefined ? window : global).webkitMediaStream) {
34389
34420
  // Enable any video streams that we previously disabled for OPENTOK-27112
34390
34421
  peerConnection._getVideoTracks().forEach(track => {
@@ -34412,12 +34443,12 @@ function SubscriberFactory(_ref2) {
34412
34443
  _widgetView.once('videoElementCreated', resolve);
34413
34444
  _subscriber.once('destroyed', reject);
34414
34445
  });
34415
- _context7.next = 44;
34446
+ _context7.next = 45;
34416
34447
  return videoElementCreated;
34417
- case 44:
34418
- _context7.next = 46;
34448
+ case 45:
34449
+ _context7.next = 47;
34419
34450
  return _pcConnected.promise;
34420
- case 46:
34451
+ case 47:
34421
34452
  if (!isSwappingStreams) {
34422
34453
  onLoaded();
34423
34454
  } else {
@@ -34453,34 +34484,34 @@ function SubscriberFactory(_ref2) {
34453
34484
  // Given an AMR transition, and an audio connector, we apply the connector for the new
34454
34485
  // relayed stream and clear it for the routed stream.
34455
34486
  if (!_isAdaptiveEnabled) {
34456
- _context7.next = 62;
34487
+ _context7.next = 63;
34457
34488
  break;
34458
34489
  }
34459
34490
  amrState.completeTransitionTo(_activeSourceStreamId);
34460
34491
  if (!(_isSubscribingToAudio && _audioConnector.audioMediaProcessorConnector)) {
34461
- _context7.next = 62;
34492
+ _context7.next = 63;
34462
34493
  break;
34463
34494
  }
34464
- _context7.prev = 53;
34465
- _context7.next = 56;
34495
+ _context7.prev = 54;
34496
+ _context7.next = 57;
34466
34497
  return _audioConnector.applyAudioConnectorOnRoutedToRelayedTransition();
34467
- case 56:
34498
+ case 57:
34468
34499
  logAnalyticsEvent('setAudioMediaProcessorConnector', 'Success', {
34469
34500
  message: 'Audio connector applied on routed to relayed transition.'
34470
34501
  });
34471
- _context7.next = 62;
34502
+ _context7.next = 63;
34472
34503
  break;
34473
- case 59:
34474
- _context7.prev = 59;
34475
- _context7.t1 = _context7["catch"](53);
34504
+ case 60:
34505
+ _context7.prev = 60;
34506
+ _context7.t1 = _context7["catch"](54);
34476
34507
  logAnalyticsEvent('setAudioMediaProcessorConnector', 'Failure', {
34477
34508
  message: _context7.t1.message
34478
34509
  });
34479
- case 62:
34510
+ case 63:
34480
34511
  case "end":
34481
34512
  return _context7.stop();
34482
34513
  }
34483
- }, _callee7, null, [[18, 23], [53, 59]]);
34514
+ }, _callee7, null, [[19, 24], [54, 60]]);
34484
34515
  }));
34485
34516
  return function onRemoteStreamAdded(_x9, _x10) {
34486
34517
  return _ref15.apply(this, arguments);
@@ -35046,8 +35077,9 @@ function SubscriberFactory(_ref2) {
35046
35077
  _context15.next = 29;
35047
35078
  return createAudioLevelSampler(peerConnection);
35048
35079
  case 29:
35080
+ _audioLevelSampler.webRTCStream(_webRTCStream);
35049
35081
  logRelayedToRoutedTransition('Success');
35050
- case 30:
35082
+ case 31:
35051
35083
  case "end":
35052
35084
  return _context15.stop();
35053
35085
  }
@@ -36661,7 +36693,7 @@ function SubscriberFactory(_ref2) {
36661
36693
  return _videoMediaProcessorConnector.setTrack(_originalVideoTrack);
36662
36694
  case 10:
36663
36695
  filteredVideoTrack = _context27.sent;
36664
- (0, _updateTrackOnStream.default)(_webRTCStream, _originalVideoTrack, filteredVideoTrack);
36696
+ updateTrackOnStream(_webRTCStream, _originalVideoTrack, filteredVideoTrack);
36665
36697
  logAnalyticsEvent('setVideoMediaProcessorConnector', 'Success');
36666
36698
  _context27.next = 20;
36667
36699
  break;
@@ -36691,7 +36723,7 @@ function SubscriberFactory(_ref2) {
36691
36723
  // We need to switch to the original track so we can transform it later when resetting the connector.
36692
36724
  const _webRTCStream$getVide2 = _webRTCStream.getVideoTracks(),
36693
36725
  filteredVideoTrack = _webRTCStream$getVide2[0];
36694
- (0, _updateTrackOnStream.default)(_webRTCStream, filteredVideoTrack, _originalVideoTrack);
36726
+ updateTrackOnStream(_webRTCStream, filteredVideoTrack, _originalVideoTrack);
36695
36727
  logAnalyticsEvent('setVideoMediaProcessorConnector', 'Success', {
36696
36728
  message: 'reset the video track'
36697
36729
  });
@@ -66861,7 +66893,7 @@ function SessionFactory(deps) {
66861
66893
  /**
66862
66894
  * The client has disconnected from the session. This event may be dispatched asynchronously
66863
66895
  * in response to a successful call to the <code>disconnect()</code> method of the Session object.
66864
- * The event may also be disptached if a session connection is lost inadvertantly, as in the case
66896
+ * The event may also be dispatched if a session connection is lost inadvertantly, as in the case
66865
66897
  * of a lost network connection.
66866
66898
  * <p>
66867
66899
  * The default behavior is that all Subscriber objects are unsubscribed and removed from the
@@ -94223,6 +94255,16 @@ var _default = _ref => {
94223
94255
  subscriber.dispatchEvent(new Events.AudioLevelUpdatedEvent(loudness));
94224
94256
  }
94225
94257
  });
94258
+ const audioLevelUpdatedAdded = () => audioLevelRunner.start();
94259
+ const subscriberDestroyed = () => audioLevelRunner.stop();
94260
+ const addListeners = () => {
94261
+ subscriber.on('audioLevelUpdated:added', audioLevelUpdatedAdded);
94262
+ subscriber.once(_eventNames.default.SUBSCRIBER_DESTROYED, subscriberDestroyed);
94263
+ };
94264
+ const removeListeners = () => {
94265
+ subscriber.off('audioLevelUpdated:added', audioLevelUpdatedAdded);
94266
+ subscriber.off(_eventNames.default.SUBSCRIBER_DESTROYED, subscriberDestroyed);
94267
+ };
94226
94268
  Object.defineProperty(subscriber, 'loudness', {
94227
94269
  get() {
94228
94270
  audioLevelRunner.start();
@@ -94237,16 +94279,14 @@ var _default = _ref => {
94237
94279
  if (subscriber.listenerCount(_eventNames.default.AUDIO_LEVEL_UPDATED)) {
94238
94280
  audioLevelRunner.start();
94239
94281
  }
94240
- subscriber.on('audioLevelUpdated:added', () => {
94241
- audioLevelRunner.start();
94242
- });
94243
- subscriber.once(_eventNames.default.SUBSCRIBER_DESTROYED, () => {
94244
- audioLevelRunner.stop();
94245
- });
94282
+ addListeners();
94246
94283
  return {
94247
94284
  destroy() {
94248
94285
  audioLevelSampler.destroy();
94249
94286
  audioLevelRunner.stop();
94287
+ removeListeners();
94288
+ // eslint-disable-next-line no-param-reassign
94289
+ subscriber = undefined;
94250
94290
  }
94251
94291
  };
94252
94292
  };
@@ -103310,6 +103350,8 @@ let SinglePeerConnectionController = /*#__PURE__*/function () {
103310
103350
  };
103311
103351
  _proto._parseOptions = function _parseOptions(options) {
103312
103352
  return Object.assign({}, options, {
103353
+ // Create only one RTCDtlsTransport
103354
+ bundlePolicy: 'max-bundle',
103313
103355
  // We always remove unused codecs after iceRestart in SPC
103314
103356
  removeUnusedCodecs: true,
103315
103357
  sendMessage: (type, payload) => {
@@ -103461,7 +103503,7 @@ let SinglePeerConnectionController = /*#__PURE__*/function () {
103461
103503
 
103462
103504
  // Singleton to make sure we are using only one PC when SPC. If SPC, we will add Subscriber
103463
103505
  // specific options to handle analytics and negotiation per Subscriber. This will take care
103464
- // to send the answer back to Rumor by its respective Subcriber and not multiple answers.
103506
+ // to send the answer back to Rumor by its respective Subscriber and not multiple answers.
103465
103507
  // It will instantiate a new regular PC for all other cases.
103466
103508
  ;
103467
103509
  _proto.getPeerConnection = function getPeerConnection(opt, subscriberPc) {