@webex/plugin-meetings 3.0.0-beta.146 → 3.0.0-beta.147

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.
Files changed (56) hide show
  1. package/dist/breakouts/breakout.js +1 -1
  2. package/dist/breakouts/index.js +1 -1
  3. package/dist/common/errors/webex-errors.js +3 -2
  4. package/dist/common/errors/webex-errors.js.map +1 -1
  5. package/dist/config.js +1 -7
  6. package/dist/config.js.map +1 -1
  7. package/dist/constants.js +7 -15
  8. package/dist/constants.js.map +1 -1
  9. package/dist/index.js +6 -0
  10. package/dist/index.js.map +1 -1
  11. package/dist/media/index.js +5 -56
  12. package/dist/media/index.js.map +1 -1
  13. package/dist/media/properties.js +15 -93
  14. package/dist/media/properties.js.map +1 -1
  15. package/dist/meeting/index.js +1092 -1865
  16. package/dist/meeting/index.js.map +1 -1
  17. package/dist/meeting/muteState.js +88 -184
  18. package/dist/meeting/muteState.js.map +1 -1
  19. package/dist/meeting/util.js +1 -23
  20. package/dist/meeting/util.js.map +1 -1
  21. package/dist/meetings/index.js +1 -2
  22. package/dist/meetings/index.js.map +1 -1
  23. package/dist/reconnection-manager/index.js +153 -134
  24. package/dist/reconnection-manager/index.js.map +1 -1
  25. package/dist/roap/index.js +8 -7
  26. package/dist/roap/index.js.map +1 -1
  27. package/dist/types/common/errors/webex-errors.d.ts +1 -1
  28. package/dist/types/config.d.ts +0 -6
  29. package/dist/types/constants.d.ts +1 -18
  30. package/dist/types/index.d.ts +1 -1
  31. package/dist/types/media/properties.d.ts +16 -38
  32. package/dist/types/meeting/index.d.ts +90 -353
  33. package/dist/types/meeting/muteState.d.ts +36 -38
  34. package/dist/types/meeting/util.d.ts +2 -4
  35. package/package.json +19 -19
  36. package/src/common/errors/webex-errors.ts +6 -2
  37. package/src/config.ts +0 -6
  38. package/src/constants.ts +1 -14
  39. package/src/index.ts +1 -0
  40. package/src/media/index.ts +10 -53
  41. package/src/media/properties.ts +32 -92
  42. package/src/meeting/index.ts +530 -1566
  43. package/src/meeting/muteState.ts +87 -178
  44. package/src/meeting/util.ts +3 -24
  45. package/src/meetings/index.ts +0 -1
  46. package/src/reconnection-manager/index.ts +4 -9
  47. package/src/roap/index.ts +13 -14
  48. package/test/integration/spec/converged-space-meetings.js +59 -3
  49. package/test/integration/spec/journey.js +330 -256
  50. package/test/integration/spec/space-meeting.js +75 -3
  51. package/test/unit/spec/meeting/index.js +767 -1344
  52. package/test/unit/spec/meeting/muteState.js +238 -394
  53. package/test/unit/spec/meeting/utils.js +2 -9
  54. package/test/unit/spec/multistream/receiveSlot.ts +1 -1
  55. package/test/unit/spec/roap/index.ts +2 -2
  56. package/test/utils/integrationTestUtils.js +5 -23
@@ -17,12 +17,10 @@ _Object$defineProperty(exports, "__esModule", {
17
17
  });
18
18
  exports.default = exports.MEDIA_UPDATE_TYPE = void 0;
19
19
  var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
20
- var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
21
- var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
22
20
  var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
21
+ var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
22
+ var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
23
23
  var _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/values"));
24
- var _assign = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/assign"));
25
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
26
24
  var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/typeof"));
27
25
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
28
26
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
@@ -34,7 +32,6 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/he
34
32
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
35
33
  var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
36
34
  var _defer2 = _interopRequireDefault(require("lodash/defer"));
37
- var _isString2 = _interopRequireDefault(require("lodash/isString"));
38
35
  var _pick2 = _interopRequireDefault(require("lodash/pick"));
39
36
  var _isEqual2 = _interopRequireDefault(require("lodash/isEqual"));
40
37
  var _cloneDeep2 = _interopRequireDefault(require("lodash/cloneDeep"));
@@ -71,7 +68,6 @@ var _reconnectionInProgress = _interopRequireDefault(require("../common/errors/r
71
68
  var _constants = require("../constants");
72
69
  var _constants2 = _interopRequireDefault(require("../metrics/constants"));
73
70
  var _parameter = _interopRequireDefault(require("../common/errors/parameter"));
74
- var _media2 = _interopRequireDefault(require("../common/errors/media"));
75
71
  var _meetingInfoV = require("../meeting-info/meeting-info-v2");
76
72
  var _browserDetection = _interopRequireDefault(require("../common/browser-detection"));
77
73
  var _receiveSlotManager = require("../multistream/receiveSlotManager");
@@ -107,11 +103,9 @@ var logRequest = function logRequest(request, _ref) {
107
103
  });
108
104
  };
109
105
  var MEDIA_UPDATE_TYPE = {
110
- ALL: 'ALL',
111
- AUDIO: 'AUDIO',
112
- VIDEO: 'VIDEO',
113
- SHARE: 'SHARE',
114
- LAMBDA: 'LAMBDA'
106
+ TRANSCODED_MEDIA_CONNECTION: 'TRANSCODED_MEDIA_CONNECTION',
107
+ LAMBDA: 'LAMBDA',
108
+ UPDATE_MEDIA: 'UPDATE_MEDIA'
115
109
  };
116
110
 
117
111
  /**
@@ -126,16 +120,6 @@ var MEDIA_UPDATE_TYPE = {
126
120
  * @property {boolean} isSharing
127
121
  */
128
122
 
129
- /**
130
- * AudioVideo
131
- * @typedef {Object} AudioVideo
132
- * @property {Object} audio
133
- * @property {String} audio.deviceId
134
- * @property {Object} video
135
- * @property {String} video.deviceId
136
- * @property {String} video.localVideoQuality // [240p, 360p, 480p, 720p, 1080p]
137
- */
138
-
139
123
  /**
140
124
  * SharePreferences
141
125
  * @typedef {Object} SharePreferences
@@ -150,21 +134,12 @@ var MEDIA_UPDATE_TYPE = {
150
134
  * @property {String} [pin]
151
135
  * @property {Boolean} [moderator]
152
136
  * @property {String|Object} [meetingQuality]
153
- * @property {String} [meetingQuality.local]
154
137
  * @property {String} [meetingQuality.remote]
155
138
  * @property {Boolean} [rejoin]
156
139
  * @property {Boolean} [enableMultistream]
157
140
  * @property {String} [correlationId]
158
141
  */
159
142
 
160
- /**
161
- * SendOptions
162
- * @typedef {Object} SendOptions
163
- * @property {Boolean} sendAudio
164
- * @property {Boolean} sendVideo
165
- * @property {Boolean} sendShare
166
- */
167
-
168
143
  /**
169
144
  * Recording
170
145
  * @typedef {Object} Recording
@@ -515,6 +490,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
515
490
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", void 0);
516
491
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "localAudioTrackMuteStateHandler", void 0);
517
492
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "localVideoTrackMuteStateHandler", void 0);
493
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "underlyingLocalTrackChangeHandler", void 0);
518
494
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "roles", void 0);
519
495
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "environment", void 0);
520
496
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "namespace", _constants.MEETINGS);
@@ -544,98 +520,6 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
544
520
  break;
545
521
  }
546
522
  });
547
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getMediaStreams", function (mediaDirection) {
548
- var audioVideo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _constants.VIDEO_RESOLUTIONS[_this.mediaProperties.localQualityLevel];
549
- var sharePreferences = arguments.length > 2 ? arguments[2] : undefined;
550
- if (mediaDirection && (mediaDirection.sendAudio || mediaDirection.sendVideo || mediaDirection.sendShare)) {
551
- if (mediaDirection && mediaDirection.sendAudio && mediaDirection.sendVideo && mediaDirection.sendShare && isBrowser('safari')) {
552
- _loggerProxy.default.logger.warn('Meeting:index#getMediaStreams --> Setting `sendShare` to FALSE, due to complications with Safari');
553
- mediaDirection.sendShare = false;
554
- _loggerProxy.default.logger.warn('Meeting:index#getMediaStreams --> Enabling `sendShare` along with `sendAudio` & `sendVideo`, on Safari, causes a failure while setting up a screen share at the same time as the camera+mic stream');
555
- _loggerProxy.default.logger.warn('Meeting:index#getMediaStreams --> Please use `meeting.shareScreen()` to manually start the screen share after successfully joining the meeting');
556
- }
557
- if (audioVideo && (0, _isString2.default)(audioVideo)) {
558
- if ((0, _keys.default)(_constants.VIDEO_RESOLUTIONS).includes(audioVideo)) {
559
- _this.mediaProperties.setLocalQualityLevel(audioVideo);
560
- audioVideo = {
561
- video: _constants.VIDEO_RESOLUTIONS[audioVideo].video
562
- };
563
- } else {
564
- throw new _parameter.default("".concat(audioVideo, " not supported. Either pass level from pre-defined resolutions or pass complete audioVideo object"));
565
- }
566
- }
567
- if (!audioVideo.video) {
568
- audioVideo = _objectSpread(_objectSpread({}, audioVideo), {}, {
569
- video: _objectSpread(_objectSpread({}, audioVideo.video), _constants.VIDEO_RESOLUTIONS[_this.mediaProperties.localQualityLevel].video)
570
- });
571
- }
572
- // extract deviceId if exists otherwise default to null.
573
- var _ref2 = audioVideo && audioVideo.video || {
574
- deviceId: null
575
- },
576
- preferredVideoDevice = _ref2.deviceId;
577
- var lastVideoDeviceId = _this.mediaProperties.getVideoDeviceId();
578
- if (preferredVideoDevice) {
579
- // Store new preferred video input device
580
- _this.mediaProperties.setVideoDeviceId(preferredVideoDevice);
581
- } else if (lastVideoDeviceId) {
582
- // no new video preference specified so use last stored value,
583
- // works with empty object {} or media constraint.
584
- // eslint-disable-next-line no-param-reassign
585
- audioVideo = _objectSpread(_objectSpread({}, audioVideo), {}, {
586
- video: _objectSpread(_objectSpread({}, audioVideo.video), {}, {
587
- deviceId: lastVideoDeviceId
588
- })
589
- });
590
- }
591
- return _media.default.getSupportedDevice({
592
- sendAudio: mediaDirection.sendAudio,
593
- sendVideo: mediaDirection.sendVideo
594
- }).catch(function (error) {
595
- return _promise.default.reject(new _media2.default('Given constraints do not match permission set for either camera or microphone', error));
596
- }).then(function (devicePermissions) {
597
- return _media.default.getUserMedia(_objectSpread(_objectSpread({}, mediaDirection), {}, {
598
- sendAudio: devicePermissions.sendAudio,
599
- sendVideo: devicePermissions.sendVideo,
600
- isSharing: _this.shareStatus === _constants.SHARE_STATUS.LOCAL_SHARE_ACTIVE
601
- }), audioVideo, sharePreferences,
602
- // @ts-ignore - config coming from registerPlugin
603
- _this.config).catch(function (error) {
604
- var _this$locusUrl;
605
- // Whenever there is a failure when trying to access a user's device
606
- // report it as an Behavioral metric
607
- // This gives visibility into common errors and can help
608
- // with further troubleshooting
609
- var metricName = _constants2.default.GET_USER_MEDIA_FAILURE;
610
- var data = {
611
- correlation_id: _this.correlationId,
612
- locus_id: (_this$locusUrl = _this.locusUrl) === null || _this$locusUrl === void 0 ? void 0 : _this$locusUrl.split('/').pop(),
613
- reason: error.message,
614
- stack: error.stack
615
- };
616
- var metadata = {
617
- type: error.name
618
- };
619
- _metrics.default.sendBehavioralMetric(metricName, data, metadata);
620
- throw new _media2.default('Unable to retrieve media streams', error);
621
- });
622
- });
623
- }
624
- return _promise.default.reject(new _media2.default('At least one of the mediaDirection value should be true'));
625
- });
626
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getSupportedDevices", function (_ref3) {
627
- var _ref3$sendAudio = _ref3.sendAudio,
628
- sendAudio = _ref3$sendAudio === void 0 ? true : _ref3$sendAudio,
629
- _ref3$sendVideo = _ref3.sendVideo,
630
- sendVideo = _ref3$sendVideo === void 0 ? true : _ref3$sendVideo;
631
- return _media.default.getSupportedDevice({
632
- sendAudio: sendAudio,
633
- sendVideo: sendVideo
634
- });
635
- });
636
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getDevices", function () {
637
- return _media.default.getDevices();
638
- });
639
523
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleRoapFailure", function (error) {
640
524
  // eslint-disable-next-line @typescript-eslint/no-shadow
641
525
  var sendBehavioralMetric = function sendBehavioralMetric(metricName, error, correlationId) {
@@ -990,30 +874,27 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
990
874
  mediaUpdateType = _this$queuedMediaUpda.mediaUpdateType,
991
875
  _options2 = _this$queuedMediaUpda.options;
992
876
  _loggerProxy.default.logger.log("Meeting:index#processNextQueuedMediaUpdate --> performing delayed media update type=".concat(mediaUpdateType));
877
+ var mediaUpdate = _promise.default.resolve();
993
878
  switch (mediaUpdateType) {
994
- case MEDIA_UPDATE_TYPE.ALL:
995
- _this.updateMedia(_options2).then(pendingPromiseResolve, pendingPromiseReject);
996
- break;
997
- case MEDIA_UPDATE_TYPE.AUDIO:
998
- _this.updateAudio(_options2).then(pendingPromiseResolve, pendingPromiseReject);
999
- break;
1000
- case MEDIA_UPDATE_TYPE.VIDEO:
1001
- _this.updateVideo(_options2).then(pendingPromiseResolve, pendingPromiseReject);
1002
- break;
1003
- case MEDIA_UPDATE_TYPE.SHARE:
1004
- _this.updateShare(_options2).then(pendingPromiseResolve, pendingPromiseReject);
879
+ case MEDIA_UPDATE_TYPE.TRANSCODED_MEDIA_CONNECTION:
880
+ mediaUpdate = _this.updateTranscodedMediaConnection();
1005
881
  break;
1006
882
  case MEDIA_UPDATE_TYPE.LAMBDA:
1007
- _options2.lambda().then(pendingPromiseResolve, pendingPromiseReject);
883
+ mediaUpdate = _options2.lambda();
884
+ break;
885
+ case MEDIA_UPDATE_TYPE.UPDATE_MEDIA:
886
+ mediaUpdate = _this.updateMedia(_options2);
1008
887
  break;
1009
888
  default:
1010
889
  _loggerProxy.default.logger.error("Peer-connection-manager:index#processNextQueuedMediaUpdate --> unsupported media update type ".concat(mediaUpdateType, " found in the queue"));
1011
890
  break;
1012
891
  }
892
+ mediaUpdate.then(pendingPromiseResolve, pendingPromiseReject).then(function () {
893
+ return _this.processNextQueuedMediaUpdate();
894
+ });
1013
895
  }
1014
896
  });
1015
897
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleShareTrackEnded", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
1016
- var _this$mediaProperties;
1017
898
  return _regenerator.default.wrap(function _callee$(_context) {
1018
899
  while (1) switch (_context.prev = _context.next) {
1019
900
  case 0:
@@ -1024,57 +905,31 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
1024
905
  _this.leave({
1025
906
  reason: _constants.MEETING_REMOVED_REASON.USER_ENDED_SHARE_STREAMS
1026
907
  });
1027
- _context.next = 22;
908
+ _context.next = 12;
1028
909
  break;
1029
910
  case 4:
1030
- if (!_this.isMultistream) {
1031
- _context.next = 21;
1032
- break;
1033
- }
1034
- _context.prev = 5;
1035
- if (!_this.mediaProperties.mediaDirection.sendShare) {
1036
- _context.next = 9;
1037
- break;
1038
- }
1039
- _context.next = 9;
1040
- return _this.releaseScreenShareFloor();
1041
- case 9:
1042
- _context.next = 14;
911
+ _context.prev = 4;
912
+ _context.next = 7;
913
+ return _this.unpublishTracks([_this.mediaProperties.shareTrack]);
914
+ case 7:
915
+ _context.next = 12;
1043
916
  break;
1044
- case 11:
1045
- _context.prev = 11;
1046
- _context.t0 = _context["catch"](5);
917
+ case 9:
918
+ _context.prev = 9;
919
+ _context.t0 = _context["catch"](4);
1047
920
  _loggerProxy.default.logger.log('Meeting:index#handleShareTrackEnded --> Error stopping share: ', _context.t0);
1048
- case 14:
1049
- _context.prev = 14;
1050
- // todo: once SPARK-399695 is done, we will be able to just call this.setLocalShareTrack(null); here instead of the next 2 lines:
1051
- (_this$mediaProperties = _this.mediaProperties.shareTrack) === null || _this$mediaProperties === void 0 ? void 0 : _this$mediaProperties.off(_mediaHelpers.LocalTrackEvents.Ended, _this.handleShareTrackEnded);
1052
- _this.mediaProperties.setLocalShareTrack(null);
1053
- _this.mediaProperties.mediaDirection.sendShare = false;
1054
- return _context.finish(14);
1055
- case 19:
1056
- _context.next = 22;
1057
- break;
1058
- case 21:
1059
- // Skip checking for a stable peerConnection
1060
- // to allow immediately stopping screenshare
1061
- _this.stopShare({
1062
- skipSignalingCheck: true
1063
- }).catch(function (error) {
1064
- _loggerProxy.default.logger.log('Meeting:index#handleShareTrackEnded --> Error stopping share: ', error);
1065
- });
1066
- case 22:
921
+ case 12:
1067
922
  _triggerProxy.default.trigger((0, _assertThisInitialized2.default)(_this), {
1068
923
  file: 'meeting/index',
1069
924
  function: 'handleShareTrackEnded'
1070
925
  }, _constants.EVENT_TRIGGERS.MEETING_STOPPED_SHARING_LOCAL, {
1071
- type: _constants.EVENT_TYPES.LOCAL_SHARE
926
+ reason: _constants.SHARE_STOPPED_REASON.TRACK_ENDED
1072
927
  });
1073
- case 23:
928
+ case 13:
1074
929
  case "end":
1075
930
  return _context.stop();
1076
931
  }
1077
- }, _callee, null, [[5, 11, 14, 19]]);
932
+ }, _callee, null, [[4, 9]]);
1078
933
  })));
1079
934
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "clearMeetingData", function () {
1080
935
  _this.audio = null;
@@ -1221,8 +1076,8 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
1221
1076
  * helper class for managing receive slots (for multistream media connections)
1222
1077
  */
1223
1078
  _this.receiveSlotManager = new _receiveSlotManager.ReceiveSlotManager(function (mediaType) {
1224
- var _this$mediaProperties2;
1225
- if (!((_this$mediaProperties2 = _this.mediaProperties) !== null && _this$mediaProperties2 !== void 0 && _this$mediaProperties2.webrtcMediaConnection)) {
1079
+ var _this$mediaProperties;
1080
+ if (!((_this$mediaProperties = _this.mediaProperties) !== null && _this$mediaProperties !== void 0 && _this$mediaProperties.webrtcMediaConnection)) {
1226
1081
  return _promise.default.reject(new Error('Webrtc media connection is missing'));
1227
1082
  }
1228
1083
  return _this.mediaProperties.webrtcMediaConnection.createReceiveSlot(mediaType);
@@ -1327,7 +1182,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
1327
1182
  */
1328
1183
  _this.reconnectionManager = new _reconnectionManager.default((0, _assertThisInitialized2.default)(_this));
1329
1184
  /**
1330
- * created later
1185
+ * created with media connection
1331
1186
  * @instance
1332
1187
  * @type {MuteState}
1333
1188
  * @private
@@ -1335,7 +1190,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
1335
1190
  */
1336
1191
  _this.audio = null;
1337
1192
  /**
1338
- * created later
1193
+ * created with media connection
1339
1194
  * @instance
1340
1195
  * @type {MuteState}
1341
1196
  * @private
@@ -1744,6 +1599,16 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
1744
1599
  _this.localVideoTrackMuteStateHandler = function (event) {
1745
1600
  _this.video.handleLocalTrackMuteStateChange((0, _assertThisInitialized2.default)(_this), event.trackState.muted);
1746
1601
  };
1602
+
1603
+ // The handling of underlying track changes should be done inside
1604
+ // @webex/internal-media-core, but for now we have to do it here, because
1605
+ // RoapMediaConnection has to use raw MediaStreamTracks in its API until
1606
+ // the Calling SDK also moves to using webrtc-core tracks
1607
+ _this.underlyingLocalTrackChangeHandler = function () {
1608
+ if (!_this.isMultistream) {
1609
+ _this.updateTranscodedMediaConnection();
1610
+ }
1611
+ };
1747
1612
  return _this;
1748
1613
  }
1749
1614
 
@@ -1759,12 +1624,12 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
1759
1624
  (0, _createClass2.default)(Meeting, [{
1760
1625
  key: "fetchMeetingInfo",
1761
1626
  value: function () {
1762
- var _fetchMeetingInfo = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_ref5) {
1763
- var _ref5$password, password, _ref5$captchaCode, captchaCode, _ref5$extraParams, extraParams, captchaInfo, info, _err$body, _err$body2;
1627
+ var _fetchMeetingInfo = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_ref3) {
1628
+ var _ref3$password, password, _ref3$captchaCode, captchaCode, _ref3$extraParams, extraParams, captchaInfo, info, _err$body, _err$body2;
1764
1629
  return _regenerator.default.wrap(function _callee2$(_context2) {
1765
1630
  while (1) switch (_context2.prev = _context2.next) {
1766
1631
  case 0:
1767
- _ref5$password = _ref5.password, password = _ref5$password === void 0 ? null : _ref5$password, _ref5$captchaCode = _ref5.captchaCode, captchaCode = _ref5$captchaCode === void 0 ? null : _ref5$captchaCode, _ref5$extraParams = _ref5.extraParams, extraParams = _ref5$extraParams === void 0 ? {} : _ref5$extraParams;
1632
+ _ref3$password = _ref3.password, password = _ref3$password === void 0 ? null : _ref3$password, _ref3$captchaCode = _ref3.captchaCode, captchaCode = _ref3$captchaCode === void 0 ? null : _ref3$captchaCode, _ref3$extraParams = _ref3.extraParams, extraParams = _ref3$extraParams === void 0 ? {} : _ref3$extraParams;
1768
1633
  // when fetch meeting info is called directly by the client, we want to clear out the random timer for sdk to do it
1769
1634
  if (this.fetchMeetingInfoTimeoutId) {
1770
1635
  clearTimeout(this.fetchMeetingInfoTimeoutId);
@@ -2335,11 +2200,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2335
2200
  _this8.pstnUpdate(payload);
2336
2201
 
2337
2202
  // If user moved to a JOINED state and there is a pending floor grant trigger it
2338
- if (_this8.floorGrantPending && payload.newSelf.state === _constants.MEETING_STATE.STATES.JOINED) {
2339
- _this8.requestScreenShareFloor().then(function () {
2340
- _this8.floorGrantPending = false;
2341
- });
2342
- }
2203
+ _this8.requestScreenShareFloorIfPending();
2343
2204
  });
2344
2205
  }
2345
2206
 
@@ -2453,10 +2314,10 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2453
2314
  key: "setupLocusControlsListener",
2454
2315
  value: function setupLocusControlsListener() {
2455
2316
  var _this12 = this;
2456
- this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_RECORDING_UPDATED, function (_ref6) {
2457
- var state = _ref6.state,
2458
- modifiedBy = _ref6.modifiedBy,
2459
- lastModified = _ref6.lastModified;
2317
+ this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_RECORDING_UPDATED, function (_ref4) {
2318
+ var state = _ref4.state,
2319
+ modifiedBy = _ref4.modifiedBy,
2320
+ lastModified = _ref4.lastModified;
2460
2321
  var event;
2461
2322
  switch (state) {
2462
2323
  case _constants.RECORDING_STATE.RECORDING:
@@ -2487,8 +2348,8 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2487
2348
  function: 'setupLocusControlsListener'
2488
2349
  }, event, _this12.recording);
2489
2350
  });
2490
- this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_MEETING_CONTAINER_UPDATED, function (_ref7) {
2491
- var meetingContainerUrl = _ref7.meetingContainerUrl;
2351
+ this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_MEETING_CONTAINER_UPDATED, function (_ref5) {
2352
+ var meetingContainerUrl = _ref5.meetingContainerUrl;
2492
2353
  _triggerProxy.default.trigger(_this12, {
2493
2354
  file: 'meeting/index',
2494
2355
  function: 'setupLocusControlsListener'
@@ -2496,9 +2357,9 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2496
2357
  meetingContainerUrl: meetingContainerUrl
2497
2358
  });
2498
2359
  });
2499
- this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_MEETING_TRANSCRIBE_UPDATED, function (_ref8) {
2500
- var caption = _ref8.caption,
2501
- transcribing = _ref8.transcribing;
2360
+ this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_MEETING_TRANSCRIBE_UPDATED, function (_ref6) {
2361
+ var caption = _ref6.caption,
2362
+ transcribing = _ref6.transcribing;
2502
2363
  // @ts-ignore - config coming from registerPlugin
2503
2364
  if (transcribing && _this12.transcription && _this12.config.receiveTranscription) {
2504
2365
  _this12.receiveTranscription();
@@ -2512,16 +2373,16 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2512
2373
  });
2513
2374
  }
2514
2375
  });
2515
- this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_MEETING_BREAKOUT_UPDATED, function (_ref9) {
2516
- var breakout = _ref9.breakout;
2376
+ this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_MEETING_BREAKOUT_UPDATED, function (_ref7) {
2377
+ var breakout = _ref7.breakout;
2517
2378
  _this12.breakouts.updateBreakout(breakout);
2518
2379
  _triggerProxy.default.trigger(_this12, {
2519
2380
  file: 'meeting/index',
2520
2381
  function: 'setupLocusControlsListener'
2521
2382
  }, _constants.EVENT_TRIGGERS.MEETING_BREAKOUTS_UPDATE);
2522
2383
  });
2523
- this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_JOIN_BREAKOUT_FROM_MAIN, function (_ref10) {
2524
- var mainLocusUrl = _ref10.mainLocusUrl;
2384
+ this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_JOIN_BREAKOUT_FROM_MAIN, function (_ref8) {
2385
+ var mainLocusUrl = _ref8.mainLocusUrl;
2525
2386
  _this12.meetingRequest.getLocusStatusByUrl(mainLocusUrl).catch(function (error) {
2526
2387
  // clear main session cache when attendee join into breakout and forbidden to get locus from main locus url,
2527
2388
  // which means main session is not active for the attendee
@@ -2530,8 +2391,8 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2530
2391
  }
2531
2392
  });
2532
2393
  });
2533
- this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_ENTRY_EXIT_TONE_UPDATED, function (_ref11) {
2534
- var entryExitTone = _ref11.entryExitTone;
2394
+ this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_ENTRY_EXIT_TONE_UPDATED, function (_ref9) {
2395
+ var entryExitTone = _ref9.entryExitTone;
2535
2396
  _triggerProxy.default.trigger(_this12, {
2536
2397
  file: 'meeting/index',
2537
2398
  function: 'setupLocusControlsListener'
@@ -2539,8 +2400,8 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2539
2400
  entryExitTone: entryExitTone
2540
2401
  });
2541
2402
  });
2542
- this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_MUTE_ON_ENTRY_CHANGED, function (_ref12) {
2543
- var state = _ref12.state;
2403
+ this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_MUTE_ON_ENTRY_CHANGED, function (_ref10) {
2404
+ var state = _ref10.state;
2544
2405
  _triggerProxy.default.trigger(_this12, {
2545
2406
  file: 'meeting/index',
2546
2407
  function: 'setupLocusControlsListener'
@@ -2548,8 +2409,8 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2548
2409
  state: state
2549
2410
  });
2550
2411
  });
2551
- this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_SHARE_CONTROL_CHANGED, function (_ref13) {
2552
- var state = _ref13.state;
2412
+ this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_SHARE_CONTROL_CHANGED, function (_ref11) {
2413
+ var state = _ref11.state;
2553
2414
  _triggerProxy.default.trigger(_this12, {
2554
2415
  file: 'meeting/index',
2555
2416
  function: 'setupLocusControlsListener'
@@ -2557,8 +2418,8 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2557
2418
  state: state
2558
2419
  });
2559
2420
  });
2560
- this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_DISALLOW_UNMUTE_CHANGED, function (_ref14) {
2561
- var state = _ref14.state;
2421
+ this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_DISALLOW_UNMUTE_CHANGED, function (_ref12) {
2422
+ var state = _ref12.state;
2562
2423
  _triggerProxy.default.trigger(_this12, {
2563
2424
  file: 'meeting/index',
2564
2425
  function: 'setupLocusControlsListener'
@@ -2566,8 +2427,8 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2566
2427
  state: state
2567
2428
  });
2568
2429
  });
2569
- this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_REACTIONS_CHANGED, function (_ref15) {
2570
- var state = _ref15.state;
2430
+ this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_REACTIONS_CHANGED, function (_ref13) {
2431
+ var state = _ref13.state;
2571
2432
  _triggerProxy.default.trigger(_this12, {
2572
2433
  file: 'meeting/index',
2573
2434
  function: 'setupLocusControlsListener'
@@ -2575,8 +2436,8 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2575
2436
  state: state
2576
2437
  });
2577
2438
  });
2578
- this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_VIEW_THE_PARTICIPANTS_LIST_CHANGED, function (_ref16) {
2579
- var state = _ref16.state;
2439
+ this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_VIEW_THE_PARTICIPANTS_LIST_CHANGED, function (_ref14) {
2440
+ var state = _ref14.state;
2580
2441
  _triggerProxy.default.trigger(_this12, {
2581
2442
  file: 'meeting/index',
2582
2443
  function: 'setupLocusControlsListener'
@@ -2584,8 +2445,8 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2584
2445
  state: state
2585
2446
  });
2586
2447
  });
2587
- this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_RAISE_HAND_CHANGED, function (_ref17) {
2588
- var state = _ref17.state;
2448
+ this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_RAISE_HAND_CHANGED, function (_ref15) {
2449
+ var state = _ref15.state;
2589
2450
  _triggerProxy.default.trigger(_this12, {
2590
2451
  file: 'meeting/index',
2591
2452
  function: 'setupLocusControlsListener'
@@ -2593,8 +2454,8 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2593
2454
  state: state
2594
2455
  });
2595
2456
  });
2596
- this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_VIDEO_CHANGED, function (_ref18) {
2597
- var state = _ref18.state;
2457
+ this.locusInfo.on(_constants.LOCUSINFO.EVENTS.CONTROLS_VIDEO_CHANGED, function (_ref16) {
2458
+ var state = _ref16.state;
2598
2459
  _triggerProxy.default.trigger(_this12, {
2599
2460
  file: 'meeting/index',
2600
2461
  function: 'setupLocusControlsListener'
@@ -2618,9 +2479,9 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2618
2479
  var _this13 = this;
2619
2480
  // Will get triggered on local and remote share
2620
2481
  this.locusInfo.on(_constants.EVENTS.LOCUS_INFO_UPDATE_MEDIA_SHARES, /*#__PURE__*/function () {
2621
- var _ref19 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(payload) {
2482
+ var _ref17 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(payload) {
2622
2483
  var _payload$previous, _payload$previous2;
2623
- var _payload$current, contentShare, whiteboardShare, previousContentShare, previousWhiteboardShare, newShareStatus, _this13$mediaProperti, localShareTrack, oldShareStatus, sendStartedSharingRemote, _this13$mediaProperti2;
2484
+ var _payload$current, contentShare, whiteboardShare, previousContentShare, previousWhiteboardShare, newShareStatus, oldShareStatus, sendStartedSharingRemote, _this13$mediaProperti;
2624
2485
  return _regenerator.default.wrap(function _callee3$(_context3) {
2625
2486
  while (1) switch (_context3.prev = _context3.next) {
2626
2487
  case 0:
@@ -2640,58 +2501,19 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2640
2501
  return _context3.abrupt("return");
2641
2502
  case 6:
2642
2503
  newShareStatus = _this13.shareStatus; // REMOTE - check if remote started sharing
2643
- if (!(_this13.selfId !== contentShare.beneficiaryId && contentShare.disposition === _constants.FLOOR_ACTION.GRANTED)) {
2644
- _context3.next = 11;
2645
- break;
2646
- }
2647
- // CONTENT - sharing content remote
2648
- newShareStatus = _constants.SHARE_STATUS.REMOTE_SHARE_ACTIVE;
2649
- _context3.next = 33;
2650
- break;
2651
- case 11:
2652
- if (!(_this13.selfId === contentShare.beneficiaryId && contentShare.disposition === _constants.FLOOR_ACTION.GRANTED)) {
2653
- _context3.next = 32;
2654
- break;
2655
- }
2656
- // @ts-ignore originalTrack is private - this will be fixed when SPARK-399695 is done
2657
- localShareTrack = (_this13$mediaProperti = _this13.mediaProperties.shareTrack) === null || _this13$mediaProperti === void 0 ? void 0 : _this13$mediaProperti.originalTrack; // todo: remove this block of code and instead make sure we have LocalTrackEvents.Ended listener always registered (SPARK-399695)
2658
- if (!((localShareTrack === null || localShareTrack === void 0 ? void 0 : localShareTrack.readyState) === 'ended')) {
2659
- _context3.next = 29;
2660
- break;
2504
+ if (_this13.selfId !== contentShare.beneficiaryId && contentShare.disposition === _constants.FLOOR_ACTION.GRANTED) {
2505
+ // CONTENT - sharing content remote
2506
+ newShareStatus = _constants.SHARE_STATUS.REMOTE_SHARE_ACTIVE;
2661
2507
  }
2662
- _context3.prev = 14;
2663
- if (!_this13.isMultistream) {
2664
- _context3.next = 20;
2665
- break;
2508
+ // LOCAL - check if we started sharing content
2509
+ else if (_this13.selfId === contentShare.beneficiaryId && contentShare.disposition === _constants.FLOOR_ACTION.GRANTED) {
2510
+ // CONTENT - sharing content local
2511
+ newShareStatus = _constants.SHARE_STATUS.LOCAL_SHARE_ACTIVE;
2666
2512
  }
2667
- _context3.next = 18;
2668
- return _this13.unpublishTracks([_this13.mediaProperties.shareTrack]);
2669
- case 18:
2670
- _context3.next = 22;
2671
- break;
2672
- case 20:
2673
- _context3.next = 22;
2674
- return _this13.stopShare({
2675
- skipSignalingCheck: true
2676
- });
2677
- case 22:
2678
- _context3.next = 27;
2679
- break;
2680
- case 24:
2681
- _context3.prev = 24;
2682
- _context3.t0 = _context3["catch"](14);
2683
- _loggerProxy.default.logger.log('Meeting:index#setUpLocusMediaSharesListener --> Error stopping share: ', _context3.t0);
2684
- case 27:
2685
- _context3.next = 30;
2686
- break;
2687
- case 29:
2688
- // CONTENT - sharing content local
2689
- newShareStatus = _constants.SHARE_STATUS.LOCAL_SHARE_ACTIVE;
2690
- case 30:
2691
- _context3.next = 33;
2692
- break;
2693
- case 32:
2694
- if (whiteboardShare.disposition === _constants.FLOOR_ACTION.GRANTED) {
2513
+ // If we did not hit the cases above, no one is sharng content, so we check if we are sharing whiteboard
2514
+ // There is no concept of local/remote share for whiteboard
2515
+ // It does not matter who requested to share the whiteboard, everyone gets the same view
2516
+ else if (whiteboardShare.disposition === _constants.FLOOR_ACTION.GRANTED) {
2695
2517
  // WHITEBOARD - sharing whiteboard
2696
2518
  newShareStatus = _constants.SHARE_STATUS.WHITEBOARD_SHARE_ACTIVE;
2697
2519
  }
@@ -2699,47 +2521,46 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2699
2521
  else if ((previousContentShare && contentShare.disposition === _constants.FLOOR_ACTION.RELEASED || contentShare.disposition === null) && (previousWhiteboardShare && whiteboardShare.disposition === _constants.FLOOR_ACTION.RELEASED || whiteboardShare.disposition === null)) {
2700
2522
  newShareStatus = _constants.SHARE_STATUS.NO_SHARE;
2701
2523
  }
2702
- case 33:
2703
2524
  if (!(newShareStatus !== _this13.shareStatus)) {
2704
- _context3.next = 75;
2525
+ _context3.next = 45;
2705
2526
  break;
2706
2527
  }
2707
2528
  oldShareStatus = _this13.shareStatus; // update our state before we send out any notifications
2708
2529
  _this13.shareStatus = newShareStatus;
2709
2530
 
2710
2531
  // send out "stop" notifications for the old state
2711
- _context3.t1 = oldShareStatus;
2712
- _context3.next = _context3.t1 === _constants.SHARE_STATUS.REMOTE_SHARE_ACTIVE ? 39 : _context3.t1 === _constants.SHARE_STATUS.LOCAL_SHARE_ACTIVE ? 41 : _context3.t1 === _constants.SHARE_STATUS.WHITEBOARD_SHARE_ACTIVE ? 43 : _context3.t1 === _constants.SHARE_STATUS.NO_SHARE ? 45 : 46;
2532
+ _context3.t0 = oldShareStatus;
2533
+ _context3.next = _context3.t0 === _constants.SHARE_STATUS.REMOTE_SHARE_ACTIVE ? 14 : _context3.t0 === _constants.SHARE_STATUS.LOCAL_SHARE_ACTIVE ? 16 : _context3.t0 === _constants.SHARE_STATUS.WHITEBOARD_SHARE_ACTIVE ? 18 : _context3.t0 === _constants.SHARE_STATUS.NO_SHARE ? 20 : 21;
2713
2534
  break;
2714
- case 39:
2535
+ case 14:
2715
2536
  _triggerProxy.default.trigger(_this13, {
2716
2537
  file: 'meetings/index',
2717
2538
  function: 'remoteShare'
2718
2539
  }, _constants.EVENT_TRIGGERS.MEETING_STOPPED_SHARING_REMOTE);
2719
- return _context3.abrupt("break", 47);
2720
- case 41:
2540
+ return _context3.abrupt("break", 22);
2541
+ case 16:
2721
2542
  _triggerProxy.default.trigger(_this13, {
2722
2543
  file: 'meeting/index',
2723
2544
  function: 'localShare'
2724
2545
  }, _constants.EVENT_TRIGGERS.MEETING_STOPPED_SHARING_LOCAL, {
2725
2546
  reason: _constants.SHARE_STOPPED_REASON.SELF_STOPPED
2726
2547
  });
2727
- return _context3.abrupt("break", 47);
2728
- case 43:
2548
+ return _context3.abrupt("break", 22);
2549
+ case 18:
2729
2550
  _triggerProxy.default.trigger(_this13, {
2730
2551
  file: 'meeting/index',
2731
2552
  function: 'stopWhiteboardShare'
2732
2553
  }, _constants.EVENT_TRIGGERS.MEETING_STOPPED_SHARING_WHITEBOARD);
2733
- return _context3.abrupt("break", 47);
2734
- case 45:
2735
- return _context3.abrupt("break", 47);
2736
- case 46:
2737
- return _context3.abrupt("break", 47);
2738
- case 47:
2739
- _context3.t2 = newShareStatus;
2740
- _context3.next = _context3.t2 === _constants.SHARE_STATUS.REMOTE_SHARE_ACTIVE ? 50 : _context3.t2 === _constants.SHARE_STATUS.LOCAL_SHARE_ACTIVE ? 64 : _context3.t2 === _constants.SHARE_STATUS.WHITEBOARD_SHARE_ACTIVE ? 67 : _context3.t2 === _constants.SHARE_STATUS.NO_SHARE ? 70 : 71;
2554
+ return _context3.abrupt("break", 22);
2555
+ case 20:
2556
+ return _context3.abrupt("break", 22);
2557
+ case 21:
2558
+ return _context3.abrupt("break", 22);
2559
+ case 22:
2560
+ _context3.t1 = newShareStatus;
2561
+ _context3.next = _context3.t1 === _constants.SHARE_STATUS.REMOTE_SHARE_ACTIVE ? 25 : _context3.t1 === _constants.SHARE_STATUS.LOCAL_SHARE_ACTIVE ? 34 : _context3.t1 === _constants.SHARE_STATUS.WHITEBOARD_SHARE_ACTIVE ? 37 : _context3.t1 === _constants.SHARE_STATUS.NO_SHARE ? 40 : 41;
2741
2562
  break;
2742
- case 50:
2563
+ case 25:
2743
2564
  sendStartedSharingRemote = function sendStartedSharingRemote() {
2744
2565
  _triggerProxy.default.trigger(_this13, {
2745
2566
  file: 'meetings/index',
@@ -2750,33 +2571,20 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2750
2571
  shareInstanceId: contentShare.shareInstanceId
2751
2572
  });
2752
2573
  };
2753
- _context3.prev = 51;
2754
- if (!((_this13$mediaProperti2 = _this13.mediaProperties.mediaDirection) !== null && _this13$mediaProperti2 !== void 0 && _this13$mediaProperti2.sendShare && oldShareStatus === _constants.SHARE_STATUS.LOCAL_SHARE_ACTIVE)) {
2755
- _context3.next = 60;
2574
+ _context3.prev = 26;
2575
+ if (!((_this13$mediaProperti = _this13.mediaProperties.mediaDirection) !== null && _this13$mediaProperti !== void 0 && _this13$mediaProperti.sendShare && oldShareStatus === _constants.SHARE_STATUS.LOCAL_SHARE_ACTIVE)) {
2576
+ _context3.next = 30;
2756
2577
  break;
2757
2578
  }
2758
- if (!_this13.isMultistream) {
2759
- _context3.next = 58;
2760
- break;
2761
- }
2762
- _context3.next = 56;
2579
+ _context3.next = 30;
2763
2580
  return _this13.unpublishTracks([_this13.mediaProperties.shareTrack]);
2764
- case 56:
2765
- _context3.next = 60;
2766
- break;
2767
- case 58:
2768
- _context3.next = 60;
2769
- return _this13.updateShare({
2770
- sendShare: false,
2771
- receiveShare: _this13.mediaProperties.mediaDirection.receiveShare
2772
- });
2773
- case 60:
2774
- _context3.prev = 60;
2581
+ case 30:
2582
+ _context3.prev = 30;
2775
2583
  sendStartedSharingRemote();
2776
- return _context3.finish(60);
2777
- case 63:
2778
- return _context3.abrupt("break", 72);
2779
- case 64:
2584
+ return _context3.finish(30);
2585
+ case 33:
2586
+ return _context3.abrupt("break", 42);
2587
+ case 34:
2780
2588
  _triggerProxy.default.trigger(_this13, {
2781
2589
  file: 'meeting/index',
2782
2590
  function: 'share'
@@ -2785,8 +2593,8 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2785
2593
  event: _config.eventType.LOCAL_SHARE_FLOOR_GRANTED,
2786
2594
  meeting: _this13
2787
2595
  });
2788
- return _context3.abrupt("break", 72);
2789
- case 67:
2596
+ return _context3.abrupt("break", 42);
2597
+ case 37:
2790
2598
  _triggerProxy.default.trigger(_this13, {
2791
2599
  file: 'meeting/index',
2792
2600
  function: 'startWhiteboardShare'
@@ -2798,16 +2606,16 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2798
2606
  event: _config.eventType.WHITEBOARD_SHARE_FLOOR_GRANTED,
2799
2607
  meeting: _this13
2800
2608
  });
2801
- return _context3.abrupt("break", 72);
2802
- case 70:
2803
- return _context3.abrupt("break", 72);
2804
- case 71:
2805
- return _context3.abrupt("break", 72);
2806
- case 72:
2609
+ return _context3.abrupt("break", 42);
2610
+ case 40:
2611
+ return _context3.abrupt("break", 42);
2612
+ case 41:
2613
+ return _context3.abrupt("break", 42);
2614
+ case 42:
2807
2615
  _this13.members.locusMediaSharesUpdate(payload);
2808
- _context3.next = 76;
2616
+ _context3.next = 46;
2809
2617
  break;
2810
- case 75:
2618
+ case 45:
2811
2619
  if (newShareStatus === _constants.SHARE_STATUS.REMOTE_SHARE_ACTIVE) {
2812
2620
  // if we got here, then some remote participant has stolen
2813
2621
  // the presentation from another remote participant
@@ -2836,14 +2644,14 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2836
2644
  });
2837
2645
  _this13.members.locusMediaSharesUpdate(payload);
2838
2646
  }
2839
- case 76:
2647
+ case 46:
2840
2648
  case "end":
2841
2649
  return _context3.stop();
2842
2650
  }
2843
- }, _callee3, null, [[14, 24], [51,, 60, 63]]);
2651
+ }, _callee3, null, [[26,, 30, 33]]);
2844
2652
  }));
2845
2653
  return function (_x2) {
2846
- return _ref19.apply(this, arguments);
2654
+ return _ref17.apply(this, arguments);
2847
2655
  };
2848
2656
  }());
2849
2657
  }
@@ -3286,46 +3094,63 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
3286
3094
  });
3287
3095
  }
3288
3096
  });
3289
- this.locusInfo.on(_constants.EVENTS.DESTROY_MEETING, function (payload) {
3290
- // if self state is NOT left
3291
-
3292
- // TODO: Handle sharing and wireless sharing when meeting end
3293
- if (_this20.wirelessShare) {
3294
- if (_this20.mediaProperties.shareTrack) {
3295
- _this20.setLocalShareTrack(null);
3296
- }
3297
- }
3298
- // when multiple WEB deviceType join with same user
3299
- // and some of the devices are joined and some are left
3300
- // when your own device is still connected you want to leave and destroy
3301
- // else you want to just destroy
3302
- // this looks odd because when it leaves it should destroy, but we get a
3303
- // leave response and we should destroy it on the next event loop
3304
- // the leave response gets parsed and we decide if we want to destroy the meeting
3305
- // the first time we just leave it, the second time it comes it destroys it from the collection
3306
- if (payload.shouldLeave) {
3307
- // TODO: We should do cleaning of meeting object if the shouldLeave: false because there might be meeting object which we are not cleaning
3308
-
3309
- _this20.leave({
3310
- reason: payload.reason
3311
- }).then(function () {
3312
- _loggerProxy.default.logger.warn('Meeting:index#setUpLocusInfoMeetingListener --> DESTROY_MEETING. The meeting has been left, but has not been destroyed, you should see a later event for leave.');
3313
- }).catch(function (error) {
3314
- // @ts-ignore
3315
- _loggerProxy.default.logger.error("Meeting:index#setUpLocusInfoMeetingListener --> DESTROY_MEETING. Issue with leave for meeting, meeting still in collection: ".concat(_this20, ", error: ").concat(error));
3316
- });
3317
- } else {
3318
- _loggerProxy.default.logger.info('Meeting:index#setUpLocusInfoMeetingListener --> MEETING_REMOVED_REASON', payload.reason);
3319
- _util.default.cleanUp(_this20);
3320
- _triggerProxy.default.trigger(_this20, {
3321
- file: 'meeting/index',
3322
- function: 'setUpLocusInfoMeetingListener'
3323
- }, _constants.EVENTS.DESTROY_MEETING, {
3324
- reason: payload.reason,
3325
- meetingId: _this20.id
3326
- });
3327
- }
3328
- });
3097
+ this.locusInfo.on(_constants.EVENTS.DESTROY_MEETING, /*#__PURE__*/function () {
3098
+ var _ref18 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(payload) {
3099
+ return _regenerator.default.wrap(function _callee4$(_context4) {
3100
+ while (1) switch (_context4.prev = _context4.next) {
3101
+ case 0:
3102
+ if (!_this20.wirelessShare) {
3103
+ _context4.next = 4;
3104
+ break;
3105
+ }
3106
+ if (!_this20.mediaProperties.shareTrack) {
3107
+ _context4.next = 4;
3108
+ break;
3109
+ }
3110
+ _context4.next = 4;
3111
+ return _this20.setLocalShareTrack(undefined);
3112
+ case 4:
3113
+ if (!payload.shouldLeave) {
3114
+ _context4.next = 16;
3115
+ break;
3116
+ }
3117
+ _context4.prev = 5;
3118
+ _context4.next = 8;
3119
+ return _this20.leave({
3120
+ reason: payload.reason
3121
+ });
3122
+ case 8:
3123
+ _loggerProxy.default.logger.warn('Meeting:index#setUpLocusInfoMeetingListener --> DESTROY_MEETING. The meeting has been left, but has not been destroyed, you should see a later event for leave.');
3124
+ _context4.next = 14;
3125
+ break;
3126
+ case 11:
3127
+ _context4.prev = 11;
3128
+ _context4.t0 = _context4["catch"](5);
3129
+ // @ts-ignore
3130
+ _loggerProxy.default.logger.error("Meeting:index#setUpLocusInfoMeetingListener --> DESTROY_MEETING. Issue with leave for meeting, meeting still in collection: ".concat(_this20, ", error: ").concat(_context4.t0));
3131
+ case 14:
3132
+ _context4.next = 19;
3133
+ break;
3134
+ case 16:
3135
+ _loggerProxy.default.logger.info('Meeting:index#setUpLocusInfoMeetingListener --> MEETING_REMOVED_REASON', payload.reason);
3136
+ _util.default.cleanUp(_this20);
3137
+ _triggerProxy.default.trigger(_this20, {
3138
+ file: 'meeting/index',
3139
+ function: 'setUpLocusInfoMeetingListener'
3140
+ }, _constants.EVENTS.DESTROY_MEETING, {
3141
+ reason: payload.reason,
3142
+ meetingId: _this20.id
3143
+ });
3144
+ case 19:
3145
+ case "end":
3146
+ return _context4.stop();
3147
+ }
3148
+ }, _callee4, null, [[5, 11]]);
3149
+ }));
3150
+ return function (_x3) {
3151
+ return _ref18.apply(this, arguments);
3152
+ };
3153
+ }());
3329
3154
  }
3330
3155
 
3331
3156
  /**
@@ -3469,78 +3294,6 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
3469
3294
  return this.members;
3470
3295
  }
3471
3296
 
3472
- /**
3473
- * Truthy when a meeting has an audio connection established
3474
- * @returns {Boolean} true if meeting audio is connected otherwise false
3475
- * @public
3476
- * @memberof Meeting
3477
- */
3478
- }, {
3479
- key: "isAudioConnected",
3480
- value: function isAudioConnected() {
3481
- return !!this.audio;
3482
- }
3483
-
3484
- /**
3485
- * Convenience function to tell whether a meeting is muted
3486
- * @returns {Boolean} if meeting audio muted or not
3487
- * @public
3488
- * @memberof Meeting
3489
- */
3490
- }, {
3491
- key: "isAudioMuted",
3492
- value: function isAudioMuted() {
3493
- return this.audio && this.audio.isMuted();
3494
- }
3495
-
3496
- /**
3497
- * Convenience function to tell if the end user last changed the audio state
3498
- * @returns {Boolean} if audio was manipulated by the end user
3499
- * @public
3500
- * @memberof Meeting
3501
- */
3502
- }, {
3503
- key: "isAudioSelf",
3504
- value: function isAudioSelf() {
3505
- return this.audio && this.audio.isSelf();
3506
- }
3507
-
3508
- /**
3509
- * Truthy when a meeting has a video connection established
3510
- * @returns {Boolean} true if meeting video connected otherwise false
3511
- * @public
3512
- * @memberof Meeting
3513
- */
3514
- }, {
3515
- key: "isVideoConnected",
3516
- value: function isVideoConnected() {
3517
- return !!this.video;
3518
- }
3519
-
3520
- /**
3521
- * Convenience function to tell whether video is muted
3522
- * @returns {Boolean} if meeting video is muted or not
3523
- * @public
3524
- * @memberof Meeting
3525
- */
3526
- }, {
3527
- key: "isVideoMuted",
3528
- value: function isVideoMuted() {
3529
- return this.video && this.video.isMuted();
3530
- }
3531
-
3532
- /**
3533
- * Convenience function to tell whether the end user changed the video state
3534
- * @returns {Boolean} if meeting video is muted or not
3535
- * @public
3536
- * @memberof Meeting
3537
- */
3538
- }, {
3539
- key: "isVideoSelf",
3540
- value: function isVideoSelf() {
3541
- return this.video && this.video.isSelf();
3542
- }
3543
-
3544
3297
  /**
3545
3298
  * Sets the meeting info on the class instance
3546
3299
  * @param {Object} meetingInfo
@@ -3649,21 +3402,6 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
3649
3402
  _triggerProxy.default.trigger(this, options, _constants.EVENTS.REQUEST_UPLOAD_LOGS, this);
3650
3403
  }
3651
3404
 
3652
- /**
3653
- * Removes remote audio and video stream on the class instance and triggers an event
3654
- * to developers
3655
- * @returns {undefined}
3656
- * @public
3657
- * @memberof Meeting
3658
- * @deprecated after v1.89.3
3659
- */
3660
- }, {
3661
- key: "unsetRemoteStream",
3662
- value: function unsetRemoteStream() {
3663
- _loggerProxy.default.logger.warn('Meeting:index#unsetRemoteStream --> [DEPRECATION WARNING]: unsetRemoteStream has been deprecated after v1.89.3');
3664
- this.mediaProperties.unsetRemoteMedia();
3665
- }
3666
-
3667
3405
  /**
3668
3406
  * Removes remote audio, video and share tracks from class instance's mediaProperties
3669
3407
  * @returns {undefined}
@@ -3699,10 +3437,10 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
3699
3437
  key: "closeRemoteTracks",
3700
3438
  value: function closeRemoteTracks() {
3701
3439
  var _this22 = this;
3702
- var _this$mediaProperties3 = this.mediaProperties,
3703
- remoteAudioTrack = _this$mediaProperties3.remoteAudioTrack,
3704
- remoteVideoTrack = _this$mediaProperties3.remoteVideoTrack,
3705
- remoteShare = _this$mediaProperties3.remoteShare;
3440
+ var _this$mediaProperties2 = this.mediaProperties,
3441
+ remoteAudioTrack = _this$mediaProperties2.remoteAudioTrack,
3442
+ remoteVideoTrack = _this$mediaProperties2.remoteVideoTrack,
3443
+ remoteShare = _this$mediaProperties2.remoteShare;
3706
3444
 
3707
3445
  /**
3708
3446
  * Triggers an event to the developer
@@ -3743,243 +3481,168 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
3743
3481
  }
3744
3482
 
3745
3483
  /**
3746
- * Emits the 'media:ready' event with a local stream that consists of 1 local audio and 1 local video track
3747
- * @returns {undefined}
3748
- * @private
3749
- * @memberof Meeting
3750
- */
3751
- }, {
3752
- key: "sendLocalMediaReadyEvent",
3753
- value: function sendLocalMediaReadyEvent() {
3754
- var _this$mediaProperties4, _this$mediaProperties5;
3755
- _triggerProxy.default.trigger(this, {
3756
- file: 'meeting/index',
3757
- function: 'sendLocalMediaReadyEvent'
3758
- }, _constants.EVENT_TRIGGERS.MEDIA_READY, {
3759
- type: _constants.EVENT_TYPES.LOCAL,
3760
- stream: _util4.default.createMediaStream([(_this$mediaProperties4 = this.mediaProperties.audioTrack) === null || _this$mediaProperties4 === void 0 ? void 0 : _this$mediaProperties4.underlyingTrack, (_this$mediaProperties5 = this.mediaProperties.videoTrack) === null || _this$mediaProperties5 === void 0 ? void 0 : _this$mediaProperties5.underlyingTrack])
3761
- });
3762
- }
3763
-
3764
- /**
3765
- * Sets the local audio track on the class and emits an event to the developer
3766
- * @param {MediaStreamTrack} rawAudioTrack
3767
- * @param {Boolean} emitEvent if true, a media ready event is emitted to the developer
3768
- * @returns {undefined}
3769
- * @private
3770
- * @memberof Meeting
3484
+ * Stores the reference to a new microphone track, sets up the required event listeners
3485
+ * on it, cleans up previous track, etc.
3486
+ *
3487
+ * @param {LocalMicrophoneTrack | null} localTrack local microphone track
3488
+ * @returns {Promise<void>}
3771
3489
  */
3772
3490
  }, {
3773
3491
  key: "setLocalAudioTrack",
3774
- value: function setLocalAudioTrack(rawAudioTrack) {
3775
- var emitEvent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
3776
- if (this.isMultistream) {
3777
- throw new Error('this method is only supposed to be used for transcoded meetings');
3778
- }
3779
- if (rawAudioTrack) {
3780
- var settings = rawAudioTrack.getSettings();
3781
- var localMicrophoneTrack = new _mediaHelpers.LocalMicrophoneTrack(_util4.default.createMediaStream([rawAudioTrack]));
3782
- this.mediaProperties.setMediaSettings('audio', {
3783
- echoCancellation: settings.echoCancellation,
3784
- noiseSuppression: settings.noiseSuppression
3785
- });
3786
- _loggerProxy.default.logger.log('Meeting:index#setLocalAudioTrack --> Audio settings.', (0, _stringify.default)(this.mediaProperties.mediaSettings.audio));
3787
- this.mediaProperties.setLocalAudioTrack(localMicrophoneTrack);
3788
- if (this.audio) this.audio.applyClientStateLocally(this);
3789
- } else {
3790
- this.mediaProperties.setLocalAudioTrack(null);
3791
- }
3792
- if (emitEvent) {
3793
- this.sendLocalMediaReadyEvent();
3794
- }
3795
- }
3492
+ value: function () {
3493
+ var _setLocalAudioTrack = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(localTrack) {
3494
+ var oldTrack;
3495
+ return _regenerator.default.wrap(function _callee5$(_context5) {
3496
+ while (1) switch (_context5.prev = _context5.next) {
3497
+ case 0:
3498
+ oldTrack = this.mediaProperties.audioTrack;
3499
+ oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.off(_mediaHelpers.LocalTrackEvents.Muted, this.localAudioTrackMuteStateHandler);
3500
+ oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.off(_mediaHelpers.LocalTrackEvents.UnderlyingTrackChange, this.underlyingLocalTrackChangeHandler);
3796
3501
 
3502
+ // we don't update this.mediaProperties.mediaDirection.sendAudio, because we always keep it as true to avoid extra SDP exchanges
3503
+ this.mediaProperties.setLocalAudioTrack(localTrack);
3504
+ this.audio.handleLocalTrackChange(this);
3505
+ localTrack === null || localTrack === void 0 ? void 0 : localTrack.on(_mediaHelpers.LocalTrackEvents.Muted, this.localAudioTrackMuteStateHandler);
3506
+ localTrack === null || localTrack === void 0 ? void 0 : localTrack.on(_mediaHelpers.LocalTrackEvents.UnderlyingTrackChange, this.underlyingLocalTrackChangeHandler);
3507
+ if (!(!this.isMultistream || !localTrack)) {
3508
+ _context5.next = 10;
3509
+ break;
3510
+ }
3511
+ _context5.next = 10;
3512
+ return this.unpublishTrack(oldTrack);
3513
+ case 10:
3514
+ _context5.next = 12;
3515
+ return this.publishTrack(this.mediaProperties.audioTrack);
3516
+ case 12:
3517
+ case "end":
3518
+ return _context5.stop();
3519
+ }
3520
+ }, _callee5, this);
3521
+ }));
3522
+ function setLocalAudioTrack(_x4) {
3523
+ return _setLocalAudioTrack.apply(this, arguments);
3524
+ }
3525
+ return setLocalAudioTrack;
3526
+ }()
3797
3527
  /**
3798
- * Sets the local video track on the class and emits an event to the developer
3799
- * @param {MediaStreamTrack} rawVideoTrack
3800
- * @param {Boolean} emitEvent if true, a media ready event is emitted to the developer
3801
- * @returns {undefined}
3802
- * @private
3803
- * @memberof Meeting
3528
+ * Stores the reference to a new camera track, sets up the required event listeners
3529
+ * on it, cleans up previous track, etc.
3530
+ *
3531
+ * @param {LocalCameraTrack | null} localTrack local camera track
3532
+ * @returns {Promise<void>}
3804
3533
  */
3805
3534
  }, {
3806
3535
  key: "setLocalVideoTrack",
3807
- value: function setLocalVideoTrack(rawVideoTrack) {
3808
- var emitEvent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
3809
- if (this.isMultistream) {
3810
- throw new Error('this method is only supposed to be used for transcoded meetings');
3811
- }
3812
- if (rawVideoTrack) {
3813
- var _rawVideoTrack$getSet = rawVideoTrack.getSettings(),
3814
- aspectRatio = _rawVideoTrack$getSet.aspectRatio,
3815
- frameRate = _rawVideoTrack$getSet.frameRate,
3816
- height = _rawVideoTrack$getSet.height,
3817
- width = _rawVideoTrack$getSet.width,
3818
- deviceId = _rawVideoTrack$getSet.deviceId;
3819
- var localQualityLevel = this.mediaProperties.localQualityLevel;
3820
- var localCameraTrack = new _mediaHelpers.LocalCameraTrack(_util4.default.createMediaStream([rawVideoTrack]));
3821
- if (Number(localQualityLevel.slice(0, -1)) > height) {
3822
- _loggerProxy.default.logger.warn("Meeting:index#setLocalVideoTrack --> Local video quality of ".concat(localQualityLevel, " not supported,\n downscaling to highest possible resolution of ").concat(height, "p"));
3823
- this.mediaProperties.setLocalQualityLevel("".concat(height, "p"));
3824
- }
3825
- this.mediaProperties.setLocalVideoTrack(localCameraTrack);
3826
- if (this.video) this.video.applyClientStateLocally(this);
3827
- this.mediaProperties.setMediaSettings('video', {
3828
- aspectRatio: aspectRatio,
3829
- frameRate: frameRate,
3830
- height: height,
3831
- width: width
3832
- });
3833
- // store and save the selected video input device
3834
- if (deviceId) {
3835
- this.mediaProperties.setVideoDeviceId(deviceId);
3836
- }
3837
- _loggerProxy.default.logger.log('Meeting:index#setLocalVideoTrack --> Video settings.', (0, _stringify.default)(this.mediaProperties.mediaSettings.video));
3838
- } else {
3839
- this.mediaProperties.setLocalVideoTrack(null);
3840
- }
3841
- if (emitEvent) {
3842
- this.sendLocalMediaReadyEvent();
3536
+ value: function () {
3537
+ var _setLocalVideoTrack = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(localTrack) {
3538
+ var oldTrack;
3539
+ return _regenerator.default.wrap(function _callee6$(_context6) {
3540
+ while (1) switch (_context6.prev = _context6.next) {
3541
+ case 0:
3542
+ oldTrack = this.mediaProperties.videoTrack;
3543
+ oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.off(_mediaHelpers.LocalTrackEvents.Muted, this.localVideoTrackMuteStateHandler);
3544
+ oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.off(_mediaHelpers.LocalTrackEvents.UnderlyingTrackChange, this.underlyingLocalTrackChangeHandler);
3545
+
3546
+ // we don't update this.mediaProperties.mediaDirection.sendVideo, because we always keep it as true to avoid extra SDP exchanges
3547
+ this.mediaProperties.setLocalVideoTrack(localTrack);
3548
+ this.video.handleLocalTrackChange(this);
3549
+ localTrack === null || localTrack === void 0 ? void 0 : localTrack.on(_mediaHelpers.LocalTrackEvents.Muted, this.localVideoTrackMuteStateHandler);
3550
+ localTrack === null || localTrack === void 0 ? void 0 : localTrack.on(_mediaHelpers.LocalTrackEvents.UnderlyingTrackChange, this.underlyingLocalTrackChangeHandler);
3551
+ if (!(!this.isMultistream || !localTrack)) {
3552
+ _context6.next = 10;
3553
+ break;
3554
+ }
3555
+ _context6.next = 10;
3556
+ return this.unpublishTrack(oldTrack);
3557
+ case 10:
3558
+ _context6.next = 12;
3559
+ return this.publishTrack(this.mediaProperties.videoTrack);
3560
+ case 12:
3561
+ case "end":
3562
+ return _context6.stop();
3563
+ }
3564
+ }, _callee6, this);
3565
+ }));
3566
+ function setLocalVideoTrack(_x5) {
3567
+ return _setLocalVideoTrack.apply(this, arguments);
3843
3568
  }
3844
- }
3845
-
3569
+ return setLocalVideoTrack;
3570
+ }()
3846
3571
  /**
3847
- * Sets the local media stream on the class and emits an event to the developer
3848
- * @param {Stream} localStream the local media stream
3849
- * @returns {undefined}
3850
- * @public
3851
- * @memberof Meeting
3852
- */
3853
- }, {
3854
- key: "setLocalTracks",
3855
- value: function setLocalTracks(localStream) {
3856
- if (localStream) {
3857
- if (this.isMultistream) {
3858
- throw new Error('addMedia() and updateMedia() APIs are not supported with multistream, use publishTracks/unpublishTracks instead');
3859
- }
3860
- var _MeetingUtil$getTrack = _util.default.getTrack(localStream),
3861
- audioTrack = _MeetingUtil$getTrack.audioTrack,
3862
- videoTrack = _MeetingUtil$getTrack.videoTrack;
3863
- this.setLocalAudioTrack(audioTrack, false);
3864
- this.setLocalVideoTrack(videoTrack, false);
3865
- this.sendLocalMediaReadyEvent();
3866
- }
3867
- }
3868
-
3869
- /**
3870
- * Sets the local media stream on the class and emits an event to the developer
3871
- * @param {MediaStreamTrack} rawLocalShareTrack the local share media track
3872
- * @returns {undefined}
3873
- * @public
3874
- * @memberof Meeting
3572
+ * Stores the reference to a new screen share track, sets up the required event listeners
3573
+ * on it, cleans up previous track, etc.
3574
+ * It also sends the floor grant/release request.
3575
+ *
3576
+ * @param {LocalDisplayTrack | undefined} localDisplayTrack local camera track
3577
+ * @returns {Promise<void>}
3875
3578
  */
3876
3579
  }, {
3877
3580
  key: "setLocalShareTrack",
3878
- value: function setLocalShareTrack(rawLocalShareTrack) {
3879
- if (rawLocalShareTrack) {
3880
- var settings = rawLocalShareTrack.getSettings();
3881
- var localDisplayTrack = new _mediaHelpers.LocalDisplayTrack(_util4.default.createMediaStream([rawLocalShareTrack]));
3882
- this.mediaProperties.setLocalShareTrack(localDisplayTrack);
3883
- this.mediaProperties.setMediaSettings('screen', {
3884
- aspectRatio: settings.aspectRatio,
3885
- frameRate: settings.frameRate,
3886
- height: settings.height,
3887
- width: settings.width,
3888
- // @ts-ignore
3889
- displaySurface: settings.displaySurface,
3890
- // @ts-ignore
3891
- cursor: settings.cursor
3892
- });
3893
- _loggerProxy.default.logger.log('Meeting:index#setLocalShareTrack --> Screen settings.', (0, _stringify.default)(this.mediaProperties.mediaSettings.screen));
3894
- localDisplayTrack.on(_mediaHelpers.LocalTrackEvents.Ended, this.handleShareTrackEnded);
3895
- _triggerProxy.default.trigger(this, {
3896
- file: 'meeting/index',
3897
- function: 'setLocalShareTrack'
3898
- }, _constants.EVENT_TRIGGERS.MEDIA_READY, {
3899
- type: _constants.EVENT_TYPES.LOCAL_SHARE,
3900
- track: rawLocalShareTrack
3901
- });
3902
- } else if (this.mediaProperties.shareTrack) {
3903
- this.mediaProperties.shareTrack.off(_mediaHelpers.LocalTrackEvents.Ended, this.handleShareTrackEnded);
3904
- this.mediaProperties.shareTrack.stop(); // todo: this line should be removed once SPARK-399695 is done
3905
- this.mediaProperties.setLocalShareTrack(null);
3581
+ value: function () {
3582
+ var _setLocalShareTrack = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(localDisplayTrack) {
3583
+ var oldTrack;
3584
+ return _regenerator.default.wrap(function _callee7$(_context7) {
3585
+ while (1) switch (_context7.prev = _context7.next) {
3586
+ case 0:
3587
+ oldTrack = this.mediaProperties.shareTrack;
3588
+ oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.off(_mediaHelpers.LocalTrackEvents.Ended, this.handleShareTrackEnded);
3589
+ oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.off(_mediaHelpers.LocalTrackEvents.UnderlyingTrackChange, this.underlyingLocalTrackChangeHandler);
3590
+ this.mediaProperties.setLocalShareTrack(localDisplayTrack);
3591
+ localDisplayTrack === null || localDisplayTrack === void 0 ? void 0 : localDisplayTrack.on(_mediaHelpers.LocalTrackEvents.Ended, this.handleShareTrackEnded);
3592
+ localDisplayTrack === null || localDisplayTrack === void 0 ? void 0 : localDisplayTrack.on(_mediaHelpers.LocalTrackEvents.UnderlyingTrackChange, this.underlyingLocalTrackChangeHandler);
3593
+ this.mediaProperties.mediaDirection.sendShare = !!localDisplayTrack;
3594
+ if (!(!this.isMultistream || !localDisplayTrack)) {
3595
+ _context7.next = 10;
3596
+ break;
3597
+ }
3598
+ _context7.next = 10;
3599
+ return this.unpublishTrack(oldTrack);
3600
+ case 10:
3601
+ _context7.next = 12;
3602
+ return this.publishTrack(this.mediaProperties.shareTrack);
3603
+ case 12:
3604
+ case "end":
3605
+ return _context7.stop();
3606
+ }
3607
+ }, _callee7, this);
3608
+ }));
3609
+ function setLocalShareTrack(_x6) {
3610
+ return _setLocalShareTrack.apply(this, arguments);
3906
3611
  }
3907
- }
3908
-
3909
- /**
3910
- * Closes the local stream from the class and emits an event to the developer
3911
- * @returns {undefined}
3912
- * @event media:stopped
3913
- * @public
3914
- * @memberof Meeting
3915
- */
3916
- }, {
3917
- key: "closeLocalStream",
3918
- value: function closeLocalStream() {
3919
- var _this23 = this;
3920
- var _this$mediaProperties6 = this.mediaProperties,
3921
- audioTrack = _this$mediaProperties6.audioTrack,
3922
- videoTrack = _this$mediaProperties6.videoTrack;
3923
- return _media.default.stopTracks(audioTrack).then(function () {
3924
- return _media.default.stopTracks(videoTrack);
3925
- }).then(function () {
3926
- if (audioTrack || videoTrack) {
3927
- _triggerProxy.default.trigger(_this23, {
3928
- file: 'meeting/index',
3929
- function: 'closeLocalStream'
3930
- }, _constants.EVENT_TRIGGERS.MEDIA_STOPPED, {
3931
- type: _constants.EVENT_TYPES.LOCAL
3932
- });
3933
- }
3934
- });
3935
- }
3936
-
3937
- /**
3938
- * Closes the local stream from the class and emits an event to the developer
3939
- * @returns {undefined}
3940
- * @event media:stopped
3941
- * @public
3942
- * @memberof Meeting
3943
- */
3944
- }, {
3945
- key: "closeLocalShare",
3946
- value: function closeLocalShare() {
3947
- var _this24 = this;
3948
- var track = this.mediaProperties.shareTrack;
3949
- return _media.default.stopTracks(track).then(function () {
3950
- if (track) {
3951
- _triggerProxy.default.trigger(_this24, {
3952
- file: 'meeting/index',
3953
- function: 'closeLocalShare'
3954
- }, _constants.EVENT_TRIGGERS.MEDIA_STOPPED, {
3955
- type: _constants.EVENT_TYPES.LOCAL_SHARE
3956
- });
3957
- }
3958
- });
3959
- }
3960
-
3961
- /**
3962
- * Removes the local stream from the class and emits an event to the developer
3963
- * @returns {undefined}
3964
- * @public
3965
- * @memberof Meeting
3966
- */
3967
- }, {
3968
- key: "unsetLocalVideoTrack",
3969
- value: function unsetLocalVideoTrack() {
3970
- this.mediaProperties.unsetLocalVideoTrack();
3971
- }
3972
-
3612
+ return setLocalShareTrack;
3613
+ }()
3973
3614
  /**
3974
- * Removes the local share from the class and emits an event to the developer
3975
- * @returns {undefined}
3976
- * @public
3977
- * @memberof Meeting
3615
+ * Removes references to local tracks. This function should be called
3616
+ * on cleanup when we leave the meeting etc.
3617
+ *
3618
+ * @internal
3619
+ * @returns {void}
3978
3620
  */
3979
3621
  }, {
3980
- key: "unsetLocalShareTrack",
3981
- value: function unsetLocalShareTrack() {
3982
- this.mediaProperties.unsetLocalShareTrack();
3622
+ key: "cleanupLocalTracks",
3623
+ value: function cleanupLocalTracks() {
3624
+ var _this$mediaProperties3 = this.mediaProperties,
3625
+ audioTrack = _this$mediaProperties3.audioTrack,
3626
+ videoTrack = _this$mediaProperties3.videoTrack,
3627
+ shareTrack = _this$mediaProperties3.shareTrack;
3628
+ audioTrack === null || audioTrack === void 0 ? void 0 : audioTrack.off(_mediaHelpers.LocalTrackEvents.Muted, this.localAudioTrackMuteStateHandler);
3629
+ audioTrack === null || audioTrack === void 0 ? void 0 : audioTrack.off(_mediaHelpers.LocalTrackEvents.UnderlyingTrackChange, this.underlyingLocalTrackChangeHandler);
3630
+ videoTrack === null || videoTrack === void 0 ? void 0 : videoTrack.off(_mediaHelpers.LocalTrackEvents.Muted, this.localVideoTrackMuteStateHandler);
3631
+ videoTrack === null || videoTrack === void 0 ? void 0 : videoTrack.off(_mediaHelpers.LocalTrackEvents.UnderlyingTrackChange, this.underlyingLocalTrackChangeHandler);
3632
+ shareTrack === null || shareTrack === void 0 ? void 0 : shareTrack.off(_mediaHelpers.LocalTrackEvents.Ended, this.handleShareTrackEnded);
3633
+ shareTrack === null || shareTrack === void 0 ? void 0 : shareTrack.off(_mediaHelpers.LocalTrackEvents.UnderlyingTrackChange, this.underlyingLocalTrackChangeHandler);
3634
+ this.mediaProperties.setLocalAudioTrack(undefined);
3635
+ this.mediaProperties.setLocalVideoTrack(undefined);
3636
+ this.mediaProperties.setLocalShareTrack(undefined);
3637
+ this.mediaProperties.mediaDirection.sendAudio = false;
3638
+ this.mediaProperties.mediaDirection.sendVideo = false;
3639
+ this.mediaProperties.mediaDirection.sendShare = false;
3640
+
3641
+ // WCME doesn't unpublish tracks when multistream connection is closed, so we do it here
3642
+ // (we have to do it for transcoded meetings anyway, so we might as well do for multistream too)
3643
+ audioTrack === null || audioTrack === void 0 ? void 0 : audioTrack.setPublished(false);
3644
+ videoTrack === null || videoTrack === void 0 ? void 0 : videoTrack.setPublished(false);
3645
+ shareTrack === null || shareTrack === void 0 ? void 0 : shareTrack.setPublished(false);
3983
3646
  }
3984
3647
 
3985
3648
  /**
@@ -3991,7 +3654,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
3991
3654
  }, {
3992
3655
  key: "setMercuryListener",
3993
3656
  value: function setMercuryListener() {
3994
- var _this25 = this;
3657
+ var _this23 = this;
3995
3658
  // Client will have a socket manager and handle reconnecting to mercury, when we reconnect to mercury
3996
3659
  // if the meeting has active peer connections, it should try to reconnect.
3997
3660
  // @ts-ignore
@@ -3999,16 +3662,16 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
3999
3662
  _loggerProxy.default.logger.info('Meeting:index#setMercuryListener --> Web socket online');
4000
3663
 
4001
3664
  // Only send restore event when it was disconnected before and for connected later
4002
- if (!_this25.hasWebsocketConnected) {
3665
+ if (!_this23.hasWebsocketConnected) {
4003
3666
  _metrics.default.postEvent({
4004
3667
  event: _config.eventType.MERCURY_CONNECTION_RESTORED,
4005
- meeting: _this25
3668
+ meeting: _this23
4006
3669
  });
4007
3670
  _metrics.default.sendBehavioralMetric(_constants2.default.MERCURY_CONNECTION_RESTORED, {
4008
- correlation_id: _this25.correlationId
3671
+ correlation_id: _this23.correlationId
4009
3672
  });
4010
3673
  }
4011
- _this25.hasWebsocketConnected = true;
3674
+ _this23.hasWebsocketConnected = true;
4012
3675
  });
4013
3676
 
4014
3677
  // @ts-ignore
@@ -4016,10 +3679,10 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4016
3679
  _loggerProxy.default.logger.error('Meeting:index#setMercuryListener --> Web socket offline');
4017
3680
  _metrics.default.postEvent({
4018
3681
  event: _config.eventType.MERCURY_CONNECTION_LOST,
4019
- meeting: _this25
3682
+ meeting: _this23
4020
3683
  });
4021
3684
  _metrics.default.sendBehavioralMetric(_constants2.default.MERCURY_CONNECTION_FAILURE, {
4022
- correlation_id: _this25.correlationId
3685
+ correlation_id: _this23.correlationId
4023
3686
  });
4024
3687
  });
4025
3688
  }
@@ -4047,6 +3710,8 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4047
3710
  this.receiveSlotManager.reset();
4048
3711
  this.mediaProperties.webrtcMediaConnection.close();
4049
3712
  }
3713
+ this.audio = null;
3714
+ this.video = null;
4050
3715
  return _promise.default.resolve();
4051
3716
  }
4052
3717
 
@@ -4081,246 +3746,41 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4081
3746
  this.correlationId = id;
4082
3747
  }
4083
3748
 
4084
- /**
4085
- * Mute the audio for a meeting
4086
- * @returns {Promise} resolves the data from muting audio {mute, self} or rejects if there is no audio set
4087
- * @public
4088
- * @memberof Meeting
4089
- */
4090
- }, {
4091
- key: "muteAudio",
4092
- value: function muteAudio() {
4093
- var _this26 = this;
4094
- if (!_util.default.isUserInJoinedState(this.locusInfo)) {
4095
- return _promise.default.reject(new _webexErrors.UserNotJoinedError());
4096
- }
4097
-
4098
- // @ts-ignore
4099
- if (!this.mediaId) {
4100
- // Happens when addMedia and mute are triggered in succession
4101
- return _promise.default.reject(new _webexErrors.NoMediaEstablishedYetError());
4102
- }
4103
- if (!this.audio) {
4104
- return _promise.default.reject(new _parameter.default('no audio control associated to the meeting'));
4105
- }
4106
-
4107
- // First, stop sending the local audio media
4108
- return logRequest(this.audio.handleClientRequest(this, true).then(function () {
4109
- _util.default.handleAudioLogging(_this26.mediaProperties.audioTrack);
4110
- _metrics.default.postEvent({
4111
- event: _config.eventType.MUTED,
4112
- meeting: _this26,
4113
- data: {
4114
- trigger: _config.trigger.USER_INTERACTION,
4115
- mediaType: _config.mediaType.AUDIO
4116
- }
4117
- });
4118
- }).catch(function (error) {
4119
- _metrics.default.sendBehavioralMetric(_constants2.default.MUTE_AUDIO_FAILURE, {
4120
- correlation_id: _this26.correlationId,
4121
- locus_id: _this26.locusUrl.split('/').pop(),
4122
- reason: error.message,
4123
- stack: error.stack
4124
- });
4125
- throw error;
4126
- }), {
4127
- logText: "Meeting:index#muteAudio --> correlationId=".concat(this.correlationId, " muting audio")
4128
- });
4129
- }
4130
-
4131
- /**
4132
- * Unmute meeting audio
4133
- * @returns {Promise} resolves data from muting audio {mute, self} or rejects if there is no audio set
4134
- * @public
4135
- * @memberof Meeting
4136
- */
4137
- }, {
4138
- key: "unmuteAudio",
4139
- value: function unmuteAudio() {
4140
- var _this27 = this;
4141
- if (!_util.default.isUserInJoinedState(this.locusInfo)) {
4142
- return _promise.default.reject(new _webexErrors.UserNotJoinedError());
4143
- }
4144
-
4145
- // @ts-ignore
4146
- if (!this.mediaId) {
4147
- // Happens when addMedia and mute are triggered in succession
4148
- return _promise.default.reject(new _webexErrors.NoMediaEstablishedYetError());
4149
- }
4150
- if (!this.audio) {
4151
- return _promise.default.reject(new _parameter.default('no audio control associated to the meeting'));
4152
- }
4153
-
4154
- // First, send the control to unmute the participant on the server
4155
- return logRequest(this.audio.handleClientRequest(this, false).then(function () {
4156
- _util.default.handleAudioLogging(_this27.mediaProperties.audioTrack);
4157
- _metrics.default.postEvent({
4158
- event: _config.eventType.UNMUTED,
4159
- meeting: _this27,
4160
- data: {
4161
- trigger: _config.trigger.USER_INTERACTION,
4162
- mediaType: _config.mediaType.AUDIO
4163
- }
4164
- });
4165
- }).catch(function (error) {
4166
- _metrics.default.sendBehavioralMetric(_constants2.default.UNMUTE_AUDIO_FAILURE, {
4167
- correlation_id: _this27.correlationId,
4168
- locus_id: _this27.locusUrl.split('/').pop(),
4169
- reason: error.message,
4170
- stack: error.stack
4171
- });
4172
- throw error;
4173
- }), {
4174
- logText: "Meeting:index#unmuteAudio --> correlationId=".concat(this.correlationId, " unmuting audio")
4175
- });
4176
- }
4177
-
4178
- /**
4179
- * Mute the video for a meeting
4180
- * @returns {Promise} resolves data from muting video {mute, self} or rejects if there is no video set
4181
- * @public
4182
- * @memberof Meeting
4183
- */
4184
- }, {
4185
- key: "muteVideo",
4186
- value: function muteVideo() {
4187
- var _this28 = this;
4188
- if (!_util.default.isUserInJoinedState(this.locusInfo)) {
4189
- return _promise.default.reject(new _webexErrors.UserNotJoinedError());
4190
- }
4191
-
4192
- // @ts-ignore
4193
- if (!this.mediaId) {
4194
- // Happens when addMedia and mute are triggered in succession
4195
- return _promise.default.reject(new _webexErrors.NoMediaEstablishedYetError());
4196
- }
4197
- if (!this.video) {
4198
- return _promise.default.reject(new _parameter.default('no video control associated to the meeting'));
4199
- }
4200
- return logRequest(this.video.handleClientRequest(this, true).then(function () {
4201
- _util.default.handleVideoLogging(_this28.mediaProperties.videoTrack);
4202
- _metrics.default.postEvent({
4203
- event: _config.eventType.MUTED,
4204
- meeting: _this28,
4205
- data: {
4206
- trigger: _config.trigger.USER_INTERACTION,
4207
- mediaType: _config.mediaType.VIDEO
4208
- }
4209
- });
4210
- }).catch(function (error) {
4211
- _metrics.default.sendBehavioralMetric(_constants2.default.MUTE_VIDEO_FAILURE, {
4212
- correlation_id: _this28.correlationId,
4213
- locus_id: _this28.locusUrl.split('/').pop(),
4214
- reason: error.message,
4215
- stack: error.stack
4216
- });
4217
- throw error;
4218
- }), {
4219
- logText: "Meeting:index#muteVideo --> correlationId=".concat(this.correlationId, " muting video")
4220
- });
4221
- }
4222
-
4223
- /**
4224
- * Unmute meeting video
4225
- * @returns {Promise} resolves data from muting video {mute, self} or rejects if there is no video set
4226
- * @public
4227
- * @memberof Meeting
4228
- */
4229
- }, {
4230
- key: "unmuteVideo",
4231
- value: function unmuteVideo() {
4232
- var _this29 = this;
4233
- if (!_util.default.isUserInJoinedState(this.locusInfo)) {
4234
- return _promise.default.reject(new _webexErrors.UserNotJoinedError());
4235
- }
4236
-
4237
- // @ts-ignore
4238
- if (!this.mediaId) {
4239
- // Happens when addMedia and mute are triggered in succession
4240
- return _promise.default.reject(new _webexErrors.NoMediaEstablishedYetError());
4241
- }
4242
- if (!this.video) {
4243
- return _promise.default.reject(new _parameter.default('no audio control associated to the meeting'));
4244
- }
4245
- return logRequest(this.video.handleClientRequest(this, false).then(function () {
4246
- _util.default.handleVideoLogging(_this29.mediaProperties.videoTrack);
4247
- _metrics.default.postEvent({
4248
- event: _config.eventType.UNMUTED,
4249
- meeting: _this29,
4250
- data: {
4251
- trigger: _config.trigger.USER_INTERACTION,
4252
- mediaType: _config.mediaType.VIDEO
4253
- }
4254
- });
4255
- }).catch(function (error) {
4256
- _metrics.default.sendBehavioralMetric(_constants2.default.UNMUTE_VIDEO_FAILURE, {
4257
- correlation_id: _this29.correlationId,
4258
- locus_id: _this29.locusUrl.split('/').pop(),
4259
- reason: error.message,
4260
- stack: error.stack
4261
- });
4262
- throw error;
4263
- }), {
4264
- logText: "Meeting:index#unmuteVideo --> correlationId=".concat(this.correlationId, " unmuting video")
4265
- });
4266
- }
4267
-
4268
3749
  /**
4269
3750
  * Shorthand function to join AND set up media
4270
3751
  * @param {Object} options - options to join with media
4271
3752
  * @param {JoinOptions} [options.joinOptions] - see #join()
4272
- * @param {MediaDirection} options.mediaSettings - see #addMedia()
4273
- * @param {AudioVideo} [options.audioVideoOptions] - see #getMediaStreams()
4274
- * @returns {Promise} -- {join: see join(), media: see addMedia(), local: see getMediaStreams()}
3753
+ * @param {MediaDirection} [options.mediaOptions] - see #addMedia()
3754
+ * @returns {Promise} -- {join: see join(), media: see addMedia()}
4275
3755
  * @public
4276
3756
  * @memberof Meeting
4277
3757
  * @example
4278
3758
  * joinWithMedia({
4279
3759
  * joinOptions: {resourceId: 'resourceId' },
4280
- * mediaSettings: {
4281
- * sendAudio: true,
4282
- * sendVideo: true,
4283
- * sendShare: false,
4284
- * receiveVideo:true,
4285
- * receiveAudio: true,
4286
- * receiveShare: true
4287
- * }
4288
- * audioVideoOptions: {
4289
- * audio: 'audioDeviceId',
4290
- * video: 'videoDeviceId'
4291
- * }})
3760
+ * mediaOptions: {
3761
+ * localTracks: { microphone: microphoneTrack, camera: cameraTrack }
3762
+ * }
3763
+ * })
4292
3764
  */
4293
3765
  }, {
4294
3766
  key: "joinWithMedia",
4295
3767
  value: function joinWithMedia() {
4296
- var _this30 = this;
3768
+ var _this24 = this;
4297
3769
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4298
- // TODO: add validations for parameters
4299
- var mediaSettings = options.mediaSettings,
4300
- joinOptions = options.joinOptions,
4301
- audioVideoOptions = options.audioVideoOptions;
3770
+ var mediaOptions = options.mediaOptions,
3771
+ joinOptions = options.joinOptions;
4302
3772
  return this.join(joinOptions).then(function (joinResponse) {
4303
- return _this30.getMediaStreams(mediaSettings, audioVideoOptions).then(function (_ref20) {
4304
- var _ref21 = (0, _slicedToArray2.default)(_ref20, 2),
4305
- localStream = _ref21[0],
4306
- localShare = _ref21[1];
4307
- return _this30.addMedia({
4308
- mediaSettings: mediaSettings,
4309
- localShare: localShare,
4310
- localStream: localStream
4311
- }).then(function (mediaResponse) {
4312
- return {
4313
- join: joinResponse,
4314
- media: mediaResponse,
4315
- local: [localStream, localShare]
4316
- };
4317
- });
3773
+ return _this24.addMedia(mediaOptions).then(function (mediaResponse) {
3774
+ return {
3775
+ join: joinResponse,
3776
+ media: mediaResponse
3777
+ };
4318
3778
  });
4319
3779
  }).catch(function (error) {
4320
3780
  _loggerProxy.default.logger.error('Meeting:index#joinWithMedia --> ', error);
4321
3781
  _metrics.default.sendBehavioralMetric(_constants2.default.JOIN_WITH_MEDIA_FAILURE, {
4322
- correlation_id: _this30.correlationId,
4323
- locus_id: _this30.locusUrl.split('/').pop(),
3782
+ correlation_id: _this24.correlationId,
3783
+ locus_id: _this24.locusUrl.split('/').pop(),
4324
3784
  reason: error.message,
4325
3785
  stack: error.stack
4326
3786
  }, {
@@ -4341,7 +3801,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4341
3801
  }, {
4342
3802
  key: "reconnect",
4343
3803
  value: function reconnect(options) {
4344
- var _this31 = this;
3804
+ var _this25 = this;
4345
3805
  _loggerProxy.default.logger.log("Meeting:index#reconnect --> attempting to reconnect meeting ".concat(this.id));
4346
3806
  if (!this.reconnectionManager || !this.reconnectionManager.reconnect) {
4347
3807
  return _promise.default.reject(new _parameter.default('Cannot reconnect, ReconnectionManager must first be defined.'));
@@ -4369,13 +3829,13 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4369
3829
  function: 'reconnect'
4370
3830
  }, _constants.EVENT_TRIGGERS.MEETING_RECONNECTION_STARTING);
4371
3831
  return this.reconnectionManager.reconnect(options).then(function () {
4372
- _triggerProxy.default.trigger(_this31, {
3832
+ _triggerProxy.default.trigger(_this25, {
4373
3833
  file: 'meeting/index',
4374
3834
  function: 'reconnect'
4375
3835
  }, _constants.EVENT_TRIGGERS.MEETING_RECONNECTION_SUCCESS);
4376
3836
  _loggerProxy.default.logger.log('Meeting:index#reconnect --> Meeting reconnect success');
4377
3837
  }).catch(function (error) {
4378
- _triggerProxy.default.trigger(_this31, {
3838
+ _triggerProxy.default.trigger(_this25, {
4379
3839
  file: 'meeting/index',
4380
3840
  function: 'reconnect'
4381
3841
  }, _constants.EVENT_TRIGGERS.MEETING_RECONNECTION_FAILURE, {
@@ -4383,18 +3843,18 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4383
3843
  });
4384
3844
  _loggerProxy.default.logger.error('Meeting:index#reconnect --> Meeting reconnect failed', error);
4385
3845
  _metrics.default.sendBehavioralMetric(_constants2.default.MEETING_RECONNECT_FAILURE, {
4386
- correlation_id: _this31.correlationId,
4387
- locus_id: _this31.locusUrl.split('/').pop(),
3846
+ correlation_id: _this25.correlationId,
3847
+ locus_id: _this25.locusUrl.split('/').pop(),
4388
3848
  reason: error.message,
4389
3849
  stack: error.stack
4390
3850
  });
4391
- _this31.uploadLogs({
3851
+ _this25.uploadLogs({
4392
3852
  file: 'meeting/index',
4393
3853
  function: 'reconnect'
4394
3854
  });
4395
3855
  return _promise.default.reject(new _reconnection.default('Reconnection failure event', error));
4396
3856
  }).finally(function () {
4397
- _this31.reconnectionManager.reset();
3857
+ _this25.reconnectionManager.reset();
4398
3858
  });
4399
3859
  }
4400
3860
 
@@ -4437,16 +3897,16 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4437
3897
  }, {
4438
3898
  key: "monitorTranscriptionSocketConnection",
4439
3899
  value: function monitorTranscriptionSocketConnection() {
4440
- var _this32 = this;
3900
+ var _this26 = this;
4441
3901
  this.transcription.onCloseSocket(function (event) {
4442
3902
  _loggerProxy.default.logger.info("Meeting:index#onCloseSocket -->\n unable to continue receiving transcription;\n low-latency mercury web socket connection is closed now.\n ".concat(event));
4443
- _this32.triggerStopReceivingTranscriptionEvent();
3903
+ _this26.triggerStopReceivingTranscriptionEvent();
4444
3904
  });
4445
3905
  this.transcription.onErrorSocket(function (event) {
4446
3906
  _loggerProxy.default.logger.error("Meeting:index#onErrorSocket -->\n unable to continue receiving transcription;\n low-latency mercury web socket connection error had occured.\n ".concat(event));
4447
- _this32.triggerStopReceivingTranscriptionEvent();
3907
+ _this26.triggerStopReceivingTranscriptionEvent();
4448
3908
  _metrics.default.sendBehavioralMetric(_constants2.default.RECEIVE_TRANSCRIPTION_FAILURE, {
4449
- correlation_id: _this32.correlationId,
3909
+ correlation_id: _this26.correlationId,
4450
3910
  reason: 'unexpected error: transcription LLM web socket connection error had occured.',
4451
3911
  event: event
4452
3912
  });
@@ -4461,16 +3921,16 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4461
3921
  }, {
4462
3922
  key: "receiveTranscription",
4463
3923
  value: function () {
4464
- var _receiveTranscription = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
4465
- var _this33 = this;
3924
+ var _receiveTranscription = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
3925
+ var _this27 = this;
4466
3926
  var datachannelUrl, _yield$this$request, webSocketUrl;
4467
- return _regenerator.default.wrap(function _callee4$(_context4) {
4468
- while (1) switch (_context4.prev = _context4.next) {
3927
+ return _regenerator.default.wrap(function _callee8$(_context8) {
3928
+ while (1) switch (_context8.prev = _context8.next) {
4469
3929
  case 0:
4470
3930
  _loggerProxy.default.logger.info("Meeting:index#receiveTranscription -->\n Attempting to generate a web socket url.");
4471
- _context4.prev = 1;
3931
+ _context8.prev = 1;
4472
3932
  datachannelUrl = this.locusInfo.info.datachannelUrl; // @ts-ignore - fix type
4473
- _context4.next = 5;
3933
+ _context8.next = 5;
4474
3934
  return this.request({
4475
3935
  method: _constants.HTTP_VERBS.POST,
4476
3936
  uri: datachannelUrl,
@@ -4479,7 +3939,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4479
3939
  }
4480
3940
  });
4481
3941
  case 5:
4482
- _yield$this$request = _context4.sent;
3942
+ _yield$this$request = _context8.sent;
4483
3943
  webSocketUrl = _yield$this$request.body.webSocketUrl;
4484
3944
  _loggerProxy.default.logger.info("Meeting:index#receiveTranscription -->\n Generated web socket url succesfully.");
4485
3945
  this.transcription = new _transcription.default(webSocketUrl,
@@ -4489,7 +3949,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4489
3949
 
4490
3950
  // retrieve and pass the payload
4491
3951
  this.transcription.subscribe(function (payload) {
4492
- _triggerProxy.default.trigger(_this33, {
3952
+ _triggerProxy.default.trigger(_this27, {
4493
3953
  file: 'meeting/index',
4494
3954
  function: 'join'
4495
3955
  }, _constants.EVENT_TRIGGERS.MEETING_STARTED_RECEIVING_TRANSCRIPTION, payload);
@@ -4497,22 +3957,22 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4497
3957
  this.monitorTranscriptionSocketConnection();
4498
3958
  // @ts-ignore - fix type
4499
3959
  this.transcription.connect(this.webex.credentials.supertoken.access_token);
4500
- _context4.next = 19;
3960
+ _context8.next = 19;
4501
3961
  break;
4502
3962
  case 15:
4503
- _context4.prev = 15;
4504
- _context4.t0 = _context4["catch"](1);
4505
- _loggerProxy.default.logger.error("Meeting:index#receiveTranscription --> ".concat(_context4.t0));
3963
+ _context8.prev = 15;
3964
+ _context8.t0 = _context8["catch"](1);
3965
+ _loggerProxy.default.logger.error("Meeting:index#receiveTranscription --> ".concat(_context8.t0));
4506
3966
  _metrics.default.sendBehavioralMetric(_constants2.default.RECEIVE_TRANSCRIPTION_FAILURE, {
4507
3967
  correlation_id: this.correlationId,
4508
- reason: _context4.t0.message,
4509
- stack: _context4.t0.stack
3968
+ reason: _context8.t0.message,
3969
+ stack: _context8.t0.stack
4510
3970
  });
4511
3971
  case 19:
4512
3972
  case "end":
4513
- return _context4.stop();
3973
+ return _context8.stop();
4514
3974
  }
4515
- }, _callee4, this, [[1, 15]]);
3975
+ }, _callee8, this, [[1, 15]]);
4516
3976
  }));
4517
3977
  function receiveTranscription() {
4518
3978
  return _receiveTranscription.apply(this, arguments);
@@ -4570,7 +4030,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4570
4030
  }, {
4571
4031
  key: "join",
4572
4032
  value: function join() {
4573
- var _this34 = this;
4033
+ var _this28 = this;
4574
4034
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4575
4035
  // @ts-ignore - fix type
4576
4036
  if (!this.webex.meetings.registered) {
@@ -4654,21 +4114,17 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4654
4114
  this.deferJoin = undefined;
4655
4115
  return _promise.default.reject(_error);
4656
4116
  }
4657
- this.mediaProperties.setLocalQualityLevel(options.meetingQuality);
4658
4117
  this.mediaProperties.setRemoteQualityLevel(options.meetingQuality);
4659
4118
  }
4660
4119
  if ((0, _typeof2.default)(options.meetingQuality) === 'object') {
4661
- if (!_constants.QUALITY_LEVELS[options.meetingQuality.local] && !_constants.QUALITY_LEVELS[options.meetingQuality.remote]) {
4662
- var _errorMessage2 = "Meeting:index#join --> ".concat(options.meetingQuality.local || options.meetingQuality.remote, " not defined");
4120
+ if (!_constants.QUALITY_LEVELS[options.meetingQuality.remote]) {
4121
+ var _errorMessage2 = "Meeting:index#join --> ".concat(options.meetingQuality.remote, " not defined");
4663
4122
  _loggerProxy.default.logger.error(_errorMessage2);
4664
4123
  var _error2 = new Error(_errorMessage2);
4665
4124
  joinFailed(_error2);
4666
4125
  this.deferJoin = undefined;
4667
4126
  return _promise.default.reject(new Error(_errorMessage2));
4668
4127
  }
4669
- if (options.meetingQuality.local) {
4670
- this.mediaProperties.setLocalQualityLevel(options.meetingQuality.local);
4671
- }
4672
4128
  if (options.meetingQuality.remote) {
4673
4129
  this.mediaProperties.setRemoteQualityLevel(options.meetingQuality.remote);
4674
4130
  }
@@ -4676,83 +4132,83 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4676
4132
  }
4677
4133
  this.isMultistream = !!options.enableMultistream;
4678
4134
  return _util.default.joinMeetingOptions(this, options).then(function (join) {
4679
- _this34.meetingFiniteStateMachine.join();
4135
+ _this28.meetingFiniteStateMachine.join();
4680
4136
  _loggerProxy.default.logger.log('Meeting:index#join --> Success');
4681
4137
  return join;
4682
4138
  }).then(function (join) {
4683
4139
  joinSuccess(join);
4684
- _this34.deferJoin = undefined;
4140
+ _this28.deferJoin = undefined;
4685
4141
  _metrics.default.sendBehavioralMetric(_constants2.default.JOIN_SUCCESS, {
4686
- correlation_id: _this34.correlationId
4142
+ correlation_id: _this28.correlationId
4687
4143
  });
4688
4144
  return join;
4689
4145
  }).then( /*#__PURE__*/function () {
4690
- var _ref22 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(join) {
4691
- return _regenerator.default.wrap(function _callee5$(_context5) {
4692
- while (1) switch (_context5.prev = _context5.next) {
4146
+ var _ref19 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(join) {
4147
+ return _regenerator.default.wrap(function _callee9$(_context9) {
4148
+ while (1) switch (_context9.prev = _context9.next) {
4693
4149
  case 0:
4694
- if (!_this34.config.enableAutomaticLLM) {
4695
- _context5.next = 3;
4150
+ if (!_this28.config.enableAutomaticLLM) {
4151
+ _context9.next = 3;
4696
4152
  break;
4697
4153
  }
4698
- _context5.next = 3;
4699
- return _this34.updateLLMConnection();
4154
+ _context9.next = 3;
4155
+ return _this28.updateLLMConnection();
4700
4156
  case 3:
4701
- return _context5.abrupt("return", join);
4157
+ return _context9.abrupt("return", join);
4702
4158
  case 4:
4703
4159
  case "end":
4704
- return _context5.stop();
4160
+ return _context9.stop();
4705
4161
  }
4706
- }, _callee5);
4162
+ }, _callee9);
4707
4163
  }));
4708
- return function (_x3) {
4709
- return _ref22.apply(this, arguments);
4164
+ return function (_x7) {
4165
+ return _ref19.apply(this, arguments);
4710
4166
  };
4711
4167
  }()).then( /*#__PURE__*/function () {
4712
- var _ref23 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(join) {
4713
- return _regenerator.default.wrap(function _callee6$(_context6) {
4714
- while (1) switch (_context6.prev = _context6.next) {
4168
+ var _ref20 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(join) {
4169
+ return _regenerator.default.wrap(function _callee10$(_context10) {
4170
+ while (1) switch (_context10.prev = _context10.next) {
4715
4171
  case 0:
4716
4172
  if (!isBrowser) {
4717
- _context6.next = 8;
4173
+ _context10.next = 8;
4718
4174
  break;
4719
4175
  }
4720
- if (!(_this34.config.receiveTranscription || options.receiveTranscription)) {
4721
- _context6.next = 6;
4176
+ if (!(_this28.config.receiveTranscription || options.receiveTranscription)) {
4177
+ _context10.next = 6;
4722
4178
  break;
4723
4179
  }
4724
- if (!_this34.isTranscriptionSupported()) {
4725
- _context6.next = 6;
4180
+ if (!_this28.isTranscriptionSupported()) {
4181
+ _context10.next = 6;
4726
4182
  break;
4727
4183
  }
4728
- _context6.next = 5;
4729
- return _this34.receiveTranscription();
4184
+ _context10.next = 5;
4185
+ return _this28.receiveTranscription();
4730
4186
  case 5:
4731
4187
  _loggerProxy.default.logger.info('Meeting:index#join --> enabled to recieve transcription!');
4732
4188
  case 6:
4733
- _context6.next = 9;
4189
+ _context10.next = 9;
4734
4190
  break;
4735
4191
  case 8:
4736
4192
  _loggerProxy.default.logger.error('Meeting:index#join --> Receving transcription is not supported on this platform');
4737
4193
  case 9:
4738
- return _context6.abrupt("return", join);
4194
+ return _context10.abrupt("return", join);
4739
4195
  case 10:
4740
4196
  case "end":
4741
- return _context6.stop();
4197
+ return _context10.stop();
4742
4198
  }
4743
- }, _callee6);
4199
+ }, _callee10);
4744
4200
  }));
4745
- return function (_x4) {
4746
- return _ref23.apply(this, arguments);
4201
+ return function (_x8) {
4202
+ return _ref20.apply(this, arguments);
4747
4203
  };
4748
4204
  }()).catch(function (error) {
4749
4205
  var _error$error;
4750
- _this34.meetingFiniteStateMachine.fail(error);
4206
+ _this28.meetingFiniteStateMachine.fail(error);
4751
4207
  _loggerProxy.default.logger.error('Meeting:index#join --> Failed', error);
4752
4208
  _metrics.default.postEvent({
4753
4209
  event: _config.eventType.LOCUS_JOIN_RESPONSE,
4754
- meeting: _this34,
4755
- meetingId: _this34.id,
4210
+ meeting: _this28,
4211
+ meetingId: _this28.id,
4756
4212
  data: {
4757
4213
  errors: [_metrics.default.parseLocusError(error.error, true)]
4758
4214
  }
@@ -4760,18 +4216,18 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4760
4216
 
4761
4217
  // TODO: change this to error codes and pre defined dictionary
4762
4218
  _metrics.default.sendBehavioralMetric(_constants2.default.JOIN_FAILURE, {
4763
- correlation_id: _this34.correlationId,
4219
+ correlation_id: _this28.correlationId,
4764
4220
  reason: (_error$error = error.error) === null || _error$error === void 0 ? void 0 : _error$error.message,
4765
4221
  stack: error.stack
4766
4222
  });
4767
4223
 
4768
4224
  // Upload logs on join Failure
4769
- _triggerProxy.default.trigger(_this34, {
4225
+ _triggerProxy.default.trigger(_this28, {
4770
4226
  file: 'meeting/index',
4771
4227
  function: 'join'
4772
- }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this34);
4228
+ }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this28);
4773
4229
  joinFailed(error);
4774
- _this34.deferJoin = undefined;
4230
+ _this28.deferJoin = undefined;
4775
4231
  return _promise.default.reject(error);
4776
4232
  });
4777
4233
  }
@@ -4785,50 +4241,50 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4785
4241
  }, {
4786
4242
  key: "updateLLMConnection",
4787
4243
  value: function () {
4788
- var _updateLLMConnection = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
4789
- var _this35 = this;
4244
+ var _updateLLMConnection = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
4245
+ var _this29 = this;
4790
4246
  var _this$locusInfo6, url, _this$locusInfo6$info, _this$locusInfo6$info2, datachannelUrl, isJoined;
4791
- return _regenerator.default.wrap(function _callee7$(_context7) {
4792
- while (1) switch (_context7.prev = _context7.next) {
4247
+ return _regenerator.default.wrap(function _callee11$(_context11) {
4248
+ while (1) switch (_context11.prev = _context11.next) {
4793
4249
  case 0:
4794
4250
  // @ts-ignore - Fix type
4795
4251
  _this$locusInfo6 = this.locusInfo, url = _this$locusInfo6.url, _this$locusInfo6$info = _this$locusInfo6.info, _this$locusInfo6$info2 = _this$locusInfo6$info === void 0 ? {} : _this$locusInfo6$info, datachannelUrl = _this$locusInfo6$info2.datachannelUrl;
4796
4252
  isJoined = this.joinedWith && this.joinedWith.state === 'JOINED'; // @ts-ignore - Fix type
4797
4253
  if (!this.webex.internal.llm.isConnected()) {
4798
- _context7.next = 8;
4254
+ _context11.next = 8;
4799
4255
  break;
4800
4256
  }
4801
4257
  if (!(url === this.webex.internal.llm.getLocusUrl() && isJoined)) {
4802
- _context7.next = 5;
4258
+ _context11.next = 5;
4803
4259
  break;
4804
4260
  }
4805
- return _context7.abrupt("return", undefined);
4261
+ return _context11.abrupt("return", undefined);
4806
4262
  case 5:
4807
- _context7.next = 7;
4263
+ _context11.next = 7;
4808
4264
  return this.webex.internal.llm.disconnectLLM();
4809
4265
  case 7:
4810
4266
  // @ts-ignore - Fix type
4811
4267
  this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
4812
4268
  case 8:
4813
4269
  if (isJoined) {
4814
- _context7.next = 10;
4270
+ _context11.next = 10;
4815
4271
  break;
4816
4272
  }
4817
- return _context7.abrupt("return", undefined);
4273
+ return _context11.abrupt("return", undefined);
4818
4274
  case 10:
4819
- return _context7.abrupt("return", this.webex.internal.llm.registerAndConnect(url, datachannelUrl).then(function (registerAndConnectResult) {
4275
+ return _context11.abrupt("return", this.webex.internal.llm.registerAndConnect(url, datachannelUrl).then(function (registerAndConnectResult) {
4820
4276
  // @ts-ignore - Fix type
4821
- _this35.webex.internal.llm.off('event:relay.event', _this35.processRelayEvent);
4277
+ _this29.webex.internal.llm.off('event:relay.event', _this29.processRelayEvent);
4822
4278
  // @ts-ignore - Fix type
4823
- _this35.webex.internal.llm.on('event:relay.event', _this35.processRelayEvent);
4279
+ _this29.webex.internal.llm.on('event:relay.event', _this29.processRelayEvent);
4824
4280
  _loggerProxy.default.logger.info('Meeting:index#updateLLMConnection --> enabled to receive relay events!');
4825
4281
  return _promise.default.resolve(registerAndConnectResult);
4826
4282
  }));
4827
4283
  case 11:
4828
4284
  case "end":
4829
- return _context7.stop();
4285
+ return _context11.stop();
4830
4286
  }
4831
- }, _callee7, this);
4287
+ }, _callee11, this);
4832
4288
  }));
4833
4289
  function updateLLMConnection() {
4834
4290
  return _updateLLMConnection.apply(this, arguments);
@@ -4873,7 +4329,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4873
4329
  }, {
4874
4330
  key: "dialInPstn",
4875
4331
  value: function dialInPstn() {
4876
- var _this36 = this;
4332
+ var _this30 = this;
4877
4333
  if (this.isPhoneProvisioned(this.dialInDeviceStatus)) return _promise.default.resolve(); // prevent multiple dial in devices from being provisioned
4878
4334
 
4879
4335
  var correlationId = this.correlationId,
@@ -4889,10 +4345,10 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4889
4345
  }).catch(function (error) {
4890
4346
  var _error$error2;
4891
4347
  _metrics.default.sendBehavioralMetric(_constants2.default.ADD_DIAL_IN_FAILURE, {
4892
- correlation_id: _this36.correlationId,
4893
- dial_in_url: _this36.dialInUrl,
4348
+ correlation_id: _this30.correlationId,
4349
+ dial_in_url: _this30.dialInUrl,
4894
4350
  locus_id: locusUrl.split('/').pop(),
4895
- client_url: _this36.deviceUrl,
4351
+ client_url: _this30.deviceUrl,
4896
4352
  reason: (_error$error2 = error.error) === null || _error$error2 === void 0 ? void 0 : _error$error2.message,
4897
4353
  stack: error.stack
4898
4354
  });
@@ -4910,7 +4366,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4910
4366
  }, {
4911
4367
  key: "dialOutPstn",
4912
4368
  value: function dialOutPstn(phoneNumber) {
4913
- var _this37 = this;
4369
+ var _this31 = this;
4914
4370
  if (this.isPhoneProvisioned(this.dialOutDeviceStatus)) return _promise.default.resolve(); // prevent multiple dial out devices from being provisioned
4915
4371
 
4916
4372
  var correlationId = this.correlationId,
@@ -4927,10 +4383,10 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4927
4383
  }).catch(function (error) {
4928
4384
  var _error$error3;
4929
4385
  _metrics.default.sendBehavioralMetric(_constants2.default.ADD_DIAL_OUT_FAILURE, {
4930
- correlation_id: _this37.correlationId,
4931
- dial_out_url: _this37.dialOutUrl,
4386
+ correlation_id: _this31.correlationId,
4387
+ dial_out_url: _this31.dialOutUrl,
4932
4388
  locus_id: locusUrl.split('/').pop(),
4933
- client_url: _this37.deviceUrl,
4389
+ client_url: _this31.deviceUrl,
4934
4390
  reason: (_error$error3 = error.error) === null || _error$error3 === void 0 ? void 0 : _error$error3.message,
4935
4391
  stack: error.stack
4936
4392
  });
@@ -4961,7 +4417,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4961
4417
  }, {
4962
4418
  key: "moveTo",
4963
4419
  value: function moveTo(resourceId) {
4964
- var _this38 = this;
4420
+ var _this32 = this;
4965
4421
  if (!resourceId) {
4966
4422
  throw new _parameter.default('Cannot move call without a resourceId.');
4967
4423
  }
@@ -4991,18 +4447,18 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4991
4447
  event: _config.eventType.MOVE_MEDIA,
4992
4448
  meeting: this
4993
4449
  });
4994
- this.locusInfo.once(_constants.LOCUSINFO.EVENTS.SELF_OBSERVING, /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
4450
+ this.locusInfo.once(_constants.LOCUSINFO.EVENTS.SELF_OBSERVING, /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
4995
4451
  var mediaSettings;
4996
- return _regenerator.default.wrap(function _callee8$(_context8) {
4997
- while (1) switch (_context8.prev = _context8.next) {
4452
+ return _regenerator.default.wrap(function _callee12$(_context12) {
4453
+ while (1) switch (_context12.prev = _context12.next) {
4998
4454
  case 0:
4999
- _context8.prev = 0;
5000
- if (!_this38.isSharing) {
5001
- _context8.next = 4;
4455
+ _context12.prev = 0;
4456
+ if (!_this32.isSharing) {
4457
+ _context12.next = 4;
5002
4458
  break;
5003
4459
  }
5004
- _context8.next = 4;
5005
- return _this38.releaseScreenShareFloor();
4460
+ _context12.next = 4;
4461
+ return _this32.releaseScreenShareFloor();
5006
4462
  case 4:
5007
4463
  mediaSettings = {
5008
4464
  mediaDirection: {
@@ -5013,55 +4469,48 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5013
4469
  sendShare: false,
5014
4470
  receiveShare: true
5015
4471
  }
5016
- }; // clean up the local tracks
5017
- _this38.mediaProperties.setMediaDirection(mediaSettings.mediaDirection);
5018
-
5019
- // close the existing local tracks
5020
- _context8.next = 8;
5021
- return _this38.closeLocalStream();
5022
- case 8:
5023
- _context8.next = 10;
5024
- return _this38.closeLocalShare();
5025
- case 10:
5026
- _this38.mediaProperties.unsetMediaTracks();
4472
+ };
4473
+ _this32.cleanupLocalTracks();
4474
+ _this32.mediaProperties.setMediaDirection(mediaSettings.mediaDirection);
4475
+ _this32.mediaProperties.unsetRemoteMedia();
5027
4476
 
5028
4477
  // when a move to is intiated by the client , Locus delets the existing media node from the server as soon the DX answers the meeting
5029
4478
  // once the DX answers we establish connection back the media server with only receiveShare enabled
5030
4479
  // @ts-ignore - reconnectMedia does not accept any argument
5031
- _context8.next = 13;
5032
- return _this38.reconnectionManager.reconnectMedia(mediaSettings).then(function () {
4480
+ _context12.next = 10;
4481
+ return _this32.reconnectionManager.reconnectMedia(mediaSettings).then(function () {
5033
4482
  _metrics.default.sendBehavioralMetric(_constants2.default.MOVE_TO_SUCCESS);
5034
4483
  });
5035
- case 13:
5036
- _context8.next = 19;
4484
+ case 10:
4485
+ _context12.next = 16;
5037
4486
  break;
5038
- case 15:
5039
- _context8.prev = 15;
5040
- _context8.t0 = _context8["catch"](0);
5041
- _loggerProxy.default.logger.error('Meeting:index#moveTo --> Failed to moveTo resourceId', _context8.t0);
4487
+ case 12:
4488
+ _context12.prev = 12;
4489
+ _context12.t0 = _context12["catch"](0);
4490
+ _loggerProxy.default.logger.error('Meeting:index#moveTo --> Failed to moveTo resourceId', _context12.t0);
5042
4491
  _metrics.default.sendBehavioralMetric(_constants2.default.MOVE_TO_FAILURE, {
5043
- correlation_id: _this38.correlationId,
5044
- locus_id: _this38.locusUrl.split('/').pop(),
5045
- reason: _context8.t0.message,
5046
- stack: _context8.t0.stack
4492
+ correlation_id: _this32.correlationId,
4493
+ locus_id: _this32.locusUrl.split('/').pop(),
4494
+ reason: _context12.t0.message,
4495
+ stack: _context12.t0.stack
5047
4496
  });
5048
- case 19:
4497
+ case 16:
5049
4498
  case "end":
5050
- return _context8.stop();
4499
+ return _context12.stop();
5051
4500
  }
5052
- }, _callee8, null, [[0, 15]]);
4501
+ }, _callee12, null, [[0, 12]]);
5053
4502
  })));
5054
4503
  _loggerProxy.default.logger.info('Meeting:index#moveTo --> Initated moved to using resourceId', resourceId);
5055
4504
  return _util.default.joinMeetingOptions(this, {
5056
4505
  resourceId: resourceId,
5057
4506
  moveToResource: true
5058
4507
  }).then(function () {
5059
- _this38.meetingFiniteStateMachine.join();
4508
+ _this32.meetingFiniteStateMachine.join();
5060
4509
  }).catch(function (error) {
5061
- _this38.meetingFiniteStateMachine.fail(error);
4510
+ _this32.meetingFiniteStateMachine.fail(error);
5062
4511
  _metrics.default.sendBehavioralMetric(_constants2.default.MOVE_TO_FAILURE, {
5063
- correlation_id: _this38.correlationId,
5064
- locus_id: _this38.locusUrl.split('/').pop(),
4512
+ correlation_id: _this32.correlationId,
4513
+ locus_id: _this32.locusUrl.split('/').pop(),
5065
4514
  reason: error.message,
5066
4515
  stack: error.stack
5067
4516
  });
@@ -5080,7 +4529,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5080
4529
  }, {
5081
4530
  key: "moveFrom",
5082
4531
  value: function moveFrom(resourceId) {
5083
- var _this39 = this;
4532
+ var _this33 = this;
5084
4533
  // On moveFrom ask the developer to re capture it moveFrom then updateMedia
5085
4534
  if (!resourceId) {
5086
4535
  throw new _parameter.default('Cannot move call without a resourceId.');
@@ -5091,19 +4540,19 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5091
4540
  meeting: this
5092
4541
  });
5093
4542
  return _util.default.joinMeetingOptions(this).then(function () {
5094
- return _util.default.leaveMeeting(_this39, {
4543
+ return _util.default.leaveMeeting(_this33, {
5095
4544
  resourceId: resourceId,
5096
4545
  correlationId: oldCorrelationId,
5097
4546
  moveMeeting: true
5098
4547
  }).then(function () {
5099
- _this39.resourceId = '';
4548
+ _this33.resourceId = '';
5100
4549
  _metrics.default.sendBehavioralMetric(_constants2.default.MOVE_FROM_SUCCESS);
5101
4550
  });
5102
4551
  }).catch(function (error) {
5103
- _this39.meetingFiniteStateMachine.fail(error);
4552
+ _this33.meetingFiniteStateMachine.fail(error);
5104
4553
  _metrics.default.sendBehavioralMetric(_constants2.default.MOVE_FROM_FAILURE, {
5105
- correlation_id: _this39.correlationId,
5106
- locus_id: _this39.locusUrl.split('/').pop(),
4554
+ correlation_id: _this33.correlationId,
4555
+ locus_id: _this33.locusUrl.split('/').pop(),
5107
4556
  reason: error.message,
5108
4557
  stack: error.stack
5109
4558
  });
@@ -5113,17 +4562,10 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5113
4562
  }
5114
4563
 
5115
4564
  /**
5116
- * Get local media streams based on options passed
4565
+ * Handles ROAP_FAILURE event from the webrtc media connection
5117
4566
  *
5118
- * NOTE: this method can only be used with transcoded meetings, not with multistream meetings
5119
- *
5120
- * @param {MediaDirection} mediaDirection A configurable options object for joining a meeting
5121
- * @param {AudioVideo} [audioVideo] audio/video object to set audioinput and videoinput devices, see #Media.getUserMedia
5122
- * @param {SharePreferences} [sharePreferences] audio/video object to set audioinput and videoinput devices, see #Media.getUserMedia
5123
- * @returns {Promise} see #Media.getUserMedia
5124
- * @public
5125
- * @todo should be static, or moved so can be called outside of a meeting
5126
- * @memberof Meeting
4567
+ * @param {Error} error
4568
+ * @returns {void}
5127
4569
  */
5128
4570
  }, {
5129
4571
  key: "getMediaConnectionDebugId",
@@ -5132,7 +4574,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5132
4574
  }
5133
4575
 
5134
4576
  /**
5135
- * Creates a webrtc media connection
4577
+ * Creates a webrtc media connection and publishes tracks to it
5136
4578
  *
5137
4579
  * @param {Object} turnServerInfo TURN server information
5138
4580
  * @param {BundlePolicy} [bundlePolicy] Bundle policy settings
@@ -5140,22 +4582,60 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5140
4582
  */
5141
4583
  }, {
5142
4584
  key: "createMediaConnection",
5143
- value: function createMediaConnection(turnServerInfo, bundlePolicy) {
5144
- var mc = _media.default.createMediaConnection(this.isMultistream, this.getMediaConnectionDebugId(), {
5145
- mediaProperties: this.mediaProperties,
5146
- remoteQualityLevel: this.mediaProperties.remoteQualityLevel,
5147
- // @ts-ignore - config coming from registerPlugin
5148
- enableRtx: this.config.enableRtx,
5149
- // @ts-ignore - config coming from registerPlugin
5150
- enableExtmap: this.config.enableExtmap,
5151
- turnServerInfo: turnServerInfo,
5152
- bundlePolicy: bundlePolicy
5153
- });
5154
- this.mediaProperties.setMediaPeerConnection(mc);
5155
- this.setupMediaConnectionListeners();
5156
- return mc;
5157
- }
4585
+ value: function () {
4586
+ var _createMediaConnection = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(turnServerInfo, bundlePolicy) {
4587
+ var mc;
4588
+ return _regenerator.default.wrap(function _callee13$(_context13) {
4589
+ while (1) switch (_context13.prev = _context13.next) {
4590
+ case 0:
4591
+ // create the actual media connection
4592
+ mc = _media.default.createMediaConnection(this.isMultistream, this.getMediaConnectionDebugId(), {
4593
+ mediaProperties: this.mediaProperties,
4594
+ remoteQualityLevel: this.mediaProperties.remoteQualityLevel,
4595
+ // @ts-ignore - config coming from registerPlugin
4596
+ enableRtx: this.config.enableRtx,
4597
+ // @ts-ignore - config coming from registerPlugin
4598
+ enableExtmap: this.config.enableExtmap,
4599
+ turnServerInfo: turnServerInfo,
4600
+ bundlePolicy: bundlePolicy
4601
+ });
4602
+ this.mediaProperties.setMediaPeerConnection(mc);
4603
+ this.setupMediaConnectionListeners();
5158
4604
 
4605
+ // publish the tracks
4606
+ if (!this.mediaProperties.audioTrack) {
4607
+ _context13.next = 6;
4608
+ break;
4609
+ }
4610
+ _context13.next = 6;
4611
+ return this.publishTrack(this.mediaProperties.audioTrack);
4612
+ case 6:
4613
+ if (!this.mediaProperties.videoTrack) {
4614
+ _context13.next = 9;
4615
+ break;
4616
+ }
4617
+ _context13.next = 9;
4618
+ return this.publishTrack(this.mediaProperties.videoTrack);
4619
+ case 9:
4620
+ if (!this.mediaProperties.shareTrack) {
4621
+ _context13.next = 12;
4622
+ break;
4623
+ }
4624
+ _context13.next = 12;
4625
+ return this.publishTrack(this.mediaProperties.shareTrack);
4626
+ case 12:
4627
+ return _context13.abrupt("return", mc);
4628
+ case 13:
4629
+ case "end":
4630
+ return _context13.stop();
4631
+ }
4632
+ }, _callee13, this);
4633
+ }));
4634
+ function createMediaConnection(_x9, _x10) {
4635
+ return _createMediaConnection.apply(this, arguments);
4636
+ }
4637
+ return createMediaConnection;
4638
+ }()
5159
4639
  /**
5160
4640
  * Listens for an event emitted by eventEmitter and emits it from the meeting object
5161
4641
  *
@@ -5168,9 +4648,9 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5168
4648
  }, {
5169
4649
  key: "forwardEvent",
5170
4650
  value: function forwardEvent(eventEmitter, eventTypeToForward, meetingEventType) {
5171
- var _this40 = this;
4651
+ var _this34 = this;
5172
4652
  eventEmitter.on(eventTypeToForward, function (data) {
5173
- return _triggerProxy.default.trigger(_this40, {
4653
+ return _triggerProxy.default.trigger(_this34, {
5174
4654
  file: 'meetings',
5175
4655
  function: 'addMedia'
5176
4656
  }, meetingEventType, data);
@@ -5178,14 +4658,9 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5178
4658
  }
5179
4659
 
5180
4660
  /**
5181
- * Specify joining via audio (option: pstn), video, screenshare
5182
- * @param {Object} options A configurable options object for joining a meeting
5183
- * @param {Object} options.resourceId pass the deviceId
5184
- * @param {MediaDirection} options.mediaSettings pass media options
5185
- * @param {MediaStream} options.localStream
5186
- * @param {MediaStream} options.localShare
5187
- * @param {BundlePolicy} options.bundlePolicy bundle policy for multistream meetings
5188
- * @param {RemoteMediaManagerConfig} options.remoteMediaManagerConfig only applies if multistream is enabled
4661
+ * Creates a media connection to the server. Media connection is required for sending or receiving any audio/video.
4662
+ *
4663
+ * @param {AddMediaOptions} options
5189
4664
  * @returns {Promise}
5190
4665
  * @public
5191
4666
  * @memberof Meeting
@@ -5193,11 +4668,13 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5193
4668
  }, {
5194
4669
  key: "addMedia",
5195
4670
  value: function addMedia() {
5196
- var _this41 = this;
4671
+ var _localTracks$screenSh,
4672
+ _this35 = this;
5197
4673
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5198
4674
  var LOG_HEADER = 'Meeting:index#addMedia -->';
5199
4675
  var turnDiscoverySkippedReason;
5200
4676
  var turnServerUsed = false;
4677
+ _loggerProxy.default.logger.info("".concat(LOG_HEADER, " called with: ").concat((0, _stringify.default)(options)));
5201
4678
  if (this.meetingState !== _constants.FULL_STATE.ACTIVE) {
5202
4679
  return _promise.default.reject(new _webexErrors.MeetingNotActiveError());
5203
4680
  }
@@ -5209,12 +4686,15 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5209
4686
  if (this.isUserUnadmitted && !this.wirelessShare) {
5210
4687
  return _promise.default.reject(new _webexErrors.UserInLobbyError());
5211
4688
  }
5212
- var localStream = options.localStream,
5213
- localShare = options.localShare,
5214
- mediaSettings = options.mediaSettings,
4689
+ var localTracks = options.localTracks,
4690
+ _options$audioEnabled = options.audioEnabled,
4691
+ audioEnabled = _options$audioEnabled === void 0 ? true : _options$audioEnabled,
4692
+ _options$videoEnabled = options.videoEnabled,
4693
+ videoEnabled = _options$videoEnabled === void 0 ? true : _options$videoEnabled,
4694
+ _options$receiveShare = options.receiveShare,
4695
+ receiveShare = _options$receiveShare === void 0 ? true : _options$receiveShare,
5215
4696
  remoteMediaManagerConfig = options.remoteMediaManagerConfig,
5216
4697
  bundlePolicy = options.bundlePolicy;
5217
- _loggerProxy.default.logger.info("".concat(LOG_HEADER, " Adding Media."));
5218
4698
  _metrics.default.postEvent({
5219
4699
  event: _config.eventType.MEDIA_CAPABILITIES,
5220
4700
  meeting: this,
@@ -5237,58 +4717,103 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5237
4717
  }
5238
4718
  }
5239
4719
  });
5240
- return _util.default.validateOptions(options).then(function () {
5241
- _this41.locusMediaRequest = new _locusMediaRequest.LocusMediaRequest({
5242
- correlationId: _this41.correlationId,
5243
- device: {
5244
- url: _this41.deviceUrl,
5245
- // @ts-ignore
5246
- deviceType: _this41.config.deviceType
5247
- },
5248
- preferTranscoding: !_this41.isMultistream
5249
- }, {
4720
+
4721
+ // when audioEnabled/videoEnabled is true, we set sendAudio/sendVideo to true even before any tracks are published
4722
+ // to avoid doing an extra SDP exchange when they are published for the first time
4723
+ this.mediaProperties.setMediaDirection({
4724
+ sendAudio: audioEnabled,
4725
+ sendVideo: videoEnabled,
4726
+ sendShare: false,
4727
+ receiveAudio: audioEnabled,
4728
+ receiveVideo: videoEnabled,
4729
+ receiveShare: receiveShare
4730
+ });
4731
+ this.locusMediaRequest = new _locusMediaRequest.LocusMediaRequest({
4732
+ correlationId: this.correlationId,
4733
+ device: {
4734
+ url: this.deviceUrl,
5250
4735
  // @ts-ignore
5251
- parent: _this41.webex
5252
- });
5253
- }).then(function () {
5254
- return _this41.roap.doTurnDiscovery(_this41, false);
5255
- }).then(function (turnDiscoveryObject) {
5256
- turnDiscoverySkippedReason = turnDiscoveryObject.turnDiscoverySkippedReason;
5257
- turnServerUsed = !turnDiscoverySkippedReason;
5258
- var turnServerInfo = turnDiscoveryObject.turnServerInfo;
5259
- _this41.preMedia(localStream, localShare, mediaSettings);
5260
- var mc = _this41.createMediaConnection(turnServerInfo, bundlePolicy);
5261
- if (_this41.isMultistream) {
5262
- _this41.remoteMediaManager = new _remoteMediaManager.RemoteMediaManager(_this41.receiveSlotManager, _this41.mediaRequestManagers, remoteMediaManagerConfig);
5263
- _this41.forwardEvent(_this41.remoteMediaManager, _remoteMediaManager.Event.AudioCreated, _constants.EVENT_TRIGGERS.REMOTE_MEDIA_AUDIO_CREATED);
5264
- _this41.forwardEvent(_this41.remoteMediaManager, _remoteMediaManager.Event.ScreenShareAudioCreated, _constants.EVENT_TRIGGERS.REMOTE_MEDIA_SCREEN_SHARE_AUDIO_CREATED);
5265
- _this41.forwardEvent(_this41.remoteMediaManager, _remoteMediaManager.Event.VideoLayoutChanged, _constants.EVENT_TRIGGERS.REMOTE_MEDIA_VIDEO_LAYOUT_CHANGED);
5266
- return _this41.remoteMediaManager.start().then(function () {
5267
- return mc.initiateOffer();
5268
- });
5269
- }
5270
- return mc.initiateOffer();
5271
- }).then(function () {
5272
- _this41.setMercuryListener();
4736
+ deviceType: this.config.deviceType
4737
+ },
4738
+ preferTranscoding: !this.isMultistream
4739
+ }, {
4740
+ // @ts-ignore
4741
+ parent: this.webex
4742
+ });
4743
+ this.audio = (0, _muteState.createMuteState)(_constants.AUDIO, this, audioEnabled);
4744
+ this.video = (0, _muteState.createMuteState)(_constants.VIDEO, this, videoEnabled);
4745
+ this.annotationInfo = localTracks === null || localTracks === void 0 ? void 0 : localTracks.annotationInfo;
4746
+ var promises = [];
4747
+
4748
+ // setup all the references to local tracks in this.mediaProperties before creating media connection
4749
+ // and before TURN discovery, so that the correct mute state is sent with TURN discovery roap messages
4750
+ if (localTracks !== null && localTracks !== void 0 && localTracks.microphone) {
4751
+ promises.push(this.setLocalAudioTrack(localTracks.microphone));
4752
+ }
4753
+ if (localTracks !== null && localTracks !== void 0 && localTracks.camera) {
4754
+ promises.push(this.setLocalVideoTrack(localTracks.camera));
4755
+ }
4756
+ if (localTracks !== null && localTracks !== void 0 && (_localTracks$screenSh = localTracks.screenShare) !== null && _localTracks$screenSh !== void 0 && _localTracks$screenSh.video) {
4757
+ promises.push(this.setLocalShareTrack(localTracks.screenShare.video));
4758
+ }
4759
+ return _promise.default.all(promises).then(function () {
4760
+ return _this35.roap.doTurnDiscovery(_this35, false);
4761
+ }).then( /*#__PURE__*/function () {
4762
+ var _ref22 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(turnDiscoveryObject) {
4763
+ var turnServerInfo, mc;
4764
+ return _regenerator.default.wrap(function _callee14$(_context14) {
4765
+ while (1) switch (_context14.prev = _context14.next) {
4766
+ case 0:
4767
+ turnDiscoverySkippedReason = turnDiscoveryObject.turnDiscoverySkippedReason;
4768
+ turnServerUsed = !turnDiscoverySkippedReason;
4769
+ turnServerInfo = turnDiscoveryObject.turnServerInfo;
4770
+ _context14.next = 5;
4771
+ return _this35.createMediaConnection(turnServerInfo, bundlePolicy);
4772
+ case 5:
4773
+ mc = _context14.sent;
4774
+ if (!_this35.isMultistream) {
4775
+ _context14.next = 13;
4776
+ break;
4777
+ }
4778
+ _this35.remoteMediaManager = new _remoteMediaManager.RemoteMediaManager(_this35.receiveSlotManager, _this35.mediaRequestManagers, remoteMediaManagerConfig);
4779
+ _this35.forwardEvent(_this35.remoteMediaManager, _remoteMediaManager.Event.AudioCreated, _constants.EVENT_TRIGGERS.REMOTE_MEDIA_AUDIO_CREATED);
4780
+ _this35.forwardEvent(_this35.remoteMediaManager, _remoteMediaManager.Event.ScreenShareAudioCreated, _constants.EVENT_TRIGGERS.REMOTE_MEDIA_SCREEN_SHARE_AUDIO_CREATED);
4781
+ _this35.forwardEvent(_this35.remoteMediaManager, _remoteMediaManager.Event.VideoLayoutChanged, _constants.EVENT_TRIGGERS.REMOTE_MEDIA_VIDEO_LAYOUT_CHANGED);
4782
+ _context14.next = 13;
4783
+ return _this35.remoteMediaManager.start();
4784
+ case 13:
4785
+ _context14.next = 15;
4786
+ return mc.initiateOffer();
4787
+ case 15:
4788
+ case "end":
4789
+ return _context14.stop();
4790
+ }
4791
+ }, _callee14);
4792
+ }));
4793
+ return function (_x11) {
4794
+ return _ref22.apply(this, arguments);
4795
+ };
4796
+ }()).then(function () {
4797
+ _this35.setMercuryListener();
5273
4798
  }).then(function () {
5274
- return _this41.getDevices().then(function (devices) {
4799
+ return (0, _mediaHelpers.getDevices)().then(function (devices) {
5275
4800
  _util.default.handleDeviceLogging(devices);
5276
4801
  });
5277
4802
  }).then(function () {
5278
- _this41.handleMediaLogging(_this41.mediaProperties);
4803
+ _this35.handleMediaLogging(_this35.mediaProperties);
5279
4804
  _loggerProxy.default.logger.info("".concat(LOG_HEADER, " media connection created"));
5280
4805
 
5281
4806
  // @ts-ignore - config coming from registerPlugin
5282
- if (_this41.config.stats.enableStatsAnalyzer) {
4807
+ if (_this35.config.stats.enableStatsAnalyzer) {
5283
4808
  // @ts-ignore - config coming from registerPlugin
5284
- _this41.networkQualityMonitor = new _networkQualityMonitor.default(_this41.config.stats);
5285
- _this41.statsAnalyzer = new _statsAnalyzer.StatsAnalyzer(
4809
+ _this35.networkQualityMonitor = new _networkQualityMonitor.default(_this35.config.stats);
4810
+ _this35.statsAnalyzer = new _statsAnalyzer.StatsAnalyzer(
5286
4811
  // @ts-ignore - config coming from registerPlugin
5287
- _this41.config.stats, function (ssrc) {
5288
- return _this41.receiveSlotManager.findReceiveSlotBySsrc(ssrc);
5289
- }, _this41.networkQualityMonitor);
5290
- _this41.setupStatsAnalyzerEventHandlers();
5291
- _this41.networkQualityMonitor.on(_constants.EVENT_TRIGGERS.NETWORK_QUALITY, _this41.sendNetworkQualityEvent.bind(_this41));
4812
+ _this35.config.stats, function (ssrc) {
4813
+ return _this35.receiveSlotManager.findReceiveSlotBySsrc(ssrc);
4814
+ }, _this35.networkQualityMonitor);
4815
+ _this35.setupStatsAnalyzerEventHandlers();
4816
+ _this35.networkQualityMonitor.on(_constants.EVENT_TRIGGERS.NETWORK_QUALITY, _this35.sendNetworkQualityEvent.bind(_this35));
5292
4817
  }
5293
4818
  }).catch(function (error) {
5294
4819
  _loggerProxy.default.logger.error("".concat(LOG_HEADER, " Error adding media , setting up peerconnection, "), error);
@@ -5299,12 +4824,12 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5299
4824
 
5300
4825
  // eslint-disable-next-line func-names
5301
4826
  // eslint-disable-next-line prefer-arrow-callback
5302
- if (_this41.type === _constants._CALL_) {
4827
+ if (_this35.type === _constants._CALL_ || _this35.meetingState === _constants.FULL_STATE.ACTIVE) {
5303
4828
  resolve();
5304
4829
  }
5305
4830
  var joiningTimer = setInterval(function () {
5306
4831
  timerCount += 1;
5307
- if (_this41.meetingState === _constants.FULL_STATE.ACTIVE) {
4832
+ if (_this35.meetingState === _constants.FULL_STATE.ACTIVE) {
5308
4833
  clearInterval(joiningTimer);
5309
4834
  resolve();
5310
4835
  }
@@ -5315,62 +4840,74 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5315
4840
  }, 1000);
5316
4841
  });
5317
4842
  }).then(function () {
5318
- return _this41.mediaProperties.waitForMediaConnectionConnected().catch(function () {
5319
- throw new Error("Timed out waiting for media connection to be connected, correlationId=".concat(_this41.correlationId));
4843
+ return _this35.mediaProperties.waitForMediaConnectionConnected().catch(function () {
4844
+ throw new Error("Timed out waiting for media connection to be connected, correlationId=".concat(_this35.correlationId));
5320
4845
  });
5321
4846
  }).then(function () {
5322
- _loggerProxy.default.logger.info("".concat(LOG_HEADER, " PeerConnection CONNECTED"));
5323
- if (mediaSettings && mediaSettings.sendShare && localShare) {
5324
- if (_this41.state === _constants.MEETING_STATE.STATES.JOINED) {
5325
- return _this41.requestScreenShareFloor();
5326
- }
5327
-
5328
- // When the self state changes to JOINED then request the floor
5329
- _this41.floorGrantPending = true;
4847
+ var _localTracks$screenSh2;
4848
+ if (localTracks !== null && localTracks !== void 0 && (_localTracks$screenSh2 = localTracks.screenShare) !== null && _localTracks$screenSh2 !== void 0 && _localTracks$screenSh2.video) {
4849
+ _this35.enqueueMediaUpdate(MEDIA_UPDATE_TYPE.LAMBDA, {
4850
+ lambda: function () {
4851
+ var _lambda = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15() {
4852
+ return _regenerator.default.wrap(function _callee15$(_context15) {
4853
+ while (1) switch (_context15.prev = _context15.next) {
4854
+ case 0:
4855
+ return _context15.abrupt("return", _this35.requestScreenShareFloor());
4856
+ case 1:
4857
+ case "end":
4858
+ return _context15.stop();
4859
+ }
4860
+ }, _callee15);
4861
+ }));
4862
+ function lambda() {
4863
+ return _lambda.apply(this, arguments);
4864
+ }
4865
+ return lambda;
4866
+ }()
4867
+ });
5330
4868
  }
5331
- return {};
5332
4869
  }).then(function () {
5333
- return _this41.mediaProperties.getCurrentConnectionType();
4870
+ return _this35.mediaProperties.getCurrentConnectionType();
5334
4871
  }).then(function (connectionType) {
5335
4872
  _metrics.default.sendBehavioralMetric(_constants2.default.ADD_MEDIA_SUCCESS, {
5336
- correlation_id: _this41.correlationId,
5337
- locus_id: _this41.locusUrl.split('/').pop(),
4873
+ correlation_id: _this35.correlationId,
4874
+ locus_id: _this35.locusUrl.split('/').pop(),
5338
4875
  connectionType: connectionType,
5339
- isMultistream: _this41.isMultistream
4876
+ isMultistream: _this35.isMultistream
5340
4877
  });
5341
4878
  }).catch(function (error) {
5342
- var _this41$mediaProperti, _this41$mediaProperti2, _this41$mediaProperti3, _this41$mediaProperti4, _this41$mediaProperti5, _this41$mediaProperti6, _this41$mediaProperti7, _this41$mediaProperti8, _this41$mediaProperti9, _this41$mediaProperti10, _this41$mediaProperti11, _this41$mediaProperti12, _this41$mediaProperti13, _this41$mediaProperti14, _this41$mediaProperti15, _this41$mediaProperti16, _this41$mediaProperti17, _this41$mediaProperti18, _this41$mediaProperti19, _this41$mediaProperti20, _this41$mediaProperti21;
4879
+ var _this35$mediaProperti, _this35$mediaProperti2, _this35$mediaProperti3, _this35$mediaProperti4, _this35$mediaProperti5, _this35$mediaProperti6, _this35$mediaProperti7, _this35$mediaProperti8, _this35$mediaProperti9, _this35$mediaProperti10, _this35$mediaProperti11, _this35$mediaProperti12, _this35$mediaProperti13, _this35$mediaProperti14, _this35$mediaProperti15, _this35$mediaProperti16, _this35$mediaProperti17, _this35$mediaProperti18, _this35$mediaProperti19, _this35$mediaProperti20, _this35$mediaProperti21;
5343
4880
  _metrics.default.sendBehavioralMetric(_constants2.default.ADD_MEDIA_FAILURE, {
5344
- correlation_id: _this41.correlationId,
5345
- locus_id: _this41.locusUrl.split('/').pop(),
4881
+ correlation_id: _this35.correlationId,
4882
+ locus_id: _this35.locusUrl.split('/').pop(),
5346
4883
  reason: error.message,
5347
4884
  stack: error.stack,
5348
4885
  code: error.code,
5349
4886
  turnDiscoverySkippedReason: turnDiscoverySkippedReason,
5350
4887
  turnServerUsed: turnServerUsed,
5351
- isMultistream: _this41.isMultistream,
5352
- signalingState: ((_this41$mediaProperti = _this41.mediaProperties.webrtcMediaConnection) === null || _this41$mediaProperti === void 0 ? void 0 : (_this41$mediaProperti2 = _this41$mediaProperti.multistreamConnection) === null || _this41$mediaProperti2 === void 0 ? void 0 : (_this41$mediaProperti3 = _this41$mediaProperti2.pc) === null || _this41$mediaProperti3 === void 0 ? void 0 : (_this41$mediaProperti4 = _this41$mediaProperti3.pc) === null || _this41$mediaProperti4 === void 0 ? void 0 : _this41$mediaProperti4.signalingState) || ((_this41$mediaProperti5 = _this41.mediaProperties.webrtcMediaConnection) === null || _this41$mediaProperti5 === void 0 ? void 0 : (_this41$mediaProperti6 = _this41$mediaProperti5.mediaConnection) === null || _this41$mediaProperti6 === void 0 ? void 0 : (_this41$mediaProperti7 = _this41$mediaProperti6.pc) === null || _this41$mediaProperti7 === void 0 ? void 0 : _this41$mediaProperti7.signalingState) || 'unknown',
5353
- connectionState: ((_this41$mediaProperti8 = _this41.mediaProperties.webrtcMediaConnection) === null || _this41$mediaProperti8 === void 0 ? void 0 : (_this41$mediaProperti9 = _this41$mediaProperti8.multistreamConnection) === null || _this41$mediaProperti9 === void 0 ? void 0 : (_this41$mediaProperti10 = _this41$mediaProperti9.pc) === null || _this41$mediaProperti10 === void 0 ? void 0 : (_this41$mediaProperti11 = _this41$mediaProperti10.pc) === null || _this41$mediaProperti11 === void 0 ? void 0 : _this41$mediaProperti11.connectionState) || ((_this41$mediaProperti12 = _this41.mediaProperties.webrtcMediaConnection) === null || _this41$mediaProperti12 === void 0 ? void 0 : (_this41$mediaProperti13 = _this41$mediaProperti12.mediaConnection) === null || _this41$mediaProperti13 === void 0 ? void 0 : (_this41$mediaProperti14 = _this41$mediaProperti13.pc) === null || _this41$mediaProperti14 === void 0 ? void 0 : _this41$mediaProperti14.connectionState) || 'unknown',
5354
- iceConnectionState: ((_this41$mediaProperti15 = _this41.mediaProperties.webrtcMediaConnection) === null || _this41$mediaProperti15 === void 0 ? void 0 : (_this41$mediaProperti16 = _this41$mediaProperti15.multistreamConnection) === null || _this41$mediaProperti16 === void 0 ? void 0 : (_this41$mediaProperti17 = _this41$mediaProperti16.pc) === null || _this41$mediaProperti17 === void 0 ? void 0 : (_this41$mediaProperti18 = _this41$mediaProperti17.pc) === null || _this41$mediaProperti18 === void 0 ? void 0 : _this41$mediaProperti18.iceConnectionState) || ((_this41$mediaProperti19 = _this41.mediaProperties.webrtcMediaConnection) === null || _this41$mediaProperti19 === void 0 ? void 0 : (_this41$mediaProperti20 = _this41$mediaProperti19.mediaConnection) === null || _this41$mediaProperti20 === void 0 ? void 0 : (_this41$mediaProperti21 = _this41$mediaProperti20.pc) === null || _this41$mediaProperti21 === void 0 ? void 0 : _this41$mediaProperti21.iceConnectionState) || 'unknown'
4888
+ isMultistream: _this35.isMultistream,
4889
+ signalingState: ((_this35$mediaProperti = _this35.mediaProperties.webrtcMediaConnection) === null || _this35$mediaProperti === void 0 ? void 0 : (_this35$mediaProperti2 = _this35$mediaProperti.multistreamConnection) === null || _this35$mediaProperti2 === void 0 ? void 0 : (_this35$mediaProperti3 = _this35$mediaProperti2.pc) === null || _this35$mediaProperti3 === void 0 ? void 0 : (_this35$mediaProperti4 = _this35$mediaProperti3.pc) === null || _this35$mediaProperti4 === void 0 ? void 0 : _this35$mediaProperti4.signalingState) || ((_this35$mediaProperti5 = _this35.mediaProperties.webrtcMediaConnection) === null || _this35$mediaProperti5 === void 0 ? void 0 : (_this35$mediaProperti6 = _this35$mediaProperti5.mediaConnection) === null || _this35$mediaProperti6 === void 0 ? void 0 : (_this35$mediaProperti7 = _this35$mediaProperti6.pc) === null || _this35$mediaProperti7 === void 0 ? void 0 : _this35$mediaProperti7.signalingState) || 'unknown',
4890
+ connectionState: ((_this35$mediaProperti8 = _this35.mediaProperties.webrtcMediaConnection) === null || _this35$mediaProperti8 === void 0 ? void 0 : (_this35$mediaProperti9 = _this35$mediaProperti8.multistreamConnection) === null || _this35$mediaProperti9 === void 0 ? void 0 : (_this35$mediaProperti10 = _this35$mediaProperti9.pc) === null || _this35$mediaProperti10 === void 0 ? void 0 : (_this35$mediaProperti11 = _this35$mediaProperti10.pc) === null || _this35$mediaProperti11 === void 0 ? void 0 : _this35$mediaProperti11.connectionState) || ((_this35$mediaProperti12 = _this35.mediaProperties.webrtcMediaConnection) === null || _this35$mediaProperti12 === void 0 ? void 0 : (_this35$mediaProperti13 = _this35$mediaProperti12.mediaConnection) === null || _this35$mediaProperti13 === void 0 ? void 0 : (_this35$mediaProperti14 = _this35$mediaProperti13.pc) === null || _this35$mediaProperti14 === void 0 ? void 0 : _this35$mediaProperti14.connectionState) || 'unknown',
4891
+ iceConnectionState: ((_this35$mediaProperti15 = _this35.mediaProperties.webrtcMediaConnection) === null || _this35$mediaProperti15 === void 0 ? void 0 : (_this35$mediaProperti16 = _this35$mediaProperti15.multistreamConnection) === null || _this35$mediaProperti16 === void 0 ? void 0 : (_this35$mediaProperti17 = _this35$mediaProperti16.pc) === null || _this35$mediaProperti17 === void 0 ? void 0 : (_this35$mediaProperti18 = _this35$mediaProperti17.pc) === null || _this35$mediaProperti18 === void 0 ? void 0 : _this35$mediaProperti18.iceConnectionState) || ((_this35$mediaProperti19 = _this35.mediaProperties.webrtcMediaConnection) === null || _this35$mediaProperti19 === void 0 ? void 0 : (_this35$mediaProperti20 = _this35$mediaProperti19.mediaConnection) === null || _this35$mediaProperti20 === void 0 ? void 0 : (_this35$mediaProperti21 = _this35$mediaProperti20.pc) === null || _this35$mediaProperti21 === void 0 ? void 0 : _this35$mediaProperti21.iceConnectionState) || 'unknown'
5355
4892
  });
5356
4893
 
5357
4894
  // Clean up stats analyzer, peer connection, and turn off listeners
5358
- var stopStatsAnalyzer = _this41.statsAnalyzer ? _this41.statsAnalyzer.stopAnalyzer() : _promise.default.resolve();
4895
+ var stopStatsAnalyzer = _this35.statsAnalyzer ? _this35.statsAnalyzer.stopAnalyzer() : _promise.default.resolve();
5359
4896
  return stopStatsAnalyzer.then(function () {
5360
- _this41.statsAnalyzer = null;
5361
- if (_this41.mediaProperties.webrtcMediaConnection) {
5362
- _this41.closePeerConnections();
5363
- _this41.unsetPeerConnections();
4897
+ _this35.statsAnalyzer = null;
4898
+ if (_this35.mediaProperties.webrtcMediaConnection) {
4899
+ _this35.closePeerConnections();
4900
+ _this35.unsetPeerConnections();
5364
4901
  }
5365
4902
  _loggerProxy.default.logger.error("".concat(LOG_HEADER, " Error adding media failed to initiate PC and send request, "), error);
5366
4903
 
5367
4904
  // Upload logs on error while adding media
5368
- _triggerProxy.default.trigger(_this41, {
4905
+ _triggerProxy.default.trigger(_this35, {
5369
4906
  file: 'meeting/index',
5370
4907
  function: 'addMedia'
5371
- }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this41);
4908
+ }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this35);
5372
4909
  if (error instanceof _internalMediaCore.Errors.SdpError) {
5373
- _this41.leave({
4910
+ _this35.leave({
5374
4911
  reason: _constants.MEETING_REMOVED_REASON.MEETING_CONNECTION_FAILED
5375
4912
  });
5376
4913
  }
@@ -5403,7 +4940,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5403
4940
  }, {
5404
4941
  key: "enqueueMediaUpdate",
5405
4942
  value: function enqueueMediaUpdate(mediaUpdateType, options) {
5406
- var _this42 = this;
4943
+ var _this36 = this;
5407
4944
  if (mediaUpdateType === MEDIA_UPDATE_TYPE.LAMBDA && typeof (options === null || options === void 0 ? void 0 : options.lambda) !== 'function') {
5408
4945
  return _promise.default.reject(new Error('lambda must be specified when enqueuing MEDIA_UPDATE_TYPE.LAMBDA'));
5409
4946
  }
@@ -5416,9 +4953,9 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5416
4953
  options: options
5417
4954
  };
5418
4955
  _loggerProxy.default.logger.log("Meeting:index#enqueueMediaUpdate --> enqueuing media update type=".concat(mediaUpdateType));
5419
- _this42.queuedMediaUpdates.push(queueItem);
4956
+ _this36.queuedMediaUpdates.push(queueItem);
5420
4957
  if (canUpdateMediaNow) {
5421
- _this42.processNextQueuedMediaUpdate();
4958
+ _this36.processNextQueuedMediaUpdate();
5422
4959
  }
5423
4960
  });
5424
4961
  }
@@ -5433,367 +4970,93 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5433
4970
  key: "updateMedia",
5434
4971
  value:
5435
4972
  /**
5436
- * A confluence of updateAudio, updateVideo, and updateShare
5437
- * this function re-establishes all of the media streams with new options
5438
- * @param {Object} options
5439
- * @param {MediaStream} options.localStream
5440
- * @param {MediaStream} options.localShare
5441
- * @param {MediaDirection} options.mediaSettings
5442
- * @returns {Promise}
5443
- * @public
5444
- * @memberof Meeting
5445
- */
5446
- function updateMedia() {
5447
- var _this43 = this;
5448
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5449
- var LOG_HEADER = 'Meeting:index#updateMedia -->';
5450
- if (!this.canUpdateMedia()) {
5451
- return this.enqueueMediaUpdate(MEDIA_UPDATE_TYPE.ALL, options);
5452
- }
5453
- if (this.isMultistream) {
5454
- var _options$mediaSetting, _options$mediaSetting2;
5455
- var audioEnabled = ((_options$mediaSetting = options.mediaSettings) === null || _options$mediaSetting === void 0 ? void 0 : _options$mediaSetting.sendAudio) || ((_options$mediaSetting2 = options.mediaSettings) === null || _options$mediaSetting2 === void 0 ? void 0 : _options$mediaSetting2.receiveAudio);
5456
- return this.mediaProperties.webrtcMediaConnection.enableMultistreamAudio(audioEnabled);
5457
- }
5458
- var localStream = options.localStream,
5459
- localShare = options.localShare,
5460
- mediaSettings = options.mediaSettings;
5461
- var previousSendShareStatus = this.mediaProperties.mediaDirection.sendShare;
5462
- if (!this.mediaProperties.webrtcMediaConnection) {
5463
- return _promise.default.reject(new Error('media connection not established, call addMedia() first'));
5464
- }
5465
- return _util.default.validateOptions(options).then(function () {
5466
- return _this43.preMedia(localStream, localShare, mediaSettings);
5467
- }).then(function () {
5468
- return _this43.mediaProperties.webrtcMediaConnection.update({
5469
- localTracks: {
5470
- audio: _this43.mediaProperties.mediaDirection.sendAudio ? _this43.mediaProperties.audioTrack.underlyingTrack : null,
5471
- video: _this43.mediaProperties.mediaDirection.sendVideo ? _this43.mediaProperties.videoTrack.underlyingTrack : null,
5472
- screenShareVideo: _this43.mediaProperties.mediaDirection.sendShare ? _this43.mediaProperties.shareTrack.underlyingTrack : null
5473
- },
5474
- direction: {
5475
- audio: _media.default.getDirection(_this43.mediaProperties.mediaDirection.receiveAudio, _this43.mediaProperties.mediaDirection.sendAudio),
5476
- video: _media.default.getDirection(_this43.mediaProperties.mediaDirection.receiveVideo, _this43.mediaProperties.mediaDirection.sendVideo),
5477
- screenShareVideo: _media.default.getDirection(_this43.mediaProperties.mediaDirection.receiveShare, _this43.mediaProperties.mediaDirection.sendShare)
5478
- },
5479
- remoteQualityLevel: _this43.mediaProperties.remoteQualityLevel
5480
- }).then(function () {
5481
- _loggerProxy.default.logger.info("".concat(LOG_HEADER, " webrtcMediaConnection.update done"));
5482
- }).catch(function (error) {
5483
- _loggerProxy.default.logger.error("".concat(LOG_HEADER, " Error updatedMedia, "), error);
5484
- _metrics.default.sendBehavioralMetric(_constants2.default.UPDATE_MEDIA_FAILURE, {
5485
- correlation_id: _this43.correlationId,
5486
- locus_id: _this43.locusUrl.split('/').pop(),
5487
- reason: error.message,
5488
- stack: error.stack
5489
- });
5490
- throw error;
5491
- })
5492
- // todo: the following code used to be called always after sending the roap message with the new SDP
5493
- // now it's called independently from the roap message (so might be before it), check if that's OK
5494
- // if not, ensure it's called after (now it's called after roap message is sent out, but we're not
5495
- // waiting for sendRoapMediaRequest() to be resolved)
5496
- .then(function () {
5497
- return _this43.enqueueMediaUpdate(MEDIA_UPDATE_TYPE.LAMBDA, {
5498
- lambda: function lambda() {
5499
- return _promise.default.resolve().then(function () {
5500
- return _this43.checkForStopShare(mediaSettings.sendShare, previousSendShareStatus);
5501
- }).then(function (startShare) {
5502
- // This is a special case if we do an /floor grant followed by /media
5503
- // we actually get a OFFER from the server and a GLAR condition happens
5504
- if (startShare) {
5505
- // We are assuming that the clients are connected when doing an update
5506
- return _this43.requestScreenShareFloor();
5507
- }
5508
- return _promise.default.resolve();
5509
- });
5510
- }
5511
- });
5512
- });
5513
- });
5514
- }
5515
-
5516
- /**
5517
- * Update the main audio track with new parameters
5518
- *
5519
- * NOTE: this method can only be used with transcoded meetings, for multistream meetings use publishTrack()
4973
+ * Updates the media connection - it allows to enable/disable all audio/video/share in the meeting.
4974
+ * This does not affect the published tracks, so for example if a microphone track is published and
4975
+ * updateMedia({audioEnabled: false}) is called, the audio will not be sent or received anymore,
4976
+ * but the track's "published" state is not changed and when updateMedia({audioEnabled: true}) is called,
4977
+ * the sending of the audio from the same track will resume.
5520
4978
  *
5521
4979
  * @param {Object} options
5522
- * @param {boolean} options.sendAudio
5523
- * @param {boolean} options.receiveAudio
5524
- * @param {MediaStream} options.stream Stream that contains the audio track to update
4980
+ * @param {boolean} options.audioEnabled [optional] enables/disables receiving and sending of main audio in the meeting
4981
+ * @param {boolean} options.videoEnabled [optional] enables/disables receiving and sending of main video in the meeting
4982
+ * @param {boolean} options.shareEnabled [optional] enables/disables receiving and sending of screen share in the meeting
5525
4983
  * @returns {Promise}
5526
4984
  * @public
5527
4985
  * @memberof Meeting
5528
4986
  */
5529
- }, {
5530
- key: "updateAudio",
5531
- value: function () {
5532
- var _updateAudio = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(options) {
5533
- var _this44 = this;
5534
- var sendAudio, receiveAudio, stream, track;
5535
- return _regenerator.default.wrap(function _callee9$(_context9) {
5536
- while (1) switch (_context9.prev = _context9.next) {
4987
+ function () {
4988
+ var _updateMedia = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16(options) {
4989
+ var audioEnabled, videoEnabled, receiveShare;
4990
+ return _regenerator.default.wrap(function _callee16$(_context16) {
4991
+ while (1) switch (_context16.prev = _context16.next) {
5537
4992
  case 0:
5538
- if (!this.isMultistream) {
5539
- _context9.next = 2;
4993
+ this.checkMediaConnection();
4994
+ audioEnabled = options.audioEnabled, videoEnabled = options.videoEnabled, receiveShare = options.receiveShare;
4995
+ _loggerProxy.default.logger.log("Meeting:index#updateMedia --> called with options=".concat((0, _stringify.default)(options)));
4996
+ if (this.canUpdateMedia()) {
4997
+ _context16.next = 5;
5540
4998
  break;
5541
4999
  }
5542
- throw new Error('updateAudio() is not supported with multistream, use publishTracks/unpublishTracks instead');
5543
- case 2:
5544
- if (this.canUpdateMedia()) {
5545
- _context9.next = 4;
5000
+ return _context16.abrupt("return", this.enqueueMediaUpdate(MEDIA_UPDATE_TYPE.UPDATE_MEDIA, options));
5001
+ case 5:
5002
+ if (!this.isMultistream) {
5003
+ _context16.next = 10;
5546
5004
  break;
5547
5005
  }
5548
- return _context9.abrupt("return", this.enqueueMediaUpdate(MEDIA_UPDATE_TYPE.AUDIO, options));
5549
- case 4:
5550
- sendAudio = options.sendAudio, receiveAudio = options.receiveAudio, stream = options.stream;
5551
- track = _util.default.getTrack(stream).audioTrack;
5552
- if (!(typeof sendAudio !== 'boolean' || typeof receiveAudio !== 'boolean')) {
5553
- _context9.next = 8;
5006
+ if (!(videoEnabled !== undefined)) {
5007
+ _context16.next = 8;
5554
5008
  break;
5555
5009
  }
5556
- return _context9.abrupt("return", _promise.default.reject(new _parameter.default('Pass sendAudio and receiveAudio parameter')));
5010
+ throw new Error('enabling/disabling video in a meeting is not supported for multistream, it can only be done upfront when calling addMedia()');
5557
5011
  case 8:
5558
- if (this.mediaProperties.webrtcMediaConnection) {
5559
- _context9.next = 10;
5012
+ if (!(receiveShare !== undefined)) {
5013
+ _context16.next = 10;
5560
5014
  break;
5561
5015
  }
5562
- return _context9.abrupt("return", _promise.default.reject(new Error('media connection not established, call addMedia() first')));
5016
+ throw new Error('toggling receiveShare in a multistream meeting is not supported, to control receiving screen share call meeting.remoteMediaManager.setLayout() with appropriate layout');
5563
5017
  case 10:
5564
- return _context9.abrupt("return", _util.default.validateOptions({
5565
- sendAudio: sendAudio,
5566
- localStream: stream
5567
- }).then(function () {
5568
- return _this44.mediaProperties.webrtcMediaConnection.update({
5569
- localTracks: {
5570
- audio: track
5571
- },
5572
- direction: {
5573
- audio: _media.default.getDirection(receiveAudio, sendAudio),
5574
- video: _media.default.getDirection(_this44.mediaProperties.mediaDirection.receiveVideo, _this44.mediaProperties.mediaDirection.sendVideo),
5575
- screenShareVideo: _media.default.getDirection(_this44.mediaProperties.mediaDirection.receiveShare, _this44.mediaProperties.mediaDirection.sendShare)
5576
- },
5577
- remoteQualityLevel: _this44.mediaProperties.remoteQualityLevel
5578
- });
5579
- }).then(function () {
5580
- _this44.setLocalAudioTrack(track);
5581
- // todo: maybe this.mediaProperties.mediaDirection could be removed? it's duplicating stuff from webrtcMediaConnection
5582
- _this44.mediaProperties.mediaDirection.sendAudio = sendAudio;
5583
- _this44.mediaProperties.mediaDirection.receiveAudio = receiveAudio;
5584
-
5585
- // audio state could be undefined if you have not sent audio before
5586
- _this44.audio = _this44.audio || (0, _muteState.createMuteState)(_constants.AUDIO, _this44, _this44.mediaProperties.mediaDirection, true);
5587
- }));
5588
- case 11:
5589
- case "end":
5590
- return _context9.stop();
5591
- }
5592
- }, _callee9, this);
5593
- }));
5594
- function updateAudio(_x5) {
5595
- return _updateAudio.apply(this, arguments);
5596
- }
5597
- return updateAudio;
5598
- }()
5599
- /**
5600
- * Update the main video track with new parameters
5601
- *
5602
- * NOTE: this method can only be used with transcoded meetings, for multistream meetings use publishTrack()
5603
- *
5604
- * @param {Object} options
5605
- * @param {boolean} options.sendVideo
5606
- * @param {boolean} options.receiveVideo
5607
- * @param {MediaStream} options.stream Stream that contains the video track to update
5608
- * @returns {Promise}
5609
- * @public
5610
- * @memberof Meeting
5611
- */
5612
- }, {
5613
- key: "updateVideo",
5614
- value: function updateVideo(options) {
5615
- var _this45 = this;
5616
- if (this.isMultistream) {
5617
- throw new Error('updateVideo() is not supported with multistream, use publishTracks/unpublishTracks instead');
5618
- }
5619
- if (!this.canUpdateMedia()) {
5620
- return this.enqueueMediaUpdate(MEDIA_UPDATE_TYPE.VIDEO, options);
5621
- }
5622
- var sendVideo = options.sendVideo,
5623
- receiveVideo = options.receiveVideo,
5624
- stream = options.stream;
5625
- var track = _util.default.getTrack(stream).videoTrack;
5626
- if (typeof sendVideo !== 'boolean' || typeof receiveVideo !== 'boolean') {
5627
- return _promise.default.reject(new _parameter.default('Pass sendVideo and receiveVideo parameter'));
5628
- }
5629
- if (!this.mediaProperties.webrtcMediaConnection) {
5630
- return _promise.default.reject(new Error('media connection not established, call addMedia() first'));
5631
- }
5632
- return _util.default.validateOptions({
5633
- sendVideo: sendVideo,
5634
- localStream: stream
5635
- }).then(function () {
5636
- return _this45.mediaProperties.webrtcMediaConnection.update({
5637
- localTracks: {
5638
- video: track
5639
- },
5640
- direction: {
5641
- audio: _media.default.getDirection(_this45.mediaProperties.mediaDirection.receiveAudio, _this45.mediaProperties.mediaDirection.sendAudio),
5642
- video: _media.default.getDirection(receiveVideo, sendVideo),
5643
- screenShareVideo: _media.default.getDirection(_this45.mediaProperties.mediaDirection.receiveShare, _this45.mediaProperties.mediaDirection.sendShare)
5644
- },
5645
- remoteQualityLevel: _this45.mediaProperties.remoteQualityLevel
5646
- });
5647
- }).then(function () {
5648
- _this45.setLocalVideoTrack(track);
5649
- _this45.mediaProperties.mediaDirection.sendVideo = sendVideo;
5650
- _this45.mediaProperties.mediaDirection.receiveVideo = receiveVideo;
5651
-
5652
- // video state could be undefined if you have not sent video before
5653
- _this45.video = _this45.video || (0, _muteState.createMuteState)(_constants.VIDEO, _this45, _this45.mediaProperties.mediaDirection, true);
5654
- });
5655
- }
5656
-
5657
- /**
5658
- * Internal function when stopping a share stream, cleanup
5659
- * @param {boolean} sendShare
5660
- * @param {boolean} previousShareStatus
5661
- * @returns {Promise}
5662
- * @private
5663
- * @memberof Meeting
5664
- */
5665
- }, {
5666
- key: "checkForStopShare",
5667
- value: function checkForStopShare(sendShare, previousShareStatus) {
5668
- if (sendShare && !previousShareStatus) {
5669
- // When user starts sharing
5670
- return _promise.default.resolve(true);
5671
- }
5672
- if (!sendShare && previousShareStatus) {
5673
- // When user stops sharing
5674
- return this.releaseScreenShareFloor().then(function () {
5675
- return _promise.default.resolve(false);
5676
- });
5677
- }
5678
- return _promise.default.resolve();
5679
- }
5680
-
5681
- /**
5682
- * Update the share streams, can be used to start sharing
5683
- *
5684
- * NOTE: this method can only be used with transcoded meetings, for multistream meetings use publishTrack()
5685
- *
5686
- * @param {Object} options
5687
- * @param {boolean} options.sendShare
5688
- * @param {boolean} options.receiveShare
5689
- * @returns {Promise}
5690
- * @public
5691
- * @memberof Meeting
5692
- */
5693
- }, {
5694
- key: "updateShare",
5695
- value: function updateShare(options) {
5696
- var _this46 = this;
5697
- if (this.isMultistream) {
5698
- throw new Error('updateShare() is not supported with multistream, use publishTracks/unpublishTracks instead');
5699
- }
5700
- if (!options.skipSignalingCheck && !this.canUpdateMedia()) {
5701
- return this.enqueueMediaUpdate(MEDIA_UPDATE_TYPE.SHARE, options);
5702
- }
5703
- var sendShare = options.sendShare,
5704
- receiveShare = options.receiveShare,
5705
- stream = options.stream;
5706
- var track = _util.default.getTrack(stream).videoTrack;
5707
- if (typeof sendShare !== 'boolean' || typeof receiveShare !== 'boolean') {
5708
- return _promise.default.reject(new _parameter.default('Pass sendShare and receiveShare parameter'));
5709
- }
5710
- if (!this.mediaProperties.webrtcMediaConnection) {
5711
- return _promise.default.reject(new Error('media connection not established, call addMedia() first'));
5712
- }
5713
- var previousSendShareStatus = this.mediaProperties.mediaDirection.sendShare;
5714
- this.setLocalShareTrack(track);
5715
- return _util.default.validateOptions({
5716
- sendShare: sendShare,
5717
- localShare: stream
5718
- }).then(function () {
5719
- return _this46.checkForStopShare(sendShare, previousSendShareStatus);
5720
- }).then(function (startShare) {
5721
- return _this46.mediaProperties.webrtcMediaConnection.update({
5722
- localTracks: {
5723
- screenShareVideo: track
5724
- },
5725
- direction: {
5726
- audio: _media.default.getDirection(_this46.mediaProperties.mediaDirection.receiveAudio, _this46.mediaProperties.mediaDirection.sendAudio),
5727
- video: _media.default.getDirection(_this46.mediaProperties.mediaDirection.receiveVideo, _this46.mediaProperties.mediaDirection.sendVideo),
5728
- screenShareVideo: _media.default.getDirection(receiveShare, sendShare)
5729
- },
5730
- remoteQualityLevel: _this46.mediaProperties.remoteQualityLevel
5731
- }).then(function () {
5732
- return _this46.enqueueMediaUpdate(MEDIA_UPDATE_TYPE.LAMBDA, {
5733
- lambda: function () {
5734
- var _lambda = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
5735
- return _regenerator.default.wrap(function _callee10$(_context10) {
5736
- while (1) switch (_context10.prev = _context10.next) {
5737
- case 0:
5738
- if (!startShare) {
5739
- _context10.next = 2;
5740
- break;
5741
- }
5742
- return _context10.abrupt("return", _this46.requestScreenShareFloor());
5743
- case 2:
5744
- return _context10.abrupt("return", undefined);
5745
- case 3:
5746
- case "end":
5747
- return _context10.stop();
5748
- }
5749
- }, _callee10);
5750
- }));
5751
- function lambda() {
5752
- return _lambda.apply(this, arguments);
5018
+ if (audioEnabled !== undefined) {
5019
+ this.mediaProperties.mediaDirection.sendAudio = audioEnabled;
5020
+ this.mediaProperties.mediaDirection.receiveAudio = audioEnabled;
5021
+ this.audio.enable(this, audioEnabled);
5022
+ }
5023
+ if (videoEnabled !== undefined) {
5024
+ this.mediaProperties.mediaDirection.sendVideo = videoEnabled;
5025
+ this.mediaProperties.mediaDirection.receiveVideo = videoEnabled;
5026
+ this.video.enable(this, videoEnabled);
5027
+ }
5028
+ if (receiveShare !== undefined) {
5029
+ this.mediaProperties.mediaDirection.receiveShare = receiveShare;
5030
+ }
5031
+ if (!this.isMultistream) {
5032
+ _context16.next = 19;
5033
+ break;
5753
5034
  }
5754
- return lambda;
5755
- }()
5756
- });
5757
- });
5758
- }).then(function () {
5759
- _this46.mediaProperties.mediaDirection.sendShare = sendShare;
5760
- _this46.mediaProperties.mediaDirection.receiveShare = receiveShare;
5761
- }).catch(function (error) {
5762
- _this46.unsetLocalShareTrack();
5763
- throw error;
5764
- });
5765
- }
5766
-
5767
- /**
5768
- * Do all the attach media pre set up before executing the actual attach
5769
- * @param {MediaStream} localStream
5770
- * @param {MediaStream} localShare
5771
- * @param {MediaDirection} mediaSettings
5772
- * @returns {undefined}
5773
- * @private
5774
- * @memberof Meeting
5775
- */
5776
- }, {
5777
- key: "preMedia",
5778
- value: function preMedia(localStream, localShare, mediaSettings) {
5779
- // eslint-disable-next-line no-warning-comments
5780
- // TODO wire into default config. There's currently an issue with the stateless plugin or how we register
5781
- // @ts-ignore - config coming from registerPlugin
5782
- this.mediaProperties.setMediaDirection((0, _assign.default)(this.config.mediaSettings, mediaSettings));
5783
-
5784
- // for multistream, this.audio and this.video are created when publishTracks() is called
5785
- if (!this.isMultistream) {
5786
- this.audio = this.audio || (0, _muteState.createMuteState)(_constants.AUDIO, this, this.mediaProperties.mediaDirection, true);
5787
- this.video = this.video || (0, _muteState.createMuteState)(_constants.VIDEO, this, this.mediaProperties.mediaDirection, true);
5788
- }
5789
- // Validation is already done in addMedia so no need to check if the lenght is greater then 0
5790
- this.setLocalTracks(localStream);
5791
- if (this.isMultistream && localShare) {
5792
- throw new Error('calling addMedia() with localShare stream is not supported when using multistream');
5035
+ if (!(audioEnabled !== undefined)) {
5036
+ _context16.next = 17;
5037
+ break;
5038
+ }
5039
+ _context16.next = 17;
5040
+ return this.mediaProperties.webrtcMediaConnection.enableMultistreamAudio(audioEnabled);
5041
+ case 17:
5042
+ _context16.next = 21;
5043
+ break;
5044
+ case 19:
5045
+ _context16.next = 21;
5046
+ return this.updateTranscodedMediaConnection();
5047
+ case 21:
5048
+ return _context16.abrupt("return", undefined);
5049
+ case 22:
5050
+ case "end":
5051
+ return _context16.stop();
5052
+ }
5053
+ }, _callee16, this);
5054
+ }));
5055
+ function updateMedia(_x12) {
5056
+ return _updateMedia.apply(this, arguments);
5793
5057
  }
5794
- this.setLocalShareTrack(_util.default.getTrack(localShare).videoTrack);
5795
- }
5796
-
5058
+ return updateMedia;
5059
+ }()
5797
5060
  /**
5798
5061
  * Acknowledge the meeting, outgoing or incoming
5799
5062
  * @param {String} type
@@ -5804,7 +5067,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5804
5067
  }, {
5805
5068
  key: "acknowledge",
5806
5069
  value: function acknowledge(type) {
5807
- var _this47 = this;
5070
+ var _this37 = this;
5808
5071
  if (!type) {
5809
5072
  return _promise.default.reject(new _parameter.default('Type must be set to acknowledge the meeting.'));
5810
5073
  }
@@ -5816,10 +5079,10 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5816
5079
  }).then(function (response) {
5817
5080
  return _promise.default.resolve(response);
5818
5081
  }).then(function (response) {
5819
- _this47.meetingFiniteStateMachine.ring(type);
5082
+ _this37.meetingFiniteStateMachine.ring(type);
5820
5083
  _metrics.default.postEvent({
5821
5084
  event: _config.eventType.ALERT_DISPLAYED,
5822
- meeting: _this47
5085
+ meeting: _this37
5823
5086
  });
5824
5087
  return _promise.default.resolve({
5825
5088
  response: response
@@ -5843,12 +5106,12 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5843
5106
  }, {
5844
5107
  key: "decline",
5845
5108
  value: function decline(reason) {
5846
- var _this48 = this;
5109
+ var _this38 = this;
5847
5110
  return _util.default.declineMeeting(this, reason).then(function (decline) {
5848
- _this48.meetingFiniteStateMachine.decline();
5111
+ _this38.meetingFiniteStateMachine.decline();
5849
5112
  return _promise.default.resolve(decline);
5850
5113
  }).catch(function (error) {
5851
- _this48.meetingFiniteStateMachine.fail(error);
5114
+ _this38.meetingFiniteStateMachine.fail(error);
5852
5115
  return _promise.default.reject(error);
5853
5116
  });
5854
5117
  }
@@ -5864,7 +5127,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5864
5127
  }, {
5865
5128
  key: "leave",
5866
5129
  value: function leave() {
5867
- var _this49 = this;
5130
+ var _this39 = this;
5868
5131
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5869
5132
  var leaveReason = options.reason || _constants.MEETING_REMOVED_REASON.CLIENT_LEAVE_REQUEST;
5870
5133
  _metrics.default.postEvent({
@@ -5878,39 +5141,39 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5878
5141
  });
5879
5142
  _loggerProxy.default.logger.log('Meeting:index#leave --> Leaving a meeting');
5880
5143
  return _util.default.leaveMeeting(this, options).then(function (leave) {
5881
- _this49.meetingFiniteStateMachine.leave();
5882
- _this49.clearMeetingData();
5144
+ _this39.meetingFiniteStateMachine.leave();
5145
+ _this39.clearMeetingData();
5883
5146
 
5884
5147
  // upload logs on leave irrespective of meeting delete
5885
- _triggerProxy.default.trigger(_this49, {
5148
+ _triggerProxy.default.trigger(_this39, {
5886
5149
  file: 'meeting/index',
5887
5150
  function: 'leave'
5888
- }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this49);
5151
+ }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this39);
5889
5152
 
5890
5153
  // TODO: more testing before we remove this code, we are not sure the scenarios for destroy here
5891
- if (_this49.wirelessShare || _this49.guest) {
5154
+ if (_this39.wirelessShare || _this39.guest) {
5892
5155
  // If screen sharing clean the meeting object
5893
- _triggerProxy.default.trigger(_this49, {
5156
+ _triggerProxy.default.trigger(_this39, {
5894
5157
  file: 'meeting/index',
5895
5158
  function: 'leave'
5896
5159
  }, _constants.EVENTS.DESTROY_MEETING, {
5897
5160
  reason: options.reason,
5898
- meetingId: _this49.id
5161
+ meetingId: _this39.id
5899
5162
  });
5900
5163
  }
5901
5164
  _loggerProxy.default.logger.log('Meeting:index#leave --> LEAVE REASON ', leaveReason);
5902
5165
  return leave;
5903
5166
  }).catch(function (error) {
5904
- _this49.meetingFiniteStateMachine.fail(error);
5167
+ _this39.meetingFiniteStateMachine.fail(error);
5905
5168
  _loggerProxy.default.logger.error('Meeting:index#leave --> Failed to leave ', error);
5906
5169
  // upload logs on leave irrespective of meeting delete
5907
- _triggerProxy.default.trigger(_this49, {
5170
+ _triggerProxy.default.trigger(_this39, {
5908
5171
  file: 'meeting/index',
5909
5172
  function: 'leave'
5910
- }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this49);
5173
+ }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this39);
5911
5174
  _metrics.default.sendBehavioralMetric(_constants2.default.MEETING_LEAVE_FAILURE, {
5912
- correlation_id: _this49.correlationId,
5913
- locus_id: _this49.locusUrl.split('/').pop(),
5175
+ correlation_id: _this39.correlationId,
5176
+ locus_id: _this39.locusUrl.split('/').pop(),
5914
5177
  reason: error.message,
5915
5178
  stack: error.stack,
5916
5179
  code: error.code
@@ -5930,7 +5193,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5930
5193
  }, {
5931
5194
  key: "startWhiteboardShare",
5932
5195
  value: function startWhiteboardShare(channelUrl, resourceToken) {
5933
- var _this50 = this;
5196
+ var _this40 = this;
5934
5197
  var whiteboard = this.locusInfo.mediaShares.find(function (element) {
5935
5198
  return element.name === 'whiteboard';
5936
5199
  });
@@ -5953,13 +5216,13 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5953
5216
  body.resourceToken = resourceToken;
5954
5217
  }
5955
5218
  return this.meetingRequest.changeMeetingFloor(body).then(function () {
5956
- _this50.isSharing = false;
5219
+ _this40.isSharing = false;
5957
5220
  return _promise.default.resolve();
5958
5221
  }).catch(function (error) {
5959
5222
  _loggerProxy.default.logger.error('Meeting:index#startWhiteboardShare --> Error ', error);
5960
5223
  _metrics.default.sendBehavioralMetric(_constants2.default.MEETING_START_WHITEBOARD_SHARE_FAILURE, {
5961
- correlation_id: _this50.correlationId,
5962
- locus_id: _this50.locusUrl.split('/').pop(),
5224
+ correlation_id: _this40.correlationId,
5225
+ locus_id: _this40.locusUrl.split('/').pop(),
5963
5226
  reason: error.message,
5964
5227
  stack: error.stack,
5965
5228
  board: {
@@ -5982,7 +5245,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5982
5245
  }, {
5983
5246
  key: "stopWhiteboardShare",
5984
5247
  value: function stopWhiteboardShare(channelUrl) {
5985
- var _this51 = this;
5248
+ var _this41 = this;
5986
5249
  var whiteboard = this.locusInfo.mediaShares.find(function (element) {
5987
5250
  return element.name === 'whiteboard';
5988
5251
  });
@@ -6001,8 +5264,8 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6001
5264
  _metrics.default.sendBehavioralMetric(
6002
5265
  // @ts-ignore - check if STOP_WHITEBOARD_SHARE_FAILURE exists
6003
5266
  _constants2.default.STOP_WHITEBOARD_SHARE_FAILURE, {
6004
- correlation_id: _this51.correlationId,
6005
- locus_id: _this51.locusUrl.split('/').pop(),
5267
+ correlation_id: _this41.correlationId,
5268
+ locus_id: _this41.locusUrl.split('/').pop(),
6006
5269
  reason: error.message,
6007
5270
  stack: error.stack,
6008
5271
  board: {
@@ -6024,55 +5287,62 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6024
5287
  }, {
6025
5288
  key: "requestScreenShareFloor",
6026
5289
  value: function requestScreenShareFloor() {
6027
- var _this52 = this;
6028
- var content = this.locusInfo.mediaShares.find(function (element) {
6029
- return element.name === _constants.CONTENT;
6030
- });
6031
- if (content && this.shareStatus !== _constants.SHARE_STATUS.LOCAL_SHARE_ACTIVE) {
6032
- _metrics.default.postEvent({
6033
- event: _config.eventType.SHARE_INITIATED,
6034
- meeting: this
5290
+ var _this42 = this;
5291
+ if (!this.mediaProperties.shareTrack || !this.mediaProperties.mediaDirection.sendShare) {
5292
+ _loggerProxy.default.logger.log("Meeting:index#requestScreenShareFloor --> NOT requesting floor, because we don't have the share track anymore (shareTrack=".concat(this.mediaProperties.shareTrack ? 'yes' : 'no', ", sendShare=").concat(this.mediaProperties.mediaDirection.sendShare, ")"));
5293
+ return _promise.default.resolve({});
5294
+ }
5295
+ if (this.state === _constants.MEETING_STATE.STATES.JOINED) {
5296
+ var content = this.locusInfo.mediaShares.find(function (element) {
5297
+ return element.name === _constants.CONTENT;
6035
5298
  });
6036
- return this.meetingRequest.changeMeetingFloor({
6037
- disposition: _constants.FLOOR_ACTION.GRANTED,
6038
- personUrl: this.locusInfo.self.url,
6039
- deviceUrl: this.deviceUrl,
6040
- uri: content.url,
6041
- resourceUrl: this.resourceUrl,
6042
- annotationInfo: this.annotationInfo
6043
- }).then(function () {
6044
- _this52.isSharing = true;
6045
- return _promise.default.resolve();
6046
- }).catch(function (error) {
6047
- _loggerProxy.default.logger.error('Meeting:index#share --> Error ', error);
6048
- _metrics.default.sendBehavioralMetric(_constants2.default.MEETING_SHARE_FAILURE, {
6049
- correlation_id: _this52.correlationId,
6050
- locus_id: _this52.locusUrl.split('/').pop(),
6051
- reason: error.message,
6052
- stack: error.stack
5299
+ if (content && this.shareStatus !== _constants.SHARE_STATUS.LOCAL_SHARE_ACTIVE) {
5300
+ _metrics.default.postEvent({
5301
+ event: _config.eventType.SHARE_INITIATED,
5302
+ meeting: this
6053
5303
  });
6054
- return _promise.default.reject(error);
6055
- });
5304
+ return this.meetingRequest.changeMeetingFloor({
5305
+ disposition: _constants.FLOOR_ACTION.GRANTED,
5306
+ personUrl: this.locusInfo.self.url,
5307
+ deviceUrl: this.deviceUrl,
5308
+ uri: content.url,
5309
+ resourceUrl: this.resourceUrl,
5310
+ annotationInfo: this.annotationInfo
5311
+ }).then(function () {
5312
+ _this42.isSharing = true;
5313
+ return _promise.default.resolve();
5314
+ }).catch(function (error) {
5315
+ _loggerProxy.default.logger.error('Meeting:index#share --> Error ', error);
5316
+ _metrics.default.sendBehavioralMetric(_constants2.default.MEETING_SHARE_FAILURE, {
5317
+ correlation_id: _this42.correlationId,
5318
+ locus_id: _this42.locusUrl.split('/').pop(),
5319
+ reason: error.message,
5320
+ stack: error.stack
5321
+ });
5322
+ return _promise.default.reject(error);
5323
+ });
5324
+ }
5325
+ return _promise.default.reject(new _parameter.default('Cannot share without content.'));
6056
5326
  }
6057
- return _promise.default.reject(new _parameter.default('Cannot share without content.'));
5327
+ this.floorGrantPending = true;
5328
+ return _promise.default.resolve({});
6058
5329
  }
6059
5330
 
6060
5331
  /**
6061
- * Stops the screen share
6062
- * @returns {Promise} see #updateShare
6063
- * @public
6064
- * @memberof Meeting
5332
+ * Requests screen share floor if such request is pending.
5333
+ * It should be called whenever meeting state changes to JOINED
5334
+ *
5335
+ * @returns {void}
6065
5336
  */
6066
- // Internal only, temporarily allows optional params
6067
- // eslint-disable-next-line valid-jsdoc
6068
5337
  }, {
6069
- key: "stopShare",
6070
- value: function stopShare() {
6071
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6072
- return this.updateShare(_objectSpread({
6073
- sendShare: false,
6074
- receiveShare: this.mediaProperties.mediaDirection.receiveShare
6075
- }, options));
5338
+ key: "requestScreenShareFloorIfPending",
5339
+ value: function requestScreenShareFloorIfPending() {
5340
+ var _this43 = this;
5341
+ if (this.floorGrantPending && this.state === _constants.MEETING_STATE.STATES.JOINED) {
5342
+ this.requestScreenShareFloor().then(function () {
5343
+ _this43.floorGrantPending = false;
5344
+ });
5345
+ }
6076
5346
  }
6077
5347
 
6078
5348
  /**
@@ -6084,16 +5354,17 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6084
5354
  }, {
6085
5355
  key: "releaseScreenShareFloor",
6086
5356
  value: function releaseScreenShareFloor() {
6087
- var _this53 = this;
5357
+ var _this44 = this;
6088
5358
  var content = this.locusInfo.mediaShares.find(function (element) {
6089
5359
  return element.name === _constants.CONTENT;
6090
5360
  });
6091
- if (content && this.mediaProperties.mediaDirection.sendShare) {
5361
+ if (content) {
5362
+ var _content$floor;
6092
5363
  _metrics.default.postEvent({
6093
5364
  event: _config.eventType.SHARE_STOPPED,
6094
5365
  meeting: this
6095
5366
  });
6096
- if (content.floor.beneficiary.id !== this.selfId) {
5367
+ if (((_content$floor = content.floor) === null || _content$floor === void 0 ? void 0 : _content$floor.beneficiary.id) !== this.selfId) {
6097
5368
  // remote participant started sharing and caused our sharing to stop, we don't want to send any floor action request in that case
6098
5369
  this.isSharing = false;
6099
5370
  return _promise.default.resolve();
@@ -6107,17 +5378,20 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6107
5378
  }).catch(function (error) {
6108
5379
  _loggerProxy.default.logger.error('Meeting:index#releaseScreenShareFloor --> Error ', error);
6109
5380
  _metrics.default.sendBehavioralMetric(_constants2.default.STOP_FLOOR_REQUEST_FAILURE, {
6110
- correlation_id: _this53.correlationId,
6111
- locus_id: _this53.locusUrl.split('/').pop(),
5381
+ correlation_id: _this44.correlationId,
5382
+ locus_id: _this44.locusUrl.split('/').pop(),
6112
5383
  reason: error.message,
6113
5384
  stack: error.stack
6114
5385
  });
6115
5386
  return _promise.default.reject(error);
6116
5387
  }).finally(function () {
6117
- _this53.isSharing = false;
5388
+ _this44.isSharing = false;
6118
5389
  });
6119
5390
  }
6120
- return _promise.default.reject(new _parameter.default('Cannot stop share without content'));
5391
+
5392
+ // according to Locus there is no content, so we don't need to release the floor (it's probably already been released)
5393
+ this.isSharing = false;
5394
+ return _promise.default.resolve();
6121
5395
  }
6122
5396
 
6123
5397
  /**
@@ -6287,14 +5561,14 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6287
5561
  }, {
6288
5562
  key: "changeVideoLayout",
6289
5563
  value: function changeVideoLayout(layoutType) {
6290
- var _this54 = this;
5564
+ var _this45 = this;
6291
5565
  var renderInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6292
5566
  var main = renderInfo.main,
6293
5567
  content = renderInfo.content;
6294
- var _this$mediaProperties7 = this.mediaProperties,
6295
- mediaDirection = _this$mediaProperties7.mediaDirection,
6296
- remoteShare = _this$mediaProperties7.remoteShare,
6297
- remoteVideoTrack = _this$mediaProperties7.remoteVideoTrack;
5568
+ var _this$mediaProperties4 = this.mediaProperties,
5569
+ mediaDirection = _this$mediaProperties4.mediaDirection,
5570
+ remoteShare = _this$mediaProperties4.remoteShare,
5571
+ remoteVideoTrack = _this$mediaProperties4.remoteVideoTrack;
6298
5572
  var layoutInfo = (0, _cloneDeep2.default)(this.lastVideoLayoutInfo);
6299
5573
 
6300
5574
  // TODO: We need a real time value for Audio, Video and Share send indicator
@@ -6341,7 +5615,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6341
5615
  }
6342
5616
  this.lastVideoLayoutInfo = (0, _cloneDeep2.default)(layoutInfo);
6343
5617
  this.locusInfo.once(_constants.LOCUSINFO.EVENTS.CONTROLS_MEETING_LAYOUT_UPDATED, function (envelope) {
6344
- _triggerProxy.default.trigger(_this54, {
5618
+ _triggerProxy.default.trigger(_this45, {
6345
5619
  file: 'meeting/index',
6346
5620
  function: 'changeVideoLayout'
6347
5621
  }, _constants.EVENT_TRIGGERS.MEETING_CONTROLS_LAYOUT_UPDATE, {
@@ -6360,69 +5634,6 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6360
5634
  });
6361
5635
  }
6362
5636
 
6363
- /**
6364
- * Sets the quality of the local video stream
6365
- * @param {String} level {LOW|MEDIUM|HIGH}
6366
- * @returns {Promise<MediaStream>} localStream
6367
- */
6368
- }, {
6369
- key: "setLocalVideoQuality",
6370
- value: function setLocalVideoQuality(level) {
6371
- var _this55 = this;
6372
- _loggerProxy.default.logger.log("Meeting:index#setLocalVideoQuality --> Setting quality to ".concat(level));
6373
- if (!_constants.VIDEO_RESOLUTIONS[level]) {
6374
- return this.rejectWithErrorLog("Meeting:index#setLocalVideoQuality --> ".concat(level, " not defined"));
6375
- }
6376
- if (!this.mediaProperties.mediaDirection.sendVideo) {
6377
- return this.rejectWithErrorLog('Meeting:index#setLocalVideoQuality --> unable to change video quality, sendVideo is disabled');
6378
- }
6379
-
6380
- // If level is already the same, don't do anything
6381
- if (level === this.mediaProperties.localQualityLevel) {
6382
- _loggerProxy.default.logger.warn("Meeting:index#setLocalQualityLevel --> Quality already set to ".concat(level));
6383
- return _promise.default.resolve();
6384
- }
6385
-
6386
- // Set the quality level in properties
6387
- this.mediaProperties.setLocalQualityLevel(level);
6388
- var mediaDirection = {
6389
- sendAudio: this.mediaProperties.mediaDirection.sendAudio,
6390
- sendVideo: this.mediaProperties.mediaDirection.sendVideo,
6391
- sendShare: this.mediaProperties.mediaDirection.sendShare
6392
- };
6393
-
6394
- // When changing local video quality level
6395
- // Need to stop current track first as chrome doesn't support resolution upscaling(for eg. changing 480p to 720p)
6396
- // Without feeding it a new track
6397
- // open bug link: https://bugs.chromium.org/p/chromium/issues/detail?id=943469
6398
- if (isBrowser('chrome') && this.mediaProperties.videoTrack) _media.default.stopTracks(this.mediaProperties.videoTrack);
6399
- return this.getMediaStreams(mediaDirection, _constants.VIDEO_RESOLUTIONS[level]).then( /*#__PURE__*/function () {
6400
- var _ref26 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(_ref25) {
6401
- var _ref27, localStream;
6402
- return _regenerator.default.wrap(function _callee11$(_context11) {
6403
- while (1) switch (_context11.prev = _context11.next) {
6404
- case 0:
6405
- _ref27 = (0, _slicedToArray2.default)(_ref25, 1), localStream = _ref27[0];
6406
- _context11.next = 3;
6407
- return _this55.updateVideo({
6408
- sendVideo: true,
6409
- receiveVideo: true,
6410
- stream: localStream
6411
- });
6412
- case 3:
6413
- return _context11.abrupt("return", localStream);
6414
- case 4:
6415
- case "end":
6416
- return _context11.stop();
6417
- }
6418
- }, _callee11);
6419
- }));
6420
- return function (_x6) {
6421
- return _ref26.apply(this, arguments);
6422
- };
6423
- }());
6424
- }
6425
-
6426
5637
  /**
6427
5638
  * Sets the quality level of the remote incoming media
6428
5639
  * @param {String} level {LOW|MEDIUM|HIGH}
@@ -6447,112 +5658,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6447
5658
 
6448
5659
  // Set the quality level in properties
6449
5660
  this.mediaProperties.setRemoteQualityLevel(level);
6450
- return this.updateMedia({
6451
- mediaSettings: this.mediaProperties.mediaDirection
6452
- });
6453
- }
6454
-
6455
- /**
6456
- * This is deprecated, please use setLocalVideoQuality for setting local and setRemoteQualityLevel for remote
6457
- * @param {String} level {LOW|MEDIUM|HIGH}
6458
- * @returns {Promise}
6459
- * @deprecated After FHD support
6460
- */
6461
- }, {
6462
- key: "setMeetingQuality",
6463
- value: function setMeetingQuality(level) {
6464
- var _this56 = this;
6465
- _loggerProxy.default.logger.log("Meeting:index#setMeetingQuality --> Setting quality to ".concat(level));
6466
- if (!_constants.QUALITY_LEVELS[level]) {
6467
- return this.rejectWithErrorLog("Meeting:index#setMeetingQuality --> ".concat(level, " not defined"));
6468
- }
6469
- var previousLevel = {
6470
- local: this.mediaProperties.localQualityLevel,
6471
- remote: this.mediaProperties.remoteQualityLevel
6472
- };
6473
-
6474
- // If level is already the same, don't do anything
6475
- if (level === this.mediaProperties.localQualityLevel && level === this.mediaProperties.remoteQualityLevel) {
6476
- _loggerProxy.default.logger.warn("Meeting:index#setMeetingQuality --> Quality already set to ".concat(level));
6477
- return _promise.default.resolve();
6478
- }
6479
-
6480
- // Determine the direction of our current media
6481
- var _this$mediaProperties8 = this.mediaProperties.mediaDirection,
6482
- receiveAudio = _this$mediaProperties8.receiveAudio,
6483
- receiveVideo = _this$mediaProperties8.receiveVideo,
6484
- sendVideo = _this$mediaProperties8.sendVideo;
6485
- return (sendVideo ? this.setLocalVideoQuality(level) : _promise.default.resolve()).then(function () {
6486
- return receiveAudio || receiveVideo ? _this56.setRemoteQualityLevel(level) : _promise.default.resolve();
6487
- }).catch(function (error) {
6488
- // From troubleshooting it seems that the stream itself doesn't change the max-fs if the peer connection isn't stable
6489
- _this56.mediaProperties.setLocalQualityLevel(previousLevel.local);
6490
- _this56.mediaProperties.setRemoteQualityLevel(previousLevel.remote);
6491
- _loggerProxy.default.logger.error("Meeting:index#setMeetingQuality --> ".concat(error.message));
6492
- _metrics.default.sendBehavioralMetric(_constants2.default.SET_MEETING_QUALITY_FAILURE, {
6493
- correlation_id: _this56.correlationId,
6494
- locus_id: _this56.locusUrl.split('/').pop(),
6495
- reason: error.message,
6496
- stack: error.stack
6497
- }, {
6498
- type: error.name
6499
- });
6500
- return _promise.default.reject(error);
6501
- });
6502
- }
6503
-
6504
- /**
6505
- *
6506
- * NOTE: this method can only be used with transcoded meetings, for multistream use publishTrack()
6507
- *
6508
- * @param {Object} options parameter
6509
- * @param {Boolean} options.sendAudio send audio from the display share
6510
- * @param {Boolean} options.sendShare send video from the display share
6511
- * @param {Object} options.sharePreferences
6512
- * @param {MediaTrackConstraints} options.sharePreferences.shareConstraints constraints to apply to video
6513
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints}
6514
- * @param {Boolean} options.sharePreferences.highFrameRate if shareConstraints isn't provided, set default values based off of this boolean
6515
- * @returns {Promise}
6516
- */
6517
- }, {
6518
- key: "shareScreen",
6519
- value: function shareScreen() {
6520
- var _this57 = this;
6521
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6522
- _loggerProxy.default.logger.log('Meeting:index#shareScreen --> Getting local share');
6523
- var shareConstraints = _objectSpread({
6524
- sendShare: true,
6525
- sendAudio: false
6526
- }, options);
6527
-
6528
- // @ts-ignore - config coming from registerPlugin
6529
- return _media.default.getDisplayMedia(shareConstraints, this.config).then(function (shareStream) {
6530
- return _this57.updateShare({
6531
- sendShare: true,
6532
- receiveShare: _this57.mediaProperties.mediaDirection.receiveShare,
6533
- stream: shareStream
6534
- });
6535
- }).catch(function (error) {
6536
- // Whenever there is a failure when trying to access a user's display
6537
- // report it as an Behavioral metric
6538
- // This gives visibility into common errors and can help
6539
- // with further troubleshooting
6540
-
6541
- // This metrics will get erros for getDisplayMedia and share errors for now
6542
- // TODO: The getDisplayMedia errors need to be moved inside `media.getDisplayMedia`
6543
- var metricName = _constants2.default.GET_DISPLAY_MEDIA_FAILURE;
6544
- var data = {
6545
- correlation_id: _this57.correlationId,
6546
- locus_id: _this57.locusUrl.split('/').pop(),
6547
- reason: error.message,
6548
- stack: error.stack
6549
- };
6550
- var metadata = {
6551
- type: error.name
6552
- };
6553
- _metrics.default.sendBehavioralMetric(metricName, data, metadata);
6554
- throw new _media2.default('Unable to retrieve display media stream', error);
6555
- });
5661
+ return this.updateTranscodedMediaConnection();
6556
5662
  }
6557
5663
 
6558
5664
  /**
@@ -6838,7 +5944,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6838
5944
  }, {
6839
5945
  key: "endMeetingForAll",
6840
5946
  value: function endMeetingForAll() {
6841
- var _this58 = this;
5947
+ var _this46 = this;
6842
5948
  _metrics.default.postEvent({
6843
5949
  event: _config.eventType.LEAVE,
6844
5950
  meeting: this,
@@ -6853,25 +5959,25 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6853
5959
  locus_id: this.locusId
6854
5960
  });
6855
5961
  return _util.default.endMeetingForAll(this).then(function (end) {
6856
- _this58.meetingFiniteStateMachine.end();
6857
- _this58.clearMeetingData();
5962
+ _this46.meetingFiniteStateMachine.end();
5963
+ _this46.clearMeetingData();
6858
5964
  // upload logs on leave irrespective of meeting delete
6859
- _triggerProxy.default.trigger(_this58, {
5965
+ _triggerProxy.default.trigger(_this46, {
6860
5966
  file: 'meeting/index',
6861
5967
  function: 'endMeetingForAll'
6862
- }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this58);
5968
+ }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this46);
6863
5969
  return end;
6864
5970
  }).catch(function (error) {
6865
- _this58.meetingFiniteStateMachine.fail(error);
5971
+ _this46.meetingFiniteStateMachine.fail(error);
6866
5972
  _loggerProxy.default.logger.error('Meeting:index#endMeetingForAll --> Failed to end meeting ', error);
6867
5973
  // upload logs on leave irrespective of meeting delete
6868
- _triggerProxy.default.trigger(_this58, {
5974
+ _triggerProxy.default.trigger(_this46, {
6869
5975
  file: 'meeting/index',
6870
5976
  function: 'endMeetingForAll'
6871
- }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this58);
5977
+ }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this46);
6872
5978
  _metrics.default.sendBehavioralMetric(_constants2.default.MEETING_END_ALL_FAILURE, {
6873
- correlation_id: _this58.correlationId,
6874
- locus_id: _this58.locusUrl.split('/').pop(),
5979
+ correlation_id: _this46.correlationId,
5980
+ locus_id: _this46.locusUrl.split('/').pop(),
6875
5981
  reason: error.message,
6876
5982
  stack: error.stack,
6877
5983
  code: error.code
@@ -6951,11 +6057,11 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6951
6057
  }, {
6952
6058
  key: "checkMediaConnection",
6953
6059
  value: function checkMediaConnection() {
6954
- var _this$mediaProperties9;
6955
- if ((_this$mediaProperties9 = this.mediaProperties) !== null && _this$mediaProperties9 !== void 0 && _this$mediaProperties9.webrtcMediaConnection) {
6060
+ var _this$mediaProperties5;
6061
+ if ((_this$mediaProperties5 = this.mediaProperties) !== null && _this$mediaProperties5 !== void 0 && _this$mediaProperties5.webrtcMediaConnection) {
6956
6062
  return;
6957
6063
  }
6958
- throw new Error('Webrtc media connection is missing, call addMedia() first');
6064
+ throw new _webexErrors.NoMediaEstablishedYetError();
6959
6065
  }
6960
6066
 
6961
6067
  /**
@@ -6967,43 +6073,171 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6967
6073
  }, {
6968
6074
  key: "enableMusicMode",
6969
6075
  value: function () {
6970
- var _enableMusicMode = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(shouldEnableMusicMode) {
6971
- return _regenerator.default.wrap(function _callee12$(_context12) {
6972
- while (1) switch (_context12.prev = _context12.next) {
6076
+ var _enableMusicMode = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(shouldEnableMusicMode) {
6077
+ return _regenerator.default.wrap(function _callee17$(_context17) {
6078
+ while (1) switch (_context17.prev = _context17.next) {
6973
6079
  case 0:
6974
6080
  this.checkMediaConnection();
6975
6081
  if (this.isMultistream) {
6976
- _context12.next = 3;
6082
+ _context17.next = 3;
6977
6083
  break;
6978
6084
  }
6979
6085
  throw new Error('enableMusicMode() only supported with multistream');
6980
6086
  case 3:
6981
6087
  if (!shouldEnableMusicMode) {
6982
- _context12.next = 8;
6088
+ _context17.next = 8;
6983
6089
  break;
6984
6090
  }
6985
- _context12.next = 6;
6091
+ _context17.next = 6;
6986
6092
  return this.mediaProperties.webrtcMediaConnection.setCodecParameters(_internalMediaCore.MediaType.AudioMain, {
6987
6093
  maxaveragebitrate: '64000',
6988
6094
  maxplaybackrate: '48000'
6989
6095
  });
6990
6096
  case 6:
6991
- _context12.next = 10;
6097
+ _context17.next = 10;
6992
6098
  break;
6993
6099
  case 8:
6994
- _context12.next = 10;
6100
+ _context17.next = 10;
6995
6101
  return this.mediaProperties.webrtcMediaConnection.deleteCodecParameters(_internalMediaCore.MediaType.AudioMain, ['maxaveragebitrate', 'maxplaybackrate']);
6996
6102
  case 10:
6997
6103
  case "end":
6998
- return _context12.stop();
6104
+ return _context17.stop();
6999
6105
  }
7000
- }, _callee12, this);
6106
+ }, _callee17, this);
7001
6107
  }));
7002
- function enableMusicMode(_x7) {
6108
+ function enableMusicMode(_x13) {
7003
6109
  return _enableMusicMode.apply(this, arguments);
7004
6110
  }
7005
6111
  return enableMusicMode;
7006
6112
  }()
6113
+ /** Updates the tracks being sent on the transcoded media connection
6114
+ *
6115
+ * @returns {Promise<void>}
6116
+ */
6117
+ }, {
6118
+ key: "updateTranscodedMediaConnection",
6119
+ value: function updateTranscodedMediaConnection() {
6120
+ var _this$mediaProperties6,
6121
+ _this$mediaProperties7,
6122
+ _this$mediaProperties8,
6123
+ _this47 = this;
6124
+ var LOG_HEADER = 'Meeting:index#updateTranscodedMediaConnection -->';
6125
+ _loggerProxy.default.logger.info("".concat(LOG_HEADER, " starting"));
6126
+ if (!this.canUpdateMedia()) {
6127
+ return this.enqueueMediaUpdate(MEDIA_UPDATE_TYPE.TRANSCODED_MEDIA_CONNECTION, {});
6128
+ }
6129
+ return this.mediaProperties.webrtcMediaConnection.update({
6130
+ localTracks: {
6131
+ audio: ((_this$mediaProperties6 = this.mediaProperties.audioTrack) === null || _this$mediaProperties6 === void 0 ? void 0 : _this$mediaProperties6.underlyingTrack) || null,
6132
+ video: ((_this$mediaProperties7 = this.mediaProperties.videoTrack) === null || _this$mediaProperties7 === void 0 ? void 0 : _this$mediaProperties7.underlyingTrack) || null,
6133
+ screenShareVideo: ((_this$mediaProperties8 = this.mediaProperties.shareTrack) === null || _this$mediaProperties8 === void 0 ? void 0 : _this$mediaProperties8.underlyingTrack) || null
6134
+ },
6135
+ direction: {
6136
+ audio: _media.default.getDirection(true, this.mediaProperties.mediaDirection.receiveAudio, this.mediaProperties.mediaDirection.sendAudio),
6137
+ video: _media.default.getDirection(true, this.mediaProperties.mediaDirection.receiveVideo, this.mediaProperties.mediaDirection.sendVideo),
6138
+ screenShareVideo: _media.default.getDirection(false, this.mediaProperties.mediaDirection.receiveShare, this.mediaProperties.mediaDirection.sendShare)
6139
+ },
6140
+ remoteQualityLevel: this.mediaProperties.remoteQualityLevel
6141
+ }).then(function () {
6142
+ _loggerProxy.default.logger.info("".concat(LOG_HEADER, " done"));
6143
+ }).catch(function (error) {
6144
+ _loggerProxy.default.logger.error("".concat(LOG_HEADER, " Error: "), error);
6145
+ _metrics.default.sendBehavioralMetric(_constants2.default.UPDATE_MEDIA_FAILURE, {
6146
+ correlation_id: _this47.correlationId,
6147
+ locus_id: _this47.locusUrl.split('/').pop(),
6148
+ reason: error.message,
6149
+ stack: error.stack
6150
+ });
6151
+ throw error;
6152
+ });
6153
+ }
6154
+
6155
+ /**
6156
+ * Publishes a track.
6157
+ *
6158
+ * @param {LocalTrack} track to publish
6159
+ * @returns {Promise}
6160
+ */
6161
+ }, {
6162
+ key: "publishTrack",
6163
+ value: function () {
6164
+ var _publishTrack = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18(track) {
6165
+ return _regenerator.default.wrap(function _callee18$(_context18) {
6166
+ while (1) switch (_context18.prev = _context18.next) {
6167
+ case 0:
6168
+ if (track) {
6169
+ _context18.next = 2;
6170
+ break;
6171
+ }
6172
+ return _context18.abrupt("return");
6173
+ case 2:
6174
+ if (!this.mediaProperties.webrtcMediaConnection) {
6175
+ _context18.next = 9;
6176
+ break;
6177
+ }
6178
+ if (!this.isMultistream) {
6179
+ _context18.next = 8;
6180
+ break;
6181
+ }
6182
+ _context18.next = 6;
6183
+ return this.mediaProperties.webrtcMediaConnection.publishTrack(track);
6184
+ case 6:
6185
+ _context18.next = 9;
6186
+ break;
6187
+ case 8:
6188
+ track.setPublished(true); // for multistream, this call is done by WCME
6189
+ case 9:
6190
+ case "end":
6191
+ return _context18.stop();
6192
+ }
6193
+ }, _callee18, this);
6194
+ }));
6195
+ function publishTrack(_x14) {
6196
+ return _publishTrack.apply(this, arguments);
6197
+ }
6198
+ return publishTrack;
6199
+ }()
6200
+ /**
6201
+ * Un-publishes a track.
6202
+ *
6203
+ * @param {LocalTrack} track to unpublish
6204
+ * @returns {Promise}
6205
+ */
6206
+ }, {
6207
+ key: "unpublishTrack",
6208
+ value: function () {
6209
+ var _unpublishTrack = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19(track) {
6210
+ return _regenerator.default.wrap(function _callee19$(_context19) {
6211
+ while (1) switch (_context19.prev = _context19.next) {
6212
+ case 0:
6213
+ if (track) {
6214
+ _context19.next = 2;
6215
+ break;
6216
+ }
6217
+ return _context19.abrupt("return");
6218
+ case 2:
6219
+ if (!(this.isMultistream && this.mediaProperties.webrtcMediaConnection)) {
6220
+ _context19.next = 7;
6221
+ break;
6222
+ }
6223
+ _context19.next = 5;
6224
+ return this.mediaProperties.webrtcMediaConnection.unpublishTrack(track);
6225
+ case 5:
6226
+ _context19.next = 8;
6227
+ break;
6228
+ case 7:
6229
+ track.setPublished(false); // for multistream, this call is done by WCME
6230
+ case 8:
6231
+ case "end":
6232
+ return _context19.stop();
6233
+ }
6234
+ }, _callee19, this);
6235
+ }));
6236
+ function unpublishTrack(_x15) {
6237
+ return _unpublishTrack.apply(this, arguments);
6238
+ }
6239
+ return unpublishTrack;
6240
+ }()
7007
6241
  /**
7008
6242
  * Publishes specified local tracks in the meeting
7009
6243
  *
@@ -7013,84 +6247,85 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
7013
6247
  }, {
7014
6248
  key: "publishTracks",
7015
6249
  value: function () {
7016
- var _publishTracks = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(tracks) {
7017
- var _tracks$screenShare;
7018
- var _tracks$screenShare2, oldTrack, localDisplayTrack, _oldTrack, localTrack, _oldTrack2, _localTrack;
7019
- return _regenerator.default.wrap(function _callee13$(_context13) {
7020
- while (1) switch (_context13.prev = _context13.next) {
6250
+ var _publishTracks = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21(tracks) {
6251
+ var _tracks$screenShare,
6252
+ _tracks$screenShare2,
6253
+ _tracks$screenShare3,
6254
+ _this48 = this;
6255
+ var floorRequestNeeded, _tracks$screenShare4;
6256
+ return _regenerator.default.wrap(function _callee21$(_context21) {
6257
+ while (1) switch (_context21.prev = _context21.next) {
7021
6258
  case 0:
7022
6259
  this.checkMediaConnection();
7023
- if (this.isMultistream) {
7024
- _context13.next = 3;
6260
+ this.annotationInfo = tracks.annotationInfo;
6261
+ if (!(!tracks.microphone && !tracks.camera && !((_tracks$screenShare = tracks.screenShare) !== null && _tracks$screenShare !== void 0 && _tracks$screenShare.audio) && !((_tracks$screenShare2 = tracks.screenShare) !== null && _tracks$screenShare2 !== void 0 && _tracks$screenShare2.video))) {
6262
+ _context21.next = 4;
7025
6263
  break;
7026
6264
  }
7027
- throw new Error('publishTracks() only supported with multistream');
7028
- case 3:
7029
- this.annotationInfo = tracks.annotationInfo;
7030
- if (!((_tracks$screenShare = tracks.screenShare) !== null && _tracks$screenShare !== void 0 && _tracks$screenShare.video)) {
7031
- _context13.next = 15;
6265
+ return _context21.abrupt("return");
6266
+ case 4:
6267
+ floorRequestNeeded = false;
6268
+ if (!((_tracks$screenShare3 = tracks.screenShare) !== null && _tracks$screenShare3 !== void 0 && _tracks$screenShare3.video)) {
6269
+ _context21.next = 9;
7032
6270
  break;
7033
6271
  }
7034
- oldTrack = this.mediaProperties.shareTrack;
7035
- localDisplayTrack = (_tracks$screenShare2 = tracks.screenShare) === null || _tracks$screenShare2 === void 0 ? void 0 : _tracks$screenShare2.video;
7036
- oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.off(_mediaHelpers.LocalTrackEvents.Ended, this.handleShareTrackEnded);
7037
-
7038
- // we are starting a screen share
7039
- this.mediaProperties.setLocalShareTrack(localDisplayTrack);
7040
- localDisplayTrack.on(_mediaHelpers.LocalTrackEvents.Ended, this.handleShareTrackEnded);
7041
- _context13.next = 12;
7042
- return this.requestScreenShareFloor();
7043
- case 12:
7044
- this.mediaProperties.mediaDirection.sendShare = true;
7045
- _context13.next = 15;
7046
- return this.mediaProperties.webrtcMediaConnection.publishTrack(this.mediaProperties.shareTrack);
7047
- case 15:
6272
+ _context21.next = 8;
6273
+ return this.setLocalShareTrack((_tracks$screenShare4 = tracks.screenShare) === null || _tracks$screenShare4 === void 0 ? void 0 : _tracks$screenShare4.video);
6274
+ case 8:
6275
+ floorRequestNeeded = true;
6276
+ case 9:
7048
6277
  if (!tracks.microphone) {
7049
- _context13.next = 25;
6278
+ _context21.next = 12;
7050
6279
  break;
7051
6280
  }
7052
- _oldTrack = this.mediaProperties.audioTrack;
7053
- localTrack = tracks.microphone;
7054
- _oldTrack === null || _oldTrack === void 0 ? void 0 : _oldTrack.off(_mediaHelpers.LocalTrackEvents.Muted, this.localAudioTrackMuteStateHandler);
7055
- this.mediaProperties.setLocalAudioTrack(localTrack);
7056
- this.mediaProperties.mediaDirection.sendAudio = true;
7057
-
7058
- // audio mute state could be undefined if you have not sent audio before
7059
- if (!this.audio) {
7060
- this.audio = (0, _muteState.createMuteState)(_constants.AUDIO, this, this.mediaProperties.mediaDirection, false);
7061
- } else {
7062
- this.audio.handleLocalTrackChange(this);
7063
- }
7064
- localTrack.on(_mediaHelpers.LocalTrackEvents.Muted, this.localAudioTrackMuteStateHandler);
7065
- _context13.next = 25;
7066
- return this.mediaProperties.webrtcMediaConnection.publishTrack(this.mediaProperties.audioTrack);
7067
- case 25:
6281
+ _context21.next = 12;
6282
+ return this.setLocalAudioTrack(tracks.microphone);
6283
+ case 12:
7068
6284
  if (!tracks.camera) {
7069
- _context13.next = 35;
6285
+ _context21.next = 15;
7070
6286
  break;
7071
6287
  }
7072
- _oldTrack2 = this.mediaProperties.videoTrack;
7073
- _localTrack = tracks.camera;
7074
- _oldTrack2 === null || _oldTrack2 === void 0 ? void 0 : _oldTrack2.off(_mediaHelpers.LocalTrackEvents.Muted, this.localVideoTrackMuteStateHandler);
7075
- this.mediaProperties.setLocalVideoTrack(_localTrack);
7076
- this.mediaProperties.mediaDirection.sendVideo = true;
7077
-
7078
- // video state could be undefined if you have not sent video before
7079
- if (!this.video) {
7080
- this.video = (0, _muteState.createMuteState)(_constants.VIDEO, this, this.mediaProperties.mediaDirection, false);
7081
- } else {
7082
- this.video.handleLocalTrackChange(this);
6288
+ _context21.next = 15;
6289
+ return this.setLocalVideoTrack(tracks.camera);
6290
+ case 15:
6291
+ if (this.isMultistream) {
6292
+ _context21.next = 18;
6293
+ break;
6294
+ }
6295
+ _context21.next = 18;
6296
+ return this.updateTranscodedMediaConnection();
6297
+ case 18:
6298
+ if (!floorRequestNeeded) {
6299
+ _context21.next = 21;
6300
+ break;
7083
6301
  }
7084
- _localTrack.on(_mediaHelpers.LocalTrackEvents.Muted, this.localVideoTrackMuteStateHandler);
7085
- _context13.next = 35;
7086
- return this.mediaProperties.webrtcMediaConnection.publishTrack(this.mediaProperties.videoTrack);
7087
- case 35:
6302
+ _context21.next = 21;
6303
+ return this.enqueueMediaUpdate(MEDIA_UPDATE_TYPE.LAMBDA, {
6304
+ lambda: function () {
6305
+ var _lambda2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20() {
6306
+ return _regenerator.default.wrap(function _callee20$(_context20) {
6307
+ while (1) switch (_context20.prev = _context20.next) {
6308
+ case 0:
6309
+ return _context20.abrupt("return", _this48.requestScreenShareFloor());
6310
+ case 1:
6311
+ case "end":
6312
+ return _context20.stop();
6313
+ }
6314
+ }, _callee20);
6315
+ }));
6316
+ function lambda() {
6317
+ return _lambda2.apply(this, arguments);
6318
+ }
6319
+ return lambda;
6320
+ }()
6321
+ });
6322
+ case 21:
7088
6323
  case "end":
7089
- return _context13.stop();
6324
+ return _context21.stop();
7090
6325
  }
7091
- }, _callee13, this);
6326
+ }, _callee21, this);
7092
6327
  }));
7093
- function publishTracks(_x8) {
6328
+ function publishTracks(_x16) {
7094
6329
  return _publishTracks.apply(this, arguments);
7095
6330
  }
7096
6331
  return publishTracks;
@@ -7104,19 +6339,13 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
7104
6339
  }, {
7105
6340
  key: "unpublishTracks",
7106
6341
  value: function () {
7107
- var _unpublishTracks = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(tracks) {
7108
- var unpublishPromises, _iterator, _step, track;
7109
- return _regenerator.default.wrap(function _callee14$(_context14) {
7110
- while (1) switch (_context14.prev = _context14.next) {
6342
+ var _unpublishTracks = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee22(tracks) {
6343
+ var promises, _iterator, _step, track;
6344
+ return _regenerator.default.wrap(function _callee22$(_context22) {
6345
+ while (1) switch (_context22.prev = _context22.next) {
7111
6346
  case 0:
7112
6347
  this.checkMediaConnection();
7113
- if (this.isMultistream) {
7114
- _context14.next = 3;
7115
- break;
7116
- }
7117
- throw new Error('unpublishTracks() is only supported with multistream');
7118
- case 3:
7119
- unpublishPromises = [];
6348
+ promises = [];
7120
6349
  _iterator = _createForOfIteratorHelper(tracks.filter(function (t) {
7121
6350
  return !!t;
7122
6351
  }));
@@ -7124,23 +6353,18 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
7124
6353
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
7125
6354
  track = _step.value;
7126
6355
  if (track === this.mediaProperties.shareTrack) {
7127
- this.mediaProperties.setLocalShareTrack(null);
7128
- track.off(_mediaHelpers.LocalTrackEvents.Ended, this.handleShareTrackEnded);
7129
- this.releaseScreenShareFloor(); // we ignore the returned promise here on purpose
7130
- this.mediaProperties.mediaDirection.sendShare = false;
7131
- unpublishPromises.push(this.mediaProperties.webrtcMediaConnection.unpublishTrack(track));
6356
+ try {
6357
+ this.releaseScreenShareFloor(); // we ignore the returned promise here on purpose
6358
+ } catch (e) {
6359
+ // nothing to do here, error is logged already inside releaseScreenShareFloor()
6360
+ }
6361
+ promises.push(this.setLocalShareTrack(undefined));
7132
6362
  }
7133
6363
  if (track === this.mediaProperties.audioTrack) {
7134
- this.mediaProperties.setLocalAudioTrack(null);
7135
- this.mediaProperties.mediaDirection.sendAudio = false;
7136
- track.off(_mediaHelpers.LocalTrackEvents.Muted, this.localAudioTrackMuteStateHandler);
7137
- unpublishPromises.push(this.mediaProperties.webrtcMediaConnection.unpublishTrack(track));
6364
+ promises.push(this.setLocalAudioTrack(undefined));
7138
6365
  }
7139
6366
  if (track === this.mediaProperties.videoTrack) {
7140
- this.mediaProperties.setLocalVideoTrack(null);
7141
- this.mediaProperties.mediaDirection.sendVideo = false;
7142
- track.off(_mediaHelpers.LocalTrackEvents.Muted, this.localVideoTrackMuteStateHandler);
7143
- unpublishPromises.push(this.mediaProperties.webrtcMediaConnection.unpublishTrack(track));
6367
+ promises.push(this.setLocalVideoTrack(undefined));
7144
6368
  }
7145
6369
  }
7146
6370
  } catch (err) {
@@ -7148,15 +6372,18 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
7148
6372
  } finally {
7149
6373
  _iterator.f();
7150
6374
  }
7151
- _context14.next = 8;
7152
- return _promise.default.all(unpublishPromises);
7153
- case 8:
6375
+ if (!this.isMultistream) {
6376
+ promises.push(this.updateTranscodedMediaConnection());
6377
+ }
6378
+ _context22.next = 7;
6379
+ return _promise.default.all(promises);
6380
+ case 7:
7154
6381
  case "end":
7155
- return _context14.stop();
6382
+ return _context22.stop();
7156
6383
  }
7157
- }, _callee14, this);
6384
+ }, _callee22, this);
7158
6385
  }));
7159
- function unpublishTracks(_x9) {
6386
+ function unpublishTracks(_x17) {
7160
6387
  return _unpublishTracks.apply(this, arguments);
7161
6388
  }
7162
6389
  return unpublishTracks;