@opentok/client 2.23.7 → 2.23.8

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.23.7 5807f4903
2
+ * @license OpenTok.js 2.23.8 44cd8f716
3
3
  *
4
4
  * Copyright (c) 2010-2022 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: Thu, 29 Sep 2022 21:06:15 GMT
8
+ * Date: Tue, 11 Oct 2022 12:50:10 GMT
9
9
  */
10
10
 
11
11
  (function webpackUniversalModuleDefinition(root, factory) {
@@ -6453,7 +6453,7 @@ const _require = __webpack_require__(138),
6453
6453
  /** @type builtInConfig */
6454
6454
 
6455
6455
 
6456
- const builtInConfig = cloneDeep({"version":"v2.23.7","buildHash":"5807f4903","minimumVersion":{"firefox":52,"chrome":49},"debug":"false","websiteURL":"http://www.tokbox.com","configURL":"https://config.opentok.com","ipWhitelistConfigURL":"","cdnURL":"https://static.opentok.com","loggingURL":"https://hlg.tokbox.com/prod","apiURL":"https://anvil.opentok.com"});
6456
+ const builtInConfig = cloneDeep({"version":"v2.23.8","buildHash":"44cd8f716","minimumVersion":{"firefox":52,"chrome":49},"debug":"false","websiteURL":"http://www.tokbox.com","configURL":"https://config.opentok.com","ipWhitelistConfigURL":"","cdnURL":"https://static.opentok.com","loggingURL":"https://hlg.tokbox.com/prod","apiURL":"https://anvil.opentok.com"});
6457
6457
  const whitelistAllowedRuntimeProperties = pick(['apiURL', 'assetURL', 'cdnURL', 'sessionInfoOverrides', 'loggingURL']);
6458
6458
  const liveConfigMap = {
6459
6459
  apiUrl: 'apiURL',
@@ -15816,25 +15816,22 @@ function WidgetViewFactory(_temp) {
15816
15816
 
15817
15817
  _proto._waitForVideoResolution = /*#__PURE__*/function () {
15818
15818
  var _waitForVideoResolution2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(webRTCStream) {
15819
- var subscribingToAudioOnlyStream;
15820
15819
  return _regenerator.default.wrap(function _callee3$(_context3) {
15821
15820
  while (1) switch (_context3.prev = _context3.next) {
15822
15821
  case 0:
15823
- subscribingToAudioOnlyStream = this.audioOnly() && this._widgetType === 'subscriber';
15824
-
15825
- if (!(!subscribingToAudioOnlyStream && webRTCStream.getVideoTracks().length > 0)) {
15826
- _context3.next = 6;
15822
+ if (!(!this.audioOnly() && webRTCStream.getVideoTracks().length > 0)) {
15823
+ _context3.next = 5;
15827
15824
  break;
15828
15825
  }
15829
15826
 
15830
15827
  logging.debug('Waiting for correct resolution');
15831
- _context3.next = 5;
15828
+ _context3.next = 4;
15832
15829
  return waitForVideoResolution(this._videoElementFacade, 5000);
15833
15830
 
15834
- case 5:
15831
+ case 4:
15835
15832
  logging.debug(`Resolution: ${this._videoElementFacade.videoWidth()}x${this._videoElementFacade.videoHeight()}`);
15836
15833
 
15837
- case 6:
15834
+ case 5:
15838
15835
  case "end":
15839
15836
  return _context3.stop();
15840
15837
  }
@@ -16920,22 +16917,27 @@ module.exports = function PublisherFactory(_ref) {
16920
16917
 
16921
16918
 
16922
16919
  const getVideoDimensions = () => {
16923
- let streamWidth;
16924
- let streamHeight;
16925
- const video = widgetView && widgetView.video(); // We set the streamWidth and streamHeight to be the minimum of the requested
16926
- // resolution and the actual resolution.
16927
-
16928
- if (properties.videoDimensions) {
16929
- streamWidth = Math.min(properties.videoDimensions.width, video && video.videoWidth() || 640);
16930
- streamHeight = Math.min(properties.videoDimensions.height, video && video.videoHeight() || 480);
16931
- } else {
16932
- streamWidth = video && video.videoWidth() || 640;
16933
- streamHeight = video && video.videoHeight() || 480;
16920
+ var _properties$videoDime, _properties$videoDime2;
16921
+
16922
+ // Values order are:
16923
+ // - Defined by the user.
16924
+ // - Default: VGA (640x480).
16925
+ let width = ((_properties$videoDime = properties.videoDimensions) == null ? void 0 : _properties$videoDime.width) || 640;
16926
+ let height = ((_properties$videoDime2 = properties.videoDimensions) == null ? void 0 : _properties$videoDime2.height) || 480;
16927
+
16928
+ if (properties.publishVideo) {
16929
+ var _widgetView;
16930
+
16931
+ // When video is on, we get the real video dimensions. If undefined, we will take the
16932
+ // previous defined width|height.
16933
+ const video = (_widgetView = widgetView) == null ? void 0 : _widgetView.video();
16934
+ width = (video == null ? void 0 : video.videoWidth()) || width;
16935
+ height = (video == null ? void 0 : video.videoHeight()) || height;
16934
16936
  }
16935
16937
 
16936
16938
  return {
16937
- width: streamWidth,
16938
- height: streamHeight
16939
+ width,
16940
+ height
16939
16941
  };
16940
16942
  }; // / Private Events
16941
16943
 
@@ -18085,6 +18087,11 @@ module.exports = function PublisherFactory(_ref) {
18085
18087
  }
18086
18088
 
18087
18089
  widgetView.on('videoDimensionsChanged', (oldValue, newValue) => {
18090
+ // Ignore this event since there is no video.
18091
+ if (!properties.publishVideo) {
18092
+ return;
18093
+ }
18094
+
18088
18095
  if (this.stream) {
18089
18096
  this.stream.setVideoDimensions(newValue.width, newValue.height);
18090
18097
  }
@@ -18146,7 +18153,7 @@ module.exports = function PublisherFactory(_ref) {
18146
18153
 
18147
18154
  case 6:
18148
18155
  if (!properties.publishVideo) {
18149
- _this._toggleVideo(properties.publishVideo);
18156
+ _this._toggleVideo(properties.publishVideo, getVideoDimensions());
18150
18157
  }
18151
18158
 
18152
18159
  if (!isScreenSharing && !isCustomVideoTrack // For filtered video, we stored the currentDeviceId already.
@@ -18550,11 +18557,10 @@ module.exports = function PublisherFactory(_ref) {
18550
18557
  let currentDeviceId;
18551
18558
  let currentVideoFilter;
18552
18559
  this._toggleVideo = blockCallsUntilComplete( /*#__PURE__*/function () {
18553
- var _ref28 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(shouldHaveVideo) {
18560
+ var _ref28 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(shouldHaveVideo, videoDimensions) {
18554
18561
  var _vidDevices$find;
18555
18562
 
18556
- var _properties$videoDime, videoDimensions, vidDevices, oldTrack, oldTrackDeviceId, newTrack, videoFilter;
18557
-
18563
+ var vidDevices, oldTrack, oldTrackDeviceId, newTrack, videoFilter;
18558
18564
  return _regenerator.default.wrap(function _callee17$(_context17) {
18559
18565
  while (1) switch (_context17.prev = _context17.next) {
18560
18566
  case 0:
@@ -18566,42 +18572,41 @@ module.exports = function PublisherFactory(_ref) {
18566
18572
  return _context17.abrupt("return");
18567
18573
 
18568
18574
  case 2:
18569
- _properties$videoDime = properties.videoDimensions, videoDimensions = _properties$videoDime === void 0 ? getVideoDimensions() : _properties$videoDime;
18570
- _context17.next = 5;
18575
+ _context17.next = 4;
18571
18576
  return getVideoDevices();
18572
18577
 
18573
- case 5:
18578
+ case 4:
18574
18579
  vidDevices = _context17.sent;
18575
18580
  oldTrack = getCurrentTrack();
18576
18581
 
18577
18582
  if (oldTrack) {
18578
- _context17.next = 9;
18583
+ _context17.next = 8;
18579
18584
  break;
18580
18585
  }
18581
18586
 
18582
18587
  throw otError(Errors.NOT_SUPPORTED, new Error('Publisher._toggleVideo cannot toggleVideo when you have no video source.'));
18583
18588
 
18584
- case 9:
18589
+ case 8:
18585
18590
  // oldTrackDeviceId is undefined when it comes from a canvasTracks, i.e.: it is currently muted
18586
18591
  oldTrackDeviceId = (_vidDevices$find = vidDevices.find(device => device.label === oldTrack.label)) == null ? void 0 : _vidDevices$find.deviceId;
18587
18592
 
18588
18593
  if (isNewTrackNeeded(shouldHaveVideo, oldTrackDeviceId)) {
18589
- _context17.next = 12;
18594
+ _context17.next = 11;
18590
18595
  break;
18591
18596
  }
18592
18597
 
18593
18598
  return _context17.abrupt("return");
18594
18599
 
18595
- case 12:
18600
+ case 11:
18596
18601
  if (!(oldTrack.readyState === 'ended')) {
18597
- _context17.next = 15;
18602
+ _context17.next = 14;
18598
18603
  break;
18599
18604
  }
18600
18605
 
18601
18606
  isTrackManuallyStopped = true;
18602
18607
  return _context17.abrupt("return");
18603
18608
 
18604
- case 15:
18609
+ case 14:
18605
18610
  if (shouldHaveVideo && OTHelpers.env.isAndroid && OTHelpers.env.isChrome) {
18606
18611
  // On Chrome on Android you need to stop the previous video track OPENTOK-37206
18607
18612
  if (oldTrack && oldTrack.stop) {
@@ -18610,21 +18615,21 @@ module.exports = function PublisherFactory(_ref) {
18610
18615
  }
18611
18616
 
18612
18617
  if (shouldHaveVideo) {
18613
- _context17.next = 32;
18618
+ _context17.next = 31;
18614
18619
  break;
18615
18620
  }
18616
18621
 
18617
- _context17.prev = 17;
18622
+ _context17.prev = 16;
18618
18623
  newTrack = createCanvasVideoTrack(videoDimensions);
18619
- _context17.next = 24;
18624
+ _context17.next = 23;
18620
18625
  break;
18621
18626
 
18622
- case 21:
18623
- _context17.prev = 21;
18624
- _context17.t0 = _context17["catch"](17);
18627
+ case 20:
18628
+ _context17.prev = 20;
18629
+ _context17.t0 = _context17["catch"](16);
18625
18630
  return _context17.abrupt("return");
18626
18631
 
18627
- case 24:
18632
+ case 23:
18628
18633
  if (oldTrackDeviceId) {
18629
18634
  // store the current deviceId to reacquire the video later
18630
18635
  currentDeviceId = oldTrackDeviceId;
@@ -18634,125 +18639,125 @@ module.exports = function PublisherFactory(_ref) {
18634
18639
  videoFilter = mediaProcessor.getVideoFilter();
18635
18640
 
18636
18641
  if (!videoFilter) {
18637
- _context17.next = 31;
18642
+ _context17.next = 30;
18638
18643
  break;
18639
18644
  }
18640
18645
 
18641
18646
  // Save the current video filter because we want to make sure it
18642
18647
  // gets enabled when the user publishes video again
18643
18648
  currentVideoFilter = videoFilter;
18644
- _context17.next = 31;
18649
+ _context17.next = 30;
18645
18650
  return destroyMediaProcessor();
18646
18651
 
18647
- case 31:
18652
+ case 30:
18648
18653
  if (_videoMediaProcessorConnector) {
18649
18654
  _videoMediaProcessorConnector.destroy();
18650
18655
 
18651
18656
  _videoMediaProcessorConnector.stopOriginalTrack();
18652
18657
  }
18653
18658
 
18654
- case 32:
18659
+ case 31:
18655
18660
  if (!(currentDeviceId && vidDevices.findIndex(device => device.deviceId === currentDeviceId) === -1)) {
18656
- _context17.next = 34;
18661
+ _context17.next = 33;
18657
18662
  break;
18658
18663
  }
18659
18664
 
18660
18665
  throw otError(Errors.NO_DEVICES_FOUND, new Error('Previous device no longer available - deviceId not found'));
18661
18666
 
18662
- case 34:
18667
+ case 33:
18663
18668
  privateEvents.emit('streamDestroy');
18664
18669
 
18665
18670
  if (!shouldHaveVideo) {
18666
- _context17.next = 63;
18671
+ _context17.next = 62;
18667
18672
  break;
18668
18673
  }
18669
18674
 
18670
18675
  if (!hasTrackFromDevice(currentDeviceId)) {
18671
- _context17.next = 38;
18676
+ _context17.next = 37;
18672
18677
  break;
18673
18678
  }
18674
18679
 
18675
18680
  return _context17.abrupt("return");
18676
18681
 
18677
- case 38:
18678
- _context17.prev = 38;
18679
- _context17.next = 41;
18682
+ case 37:
18683
+ _context17.prev = 37;
18684
+ _context17.next = 40;
18680
18685
  return getTrackFromDeviceId(currentDeviceId);
18681
18686
 
18682
- case 41:
18687
+ case 40:
18683
18688
  newTrack = _context17.sent;
18684
- _context17.next = 48;
18689
+ _context17.next = 47;
18685
18690
  break;
18686
18691
 
18687
- case 44:
18688
- _context17.prev = 44;
18689
- _context17.t1 = _context17["catch"](38);
18692
+ case 43:
18693
+ _context17.prev = 43;
18694
+ _context17.t1 = _context17["catch"](37);
18690
18695
  logging.error(`Error getting new track for current device(${currentDeviceId}): ${_context17.t1}`);
18691
- return _context17.abrupt("return");
18696
+ throw _context17.t1;
18692
18697
 
18693
- case 48:
18698
+ case 47:
18694
18699
  if (newTrack) {
18695
- _context17.next = 51;
18700
+ _context17.next = 50;
18696
18701
  break;
18697
18702
  }
18698
18703
 
18699
18704
  logging.error('Failed to enable video. It was not possible to get a new track from the camera');
18700
18705
  return _context17.abrupt("return");
18701
18706
 
18702
- case 51:
18707
+ case 50:
18703
18708
  if (!currentVideoFilter) {
18704
- _context17.next = 59;
18709
+ _context17.next = 58;
18705
18710
  break;
18706
18711
  }
18707
18712
 
18708
- _context17.next = 54;
18713
+ _context17.next = 53;
18709
18714
  return mediaProcessor.setVideoFilter(currentVideoFilter);
18710
18715
 
18711
- case 54:
18712
- _context17.next = 56;
18716
+ case 53:
18717
+ _context17.next = 55;
18713
18718
  return mediaProcessor.setMediaStream(webRTCStream);
18714
18719
 
18715
- case 56:
18716
- _context17.next = 58;
18720
+ case 55:
18721
+ _context17.next = 57;
18717
18722
  return mediaProcessor.setVideoTrack(newTrack);
18718
18723
 
18719
- case 58:
18724
+ case 57:
18720
18725
  newTrack = _context17.sent;
18721
18726
 
18722
- case 59:
18727
+ case 58:
18723
18728
  if (!_videoMediaProcessorConnector) {
18724
- _context17.next = 63;
18729
+ _context17.next = 62;
18725
18730
  break;
18726
18731
  }
18727
18732
 
18728
- _context17.next = 62;
18733
+ _context17.next = 61;
18729
18734
  return _videoMediaProcessorConnector.setTrack(newTrack);
18730
18735
 
18731
- case 62:
18736
+ case 61:
18732
18737
  newTrack = _context17.sent;
18733
18738
 
18734
- case 63:
18735
- _context17.prev = 63;
18736
- _context17.next = 66;
18739
+ case 62:
18740
+ _context17.prev = 62;
18741
+ _context17.next = 65;
18737
18742
  return replaceTrackAndUpdate(oldTrack, newTrack);
18738
18743
 
18739
- case 66:
18740
- _context17.next = 71;
18744
+ case 65:
18745
+ _context17.next = 70;
18741
18746
  break;
18742
18747
 
18743
- case 68:
18744
- _context17.prev = 68;
18745
- _context17.t2 = _context17["catch"](63);
18748
+ case 67:
18749
+ _context17.prev = 67;
18750
+ _context17.t2 = _context17["catch"](62);
18746
18751
  throw _context17.t2;
18747
18752
 
18748
- case 71:
18753
+ case 70:
18749
18754
  case "end":
18750
18755
  return _context17.stop();
18751
18756
  }
18752
- }, _callee17, null, [[17, 21], [38, 44], [63, 68]]);
18757
+ }, _callee17, null, [[16, 20], [37, 43], [62, 67]]);
18753
18758
  }));
18754
18759
 
18755
- return function (_x13) {
18760
+ return function (_x13, _x14) {
18756
18761
  return _ref28.apply(this, arguments);
18757
18762
  };
18758
18763
  }());
@@ -18802,11 +18807,13 @@ module.exports = function PublisherFactory(_ref) {
18802
18807
  this.publishVideo = value => {
18803
18808
  logAnalyticsEvent('publishVideo', 'Attempt', {
18804
18809
  publishVideo: value
18805
- });
18810
+ }); // Save videoDimensions to not alter video size between mute states.
18811
+
18812
+ const videoDimensions = getVideoDimensions();
18806
18813
  properties.publishVideo = value;
18807
18814
 
18808
18815
  try {
18809
- this._toggleVideo(properties.publishVideo);
18816
+ this._toggleVideo(properties.publishVideo, videoDimensions);
18810
18817
 
18811
18818
  updateVideo();
18812
18819
  logAnalyticsEvent('publishVideo', 'Success', {
@@ -19291,7 +19298,7 @@ module.exports = function PublisherFactory(_ref) {
19291
19298
  }, _callee20);
19292
19299
  }));
19293
19300
 
19294
- return function (_x16) {
19301
+ return function (_x17) {
19295
19302
  return _ref32.apply(this, arguments);
19296
19303
  };
19297
19304
  }()));
@@ -19339,7 +19346,7 @@ module.exports = function PublisherFactory(_ref) {
19339
19346
  }, _callee21);
19340
19347
  }));
19341
19348
 
19342
- return function replaceTrackAndUpdate(_x14, _x15) {
19349
+ return function replaceTrackAndUpdate(_x15, _x16) {
19343
19350
  return _ref31.apply(this, arguments);
19344
19351
  };
19345
19352
  }();
@@ -19370,15 +19377,16 @@ module.exports = function PublisherFactory(_ref) {
19370
19377
 
19371
19378
  case 11:
19372
19379
  newVideoStream = _context22.sent;
19373
- _context22.next = 17;
19380
+ _context22.next = 18;
19374
19381
  break;
19375
19382
 
19376
19383
  case 14:
19377
19384
  _context22.prev = 14;
19378
19385
  _context22.t0 = _context22["catch"](8);
19379
- logging.error(_context22.t0); // TODO We may want to consider bubbling up the err here
19386
+ logging.error(_context22.t0);
19387
+ throw _context22.t0;
19380
19388
 
19381
- case 17:
19389
+ case 18:
19382
19390
  _newVideoStream$getVi = (_newVideoStream = newVideoStream) == null ? void 0 : _newVideoStream.getVideoTracks(), track = _newVideoStream$getVi[0];
19383
19391
 
19384
19392
  if (!track) {
@@ -19387,14 +19395,14 @@ module.exports = function PublisherFactory(_ref) {
19387
19395
 
19388
19396
  return _context22.abrupt("return", track);
19389
19397
 
19390
- case 20:
19398
+ case 21:
19391
19399
  case "end":
19392
19400
  return _context22.stop();
19393
19401
  }
19394
19402
  }, _callee22, null, [[8, 14]]);
19395
19403
  }));
19396
19404
 
19397
- return function getTrackFromDeviceId(_x17) {
19405
+ return function getTrackFromDeviceId(_x18) {
19398
19406
  return _ref33.apply(this, arguments);
19399
19407
  };
19400
19408
  }();
@@ -19518,7 +19526,7 @@ module.exports = function PublisherFactory(_ref) {
19518
19526
  }, _callee24);
19519
19527
  }));
19520
19528
 
19521
- return function replaceAudioTrack(_x18, _x19) {
19529
+ return function replaceAudioTrack(_x19, _x20) {
19522
19530
  return _ref35.apply(this, arguments);
19523
19531
  };
19524
19532
  }();
@@ -19559,7 +19567,7 @@ module.exports = function PublisherFactory(_ref) {
19559
19567
  }, _callee25, null, [[1, 8]]);
19560
19568
  }));
19561
19569
 
19562
- return function resetAudioSource(_x20) {
19570
+ return function resetAudioSource(_x21) {
19563
19571
  return _ref36.apply(this, arguments);
19564
19572
  };
19565
19573
  }(); // this should be called when we detect a mute event from a bugged device
@@ -19881,7 +19889,7 @@ module.exports = function PublisherFactory(_ref) {
19881
19889
  }, _callee27, null, [[11, 20], [36, 46]]);
19882
19890
  }));
19883
19891
 
19884
- return function setAudioSource(_x21) {
19892
+ return function setAudioSource(_x22) {
19885
19893
  return _ref38.apply(this, arguments);
19886
19894
  };
19887
19895
  }();
@@ -19999,7 +20007,7 @@ module.exports = function PublisherFactory(_ref) {
19999
20007
  }, _callee28);
20000
20008
  }));
20001
20009
 
20002
- function setVideoSource(_x22) {
20010
+ function setVideoSource(_x23) {
20003
20011
  return _setVideoSource.apply(this, arguments);
20004
20012
  }
20005
20013
 
@@ -20059,7 +20067,7 @@ module.exports = function PublisherFactory(_ref) {
20059
20067
  _context29.t0 = _context29["catch"](8);
20060
20068
  currentDeviceId = oldDeviceID;
20061
20069
  logging.error(_context29.t0);
20062
- return _context29.abrupt("return");
20070
+ throw _context29.t0;
20063
20071
 
20064
20072
  case 19:
20065
20073
  if (newVideoTrack) {
@@ -20110,7 +20118,7 @@ module.exports = function PublisherFactory(_ref) {
20110
20118
  }, _callee29, null, [[8, 14]]);
20111
20119
  }));
20112
20120
 
20113
- return function attemptToSetVideoTrack(_x23) {
20121
+ return function attemptToSetVideoTrack(_x24) {
20114
20122
  return _ref39.apply(this, arguments);
20115
20123
  };
20116
20124
  }();
@@ -20290,8 +20298,8 @@ module.exports = function PublisherFactory(_ref) {
20290
20298
  active: properties.publishVideo,
20291
20299
  orientation: VideoOrientation.ROTATED_NORMAL,
20292
20300
  frameRate: properties.frameRate,
20293
- width: video.videoWidth(),
20294
- height: video.videoHeight(),
20301
+ width: this.videoWidth(),
20302
+ height: this.videoHeight(),
20295
20303
  e2ee: session._.isE2ee(),
20296
20304
  source: (() => {
20297
20305
  if (isScreenSharing) {
@@ -20765,10 +20773,7 @@ module.exports = function PublisherFactory(_ref) {
20765
20773
  */
20766
20774
 
20767
20775
 
20768
- this.videoWidth = function () {
20769
- const video = widgetView && widgetView.video();
20770
- return video ? video.videoWidth() : undefined;
20771
- };
20776
+ this.videoWidth = () => getVideoDimensions().width;
20772
20777
  /**
20773
20778
  * Returns the height, in pixels, of the Publisher video. This may differ from the
20774
20779
  * <code>resolution</code> property passed in as the <code>properties</code> property
@@ -20781,10 +20786,7 @@ module.exports = function PublisherFactory(_ref) {
20781
20786
  */
20782
20787
 
20783
20788
 
20784
- this.videoHeight = function () {
20785
- const video = widgetView && widgetView.video();
20786
- return video ? video.videoHeight() : undefined;
20787
- };
20789
+ this.videoHeight = () => getVideoDimensions().height;
20788
20790
  /**
20789
20791
  * Returns the details on the publisher's stream quality, including the following:
20790
20792
  *
@@ -21098,37 +21100,55 @@ module.exports = function PublisherFactory(_ref) {
21098
21100
  throw otError(Errors.INVALID_PARAMETER, new Error('Video filters can not be applied to screen share'));
21099
21101
 
21100
21102
  case 16:
21101
- if (!_this.getVideoFilter()) {
21102
- _context34.next = 29;
21103
+ enableMediaProcessorLogging();
21104
+
21105
+ if (properties.publishVideo) {
21106
+ _context34.next = 21;
21107
+ break;
21108
+ }
21109
+
21110
+ currentVideoFilter = videoFilter;
21111
+ logAnalyticsEvent('applyVideoFilter', 'Success', {
21112
+ videoFilter
21113
+ });
21114
+ return _context34.abrupt("return");
21115
+
21116
+ case 21:
21117
+ if (!mediaProcessor.getVideoFilter()) {
21118
+ _context34.next = 36;
21103
21119
  break;
21104
21120
  }
21105
21121
 
21106
21122
  if (!mediaProcessor.canUpdateVideoFilter(videoFilter.type)) {
21107
- _context34.next = 27;
21123
+ _context34.next = 34;
21108
21124
  break;
21109
21125
  }
21110
21126
 
21111
- _context34.prev = 18;
21112
- _context34.next = 21;
21127
+ _context34.prev = 23;
21128
+ _context34.next = 26;
21113
21129
  return mediaProcessor.updateVideoFilter(videoFilter);
21114
21130
 
21115
- case 21:
21131
+ case 26:
21132
+ currentVideoFilter = videoFilter;
21133
+ logAnalyticsEvent('applyVideoFilter', 'Success', {
21134
+ videoFilter
21135
+ });
21116
21136
  return _context34.abrupt("return");
21117
21137
 
21118
- case 24:
21119
- _context34.prev = 24;
21120
- _context34.t0 = _context34["catch"](18);
21138
+ case 31:
21139
+ _context34.prev = 31;
21140
+ _context34.t0 = _context34["catch"](23);
21121
21141
  logging.warn(`Error updating video filter: ${_context34.t0}`);
21122
21142
 
21123
- case 27:
21124
- _context34.next = 29;
21143
+ case 34:
21144
+ _context34.next = 36;
21125
21145
  return _this.clearVideoFilter();
21126
21146
 
21127
- case 29:
21147
+ case 36:
21128
21148
  _webRTCStream$getVide2 = webRTCStream.getVideoTracks(), originalVideoTrack = _webRTCStream$getVide2[0];
21129
21149
 
21130
21150
  if (originalVideoTrack) {
21131
- _context34.next = 35;
21151
+ _context34.next = 42;
21132
21152
  break;
21133
21153
  }
21134
21154
 
@@ -21139,32 +21159,31 @@ module.exports = function PublisherFactory(_ref) {
21139
21159
  logging.warn(message);
21140
21160
  return _context34.abrupt("return");
21141
21161
 
21142
- case 35:
21143
- enableMediaProcessorLogging();
21144
- _context34.next = 38;
21162
+ case 42:
21163
+ _context34.next = 44;
21145
21164
  return mediaProcessor.setVideoFilter(videoFilter);
21146
21165
 
21147
- case 38:
21148
- _context34.next = 40;
21166
+ case 44:
21167
+ _context34.next = 46;
21149
21168
  return mediaProcessor.setMediaStream(webRTCStream);
21150
21169
 
21151
- case 40:
21170
+ case 46:
21152
21171
  filteredVideoTrack = _context34.sent;
21153
21172
 
21154
21173
  if (!filteredVideoTrack) {
21155
- _context34.next = 44;
21174
+ _context34.next = 50;
21156
21175
  break;
21157
21176
  }
21158
21177
 
21159
- _context34.next = 44;
21178
+ _context34.next = 50;
21160
21179
  return replaceTrackAndUpdate(originalVideoTrack, filteredVideoTrack);
21161
21180
 
21162
- case 44:
21163
- _context34.next = 51;
21181
+ case 50:
21182
+ _context34.next = 57;
21164
21183
  break;
21165
21184
 
21166
- case 46:
21167
- _context34.prev = 46;
21185
+ case 52:
21186
+ _context34.prev = 52;
21168
21187
  _context34.t1 = _context34["catch"](1);
21169
21188
  logging.error(`Error applying video filter: ${_context34.t1}`);
21170
21189
  logAnalyticsEvent('applyVideoFilter', 'Failure', {
@@ -21172,20 +21191,20 @@ module.exports = function PublisherFactory(_ref) {
21172
21191
  });
21173
21192
  throw _context34.t1;
21174
21193
 
21175
- case 51:
21194
+ case 57:
21176
21195
  currentVideoFilter = videoFilter;
21177
21196
  logAnalyticsEvent('applyVideoFilter', 'Success', {
21178
21197
  videoFilter
21179
21198
  });
21180
21199
 
21181
- case 53:
21200
+ case 59:
21182
21201
  case "end":
21183
21202
  return _context34.stop();
21184
21203
  }
21185
- }, _callee34, null, [[1, 46], [18, 24]]);
21204
+ }, _callee34, null, [[1, 52], [23, 31]]);
21186
21205
  }));
21187
21206
 
21188
- return function (_x24) {
21207
+ return function (_x25) {
21189
21208
  return _ref41.apply(this, arguments);
21190
21209
  };
21191
21210
  }();
@@ -21220,9 +21239,8 @@ module.exports = function PublisherFactory(_ref) {
21220
21239
 
21221
21240
  this.getVideoFilter = () => {
21222
21241
  logAnalyticsEvent('getVideoFilter', 'Attempt');
21223
- const videoFilter = mediaProcessor.getVideoFilter();
21224
21242
  logAnalyticsEvent('getVideoFilter', 'Success');
21225
- return videoFilter;
21243
+ return currentVideoFilter || null;
21226
21244
  };
21227
21245
  /**
21228
21246
  * Sets a
@@ -21407,7 +21425,7 @@ module.exports = function PublisherFactory(_ref) {
21407
21425
  }, _callee35, null, [[28, 36]]);
21408
21426
  }));
21409
21427
 
21410
- return function (_x25) {
21428
+ return function (_x26) {
21411
21429
  return _ref42.apply(this, arguments);
21412
21430
  };
21413
21431
  }();
@@ -21564,7 +21582,7 @@ module.exports = function PublisherFactory(_ref) {
21564
21582
  }, _callee36, null, [[21, 29]]);
21565
21583
  }));
21566
21584
 
21567
- return function (_x26) {
21585
+ return function (_x27) {
21568
21586
  return _ref43.apply(this, arguments);
21569
21587
  };
21570
21588
  }();
@@ -21595,8 +21613,18 @@ module.exports = function PublisherFactory(_ref) {
21595
21613
  case 0:
21596
21614
  logAnalyticsEvent('clearVideoFilter', 'Attempt');
21597
21615
 
21598
- if (_this.getVideoFilter()) {
21599
- _context37.next = 6;
21616
+ if (!(!properties.publishVideo && !mediaProcessor.getVideoFilter())) {
21617
+ _context37.next = 5;
21618
+ break;
21619
+ }
21620
+
21621
+ currentVideoFilter = null;
21622
+ logAnalyticsEvent('clearVideoFilter', 'Success');
21623
+ return _context37.abrupt("return");
21624
+
21625
+ case 5:
21626
+ if (!(!mediaProcessor.getVideoFilter() && !currentVideoFilter)) {
21627
+ _context37.next = 10;
21600
21628
  break;
21601
21629
  }
21602
21630
 
@@ -21607,9 +21635,9 @@ module.exports = function PublisherFactory(_ref) {
21607
21635
  logging.debug(message);
21608
21636
  return _context37.abrupt("return");
21609
21637
 
21610
- case 6:
21638
+ case 10:
21611
21639
  if (MediaProcessor.isSupported()) {
21612
- _context37.next = 11;
21640
+ _context37.next = 15;
21613
21641
  break;
21614
21642
  }
21615
21643
 
@@ -21620,9 +21648,9 @@ module.exports = function PublisherFactory(_ref) {
21620
21648
  logging.warn(message);
21621
21649
  return _context37.abrupt("return");
21622
21650
 
21623
- case 11:
21651
+ case 15:
21624
21652
  if (webRTCStream) {
21625
- _context37.next = 16;
21653
+ _context37.next = 20;
21626
21654
  break;
21627
21655
  }
21628
21656
 
@@ -21633,64 +21661,62 @@ module.exports = function PublisherFactory(_ref) {
21633
21661
  logging.warn(message);
21634
21662
  return _context37.abrupt("return");
21635
21663
 
21636
- case 16:
21637
- if (!currentVideoFilter) {
21638
- _context37.next = 43;
21639
- break;
21640
- }
21641
-
21664
+ case 20:
21642
21665
  oldVideoFilter = currentVideoFilter;
21643
21666
  currentVideoFilter = null;
21644
21667
  _webRTCStream$getVide5 = webRTCStream.getVideoTracks(), filteredVideoTrack = _webRTCStream$getVide5[0];
21645
- _context37.prev = 20;
21646
- _context37.next = 23;
21668
+ _context37.prev = 23;
21669
+ _context37.next = 26;
21647
21670
  return getTrackFromDeviceId(currentDeviceId);
21648
21671
 
21649
- case 23:
21672
+ case 26:
21650
21673
  videoTrack = _context37.sent;
21651
- _context37.next = 30;
21674
+ _context37.next = 33;
21652
21675
  break;
21653
21676
 
21654
- case 26:
21655
- _context37.prev = 26;
21656
- _context37.t0 = _context37["catch"](20);
21677
+ case 29:
21678
+ _context37.prev = 29;
21679
+ _context37.t0 = _context37["catch"](23);
21657
21680
  logging.error(_context37.t0);
21658
21681
  return _context37.abrupt("return");
21659
21682
 
21660
- case 30:
21683
+ case 33:
21661
21684
  if (videoTrack) {
21662
- _context37.next = 33;
21685
+ _context37.next = 36;
21663
21686
  break;
21664
21687
  }
21665
21688
 
21666
21689
  logging.warn('Failed to clear filter because there is no video track.');
21667
21690
  return _context37.abrupt("return");
21668
21691
 
21669
- case 33:
21670
- _context37.prev = 33;
21671
- _context37.next = 36;
21692
+ case 36:
21693
+ _context37.prev = 36;
21694
+ _context37.next = 39;
21672
21695
  return replaceTrackAndUpdate(filteredVideoTrack, videoTrack);
21673
21696
 
21674
- case 36:
21675
- _context37.next = 38;
21697
+ case 39:
21698
+ _context37.next = 41;
21676
21699
  return destroyMediaProcessor();
21677
21700
 
21678
- case 38:
21679
- _context37.next = 43;
21701
+ case 41:
21702
+ _context37.next = 46;
21680
21703
  break;
21681
21704
 
21682
- case 40:
21683
- _context37.prev = 40;
21684
- _context37.t1 = _context37["catch"](33);
21705
+ case 43:
21706
+ _context37.prev = 43;
21707
+ _context37.t1 = _context37["catch"](36);
21685
21708
  // Restore the previous filter since this call has failed. This way, this function can be
21686
21709
  // called again if needed.
21687
21710
  currentVideoFilter = oldVideoFilter;
21688
21711
 
21689
- case 43:
21712
+ case 46:
21713
+ logAnalyticsEvent('clearVideoFilter', 'Success');
21714
+
21715
+ case 47:
21690
21716
  case "end":
21691
21717
  return _context37.stop();
21692
21718
  }
21693
- }, _callee37, null, [[20, 26], [33, 40]]);
21719
+ }, _callee37, null, [[23, 29], [36, 43]]);
21694
21720
  }));
21695
21721
  };
21696
21722
  /**
@@ -63271,7 +63297,14 @@ module.exports = function SessionFactory(deps) {
63271
63297
 
63272
63298
  const messagingUrl = prependProxyToUrlIfNeeded(this.sessionInfo.messagingURL, proxyUrl); // capabilities supported by default.
63273
63299
 
63274
- const capabilities = ['forceMute', 'adaptive']; // Add SPC capability if forced, otherwise we don't add it to force not to use it.
63300
+ const capabilities = ['forceMute']; // Add Adaptive Media Routing capability if enabled for the session.
63301
+
63302
+ const isAdaptiveEnabled = this.sessionInfo.isAdaptiveEnabled;
63303
+
63304
+ if (isAdaptiveEnabled) {
63305
+ capabilities.push('amr');
63306
+ } // Add SPC capability if forced, otherwise we don't add it to force not to use it.
63307
+
63275
63308
 
63276
63309
  if (_useSinglePeerConnection) {
63277
63310
  capabilities.push('spc');