@opentok/client 2.28.5-alpha.1 → 2.28.5-alpha.3

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.5 f0ac55a
2
+ * @license OpenTok.js 2.28.5 dd5d756
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, 22 Nov 2024 23:17:50 GMT
8
+ * Date: Wed, 27 Nov 2024 21:58:46 GMT
9
9
  */
10
10
 
11
11
  (function webpackUniversalModuleDefinition(root, factory) {
@@ -8107,7 +8107,7 @@ const logging = (0, _log.default)('StaticConfig');
8107
8107
  */
8108
8108
 
8109
8109
  /** @type builtInConfig */
8110
- const builtInConfig = (0, _cloneDeep.default)({"version":"v2.28.5","buildHash":"f0ac55a","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"});
8110
+ const builtInConfig = (0, _cloneDeep.default)({"version":"v2.28.5","buildHash":"dd5d756","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"});
8111
8111
  const whitelistAllowedRuntimeProperties = (0, _pick.default)(['apiURL', 'assetURL', 'cdnURL', 'sessionInfoOverrides', 'loggingURL']);
8112
8112
  const liveConfigMap = {
8113
8113
  apiUrl: 'apiURL',
@@ -17094,6 +17094,7 @@ function PublisherFactory(_ref) {
17094
17094
  const STREAM_DESTROY_DELAY = 5000;
17095
17095
  let pendingRumorAudioFallbackMessage = false;
17096
17096
  let removeDeviceChangeListener;
17097
+ const _initialPeerConnections = {};
17097
17098
 
17098
17099
  /** @type IntervalRunnerDefault | undefined */
17099
17100
  let connectivityAttemptPinger;
@@ -17113,6 +17114,11 @@ function PublisherFactory(_ref) {
17113
17114
  const streamChannels = [];
17114
17115
  const mediaProcessor = new MediaProcessor();
17115
17116
  const amrAudioTrackProcessor = new _amrAudioTrackProcessor.default();
17117
+ const _savePeerConnection = (peerId, peerConnection) => {
17118
+ if (!_initialPeerConnections[peerId]) {
17119
+ _initialPeerConnections[peerId] = peerConnection;
17120
+ }
17121
+ };
17116
17122
  this.once('publishComplete', err => {
17117
17123
  if (!err) {
17118
17124
  var _this$session;
@@ -17912,7 +17918,7 @@ function PublisherFactory(_ref) {
17912
17918
  }, 2000);
17913
17919
  }
17914
17920
  if (!(newState === 'connected')) {
17915
- _context6.next = 26;
17921
+ _context6.next = 27;
17916
17922
  break;
17917
17923
  }
17918
17924
  clearTimeout(_streamDestroyTimeout);
@@ -17954,19 +17960,21 @@ function PublisherFactory(_ref) {
17954
17960
  _stopSendingRtpToMantis();
17955
17961
  }
17956
17962
  case 26:
17963
+ _savePeerConnection(getPeerConnectionMeta(peerConnection).peerId, peerConnection);
17964
+ case 27:
17957
17965
  if (!(newState === 'failed')) {
17958
- _context6.next = 34;
17966
+ _context6.next = 35;
17959
17967
  break;
17960
17968
  }
17961
17969
  isSocketReconnecting = _this.session._.isSocketReconnecting;
17962
17970
  socket = _this.session._.getSocket();
17963
17971
  isSocketConnected = socket.is('connected') && !isSocketReconnecting();
17964
17972
  if (!(!isSocketConnected || sourceStreamId !== activeSourceStreamId)) {
17965
- _context6.next = 32;
17973
+ _context6.next = 33;
17966
17974
  break;
17967
17975
  }
17968
17976
  return _context6.abrupt("return");
17969
- case 32:
17977
+ case 33:
17970
17978
  // Instead of destroying the publisher straight away, we will destroy it after 5 secs
17971
17979
  // in order to avoid a race condition where we just got the socket connected at the
17972
17980
  // same moment PC transition to failed
@@ -18026,7 +18034,7 @@ function PublisherFactory(_ref) {
18026
18034
  // If Mantis PC fails, then nothing else to do.
18027
18035
  destroyStream();
18028
18036
  }
18029
- case 34:
18037
+ case 35:
18030
18038
  case "end":
18031
18039
  return _context6.stop();
18032
18040
  }
@@ -21020,6 +21028,28 @@ function PublisherFactory(_ref) {
21020
21028
  }
21021
21029
  return this._.unpublishFromSession(session, reason);
21022
21030
  },
21031
+ startMigration: () => {
21032
+ const sources = [];
21033
+ if (!this.session.sessionInfo.p2pEnabled) {
21034
+ sources.push('MANTIS');
21035
+ }
21036
+ if (activeSourceStreamId === 'P2P') {
21037
+ sources.push('P2P');
21038
+ }
21039
+ sources.forEach(source => _createStream(source, messagingError => {
21040
+ if (messagingError) {
21041
+ throw new Error(messagingError);
21042
+ }
21043
+ }));
21044
+ },
21045
+ finishMigration: () => {
21046
+ Object.entries(_initialPeerConnections).forEach(_ref51 => {
21047
+ let peerId = _ref51[0],
21048
+ peerConnection = _ref51[1];
21049
+ peerConnection == null ? void 0 : peerConnection.destroy();
21050
+ delete _initialPeerConnections[peerId];
21051
+ });
21052
+ },
21023
21053
  streamDestroyed: reason => {
21024
21054
  if (['reset'].indexOf(reason) < 0) {
21025
21055
  // We're back to being a stand-alone publisher again.
@@ -21558,7 +21588,7 @@ function PublisherFactory(_ref) {
21558
21588
  * If there is an error, the promise is rejected and no new video filter is set.
21559
21589
  */
21560
21590
  this.applyVideoFilter = /*#__PURE__*/function () {
21561
- var _ref51 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee43(videoFilter) {
21591
+ var _ref52 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee43(videoFilter) {
21562
21592
  var sanitizedVideoFilter, isSupported, message, _webRTCStream$getVide2, originalVideoTrack, filteredVideoTrack;
21563
21593
  return _regenerator.default.wrap(function _callee43$(_context43) {
21564
21594
  while (1) switch (_context43.prev = _context43.next) {
@@ -21688,7 +21718,7 @@ function PublisherFactory(_ref) {
21688
21718
  }, _callee43, null, [[2, 53], [24, 32]]);
21689
21719
  }));
21690
21720
  return function (_x33) {
21691
- return _ref51.apply(this, arguments);
21721
+ return _ref52.apply(this, arguments);
21692
21722
  };
21693
21723
  }();
21694
21724
 
@@ -21794,7 +21824,7 @@ function PublisherFactory(_ref) {
21794
21824
  * If there is an error, the promise is rejected and no new video filter is set.
21795
21825
  */
21796
21826
  this.applyAudioFilter = /*#__PURE__*/function () {
21797
- var _ref52 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee44(audioFilter) {
21827
+ var _ref53 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee44(audioFilter) {
21798
21828
  var isSupported, message, _NoiseSuppressionConf, assetsDirBaseUrl, vonageNoiseSuppression, noiseSuppressionConnector;
21799
21829
  return _regenerator.default.wrap(function _callee44$(_context44) {
21800
21830
  while (1) switch (_context44.prev = _context44.next) {
@@ -21892,7 +21922,7 @@ function PublisherFactory(_ref) {
21892
21922
  }, _callee44, null, [[20, 34]]);
21893
21923
  }));
21894
21924
  return function (_x34) {
21895
- return _ref52.apply(this, arguments);
21925
+ return _ref53.apply(this, arguments);
21896
21926
  };
21897
21927
  }();
21898
21928
 
@@ -22075,7 +22105,7 @@ function PublisherFactory(_ref) {
22075
22105
  * If there is an error, the promise is rejected and no connector is set.
22076
22106
  */
22077
22107
  this.setVideoMediaProcessorConnector = /*#__PURE__*/function () {
22078
- var _ref54 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee46(mediaProcessorConnector) {
22108
+ var _ref55 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee46(mediaProcessorConnector) {
22079
22109
  var _webRTCStream$getVide3, filteredVideoTrack, videoTrack, _webRTCStream$getVide4, originalVideoTrack, message;
22080
22110
  return _regenerator.default.wrap(function _callee46$(_context46) {
22081
22111
  while (1) switch (_context46.prev = _context46.next) {
@@ -22168,7 +22198,7 @@ function PublisherFactory(_ref) {
22168
22198
  }, _callee46, null, [[28, 36]]);
22169
22199
  }));
22170
22200
  return function (_x35) {
22171
- return _ref54.apply(this, arguments);
22201
+ return _ref55.apply(this, arguments);
22172
22202
  };
22173
22203
  }();
22174
22204
 
@@ -22231,7 +22261,7 @@ function PublisherFactory(_ref) {
22231
22261
  * If there is an error, the promise is rejected and no connector is set.
22232
22262
  */
22233
22263
  this.setAudioMediaProcessorConnector = /*#__PURE__*/function () {
22234
- var _ref55 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee47(mediaProcessorConnector) {
22264
+ var _ref56 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee47(mediaProcessorConnector) {
22235
22265
  return _regenerator.default.wrap(function _callee47$(_context47) {
22236
22266
  while (1) switch (_context47.prev = _context47.next) {
22237
22267
  case 0:
@@ -22261,11 +22291,11 @@ function PublisherFactory(_ref) {
22261
22291
  }, _callee47, null, [[1, 7]]);
22262
22292
  }));
22263
22293
  return function (_x36) {
22264
- return _ref55.apply(this, arguments);
22294
+ return _ref56.apply(this, arguments);
22265
22295
  };
22266
22296
  }();
22267
22297
  const _setAudioMediaProcessorConnector = /*#__PURE__*/function () {
22268
- var _ref56 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee48(mediaProcessorConnector) {
22298
+ var _ref57 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee48(mediaProcessorConnector) {
22269
22299
  var message, _webRTCStream$getAudi, filteredAudioTrack, _webRTCStream$getAudi2, originalAudioTrack;
22270
22300
  return _regenerator.default.wrap(function _callee48$(_context48) {
22271
22301
  while (1) switch (_context48.prev = _context48.next) {
@@ -22335,7 +22365,7 @@ function PublisherFactory(_ref) {
22335
22365
  }, _callee48, null, [[21, 29]]);
22336
22366
  }));
22337
22367
  return function _setAudioMediaProcessorConnector(_x37) {
22338
- return _ref56.apply(this, arguments);
22368
+ return _ref57.apply(this, arguments);
22339
22369
  };
22340
22370
  }();
22341
22371
 
@@ -33904,11 +33934,13 @@ function SubscriberFactory(_ref2) {
33904
33934
  let _senderStats;
33905
33935
  let _resizeObserver;
33906
33936
  let _exposedWebRTCStream;
33937
+ const _initialPeerConnections = {};
33938
+ let _isMigrating = false;
33907
33939
 
33908
33940
  // The audio stats watcher is only supported on chromium-based browsers that supports
33909
33941
  // the standard version of the getStats API.
33910
33942
  const _supportsAudioStatsWatcher = env.name === 'Chrome' && env.version >= 58 || env.isChromiumEdge || env.isOpera;
33911
- const socket = _session._.getSocket();
33943
+ let socket = _session._.getSocket();
33912
33944
  const amrState = (0, _amrStateMachine.default)(AMRStateDurations);
33913
33945
  amrState.on('transitionToP2PTimeout', () => {
33914
33946
  socket.subscriberDestroy(_stream.id, this.widgetId, _amrStates.default.P2P);
@@ -33941,6 +33973,11 @@ function SubscriberFactory(_ref2) {
33941
33973
  return _ref4.apply(this, arguments);
33942
33974
  };
33943
33975
  }();
33976
+ const _savePeerConnection = (sourceStreamId, peerConnection) => {
33977
+ if (!_initialPeerConnections[sourceStreamId]) {
33978
+ _initialPeerConnections[sourceStreamId] = peerConnection;
33979
+ }
33980
+ };
33944
33981
  const removeWebRTCStream = sourceStreamId => {
33945
33982
  delete webRTCStreams[sourceStreamId];
33946
33983
  };
@@ -34213,12 +34250,17 @@ function SubscriberFactory(_ref2) {
34213
34250
  return null;
34214
34251
  }
34215
34252
  (0, _eventing.default)(this);
34253
+ const qosQualityScores = {
34254
+ audioQualityScore: undefined,
34255
+ videoQualityScore: undefined
34256
+ };
34216
34257
  const scoreEmitter = createMOSScoreHelper();
34217
34258
  scoreEmitter.startMonitoringInterval({
34218
34259
  getStats: _getStats,
34219
34260
  subscriber: this,
34220
34261
  getCurrentPeerConnection,
34221
- logging
34262
+ logging,
34263
+ qosQualityScores
34222
34264
  });
34223
34265
  _subscriber.once('subscribeComplete', function () {
34224
34266
  try {
@@ -34310,7 +34352,7 @@ function SubscriberFactory(_ref2) {
34310
34352
  remoteConnectionId = _ref12.remoteConnectionId,
34311
34353
  peerId = _ref12.peerId,
34312
34354
  sourceStreamId = _ref12.sourceStreamId;
34313
- const QoSBlob = {
34355
+ const QoSBlob = Object.assign({
34314
34356
  widgetType: 'Subscriber',
34315
34357
  width: _widgetView.width,
34316
34358
  height: _widgetView.height,
@@ -34334,7 +34376,7 @@ function SubscriberFactory(_ref2) {
34334
34376
  preferredFrameRate: _properties.preferredFrameRate,
34335
34377
  audioFallback: !_videoEnabled && _lastSubscribeToVideoReason === 'auto',
34336
34378
  initials: _stream.initials
34337
- };
34379
+ }, qosQualityScores);
34338
34380
  const combinedStats = (0, _assign.default)(QoSBlob, parsedStats);
34339
34381
  analytics.logQOS(combinedStats);
34340
34382
  this.trigger('qos', Object.assign({}, analytics.commonQoSFields(), combinedStats));
@@ -34630,7 +34672,7 @@ function SubscriberFactory(_ref2) {
34630
34672
  return _regenerator.default.wrap(function _callee7$(_context7) {
34631
34673
  while (1) switch (_context7.prev = _context7.next) {
34632
34674
  case 0:
34633
- isSwappingStreams = Object.keys(webRTCStreams).length === 1;
34675
+ isSwappingStreams = Object.keys(webRTCStreams).length === 1 || _isMigrating;
34634
34676
  sourceStreamId = peerConnection == null ? void 0 : peerConnection.getSourceStreamId();
34635
34677
  _session2 = _session, sessionInfo = _session2.sessionInfo;
34636
34678
  if (!_exposedWebRTCStream) {
@@ -34818,6 +34860,8 @@ function SubscriberFactory(_ref2) {
34818
34860
  message: _context7.t1.message
34819
34861
  });
34820
34862
  case 63:
34863
+ _savePeerConnection(sourceStreamId, peerConnection);
34864
+ case 64:
34821
34865
  case "end":
34822
34866
  return _context7.stop();
34823
34867
  }
@@ -35290,7 +35334,7 @@ function SubscriberFactory(_ref2) {
35290
35334
  this.trigger('encryptionSecretMatch');
35291
35335
  logAnalyticsEvent('encryptionSecretMatch', 'Event');
35292
35336
  });
35293
- _peerConnectionEvents[sourceStreamId] = _peerConnectionEvents;
35337
+ _peerConnectionEvents[sourceStreamId] = peerConnectionEvents;
35294
35338
  };
35295
35339
  const _transitionRoutedToRelayed = /*#__PURE__*/function () {
35296
35340
  var _ref22 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14() {
@@ -35590,25 +35634,17 @@ function SubscriberFactory(_ref2) {
35590
35634
  return getPeerConnectionBySourceStreamId(sourceStreamId);
35591
35635
  case 6:
35592
35636
  peerConnection = _context17.sent;
35593
- if (!peerConnection) {
35594
- _context17.next = 11;
35595
- break;
35596
- }
35597
- peerConnection.processMessage(type, message);
35598
- _context17.next = 16;
35599
- break;
35600
- case 11:
35601
35637
  if (!(type === 'offer')) {
35602
- _context17.next = 16;
35638
+ _context17.next = 14;
35603
35639
  break;
35604
35640
  }
35605
- _context17.next = 14;
35641
+ _context17.next = 10;
35606
35642
  return processOffer({
35607
35643
  peerId,
35608
35644
  fromConnectionId,
35609
35645
  sourceStreamId
35610
35646
  });
35611
- case 14:
35647
+ case 10:
35612
35648
  peerConnection = _context17.sent;
35613
35649
  if (_shouldUseSpc && sourceStreamId === 'MANTIS') {
35614
35650
  _singlePeerConnectionController.addSubscriber(() => {
@@ -35618,7 +35654,13 @@ function SubscriberFactory(_ref2) {
35618
35654
  // Pace subscriber creation when MPC.
35619
35655
  _this.session._.addSubscriberToPeerConnectionsQueue(peerConnection, message);
35620
35656
  }
35621
- case 16:
35657
+ _context17.next = 15;
35658
+ break;
35659
+ case 14:
35660
+ if (peerConnection) {
35661
+ peerConnection.processMessage(type, message);
35662
+ }
35663
+ case 15:
35622
35664
  case "end":
35623
35665
  return _context17.stop();
35624
35666
  }
@@ -36638,6 +36680,25 @@ function SubscriberFactory(_ref2) {
36638
36680
  startRelayedToRoutedTransition() {
36639
36681
  amrState.startTransitionToRouted(_transitionRelayedToRouted);
36640
36682
  },
36683
+ startMigration() {
36684
+ if (_isMigrating) {
36685
+ return;
36686
+ }
36687
+ _isMigrating = true;
36688
+ socket = _session._.getSocket();
36689
+ Object.keys(_initialPeerConnections).forEach(source => socket.subscriberCreate(_stream.id, _widgetId,
36690
+ // subscriberId
36691
+ channelsToSubscribeTo, source, _session._.isE2ee(), () => {}));
36692
+ },
36693
+ finishMigration() {
36694
+ Object.entries(_initialPeerConnections).forEach(_ref34 => {
36695
+ let source = _ref34[0],
36696
+ peerConnection = _ref34[1];
36697
+ peerConnection.close();
36698
+ delete _initialPeerConnections[source];
36699
+ });
36700
+ _isMigrating = false;
36701
+ },
36641
36702
  setSinkId(deviceId) {
36642
36703
  const video = _widgetView && _widgetView.video();
36643
36704
  if (video) {
@@ -36762,7 +36823,7 @@ function SubscriberFactory(_ref2) {
36762
36823
  * @memberOf Subscriber
36763
36824
  */
36764
36825
  this.subscribeToCaptions = /*#__PURE__*/function () {
36765
- var _ref34 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee25(value) {
36826
+ var _ref35 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee25(value) {
36766
36827
  var active, attributes;
36767
36828
  return _regenerator.default.wrap(function _callee25$(_context25) {
36768
36829
  while (1) switch (_context25.prev = _context25.next) {
@@ -36786,7 +36847,7 @@ function SubscriberFactory(_ref2) {
36786
36847
  }, _callee25);
36787
36848
  }));
36788
36849
  return function (_x22) {
36789
- return _ref34.apply(this, arguments);
36850
+ return _ref35.apply(this, arguments);
36790
36851
  };
36791
36852
  }();
36792
36853
 
@@ -36928,7 +36989,7 @@ function SubscriberFactory(_ref2) {
36928
36989
  * If there is an error, the promise is rejected and no connector is set.
36929
36990
  */
36930
36991
  this.setVideoMediaProcessorConnector = /*#__PURE__*/function () {
36931
- var _ref35 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee26(mediaProcessorConnector) {
36992
+ var _ref36 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee26(mediaProcessorConnector) {
36932
36993
  var isTransitioning;
36933
36994
  return _regenerator.default.wrap(function _callee26$(_context26) {
36934
36995
  while (1) switch (_context26.prev = _context26.next) {
@@ -36991,11 +37052,11 @@ function SubscriberFactory(_ref2) {
36991
37052
  }, _callee26, null, [[15, 20]]);
36992
37053
  }));
36993
37054
  return function (_x23) {
36994
- return _ref35.apply(this, arguments);
37055
+ return _ref36.apply(this, arguments);
36995
37056
  };
36996
37057
  }();
36997
37058
  const _setVideoMediaProcessorConnector = /*#__PURE__*/function () {
36998
- var _ref36 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee27() {
37059
+ var _ref37 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee27() {
36999
37060
  var _webRTCStream$getVide, message, filteredVideoTrack;
37000
37061
  return _regenerator.default.wrap(function _callee27$(_context27) {
37001
37062
  while (1) switch (_context27.prev = _context27.next) {
@@ -37037,7 +37098,7 @@ function SubscriberFactory(_ref2) {
37037
37098
  }, _callee27, null, [[7, 15]]);
37038
37099
  }));
37039
37100
  return function _setVideoMediaProcessorConnector() {
37040
- return _ref36.apply(this, arguments);
37101
+ return _ref37.apply(this, arguments);
37041
37102
  };
37042
37103
  }();
37043
37104
  const _resetVideoStream = () => {
@@ -37112,7 +37173,7 @@ function SubscriberFactory(_ref2) {
37112
37173
  * If there is an error, the promise is rejected and no connector is set.
37113
37174
  */
37114
37175
  this.setAudioMediaProcessorConnector = /*#__PURE__*/function () {
37115
- var _ref37 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee28(mediaProcessorConnector) {
37176
+ var _ref38 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee28(mediaProcessorConnector) {
37116
37177
  var message, isTransitioning;
37117
37178
  return _regenerator.default.wrap(function _callee28$(_context28) {
37118
37179
  while (1) switch (_context28.prev = _context28.next) {
@@ -37165,11 +37226,11 @@ function SubscriberFactory(_ref2) {
37165
37226
  }, _callee28);
37166
37227
  }));
37167
37228
  return function (_x24) {
37168
- return _ref37.apply(this, arguments);
37229
+ return _ref38.apply(this, arguments);
37169
37230
  };
37170
37231
  }();
37171
37232
  const _setAudioMediaProcessorConnector = /*#__PURE__*/function () {
37172
- var _ref38 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee29() {
37233
+ var _ref39 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee29() {
37173
37234
  return _regenerator.default.wrap(function _callee29$(_context29) {
37174
37235
  while (1) switch (_context29.prev = _context29.next) {
37175
37236
  case 0:
@@ -37196,7 +37257,7 @@ function SubscriberFactory(_ref2) {
37196
37257
  }, _callee29, null, [[0, 5]]);
37197
37258
  }));
37198
37259
  return function _setAudioMediaProcessorConnector() {
37199
- return _ref38.apply(this, arguments);
37260
+ return _ref39.apply(this, arguments);
37200
37261
  };
37201
37262
  }();
37202
37263
 
@@ -64380,6 +64441,8 @@ function SessionFactory(deps) {
64380
64441
  this.keyStore = new KeyStore();
64381
64442
  this.sFrameClientStore = new SFrameClientStore();
64382
64443
  let _socket;
64444
+ const _sockets = {};
64445
+ let _messagingUrl;
64383
64446
 
64384
64447
  /** @type IntervalRunner | undefined */
64385
64448
  let _connectivityAttemptPinger;
@@ -64405,7 +64468,7 @@ function SessionFactory(deps) {
64405
64468
  let reset;
64406
64469
  let destroyPublishers;
64407
64470
  let destroySubscribers;
64408
- const setState = OTHelpers.statable(this, ['disconnected', 'connecting', 'connected', 'disconnecting'], 'disconnected');
64471
+ const setState = OTHelpers.statable(this, ['disconnected', 'connecting', 'connected', 'migrating', 'disconnecting'], 'disconnected');
64409
64472
  this.connection = null;
64410
64473
  this.connections = new OTHelpers.Collection();
64411
64474
  this.streams = new OTHelpers.Collection();
@@ -64443,6 +64506,10 @@ function SessionFactory(deps) {
64443
64506
  this.trigger('sessionConnectFailed', error);
64444
64507
  };
64445
64508
  const sessionDisconnectedHandler = function sessionDisconnectedHandler(event) {
64509
+ const socketsConnected = Object.values(_sockets).filter(socket => socket.isNot('disconnected'));
64510
+ if (socketsConnected.length) {
64511
+ return;
64512
+ }
64446
64513
  _isSocketReconnecting = false;
64447
64514
  const reason = event.reason;
64448
64515
  this.logEvent('Connect', 'Disconnected', {
@@ -64498,7 +64565,18 @@ function SessionFactory(deps) {
64498
64565
  };
64499
64566
  const streamCreatedHandler = function streamCreatedHandler(stream) {
64500
64567
  if (stream && stream.connection && (!this.connection || stream.connection.id !== this.connection.id)) {
64501
- this.dispatchEvent(new Events.StreamEvent(_eventNames.default.STREAM_CREATED, stream, null, false));
64568
+ // check if we are migrating
64569
+ // if so check with all Subscribers then subcriber.migrate()
64570
+ if (this.is('migrating')) {
64571
+ const _sessionObjects$subsc = sessionObjects.subscribers.where({
64572
+ streamId: stream.id
64573
+ }),
64574
+ subscriber = _sessionObjects$subsc[0];
64575
+ subscriber == null ? void 0 : subscriber._.startMigration();
64576
+ } else {
64577
+ // if not dispatch event
64578
+ this.dispatchEvent(new Events.StreamEvent(_eventNames.default.STREAM_CREATED, stream, null, false));
64579
+ }
64502
64580
  }
64503
64581
  };
64504
64582
  const streamPropertyModifiedHandler = function streamPropertyModifiedHandler(event) {
@@ -64645,7 +64723,10 @@ function SessionFactory(deps) {
64645
64723
  if (_useSinglePeerConnection) {
64646
64724
  capabilities.push('spc');
64647
64725
  }
64648
- _socket = new RaptorSocket({
64726
+ // add migration capability
64727
+
64728
+ // map socket
64729
+ _sockets[messagingUrl] = new RaptorSocket({
64649
64730
  connectionId: _connectionId,
64650
64731
  sessionId,
64651
64732
  messagingSocketUrl: messagingUrl,
@@ -64656,6 +64737,8 @@ function SessionFactory(deps) {
64656
64737
  analytics,
64657
64738
  requestedCapabilities: capabilities
64658
64739
  });
64740
+ _socket = _sockets[messagingUrl];
64741
+ _messagingUrl = messagingUrl;
64659
64742
 
64660
64743
  /**
64661
64744
  * Maps an error from RaptorSocket.connect to its corresponding name
@@ -64727,7 +64810,12 @@ function SessionFactory(deps) {
64727
64810
  if (this.connection) {
64728
64811
  this.capabilities = this.connection.permissions;
64729
64812
  }
64730
- setState('connected');
64813
+ if (this.isNot('migrating')) {
64814
+ setState('connected');
64815
+ } else {
64816
+ // When migrating, once new Rumor is connected, migrate all Publishers
64817
+ sessionObjects.publishers.forEach(publisher => publisher._.startMigration());
64818
+ }
64731
64819
  this.logConnectivityEvent('Success', {
64732
64820
  connectionId: this.connection.id
64733
64821
  });
@@ -64783,7 +64871,7 @@ function SessionFactory(deps) {
64783
64871
  return error;
64784
64872
  };
64785
64873
  const checkMuteCapabilities = () => {
64786
- if (this.isNot('connected')) {
64874
+ if (!this.isConnected()) {
64787
64875
  return dispatchMuteError(_forceMuteErrors.default.NOT_CONNECTED);
64788
64876
  }
64789
64877
  if (!permittedTo('forceMute')) {
@@ -65438,7 +65526,7 @@ function SessionFactory(deps) {
65438
65526
  properties = undefined;
65439
65527
  }
65440
65528
  completionHandler = completionHandler || function () {};
65441
- if (this.isNot('connected')) {
65529
+ if (!this.isConnected()) {
65442
65530
  analytics.logError(1010, 'OT.exception', 'We need to be connected before you can publish', null, {
65443
65531
  action: 'Publish',
65444
65532
  variation: 'Failure',
@@ -66481,6 +66569,51 @@ function SessionFactory(deps) {
66481
66569
  disableMuteOnEntry: () => {
66482
66570
  _muteOnEntry = false;
66483
66571
  },
66572
+ migrate: () => {
66573
+ setState('migrating');
66574
+ const onSessionInfo = sessionInfo => {
66575
+ const currentMesagingUrl = _messagingUrl;
66576
+ analytics.sessionInfo = sessionInfo;
66577
+ this.sessionInfo = sessionInfo;
66578
+ this._.setIceServers(this.sessionInfo.iceServers);
66579
+ _messagingServer = sessionInfo.messagingServer;
66580
+ const overrides = this.staticConfig.sessionInfoOverrides || {};
66581
+ if (_prioritizeVP9) {
66582
+ overrides.priorityVideoCodec = 'vp9';
66583
+ }
66584
+ if (overrides != null && typeof overrides === 'object') {
66585
+ Object.keys(overrides).forEach(key => {
66586
+ Object.defineProperty(this.sessionInfo, key, {
66587
+ value: overrides[key]
66588
+ });
66589
+ });
66590
+ }
66591
+ connectMessenger.call(this);
66592
+
66593
+ // Finish migration after 30s
66594
+ setTimeout(() => {
66595
+ // Disconnect old Rumor
66596
+ _sockets[currentMesagingUrl].disconnect();
66597
+ delete _sockets[currentMesagingUrl];
66598
+
66599
+ // Disconnect previous publisher and subcribers
66600
+ sessionObjects.publishers.forEach(publisher => publisher._.finishMigration());
66601
+ sessionObjects.subscribers.forEach(subscriber => subscriber._.finishMigration());
66602
+ setState('connected');
66603
+ }, 30000);
66604
+ };
66605
+ const targetUrl = (0, _proxyUrlHelper.default)(this.staticConfig.apiUrl, proxyUrl);
66606
+
66607
+ // GSI
66608
+ getSessionInfo({
66609
+ // anvilUrl: targetUrl,
66610
+ anvilUrl: 'https://api.dev.opentok.com',
66611
+ sessionId,
66612
+ token: _token,
66613
+ connectionId: _connectionId,
66614
+ clientVersion: this.staticConfig.clientVersion
66615
+ }).then(onSessionInfo, () => {});
66616
+ },
66484
66617
  privateEvents: new _events.default()
66485
66618
  };
66486
66619
 
@@ -66608,7 +66741,7 @@ function SessionFactory(deps) {
66608
66741
  _completion = _options;
66609
66742
  _options = null;
66610
66743
  }
66611
- if (this.isNot('connected')) {
66744
+ if (!this.isConnected()) {
66612
66745
  const notConnectedErrorMsg = 'Unable to send signal - you are not connected to the session.';
66613
66746
  dispatchOTError(otError(errors.NOT_CONNECTED, new Error(notConnectedErrorMsg), 500), _completion);
66614
66747
  return;
@@ -66734,7 +66867,7 @@ function SessionFactory(deps) {
66734
66867
  */
66735
66868
 
66736
66869
  this.forceDisconnect = function (connectionOrConnectionId, completionHandler) {
66737
- if (this.isNot('connected')) {
66870
+ if (!this.isConnected()) {
66738
66871
  const notConnectedErrorMsg = 'Cannot call forceDisconnect(). You are not ' + 'connected to the session.';
66739
66872
  dispatchOTError(otError(errors.NOT_CONNECTED, new Error(notConnectedErrorMsg), ExceptionCodes.NOT_CONNECTED), completionHandler);
66740
66873
  return;
@@ -66853,7 +66986,7 @@ function SessionFactory(deps) {
66853
66986
  dispatchError(invalidParameterError);
66854
66987
  return;
66855
66988
  }
66856
- if (_this.isNot('connected')) {
66989
+ if (!_this.isConnected()) {
66857
66990
  dispatchError(notConnectedError);
66858
66991
  return;
66859
66992
  }
@@ -67196,7 +67329,7 @@ function SessionFactory(deps) {
67196
67329
  return _ref5.apply(this, arguments);
67197
67330
  };
67198
67331
  }();
67199
- this.isConnected = () => this.is('connected');
67332
+ this.isConnected = () => this.is('connected', 'migrating');
67200
67333
  this.capabilities = new Capabilities([], {
67201
67334
  hasE2eeCapability
67202
67335
  });
@@ -68473,6 +68606,12 @@ function SessionDispatcher(session, _temp) {
68473
68606
  dispatcher.on('connection#created', connection => {
68474
68607
  addConnection(connection);
68475
68608
  });
68609
+
68610
+ // message to migrate the session
68611
+ // dispatcher.on('connection#migrate', () => {
68612
+ // session._.migrate();
68613
+ // });
68614
+
68476
68615
  dispatcher.on('connection#deleted', (connection, reason) => {
68477
68616
  connection = session.connections.get(connection);
68478
68617
  if (!connection) {
@@ -95288,6 +95427,7 @@ const createMOSScoreHelper = () => ({
95288
95427
  subscriber = properties.subscriber,
95289
95428
  getCurrentPeerConnection = properties.getCurrentPeerConnection,
95290
95429
  logging = properties.logging,
95430
+ qosQualityScores = properties.qosQualityScores,
95291
95431
  _properties$rtcScore = properties.rtcScore,
95292
95432
  rtcScore = _properties$rtcScore === void 0 ? _rtcscore.score : _properties$rtcScore,
95293
95433
  _properties$samplingI = properties.samplingInterval,
@@ -95396,6 +95536,10 @@ const createMOSScoreHelper = () => ({
95396
95536
  qualityScore = {};
95397
95537
  currentAudioScore = Number.isNaN(scores.audio) ? undefined : scores.audio;
95398
95538
  currentVideoScore = Number.isNaN(scores.video) ? undefined : scores.video;
95539
+ if (qosQualityScores) {
95540
+ qosQualityScores.audioQualityScore = currentAudioScore;
95541
+ qosQualityScores.videoQualityScore = currentVideoScore;
95542
+ }
95399
95543
  if (scores.audio && subscriber.stream.hasAudio) {
95400
95544
  qualityScore.audioQualityScore = scores.audio;
95401
95545
  }
@@ -95410,7 +95554,7 @@ const createMOSScoreHelper = () => ({
95410
95554
  }
95411
95555
  previousAudioScore = currentAudioScore;
95412
95556
  previousVideoScore = currentVideoScore;
95413
- case 22:
95557
+ case 23:
95414
95558
  case "end":
95415
95559
  return _context.stop();
95416
95560
  }