@opentok/client 2.35.0-alpha.21 → 2.35.0-alpha.23

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.35.0 ed92bfe44
2
+ * @license OpenTok.js 2.35.0 b3cd7abe5
3
3
  *
4
4
  * Copyright (c) 2010-2026 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: Tue, 12 May 2026 09:42:15 GMT
8
+ * Date: Wed, 13 May 2026 13:03:31 GMT
9
9
  */
10
10
 
11
11
  (function webpackUniversalModuleDefinition(root, factory) {
@@ -5059,6 +5059,7 @@ function SinglePeerConnectionAdapterFactory(deps) {
5059
5059
  };
5060
5060
 
5061
5061
  // SPC events wrapper for PeerConnection
5062
+ const _onIceRestartAttempt = ev => this.trigger('iceRestartAttempt', ev);
5062
5063
  const _onClosed = () => this.trigger('close');
5063
5064
  const _onRemoteVideoSupported = supported => this.trigger('remoteVideoSupported', supported);
5064
5065
  const _onPeerError = _ref => {
@@ -5100,6 +5101,7 @@ function SinglePeerConnectionAdapterFactory(deps) {
5100
5101
  error: _onPeerError,
5101
5102
  qos: _onQoS,
5102
5103
  iceConnectionStateChange: _onIceConnectionStateChanged,
5104
+ iceRestartAttempt: _onIceRestartAttempt,
5103
5105
  remoteVideoSupported: _onRemoteVideoSupported,
5104
5106
  decryptFailed: _onDecryptFailed,
5105
5107
  decryptRestored: _onDecryptRestored
@@ -5210,7 +5212,7 @@ function SinglePeerConnectionAdapterFactory(deps) {
5210
5212
  };
5211
5213
  this.remoteStreams = () => _peerConnection.remoteStreams();
5212
5214
  this.hasRelayCandidates = () => _peerConnection.hasRelayCandidates();
5213
- this.iceRestart = () => _peerConnection.iceRestart();
5215
+ this.iceRestart = (reason, forcedRestart) => _peerConnection.iceRestart(reason, forcedRestart);
5214
5216
  this.iceConnectionStateIsConnected = () => _peerConnection.iceConnectionStateIsConnected();
5215
5217
  this.startDecryption = (connectionId, transceiver) => _peerConnection.startDecryption(connectionId, transceiver);
5216
5218
  };
@@ -6437,6 +6439,10 @@ function PublisherPeerConnectionFactory(deps) {
6437
6439
  const statsHelpers = getStatsHelpers();
6438
6440
 
6439
6441
  // Private
6442
+ const _onIceRestartAttempt = ev => {
6443
+ _awaitingIceRestart = true;
6444
+ this.trigger('iceRestartAttempt', ev);
6445
+ };
6440
6446
  const _onPeerClosed = function _onPeerClosed() {
6441
6447
  this.destroy();
6442
6448
  if (_awaitingIceRestart) {
@@ -6622,7 +6628,8 @@ function PublisherPeerConnectionFactory(deps) {
6622
6628
  close: _onPeerClosed,
6623
6629
  error: _onPeerError,
6624
6630
  qos: _qos => this.trigger('qos', _qos),
6625
- iceConnectionStateChange: _onIceConnectionStateChange
6631
+ iceConnectionStateChange: _onIceConnectionStateChange,
6632
+ iceRestartAttempt: _onIceRestartAttempt
6626
6633
  }, this);
6627
6634
  _peerConnection.addLocalStream(webRTCStream).then(() => {
6628
6635
  completion(undefined);
@@ -6638,11 +6645,9 @@ function PublisherPeerConnectionFactory(deps) {
6638
6645
  this.getSenders = function () {
6639
6646
  return _peerConnection.getSenders();
6640
6647
  };
6641
- this.iceRestart = function () {
6642
- if (_peerConnection) {
6643
- _awaitingIceRestart = true;
6644
- _peerConnection.iceRestart();
6645
- }
6648
+ this.iceRestart = function (reason, forcedRestart) {
6649
+ var _peerConnection2;
6650
+ (_peerConnection2 = _peerConnection) == null ? void 0 : _peerConnection2.iceRestart(reason, forcedRestart);
6646
6651
  };
6647
6652
  this.hasRelayCandidates = () => _peerConnection.hasRelayCandidates();
6648
6653
  this.iceConnectionStateIsConnected = function () {
@@ -20048,6 +20053,10 @@ function SubscriberPeerConnectionFactory(deps) {
20048
20053
  const _audioTracks = [];
20049
20054
 
20050
20055
  // Private
20056
+ const _onIceRestartAttempt = ev => {
20057
+ _awaitingIceRestart = true;
20058
+ this.trigger('iceRestartAttempt', ev);
20059
+ };
20051
20060
  const _onPeerClosed = function _onPeerClosed() {
20052
20061
  this.destroy();
20053
20062
  if (_awaitingIceRestart) {
@@ -20239,9 +20248,8 @@ function SubscriberPeerConnectionFactory(deps) {
20239
20248
  this.hasRelayCandidates = function () {
20240
20249
  return _peerConnection.hasRelayCandidates();
20241
20250
  };
20242
- this.iceRestart = function () {
20243
- _awaitingIceRestart = true;
20244
- return _peerConnection.iceRestart();
20251
+ this.iceRestart = function (reason, forcedRestart) {
20252
+ return _peerConnection.iceRestart(reason, forcedRestart);
20245
20253
  };
20246
20254
  this.iceConnectionStateIsConnected = function () {
20247
20255
  return _peerConnection.iceConnectionStateIsConnected();
@@ -20292,6 +20300,7 @@ function SubscriberPeerConnectionFactory(deps) {
20292
20300
  error: _onPeerError,
20293
20301
  qos: _qos => this.trigger('qos', _qos),
20294
20302
  iceConnectionStateChange: _onIceConnectionStateChange,
20303
+ iceRestartAttempt: _onIceRestartAttempt,
20295
20304
  remoteVideoSupported: _onRemoteVideoSupported,
20296
20305
  decryptFailed: _onDecryptFailed,
20297
20306
  decryptRestored: _onDecryptRestored
@@ -24498,8 +24507,8 @@ function SubscriberFactory(_ref2) {
24498
24507
  logAnalyticsEvent('Subscribe', variation, payload, options);
24499
24508
  }
24500
24509
  };
24501
- const logResubscribe = (variation, payload) => {
24502
- logAnalyticsEvent('ICERestart', variation, payload);
24510
+ const logResubscribe = (variation, payload, options) => {
24511
+ logAnalyticsEvent('ICERestart', variation, payload, options);
24503
24512
  };
24504
24513
  const recordQOS = _ref13 => {
24505
24514
  var _session$connection$c, _session8, _session8$connection, _properties$preferred, _properties$preferred2, _socket;
@@ -25223,13 +25232,17 @@ function SubscriberFactory(_ref2) {
25223
25232
  _subscriberConnectionState = currentConnectionState;
25224
25233
  }
25225
25234
  };
25226
- const onIceRestartSuccess = () => {
25227
- logResubscribe('Success');
25228
- };
25229
- const onIceRestartFailure = () => {
25230
- logResubscribe('Failure', {
25231
- reason: 'ICEWorkflow',
25232
- message: 'OT.Subscriber PeerConnection Error: ' + 'The stream was unable to connect due to a network error.' + ' Make sure your connection isn\'t blocked by a firewall.'
25235
+ const onIceRestartAction = (ev, variation, peerConnection, peerId) => {
25236
+ const sourceStreamId = peerConnection.getSourceStreamId();
25237
+ const payload = {
25238
+ isActive: sourceStreamId === _activeSourceStreamId
25239
+ };
25240
+ if (variation === 'Attempt' && ev != null && ev.reason) {
25241
+ payload.reason = ev.reason;
25242
+ }
25243
+ logResubscribe(variation, payload, {
25244
+ peerId,
25245
+ sourceStreamId
25233
25246
  });
25234
25247
  };
25235
25248
  const streamUpdated = event => {
@@ -25518,7 +25531,7 @@ function SubscriberFactory(_ref2) {
25518
25531
  return _ref22.apply(this, arguments);
25519
25532
  };
25520
25533
  }();
25521
- const setPeerConnectionEvents = (peerConnection, sourceStreamId) => {
25534
+ const setPeerConnectionEvents = (peerConnection, sourceStreamId, peerId) => {
25522
25535
  if (_peerConnectionEvents[sourceStreamId]) {
25523
25536
  _peerConnectionEvents[sourceStreamId].removeAll();
25524
25537
  const onDisconnected = () => {
@@ -25576,8 +25589,9 @@ function SubscriberFactory(_ref2) {
25576
25589
  }, _callee13);
25577
25590
  })));
25578
25591
  peerConnectionEvents.on('iceConnectionStateChange', state => onIceConnectionStateChange(state, peerConnection));
25579
- peerConnectionEvents.on('iceRestartSuccess', onIceRestartSuccess);
25580
- peerConnectionEvents.on('iceRestartFailure', onIceRestartFailure);
25592
+ peerConnectionEvents.on('iceRestartAttempt', ev => onIceRestartAction(ev, 'Attempt', peerConnection, peerId));
25593
+ peerConnectionEvents.on('iceRestartSuccess', ev => onIceRestartAction(ev, 'Success', peerConnection, peerId));
25594
+ peerConnectionEvents.on('iceRestartFailure', ev => onIceRestartAction(ev, 'Failure', peerConnection, peerId));
25581
25595
  peerConnectionEvents.on('remoteVideoSupported', onRemoteVideoSupported);
25582
25596
  peerConnectionEvents.on('decryptFailed', () => {
25583
25597
  this.trigger('encryptionSecretMismatch');
@@ -25877,7 +25891,8 @@ function SubscriberFactory(_ref2) {
25877
25891
  send,
25878
25892
  log,
25879
25893
  logQoS,
25880
- sourceStreamId
25894
+ sourceStreamId,
25895
+ peerId
25881
25896
  }));
25882
25897
  case 6:
25883
25898
  case "end":
@@ -26735,11 +26750,11 @@ function SubscriberFactory(_ref2) {
26735
26750
  };
26736
26751
  this._setupPeerConnection = /*#__PURE__*/function () {
26737
26752
  var _ref35 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19(_ref34) {
26738
- var send, log, logQoS, sourceStreamId;
26753
+ var send, log, logQoS, sourceStreamId, peerId;
26739
26754
  return _regenerator.default.wrap(function _callee19$(_context19) {
26740
26755
  while (1) switch (_context19.prev = _context19.next) {
26741
26756
  case 0:
26742
- send = _ref34.send, log = _ref34.log, logQoS = _ref34.logQoS, sourceStreamId = _ref34.sourceStreamId;
26757
+ send = _ref34.send, log = _ref34.log, logQoS = _ref34.logQoS, sourceStreamId = _ref34.sourceStreamId, peerId = _ref34.peerId;
26743
26758
  if (_properties.testNetwork) {
26744
26759
  _this.setAudioVolume(0);
26745
26760
  }
@@ -26779,7 +26794,7 @@ function SubscriberFactory(_ref2) {
26779
26794
  peerConnection.once('iceConnected', _pcConnected.resolve);
26780
26795
  peerConnection.once('error', _pcConnected.reject);
26781
26796
  peerConnection.on('qos', logQoS);
26782
- setPeerConnectionEvents(peerConnection, sourceStreamId);
26797
+ setPeerConnectionEvents(peerConnection, sourceStreamId, peerId);
26783
26798
 
26784
26799
  // initialize the peer connection AFTER we've added the event listeners
26785
26800
  peerConnection.init(err => {
@@ -26911,15 +26926,9 @@ function SubscriberFactory(_ref2) {
26911
26926
  logging.debug('Subscriber: Skipping ice restart, we have no peer connection');
26912
26927
  return _context21.abrupt("return");
26913
26928
  case 12:
26914
- logResubscribe('Attempt', {
26915
- reason
26916
- });
26917
26929
  logging.debug('Subscriber: iceRestart attempt');
26918
- peerConnection.iceRestart();
26919
- if (forcedRestart) {
26920
- peerConnection.generateOffer();
26921
- }
26922
- case 16:
26930
+ peerConnection.iceRestart(reason, forcedRestart);
26931
+ case 14:
26923
26932
  case "end":
26924
26933
  return _context21.stop();
26925
26934
  }
@@ -41649,7 +41658,7 @@ function staticConfigFactory(_temp) {
41649
41658
  _ref$axios = _ref.axios,
41650
41659
  axios = _ref$axios === void 0 ? _axios.default : _ref$axios,
41651
41660
  _ref$properties = _ref.properties,
41652
- properties = _ref$properties === void 0 ? {"version":"v2.35.0","buildHash":"ed92bfe44","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","vonageApiURL":""} : _ref$properties;
41661
+ properties = _ref$properties === void 0 ? {"version":"v2.35.0","buildHash":"b3cd7abe5","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","vonageApiURL":""} : _ref$properties;
41653
41662
  /** @type builtInConfig */
41654
41663
  const builtInConfig = (0, _cloneDeep.default)(properties);
41655
41664
  /**
@@ -43399,6 +43408,7 @@ function PublisherFactory(_ref) {
43399
43408
  * @property {String} remoteSubscriberId The subscriber id of the remote side
43400
43409
  * @property {String} peerId The peerId of this peer connection
43401
43410
  * @property {String} peerConnectionId Our local identifier for this peer connection
43411
+ * @property {String} sourceStreamId The source stream id for this peer connection, either 'MANTIS' or 'P2P'
43402
43412
  */
43403
43413
 
43404
43414
  /**
@@ -43877,8 +43887,8 @@ function PublisherFactory(_ref) {
43877
43887
  logAnalyticsEvent('Publish', variation, payload, logOptions);
43878
43888
  }
43879
43889
  };
43880
- const logRepublish = (variation, payload) => {
43881
- logAnalyticsEvent('ICERestart', variation, payload);
43890
+ const logRepublish = (variation, payload, logOptions) => {
43891
+ logAnalyticsEvent('ICERestart', variation, payload, logOptions);
43882
43892
  };
43883
43893
  const logHybridSessionTransition = (action, variation, payload) => {
43884
43894
  if (variation === 'Attempt') {
@@ -44397,30 +44407,29 @@ function PublisherFactory(_ref) {
44397
44407
  var _this$session8, _this$session8$sessio;
44398
44408
  return ((_this$session8 = this.session) == null ? void 0 : (_this$session8$sessio = _this$session8.sessionInfo) == null ? void 0 : _this$session8$sessio.isAdaptiveEnabled) && peerConnection.getSourceStreamId() === 'P2P';
44399
44409
  };
44400
- const onIceRestartSuccess = peerConnection => {
44410
+ const onIceRestartAction = (ev, variation, peerConnection) => {
44401
44411
  const _getPeerConnectionMet4 = getPeerConnectionMeta(peerConnection),
44402
- remoteConnectionId = _getPeerConnectionMet4.remoteConnectionId;
44403
- logRepublish('Success', {
44404
- remoteConnectionId
44405
- });
44406
- };
44407
- const onIceRestartFailure = peerConnection => {
44408
- const _getPeerConnectionMet5 = getPeerConnectionMeta(peerConnection),
44409
- remoteConnectionId = _getPeerConnectionMet5.remoteConnectionId;
44410
- logRepublish('Failure', {
44411
- reason: 'ICEWorkflow',
44412
- message: 'OT.Publisher PeerConnection Error: ' + 'The stream was unable to connect due to a network error.' + ' Make sure your connection isn\'t blocked by a firewall.',
44413
- remoteConnectionId
44412
+ peerId = _getPeerConnectionMet4.peerId,
44413
+ remoteConnectionId = _getPeerConnectionMet4.remoteConnectionId,
44414
+ sourceStreamId = _getPeerConnectionMet4.sourceStreamId;
44415
+ if (variation === 'Success' && sourceStreamId === 'MANTIS' && activeSourceStreamId === 'P2P') {
44416
+ _keepSendingRtcpToMantis(true);
44417
+ }
44418
+ const payload = {
44419
+ remoteConnectionId,
44420
+ isActive: sourceStreamId === activeSourceStreamId
44421
+ };
44422
+ if (variation === 'Attempt' && ev != null && ev.reason) {
44423
+ payload.reason = ev.reason;
44424
+ }
44425
+ logRepublish(variation, payload, {
44426
+ peerId,
44427
+ sourceStreamId
44414
44428
  });
44415
44429
  };
44416
44430
  const handleDisconnect = peerConnection => {
44417
44431
  if (_session._.isSocketConnected()) {
44418
- const _getPeerConnectionMet6 = getPeerConnectionMeta(peerConnection),
44419
- remoteConnectionId = _getPeerConnectionMet6.remoteConnectionId;
44420
- logRepublish('Attempt', {
44421
- remoteConnectionId
44422
- });
44423
- peerConnection.iceRestart();
44432
+ peerConnection.iceRestart('peer connection disconnected');
44424
44433
  }
44425
44434
  };
44426
44435
  const handleConnect = /*#__PURE__*/function () {
@@ -44559,9 +44568,9 @@ function PublisherFactory(_ref) {
44559
44568
  if (isRoutedToRelayedTransitionComplete(peerConnection)) {
44560
44569
  logRoutedToRelayedTransition('Success');
44561
44570
  }
44562
- const _getPeerConnectionMet7 = getPeerConnectionMeta(peerConnection),
44563
- peerConnectionId = _getPeerConnectionMet7.peerConnectionId,
44564
- remoteSubscriberId = _getPeerConnectionMet7.remoteSubscriberId;
44571
+ const _getPeerConnectionMet5 = getPeerConnectionMeta(peerConnection),
44572
+ peerConnectionId = _getPeerConnectionMet5.peerConnectionId,
44573
+ remoteSubscriberId = _getPeerConnectionMet5.remoteSubscriberId;
44565
44574
  (_publisherSenderStats2 = publisherSenderStats) == null ? void 0 : _publisherSenderStats2.addConnection(peerConnection, peerConnectionId, remoteSubscriberId);
44566
44575
  if (properties.publishVideo) {
44567
44576
  if (videoQualityChangedListenersCount > 0) {
@@ -44699,8 +44708,9 @@ function PublisherFactory(_ref) {
44699
44708
  });
44700
44709
  },
44701
44710
  qos: logQoS,
44702
- iceRestartSuccess: () => onIceRestartSuccess(peerConnection),
44703
- iceRestartFailure: () => onIceRestartFailure(peerConnection),
44711
+ iceRestartAttempt: ev => onIceRestartAction(ev, 'Attempt', peerConnection),
44712
+ iceRestartSuccess: ev => onIceRestartAction(ev, 'Success', peerConnection),
44713
+ iceRestartFailure: ev => onIceRestartAction(ev, 'Failure', peerConnection),
44704
44714
  iceConnectionStateChange: newState => onIceConnectionStateChange(newState, peerConnection),
44705
44715
  audioAcquisitionProblem: () => {
44706
44716
  audioAcquisitionProblemDetected = true;
@@ -44721,9 +44731,9 @@ function PublisherFactory(_ref) {
44721
44731
  peerId: getPeerConnectionMeta(peerConnection).peerId
44722
44732
  })),
44723
44733
  videoQualityChanged: ev => {
44724
- const _getPeerConnectionMet8 = getPeerConnectionMeta(peerConnection),
44725
- remoteConnectionId = _getPeerConnectionMet8.remoteConnectionId,
44726
- remoteSubscriberId = _getPeerConnectionMet8.remoteSubscriberId;
44734
+ const _getPeerConnectionMet6 = getPeerConnectionMeta(peerConnection),
44735
+ remoteConnectionId = _getPeerConnectionMet6.remoteConnectionId,
44736
+ remoteSubscriberId = _getPeerConnectionMet6.remoteSubscriberId;
44727
44737
  const statsContainer = (0, _assign.default)(remoteConnectionId.match(/^symphony\./) ? {} : {
44728
44738
  subscriberId: remoteSubscriberId,
44729
44739
  connectionId: remoteConnectionId
@@ -44952,9 +44962,9 @@ function PublisherFactory(_ref) {
44952
44962
  results = pcsAndStats.map(_ref22 => {
44953
44963
  let pc = _ref22.pc,
44954
44964
  stats = _ref22.stats;
44955
- const _getPeerConnectionMet9 = getPeerConnectionMeta(pc),
44956
- remoteConnectionId = _getPeerConnectionMet9.remoteConnectionId,
44957
- remoteSubscriberId = _getPeerConnectionMet9.remoteSubscriberId;
44965
+ const _getPeerConnectionMet7 = getPeerConnectionMeta(pc),
44966
+ remoteConnectionId = _getPeerConnectionMet7.remoteConnectionId,
44967
+ remoteSubscriberId = _getPeerConnectionMet7.remoteSubscriberId;
44958
44968
  return (0, _assign.default)(remoteConnectionId.match(/^symphony\./) ? {} : {
44959
44969
  subscriberId: remoteSubscriberId,
44960
44970
  connectionId: remoteConnectionId
@@ -45011,7 +45021,7 @@ function PublisherFactory(_ref) {
45011
45021
  case 3:
45012
45022
  mantisPC = _context13.sent;
45013
45023
  if (!mantisPC) {
45014
- _context13.next = 19;
45024
+ _context13.next = 17;
45015
45025
  break;
45016
45026
  }
45017
45027
  _this.trigger('sourceStreamIdChanged', 'P2P');
@@ -45037,13 +45047,15 @@ function PublisherFactory(_ref) {
45037
45047
  _context13.next = 16;
45038
45048
  return mantisPC.deactivateVideoEncodings();
45039
45049
  case 16:
45040
- if (!(OTHelpers.env.isFirefox && OTHelpers.env.version < 96)) {
45041
- _context13.next = 19;
45042
- break;
45050
+ // In FF < v96, when the media direction is changed to inactive, it stops sending RTCP.
45051
+ // This causes that after ~60 seconds, MANTIS considers the stream is inactive
45052
+ // and destroys it.
45053
+ // As a workaround, we are going to send RTP and RTCP every 30 seconds to keep the
45054
+ // connection alive. See: OPENTOK-44341
45055
+ if (OTHelpers.env.isFirefox && OTHelpers.env.version < 96) {
45056
+ _keepSendingRtcpToMantis();
45043
45057
  }
45044
- _context13.next = 19;
45045
- return _keepSendingRtcpToMantis();
45046
- case 19:
45058
+ case 17:
45047
45059
  case "end":
45048
45060
  return _context13.stop();
45049
45061
  }
@@ -45078,6 +45090,7 @@ function PublisherFactory(_ref) {
45078
45090
  }
45079
45091
  if (_keepSendingRtcpToMantisTimeout) {
45080
45092
  clearTimeout(_keepSendingRtcpToMantisTimeout);
45093
+ _keepSendingRtcpToMantisTimeout = null;
45081
45094
  }
45082
45095
  _this.trigger('sourceStreamIdChanged', 'MANTIS');
45083
45096
  if (!(properties.publishVideo && (properties.publisherAudioFallbackEnabled || getStatsCalled || networkConditionChangedListenersCount > 0))) {
@@ -45099,51 +45112,106 @@ function PublisherFactory(_ref) {
45099
45112
  return _ref24.apply(this, arguments);
45100
45113
  };
45101
45114
  }();
45115
+ const sendRtcpBurst = /*#__PURE__*/function () {
45116
+ var _ref25 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15(peerConnection) {
45117
+ return _regenerator.default.wrap(function _callee15$(_context15) {
45118
+ while (1) switch (_context15.prev = _context15.next) {
45119
+ case 0:
45120
+ _context15.prev = 0;
45121
+ _context15.next = 3;
45122
+ return peerConnection.activateVideoEncodings();
45123
+ case 3:
45124
+ _context15.next = 5;
45125
+ return (0, _promiseDelay.default)(KEEP_SENDING_MEDIA_TO_KEEP_ALIVE);
45126
+ case 5:
45127
+ if (!(activeSourceStreamId === 'P2P')) {
45128
+ _context15.next = 8;
45129
+ break;
45130
+ }
45131
+ _context15.next = 8;
45132
+ return peerConnection.deactivateVideoEncodings();
45133
+ case 8:
45134
+ _context15.next = 13;
45135
+ break;
45136
+ case 10:
45137
+ _context15.prev = 10;
45138
+ _context15.t0 = _context15["catch"](0);
45139
+ logging.error('Error while trying to keep sending RTCP to MANTIS:', _context15.t0);
45140
+ case 13:
45141
+ case "end":
45142
+ return _context15.stop();
45143
+ }
45144
+ }, _callee15, null, [[0, 10]]);
45145
+ }));
45146
+ return function sendRtcpBurst(_x10) {
45147
+ return _ref25.apply(this, arguments);
45148
+ };
45149
+ }();
45102
45150
  const _keepSendingRtcpToMantis = /*#__PURE__*/function () {
45103
- var _ref25 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16() {
45151
+ var _ref26 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(onlyOnce) {
45104
45152
  var peerConnection;
45105
- return _regenerator.default.wrap(function _callee16$(_context16) {
45106
- while (1) switch (_context16.prev = _context16.next) {
45153
+ return _regenerator.default.wrap(function _callee17$(_context17) {
45154
+ while (1) switch (_context17.prev = _context17.next) {
45107
45155
  case 0:
45108
- _context16.next = 2;
45156
+ if (onlyOnce === void 0) {
45157
+ onlyOnce = false;
45158
+ }
45159
+ _context17.prev = 1;
45160
+ _context17.next = 4;
45109
45161
  return getMantisPeerConnection();
45110
- case 2:
45111
- peerConnection = _context16.sent;
45162
+ case 4:
45163
+ peerConnection = _context17.sent;
45164
+ _context17.next = 10;
45165
+ break;
45166
+ case 7:
45167
+ _context17.prev = 7;
45168
+ _context17.t0 = _context17["catch"](1);
45169
+ logging.error('Error while trying to get MANTIS peer connection to keep sending RTCP:', _context17.t0);
45170
+ case 10:
45112
45171
  if (peerConnection) {
45113
- _keepSendingRtcpToMantisTimeout = setTimeout( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15() {
45114
- return _regenerator.default.wrap(function _callee15$(_context15) {
45115
- while (1) switch (_context15.prev = _context15.next) {
45172
+ _context17.next = 12;
45173
+ break;
45174
+ }
45175
+ return _context17.abrupt("return");
45176
+ case 12:
45177
+ if (onlyOnce) {
45178
+ sendRtcpBurst(peerConnection);
45179
+ } else {
45180
+ _keepSendingRtcpToMantisTimeout = setTimeout( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16() {
45181
+ return _regenerator.default.wrap(function _callee16$(_context16) {
45182
+ while (1) switch (_context16.prev = _context16.next) {
45116
45183
  case 0:
45117
45184
  if (!(activeSourceStreamId === 'P2P')) {
45118
- _context15.next = 9;
45185
+ _context16.next = 6;
45119
45186
  break;
45120
45187
  }
45121
- _context15.next = 3;
45122
- return peerConnection.activateVideoEncodings();
45188
+ _context16.next = 3;
45189
+ return sendRtcpBurst(peerConnection);
45123
45190
  case 3:
45124
- _context15.next = 5;
45125
- return (0, _promiseDelay.default)(KEEP_SENDING_MEDIA_TO_KEEP_ALIVE);
45126
- case 5:
45127
- _context15.next = 7;
45128
- return peerConnection.deactivateVideoEncodings();
45191
+ if (activeSourceStreamId === 'P2P') {
45192
+ _keepSendingRtcpToMantis();
45193
+ } else {
45194
+ _keepSendingRtcpToMantisTimeout = null;
45195
+ }
45196
+ _context16.next = 7;
45197
+ break;
45198
+ case 6:
45199
+ _keepSendingRtcpToMantisTimeout = null;
45129
45200
  case 7:
45130
- _context15.next = 9;
45131
- return _keepSendingRtcpToMantis();
45132
- case 9:
45133
45201
  case "end":
45134
- return _context15.stop();
45202
+ return _context16.stop();
45135
45203
  }
45136
- }, _callee15);
45204
+ }, _callee16);
45137
45205
  })), KEEP_SENDING_RTCP_DELAY);
45138
45206
  }
45139
- case 4:
45207
+ case 13:
45140
45208
  case "end":
45141
- return _context16.stop();
45209
+ return _context17.stop();
45142
45210
  }
45143
- }, _callee16);
45211
+ }, _callee17, null, [[1, 7]]);
45144
45212
  }));
45145
- return function _keepSendingRtcpToMantis() {
45146
- return _ref25.apply(this, arguments);
45213
+ return function _keepSendingRtcpToMantis(_x11) {
45214
+ return _ref26.apply(this, arguments);
45147
45215
  };
45148
45216
  }();
45149
45217
  const _transitionRoutedToRelayed = () => {
@@ -45179,55 +45247,55 @@ function PublisherFactory(_ref) {
45179
45247
  });
45180
45248
  };
45181
45249
  const _transitionRelayedToRouted = /*#__PURE__*/function () {
45182
- var _ref27 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17() {
45183
- return _regenerator.default.wrap(function _callee17$(_context17) {
45184
- while (1) switch (_context17.prev = _context17.next) {
45250
+ var _ref28 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18() {
45251
+ return _regenerator.default.wrap(function _callee18$(_context18) {
45252
+ while (1) switch (_context18.prev = _context18.next) {
45185
45253
  case 0:
45186
45254
  if (!(activeSourceStreamId !== 'P2P')) {
45187
- _context17.next = 2;
45255
+ _context18.next = 2;
45188
45256
  break;
45189
45257
  }
45190
- return _context17.abrupt("return");
45258
+ return _context18.abrupt("return");
45191
45259
  case 2:
45192
45260
  logRelayedToRoutedTransition('Attempt');
45193
45261
  if (_this.session) {
45194
- _context17.next = 6;
45262
+ _context18.next = 6;
45195
45263
  break;
45196
45264
  }
45197
45265
  logRelayedToRoutedTransition('Failure', {
45198
45266
  reason: 'Not connected to the session.'
45199
45267
  });
45200
- return _context17.abrupt("return");
45268
+ return _context18.abrupt("return");
45201
45269
  case 6:
45202
45270
  if (_this.streamId) {
45203
- _context17.next = 9;
45271
+ _context18.next = 9;
45204
45272
  break;
45205
45273
  }
45206
45274
  logRelayedToRoutedTransition('Failure', {
45207
45275
  reason: 'No streamId available'
45208
45276
  });
45209
- return _context17.abrupt("return");
45277
+ return _context18.abrupt("return");
45210
45278
  case 9:
45211
- _context17.next = 11;
45279
+ _context18.next = 11;
45212
45280
  return _restartSendingRtpToMantis();
45213
45281
  case 11:
45214
45282
  _this.session._.streamDestroy(_this.streamId, 'P2P');
45215
- _context17.t0 = _this;
45216
- _context17.next = 15;
45283
+ _context18.t0 = _this;
45284
+ _context18.next = 15;
45217
45285
  return getP2pPeerConnection();
45218
45286
  case 15:
45219
- _context17.t1 = _context17.sent;
45220
- _context17.t0._removePeerConnection.call(_context17.t0, _context17.t1);
45287
+ _context18.t1 = _context18.sent;
45288
+ _context18.t0._removePeerConnection.call(_context18.t0, _context18.t1);
45221
45289
  logRelayedToRoutedTransition('Success');
45222
45290
  _this.trigger('streamDestroyForP2PComplete');
45223
45291
  case 19:
45224
45292
  case "end":
45225
- return _context17.stop();
45293
+ return _context18.stop();
45226
45294
  }
45227
- }, _callee17);
45295
+ }, _callee18);
45228
45296
  }));
45229
45297
  return function _transitionRelayedToRouted() {
45230
- return _ref27.apply(this, arguments);
45298
+ return _ref28.apply(this, arguments);
45231
45299
  };
45232
45300
  }();
45233
45301
 
@@ -45359,11 +45427,11 @@ function PublisherFactory(_ref) {
45359
45427
  this.dispatchEvent(event);
45360
45428
  });
45361
45429
  getUserMedia().catch(userMediaError).then( /*#__PURE__*/function () {
45362
- var _ref28 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18(stream) {
45430
+ var _ref29 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19(stream) {
45363
45431
  var _audioDevices, _videoDevices;
45364
45432
  var hasVideoFilter, addAudioInputDevicesChangeListener, hasAudioVideoDevices;
45365
- return _regenerator.default.wrap(function _callee18$(_context18) {
45366
- while (1) switch (_context18.prev = _context18.next) {
45433
+ return _regenerator.default.wrap(function _callee19$(_context19) {
45434
+ while (1) switch (_context19.prev = _context19.next) {
45367
45435
  case 0:
45368
45436
  // this comes from deviceHelpers.shouldAskForDevices in a round-about way
45369
45437
  audioDevices = processedOptions.audioDevices;
@@ -45388,7 +45456,7 @@ function PublisherFactory(_ref) {
45388
45456
  // else the wrong device will be returned/nonsensical
45389
45457
  currentDeviceId = (0, _getDeviceIdFromStream.default)(stream, videoDevices);
45390
45458
  }
45391
- _context18.next = 9;
45459
+ _context19.next = 9;
45392
45460
  return onStreamAvailable(stream);
45393
45461
  case 9:
45394
45462
  if (!properties.publishVideo) {
@@ -45403,7 +45471,7 @@ function PublisherFactory(_ref) {
45403
45471
  setCurrentTrackDeviceId(currentDeviceId);
45404
45472
  }
45405
45473
  }
45406
- return _context18.abrupt("return", bindVideo().catch(error => {
45474
+ return _context19.abrupt("return", bindVideo().catch(error => {
45407
45475
  if (error instanceof _cancel.CancellationError) {
45408
45476
  // If we get a CancellationError, it means something newer tried
45409
45477
  // to bindVideo before the old one succeeded, perhaps they called
@@ -45424,118 +45492,118 @@ function PublisherFactory(_ref) {
45424
45492
  }));
45425
45493
  case 12:
45426
45494
  case "end":
45427
- return _context18.stop();
45495
+ return _context19.stop();
45428
45496
  }
45429
- }, _callee18);
45497
+ }, _callee19);
45430
45498
  }));
45431
- return function (_x10) {
45432
- return _ref28.apply(this, arguments);
45499
+ return function (_x12) {
45500
+ return _ref29.apply(this, arguments);
45433
45501
  };
45434
45502
  }());
45435
45503
  });
45436
45504
  return this;
45437
45505
  };
45438
- this._getVideoSenders = /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19() {
45439
- return _regenerator.default.wrap(function _callee19$(_context19) {
45440
- while (1) switch (_context19.prev = _context19.next) {
45506
+ this._getVideoSenders = /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20() {
45507
+ return _regenerator.default.wrap(function _callee20$(_context20) {
45508
+ while (1) switch (_context20.prev = _context20.next) {
45441
45509
  case 0:
45442
- return _context19.abrupt("return", getAllPeerConnections().then(peerConnections => peerConnections[0].getSenders().filter(_ref30 => {
45443
- let kind = _ref30.track.kind;
45510
+ return _context20.abrupt("return", getAllPeerConnections().then(peerConnections => peerConnections[0].getSenders().filter(_ref31 => {
45511
+ let kind = _ref31.track.kind;
45444
45512
  return kind === 'video';
45445
45513
  })));
45446
45514
  case 1:
45447
45515
  case "end":
45448
- return _context19.stop();
45516
+ return _context20.stop();
45449
45517
  }
45450
- }, _callee19);
45518
+ }, _callee20);
45451
45519
  }));
45452
45520
  this._setScalableValues = /*#__PURE__*/function () {
45453
- var _ref31 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20(scalableParam, scalableValues) {
45521
+ var _ref32 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21(scalableParam, scalableValues) {
45454
45522
  var senders, sender, sendParameters;
45455
- return _regenerator.default.wrap(function _callee20$(_context20) {
45456
- while (1) switch (_context20.prev = _context20.next) {
45523
+ return _regenerator.default.wrap(function _callee21$(_context21) {
45524
+ while (1) switch (_context21.prev = _context21.next) {
45457
45525
  case 0:
45458
- _context20.next = 2;
45526
+ _context21.next = 2;
45459
45527
  return _this._getVideoSenders();
45460
45528
  case 2:
45461
- senders = _context20.sent;
45529
+ senders = _context21.sent;
45462
45530
  sender = senders[0];
45463
45531
  sendParameters = sender.getParameters();
45464
45532
  sendParameters.encodings.forEach((encoding, index) => {
45465
45533
  encoding[scalableParam] = scalableValues[index]; // eslint-disable-line no-param-reassign
45466
45534
  });
45467
- _context20.next = 8;
45535
+ _context21.next = 8;
45468
45536
  return sender.setParameters(sendParameters);
45469
45537
  case 8:
45470
45538
  case "end":
45471
- return _context20.stop();
45539
+ return _context21.stop();
45472
45540
  }
45473
- }, _callee20);
45541
+ }, _callee21);
45474
45542
  }));
45475
- return function (_x11, _x12) {
45476
- return _ref31.apply(this, arguments);
45543
+ return function (_x13, _x14) {
45544
+ return _ref32.apply(this, arguments);
45477
45545
  };
45478
45546
  }();
45479
45547
  this._setScalabilityMode = /*#__PURE__*/function () {
45480
- var _ref32 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21(scalabilityMode, codecsWhitelist) {
45481
- return _regenerator.default.wrap(function _callee21$(_context21) {
45482
- while (1) switch (_context21.prev = _context21.next) {
45548
+ var _ref33 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee22(scalabilityMode, codecsWhitelist) {
45549
+ return _regenerator.default.wrap(function _callee22$(_context22) {
45550
+ while (1) switch (_context22.prev = _context22.next) {
45483
45551
  case 0:
45484
- return _context21.abrupt("return", setScalabilityMode(_this, scalabilityMode, codecsWhitelist));
45552
+ return _context22.abrupt("return", setScalabilityMode(_this, scalabilityMode, codecsWhitelist));
45485
45553
  case 1:
45486
45554
  case "end":
45487
- return _context21.stop();
45555
+ return _context22.stop();
45488
45556
  }
45489
- }, _callee21);
45557
+ }, _callee22);
45490
45558
  }));
45491
- return function (_x13, _x14) {
45492
- return _ref32.apply(this, arguments);
45559
+ return function (_x15, _x16) {
45560
+ return _ref33.apply(this, arguments);
45493
45561
  };
45494
45562
  }();
45495
45563
  this._setScalableFramerates = /*#__PURE__*/function () {
45496
- var _ref33 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee22(frameRates) {
45564
+ var _ref34 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee23(frameRates) {
45497
45565
  var framerateValues;
45498
- return _regenerator.default.wrap(function _callee22$(_context22) {
45499
- while (1) switch (_context22.prev = _context22.next) {
45566
+ return _regenerator.default.wrap(function _callee23$(_context23) {
45567
+ while (1) switch (_context23.prev = _context23.next) {
45500
45568
  case 0:
45501
45569
  framerateValues = normalizeScalableValues(frameRates);
45502
45570
  if (!(framerateValues && areValidFramerates(framerateValues))) {
45503
- _context22.next = 4;
45571
+ _context23.next = 4;
45504
45572
  break;
45505
45573
  }
45506
- _context22.next = 4;
45574
+ _context23.next = 4;
45507
45575
  return _this._setScalableValues('maxFramerate', framerateValues);
45508
45576
  case 4:
45509
45577
  case "end":
45510
- return _context22.stop();
45578
+ return _context23.stop();
45511
45579
  }
45512
- }, _callee22);
45580
+ }, _callee23);
45513
45581
  }));
45514
- return function (_x15) {
45515
- return _ref33.apply(this, arguments);
45582
+ return function (_x17) {
45583
+ return _ref34.apply(this, arguments);
45516
45584
  };
45517
45585
  }();
45518
45586
  this._setScalableVideoLayers = /*#__PURE__*/function () {
45519
- var _ref34 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee23(videoLayers) {
45587
+ var _ref35 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee24(videoLayers) {
45520
45588
  var videoLayerValues;
45521
- return _regenerator.default.wrap(function _callee23$(_context23) {
45522
- while (1) switch (_context23.prev = _context23.next) {
45589
+ return _regenerator.default.wrap(function _callee24$(_context24) {
45590
+ while (1) switch (_context24.prev = _context24.next) {
45523
45591
  case 0:
45524
45592
  videoLayerValues = normalizeScalableValues(videoLayers);
45525
45593
  if (!(videoLayerValues && areValidResolutionScales(videoLayerValues))) {
45526
- _context23.next = 4;
45594
+ _context24.next = 4;
45527
45595
  break;
45528
45596
  }
45529
- _context23.next = 4;
45597
+ _context24.next = 4;
45530
45598
  return _this._setScalableValues('scaleResolutionDownBy', videoLayerValues);
45531
45599
  case 4:
45532
45600
  case "end":
45533
- return _context23.stop();
45601
+ return _context24.stop();
45534
45602
  }
45535
- }, _callee23);
45603
+ }, _callee24);
45536
45604
  }));
45537
- return function (_x16) {
45538
- return _ref34.apply(this, arguments);
45605
+ return function (_x18) {
45606
+ return _ref35.apply(this, arguments);
45539
45607
  };
45540
45608
  }();
45541
45609
  const areValidFramerates = framerates => {
@@ -45687,15 +45755,15 @@ function PublisherFactory(_ref) {
45687
45755
  let isTrackManuallyStopped = false;
45688
45756
  const updateVideo = () => {
45689
45757
  const shouldSendVideo = haveWorkingTracks('video') && properties.publishVideo;
45690
- (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee24() {
45758
+ (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee25() {
45691
45759
  var peerConnections, shouldApplyCustomMaxBitrate, executionSentinel, activePeerConnections;
45692
- return _regenerator.default.wrap(function _callee24$(_context24) {
45693
- while (1) switch (_context24.prev = _context24.next) {
45760
+ return _regenerator.default.wrap(function _callee25$(_context25) {
45761
+ while (1) switch (_context25.prev = _context25.next) {
45694
45762
  case 0:
45695
- _context24.next = 2;
45763
+ _context25.next = 2;
45696
45764
  return getAllPeerConnections();
45697
45765
  case 2:
45698
- peerConnections = _context24.sent;
45766
+ peerConnections = _context25.sent;
45699
45767
  // Set maxBitrare only if video is enabled and customMaxBitrate/videoPreset is enforced.
45700
45768
  // Please note this may disable some encodings in Simulcast VP8.
45701
45769
  shouldApplyCustomMaxBitrate = shouldSendVideo && _videoMaxBitrateSetting;
@@ -45716,10 +45784,10 @@ function PublisherFactory(_ref) {
45716
45784
  });
45717
45785
  }
45718
45786
  }
45719
- _context24.next = 7;
45787
+ _context25.next = 7;
45720
45788
  return getActivePeerConnections();
45721
45789
  case 7:
45722
- activePeerConnections = _context24.sent;
45790
+ activePeerConnections = _context25.sent;
45723
45791
  if (shouldSendVideo && videoQualityChangedListenersCount > 0) {
45724
45792
  activePeerConnections.forEach(peerConnection => {
45725
45793
  peerConnection.enableVideoQualityWatcher();
@@ -45731,9 +45799,9 @@ function PublisherFactory(_ref) {
45731
45799
  }
45732
45800
  case 9:
45733
45801
  case "end":
45734
- return _context24.stop();
45802
+ return _context25.stop();
45735
45803
  }
45736
- }, _callee24);
45804
+ }, _callee25);
45737
45805
  }))();
45738
45806
  if (isCustomVideoTrack && mediaProcessor) {
45739
45807
  const originalTrack = mediaProcessor.getOriginalVideoTrack();
@@ -45759,25 +45827,25 @@ function PublisherFactory(_ref) {
45759
45827
  refreshAudioVideoUI();
45760
45828
  };
45761
45829
  const destroyMediaProcessor = /*#__PURE__*/function () {
45762
- var _ref36 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee25() {
45830
+ var _ref37 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee26() {
45763
45831
  var videoTrack;
45764
- return _regenerator.default.wrap(function _callee25$(_context25) {
45765
- while (1) switch (_context25.prev = _context25.next) {
45832
+ return _regenerator.default.wrap(function _callee26$(_context26) {
45833
+ while (1) switch (_context26.prev = _context26.next) {
45766
45834
  case 0:
45767
45835
  // We need to cache this since calling the method below will
45768
45836
  // clear this value.
45769
45837
  videoTrack = mediaProcessor.getOriginalVideoTrack(); // Note: this needs to be called before the `stop` method below. Reversing
45770
45838
  // the order may cause race conditions with the MP worker.
45771
- _context25.prev = 1;
45772
- _context25.next = 4;
45839
+ _context26.prev = 1;
45840
+ _context26.next = 4;
45773
45841
  return mediaProcessor.destroy();
45774
45842
  case 4:
45775
- _context25.next = 9;
45843
+ _context26.next = 9;
45776
45844
  break;
45777
45845
  case 6:
45778
- _context25.prev = 6;
45779
- _context25.t0 = _context25["catch"](1);
45780
- logging.warn(`Error cleaning up mediaProcessor: ${_context25.t0}`);
45846
+ _context26.prev = 6;
45847
+ _context26.t0 = _context26["catch"](1);
45848
+ logging.warn(`Error cleaning up mediaProcessor: ${_context26.t0}`);
45781
45849
  case 9:
45782
45850
  // Since no filtering is being applied, we perform some cleanup. We
45783
45851
  // stop the original video track here since it's not being used
@@ -45785,12 +45853,12 @@ function PublisherFactory(_ref) {
45785
45853
  videoTrack.stop();
45786
45854
  case 10:
45787
45855
  case "end":
45788
- return _context25.stop();
45856
+ return _context26.stop();
45789
45857
  }
45790
- }, _callee25, null, [[1, 6]]);
45858
+ }, _callee26, null, [[1, 6]]);
45791
45859
  }));
45792
45860
  return function destroyMediaProcessor() {
45793
- return _ref36.apply(this, arguments);
45861
+ return _ref37.apply(this, arguments);
45794
45862
  };
45795
45863
  }();
45796
45864
  const hasTrackFromDevice = deviceId =>
@@ -45818,25 +45886,25 @@ function PublisherFactory(_ref) {
45818
45886
  let currentVideoFilter;
45819
45887
  let currentAudioFilter;
45820
45888
  this._toggleVideo = (0, _blockCallsUntilComplete.default)( /*#__PURE__*/function () {
45821
- var _ref37 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee26(shouldHaveVideo, videoDimensions) {
45889
+ var _ref38 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee27(shouldHaveVideo, videoDimensions) {
45822
45890
  var _vidDevices$find;
45823
45891
  var vidDevices, oldTrack, oldTrackDeviceId, newTrack, videoFilter, originalVideoTrack, _originalVideoTrack;
45824
- return _regenerator.default.wrap(function _callee26$(_context26) {
45825
- while (1) switch (_context26.prev = _context26.next) {
45892
+ return _regenerator.default.wrap(function _callee27$(_context27) {
45893
+ while (1) switch (_context27.prev = _context27.next) {
45826
45894
  case 0:
45827
45895
  if (!(isScreenSharing || isCustomVideoTrack || isTrackManuallyStopped)) {
45828
- _context26.next = 2;
45896
+ _context27.next = 2;
45829
45897
  break;
45830
45898
  }
45831
- return _context26.abrupt("return");
45899
+ return _context27.abrupt("return");
45832
45900
  case 2:
45833
- _context26.next = 4;
45901
+ _context27.next = 4;
45834
45902
  return getVideoDevices();
45835
45903
  case 4:
45836
- vidDevices = _context26.sent;
45904
+ vidDevices = _context27.sent;
45837
45905
  oldTrack = getCurrentTrack();
45838
45906
  if (oldTrack) {
45839
- _context26.next = 8;
45907
+ _context27.next = 8;
45840
45908
  break;
45841
45909
  }
45842
45910
  throw otError(Errors.NOT_SUPPORTED, new Error('Publisher._toggleVideo cannot toggleVideo when you have no video source.'));
@@ -45844,17 +45912,17 @@ function PublisherFactory(_ref) {
45844
45912
  // oldTrackDeviceId is undefined when it comes from a canvasTracks, i.e.: it is currently muted
45845
45913
  oldTrackDeviceId = (_vidDevices$find = vidDevices.find(device => device.label === oldTrack.label)) == null ? void 0 : _vidDevices$find.deviceId;
45846
45914
  if (isNewTrackNeeded(shouldHaveVideo, oldTrackDeviceId)) {
45847
- _context26.next = 11;
45915
+ _context27.next = 11;
45848
45916
  break;
45849
45917
  }
45850
- return _context26.abrupt("return");
45918
+ return _context27.abrupt("return");
45851
45919
  case 11:
45852
45920
  if (!(oldTrack.readyState === 'ended')) {
45853
- _context26.next = 14;
45921
+ _context27.next = 14;
45854
45922
  break;
45855
45923
  }
45856
45924
  isTrackManuallyStopped = true;
45857
- return _context26.abrupt("return");
45925
+ return _context27.abrupt("return");
45858
45926
  case 14:
45859
45927
  if (shouldHaveVideo && OTHelpers.env.isAndroid && (OTHelpers.env.isChrome || OTHelpers.env.isSamsung)) {
45860
45928
  // On Chrome on Android you need to stop the previous video track OPENTOK-37206
@@ -45863,17 +45931,17 @@ function PublisherFactory(_ref) {
45863
45931
  }
45864
45932
  }
45865
45933
  if (shouldHaveVideo) {
45866
- _context26.next = 31;
45934
+ _context27.next = 31;
45867
45935
  break;
45868
45936
  }
45869
- _context26.prev = 16;
45937
+ _context27.prev = 16;
45870
45938
  newTrack = (0, _createCanvasVideoTrack.default)(videoDimensions);
45871
- _context26.next = 23;
45939
+ _context27.next = 23;
45872
45940
  break;
45873
45941
  case 20:
45874
- _context26.prev = 20;
45875
- _context26.t0 = _context26["catch"](16);
45876
- return _context26.abrupt("return");
45942
+ _context27.prev = 20;
45943
+ _context27.t0 = _context27["catch"](16);
45944
+ return _context27.abrupt("return");
45877
45945
  case 23:
45878
45946
  if (oldTrackDeviceId) {
45879
45947
  // store the current deviceId to reacquire the video later
@@ -45882,13 +45950,13 @@ function PublisherFactory(_ref) {
45882
45950
  setCurrentTrackDeviceId(newTrack.label);
45883
45951
  videoFilter = mediaProcessor.getVideoFilter();
45884
45952
  if (!videoFilter) {
45885
- _context26.next = 30;
45953
+ _context27.next = 30;
45886
45954
  break;
45887
45955
  }
45888
45956
  // Save the current video filter because we want to make sure it
45889
45957
  // gets enabled when the user publishes video again
45890
45958
  currentVideoFilter = videoFilter;
45891
- _context26.next = 30;
45959
+ _context27.next = 30;
45892
45960
  return destroyMediaProcessor();
45893
45961
  case 30:
45894
45962
  if (_videoMediaProcessorConnector) {
@@ -45897,102 +45965,102 @@ function PublisherFactory(_ref) {
45897
45965
  }
45898
45966
  case 31:
45899
45967
  if (!(currentDeviceId && vidDevices.findIndex(device => device.deviceId === currentDeviceId) === -1)) {
45900
- _context26.next = 33;
45968
+ _context27.next = 33;
45901
45969
  break;
45902
45970
  }
45903
45971
  throw otError(Errors.NO_DEVICES_FOUND, new Error('Previous device no longer available - deviceId not found'));
45904
45972
  case 33:
45905
45973
  privateEvents.emit('streamDestroy');
45906
45974
  if (!shouldHaveVideo) {
45907
- _context26.next = 64;
45975
+ _context27.next = 64;
45908
45976
  break;
45909
45977
  }
45910
45978
  if (!hasTrackFromDevice(currentDeviceId)) {
45911
- _context26.next = 37;
45979
+ _context27.next = 37;
45912
45980
  break;
45913
45981
  }
45914
- return _context26.abrupt("return");
45982
+ return _context27.abrupt("return");
45915
45983
  case 37:
45916
- _context26.prev = 37;
45917
- _context26.next = 40;
45984
+ _context27.prev = 37;
45985
+ _context27.next = 40;
45918
45986
  return getTrackFromDeviceId(currentDeviceId);
45919
45987
  case 40:
45920
- newTrack = _context26.sent;
45921
- _context26.next = 47;
45988
+ newTrack = _context27.sent;
45989
+ _context27.next = 47;
45922
45990
  break;
45923
45991
  case 43:
45924
- _context26.prev = 43;
45925
- _context26.t1 = _context26["catch"](37);
45926
- logging.error(`Error getting new track for current device(${currentDeviceId}): ${_context26.t1}`);
45927
- throw _context26.t1;
45992
+ _context27.prev = 43;
45993
+ _context27.t1 = _context27["catch"](37);
45994
+ logging.error(`Error getting new track for current device(${currentDeviceId}): ${_context27.t1}`);
45995
+ throw _context27.t1;
45928
45996
  case 47:
45929
45997
  if (newTrack) {
45930
- _context26.next = 50;
45998
+ _context27.next = 50;
45931
45999
  break;
45932
46000
  }
45933
46001
  logging.error('Failed to enable video. It was not possible to get a new track from the camera');
45934
- return _context26.abrupt("return");
46002
+ return _context27.abrupt("return");
45935
46003
  case 50:
45936
46004
  if (!currentVideoFilter) {
45937
- _context26.next = 59;
46005
+ _context27.next = 59;
45938
46006
  break;
45939
46007
  }
45940
46008
  originalVideoTrack = mediaProcessor.getOriginalVideoTrack();
45941
- _context26.next = 54;
46009
+ _context27.next = 54;
45942
46010
  return mediaProcessor.setVideoFilter(currentVideoFilter, true);
45943
46011
  case 54:
45944
- _context26.next = 56;
46012
+ _context27.next = 56;
45945
46013
  return mediaProcessor.setMediaStream(webRTCStream);
45946
46014
  case 56:
45947
- _context26.next = 58;
46015
+ _context27.next = 58;
45948
46016
  return mediaProcessor.setVideoTrack(newTrack);
45949
46017
  case 58:
45950
- newTrack = _context26.sent;
46018
+ newTrack = _context27.sent;
45951
46019
  case 59:
45952
46020
  if (!_videoMediaProcessorConnector) {
45953
- _context26.next = 64;
46021
+ _context27.next = 64;
45954
46022
  break;
45955
46023
  }
45956
46024
  originalVideoTrack = _videoMediaProcessorConnector.originalTrack;
45957
- _context26.next = 63;
46025
+ _context27.next = 63;
45958
46026
  return _videoMediaProcessorConnector.setTrack(newTrack);
45959
46027
  case 63:
45960
- newTrack = _context26.sent;
46028
+ newTrack = _context27.sent;
45961
46029
  case 64:
45962
- _context26.prev = 64;
45963
- _context26.next = 67;
46030
+ _context27.prev = 64;
46031
+ _context27.next = 67;
45964
46032
  return replaceTrackAndUpdate(oldTrack, newTrack);
45965
46033
  case 67:
45966
46034
  // We stop the original track as a final step because whatever effects
45967
46035
  // were applied to it should remain in effect until the new track is
45968
46036
  // set
45969
46037
  (_originalVideoTrack = originalVideoTrack) == null ? void 0 : _originalVideoTrack.stop();
45970
- _context26.next = 73;
46038
+ _context27.next = 73;
45971
46039
  break;
45972
46040
  case 70:
45973
- _context26.prev = 70;
45974
- _context26.t2 = _context26["catch"](64);
45975
- throw _context26.t2;
46041
+ _context27.prev = 70;
46042
+ _context27.t2 = _context27["catch"](64);
46043
+ throw _context27.t2;
45976
46044
  case 73:
45977
46045
  case "end":
45978
- return _context26.stop();
46046
+ return _context27.stop();
45979
46047
  }
45980
- }, _callee26, null, [[16, 20], [37, 43], [64, 70]]);
46048
+ }, _callee27, null, [[16, 20], [37, 43], [64, 70]]);
45981
46049
  }));
45982
- return function (_x17, _x18) {
45983
- return _ref37.apply(this, arguments);
46050
+ return function (_x19, _x20) {
46051
+ return _ref38.apply(this, arguments);
45984
46052
  };
45985
46053
  }());
45986
46054
  const resetCongestionLevelEstimationOnPeerConnection = (0, _cancellation.callWithCancellation)( /*#__PURE__*/function () {
45987
- var _ref38 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee27(isActive, cancellation) {
46055
+ var _ref39 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee28(isActive, cancellation) {
45988
46056
  var peerConnections;
45989
- return _regenerator.default.wrap(function _callee27$(_context27) {
45990
- while (1) switch (_context27.prev = _context27.next) {
46057
+ return _regenerator.default.wrap(function _callee28$(_context28) {
46058
+ while (1) switch (_context28.prev = _context28.next) {
45991
46059
  case 0:
45992
- _context27.next = 2;
46060
+ _context28.next = 2;
45993
46061
  return getAllPeerConnections();
45994
46062
  case 2:
45995
- peerConnections = _context27.sent;
46063
+ peerConnections = _context28.sent;
45996
46064
  if (!cancellation.isCanceled()) {
45997
46065
  peerConnections.forEach(peerConnection => {
45998
46066
  if (isActive) {
@@ -46004,12 +46072,12 @@ function PublisherFactory(_ref) {
46004
46072
  }
46005
46073
  case 4:
46006
46074
  case "end":
46007
- return _context27.stop();
46075
+ return _context28.stop();
46008
46076
  }
46009
- }, _callee27);
46077
+ }, _callee28);
46010
46078
  }));
46011
- return function (_x19, _x20) {
46012
- return _ref38.apply(this, arguments);
46079
+ return function (_x21, _x22) {
46080
+ return _ref39.apply(this, arguments);
46013
46081
  };
46014
46082
  }());
46015
46083
  const resetAudioFallbackState = () => {
@@ -46019,10 +46087,10 @@ function PublisherFactory(_ref) {
46019
46087
  (_chromeMixin2 = chromeMixin) == null ? void 0 : _chromeMixin2.videoDisabledIndicator.setWarning(false);
46020
46088
  };
46021
46089
  const onAudioFallbackActiveVideo = /*#__PURE__*/function () {
46022
- var _ref39 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee28(previousState) {
46090
+ var _ref40 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee29(previousState) {
46023
46091
  var _chromeMixin3, _chromeMixin4;
46024
- return _regenerator.default.wrap(function _callee28$(_context28) {
46025
- while (1) switch (_context28.prev = _context28.next) {
46092
+ return _regenerator.default.wrap(function _callee29$(_context29) {
46093
+ while (1) switch (_context29.prev = _context29.next) {
46026
46094
  case 0:
46027
46095
  (_chromeMixin3 = chromeMixin) == null ? void 0 : _chromeMixin3.videoDisabledIndicator.disableVideo(false);
46028
46096
  (_chromeMixin4 = chromeMixin) == null ? void 0 : _chromeMixin4.videoDisabledIndicator.setWarning(false);
@@ -46036,12 +46104,12 @@ function PublisherFactory(_ref) {
46036
46104
  }
46037
46105
  case 4:
46038
46106
  case "end":
46039
- return _context28.stop();
46107
+ return _context29.stop();
46040
46108
  }
46041
- }, _callee28);
46109
+ }, _callee29);
46042
46110
  }));
46043
- return function onAudioFallbackActiveVideo(_x21) {
46044
- return _ref39.apply(this, arguments);
46111
+ return function onAudioFallbackActiveVideo(_x23) {
46112
+ return _ref40.apply(this, arguments);
46045
46113
  };
46046
46114
  }();
46047
46115
  const onAudioFallbackActiveVideoWithWarning = () => {
@@ -46052,10 +46120,10 @@ function PublisherFactory(_ref) {
46052
46120
  this.trigger('videoDisableWarning');
46053
46121
  };
46054
46122
  const onAudioFallbackSuspendedVideo = /*#__PURE__*/function () {
46055
- var _ref40 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee29() {
46123
+ var _ref41 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee30() {
46056
46124
  var _chromeMixin6;
46057
- return _regenerator.default.wrap(function _callee29$(_context29) {
46058
- while (1) switch (_context29.prev = _context29.next) {
46125
+ return _regenerator.default.wrap(function _callee30$(_context30) {
46126
+ while (1) switch (_context30.prev = _context30.next) {
46059
46127
  case 0:
46060
46128
  if (properties.publishVideo) {
46061
46129
  (_chromeMixin6 = chromeMixin) == null ? void 0 : _chromeMixin6.videoDisabledIndicator.disableVideo(true);
@@ -46065,12 +46133,12 @@ function PublisherFactory(_ref) {
46065
46133
  });
46066
46134
  case 2:
46067
46135
  case "end":
46068
- return _context29.stop();
46136
+ return _context30.stop();
46069
46137
  }
46070
- }, _callee29);
46138
+ }, _callee30);
46071
46139
  }));
46072
46140
  return function onAudioFallbackSuspendedVideo() {
46073
- return _ref40.apply(this, arguments);
46141
+ return _ref41.apply(this, arguments);
46074
46142
  };
46075
46143
  }();
46076
46144
  let audioFallbackCoordinator;
@@ -46083,9 +46151,9 @@ function PublisherFactory(_ref) {
46083
46151
  [_audioFallbackVideoStates.default.ACTIVE_VIDEO_WITH_WARNING]: onAudioFallbackActiveVideoWithWarning,
46084
46152
  [_audioFallbackVideoStates.default.SUSPENDED_VIDEO]: onAudioFallbackSuspendedVideo
46085
46153
  };
46086
- audioFallbackCoordinator.on('stateChange', _ref41 => {
46087
- let previousState = _ref41.previousState,
46088
- audioFallbackVideoState = _ref41.state;
46154
+ audioFallbackCoordinator.on('stateChange', _ref42 => {
46155
+ let previousState = _ref42.previousState,
46156
+ audioFallbackVideoState = _ref42.state;
46089
46157
  try {
46090
46158
  audioFallbackStateHandlers[audioFallbackVideoState](previousState);
46091
46159
  } catch (err) {
@@ -46177,10 +46245,10 @@ function PublisherFactory(_ref) {
46177
46245
  return this;
46178
46246
  };
46179
46247
  this._publishVideo = /*#__PURE__*/function () {
46180
- var _ref42 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee30(value) {
46248
+ var _ref43 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee31(value) {
46181
46249
  var videoDimensions;
46182
- return _regenerator.default.wrap(function _callee30$(_context30) {
46183
- while (1) switch (_context30.prev = _context30.next) {
46250
+ return _regenerator.default.wrap(function _callee31$(_context31) {
46251
+ while (1) switch (_context31.prev = _context31.next) {
46184
46252
  case 0:
46185
46253
  // Save videoDimensions to not alter video size between mute states.
46186
46254
  videoDimensions = getVideoDimensions();
@@ -46194,16 +46262,16 @@ function PublisherFactory(_ref) {
46194
46262
  resetAudioFallbackState();
46195
46263
  }
46196
46264
  }
46197
- _context30.next = 5;
46265
+ _context31.next = 5;
46198
46266
  return Promise.all([_this._toggleVideo(properties.publishVideo, videoDimensions), updateVideo()]);
46199
46267
  case 5:
46200
46268
  case "end":
46201
- return _context30.stop();
46269
+ return _context31.stop();
46202
46270
  }
46203
- }, _callee30);
46271
+ }, _callee31);
46204
46272
  }));
46205
- return function (_x22) {
46206
- return _ref42.apply(this, arguments);
46273
+ return function (_x24) {
46274
+ return _ref43.apply(this, arguments);
46207
46275
  };
46208
46276
  }();
46209
46277
 
@@ -46478,42 +46546,42 @@ function PublisherFactory(_ref) {
46478
46546
  {
46479
46547
  let videoIndex = 0;
46480
46548
  const cycleVideo = /*#__PURE__*/function () {
46481
- var _ref43 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee31() {
46549
+ var _ref44 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee32() {
46482
46550
  var oldTrack, vidDevices, hasOtherVideoDevices, newVideoDevice, deviceId;
46483
- return _regenerator.default.wrap(function _callee31$(_context31) {
46484
- while (1) switch (_context31.prev = _context31.next) {
46551
+ return _regenerator.default.wrap(function _callee32$(_context32) {
46552
+ while (1) switch (_context32.prev = _context32.next) {
46485
46553
  case 0:
46486
46554
  if (!(OTHelpers.env.isLegacyEdge || !windowMock.RTCRtpSender || typeof windowMock.RTCRtpSender.prototype.replaceTrack !== 'function')) {
46487
- _context31.next = 2;
46555
+ _context32.next = 2;
46488
46556
  break;
46489
46557
  }
46490
46558
  throw otError(Errors.UNSUPPORTED_BROWSER, new Error('Publisher#cycleVideo is not supported in your browser.'), ExceptionCodes.UNABLE_TO_PUBLISH);
46491
46559
  case 2:
46492
46560
  if (!(isCustomVideoTrack || isScreenSharing)) {
46493
- _context31.next = 4;
46561
+ _context32.next = 4;
46494
46562
  break;
46495
46563
  }
46496
46564
  throw otError(Errors.NOT_SUPPORTED, new Error('Publisher#cycleVideo: The publisher is not using a camera video source'));
46497
46565
  case 4:
46498
46566
  oldTrack = getCurrentTrack();
46499
46567
  if (oldTrack) {
46500
- _context31.next = 7;
46568
+ _context32.next = 7;
46501
46569
  break;
46502
46570
  }
46503
46571
  throw otError(Errors.NOT_SUPPORTED, new Error('Publisher#cycleVideo cannot cycleVideo when you have no video source.'));
46504
46572
  case 7:
46505
46573
  videoIndex += 1;
46506
- _context31.next = 10;
46574
+ _context32.next = 10;
46507
46575
  return getVideoDevices();
46508
46576
  case 10:
46509
- vidDevices = _context31.sent;
46577
+ vidDevices = _context32.sent;
46510
46578
  // different devices return the cameras in different orders
46511
46579
  hasOtherVideoDevices = vidDevices.filter(device => device.deviceId !== currentDeviceId).length > 0;
46512
46580
  if (hasOtherVideoDevices) {
46513
- _context31.next = 14;
46581
+ _context32.next = 14;
46514
46582
  break;
46515
46583
  }
46516
- return _context31.abrupt("return", currentDeviceId);
46584
+ return _context32.abrupt("return", currentDeviceId);
46517
46585
  case 14:
46518
46586
  while (vidDevices[videoIndex % vidDevices.length].deviceId === currentDeviceId) {
46519
46587
  videoIndex += 1;
@@ -46521,18 +46589,18 @@ function PublisherFactory(_ref) {
46521
46589
  privateEvents.emit('streamDestroy');
46522
46590
  newVideoDevice = vidDevices[videoIndex % vidDevices.length];
46523
46591
  deviceId = newVideoDevice.deviceId;
46524
- _context31.next = 20;
46592
+ _context32.next = 20;
46525
46593
  return attemptToSetVideoTrack(deviceId, 'cycleVideo');
46526
46594
  case 20:
46527
- return _context31.abrupt("return", currentDeviceId);
46595
+ return _context32.abrupt("return", currentDeviceId);
46528
46596
  case 21:
46529
46597
  case "end":
46530
- return _context31.stop();
46598
+ return _context32.stop();
46531
46599
  }
46532
- }, _callee31);
46600
+ }, _callee32);
46533
46601
  }));
46534
46602
  return function cycleVideo() {
46535
- return _ref43.apply(this, arguments);
46603
+ return _ref44.apply(this, arguments);
46536
46604
  };
46537
46605
  }();
46538
46606
 
@@ -46577,75 +46645,75 @@ function PublisherFactory(_ref) {
46577
46645
  *
46578
46646
  * @see <a href="#setVideoSource">Publisher.setVideoSource()</a>
46579
46647
  */
46580
- this.cycleVideo = (0, _blockCallsUntilComplete.default)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee32() {
46648
+ this.cycleVideo = (0, _blockCallsUntilComplete.default)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee33() {
46581
46649
  var deviceId;
46582
- return _regenerator.default.wrap(function _callee32$(_context32) {
46583
- while (1) switch (_context32.prev = _context32.next) {
46650
+ return _regenerator.default.wrap(function _callee33$(_context33) {
46651
+ while (1) switch (_context33.prev = _context33.next) {
46584
46652
  case 0:
46585
- _context32.prev = 0;
46586
- _context32.next = 3;
46653
+ _context33.prev = 0;
46654
+ _context33.next = 3;
46587
46655
  return cycleVideo();
46588
46656
  case 3:
46589
- deviceId = _context32.sent;
46590
- _context32.next = 10;
46657
+ deviceId = _context33.sent;
46658
+ _context33.next = 10;
46591
46659
  break;
46592
46660
  case 6:
46593
- _context32.prev = 6;
46594
- _context32.t0 = _context32["catch"](0);
46595
- logging.error(`Publisher#cycleVideo: could not cycle video: ${_context32.t0}`);
46596
- throw _context32.t0;
46661
+ _context33.prev = 6;
46662
+ _context33.t0 = _context33["catch"](0);
46663
+ logging.error(`Publisher#cycleVideo: could not cycle video: ${_context33.t0}`);
46664
+ throw _context33.t0;
46597
46665
  case 10:
46598
- return _context32.abrupt("return", {
46666
+ return _context33.abrupt("return", {
46599
46667
  deviceId
46600
46668
  });
46601
46669
  case 11:
46602
46670
  case "end":
46603
- return _context32.stop();
46671
+ return _context33.stop();
46604
46672
  }
46605
- }, _callee32, null, [[0, 6]]);
46673
+ }, _callee33, null, [[0, 6]]);
46606
46674
  })));
46607
46675
  }
46608
46676
  const replaceTrackAndUpdate = /*#__PURE__*/function () {
46609
- var _ref45 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee34(oldTrack, newTrack) {
46677
+ var _ref46 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee35(oldTrack, newTrack) {
46610
46678
  var pcs, video;
46611
- return _regenerator.default.wrap(function _callee34$(_context34) {
46612
- while (1) switch (_context34.prev = _context34.next) {
46679
+ return _regenerator.default.wrap(function _callee35$(_context35) {
46680
+ while (1) switch (_context35.prev = _context35.next) {
46613
46681
  case 0:
46614
- _context34.next = 2;
46682
+ _context35.next = 2;
46615
46683
  return getAllPeerConnections();
46616
46684
  case 2:
46617
- pcs = _context34.sent;
46618
- _context34.next = 5;
46685
+ pcs = _context35.sent;
46686
+ _context35.next = 5;
46619
46687
  return Promise.all(pcs.map( /*#__PURE__*/function () {
46620
- var _ref46 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee33(pc) {
46621
- return _regenerator.default.wrap(function _callee33$(_context33) {
46622
- while (1) switch (_context33.prev = _context33.next) {
46688
+ var _ref47 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee34(pc) {
46689
+ return _regenerator.default.wrap(function _callee34$(_context34) {
46690
+ while (1) switch (_context34.prev = _context34.next) {
46623
46691
  case 0:
46624
- _context33.next = 2;
46692
+ _context34.next = 2;
46625
46693
  return pc.findAndReplaceTrack(oldTrack, newTrack);
46626
46694
  case 2:
46627
46695
  pc._setP2PDefaultMaxBitrate();
46628
46696
  case 3:
46629
46697
  case "end":
46630
- return _context33.stop();
46698
+ return _context34.stop();
46631
46699
  }
46632
- }, _callee33);
46700
+ }, _callee34);
46633
46701
  }));
46634
- return function (_x25) {
46635
- return _ref46.apply(this, arguments);
46702
+ return function (_x27) {
46703
+ return _ref47.apply(this, arguments);
46636
46704
  };
46637
46705
  }()));
46638
46706
  case 5:
46639
46707
  webRTCStream.removeTrack(oldTrack);
46640
46708
  webRTCStream.addTrack(newTrack);
46641
46709
  if (!(newTrack.id !== filteredVideoTrackId)) {
46642
- _context34.next = 11;
46710
+ _context35.next = 11;
46643
46711
  break;
46644
46712
  }
46645
46713
  if (oldTrack && oldTrack.stop) {
46646
46714
  oldTrack.stop();
46647
46715
  }
46648
- _context34.next = 11;
46716
+ _context35.next = 11;
46649
46717
  return applyVideoConstraintsTo(newTrack);
46650
46718
  case 11:
46651
46719
  if (OTHelpers.env.name === 'Firefox' || OTHelpers.env.name === 'Safari') {
@@ -46664,20 +46732,20 @@ function PublisherFactory(_ref) {
46664
46732
  updateVideo();
46665
46733
  case 16:
46666
46734
  case "end":
46667
- return _context34.stop();
46735
+ return _context35.stop();
46668
46736
  }
46669
- }, _callee34);
46737
+ }, _callee35);
46670
46738
  }));
46671
- return function replaceTrackAndUpdate(_x23, _x24) {
46672
- return _ref45.apply(this, arguments);
46739
+ return function replaceTrackAndUpdate(_x25, _x26) {
46740
+ return _ref46.apply(this, arguments);
46673
46741
  };
46674
46742
  }();
46675
46743
  const getTrackFromDeviceId = /*#__PURE__*/function () {
46676
- var _ref47 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee35(deviceId) {
46744
+ var _ref48 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee36(deviceId) {
46677
46745
  var _newVideoStream;
46678
46746
  var oldTrackDeviceId, newOptions, _processedOptions2, getUserMediaHelper, newVideoStream, _newVideoStream$getVi, track;
46679
- return _regenerator.default.wrap(function _callee35$(_context35) {
46680
- while (1) switch (_context35.prev = _context35.next) {
46747
+ return _regenerator.default.wrap(function _callee36$(_context36) {
46748
+ while (1) switch (_context36.prev = _context36.next) {
46681
46749
  case 0:
46682
46750
  oldTrackDeviceId = getCurrentTrackDeviceId();
46683
46751
  setCurrentTrackDeviceId(deviceId);
@@ -46690,32 +46758,32 @@ function PublisherFactory(_ref) {
46690
46758
  accessDialogClosed: onAccessDialogClosed
46691
46759
  });
46692
46760
  _processedOptions2 = processedOptions, getUserMediaHelper = _processedOptions2.getUserMedia;
46693
- _context35.prev = 8;
46694
- _context35.next = 11;
46761
+ _context36.prev = 8;
46762
+ _context36.next = 11;
46695
46763
  return getUserMediaHelper();
46696
46764
  case 11:
46697
- newVideoStream = _context35.sent;
46698
- _context35.next = 18;
46765
+ newVideoStream = _context36.sent;
46766
+ _context36.next = 18;
46699
46767
  break;
46700
46768
  case 14:
46701
- _context35.prev = 14;
46702
- _context35.t0 = _context35["catch"](8);
46703
- logging.error(_context35.t0);
46704
- throw _context35.t0;
46769
+ _context36.prev = 14;
46770
+ _context36.t0 = _context36["catch"](8);
46771
+ logging.error(_context36.t0);
46772
+ throw _context36.t0;
46705
46773
  case 18:
46706
46774
  _newVideoStream$getVi = (_newVideoStream = newVideoStream) == null ? void 0 : _newVideoStream.getVideoTracks(), track = _newVideoStream$getVi[0];
46707
46775
  if (!track) {
46708
46776
  setCurrentTrackDeviceId(oldTrackDeviceId);
46709
46777
  }
46710
- return _context35.abrupt("return", track);
46778
+ return _context36.abrupt("return", track);
46711
46779
  case 21:
46712
46780
  case "end":
46713
- return _context35.stop();
46781
+ return _context36.stop();
46714
46782
  }
46715
- }, _callee35, null, [[8, 14]]);
46783
+ }, _callee36, null, [[8, 14]]);
46716
46784
  }));
46717
- return function getTrackFromDeviceId(_x26) {
46718
- return _ref47.apply(this, arguments);
46785
+ return function getTrackFromDeviceId(_x28) {
46786
+ return _ref48.apply(this, arguments);
46719
46787
  };
46720
46788
  }();
46721
46789
  const getCurrentTrack = () => {
@@ -46732,96 +46800,96 @@ function PublisherFactory(_ref) {
46732
46800
  _currentTrackDeviceId = deviceId;
46733
46801
  };
46734
46802
  const getVideoDevices = /*#__PURE__*/function () {
46735
- var _ref48 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee36() {
46803
+ var _ref49 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee37() {
46736
46804
  var devices, vidDevices;
46737
- return _regenerator.default.wrap(function _callee36$(_context36) {
46738
- while (1) switch (_context36.prev = _context36.next) {
46805
+ return _regenerator.default.wrap(function _callee37$(_context37) {
46806
+ while (1) switch (_context37.prev = _context37.next) {
46739
46807
  case 0:
46740
- _context36.next = 2;
46808
+ _context37.next = 2;
46741
46809
  return deviceHelpers.shouldAskForDevices();
46742
46810
  case 2:
46743
- devices = _context36.sent;
46811
+ devices = _context37.sent;
46744
46812
  vidDevices = devices.videoDevices;
46745
46813
  if (!(!devices.video || !vidDevices || !vidDevices.length)) {
46746
- _context36.next = 6;
46814
+ _context37.next = 6;
46747
46815
  break;
46748
46816
  }
46749
46817
  throw otError(Errors.NO_DEVICES_FOUND, new Error('No video devices available'), ExceptionCodes.UNABLE_TO_PUBLISH);
46750
46818
  case 6:
46751
- return _context36.abrupt("return", vidDevices);
46819
+ return _context37.abrupt("return", vidDevices);
46752
46820
  case 7:
46753
46821
  case "end":
46754
- return _context36.stop();
46822
+ return _context37.stop();
46755
46823
  }
46756
- }, _callee36);
46824
+ }, _callee37);
46757
46825
  }));
46758
46826
  return function getVideoDevices() {
46759
- return _ref48.apply(this, arguments);
46827
+ return _ref49.apply(this, arguments);
46760
46828
  };
46761
46829
  }();
46762
46830
  const replaceAudioTrackInPeerConnections = /*#__PURE__*/function () {
46763
- var _ref49 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee37(oldTrack, newTrack) {
46831
+ var _ref50 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee38(oldTrack, newTrack) {
46764
46832
  var _this$session$session2;
46765
46833
  var activePeerConnection, inactivePeerConnection, pcs;
46766
- return _regenerator.default.wrap(function _callee37$(_context37) {
46767
- while (1) switch (_context37.prev = _context37.next) {
46834
+ return _regenerator.default.wrap(function _callee38$(_context38) {
46835
+ while (1) switch (_context38.prev = _context38.next) {
46768
46836
  case 0:
46769
46837
  if (_this.session) {
46770
- _context37.next = 2;
46838
+ _context38.next = 2;
46771
46839
  break;
46772
46840
  }
46773
- return _context37.abrupt("return");
46841
+ return _context38.abrupt("return");
46774
46842
  case 2:
46775
46843
  if (!((_this$session$session2 = _this.session.sessionInfo) != null && _this$session$session2.isAdaptiveEnabled && activeSourceStreamId === 'P2P')) {
46776
- _context37.next = 15;
46844
+ _context38.next = 15;
46777
46845
  break;
46778
46846
  }
46779
- _context37.next = 5;
46847
+ _context38.next = 5;
46780
46848
  return getP2pPeerConnection();
46781
46849
  case 5:
46782
- activePeerConnection = _context37.sent;
46783
- _context37.next = 8;
46850
+ activePeerConnection = _context38.sent;
46851
+ _context38.next = 8;
46784
46852
  return activePeerConnection == null ? void 0 : activePeerConnection.findAndReplaceTrack(oldTrack, newTrack);
46785
46853
  case 8:
46786
- _context37.next = 10;
46854
+ _context38.next = 10;
46787
46855
  return getMantisPeerConnection();
46788
46856
  case 10:
46789
- inactivePeerConnection = _context37.sent;
46790
- _context37.next = 13;
46857
+ inactivePeerConnection = _context38.sent;
46858
+ _context38.next = 13;
46791
46859
  return amrAudioTrackProcessor.replaceTrackInMutedAudioTracks(inactivePeerConnection, oldTrack, newTrack);
46792
46860
  case 13:
46793
- _context37.next = 20;
46861
+ _context38.next = 20;
46794
46862
  break;
46795
46863
  case 15:
46796
- _context37.next = 17;
46864
+ _context38.next = 17;
46797
46865
  return getAllPeerConnections();
46798
46866
  case 17:
46799
- pcs = _context37.sent;
46800
- _context37.next = 20;
46867
+ pcs = _context38.sent;
46868
+ _context38.next = 20;
46801
46869
  return Promise.all(pcs.map(pc => pc.findAndReplaceTrack(oldTrack, newTrack)));
46802
46870
  case 20:
46803
46871
  case "end":
46804
- return _context37.stop();
46872
+ return _context38.stop();
46805
46873
  }
46806
- }, _callee37);
46874
+ }, _callee38);
46807
46875
  }));
46808
- return function replaceAudioTrackInPeerConnections(_x27, _x28) {
46809
- return _ref49.apply(this, arguments);
46876
+ return function replaceAudioTrackInPeerConnections(_x29, _x30) {
46877
+ return _ref50.apply(this, arguments);
46810
46878
  };
46811
46879
  }();
46812
46880
  const replaceAudioTrack = /*#__PURE__*/function () {
46813
- var _ref50 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee38(oldTrack, newTrack) {
46881
+ var _ref51 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee39(oldTrack, newTrack) {
46814
46882
  var video, isFilteredTrack;
46815
- return _regenerator.default.wrap(function _callee38$(_context38) {
46816
- while (1) switch (_context38.prev = _context38.next) {
46883
+ return _regenerator.default.wrap(function _callee39$(_context39) {
46884
+ while (1) switch (_context39.prev = _context39.next) {
46817
46885
  case 0:
46818
46886
  if (!(oldTrack === newTrack)) {
46819
- _context38.next = 2;
46887
+ _context39.next = 2;
46820
46888
  break;
46821
46889
  }
46822
- return _context38.abrupt("return");
46890
+ return _context39.abrupt("return");
46823
46891
  case 2:
46824
- _context38.next = 4;
46892
+ _context39.next = 4;
46825
46893
  return replaceAudioTrackInPeerConnections(oldTrack, newTrack);
46826
46894
  case 4:
46827
46895
  if (newTrack) {
@@ -46863,23 +46931,23 @@ function PublisherFactory(_ref) {
46863
46931
  refreshAudioVideoUI();
46864
46932
  case 14:
46865
46933
  case "end":
46866
- return _context38.stop();
46934
+ return _context39.stop();
46867
46935
  }
46868
- }, _callee38);
46936
+ }, _callee39);
46869
46937
  }));
46870
- return function replaceAudioTrack(_x29, _x30) {
46871
- return _ref50.apply(this, arguments);
46938
+ return function replaceAudioTrack(_x31, _x32) {
46939
+ return _ref51.apply(this, arguments);
46872
46940
  };
46873
46941
  }();
46874
46942
  const resetAudioSource = /*#__PURE__*/function () {
46875
- var _ref51 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee39(audioTrack) {
46943
+ var _ref52 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee40(audioTrack) {
46876
46944
  var audioDeviceId, newAudioTrack;
46877
- return _regenerator.default.wrap(function _callee39$(_context39) {
46878
- while (1) switch (_context39.prev = _context39.next) {
46945
+ return _regenerator.default.wrap(function _callee40$(_context40) {
46946
+ while (1) switch (_context40.prev = _context40.next) {
46879
46947
  case 0:
46880
46948
  audioDeviceId = audioTrack.getSettings().deviceId;
46881
- _context39.prev = 1;
46882
- _context39.next = 4;
46949
+ _context40.prev = 1;
46950
+ _context40.next = 4;
46883
46951
  return _this.setAudioSource(audioDeviceId);
46884
46952
  case 4:
46885
46953
  // We need to add the onmute listener to the new audio track.
@@ -46888,20 +46956,20 @@ function PublisherFactory(_ref) {
46888
46956
  newAudioTrack.onmute = () => handleBuggedMutedLocalAudioTrack(newAudioTrack);
46889
46957
  newAudioTrack.onunmute = () => handleBuggedUnMutedLocalAudioTrack(newAudioTrack);
46890
46958
  }
46891
- _context39.next = 11;
46959
+ _context40.next = 11;
46892
46960
  break;
46893
46961
  case 8:
46894
- _context39.prev = 8;
46895
- _context39.t0 = _context39["catch"](1);
46896
- logging.error(_context39.t0);
46962
+ _context40.prev = 8;
46963
+ _context40.t0 = _context40["catch"](1);
46964
+ logging.error(_context40.t0);
46897
46965
  case 11:
46898
46966
  case "end":
46899
- return _context39.stop();
46967
+ return _context40.stop();
46900
46968
  }
46901
- }, _callee39, null, [[1, 8]]);
46969
+ }, _callee40, null, [[1, 8]]);
46902
46970
  }));
46903
- return function resetAudioSource(_x31) {
46904
- return _ref51.apply(this, arguments);
46971
+ return function resetAudioSource(_x33) {
46972
+ return _ref52.apply(this, arguments);
46905
46973
  };
46906
46974
  }();
46907
46975
 
@@ -46915,15 +46983,15 @@ function PublisherFactory(_ref) {
46915
46983
  }
46916
46984
  // trigger the handler onVisibilityChange
46917
46985
  const visibilityHandler = /*#__PURE__*/function () {
46918
- var _ref52 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee40() {
46919
- return _regenerator.default.wrap(function _callee40$(_context40) {
46920
- while (1) switch (_context40.prev = _context40.next) {
46986
+ var _ref53 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee41() {
46987
+ return _regenerator.default.wrap(function _callee41$(_context41) {
46988
+ while (1) switch (_context41.prev = _context41.next) {
46921
46989
  case 0:
46922
46990
  if (document.hidden) {
46923
- _context40.next = 5;
46991
+ _context41.next = 5;
46924
46992
  break;
46925
46993
  }
46926
- _context40.next = 3;
46994
+ _context41.next = 3;
46927
46995
  return resetAudioSource(audioTrack);
46928
46996
  case 3:
46929
46997
  if (shouldRePublishVideo) {
@@ -46932,12 +47000,12 @@ function PublisherFactory(_ref) {
46932
47000
  document.removeEventListener('visibilitychange', visibilityHandler);
46933
47001
  case 5:
46934
47002
  case "end":
46935
- return _context40.stop();
47003
+ return _context41.stop();
46936
47004
  }
46937
- }, _callee40);
47005
+ }, _callee41);
46938
47006
  }));
46939
47007
  return function visibilityHandler() {
46940
- return _ref52.apply(this, arguments);
47008
+ return _ref53.apply(this, arguments);
46941
47009
  };
46942
47010
  }();
46943
47011
  document.addEventListener('visibilitychange', visibilityHandler);
@@ -47018,84 +47086,84 @@ function PublisherFactory(_ref) {
47018
47086
  };
47019
47087
  const isMediaStreamTrack = track => track instanceof MediaStreamTrack || track && typeof track === 'object' && Object.getPrototypeOf(track).toString().includes('MediaStreamTrack');
47020
47088
  const setAudioSource = /*#__PURE__*/function () {
47021
- var _ref53 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee42(audioSource) {
47089
+ var _ref54 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee43(audioSource) {
47022
47090
  var currentCancelSentinel, setStreamIfNotCancelled, prevAudioSource, newTrack, newOptions, prevLabel, prevDeviceId, _processedOptions3, getUserMediaHelper, prevOptions, previousDevice, stream;
47023
- return _regenerator.default.wrap(function _callee42$(_context42) {
47024
- while (1) switch (_context42.prev = _context42.next) {
47091
+ return _regenerator.default.wrap(function _callee43$(_context43) {
47092
+ while (1) switch (_context43.prev = _context43.next) {
47025
47093
  case 0:
47026
47094
  if (isSetAudioSourceSupported) {
47027
- _context42.next = 2;
47095
+ _context43.next = 2;
47028
47096
  break;
47029
47097
  }
47030
47098
  throw setAudioSourceNotSupportedError();
47031
47099
  case 2:
47032
47100
  currentCancelSentinel = getSetAudioSourceCancellationSentinel();
47033
47101
  setStreamIfNotCancelled = /*#__PURE__*/function () {
47034
- var _ref54 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee41(stream) {
47035
- return _regenerator.default.wrap(function _callee41$(_context41) {
47036
- while (1) switch (_context41.prev = _context41.next) {
47102
+ var _ref55 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee42(stream) {
47103
+ return _regenerator.default.wrap(function _callee42$(_context42) {
47104
+ while (1) switch (_context42.prev = _context42.next) {
47037
47105
  case 0:
47038
47106
  if (!currentCancelSentinel.isCanceled()) {
47039
- _context41.next = 3;
47107
+ _context42.next = 3;
47040
47108
  break;
47041
47109
  }
47042
47110
  stream.getTracks(track => track.stop());
47043
47111
  throw setAudioSourceCancellationError();
47044
47112
  case 3:
47045
- return _context41.abrupt("return", setAudioSource(stream.getAudioTracks()[0]));
47113
+ return _context42.abrupt("return", setAudioSource(stream.getAudioTracks()[0]));
47046
47114
  case 4:
47047
47115
  case "end":
47048
- return _context41.stop();
47116
+ return _context42.stop();
47049
47117
  }
47050
- }, _callee41);
47118
+ }, _callee42);
47051
47119
  }));
47052
- return function setStreamIfNotCancelled(_x33) {
47053
- return _ref54.apply(this, arguments);
47120
+ return function setStreamIfNotCancelled(_x35) {
47121
+ return _ref55.apply(this, arguments);
47054
47122
  };
47055
47123
  }();
47056
47124
  prevAudioSource = _this._getAudioSource();
47057
47125
  if (prevAudioSource) {
47058
- _context42.next = 7;
47126
+ _context43.next = 7;
47059
47127
  break;
47060
47128
  }
47061
47129
  throw otError(Errors.NOT_SUPPORTED, new Error('Publisher#setAudioSource cannot add an audio source when you started without one.'));
47062
47130
  case 7:
47063
47131
  if (!isMediaStreamTrack(audioSource)) {
47064
- _context42.next = 27;
47132
+ _context43.next = 27;
47065
47133
  break;
47066
47134
  }
47067
47135
  if (!currentCancelSentinel.isCanceled()) {
47068
- _context42.next = 10;
47136
+ _context43.next = 10;
47069
47137
  break;
47070
47138
  }
47071
47139
  throw setAudioSourceCancellationError();
47072
47140
  case 10:
47073
47141
  if (!_audioMediaProcessorConnector) {
47074
- _context42.next = 23;
47142
+ _context43.next = 23;
47075
47143
  break;
47076
47144
  }
47077
- _context42.prev = 11;
47078
- _context42.next = 14;
47145
+ _context43.prev = 11;
47146
+ _context43.next = 14;
47079
47147
  return _audioMediaProcessorConnector.setTrack(audioSource);
47080
47148
  case 14:
47081
- newTrack = _context42.sent;
47082
- _context42.next = 17;
47149
+ newTrack = _context43.sent;
47150
+ _context43.next = 17;
47083
47151
  return replaceAudioTrack(prevAudioSource, newTrack);
47084
47152
  case 17:
47085
- return _context42.abrupt("return", _context42.sent);
47153
+ return _context43.abrupt("return", _context43.sent);
47086
47154
  case 20:
47087
- _context42.prev = 20;
47088
- _context42.t0 = _context42["catch"](11);
47089
- logging.error(`Error setting track on audioMediaProcessorConnector: ${_context42.t0}`);
47155
+ _context43.prev = 20;
47156
+ _context43.t0 = _context43["catch"](11);
47157
+ logging.error(`Error setting track on audioMediaProcessorConnector: ${_context43.t0}`);
47090
47158
  case 23:
47091
47159
  logAnalyticsEvent('setAudioSource', 'Event', {
47092
47160
  deviceId: audioSource.getSettings().deviceId,
47093
47161
  hasAudio: properties.publishAudio
47094
47162
  });
47095
- return _context42.abrupt("return", replaceAudioTrack(prevAudioSource, audioSource));
47163
+ return _context43.abrupt("return", replaceAudioTrack(prevAudioSource, audioSource));
47096
47164
  case 27:
47097
47165
  if (!(typeof audioSource === 'string')) {
47098
- _context42.next = 74;
47166
+ _context43.next = 74;
47099
47167
  break;
47100
47168
  }
47101
47169
  // Must be a deviceId, call getUserMedia and get the MediaStreamTrack
@@ -47113,21 +47181,21 @@ function PublisherFactory(_ref) {
47113
47181
  prevAudioSource.stop();
47114
47182
  }
47115
47183
  _processedOptions3 = processedOptions, getUserMediaHelper = _processedOptions3.getUserMedia;
47116
- _context42.prev = 37;
47117
- _context42.t1 = setStreamIfNotCancelled;
47118
- _context42.next = 41;
47184
+ _context43.prev = 37;
47185
+ _context43.t1 = setStreamIfNotCancelled;
47186
+ _context43.next = 41;
47119
47187
  return getUserMediaHelper();
47120
47188
  case 41:
47121
- _context42.t2 = _context42.sent;
47122
- _context42.next = 44;
47123
- return (0, _context42.t1)(_context42.t2);
47189
+ _context43.t2 = _context43.sent;
47190
+ _context43.next = 44;
47191
+ return (0, _context43.t1)(_context43.t2);
47124
47192
  case 44:
47125
- return _context42.abrupt("return", _context42.sent);
47193
+ return _context43.abrupt("return", _context43.sent);
47126
47194
  case 47:
47127
- _context42.prev = 47;
47128
- _context42.t3 = _context42["catch"](37);
47195
+ _context43.prev = 47;
47196
+ _context43.t3 = _context43["catch"](37);
47129
47197
  if (!currentCancelSentinel.isCanceled()) {
47130
- _context42.next = 51;
47198
+ _context43.next = 51;
47131
47199
  break;
47132
47200
  }
47133
47201
  throw setAudioSourceCancellationError();
@@ -47136,15 +47204,15 @@ function PublisherFactory(_ref) {
47136
47204
  prevOptions.videoSource = null;
47137
47205
  prevOptions.audioSource = prevDeviceId;
47138
47206
  if (!(!prevOptions.audioSource && prevLabel)) {
47139
- _context42.next = 61;
47207
+ _context43.next = 61;
47140
47208
  break;
47141
47209
  }
47142
- _context42.next = 57;
47210
+ _context43.next = 57;
47143
47211
  return deviceHelpers.getInputMediaDevices();
47144
47212
  case 57:
47145
- previousDevice = _context42.sent.find(x => x.label === prevLabel);
47213
+ previousDevice = _context43.sent.find(x => x.label === prevLabel);
47146
47214
  if (!currentCancelSentinel.isCanceled()) {
47147
- _context42.next = 60;
47215
+ _context43.next = 60;
47148
47216
  break;
47149
47217
  }
47150
47218
  throw setAudioSourceCancellationError();
@@ -47154,39 +47222,39 @@ function PublisherFactory(_ref) {
47154
47222
  }
47155
47223
  case 61:
47156
47224
  if (prevOptions.audioSource) {
47157
- _context42.next = 64;
47225
+ _context43.next = 64;
47158
47226
  break;
47159
47227
  }
47160
- _context42.t3.message += ' (could not determine previous audio device)';
47161
- throw otError(Errors.NOT_FOUND, _context42.t3);
47228
+ _context43.t3.message += ' (could not determine previous audio device)';
47229
+ throw otError(Errors.NOT_FOUND, _context43.t3);
47162
47230
  case 64:
47163
47231
  processedOptions = processPubOptions(prevOptions, 'OT.Publisher.setAudioSource', () => currentCancelSentinel.isCanceled() || state && state.isDestroyed());
47164
- _context42.next = 67;
47232
+ _context43.next = 67;
47165
47233
  return processedOptions.getUserMedia().catch(error => {
47166
47234
  // eslint-disable-next-line no-param-reassign
47167
47235
  error.message += ' (could not obtain previous audio device)';
47168
47236
  throw error;
47169
47237
  });
47170
47238
  case 67:
47171
- stream = _context42.sent;
47172
- _context42.next = 70;
47239
+ stream = _context43.sent;
47240
+ _context43.next = 70;
47173
47241
  return setStreamIfNotCancelled(stream);
47174
47242
  case 70:
47175
- _context42.t3.message += ' (reverted to previous audio device)';
47176
- throw _context42.t3;
47243
+ _context43.t3.message += ' (reverted to previous audio device)';
47244
+ throw _context43.t3;
47177
47245
  case 72:
47178
- _context42.next = 75;
47246
+ _context43.next = 75;
47179
47247
  break;
47180
47248
  case 74:
47181
47249
  throw otError(Errors.INVALID_PARAMETER, new Error('Invalid parameter passed to OT.Publisher.setAudioSource(). Expected string or MediaStreamTrack.'));
47182
47250
  case 75:
47183
47251
  case "end":
47184
- return _context42.stop();
47252
+ return _context43.stop();
47185
47253
  }
47186
- }, _callee42, null, [[11, 20], [37, 47]]);
47254
+ }, _callee43, null, [[11, 20], [37, 47]]);
47187
47255
  }));
47188
- return function setAudioSource(_x32) {
47189
- return _ref53.apply(this, arguments);
47256
+ return function setAudioSource(_x34) {
47257
+ return _ref54.apply(this, arguments);
47190
47258
  };
47191
47259
  }();
47192
47260
  this.setAudioSource = setAudioSource;
@@ -47249,21 +47317,21 @@ function PublisherFactory(_ref) {
47249
47317
  * completes successfully. If there is an error, the promise is rejected.
47250
47318
  */
47251
47319
  const setVideoSource = /*#__PURE__*/function () {
47252
- var _setVideoSource = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee43(videoSourceId) {
47320
+ var _setVideoSource = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee44(videoSourceId) {
47253
47321
  var invalidVideoSourceOtError, setVideoSourceOtError, isAudioOnly, deviceList, isValidVideoDeviceId;
47254
- return _regenerator.default.wrap(function _callee43$(_context43) {
47255
- while (1) switch (_context43.prev = _context43.next) {
47322
+ return _regenerator.default.wrap(function _callee44$(_context44) {
47323
+ while (1) switch (_context44.prev = _context44.next) {
47256
47324
  case 0:
47257
47325
  invalidVideoSourceOtError = otError(Errors.INVALID_VIDEO_SOURCE, new Error('Invalid video source. Video source must be a valid video input deviceId'), 1041);
47258
47326
  setVideoSourceOtError = otError(Errors.SET_VIDEO_SOURCE_FAILURE, new Error('You cannot reset the video source on a publisher that does not currently use a camera source.'), 1040);
47259
47327
  if (!(OTHelpers.env.isLegacyEdge || !windowMock.RTCRtpSender || typeof windowMock.RTCRtpSender.prototype.replaceTrack !== 'function')) {
47260
- _context43.next = 4;
47328
+ _context44.next = 4;
47261
47329
  break;
47262
47330
  }
47263
47331
  throw otError(Errors.UNSUPPORTED_BROWSER, new Error('setVideoSource is not supported in your browser.'), ExceptionCodes.UNABLE_TO_PUBLISH);
47264
47332
  case 4:
47265
47333
  if (!(typeof videoSourceId !== 'string')) {
47266
- _context43.next = 6;
47334
+ _context44.next = 6;
47267
47335
  break;
47268
47336
  }
47269
47337
  throw invalidVideoSourceOtError;
@@ -47271,75 +47339,75 @@ function PublisherFactory(_ref) {
47271
47339
  // we can't use hasVideo because that only checks if the video is
47272
47340
  isAudioOnly = !webRTCStream || webRTCStream.getVideoTracks().length === 0;
47273
47341
  if (!(isCustomVideoTrack || isScreenSharing || isAudioOnly)) {
47274
- _context43.next = 9;
47342
+ _context44.next = 9;
47275
47343
  break;
47276
47344
  }
47277
47345
  throw setVideoSourceOtError;
47278
47346
  case 9:
47279
- _context43.next = 11;
47347
+ _context44.next = 11;
47280
47348
  return deviceHelpers.getInputMediaDevices();
47281
47349
  case 11:
47282
- deviceList = _context43.sent;
47350
+ deviceList = _context44.sent;
47283
47351
  isValidVideoDeviceId = deviceList.find(device => device.kind === 'videoInput' && device.deviceId === videoSourceId);
47284
47352
  if (isValidVideoDeviceId) {
47285
- _context43.next = 15;
47353
+ _context44.next = 15;
47286
47354
  break;
47287
47355
  }
47288
47356
  throw invalidVideoSourceOtError;
47289
47357
  case 15:
47290
- _context43.next = 17;
47358
+ _context44.next = 17;
47291
47359
  return attemptToSetVideoTrack(videoSourceId, 'setVideoSource');
47292
47360
  case 17:
47293
47361
  case "end":
47294
- return _context43.stop();
47362
+ return _context44.stop();
47295
47363
  }
47296
- }, _callee43);
47364
+ }, _callee44);
47297
47365
  }));
47298
- function setVideoSource(_x34) {
47366
+ function setVideoSource(_x36) {
47299
47367
  return _setVideoSource.apply(this, arguments);
47300
47368
  }
47301
47369
  return setVideoSource;
47302
47370
  }();
47303
47371
  this.setVideoSource = setVideoSource;
47304
47372
  const attemptToSetVideoTrack = /*#__PURE__*/function () {
47305
- var _ref55 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee44(newVideoDeviceId, action) {
47373
+ var _ref56 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee45(newVideoDeviceId, action) {
47306
47374
  var _originalVideoTrack2;
47307
47375
  var oldDeviceID, oldTrack, supportedBrowsers, videoFilterToReapplyOnAndroid, newVideoTrack, originalVideoTrack;
47308
- return _regenerator.default.wrap(function _callee44$(_context44) {
47309
- while (1) switch (_context44.prev = _context44.next) {
47376
+ return _regenerator.default.wrap(function _callee45$(_context45) {
47377
+ while (1) switch (_context45.prev = _context45.next) {
47310
47378
  case 0:
47311
47379
  oldDeviceID = currentDeviceId;
47312
47380
  currentDeviceId = newVideoDeviceId;
47313
47381
 
47314
47382
  // We shouldn't replace the track unless the video is on
47315
47383
  if (properties.publishVideo) {
47316
- _context44.next = 5;
47384
+ _context45.next = 5;
47317
47385
  break;
47318
47386
  }
47319
47387
  logAnalyticsEvent(action, 'Event', {
47320
47388
  deviceId: newVideoDeviceId,
47321
47389
  hasVideo: properties.publishVideo
47322
47390
  });
47323
- return _context44.abrupt("return");
47391
+ return _context45.abrupt("return");
47324
47392
  case 5:
47325
47393
  if (!hasTrackFromDevice(newVideoDeviceId)) {
47326
- _context44.next = 7;
47394
+ _context45.next = 7;
47327
47395
  break;
47328
47396
  }
47329
- return _context44.abrupt("return");
47397
+ return _context45.abrupt("return");
47330
47398
  case 7:
47331
47399
  oldTrack = getCurrentTrack();
47332
47400
  supportedBrowsers = OTHelpers.env.isChrome || OTHelpers.env.isFirefox || OTHelpers.env.isSamsung;
47333
47401
  if (!(properties.publishVideo && OTHelpers.env.isAndroid && supportedBrowsers)) {
47334
- _context44.next = 16;
47402
+ _context45.next = 16;
47335
47403
  break;
47336
47404
  }
47337
47405
  if (!currentVideoFilter) {
47338
- _context44.next = 15;
47406
+ _context45.next = 15;
47339
47407
  break;
47340
47408
  }
47341
47409
  videoFilterToReapplyOnAndroid = currentVideoFilter;
47342
- _context44.next = 14;
47410
+ _context45.next = 14;
47343
47411
  return destroyMediaProcessor();
47344
47412
  case 14:
47345
47413
  currentVideoFilter = null;
@@ -47348,22 +47416,22 @@ function PublisherFactory(_ref) {
47348
47416
  oldTrack.stop();
47349
47417
  }
47350
47418
  case 16:
47351
- _context44.prev = 16;
47352
- _context44.next = 19;
47419
+ _context45.prev = 16;
47420
+ _context45.next = 19;
47353
47421
  return getTrackFromDeviceId(newVideoDeviceId);
47354
47422
  case 19:
47355
- newVideoTrack = _context44.sent;
47356
- _context44.next = 27;
47423
+ newVideoTrack = _context45.sent;
47424
+ _context45.next = 27;
47357
47425
  break;
47358
47426
  case 22:
47359
- _context44.prev = 22;
47360
- _context44.t0 = _context44["catch"](16);
47427
+ _context45.prev = 22;
47428
+ _context45.t0 = _context45["catch"](16);
47361
47429
  currentDeviceId = oldDeviceID;
47362
- logging.error(_context44.t0);
47363
- throw _context44.t0;
47430
+ logging.error(_context45.t0);
47431
+ throw _context45.t0;
47364
47432
  case 27:
47365
47433
  if (newVideoTrack) {
47366
- _context44.next = 31;
47434
+ _context45.next = 31;
47367
47435
  break;
47368
47436
  }
47369
47437
  logAnalyticsEvent(action, 'Event', {
@@ -47372,36 +47440,36 @@ function PublisherFactory(_ref) {
47372
47440
  error: 'Unable to aquire video track'
47373
47441
  });
47374
47442
  logging.warn('Unable to aquire video track. Moving to next device.');
47375
- return _context44.abrupt("return");
47443
+ return _context45.abrupt("return");
47376
47444
  case 31:
47377
47445
  if (!currentVideoFilter) {
47378
- _context44.next = 36;
47446
+ _context45.next = 36;
47379
47447
  break;
47380
47448
  }
47381
47449
  originalVideoTrack = mediaProcessor.getOriginalVideoTrack();
47382
- _context44.next = 35;
47450
+ _context45.next = 35;
47383
47451
  return mediaProcessor.setVideoTrack(newVideoTrack);
47384
47452
  case 35:
47385
- newVideoTrack = _context44.sent;
47453
+ newVideoTrack = _context45.sent;
47386
47454
  case 36:
47387
47455
  if (!_videoMediaProcessorConnector) {
47388
- _context44.next = 41;
47456
+ _context45.next = 41;
47389
47457
  break;
47390
47458
  }
47391
47459
  originalVideoTrack = _videoMediaProcessorConnector.originalTrack;
47392
- _context44.next = 40;
47460
+ _context45.next = 40;
47393
47461
  return _videoMediaProcessorConnector.setTrack(newVideoTrack);
47394
47462
  case 40:
47395
- newVideoTrack = _context44.sent;
47463
+ newVideoTrack = _context45.sent;
47396
47464
  case 41:
47397
- _context44.next = 43;
47465
+ _context45.next = 43;
47398
47466
  return replaceTrackAndUpdate(oldTrack, newVideoTrack);
47399
47467
  case 43:
47400
47468
  if (!videoFilterToReapplyOnAndroid) {
47401
- _context44.next = 46;
47469
+ _context45.next = 46;
47402
47470
  break;
47403
47471
  }
47404
- _context44.next = 46;
47472
+ _context45.next = 46;
47405
47473
  return _this.applyVideoFilter(videoFilterToReapplyOnAndroid);
47406
47474
  case 46:
47407
47475
  logAnalyticsEvent(action, 'Event', {
@@ -47418,12 +47486,12 @@ function PublisherFactory(_ref) {
47418
47486
  }
47419
47487
  case 49:
47420
47488
  case "end":
47421
- return _context44.stop();
47489
+ return _context45.stop();
47422
47490
  }
47423
- }, _callee44, null, [[16, 22]]);
47491
+ }, _callee45, null, [[16, 22]]);
47424
47492
  }));
47425
- return function attemptToSetVideoTrack(_x35, _x36) {
47426
- return _ref55.apply(this, arguments);
47493
+ return function attemptToSetVideoTrack(_x37, _x38) {
47494
+ return _ref56.apply(this, arguments);
47427
47495
  };
47428
47496
  }();
47429
47497
 
@@ -47473,21 +47541,21 @@ function PublisherFactory(_ref) {
47473
47541
  this._ = {
47474
47542
  privateEvents,
47475
47543
  setIceConfig(newIceConfig) {
47476
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee45() {
47544
+ return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee46() {
47477
47545
  var pcs;
47478
- return _regenerator.default.wrap(function _callee45$(_context45) {
47479
- while (1) switch (_context45.prev = _context45.next) {
47546
+ return _regenerator.default.wrap(function _callee46$(_context46) {
47547
+ while (1) switch (_context46.prev = _context46.next) {
47480
47548
  case 0:
47481
- _context45.next = 2;
47549
+ _context46.next = 2;
47482
47550
  return getAllPeerConnections();
47483
47551
  case 2:
47484
- pcs = _context45.sent;
47552
+ pcs = _context46.sent;
47485
47553
  pcs.forEach(pc => pc.setIceConfig(newIceConfig));
47486
47554
  case 4:
47487
47555
  case "end":
47488
- return _context45.stop();
47556
+ return _context46.stop();
47489
47557
  }
47490
- }, _callee45);
47558
+ }, _callee46);
47491
47559
  }))();
47492
47560
  },
47493
47561
  publishToSession: (session, analyticsReplacement) => {
@@ -47523,8 +47591,8 @@ function PublisherFactory(_ref) {
47523
47591
  return;
47524
47592
  }
47525
47593
  this.once('initSuccess', resolve);
47526
- this.once('destroyed', _ref56 => {
47527
- let reason = _ref56.reason;
47594
+ this.once('destroyed', _ref57 => {
47595
+ let reason = _ref57.reason;
47528
47596
  let reasonDescription = '';
47529
47597
  if (reason) {
47530
47598
  reasonDescription = ` Reason: ${reason}`;
@@ -47534,16 +47602,16 @@ function PublisherFactory(_ref) {
47534
47602
  });
47535
47603
  logging.debug('publishToSession: waiting for publishComplete, which is triggered by ' + 'stream#created from rumor');
47536
47604
  const checkForAndSetScalabilityMode = /*#__PURE__*/function () {
47537
- var _ref57 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee46() {
47605
+ var _ref58 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee47() {
47538
47606
  var scalabilityMode, codecsWhitelist, isCamera, contentHint;
47539
- return _regenerator.default.wrap(function _callee46$(_context46) {
47540
- while (1) switch (_context46.prev = _context46.next) {
47607
+ return _regenerator.default.wrap(function _callee47$(_context47) {
47608
+ while (1) switch (_context47.prev = _context47.next) {
47541
47609
  case 0:
47542
47610
  if (!(!properties.constraints.video || !sessionSimulcastEnabled || capableSimulcastStreams < 2)) {
47543
- _context46.next = 2;
47611
+ _context47.next = 2;
47544
47612
  break;
47545
47613
  }
47546
- return _context46.abrupt("return");
47614
+ return _context47.abrupt("return");
47547
47615
  case 2:
47548
47616
  codecsWhitelist = ['VP9'];
47549
47617
  isCamera = !isScreenSharing && !isCustomVideoTrack;
@@ -47559,12 +47627,12 @@ function PublisherFactory(_ref) {
47559
47627
  }
47560
47628
  case 6:
47561
47629
  case "end":
47562
- return _context46.stop();
47630
+ return _context47.stop();
47563
47631
  }
47564
- }, _callee46);
47632
+ }, _callee47);
47565
47633
  }));
47566
47634
  return function checkForAndSetScalabilityMode() {
47567
- return _ref57.apply(this, arguments);
47635
+ return _ref58.apply(this, arguments);
47568
47636
  };
47569
47637
  }();
47570
47638
  const completedPromise = new Promise((resolve, reject) => {
@@ -47764,11 +47832,11 @@ function PublisherFactory(_ref) {
47764
47832
  return this._.unpublishFromSession(session, reason);
47765
47833
  },
47766
47834
  startMigration: function () {
47767
- var _startMigration = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee47() {
47835
+ var _startMigration = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee48() {
47768
47836
  var _publisherSenderStats4, _this$session23, _this$session23$sessi;
47769
47837
  var relayedPeerConnection, onCreateStreamError;
47770
- return _regenerator.default.wrap(function _callee47$(_context47) {
47771
- while (1) switch (_context47.prev = _context47.next) {
47838
+ return _regenerator.default.wrap(function _callee48$(_context48) {
47839
+ while (1) switch (_context48.prev = _context48.next) {
47772
47840
  case 0:
47773
47841
  state.set('Migrating');
47774
47842
  logAnalyticsEvent('SessionMigration', 'Attempt');
@@ -47776,10 +47844,10 @@ function PublisherFactory(_ref) {
47776
47844
 
47777
47845
  // Update sender method in P2P PC because it needs to use the new Rumor. No need for
47778
47846
  // Mantis PC since a new PC will be created.
47779
- _context47.next = 5;
47847
+ _context48.next = 5;
47780
47848
  return getP2pPeerConnection();
47781
47849
  case 5:
47782
- relayedPeerConnection = _context47.sent;
47850
+ relayedPeerConnection = _context48.sent;
47783
47851
  relayedPeerConnection == null ? void 0 : relayedPeerConnection.setSendMessage(createSendMessage('P2P'));
47784
47852
  (_publisherSenderStats4 = publisherSenderStats) == null ? void 0 : _publisherSenderStats4.setSocket(_this.session._.getSocket());
47785
47853
  onCreateStreamError = error => {
@@ -47788,23 +47856,23 @@ function PublisherFactory(_ref) {
47788
47856
  }
47789
47857
  };
47790
47858
  if (!((_this$session23 = _this.session) != null && (_this$session23$sessi = _this$session23.sessionInfo) != null && _this$session23$sessi.p2pEnabled)) {
47791
- _context47.next = 13;
47859
+ _context48.next = 13;
47792
47860
  break;
47793
47861
  }
47794
47862
  _createStream('P2P', onCreateStreamError);
47795
- _context47.next = 17;
47863
+ _context48.next = 17;
47796
47864
  break;
47797
47865
  case 13:
47798
- _context47.next = 15;
47866
+ _context48.next = 15;
47799
47867
  return getMantisPeerConnection();
47800
47868
  case 15:
47801
- _previousPeerConnection = _context47.sent;
47869
+ _previousPeerConnection = _context48.sent;
47802
47870
  _createStream('MANTIS', onCreateStreamError);
47803
47871
  case 17:
47804
47872
  case "end":
47805
- return _context47.stop();
47873
+ return _context48.stop();
47806
47874
  }
47807
- }, _callee47);
47875
+ }, _callee48);
47808
47876
  }));
47809
47877
  function startMigration() {
47810
47878
  return _startMigration.apply(this, arguments);
@@ -47815,30 +47883,30 @@ function PublisherFactory(_ref) {
47815
47883
  var _this$session24, _this$session24$sessi;
47816
47884
  clearTimeout(_migrationTimeoutId);
47817
47885
  const destroyPeerConnection = /*#__PURE__*/function () {
47818
- var _ref58 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee48(pc) {
47819
- var _getPeerConnectionMet10, peerConnectionId;
47820
- return _regenerator.default.wrap(function _callee48$(_context48) {
47821
- while (1) switch (_context48.prev = _context48.next) {
47886
+ var _ref59 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee49(pc) {
47887
+ var _getPeerConnectionMet8, peerConnectionId;
47888
+ return _regenerator.default.wrap(function _callee49$(_context49) {
47889
+ while (1) switch (_context49.prev = _context49.next) {
47822
47890
  case 0:
47823
47891
  if (!pc) {
47824
- _context48.next = 7;
47892
+ _context49.next = 7;
47825
47893
  break;
47826
47894
  }
47827
- _context48.next = 3;
47895
+ _context49.next = 3;
47828
47896
  return _publisherStatsHelper.removePeerConnection(pc);
47829
47897
  case 3:
47830
- _getPeerConnectionMet10 = getPeerConnectionMeta(pc), peerConnectionId = _getPeerConnectionMet10.peerConnectionId;
47898
+ _getPeerConnectionMet8 = getPeerConnectionMeta(pc), peerConnectionId = _getPeerConnectionMet8.peerConnectionId;
47831
47899
  delete peerConnectionsAsync[peerConnectionId];
47832
47900
  pc.off('iceConnectionStateChange');
47833
47901
  pc.destroy();
47834
47902
  case 7:
47835
47903
  case "end":
47836
- return _context48.stop();
47904
+ return _context49.stop();
47837
47905
  }
47838
- }, _callee48);
47906
+ }, _callee49);
47839
47907
  }));
47840
- return function destroyPeerConnection(_x37) {
47841
- return _ref58.apply(this, arguments);
47908
+ return function destroyPeerConnection(_x39) {
47909
+ return _ref59.apply(this, arguments);
47842
47910
  };
47843
47911
  }();
47844
47912
 
@@ -47878,55 +47946,55 @@ function PublisherFactory(_ref) {
47878
47946
  return webRTCStream;
47879
47947
  },
47880
47948
  switchTracks() {
47881
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee49() {
47949
+ return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee50() {
47882
47950
  var stream;
47883
- return _regenerator.default.wrap(function _callee49$(_context49) {
47884
- while (1) switch (_context49.prev = _context49.next) {
47951
+ return _regenerator.default.wrap(function _callee50$(_context50) {
47952
+ while (1) switch (_context50.prev = _context50.next) {
47885
47953
  case 0:
47886
- _context49.prev = 0;
47887
- _context49.next = 3;
47954
+ _context50.prev = 0;
47955
+ _context50.next = 3;
47888
47956
  return getUserMedia().catch(userMediaError);
47889
47957
  case 3:
47890
- stream = _context49.sent;
47891
- _context49.next = 10;
47958
+ stream = _context50.sent;
47959
+ _context50.next = 10;
47892
47960
  break;
47893
47961
  case 6:
47894
- _context49.prev = 6;
47895
- _context49.t0 = _context49["catch"](0);
47896
- logging.error(`OT.Publisher.switchTracks failed to getUserMedia: ${_context49.t0}`);
47897
- throw _context49.t0;
47962
+ _context50.prev = 6;
47963
+ _context50.t0 = _context50["catch"](0);
47964
+ logging.error(`OT.Publisher.switchTracks failed to getUserMedia: ${_context50.t0}`);
47965
+ throw _context50.t0;
47898
47966
  case 10:
47899
47967
  setNewStream(stream);
47900
- _context49.prev = 11;
47968
+ _context50.prev = 11;
47901
47969
  bindVideo();
47902
- _context49.next = 21;
47970
+ _context50.next = 21;
47903
47971
  break;
47904
47972
  case 15:
47905
- _context49.prev = 15;
47906
- _context49.t1 = _context49["catch"](11);
47907
- if (!(_context49.t1 instanceof _cancel.CancellationError)) {
47908
- _context49.next = 19;
47973
+ _context50.prev = 15;
47974
+ _context50.t1 = _context50["catch"](11);
47975
+ if (!(_context50.t1 instanceof _cancel.CancellationError)) {
47976
+ _context50.next = 19;
47909
47977
  break;
47910
47978
  }
47911
- return _context49.abrupt("return");
47979
+ return _context50.abrupt("return");
47912
47980
  case 19:
47913
- logging.error('Error while binding video', _context49.t1);
47914
- throw _context49.t1;
47981
+ logging.error('Error while binding video', _context50.t1);
47982
+ throw _context50.t1;
47915
47983
  case 21:
47916
- _context49.prev = 21;
47984
+ _context50.prev = 21;
47917
47985
  replaceTracks();
47918
- _context49.next = 29;
47986
+ _context50.next = 29;
47919
47987
  break;
47920
47988
  case 25:
47921
- _context49.prev = 25;
47922
- _context49.t2 = _context49["catch"](21);
47923
- logging.error('Error replacing tracks', _context49.t2);
47924
- throw _context49.t2;
47989
+ _context50.prev = 25;
47990
+ _context50.t2 = _context50["catch"](21);
47991
+ logging.error('Error replacing tracks', _context50.t2);
47992
+ throw _context50.t2;
47925
47993
  case 29:
47926
47994
  case "end":
47927
- return _context49.stop();
47995
+ return _context50.stop();
47928
47996
  }
47929
- }, _callee49, null, [[0, 6], [11, 15], [21, 25]]);
47997
+ }, _callee50, null, [[0, 6], [11, 15], [21, 25]]);
47930
47998
  }))();
47931
47999
  },
47932
48000
  getDataChannel(label, getOptions, completion) {
@@ -47942,22 +48010,14 @@ function PublisherFactory(_ref) {
47942
48010
  peerConnection.getDataChannel(label, getOptions, completion);
47943
48011
  });
47944
48012
  },
47945
- iceRestart(forcedRestart) {
48013
+ iceRestart(reason, forcedRestart) {
47946
48014
  if (forcedRestart === void 0) {
47947
48015
  forcedRestart = false;
47948
48016
  }
47949
48017
  getAllPeerConnections().then(peerConnections => {
47950
48018
  peerConnections.forEach(peerConnection => {
47951
- const _getPeerConnectionMet11 = getPeerConnectionMeta(peerConnection),
47952
- remoteConnectionId = _getPeerConnectionMet11.remoteConnectionId;
47953
- logRepublish('Attempt', {
47954
- remoteConnectionId
47955
- });
47956
48019
  logging.debug('Publisher: ice restart attempt');
47957
- peerConnection.iceRestart();
47958
- if (forcedRestart) {
47959
- peerConnection.generateOffer();
47960
- }
48020
+ peerConnection.iceRestart(reason, forcedRestart);
47961
48021
  });
47962
48022
  });
47963
48023
  },
@@ -47966,27 +48026,27 @@ function PublisherFactory(_ref) {
47966
48026
  },
47967
48027
  demoOnlyCycleVideo: this.cycleVideo,
47968
48028
  testOnlyGetFramesEncoded() {
47969
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee50() {
48029
+ return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee51() {
47970
48030
  var peerConnections;
47971
- return _regenerator.default.wrap(function _callee50$(_context50) {
47972
- while (1) switch (_context50.prev = _context50.next) {
48031
+ return _regenerator.default.wrap(function _callee51$(_context51) {
48032
+ while (1) switch (_context51.prev = _context51.next) {
47973
48033
  case 0:
47974
- _context50.next = 2;
48034
+ _context51.next = 2;
47975
48035
  return getAllPeerConnections();
47976
48036
  case 2:
47977
- peerConnections = _context50.sent;
48037
+ peerConnections = _context51.sent;
47978
48038
  if (peerConnections.length) {
47979
- _context50.next = 5;
48039
+ _context51.next = 5;
47980
48040
  break;
47981
48041
  }
47982
48042
  throw new Error('No established PeerConnections yet');
47983
48043
  case 5:
47984
- return _context50.abrupt("return", peerConnections[0]._testOnlyGetFramesEncoded());
48044
+ return _context51.abrupt("return", peerConnections[0]._testOnlyGetFramesEncoded());
47985
48045
  case 6:
47986
48046
  case "end":
47987
- return _context50.stop();
48047
+ return _context51.stop();
47988
48048
  }
47989
- }, _callee50);
48049
+ }, _callee51);
47990
48050
  }))();
47991
48051
  },
47992
48052
  onStreamAvailable,
@@ -48015,47 +48075,47 @@ function PublisherFactory(_ref) {
48015
48075
  }
48016
48076
  }.bind(this),
48017
48077
  setCongestionLevel: function () {
48018
- var _setCongestionLevel = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee51(level, peerId) {
48078
+ var _setCongestionLevel = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee52(level, peerId) {
48019
48079
  var pcs;
48020
- return _regenerator.default.wrap(function _callee51$(_context51) {
48021
- while (1) switch (_context51.prev = _context51.next) {
48080
+ return _regenerator.default.wrap(function _callee52$(_context52) {
48081
+ while (1) switch (_context52.prev = _context52.next) {
48022
48082
  case 0:
48023
48083
  if (!audioFallbackCoordinator) {
48024
- _context51.next = 15;
48084
+ _context52.next = 15;
48025
48085
  break;
48026
48086
  }
48027
48087
  if (!peerId) {
48028
- _context51.next = 8;
48088
+ _context52.next = 8;
48029
48089
  break;
48030
48090
  }
48031
- _context51.next = 4;
48091
+ _context52.next = 4;
48032
48092
  return getPeerConnectionById(peerId);
48033
48093
  case 4:
48034
- _context51.t1 = _context51.sent;
48035
- _context51.t0 = [_context51.t1];
48036
- _context51.next = 11;
48094
+ _context52.t1 = _context52.sent;
48095
+ _context52.t0 = [_context52.t1];
48096
+ _context52.next = 11;
48037
48097
  break;
48038
48098
  case 8:
48039
- _context51.next = 10;
48099
+ _context52.next = 10;
48040
48100
  return getAllPeerConnections();
48041
48101
  case 10:
48042
- _context51.t0 = _context51.sent;
48102
+ _context52.t0 = _context52.sent;
48043
48103
  case 11:
48044
- pcs = _context51.t0;
48104
+ pcs = _context52.t0;
48045
48105
  pcs.forEach(pc => {
48046
48106
  pc.setCongestionLevel(level);
48047
48107
  });
48048
- _context51.next = 16;
48108
+ _context52.next = 16;
48049
48109
  break;
48050
48110
  case 15:
48051
48111
  logging.warn('Audio Fallback is not enabled');
48052
48112
  case 16:
48053
48113
  case "end":
48054
- return _context51.stop();
48114
+ return _context52.stop();
48055
48115
  }
48056
- }, _callee51);
48116
+ }, _callee52);
48057
48117
  }));
48058
- function setCongestionLevel(_x38, _x39) {
48118
+ function setCongestionLevel(_x40, _x41) {
48059
48119
  return _setCongestionLevel.apply(this, arguments);
48060
48120
  }
48061
48121
  return setCongestionLevel;
@@ -48442,10 +48502,10 @@ function PublisherFactory(_ref) {
48442
48502
  * If there is an error, the promise is rejected and no new video filter is set.
48443
48503
  */
48444
48504
  this.applyVideoFilter = /*#__PURE__*/function () {
48445
- var _ref59 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee52(videoFilter, avoidOriginalTrackLeak) {
48505
+ var _ref60 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee53(videoFilter, avoidOriginalTrackLeak) {
48446
48506
  var sanitizedVideoFilter, isSupported, message, _webRTCStream$getVide2, originalVideoTrack, filteredVideoTrack;
48447
- return _regenerator.default.wrap(function _callee52$(_context52) {
48448
- while (1) switch (_context52.prev = _context52.next) {
48507
+ return _regenerator.default.wrap(function _callee53$(_context53) {
48508
+ while (1) switch (_context53.prev = _context53.next) {
48449
48509
  case 0:
48450
48510
  if (avoidOriginalTrackLeak === void 0) {
48451
48511
  avoidOriginalTrackLeak = false;
@@ -48454,28 +48514,28 @@ function PublisherFactory(_ref) {
48454
48514
  logAnalyticsEvent('applyVideoFilter', 'Attempt', {
48455
48515
  videoFilter: sanitizedVideoFilter
48456
48516
  });
48457
- _context52.prev = 3;
48517
+ _context53.prev = 3;
48458
48518
  if (!_videoMediaProcessorConnector) {
48459
- _context52.next = 6;
48519
+ _context53.next = 6;
48460
48520
  break;
48461
48521
  }
48462
48522
  throw otError(Errors.NOT_SUPPORTED, new Error('Cannot apply video filter when videoMediaProcessorConnector is set.'));
48463
48523
  case 6:
48464
48524
  isSupported = MediaProcessor.isSupported('video');
48465
48525
  if (isSupported) {
48466
- _context52.next = 9;
48526
+ _context53.next = 9;
48467
48527
  break;
48468
48528
  }
48469
48529
  throw otError(Errors.NOT_SUPPORTED, new Error('Browser does not support video filters (Insertable Streams and Worker APIs are required)'));
48470
48530
  case 9:
48471
48531
  if (mediaProcessor.isValidVideoFilter(videoFilter)) {
48472
- _context52.next = 11;
48532
+ _context53.next = 11;
48473
48533
  break;
48474
48534
  }
48475
48535
  throw otError(Errors.INVALID_PARAMETER, new Error('Video filter has invalid configuration'));
48476
48536
  case 11:
48477
48537
  if (webRTCStream) {
48478
- _context52.next = 16;
48538
+ _context53.next = 16;
48479
48539
  break;
48480
48540
  }
48481
48541
  message = 'Ignoring. No mediaStream';
@@ -48483,53 +48543,53 @@ function PublisherFactory(_ref) {
48483
48543
  message
48484
48544
  });
48485
48545
  logging.warn(message);
48486
- return _context52.abrupt("return");
48546
+ return _context53.abrupt("return");
48487
48547
  case 16:
48488
48548
  if (!isScreenSharing) {
48489
- _context52.next = 18;
48549
+ _context53.next = 18;
48490
48550
  break;
48491
48551
  }
48492
48552
  throw otError(Errors.INVALID_PARAMETER, new Error('Video filters can not be applied to screen share'));
48493
48553
  case 18:
48494
48554
  enableMediaProcessorLogging();
48495
48555
  if (properties.publishVideo) {
48496
- _context52.next = 23;
48556
+ _context53.next = 23;
48497
48557
  break;
48498
48558
  }
48499
48559
  currentVideoFilter = videoFilter;
48500
48560
  logAnalyticsEvent('applyVideoFilter', 'Success', {
48501
48561
  videoFilter: sanitizedVideoFilter
48502
48562
  });
48503
- return _context52.abrupt("return");
48563
+ return _context53.abrupt("return");
48504
48564
  case 23:
48505
48565
  if (!mediaProcessor.getVideoFilter()) {
48506
- _context52.next = 38;
48566
+ _context53.next = 38;
48507
48567
  break;
48508
48568
  }
48509
48569
  if (!mediaProcessor.canUpdateVideoFilter(videoFilter.type)) {
48510
- _context52.next = 36;
48570
+ _context53.next = 36;
48511
48571
  break;
48512
48572
  }
48513
- _context52.prev = 25;
48514
- _context52.next = 28;
48573
+ _context53.prev = 25;
48574
+ _context53.next = 28;
48515
48575
  return mediaProcessor.updateVideoFilter(videoFilter);
48516
48576
  case 28:
48517
48577
  currentVideoFilter = videoFilter;
48518
48578
  logAnalyticsEvent('applyVideoFilter', 'Success', {
48519
48579
  videoFilter: sanitizedVideoFilter
48520
48580
  });
48521
- return _context52.abrupt("return");
48581
+ return _context53.abrupt("return");
48522
48582
  case 33:
48523
- _context52.prev = 33;
48524
- _context52.t0 = _context52["catch"](25);
48525
- logging.warn(`Error updating video filter: ${_context52.t0}`);
48583
+ _context53.prev = 33;
48584
+ _context53.t0 = _context53["catch"](25);
48585
+ logging.warn(`Error updating video filter: ${_context53.t0}`);
48526
48586
  case 36:
48527
- _context52.next = 38;
48587
+ _context53.next = 38;
48528
48588
  return _this.clearVideoFilter();
48529
48589
  case 38:
48530
48590
  _webRTCStream$getVide2 = webRTCStream.getVideoTracks(), originalVideoTrack = _webRTCStream$getVide2[0];
48531
48591
  if (originalVideoTrack) {
48532
- _context52.next = 44;
48592
+ _context53.next = 44;
48533
48593
  break;
48534
48594
  }
48535
48595
  message = 'Ignoring. No video';
@@ -48537,33 +48597,33 @@ function PublisherFactory(_ref) {
48537
48597
  message
48538
48598
  });
48539
48599
  logging.warn(message);
48540
- return _context52.abrupt("return");
48600
+ return _context53.abrupt("return");
48541
48601
  case 44:
48542
- _context52.next = 46;
48602
+ _context53.next = 46;
48543
48603
  return mediaProcessor.setVideoFilter(videoFilter, avoidOriginalTrackLeak);
48544
48604
  case 46:
48545
- _context52.next = 48;
48605
+ _context53.next = 48;
48546
48606
  return mediaProcessor.setMediaStream(webRTCStream);
48547
48607
  case 48:
48548
- filteredVideoTrack = _context52.sent;
48608
+ filteredVideoTrack = _context53.sent;
48549
48609
  if (!filteredVideoTrack) {
48550
- _context52.next = 53;
48610
+ _context53.next = 53;
48551
48611
  break;
48552
48612
  }
48553
48613
  filteredVideoTrackId = filteredVideoTrack.id;
48554
- _context52.next = 53;
48614
+ _context53.next = 53;
48555
48615
  return replaceTrackAndUpdate(originalVideoTrack, filteredVideoTrack);
48556
48616
  case 53:
48557
- _context52.next = 60;
48617
+ _context53.next = 60;
48558
48618
  break;
48559
48619
  case 55:
48560
- _context52.prev = 55;
48561
- _context52.t1 = _context52["catch"](3);
48562
- logging.error(`Error applying video filter: ${_context52.t1}`);
48620
+ _context53.prev = 55;
48621
+ _context53.t1 = _context53["catch"](3);
48622
+ logging.error(`Error applying video filter: ${_context53.t1}`);
48563
48623
  logAnalyticsEvent('applyVideoFilter', 'Failure', {
48564
- message: _context52.t1.message
48624
+ message: _context53.t1.message
48565
48625
  });
48566
- throw _context52.t1;
48626
+ throw _context53.t1;
48567
48627
  case 60:
48568
48628
  currentVideoFilter = videoFilter;
48569
48629
  logAnalyticsEvent('applyVideoFilter', 'Success', {
@@ -48571,12 +48631,12 @@ function PublisherFactory(_ref) {
48571
48631
  });
48572
48632
  case 62:
48573
48633
  case "end":
48574
- return _context52.stop();
48634
+ return _context53.stop();
48575
48635
  }
48576
- }, _callee52, null, [[3, 55], [25, 33]]);
48636
+ }, _callee53, null, [[3, 55], [25, 33]]);
48577
48637
  }));
48578
- return function (_x40, _x41) {
48579
- return _ref59.apply(this, arguments);
48638
+ return function (_x42, _x43) {
48639
+ return _ref60.apply(this, arguments);
48580
48640
  };
48581
48641
  }();
48582
48642
 
@@ -48683,35 +48743,35 @@ function PublisherFactory(_ref) {
48683
48743
  * If there is an error, the promise is rejected and no new video filter is set.
48684
48744
  */
48685
48745
  this.applyAudioFilter = /*#__PURE__*/function () {
48686
- var _ref60 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee53(audioFilter) {
48746
+ var _ref61 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee54(audioFilter) {
48687
48747
  var isSupported, message, _getNoiseSuppressionC, assetsDirBaseUrl, vonageNoiseSuppression, noiseSuppressionConnector;
48688
- return _regenerator.default.wrap(function _callee53$(_context53) {
48689
- while (1) switch (_context53.prev = _context53.next) {
48748
+ return _regenerator.default.wrap(function _callee54$(_context54) {
48749
+ while (1) switch (_context54.prev = _context54.next) {
48690
48750
  case 0:
48691
48751
  logAnalyticsEvent('applyAudioFilter', 'Attempt', {
48692
48752
  audioFilter
48693
48753
  });
48694
48754
  isSupported = MediaProcessor.isSupported('audio');
48695
48755
  if (isSupported) {
48696
- _context53.next = 4;
48756
+ _context54.next = 4;
48697
48757
  break;
48698
48758
  }
48699
48759
  throw otError(Errors.NOT_SUPPORTED, new Error('Browser does not support audio filters (Insertable Streams and Worker APIs are required)'));
48700
48760
  case 4:
48701
48761
  if ((0, _isValidAudioFilter.default)(audioFilter)) {
48702
- _context53.next = 6;
48762
+ _context54.next = 6;
48703
48763
  break;
48704
48764
  }
48705
48765
  throw otError(Errors.INVALID_PARAMETER, new Error('Audio filter has invalid configuration'));
48706
48766
  case 6:
48707
48767
  if (!_audioMediaProcessorConnector) {
48708
- _context53.next = 8;
48768
+ _context54.next = 8;
48709
48769
  break;
48710
48770
  }
48711
48771
  throw otError(Errors.NOT_SUPPORTED, new Error('Cannot apply audio filter when audioMediaProcessorConnector is set.'));
48712
48772
  case 8:
48713
48773
  if (webRTCStream) {
48714
- _context53.next = 13;
48774
+ _context54.next = 13;
48715
48775
  break;
48716
48776
  }
48717
48777
  message = 'Ignoring. No mediaStream';
@@ -48719,68 +48779,68 @@ function PublisherFactory(_ref) {
48719
48779
  message
48720
48780
  });
48721
48781
  logging.warn(message);
48722
- return _context53.abrupt("return");
48782
+ return _context54.abrupt("return");
48723
48783
  case 13:
48724
48784
  if (properties.publishAudio) {
48725
- _context53.next = 17;
48785
+ _context54.next = 17;
48726
48786
  break;
48727
48787
  }
48728
48788
  currentAudioFilter = audioFilter;
48729
48789
  logAnalyticsEvent('applyAudioFilter', 'Success', {
48730
48790
  audioFilter
48731
48791
  });
48732
- return _context53.abrupt("return");
48792
+ return _context54.abrupt("return");
48733
48793
  case 17:
48734
48794
  if (!_this.getAudioFilter()) {
48735
- _context53.next = 20;
48795
+ _context54.next = 20;
48736
48796
  break;
48737
48797
  }
48738
- _context53.next = 20;
48798
+ _context54.next = 20;
48739
48799
  return _this.clearAudioFilter();
48740
48800
  case 20:
48741
- _context53.prev = 20;
48801
+ _context54.prev = 20;
48742
48802
  if (!(audioFilter.type === 'advancedNoiseSuppression')) {
48743
- _context53.next = 32;
48803
+ _context54.next = 32;
48744
48804
  break;
48745
48805
  }
48746
48806
  _getNoiseSuppressionC = (0, _getDefaultConfig.default)({
48747
48807
  proxyUrl: (0, _proxyUrl.getProxyUrl)()
48748
48808
  }), assetsDirBaseUrl = _getNoiseSuppressionC.assetsDirBaseUrl;
48749
48809
  vonageNoiseSuppression = createVonageNoiseSuppression();
48750
- _context53.next = 26;
48810
+ _context54.next = 26;
48751
48811
  return vonageNoiseSuppression.init({
48752
48812
  assetsDirBaseUrl
48753
48813
  });
48754
48814
  case 26:
48755
- _context53.next = 28;
48815
+ _context54.next = 28;
48756
48816
  return vonageNoiseSuppression.getConnector();
48757
48817
  case 28:
48758
- noiseSuppressionConnector = _context53.sent;
48759
- _context53.next = 31;
48818
+ noiseSuppressionConnector = _context54.sent;
48819
+ _context54.next = 31;
48760
48820
  return _setAudioMediaProcessorConnector(noiseSuppressionConnector);
48761
48821
  case 31:
48762
48822
  currentAudioFilter = audioFilter;
48763
48823
  case 32:
48764
- _context53.next = 39;
48824
+ _context54.next = 39;
48765
48825
  break;
48766
48826
  case 34:
48767
- _context53.prev = 34;
48768
- _context53.t0 = _context53["catch"](20);
48769
- logging.error(`Error applying audio filter: ${_context53.t0}`);
48827
+ _context54.prev = 34;
48828
+ _context54.t0 = _context54["catch"](20);
48829
+ logging.error(`Error applying audio filter: ${_context54.t0}`);
48770
48830
  logAnalyticsEvent('applyAudioFilter', 'Failure', {
48771
- message: _context53.t0.message
48831
+ message: _context54.t0.message
48772
48832
  });
48773
- throw _context53.t0;
48833
+ throw _context54.t0;
48774
48834
  case 39:
48775
48835
  logAnalyticsEvent('applyAudioFilter', 'Success');
48776
48836
  case 40:
48777
48837
  case "end":
48778
- return _context53.stop();
48838
+ return _context54.stop();
48779
48839
  }
48780
- }, _callee53, null, [[20, 34]]);
48840
+ }, _callee54, null, [[20, 34]]);
48781
48841
  }));
48782
- return function (_x42) {
48783
- return _ref60.apply(this, arguments);
48842
+ return function (_x44) {
48843
+ return _ref61.apply(this, arguments);
48784
48844
  };
48785
48845
  }();
48786
48846
 
@@ -48801,22 +48861,22 @@ function PublisherFactory(_ref) {
48801
48861
  * @return {Promise} A promise that resolves when the operation completes successfully.
48802
48862
  * If there is an error, the promise is rejected.
48803
48863
  */
48804
- this.clearAudioFilter = /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee54() {
48864
+ this.clearAudioFilter = /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee55() {
48805
48865
  var message;
48806
- return _regenerator.default.wrap(function _callee54$(_context54) {
48807
- while (1) switch (_context54.prev = _context54.next) {
48866
+ return _regenerator.default.wrap(function _callee55$(_context55) {
48867
+ while (1) switch (_context55.prev = _context55.next) {
48808
48868
  case 0:
48809
48869
  logAnalyticsEvent('clearAudioFilter', 'Attempt');
48810
48870
  if (!(!properties.publishAudio && _this.getAudioFilter())) {
48811
- _context54.next = 5;
48871
+ _context55.next = 5;
48812
48872
  break;
48813
48873
  }
48814
48874
  currentAudioFilter = null;
48815
48875
  logAnalyticsEvent('clearAudioFilter', 'Success');
48816
- return _context54.abrupt("return");
48876
+ return _context55.abrupt("return");
48817
48877
  case 5:
48818
48878
  if (MediaProcessor.isSupported('audio')) {
48819
- _context54.next = 10;
48879
+ _context55.next = 10;
48820
48880
  break;
48821
48881
  }
48822
48882
  message = 'Ignoring. "clearAudioFilter" not supported.';
@@ -48824,10 +48884,10 @@ function PublisherFactory(_ref) {
48824
48884
  message
48825
48885
  });
48826
48886
  logging.warn(message);
48827
- return _context54.abrupt("return");
48887
+ return _context55.abrupt("return");
48828
48888
  case 10:
48829
48889
  if (_this.getAudioFilter()) {
48830
- _context54.next = 15;
48890
+ _context55.next = 15;
48831
48891
  break;
48832
48892
  }
48833
48893
  message = 'Ignoring. No audio filter applied';
@@ -48835,10 +48895,10 @@ function PublisherFactory(_ref) {
48835
48895
  message
48836
48896
  });
48837
48897
  logging.debug(message);
48838
- return _context54.abrupt("return");
48898
+ return _context55.abrupt("return");
48839
48899
  case 15:
48840
48900
  if (webRTCStream) {
48841
- _context54.next = 20;
48901
+ _context55.next = 20;
48842
48902
  break;
48843
48903
  }
48844
48904
  message = 'Ignoring. No mediaStream';
@@ -48846,29 +48906,29 @@ function PublisherFactory(_ref) {
48846
48906
  message
48847
48907
  });
48848
48908
  logging.warn(message);
48849
- return _context54.abrupt("return");
48909
+ return _context55.abrupt("return");
48850
48910
  case 20:
48851
- _context54.prev = 20;
48852
- _context54.next = 23;
48911
+ _context55.prev = 20;
48912
+ _context55.next = 23;
48853
48913
  return _setAudioMediaProcessorConnector(null);
48854
48914
  case 23:
48855
48915
  currentAudioFilter = null;
48856
- _context54.next = 30;
48916
+ _context55.next = 30;
48857
48917
  break;
48858
48918
  case 26:
48859
- _context54.prev = 26;
48860
- _context54.t0 = _context54["catch"](20);
48919
+ _context55.prev = 26;
48920
+ _context55.t0 = _context55["catch"](20);
48861
48921
  logAnalyticsEvent('clearAudioFilter', 'Failure', {
48862
- error: _context54.t0
48922
+ error: _context55.t0
48863
48923
  });
48864
- return _context54.abrupt("return");
48924
+ return _context55.abrupt("return");
48865
48925
  case 30:
48866
48926
  logAnalyticsEvent('clearAudioFilter', 'Success');
48867
48927
  case 31:
48868
48928
  case "end":
48869
- return _context54.stop();
48929
+ return _context55.stop();
48870
48930
  }
48871
- }, _callee54, null, [[20, 26]]);
48931
+ }, _callee55, null, [[20, 26]]);
48872
48932
  }));
48873
48933
 
48874
48934
  /**
@@ -48963,16 +49023,16 @@ function PublisherFactory(_ref) {
48963
49023
  * If there is an error, the promise is rejected and no connector is set.
48964
49024
  */
48965
49025
  this.setVideoMediaProcessorConnector = /*#__PURE__*/function () {
48966
- var _ref62 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee55(mediaProcessorConnector) {
49026
+ var _ref63 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee56(mediaProcessorConnector) {
48967
49027
  var _webRTCStream$getVide3, filteredVideoTrack, videoTrack, _webRTCStream$getVide4, originalVideoTrack, message;
48968
- return _regenerator.default.wrap(function _callee55$(_context55) {
48969
- while (1) switch (_context55.prev = _context55.next) {
49028
+ return _regenerator.default.wrap(function _callee56$(_context56) {
49029
+ while (1) switch (_context56.prev = _context56.next) {
48970
49030
  case 0:
48971
49031
  logAnalyticsEvent('setVideoMediaProcessorConnector', 'Attempt', {
48972
49032
  message: mediaProcessorConnector ? 'setting the connector' : 'clearing the connector'
48973
49033
  });
48974
49034
  if (!_this.getVideoFilter()) {
48975
- _context55.next = 4;
49035
+ _context56.next = 4;
48976
49036
  break;
48977
49037
  }
48978
49038
  logAnalyticsEvent('setVideoMediaProcessorConnector', 'Failure', {
@@ -48981,16 +49041,16 @@ function PublisherFactory(_ref) {
48981
49041
  throw otError(Errors.NOT_SUPPORTED, new Error('setVideoMediaProcessorConnector: Cannot use this method when videoFilter is set.'));
48982
49042
  case 4:
48983
49043
  if (!_videoMediaProcessorConnector) {
48984
- _context55.next = 15;
49044
+ _context56.next = 15;
48985
49045
  break;
48986
49046
  }
48987
49047
  _webRTCStream$getVide3 = webRTCStream.getVideoTracks(), filteredVideoTrack = _webRTCStream$getVide3[0];
48988
- _context55.next = 8;
49048
+ _context56.next = 8;
48989
49049
  return getTrackFromDeviceId(currentDeviceId);
48990
49050
  case 8:
48991
- videoTrack = _context55.sent;
49051
+ videoTrack = _context56.sent;
48992
49052
  filteredVideoTrackId = null;
48993
- _context55.next = 12;
49053
+ _context56.next = 12;
48994
49054
  return replaceTrackAndUpdate(filteredVideoTrack, videoTrack);
48995
49055
  case 12:
48996
49056
  _videoMediaProcessorConnector.destroy();
@@ -48998,16 +49058,16 @@ function PublisherFactory(_ref) {
48998
49058
  _videoMediaProcessorConnector = null;
48999
49059
  case 15:
49000
49060
  if (mediaProcessorConnector) {
49001
- _context55.next = 18;
49061
+ _context56.next = 18;
49002
49062
  break;
49003
49063
  }
49004
49064
  logAnalyticsEvent('setVideoMediaProcessorConnector', 'Success', {
49005
49065
  message: 'clearing the connector'
49006
49066
  });
49007
- return _context55.abrupt("return");
49067
+ return _context56.abrupt("return");
49008
49068
  case 18:
49009
49069
  if (MediaProcessorConnector.isValidConnector(mediaProcessorConnector)) {
49010
- _context55.next = 21;
49070
+ _context56.next = 21;
49011
49071
  break;
49012
49072
  }
49013
49073
  logAnalyticsEvent('setVideoMediaProcessorConnector', 'Failure', {
@@ -49018,7 +49078,7 @@ function PublisherFactory(_ref) {
49018
49078
  _videoMediaProcessorConnector = new MediaProcessorConnector(mediaProcessorConnector);
49019
49079
  _webRTCStream$getVide4 = webRTCStream.getVideoTracks(), originalVideoTrack = _webRTCStream$getVide4[0];
49020
49080
  if (originalVideoTrack) {
49021
- _context55.next = 29;
49081
+ _context56.next = 29;
49022
49082
  break;
49023
49083
  }
49024
49084
  message = 'Connector not set as no video track is present.';
@@ -49027,38 +49087,38 @@ function PublisherFactory(_ref) {
49027
49087
  });
49028
49088
  logging.warn(`setVideoMediaProcessorConnector: ${message}`);
49029
49089
  _videoMediaProcessorConnector = null;
49030
- return _context55.abrupt("return");
49090
+ return _context56.abrupt("return");
49031
49091
  case 29:
49032
- _context55.prev = 29;
49033
- _context55.next = 32;
49092
+ _context56.prev = 29;
49093
+ _context56.next = 32;
49034
49094
  return _videoMediaProcessorConnector.setTrack(originalVideoTrack);
49035
49095
  case 32:
49036
- filteredVideoTrack = _context55.sent;
49096
+ filteredVideoTrack = _context56.sent;
49037
49097
  filteredVideoTrackId = filteredVideoTrack.id;
49038
- _context55.next = 36;
49098
+ _context56.next = 36;
49039
49099
  return replaceTrackAndUpdate(originalVideoTrack, filteredVideoTrack);
49040
49100
  case 36:
49041
- _context55.next = 44;
49101
+ _context56.next = 44;
49042
49102
  break;
49043
49103
  case 38:
49044
- _context55.prev = 38;
49045
- _context55.t0 = _context55["catch"](29);
49104
+ _context56.prev = 38;
49105
+ _context56.t0 = _context56["catch"](29);
49046
49106
  _videoMediaProcessorConnector = null;
49047
- logging.error(`setVideoMediaProcessorConnector: Error getting track from MediaProcessorConnector: ${_context55.t0}`);
49107
+ logging.error(`setVideoMediaProcessorConnector: Error getting track from MediaProcessorConnector: ${_context56.t0}`);
49048
49108
  logAnalyticsEvent('setVideoMediaProcessorConnector', 'Failure', {
49049
- message: _context55.t0.message
49109
+ message: _context56.t0.message
49050
49110
  });
49051
- throw _context55.t0;
49111
+ throw _context56.t0;
49052
49112
  case 44:
49053
49113
  logAnalyticsEvent('setVideoMediaProcessorConnector', 'Success');
49054
49114
  case 45:
49055
49115
  case "end":
49056
- return _context55.stop();
49116
+ return _context56.stop();
49057
49117
  }
49058
- }, _callee55, null, [[29, 38]]);
49118
+ }, _callee56, null, [[29, 38]]);
49059
49119
  }));
49060
- return function (_x43) {
49061
- return _ref62.apply(this, arguments);
49120
+ return function (_x45) {
49121
+ return _ref63.apply(this, arguments);
49062
49122
  };
49063
49123
  }();
49064
49124
 
@@ -49122,71 +49182,71 @@ function PublisherFactory(_ref) {
49122
49182
  * If there is an error, the promise is rejected and no connector is set.
49123
49183
  */
49124
49184
  this.setAudioMediaProcessorConnector = /*#__PURE__*/function () {
49125
- var _ref63 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee56(mediaProcessorConnector) {
49126
- return _regenerator.default.wrap(function _callee56$(_context56) {
49127
- while (1) switch (_context56.prev = _context56.next) {
49185
+ var _ref64 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee57(mediaProcessorConnector) {
49186
+ return _regenerator.default.wrap(function _callee57$(_context57) {
49187
+ while (1) switch (_context57.prev = _context57.next) {
49128
49188
  case 0:
49129
49189
  logAnalyticsEvent('setAudioMediaProcessorConnector', 'Attempt', {
49130
49190
  message: mediaProcessorConnector ? 'setting the connector' : 'clearing the connector'
49131
49191
  });
49132
- _context56.prev = 1;
49133
- _context56.next = 4;
49192
+ _context57.prev = 1;
49193
+ _context57.next = 4;
49134
49194
  return _setAudioMediaProcessorConnector(mediaProcessorConnector);
49135
49195
  case 4:
49136
49196
  logAnalyticsEvent('setAudioMediaProcessorConnector', 'Success', {
49137
49197
  message: mediaProcessorConnector ? undefined : 'clearing the connector'
49138
49198
  });
49139
- _context56.next = 11;
49199
+ _context57.next = 11;
49140
49200
  break;
49141
49201
  case 7:
49142
- _context56.prev = 7;
49143
- _context56.t0 = _context56["catch"](1);
49202
+ _context57.prev = 7;
49203
+ _context57.t0 = _context57["catch"](1);
49144
49204
  logAnalyticsEvent('setAudioMediaProcessorConnector', 'Failure', {
49145
- message: _context56.t0.message
49205
+ message: _context57.t0.message
49146
49206
  });
49147
- throw _context56.t0;
49207
+ throw _context57.t0;
49148
49208
  case 11:
49149
49209
  case "end":
49150
- return _context56.stop();
49210
+ return _context57.stop();
49151
49211
  }
49152
- }, _callee56, null, [[1, 7]]);
49212
+ }, _callee57, null, [[1, 7]]);
49153
49213
  }));
49154
- return function (_x44) {
49155
- return _ref63.apply(this, arguments);
49214
+ return function (_x46) {
49215
+ return _ref64.apply(this, arguments);
49156
49216
  };
49157
49217
  }();
49158
49218
  const _setAudioMediaProcessorConnector = /*#__PURE__*/function () {
49159
- var _ref64 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee57(mediaProcessorConnector) {
49219
+ var _ref65 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee58(mediaProcessorConnector) {
49160
49220
  var message, _webRTCStream$getAudi, filteredAudioTrack, _webRTCStream$getAudi2, originalAudioTrack;
49161
- return _regenerator.default.wrap(function _callee57$(_context57) {
49162
- while (1) switch (_context57.prev = _context57.next) {
49221
+ return _regenerator.default.wrap(function _callee58$(_context58) {
49222
+ while (1) switch (_context58.prev = _context58.next) {
49163
49223
  case 0:
49164
49224
  if (!(_this.getAudioFilter() && mediaProcessorConnector)) {
49165
- _context57.next = 3;
49225
+ _context58.next = 3;
49166
49226
  break;
49167
49227
  }
49168
49228
  message = 'Tried to set audio MediaProcessorConnector when audio filter applied.';
49169
49229
  throw otError(Errors.NOT_SUPPORTED, new Error(message));
49170
49230
  case 3:
49171
49231
  if (!_audioMediaProcessorConnector) {
49172
- _context57.next = 9;
49232
+ _context58.next = 9;
49173
49233
  break;
49174
49234
  }
49175
49235
  _webRTCStream$getAudi = webRTCStream.getAudioTracks(), filteredAudioTrack = _webRTCStream$getAudi[0];
49176
- _context57.next = 7;
49236
+ _context58.next = 7;
49177
49237
  return replaceAudioTrack(filteredAudioTrack, _audioMediaProcessorConnector.originalTrack);
49178
49238
  case 7:
49179
49239
  _audioMediaProcessorConnector.destroy();
49180
49240
  _audioMediaProcessorConnector = null;
49181
49241
  case 9:
49182
49242
  if (mediaProcessorConnector) {
49183
- _context57.next = 11;
49243
+ _context58.next = 11;
49184
49244
  break;
49185
49245
  }
49186
- return _context57.abrupt("return");
49246
+ return _context58.abrupt("return");
49187
49247
  case 11:
49188
49248
  if (MediaProcessorConnector.isValidConnector(mediaProcessorConnector)) {
49189
- _context57.next = 14;
49249
+ _context58.next = 14;
49190
49250
  break;
49191
49251
  }
49192
49252
  message = 'Invalid MediaProcessorConnector';
@@ -49194,7 +49254,7 @@ function PublisherFactory(_ref) {
49194
49254
  case 14:
49195
49255
  _webRTCStream$getAudi2 = webRTCStream.getAudioTracks(), originalAudioTrack = _webRTCStream$getAudi2[0];
49196
49256
  if (originalAudioTrack) {
49197
- _context57.next = 20;
49257
+ _context58.next = 20;
49198
49258
  break;
49199
49259
  }
49200
49260
  message = 'Connector not set as no audio track is present.';
@@ -49203,30 +49263,30 @@ function PublisherFactory(_ref) {
49203
49263
  throw new Error(message);
49204
49264
  case 20:
49205
49265
  _audioMediaProcessorConnector = new MediaProcessorConnector(mediaProcessorConnector);
49206
- _context57.prev = 21;
49207
- _context57.next = 24;
49266
+ _context58.prev = 21;
49267
+ _context58.next = 24;
49208
49268
  return _audioMediaProcessorConnector.setTrack(originalAudioTrack);
49209
49269
  case 24:
49210
- filteredAudioTrack = _context57.sent;
49211
- _context57.next = 27;
49270
+ filteredAudioTrack = _context58.sent;
49271
+ _context58.next = 27;
49212
49272
  return replaceAudioTrack(_this._getAudioSource(), filteredAudioTrack);
49213
49273
  case 27:
49214
- _context57.next = 34;
49274
+ _context58.next = 34;
49215
49275
  break;
49216
49276
  case 29:
49217
- _context57.prev = 29;
49218
- _context57.t0 = _context57["catch"](21);
49277
+ _context58.prev = 29;
49278
+ _context58.t0 = _context58["catch"](21);
49219
49279
  _audioMediaProcessorConnector = null;
49220
- logging.error(`setAudioMediaProcessorConnector: Error getting track from MediaProcessorConnector: ${_context57.t0}`);
49221
- throw _context57.t0;
49280
+ logging.error(`setAudioMediaProcessorConnector: Error getting track from MediaProcessorConnector: ${_context58.t0}`);
49281
+ throw _context58.t0;
49222
49282
  case 34:
49223
49283
  case "end":
49224
- return _context57.stop();
49284
+ return _context58.stop();
49225
49285
  }
49226
- }, _callee57, null, [[21, 29]]);
49286
+ }, _callee58, null, [[21, 29]]);
49227
49287
  }));
49228
- return function _setAudioMediaProcessorConnector(_x45) {
49229
- return _ref64.apply(this, arguments);
49288
+ return function _setAudioMediaProcessorConnector(_x47) {
49289
+ return _ref65.apply(this, arguments);
49230
49290
  };
49231
49291
  }();
49232
49292
 
@@ -49247,22 +49307,22 @@ function PublisherFactory(_ref) {
49247
49307
  * @return {Promise} A promise that resolves when the operation completes successfully.
49248
49308
  * If there is an error, the promise is rejected.
49249
49309
  */
49250
- this.clearVideoFilter = /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee58() {
49310
+ this.clearVideoFilter = /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee59() {
49251
49311
  var message, oldVideoFilter, _webRTCStream$getVide5, filteredVideoTrack, videoTrack;
49252
- return _regenerator.default.wrap(function _callee58$(_context58) {
49253
- while (1) switch (_context58.prev = _context58.next) {
49312
+ return _regenerator.default.wrap(function _callee59$(_context59) {
49313
+ while (1) switch (_context59.prev = _context59.next) {
49254
49314
  case 0:
49255
49315
  logAnalyticsEvent('clearVideoFilter', 'Attempt');
49256
49316
  if (!(!properties.publishVideo && !mediaProcessor.getVideoFilter())) {
49257
- _context58.next = 5;
49317
+ _context59.next = 5;
49258
49318
  break;
49259
49319
  }
49260
49320
  currentVideoFilter = null;
49261
49321
  logAnalyticsEvent('clearVideoFilter', 'Success');
49262
- return _context58.abrupt("return");
49322
+ return _context59.abrupt("return");
49263
49323
  case 5:
49264
49324
  if (!(!mediaProcessor.getVideoFilter() && !currentVideoFilter)) {
49265
- _context58.next = 10;
49325
+ _context59.next = 10;
49266
49326
  break;
49267
49327
  }
49268
49328
  message = 'Ignoring. No video filter applied';
@@ -49270,10 +49330,10 @@ function PublisherFactory(_ref) {
49270
49330
  message
49271
49331
  });
49272
49332
  logging.debug(message);
49273
- return _context58.abrupt("return");
49333
+ return _context59.abrupt("return");
49274
49334
  case 10:
49275
49335
  if (MediaProcessor.isSupported('video')) {
49276
- _context58.next = 15;
49336
+ _context59.next = 15;
49277
49337
  break;
49278
49338
  }
49279
49339
  message = 'Ignoring. "clearVideoFilter" not supported.';
@@ -49281,10 +49341,10 @@ function PublisherFactory(_ref) {
49281
49341
  message
49282
49342
  });
49283
49343
  logging.warn(message);
49284
- return _context58.abrupt("return");
49344
+ return _context59.abrupt("return");
49285
49345
  case 15:
49286
49346
  if (webRTCStream) {
49287
- _context58.next = 20;
49347
+ _context59.next = 20;
49288
49348
  break;
49289
49349
  }
49290
49350
  message = 'Ignoring. No mediaStream';
@@ -49292,44 +49352,44 @@ function PublisherFactory(_ref) {
49292
49352
  message
49293
49353
  });
49294
49354
  logging.warn(message);
49295
- return _context58.abrupt("return");
49355
+ return _context59.abrupt("return");
49296
49356
  case 20:
49297
49357
  oldVideoFilter = currentVideoFilter;
49298
49358
  currentVideoFilter = null;
49299
49359
  _webRTCStream$getVide5 = webRTCStream.getVideoTracks(), filteredVideoTrack = _webRTCStream$getVide5[0];
49300
- _context58.prev = 23;
49301
- _context58.next = 26;
49360
+ _context59.prev = 23;
49361
+ _context59.next = 26;
49302
49362
  return getTrackFromDeviceId(currentDeviceId);
49303
49363
  case 26:
49304
- videoTrack = _context58.sent;
49305
- _context58.next = 33;
49364
+ videoTrack = _context59.sent;
49365
+ _context59.next = 33;
49306
49366
  break;
49307
49367
  case 29:
49308
- _context58.prev = 29;
49309
- _context58.t0 = _context58["catch"](23);
49310
- logging.error(_context58.t0);
49311
- return _context58.abrupt("return");
49368
+ _context59.prev = 29;
49369
+ _context59.t0 = _context59["catch"](23);
49370
+ logging.error(_context59.t0);
49371
+ return _context59.abrupt("return");
49312
49372
  case 33:
49313
49373
  if (videoTrack) {
49314
- _context58.next = 36;
49374
+ _context59.next = 36;
49315
49375
  break;
49316
49376
  }
49317
49377
  logging.warn('Failed to clear filter because there is no video track.');
49318
- return _context58.abrupt("return");
49378
+ return _context59.abrupt("return");
49319
49379
  case 36:
49320
49380
  filteredVideoTrackId = null;
49321
- _context58.prev = 37;
49322
- _context58.next = 40;
49381
+ _context59.prev = 37;
49382
+ _context59.next = 40;
49323
49383
  return replaceTrackAndUpdate(filteredVideoTrack, videoTrack);
49324
49384
  case 40:
49325
- _context58.next = 42;
49385
+ _context59.next = 42;
49326
49386
  return destroyMediaProcessor();
49327
49387
  case 42:
49328
- _context58.next = 47;
49388
+ _context59.next = 47;
49329
49389
  break;
49330
49390
  case 44:
49331
- _context58.prev = 44;
49332
- _context58.t1 = _context58["catch"](37);
49391
+ _context59.prev = 44;
49392
+ _context59.t1 = _context59["catch"](37);
49333
49393
  // Restore the previous filter since this call has failed. This way, this function can be
49334
49394
  // called again if needed.
49335
49395
  currentVideoFilter = oldVideoFilter;
@@ -49337,29 +49397,29 @@ function PublisherFactory(_ref) {
49337
49397
  logAnalyticsEvent('clearVideoFilter', 'Success');
49338
49398
  case 48:
49339
49399
  case "end":
49340
- return _context58.stop();
49400
+ return _context59.stop();
49341
49401
  }
49342
- }, _callee58, null, [[23, 29], [37, 44]]);
49402
+ }, _callee59, null, [[23, 29], [37, 44]]);
49343
49403
  }));
49344
49404
  const applySetMaxBitrateToPeerConnection = /*#__PURE__*/function () {
49345
- var _ref66 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee59(peerConnection) {
49405
+ var _ref67 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee60(peerConnection) {
49346
49406
  var maxBitrateHasChanged, isPreset;
49347
- return _regenerator.default.wrap(function _callee59$(_context59) {
49348
- while (1) switch (_context59.prev = _context59.next) {
49407
+ return _regenerator.default.wrap(function _callee60$(_context60) {
49408
+ while (1) switch (_context60.prev = _context60.next) {
49349
49409
  case 0:
49350
- _context59.next = 2;
49410
+ _context60.next = 2;
49351
49411
  return peerConnection.setMaxBitrate(_videoMaxBitrateSetting);
49352
49412
  case 2:
49353
- maxBitrateHasChanged = _context59.sent;
49413
+ maxBitrateHasChanged = _context60.sent;
49354
49414
  if (!maxBitrateHasChanged) {
49355
- _context59.next = 8;
49415
+ _context60.next = 8;
49356
49416
  break;
49357
49417
  }
49358
49418
  if (!(_videoMaxBitrateSetting === 0)) {
49359
- _context59.next = 6;
49419
+ _context60.next = 6;
49360
49420
  break;
49361
49421
  }
49362
- return _context59.abrupt("return");
49422
+ return _context60.abrupt("return");
49363
49423
  case 6:
49364
49424
  isPreset = typeof _videoMaxBitrateSetting === 'string';
49365
49425
  if (isPreset) {
@@ -49371,12 +49431,12 @@ function PublisherFactory(_ref) {
49371
49431
  }
49372
49432
  case 8:
49373
49433
  case "end":
49374
- return _context59.stop();
49434
+ return _context60.stop();
49375
49435
  }
49376
- }, _callee59);
49436
+ }, _callee60);
49377
49437
  }));
49378
- return function applySetMaxBitrateToPeerConnection(_x46) {
49379
- return _ref66.apply(this, arguments);
49438
+ return function applySetMaxBitrateToPeerConnection(_x48) {
49439
+ return _ref67.apply(this, arguments);
49380
49440
  };
49381
49441
  }();
49382
49442
 
@@ -49404,16 +49464,16 @@ function PublisherFactory(_ref) {
49404
49464
  */
49405
49465
  this.getVideoBitratePreset = () => properties.videoBitratePreset;
49406
49466
  const setMaxVideoBitrateToPublisher = /*#__PURE__*/function () {
49407
- var _ref67 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee61(peerConnection) {
49467
+ var _ref68 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee62(peerConnection) {
49408
49468
  var logOptions, applyMaxBitrate, peerConnections;
49409
- return _regenerator.default.wrap(function _callee61$(_context61) {
49410
- while (1) switch (_context61.prev = _context61.next) {
49469
+ return _regenerator.default.wrap(function _callee62$(_context62) {
49470
+ while (1) switch (_context62.prev = _context62.next) {
49411
49471
  case 0:
49412
49472
  if (!(_videoMaxBitrateSetting === undefined)) {
49413
- _context61.next = 2;
49473
+ _context62.next = 2;
49414
49474
  break;
49415
49475
  }
49416
- return _context61.abrupt("return");
49476
+ return _context62.abrupt("return");
49417
49477
  case 2:
49418
49478
  if (isNaN(_videoMaxBitrateSetting)) {
49419
49479
  logOptions = {
@@ -49429,57 +49489,57 @@ function PublisherFactory(_ref) {
49429
49489
  logOptions.NearestResolution = (0, _getSpatialResolution.default)(_this.videoWidth(), _this.videoHeight());
49430
49490
  logAnalyticsEvent('SetMaxVideoBitrateOnRtpSender', 'Attempt', {}, logOptions);
49431
49491
  applyMaxBitrate = /*#__PURE__*/function () {
49432
- var _ref68 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee60(pc) {
49433
- return _regenerator.default.wrap(function _callee60$(_context60) {
49434
- while (1) switch (_context60.prev = _context60.next) {
49492
+ var _ref69 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee61(pc) {
49493
+ return _regenerator.default.wrap(function _callee61$(_context61) {
49494
+ while (1) switch (_context61.prev = _context61.next) {
49435
49495
  case 0:
49436
- _context60.prev = 0;
49437
- _context60.next = 3;
49496
+ _context61.prev = 0;
49497
+ _context61.next = 3;
49438
49498
  return applySetMaxBitrateToPeerConnection(pc);
49439
49499
  case 3:
49440
49500
  logAnalyticsEvent('SetMaxVideoBitrateOnRtpSender', 'Success', {}, logOptions);
49441
- _context60.next = 11;
49501
+ _context61.next = 11;
49442
49502
  break;
49443
49503
  case 6:
49444
- _context60.prev = 6;
49445
- _context60.t0 = _context60["catch"](0);
49446
- logOptions.failureReason = _context60.t0.message;
49504
+ _context61.prev = 6;
49505
+ _context61.t0 = _context61["catch"](0);
49506
+ logOptions.failureReason = _context61.t0.message;
49447
49507
  logAnalyticsEvent('SetMaxVideoBitrateOnRtpSender', 'Failure', {}, logOptions);
49448
49508
  throw otError(Errors.UNEXPECTED_ERROR_CODE, new Error('An unexpected error was encountered'));
49449
49509
  case 11:
49450
49510
  case "end":
49451
- return _context60.stop();
49511
+ return _context61.stop();
49452
49512
  }
49453
- }, _callee60, null, [[0, 6]]);
49513
+ }, _callee61, null, [[0, 6]]);
49454
49514
  }));
49455
- return function applyMaxBitrate(_x48) {
49456
- return _ref68.apply(this, arguments);
49515
+ return function applyMaxBitrate(_x50) {
49516
+ return _ref69.apply(this, arguments);
49457
49517
  };
49458
49518
  }();
49459
49519
  if (!peerConnection) {
49460
- _context61.next = 11;
49520
+ _context62.next = 11;
49461
49521
  break;
49462
49522
  }
49463
- _context61.next = 9;
49523
+ _context62.next = 9;
49464
49524
  return applyMaxBitrate(peerConnection);
49465
49525
  case 9:
49466
- _context61.next = 16;
49526
+ _context62.next = 16;
49467
49527
  break;
49468
49528
  case 11:
49469
- _context61.next = 13;
49529
+ _context62.next = 13;
49470
49530
  return getAllPeerConnections();
49471
49531
  case 13:
49472
- peerConnections = _context61.sent;
49473
- _context61.next = 16;
49532
+ peerConnections = _context62.sent;
49533
+ _context62.next = 16;
49474
49534
  return Promise.all(peerConnections.map(applyMaxBitrate));
49475
49535
  case 16:
49476
49536
  case "end":
49477
- return _context61.stop();
49537
+ return _context62.stop();
49478
49538
  }
49479
- }, _callee61);
49539
+ }, _callee62);
49480
49540
  }));
49481
- return function setMaxVideoBitrateToPublisher(_x47) {
49482
- return _ref67.apply(this, arguments);
49541
+ return function setMaxVideoBitrateToPublisher(_x49) {
49542
+ return _ref68.apply(this, arguments);
49483
49543
  };
49484
49544
  }();
49485
49545
  const applyVideoConstraintsTo = track => {
@@ -49535,17 +49595,17 @@ function PublisherFactory(_ref) {
49535
49595
  * @memberOf Publisher
49536
49596
  */
49537
49597
  this.setPreferredResolution = /*#__PURE__*/function () {
49538
- var _ref69 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee62(preferredResolution) {
49598
+ var _ref70 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee63(preferredResolution) {
49539
49599
  var _webRTCStream, _webRTCStream$getVide6, _properties$videoDime3, _properties$videoDime4;
49540
49600
  var message, startingWidth, startingHeight, startingArea, preferredArea, result;
49541
- return _regenerator.default.wrap(function _callee62$(_context62) {
49542
- while (1) switch (_context62.prev = _context62.next) {
49601
+ return _regenerator.default.wrap(function _callee63$(_context63) {
49602
+ while (1) switch (_context63.prev = _context63.next) {
49543
49603
  case 0:
49544
49604
  logAnalyticsEvent('setPreferredResolution', 'Attempt', {
49545
49605
  preferredResolution
49546
49606
  });
49547
49607
  if (!(!properties.publishVideo || !((_webRTCStream = webRTCStream) != null && (_webRTCStream$getVide6 = _webRTCStream.getVideoTracks()) != null && _webRTCStream$getVide6.length))) {
49548
- _context62.next = 5;
49608
+ _context63.next = 5;
49549
49609
  break;
49550
49610
  }
49551
49611
  message = 'setPreferredResolution needs to be called on a video publisher';
@@ -49556,7 +49616,7 @@ function PublisherFactory(_ref) {
49556
49616
  throw new Error(message);
49557
49617
  case 5:
49558
49618
  if (!(!preferredResolution || !Number.isInteger(preferredResolution.width) || preferredResolution.width <= 0 || !Number.isInteger(preferredResolution.height) || preferredResolution.height <= 0)) {
49559
- _context62.next = 9;
49619
+ _context63.next = 9;
49560
49620
  break;
49561
49621
  }
49562
49622
  message = 'preferredResolution must be an object with positive integer width and height properties';
@@ -49571,7 +49631,7 @@ function PublisherFactory(_ref) {
49571
49631
  startingArea = startingWidth * startingHeight;
49572
49632
  preferredArea = preferredResolution.width * preferredResolution.height;
49573
49633
  if (!(preferredArea > startingArea)) {
49574
- _context62.next = 17;
49634
+ _context63.next = 17;
49575
49635
  break;
49576
49636
  }
49577
49637
  message = 'preferredResolution cannot be higher than the initial ' + 'publishing resolution';
@@ -49583,31 +49643,31 @@ function PublisherFactory(_ref) {
49583
49643
  case 17:
49584
49644
  _preferredWidth = preferredResolution.width;
49585
49645
  _preferredHeight = preferredResolution.height;
49586
- _context62.prev = 19;
49587
- _context62.next = 22;
49646
+ _context63.prev = 19;
49647
+ _context63.next = 22;
49588
49648
  return applyVideoConstraints();
49589
49649
  case 22:
49590
- result = _context62.sent;
49650
+ result = _context63.sent;
49591
49651
  logAnalyticsEvent('setPreferredResolution', 'Success', {
49592
49652
  preferredResolution
49593
49653
  });
49594
- return _context62.abrupt("return", result);
49654
+ return _context63.abrupt("return", result);
49595
49655
  case 27:
49596
- _context62.prev = 27;
49597
- _context62.t0 = _context62["catch"](19);
49656
+ _context63.prev = 27;
49657
+ _context63.t0 = _context63["catch"](19);
49598
49658
  logAnalyticsEvent('setPreferredResolution', 'Failure', {
49599
49659
  preferredResolution,
49600
- message: _context62.t0.message
49660
+ message: _context63.t0.message
49601
49661
  });
49602
- throw _context62.t0;
49662
+ throw _context63.t0;
49603
49663
  case 31:
49604
49664
  case "end":
49605
- return _context62.stop();
49665
+ return _context63.stop();
49606
49666
  }
49607
- }, _callee62, null, [[19, 27]]);
49667
+ }, _callee63, null, [[19, 27]]);
49608
49668
  }));
49609
- return function (_x49) {
49610
- return _ref69.apply(this, arguments);
49669
+ return function (_x51) {
49670
+ return _ref70.apply(this, arguments);
49611
49671
  };
49612
49672
  }();
49613
49673
 
@@ -49628,17 +49688,17 @@ function PublisherFactory(_ref) {
49628
49688
  * @memberOf Publisher
49629
49689
  */
49630
49690
  this.setPreferredFrameRate = /*#__PURE__*/function () {
49631
- var _ref70 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee63(frameRate) {
49691
+ var _ref71 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee64(frameRate) {
49632
49692
  var _webRTCStream2, _webRTCStream2$getVid;
49633
49693
  var message, result;
49634
- return _regenerator.default.wrap(function _callee63$(_context63) {
49635
- while (1) switch (_context63.prev = _context63.next) {
49694
+ return _regenerator.default.wrap(function _callee64$(_context64) {
49695
+ while (1) switch (_context64.prev = _context64.next) {
49636
49696
  case 0:
49637
49697
  logAnalyticsEvent('setPreferredFrameRate', 'Attempt', {
49638
49698
  frameRate
49639
49699
  });
49640
49700
  if (!(!properties.publishVideo || !((_webRTCStream2 = webRTCStream) != null && (_webRTCStream2$getVid = _webRTCStream2.getVideoTracks()) != null && _webRTCStream2$getVid.length))) {
49641
- _context63.next = 5;
49701
+ _context64.next = 5;
49642
49702
  break;
49643
49703
  }
49644
49704
  message = 'setPreferredFrameRate needs to be called on a video publisher';
@@ -49649,7 +49709,7 @@ function PublisherFactory(_ref) {
49649
49709
  throw new Error(message);
49650
49710
  case 5:
49651
49711
  if (!(!Number.isInteger(frameRate) || frameRate < 1)) {
49652
- _context63.next = 9;
49712
+ _context64.next = 9;
49653
49713
  break;
49654
49714
  }
49655
49715
  message = 'Invalid frameRate: must be an integer ≥ 1';
@@ -49660,31 +49720,31 @@ function PublisherFactory(_ref) {
49660
49720
  throw new Error(message);
49661
49721
  case 9:
49662
49722
  _preferredFrameRate = frameRate;
49663
- _context63.prev = 10;
49664
- _context63.next = 13;
49723
+ _context64.prev = 10;
49724
+ _context64.next = 13;
49665
49725
  return applyVideoConstraints();
49666
49726
  case 13:
49667
- result = _context63.sent;
49727
+ result = _context64.sent;
49668
49728
  logAnalyticsEvent('setPreferredFrameRate', 'Success', {
49669
49729
  frameRate
49670
49730
  });
49671
- return _context63.abrupt("return", result);
49731
+ return _context64.abrupt("return", result);
49672
49732
  case 18:
49673
- _context63.prev = 18;
49674
- _context63.t0 = _context63["catch"](10);
49733
+ _context64.prev = 18;
49734
+ _context64.t0 = _context64["catch"](10);
49675
49735
  logAnalyticsEvent('setPreferredFrameRate', 'Failure', {
49676
49736
  frameRate,
49677
- message: _context63.t0.message
49737
+ message: _context64.t0.message
49678
49738
  });
49679
- throw _context63.t0;
49739
+ throw _context64.t0;
49680
49740
  case 22:
49681
49741
  case "end":
49682
- return _context63.stop();
49742
+ return _context64.stop();
49683
49743
  }
49684
- }, _callee63, null, [[10, 18]]);
49744
+ }, _callee64, null, [[10, 18]]);
49685
49745
  }));
49686
- return function (_x50) {
49687
- return _ref70.apply(this, arguments);
49746
+ return function (_x52) {
49747
+ return _ref71.apply(this, arguments);
49688
49748
  };
49689
49749
  }();
49690
49750
 
@@ -49708,44 +49768,44 @@ function PublisherFactory(_ref) {
49708
49768
  * @memberOf Publisher
49709
49769
  */
49710
49770
  this.setMaxVideoBitrate = /*#__PURE__*/function () {
49711
- var _ref71 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee64(bitrateBps) {
49771
+ var _ref72 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee65(bitrateBps) {
49712
49772
  var bitrate;
49713
- return _regenerator.default.wrap(function _callee64$(_context64) {
49714
- while (1) switch (_context64.prev = _context64.next) {
49773
+ return _regenerator.default.wrap(function _callee65$(_context65) {
49774
+ while (1) switch (_context65.prev = _context65.next) {
49715
49775
  case 0:
49716
49776
  if (!(typeof bitrateBps !== 'number')) {
49717
- _context64.next = 2;
49777
+ _context65.next = 2;
49718
49778
  break;
49719
49779
  }
49720
49780
  throw otError(Errors.INVALID_PARAMETER, new Error('Invalid bitrate: it must be 0 or any number between 5000 and 10000000'));
49721
49781
  case 2:
49722
49782
  bitrate = parseInt(bitrateBps, 10);
49723
49783
  if (!(isNaN(bitrate) || bitrate !== 0 && (bitrate < 5000 || bitrate > 10000000))) {
49724
- _context64.next = 5;
49784
+ _context65.next = 5;
49725
49785
  break;
49726
49786
  }
49727
49787
  throw otError(Errors.INVALID_PARAMETER, new Error('Invalid bitrate: it must be 0 or any number between 5000 and 10000000'));
49728
49788
  case 5:
49729
49789
  _videoMaxBitrateSetting = bitrate === 0 ? _VideoBitratePreset.default.DEFAULT : bitrate;
49730
49790
  if (isAudioFallbackActive()) {
49731
- _context64.next = 11;
49791
+ _context65.next = 11;
49732
49792
  break;
49733
49793
  }
49734
- _context64.next = 9;
49794
+ _context65.next = 9;
49735
49795
  return setMaxVideoBitrateToPublisher();
49736
49796
  case 9:
49737
- _context64.next = 12;
49797
+ _context65.next = 12;
49738
49798
  break;
49739
49799
  case 11:
49740
49800
  logging.debug('Video is currently inactive, max bitrate will be applied once active.');
49741
49801
  case 12:
49742
49802
  case "end":
49743
- return _context64.stop();
49803
+ return _context65.stop();
49744
49804
  }
49745
- }, _callee64);
49805
+ }, _callee65);
49746
49806
  }));
49747
- return function (_x51) {
49748
- return _ref71.apply(this, arguments);
49807
+ return function (_x53) {
49808
+ return _ref72.apply(this, arguments);
49749
49809
  };
49750
49810
  }();
49751
49811
 
@@ -49767,44 +49827,44 @@ function PublisherFactory(_ref) {
49767
49827
  * @memberOf Publisher
49768
49828
  */
49769
49829
  this.setVideoBitratePreset = /*#__PURE__*/function () {
49770
- var _ref72 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee65(preset) {
49830
+ var _ref73 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee66(preset) {
49771
49831
  var filteredPreset;
49772
- return _regenerator.default.wrap(function _callee65$(_context65) {
49773
- while (1) switch (_context65.prev = _context65.next) {
49832
+ return _regenerator.default.wrap(function _callee66$(_context66) {
49833
+ while (1) switch (_context66.prev = _context66.next) {
49774
49834
  case 0:
49775
49835
  if (!(typeof preset !== 'string')) {
49776
- _context65.next = 2;
49836
+ _context66.next = 2;
49777
49837
  break;
49778
49838
  }
49779
49839
  throw otError(Errors.INVALID_PARAMETER, new Error('Invalid preset. It must be either "default", "bw_saver", or "extra_bw_saver"'));
49780
49840
  case 2:
49781
49841
  filteredPreset = _VideoBitratePreset.default[preset.toUpperCase()];
49782
49842
  if (!(filteredPreset === undefined)) {
49783
- _context65.next = 5;
49843
+ _context66.next = 5;
49784
49844
  break;
49785
49845
  }
49786
49846
  throw otError(Errors.INVALID_PARAMETER, new Error('Invalid preset. It must be either "default", "bw_saver", or "extra_bw_saver"'));
49787
49847
  case 5:
49788
49848
  _videoMaxBitrateSetting = filteredPreset;
49789
49849
  if (isAudioFallbackActive()) {
49790
- _context65.next = 11;
49850
+ _context66.next = 11;
49791
49851
  break;
49792
49852
  }
49793
- _context65.next = 9;
49853
+ _context66.next = 9;
49794
49854
  return setMaxVideoBitrateToPublisher();
49795
49855
  case 9:
49796
- _context65.next = 12;
49856
+ _context66.next = 12;
49797
49857
  break;
49798
49858
  case 11:
49799
49859
  logging.debug('Video is currently inactive, bitrate preset will be applied once active.');
49800
49860
  case 12:
49801
49861
  case "end":
49802
- return _context65.stop();
49862
+ return _context66.stop();
49803
49863
  }
49804
- }, _callee65);
49864
+ }, _callee66);
49805
49865
  }));
49806
- return function (_x52) {
49807
- return _ref72.apply(this, arguments);
49866
+ return function (_x54) {
49867
+ return _ref73.apply(this, arguments);
49808
49868
  };
49809
49869
  }();
49810
49870
 
@@ -65861,13 +65921,16 @@ function PeerConnectionFactory(deps) {
65861
65921
  iceRestartTimeout = null;
65862
65922
  }
65863
65923
  };
65864
- const _createOfferWithIceRestart = force => {
65924
+ const _createOfferWithIceRestart = (reason, forcedRestart, recentlyIceRestartNeeded) => {
65865
65925
  clearIceRestartTimeout();
65866
- if (!api.iceConnectionStateIsConnected()) {
65867
- if (force) {
65926
+ if (forcedRestart || !api.iceConnectionStateIsConnected()) {
65927
+ if (forcedRestart || recentlyIceRestartNeeded) {
65928
+ api.trigger('iceRestartAttempt', {
65929
+ reason
65930
+ });
65868
65931
  api.generateOfferAndSend();
65869
65932
  } else {
65870
- debouncedGenerateOfferAndSend();
65933
+ debouncedGenerateOfferAndSend(reason);
65871
65934
  }
65872
65935
  } else {
65873
65936
  logging.debug('iceRestart is going to wait until we disconnect or negotiationNeeded' + ' and then restart ice');
@@ -65878,20 +65941,25 @@ function PeerConnectionFactory(deps) {
65878
65941
  };
65879
65942
  const _iceRestartNeeded = (() => {
65880
65943
  let value = false;
65944
+ let reason;
65881
65945
  let lastIceRestartNeededTime = 0;
65882
65946
  return {
65883
65947
  get() {
65884
65948
  return value;
65885
65949
  },
65886
- set(newValueParam) {
65950
+ set(newValueParam, iceRestartReason, forcedRestart) {
65951
+ if (forcedRestart === void 0) {
65952
+ forcedRestart = false;
65953
+ }
65887
65954
  const newValue = Boolean(newValueParam);
65888
65955
  if (newValue !== value) {
65889
65956
  value = newValue;
65957
+ reason = iceRestartReason;
65890
65958
  if (value) {
65891
65959
  const prevIceRestartNeededTime = lastIceRestartNeededTime;
65892
65960
  lastIceRestartNeededTime = Date.now();
65893
65961
  const recentlyIceRestartNeeded = lastIceRestartNeededTime - prevIceRestartNeededTime < 10000;
65894
- _createOfferWithIceRestart(recentlyIceRestartNeeded);
65962
+ _createOfferWithIceRestart(reason, forcedRestart, recentlyIceRestartNeeded);
65895
65963
  } else {
65896
65964
  clearIceRestartTimeout();
65897
65965
  debouncedGenerateOfferAndSend.cancel();
@@ -65901,7 +65969,7 @@ function PeerConnectionFactory(deps) {
65901
65969
  run() {
65902
65970
  if (value) {
65903
65971
  clearIceRestartTimeout();
65904
- debouncedGenerateOfferAndSend();
65972
+ debouncedGenerateOfferAndSend(reason);
65905
65973
  }
65906
65974
  return value;
65907
65975
  }
@@ -66602,7 +66670,12 @@ function PeerConnectionFactory(deps) {
66602
66670
  };
66603
66671
  api.generateOffer(offerSender);
66604
66672
  };
66605
- const debouncedGenerateOfferAndSend = debounce(api.generateOfferAndSend, 2000);
66673
+ const debouncedGenerateOfferAndSend = debounce(reason => {
66674
+ api.trigger('iceRestartAttempt', {
66675
+ reason
66676
+ });
66677
+ api.generateOfferAndSend();
66678
+ }, 2000);
66606
66679
  api.generateOffer = debounce(function (onOfferCreated) {
66607
66680
  if (onOfferCreated === void 0) {
66608
66681
  onOfferCreated = () => {};
@@ -66771,7 +66844,7 @@ function PeerConnectionFactory(deps) {
66771
66844
  setTimeout(tearDownPeerConnection);
66772
66845
  }
66773
66846
  };
66774
- api.iceRestart = () => _iceRestartNeeded.set(true);
66847
+ api.iceRestart = (reason, forcedRestart) => _iceRestartNeeded.set(true, reason, forcedRestart);
66775
66848
  api.clearFailedTimeout = () => {
66776
66849
  if (_transitionToFailedTimeOut) {
66777
66850
  clearTimeout(_transitionToFailedTimeOut);
@@ -71020,7 +71093,7 @@ function SessionFactory(deps) {
71020
71093
  sessionObjects.publishers.where({
71021
71094
  session: this
71022
71095
  }).forEach(publisher => {
71023
- publisher._.iceRestart();
71096
+ publisher._.iceRestart('socket reconnected');
71024
71097
  });
71025
71098
  if (!((_this$session = this.session) != null && (_this$session$session = _this$session.sessionInfo) != null && _this$session$session.p2pEnabled)) {
71026
71099
  sessionObjects.subscribers.where({