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

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 (60) hide show
  1. package/dist/annotation/index.js +0 -2
  2. package/dist/annotation/index.js.map +1 -1
  3. package/dist/breakouts/breakout.js +1 -1
  4. package/dist/breakouts/index.js +1 -1
  5. package/dist/common/errors/webex-errors.js +3 -2
  6. package/dist/common/errors/webex-errors.js.map +1 -1
  7. package/dist/config.js +1 -7
  8. package/dist/config.js.map +1 -1
  9. package/dist/constants.js +7 -15
  10. package/dist/constants.js.map +1 -1
  11. package/dist/index.js +6 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/media/index.js +5 -56
  14. package/dist/media/index.js.map +1 -1
  15. package/dist/media/properties.js +15 -93
  16. package/dist/media/properties.js.map +1 -1
  17. package/dist/meeting/index.js +1112 -1873
  18. package/dist/meeting/index.js.map +1 -1
  19. package/dist/meeting/muteState.js +88 -184
  20. package/dist/meeting/muteState.js.map +1 -1
  21. package/dist/meeting/util.js +1 -23
  22. package/dist/meeting/util.js.map +1 -1
  23. package/dist/meetings/index.js +1 -2
  24. package/dist/meetings/index.js.map +1 -1
  25. package/dist/reconnection-manager/index.js +153 -134
  26. package/dist/reconnection-manager/index.js.map +1 -1
  27. package/dist/roap/index.js +8 -7
  28. package/dist/roap/index.js.map +1 -1
  29. package/dist/types/common/errors/webex-errors.d.ts +1 -1
  30. package/dist/types/config.d.ts +0 -6
  31. package/dist/types/constants.d.ts +1 -18
  32. package/dist/types/index.d.ts +1 -1
  33. package/dist/types/media/properties.d.ts +16 -38
  34. package/dist/types/meeting/index.d.ts +97 -353
  35. package/dist/types/meeting/muteState.d.ts +36 -38
  36. package/dist/types/meeting/util.d.ts +2 -4
  37. package/package.json +19 -19
  38. package/src/annotation/index.ts +0 -2
  39. package/src/common/errors/webex-errors.ts +6 -2
  40. package/src/config.ts +0 -6
  41. package/src/constants.ts +1 -14
  42. package/src/index.ts +1 -0
  43. package/src/media/index.ts +10 -53
  44. package/src/media/properties.ts +32 -92
  45. package/src/meeting/index.ts +544 -1567
  46. package/src/meeting/muteState.ts +87 -178
  47. package/src/meeting/util.ts +3 -24
  48. package/src/meetings/index.ts +0 -1
  49. package/src/reconnection-manager/index.ts +4 -9
  50. package/src/roap/index.ts +13 -14
  51. package/test/integration/spec/converged-space-meetings.js +59 -3
  52. package/test/integration/spec/journey.js +330 -256
  53. package/test/integration/spec/space-meeting.js +75 -3
  54. package/test/unit/spec/annotation/index.ts +4 -4
  55. package/test/unit/spec/meeting/index.js +811 -1367
  56. package/test/unit/spec/meeting/muteState.js +238 -394
  57. package/test/unit/spec/meeting/utils.js +2 -9
  58. package/test/unit/spec/multistream/receiveSlot.ts +1 -1
  59. package/test/unit/spec/roap/index.ts +2 -2
  60. 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'
@@ -2604,6 +2465,23 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2604
2465
  });
2605
2466
  }
2606
2467
 
2468
+ /**
2469
+ * Trigger annotation info update event
2470
+ @returns {undefined}
2471
+ @param {object} contentShare
2472
+ @param {object} previousContentShare
2473
+ */
2474
+ }, {
2475
+ key: "triggerAnnotationInfoEvent",
2476
+ value: function triggerAnnotationInfoEvent(contentShare, previousContentShare) {
2477
+ if (contentShare !== null && contentShare !== void 0 && contentShare.annotation && !(0, _isEqual2.default)(contentShare === null || contentShare === void 0 ? void 0 : contentShare.annotation, previousContentShare === null || previousContentShare === void 0 ? void 0 : previousContentShare.annotation)) {
2478
+ _triggerProxy.default.trigger(this, {
2479
+ file: 'meeting/index',
2480
+ function: 'triggerAnnotationInfoEvent'
2481
+ }, _constants.EVENT_TRIGGERS.MEETING_UPDATE_ANNOTATION_INFO, contentShare.annotation);
2482
+ }
2483
+ }
2484
+
2607
2485
  /**
2608
2486
  * Set up the locus info media shares listener
2609
2487
  * update content and whiteboard sharing id value for members, and updates the member
@@ -2618,21 +2496,16 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2618
2496
  var _this13 = this;
2619
2497
  // Will get triggered on local and remote share
2620
2498
  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) {
2499
+ var _ref17 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(payload) {
2622
2500
  var _payload$previous, _payload$previous2;
2623
- var _payload$current, contentShare, whiteboardShare, previousContentShare, previousWhiteboardShare, newShareStatus, _this13$mediaProperti, localShareTrack, oldShareStatus, sendStartedSharingRemote, _this13$mediaProperti2;
2501
+ var _payload$current, contentShare, whiteboardShare, previousContentShare, previousWhiteboardShare, newShareStatus, oldShareStatus, sendStartedSharingRemote, _this13$mediaProperti;
2624
2502
  return _regenerator.default.wrap(function _callee3$(_context3) {
2625
2503
  while (1) switch (_context3.prev = _context3.next) {
2626
2504
  case 0:
2627
2505
  _payload$current = payload.current, contentShare = _payload$current.content, whiteboardShare = _payload$current.whiteboard;
2628
2506
  previousContentShare = (_payload$previous = payload.previous) === null || _payload$previous === void 0 ? void 0 : _payload$previous.content;
2629
2507
  previousWhiteboardShare = (_payload$previous2 = payload.previous) === null || _payload$previous2 === void 0 ? void 0 : _payload$previous2.whiteboard;
2630
- if (!(0, _isEqual2.default)(contentShare === null || contentShare === void 0 ? void 0 : contentShare.annotation, previousContentShare === null || previousContentShare === void 0 ? void 0 : previousContentShare.annotation)) {
2631
- _triggerProxy.default.trigger(_this13, {
2632
- file: 'meetings/index',
2633
- function: 'remoteShare'
2634
- }, _constants.EVENT_TRIGGERS.MEETING_UPDATE_ANNOTATION_INFO, contentShare.annotation);
2635
- }
2508
+ _this13.triggerAnnotationInfoEvent(contentShare, previousContentShare);
2636
2509
  if (!(contentShare.beneficiaryId === (previousContentShare === null || previousContentShare === void 0 ? void 0 : previousContentShare.beneficiaryId) && contentShare.disposition === (previousContentShare === null || previousContentShare === void 0 ? void 0 : previousContentShare.disposition) && whiteboardShare.beneficiaryId === (previousWhiteboardShare === null || previousWhiteboardShare === void 0 ? void 0 : previousWhiteboardShare.beneficiaryId) && whiteboardShare.disposition === (previousWhiteboardShare === null || previousWhiteboardShare === void 0 ? void 0 : previousWhiteboardShare.disposition) && whiteboardShare.resourceUrl === (previousWhiteboardShare === null || previousWhiteboardShare === void 0 ? void 0 : previousWhiteboardShare.resourceUrl))) {
2637
2510
  _context3.next = 6;
2638
2511
  break;
@@ -2640,58 +2513,19 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2640
2513
  return _context3.abrupt("return");
2641
2514
  case 6:
2642
2515
  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;
2516
+ if (_this13.selfId !== contentShare.beneficiaryId && contentShare.disposition === _constants.FLOOR_ACTION.GRANTED) {
2517
+ // CONTENT - sharing content remote
2518
+ newShareStatus = _constants.SHARE_STATUS.REMOTE_SHARE_ACTIVE;
2661
2519
  }
2662
- _context3.prev = 14;
2663
- if (!_this13.isMultistream) {
2664
- _context3.next = 20;
2665
- break;
2520
+ // LOCAL - check if we started sharing content
2521
+ else if (_this13.selfId === contentShare.beneficiaryId && contentShare.disposition === _constants.FLOOR_ACTION.GRANTED) {
2522
+ // CONTENT - sharing content local
2523
+ newShareStatus = _constants.SHARE_STATUS.LOCAL_SHARE_ACTIVE;
2666
2524
  }
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) {
2525
+ // If we did not hit the cases above, no one is sharng content, so we check if we are sharing whiteboard
2526
+ // There is no concept of local/remote share for whiteboard
2527
+ // It does not matter who requested to share the whiteboard, everyone gets the same view
2528
+ else if (whiteboardShare.disposition === _constants.FLOOR_ACTION.GRANTED) {
2695
2529
  // WHITEBOARD - sharing whiteboard
2696
2530
  newShareStatus = _constants.SHARE_STATUS.WHITEBOARD_SHARE_ACTIVE;
2697
2531
  }
@@ -2699,47 +2533,46 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2699
2533
  else if ((previousContentShare && contentShare.disposition === _constants.FLOOR_ACTION.RELEASED || contentShare.disposition === null) && (previousWhiteboardShare && whiteboardShare.disposition === _constants.FLOOR_ACTION.RELEASED || whiteboardShare.disposition === null)) {
2700
2534
  newShareStatus = _constants.SHARE_STATUS.NO_SHARE;
2701
2535
  }
2702
- case 33:
2703
2536
  if (!(newShareStatus !== _this13.shareStatus)) {
2704
- _context3.next = 75;
2537
+ _context3.next = 45;
2705
2538
  break;
2706
2539
  }
2707
2540
  oldShareStatus = _this13.shareStatus; // update our state before we send out any notifications
2708
2541
  _this13.shareStatus = newShareStatus;
2709
2542
 
2710
2543
  // 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;
2544
+ _context3.t0 = oldShareStatus;
2545
+ _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
2546
  break;
2714
- case 39:
2547
+ case 14:
2715
2548
  _triggerProxy.default.trigger(_this13, {
2716
2549
  file: 'meetings/index',
2717
2550
  function: 'remoteShare'
2718
2551
  }, _constants.EVENT_TRIGGERS.MEETING_STOPPED_SHARING_REMOTE);
2719
- return _context3.abrupt("break", 47);
2720
- case 41:
2552
+ return _context3.abrupt("break", 22);
2553
+ case 16:
2721
2554
  _triggerProxy.default.trigger(_this13, {
2722
2555
  file: 'meeting/index',
2723
2556
  function: 'localShare'
2724
2557
  }, _constants.EVENT_TRIGGERS.MEETING_STOPPED_SHARING_LOCAL, {
2725
2558
  reason: _constants.SHARE_STOPPED_REASON.SELF_STOPPED
2726
2559
  });
2727
- return _context3.abrupt("break", 47);
2728
- case 43:
2560
+ return _context3.abrupt("break", 22);
2561
+ case 18:
2729
2562
  _triggerProxy.default.trigger(_this13, {
2730
2563
  file: 'meeting/index',
2731
2564
  function: 'stopWhiteboardShare'
2732
2565
  }, _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;
2566
+ return _context3.abrupt("break", 22);
2567
+ case 20:
2568
+ return _context3.abrupt("break", 22);
2569
+ case 21:
2570
+ return _context3.abrupt("break", 22);
2571
+ case 22:
2572
+ _context3.t1 = newShareStatus;
2573
+ _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
2574
  break;
2742
- case 50:
2575
+ case 25:
2743
2576
  sendStartedSharingRemote = function sendStartedSharingRemote() {
2744
2577
  _triggerProxy.default.trigger(_this13, {
2745
2578
  file: 'meetings/index',
@@ -2750,33 +2583,20 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2750
2583
  shareInstanceId: contentShare.shareInstanceId
2751
2584
  });
2752
2585
  };
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;
2586
+ _context3.prev = 26;
2587
+ if (!((_this13$mediaProperti = _this13.mediaProperties.mediaDirection) !== null && _this13$mediaProperti !== void 0 && _this13$mediaProperti.sendShare && oldShareStatus === _constants.SHARE_STATUS.LOCAL_SHARE_ACTIVE)) {
2588
+ _context3.next = 30;
2756
2589
  break;
2757
2590
  }
2758
- if (!_this13.isMultistream) {
2759
- _context3.next = 58;
2760
- break;
2761
- }
2762
- _context3.next = 56;
2591
+ _context3.next = 30;
2763
2592
  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;
2593
+ case 30:
2594
+ _context3.prev = 30;
2775
2595
  sendStartedSharingRemote();
2776
- return _context3.finish(60);
2777
- case 63:
2778
- return _context3.abrupt("break", 72);
2779
- case 64:
2596
+ return _context3.finish(30);
2597
+ case 33:
2598
+ return _context3.abrupt("break", 42);
2599
+ case 34:
2780
2600
  _triggerProxy.default.trigger(_this13, {
2781
2601
  file: 'meeting/index',
2782
2602
  function: 'share'
@@ -2785,8 +2605,8 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2785
2605
  event: _config.eventType.LOCAL_SHARE_FLOOR_GRANTED,
2786
2606
  meeting: _this13
2787
2607
  });
2788
- return _context3.abrupt("break", 72);
2789
- case 67:
2608
+ return _context3.abrupt("break", 42);
2609
+ case 37:
2790
2610
  _triggerProxy.default.trigger(_this13, {
2791
2611
  file: 'meeting/index',
2792
2612
  function: 'startWhiteboardShare'
@@ -2798,16 +2618,16 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2798
2618
  event: _config.eventType.WHITEBOARD_SHARE_FLOOR_GRANTED,
2799
2619
  meeting: _this13
2800
2620
  });
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:
2621
+ return _context3.abrupt("break", 42);
2622
+ case 40:
2623
+ return _context3.abrupt("break", 42);
2624
+ case 41:
2625
+ return _context3.abrupt("break", 42);
2626
+ case 42:
2807
2627
  _this13.members.locusMediaSharesUpdate(payload);
2808
- _context3.next = 76;
2628
+ _context3.next = 46;
2809
2629
  break;
2810
- case 75:
2630
+ case 45:
2811
2631
  if (newShareStatus === _constants.SHARE_STATUS.REMOTE_SHARE_ACTIVE) {
2812
2632
  // if we got here, then some remote participant has stolen
2813
2633
  // the presentation from another remote participant
@@ -2836,14 +2656,14 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
2836
2656
  });
2837
2657
  _this13.members.locusMediaSharesUpdate(payload);
2838
2658
  }
2839
- case 76:
2659
+ case 46:
2840
2660
  case "end":
2841
2661
  return _context3.stop();
2842
2662
  }
2843
- }, _callee3, null, [[14, 24], [51,, 60, 63]]);
2663
+ }, _callee3, null, [[26,, 30, 33]]);
2844
2664
  }));
2845
2665
  return function (_x2) {
2846
- return _ref19.apply(this, arguments);
2666
+ return _ref17.apply(this, arguments);
2847
2667
  };
2848
2668
  }());
2849
2669
  }
@@ -3286,46 +3106,63 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
3286
3106
  });
3287
3107
  }
3288
3108
  });
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
- });
3109
+ this.locusInfo.on(_constants.EVENTS.DESTROY_MEETING, /*#__PURE__*/function () {
3110
+ var _ref18 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(payload) {
3111
+ return _regenerator.default.wrap(function _callee4$(_context4) {
3112
+ while (1) switch (_context4.prev = _context4.next) {
3113
+ case 0:
3114
+ if (!_this20.wirelessShare) {
3115
+ _context4.next = 4;
3116
+ break;
3117
+ }
3118
+ if (!_this20.mediaProperties.shareTrack) {
3119
+ _context4.next = 4;
3120
+ break;
3121
+ }
3122
+ _context4.next = 4;
3123
+ return _this20.setLocalShareTrack(undefined);
3124
+ case 4:
3125
+ if (!payload.shouldLeave) {
3126
+ _context4.next = 16;
3127
+ break;
3128
+ }
3129
+ _context4.prev = 5;
3130
+ _context4.next = 8;
3131
+ return _this20.leave({
3132
+ reason: payload.reason
3133
+ });
3134
+ case 8:
3135
+ _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.');
3136
+ _context4.next = 14;
3137
+ break;
3138
+ case 11:
3139
+ _context4.prev = 11;
3140
+ _context4.t0 = _context4["catch"](5);
3141
+ // @ts-ignore
3142
+ _loggerProxy.default.logger.error("Meeting:index#setUpLocusInfoMeetingListener --> DESTROY_MEETING. Issue with leave for meeting, meeting still in collection: ".concat(_this20, ", error: ").concat(_context4.t0));
3143
+ case 14:
3144
+ _context4.next = 19;
3145
+ break;
3146
+ case 16:
3147
+ _loggerProxy.default.logger.info('Meeting:index#setUpLocusInfoMeetingListener --> MEETING_REMOVED_REASON', payload.reason);
3148
+ _util.default.cleanUp(_this20);
3149
+ _triggerProxy.default.trigger(_this20, {
3150
+ file: 'meeting/index',
3151
+ function: 'setUpLocusInfoMeetingListener'
3152
+ }, _constants.EVENTS.DESTROY_MEETING, {
3153
+ reason: payload.reason,
3154
+ meetingId: _this20.id
3155
+ });
3156
+ case 19:
3157
+ case "end":
3158
+ return _context4.stop();
3159
+ }
3160
+ }, _callee4, null, [[5, 11]]);
3161
+ }));
3162
+ return function (_x3) {
3163
+ return _ref18.apply(this, arguments);
3164
+ };
3165
+ }());
3329
3166
  }
3330
3167
 
3331
3168
  /**
@@ -3469,78 +3306,6 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
3469
3306
  return this.members;
3470
3307
  }
3471
3308
 
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
3309
  /**
3545
3310
  * Sets the meeting info on the class instance
3546
3311
  * @param {Object} meetingInfo
@@ -3649,21 +3414,6 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
3649
3414
  _triggerProxy.default.trigger(this, options, _constants.EVENTS.REQUEST_UPLOAD_LOGS, this);
3650
3415
  }
3651
3416
 
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
3417
  /**
3668
3418
  * Removes remote audio, video and share tracks from class instance's mediaProperties
3669
3419
  * @returns {undefined}
@@ -3699,10 +3449,10 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
3699
3449
  key: "closeRemoteTracks",
3700
3450
  value: function closeRemoteTracks() {
3701
3451
  var _this22 = this;
3702
- var _this$mediaProperties3 = this.mediaProperties,
3703
- remoteAudioTrack = _this$mediaProperties3.remoteAudioTrack,
3704
- remoteVideoTrack = _this$mediaProperties3.remoteVideoTrack,
3705
- remoteShare = _this$mediaProperties3.remoteShare;
3452
+ var _this$mediaProperties2 = this.mediaProperties,
3453
+ remoteAudioTrack = _this$mediaProperties2.remoteAudioTrack,
3454
+ remoteVideoTrack = _this$mediaProperties2.remoteVideoTrack,
3455
+ remoteShare = _this$mediaProperties2.remoteShare;
3706
3456
 
3707
3457
  /**
3708
3458
  * Triggers an event to the developer
@@ -3743,243 +3493,168 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
3743
3493
  }
3744
3494
 
3745
3495
  /**
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
3496
+ * Stores the reference to a new microphone track, sets up the required event listeners
3497
+ * on it, cleans up previous track, etc.
3498
+ *
3499
+ * @param {LocalMicrophoneTrack | null} localTrack local microphone track
3500
+ * @returns {Promise<void>}
3750
3501
  */
3751
3502
  }, {
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
- }
3503
+ key: "setLocalAudioTrack",
3504
+ value: function () {
3505
+ var _setLocalAudioTrack = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(localTrack) {
3506
+ var oldTrack;
3507
+ return _regenerator.default.wrap(function _callee5$(_context5) {
3508
+ while (1) switch (_context5.prev = _context5.next) {
3509
+ case 0:
3510
+ oldTrack = this.mediaProperties.audioTrack;
3511
+ oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.off(_mediaHelpers.LocalTrackEvents.Muted, this.localAudioTrackMuteStateHandler);
3512
+ oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.off(_mediaHelpers.LocalTrackEvents.UnderlyingTrackChange, this.underlyingLocalTrackChangeHandler);
3763
3513
 
3514
+ // we don't update this.mediaProperties.mediaDirection.sendAudio, because we always keep it as true to avoid extra SDP exchanges
3515
+ this.mediaProperties.setLocalAudioTrack(localTrack);
3516
+ this.audio.handleLocalTrackChange(this);
3517
+ localTrack === null || localTrack === void 0 ? void 0 : localTrack.on(_mediaHelpers.LocalTrackEvents.Muted, this.localAudioTrackMuteStateHandler);
3518
+ localTrack === null || localTrack === void 0 ? void 0 : localTrack.on(_mediaHelpers.LocalTrackEvents.UnderlyingTrackChange, this.underlyingLocalTrackChangeHandler);
3519
+ if (!(!this.isMultistream || !localTrack)) {
3520
+ _context5.next = 10;
3521
+ break;
3522
+ }
3523
+ _context5.next = 10;
3524
+ return this.unpublishTrack(oldTrack);
3525
+ case 10:
3526
+ _context5.next = 12;
3527
+ return this.publishTrack(this.mediaProperties.audioTrack);
3528
+ case 12:
3529
+ case "end":
3530
+ return _context5.stop();
3531
+ }
3532
+ }, _callee5, this);
3533
+ }));
3534
+ function setLocalAudioTrack(_x4) {
3535
+ return _setLocalAudioTrack.apply(this, arguments);
3536
+ }
3537
+ return setLocalAudioTrack;
3538
+ }()
3764
3539
  /**
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
3540
+ * Stores the reference to a new camera track, sets up the required event listeners
3541
+ * on it, cleans up previous track, etc.
3542
+ *
3543
+ * @param {LocalCameraTrack | null} localTrack local camera track
3544
+ * @returns {Promise<void>}
3771
3545
  */
3772
3546
  }, {
3773
- 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();
3547
+ key: "setLocalVideoTrack",
3548
+ value: function () {
3549
+ var _setLocalVideoTrack = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(localTrack) {
3550
+ var oldTrack;
3551
+ return _regenerator.default.wrap(function _callee6$(_context6) {
3552
+ while (1) switch (_context6.prev = _context6.next) {
3553
+ case 0:
3554
+ oldTrack = this.mediaProperties.videoTrack;
3555
+ oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.off(_mediaHelpers.LocalTrackEvents.Muted, this.localVideoTrackMuteStateHandler);
3556
+ oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.off(_mediaHelpers.LocalTrackEvents.UnderlyingTrackChange, this.underlyingLocalTrackChangeHandler);
3557
+
3558
+ // we don't update this.mediaProperties.mediaDirection.sendVideo, because we always keep it as true to avoid extra SDP exchanges
3559
+ this.mediaProperties.setLocalVideoTrack(localTrack);
3560
+ this.video.handleLocalTrackChange(this);
3561
+ localTrack === null || localTrack === void 0 ? void 0 : localTrack.on(_mediaHelpers.LocalTrackEvents.Muted, this.localVideoTrackMuteStateHandler);
3562
+ localTrack === null || localTrack === void 0 ? void 0 : localTrack.on(_mediaHelpers.LocalTrackEvents.UnderlyingTrackChange, this.underlyingLocalTrackChangeHandler);
3563
+ if (!(!this.isMultistream || !localTrack)) {
3564
+ _context6.next = 10;
3565
+ break;
3566
+ }
3567
+ _context6.next = 10;
3568
+ return this.unpublishTrack(oldTrack);
3569
+ case 10:
3570
+ _context6.next = 12;
3571
+ return this.publishTrack(this.mediaProperties.videoTrack);
3572
+ case 12:
3573
+ case "end":
3574
+ return _context6.stop();
3575
+ }
3576
+ }, _callee6, this);
3577
+ }));
3578
+ function setLocalVideoTrack(_x5) {
3579
+ return _setLocalVideoTrack.apply(this, arguments);
3794
3580
  }
3795
- }
3796
-
3581
+ return setLocalVideoTrack;
3582
+ }()
3797
3583
  /**
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
3804
- */
3805
- }, {
3806
- 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();
3843
- }
3844
- }
3845
-
3846
- /**
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
3584
+ * Stores the reference to a new screen share track, sets up the required event listeners
3585
+ * on it, cleans up previous track, etc.
3586
+ * It also sends the floor grant/release request.
3587
+ *
3588
+ * @param {LocalDisplayTrack | undefined} localDisplayTrack local camera track
3589
+ * @returns {Promise<void>}
3875
3590
  */
3876
3591
  }, {
3877
3592
  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);
3593
+ value: function () {
3594
+ var _setLocalShareTrack = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(localDisplayTrack) {
3595
+ var oldTrack;
3596
+ return _regenerator.default.wrap(function _callee7$(_context7) {
3597
+ while (1) switch (_context7.prev = _context7.next) {
3598
+ case 0:
3599
+ oldTrack = this.mediaProperties.shareTrack;
3600
+ oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.off(_mediaHelpers.LocalTrackEvents.Ended, this.handleShareTrackEnded);
3601
+ oldTrack === null || oldTrack === void 0 ? void 0 : oldTrack.off(_mediaHelpers.LocalTrackEvents.UnderlyingTrackChange, this.underlyingLocalTrackChangeHandler);
3602
+ this.mediaProperties.setLocalShareTrack(localDisplayTrack);
3603
+ localDisplayTrack === null || localDisplayTrack === void 0 ? void 0 : localDisplayTrack.on(_mediaHelpers.LocalTrackEvents.Ended, this.handleShareTrackEnded);
3604
+ localDisplayTrack === null || localDisplayTrack === void 0 ? void 0 : localDisplayTrack.on(_mediaHelpers.LocalTrackEvents.UnderlyingTrackChange, this.underlyingLocalTrackChangeHandler);
3605
+ this.mediaProperties.mediaDirection.sendShare = !!localDisplayTrack;
3606
+ if (!(!this.isMultistream || !localDisplayTrack)) {
3607
+ _context7.next = 10;
3608
+ break;
3609
+ }
3610
+ _context7.next = 10;
3611
+ return this.unpublishTrack(oldTrack);
3612
+ case 10:
3613
+ _context7.next = 12;
3614
+ return this.publishTrack(this.mediaProperties.shareTrack);
3615
+ case 12:
3616
+ case "end":
3617
+ return _context7.stop();
3618
+ }
3619
+ }, _callee7, this);
3620
+ }));
3621
+ function setLocalShareTrack(_x6) {
3622
+ return _setLocalShareTrack.apply(this, arguments);
3906
3623
  }
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
-
3624
+ return setLocalShareTrack;
3625
+ }()
3973
3626
  /**
3974
- * Removes the local share from the class and emits an event to the developer
3975
- * @returns {undefined}
3976
- * @public
3977
- * @memberof Meeting
3627
+ * Removes references to local tracks. This function should be called
3628
+ * on cleanup when we leave the meeting etc.
3629
+ *
3630
+ * @internal
3631
+ * @returns {void}
3978
3632
  */
3979
3633
  }, {
3980
- key: "unsetLocalShareTrack",
3981
- value: function unsetLocalShareTrack() {
3982
- this.mediaProperties.unsetLocalShareTrack();
3634
+ key: "cleanupLocalTracks",
3635
+ value: function cleanupLocalTracks() {
3636
+ var _this$mediaProperties3 = this.mediaProperties,
3637
+ audioTrack = _this$mediaProperties3.audioTrack,
3638
+ videoTrack = _this$mediaProperties3.videoTrack,
3639
+ shareTrack = _this$mediaProperties3.shareTrack;
3640
+ audioTrack === null || audioTrack === void 0 ? void 0 : audioTrack.off(_mediaHelpers.LocalTrackEvents.Muted, this.localAudioTrackMuteStateHandler);
3641
+ audioTrack === null || audioTrack === void 0 ? void 0 : audioTrack.off(_mediaHelpers.LocalTrackEvents.UnderlyingTrackChange, this.underlyingLocalTrackChangeHandler);
3642
+ videoTrack === null || videoTrack === void 0 ? void 0 : videoTrack.off(_mediaHelpers.LocalTrackEvents.Muted, this.localVideoTrackMuteStateHandler);
3643
+ videoTrack === null || videoTrack === void 0 ? void 0 : videoTrack.off(_mediaHelpers.LocalTrackEvents.UnderlyingTrackChange, this.underlyingLocalTrackChangeHandler);
3644
+ shareTrack === null || shareTrack === void 0 ? void 0 : shareTrack.off(_mediaHelpers.LocalTrackEvents.Ended, this.handleShareTrackEnded);
3645
+ shareTrack === null || shareTrack === void 0 ? void 0 : shareTrack.off(_mediaHelpers.LocalTrackEvents.UnderlyingTrackChange, this.underlyingLocalTrackChangeHandler);
3646
+ this.mediaProperties.setLocalAudioTrack(undefined);
3647
+ this.mediaProperties.setLocalVideoTrack(undefined);
3648
+ this.mediaProperties.setLocalShareTrack(undefined);
3649
+ this.mediaProperties.mediaDirection.sendAudio = false;
3650
+ this.mediaProperties.mediaDirection.sendVideo = false;
3651
+ this.mediaProperties.mediaDirection.sendShare = false;
3652
+
3653
+ // WCME doesn't unpublish tracks when multistream connection is closed, so we do it here
3654
+ // (we have to do it for transcoded meetings anyway, so we might as well do for multistream too)
3655
+ audioTrack === null || audioTrack === void 0 ? void 0 : audioTrack.setPublished(false);
3656
+ videoTrack === null || videoTrack === void 0 ? void 0 : videoTrack.setPublished(false);
3657
+ shareTrack === null || shareTrack === void 0 ? void 0 : shareTrack.setPublished(false);
3983
3658
  }
3984
3659
 
3985
3660
  /**
@@ -3991,7 +3666,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
3991
3666
  }, {
3992
3667
  key: "setMercuryListener",
3993
3668
  value: function setMercuryListener() {
3994
- var _this25 = this;
3669
+ var _this23 = this;
3995
3670
  // Client will have a socket manager and handle reconnecting to mercury, when we reconnect to mercury
3996
3671
  // if the meeting has active peer connections, it should try to reconnect.
3997
3672
  // @ts-ignore
@@ -3999,16 +3674,16 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
3999
3674
  _loggerProxy.default.logger.info('Meeting:index#setMercuryListener --> Web socket online');
4000
3675
 
4001
3676
  // Only send restore event when it was disconnected before and for connected later
4002
- if (!_this25.hasWebsocketConnected) {
3677
+ if (!_this23.hasWebsocketConnected) {
4003
3678
  _metrics.default.postEvent({
4004
3679
  event: _config.eventType.MERCURY_CONNECTION_RESTORED,
4005
- meeting: _this25
3680
+ meeting: _this23
4006
3681
  });
4007
3682
  _metrics.default.sendBehavioralMetric(_constants2.default.MERCURY_CONNECTION_RESTORED, {
4008
- correlation_id: _this25.correlationId
3683
+ correlation_id: _this23.correlationId
4009
3684
  });
4010
3685
  }
4011
- _this25.hasWebsocketConnected = true;
3686
+ _this23.hasWebsocketConnected = true;
4012
3687
  });
4013
3688
 
4014
3689
  // @ts-ignore
@@ -4016,10 +3691,10 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4016
3691
  _loggerProxy.default.logger.error('Meeting:index#setMercuryListener --> Web socket offline');
4017
3692
  _metrics.default.postEvent({
4018
3693
  event: _config.eventType.MERCURY_CONNECTION_LOST,
4019
- meeting: _this25
3694
+ meeting: _this23
4020
3695
  });
4021
3696
  _metrics.default.sendBehavioralMetric(_constants2.default.MERCURY_CONNECTION_FAILURE, {
4022
- correlation_id: _this25.correlationId
3697
+ correlation_id: _this23.correlationId
4023
3698
  });
4024
3699
  });
4025
3700
  }
@@ -4047,6 +3722,8 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4047
3722
  this.receiveSlotManager.reset();
4048
3723
  this.mediaProperties.webrtcMediaConnection.close();
4049
3724
  }
3725
+ this.audio = null;
3726
+ this.video = null;
4050
3727
  return _promise.default.resolve();
4051
3728
  }
4052
3729
 
@@ -4081,246 +3758,41 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4081
3758
  this.correlationId = id;
4082
3759
  }
4083
3760
 
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
3761
  /**
4269
3762
  * Shorthand function to join AND set up media
4270
3763
  * @param {Object} options - options to join with media
4271
3764
  * @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()}
3765
+ * @param {MediaDirection} [options.mediaOptions] - see #addMedia()
3766
+ * @returns {Promise} -- {join: see join(), media: see addMedia()}
4275
3767
  * @public
4276
3768
  * @memberof Meeting
4277
3769
  * @example
4278
3770
  * joinWithMedia({
4279
3771
  * 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
- * }})
3772
+ * mediaOptions: {
3773
+ * localTracks: { microphone: microphoneTrack, camera: cameraTrack }
3774
+ * }
3775
+ * })
4292
3776
  */
4293
3777
  }, {
4294
3778
  key: "joinWithMedia",
4295
3779
  value: function joinWithMedia() {
4296
- var _this30 = this;
3780
+ var _this24 = this;
4297
3781
  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;
3782
+ var mediaOptions = options.mediaOptions,
3783
+ joinOptions = options.joinOptions;
4302
3784
  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
- });
3785
+ return _this24.addMedia(mediaOptions).then(function (mediaResponse) {
3786
+ return {
3787
+ join: joinResponse,
3788
+ media: mediaResponse
3789
+ };
4318
3790
  });
4319
3791
  }).catch(function (error) {
4320
3792
  _loggerProxy.default.logger.error('Meeting:index#joinWithMedia --> ', error);
4321
3793
  _metrics.default.sendBehavioralMetric(_constants2.default.JOIN_WITH_MEDIA_FAILURE, {
4322
- correlation_id: _this30.correlationId,
4323
- locus_id: _this30.locusUrl.split('/').pop(),
3794
+ correlation_id: _this24.correlationId,
3795
+ locus_id: _this24.locusUrl.split('/').pop(),
4324
3796
  reason: error.message,
4325
3797
  stack: error.stack
4326
3798
  }, {
@@ -4341,7 +3813,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4341
3813
  }, {
4342
3814
  key: "reconnect",
4343
3815
  value: function reconnect(options) {
4344
- var _this31 = this;
3816
+ var _this25 = this;
4345
3817
  _loggerProxy.default.logger.log("Meeting:index#reconnect --> attempting to reconnect meeting ".concat(this.id));
4346
3818
  if (!this.reconnectionManager || !this.reconnectionManager.reconnect) {
4347
3819
  return _promise.default.reject(new _parameter.default('Cannot reconnect, ReconnectionManager must first be defined.'));
@@ -4369,13 +3841,13 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4369
3841
  function: 'reconnect'
4370
3842
  }, _constants.EVENT_TRIGGERS.MEETING_RECONNECTION_STARTING);
4371
3843
  return this.reconnectionManager.reconnect(options).then(function () {
4372
- _triggerProxy.default.trigger(_this31, {
3844
+ _triggerProxy.default.trigger(_this25, {
4373
3845
  file: 'meeting/index',
4374
3846
  function: 'reconnect'
4375
3847
  }, _constants.EVENT_TRIGGERS.MEETING_RECONNECTION_SUCCESS);
4376
3848
  _loggerProxy.default.logger.log('Meeting:index#reconnect --> Meeting reconnect success');
4377
3849
  }).catch(function (error) {
4378
- _triggerProxy.default.trigger(_this31, {
3850
+ _triggerProxy.default.trigger(_this25, {
4379
3851
  file: 'meeting/index',
4380
3852
  function: 'reconnect'
4381
3853
  }, _constants.EVENT_TRIGGERS.MEETING_RECONNECTION_FAILURE, {
@@ -4383,18 +3855,18 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4383
3855
  });
4384
3856
  _loggerProxy.default.logger.error('Meeting:index#reconnect --> Meeting reconnect failed', error);
4385
3857
  _metrics.default.sendBehavioralMetric(_constants2.default.MEETING_RECONNECT_FAILURE, {
4386
- correlation_id: _this31.correlationId,
4387
- locus_id: _this31.locusUrl.split('/').pop(),
3858
+ correlation_id: _this25.correlationId,
3859
+ locus_id: _this25.locusUrl.split('/').pop(),
4388
3860
  reason: error.message,
4389
3861
  stack: error.stack
4390
3862
  });
4391
- _this31.uploadLogs({
3863
+ _this25.uploadLogs({
4392
3864
  file: 'meeting/index',
4393
3865
  function: 'reconnect'
4394
3866
  });
4395
3867
  return _promise.default.reject(new _reconnection.default('Reconnection failure event', error));
4396
3868
  }).finally(function () {
4397
- _this31.reconnectionManager.reset();
3869
+ _this25.reconnectionManager.reset();
4398
3870
  });
4399
3871
  }
4400
3872
 
@@ -4437,16 +3909,16 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4437
3909
  }, {
4438
3910
  key: "monitorTranscriptionSocketConnection",
4439
3911
  value: function monitorTranscriptionSocketConnection() {
4440
- var _this32 = this;
3912
+ var _this26 = this;
4441
3913
  this.transcription.onCloseSocket(function (event) {
4442
3914
  _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();
3915
+ _this26.triggerStopReceivingTranscriptionEvent();
4444
3916
  });
4445
3917
  this.transcription.onErrorSocket(function (event) {
4446
3918
  _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();
3919
+ _this26.triggerStopReceivingTranscriptionEvent();
4448
3920
  _metrics.default.sendBehavioralMetric(_constants2.default.RECEIVE_TRANSCRIPTION_FAILURE, {
4449
- correlation_id: _this32.correlationId,
3921
+ correlation_id: _this26.correlationId,
4450
3922
  reason: 'unexpected error: transcription LLM web socket connection error had occured.',
4451
3923
  event: event
4452
3924
  });
@@ -4461,16 +3933,16 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4461
3933
  }, {
4462
3934
  key: "receiveTranscription",
4463
3935
  value: function () {
4464
- var _receiveTranscription = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
4465
- var _this33 = this;
3936
+ var _receiveTranscription = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
3937
+ var _this27 = this;
4466
3938
  var datachannelUrl, _yield$this$request, webSocketUrl;
4467
- return _regenerator.default.wrap(function _callee4$(_context4) {
4468
- while (1) switch (_context4.prev = _context4.next) {
3939
+ return _regenerator.default.wrap(function _callee8$(_context8) {
3940
+ while (1) switch (_context8.prev = _context8.next) {
4469
3941
  case 0:
4470
3942
  _loggerProxy.default.logger.info("Meeting:index#receiveTranscription -->\n Attempting to generate a web socket url.");
4471
- _context4.prev = 1;
3943
+ _context8.prev = 1;
4472
3944
  datachannelUrl = this.locusInfo.info.datachannelUrl; // @ts-ignore - fix type
4473
- _context4.next = 5;
3945
+ _context8.next = 5;
4474
3946
  return this.request({
4475
3947
  method: _constants.HTTP_VERBS.POST,
4476
3948
  uri: datachannelUrl,
@@ -4479,7 +3951,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4479
3951
  }
4480
3952
  });
4481
3953
  case 5:
4482
- _yield$this$request = _context4.sent;
3954
+ _yield$this$request = _context8.sent;
4483
3955
  webSocketUrl = _yield$this$request.body.webSocketUrl;
4484
3956
  _loggerProxy.default.logger.info("Meeting:index#receiveTranscription -->\n Generated web socket url succesfully.");
4485
3957
  this.transcription = new _transcription.default(webSocketUrl,
@@ -4489,7 +3961,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4489
3961
 
4490
3962
  // retrieve and pass the payload
4491
3963
  this.transcription.subscribe(function (payload) {
4492
- _triggerProxy.default.trigger(_this33, {
3964
+ _triggerProxy.default.trigger(_this27, {
4493
3965
  file: 'meeting/index',
4494
3966
  function: 'join'
4495
3967
  }, _constants.EVENT_TRIGGERS.MEETING_STARTED_RECEIVING_TRANSCRIPTION, payload);
@@ -4497,22 +3969,22 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4497
3969
  this.monitorTranscriptionSocketConnection();
4498
3970
  // @ts-ignore - fix type
4499
3971
  this.transcription.connect(this.webex.credentials.supertoken.access_token);
4500
- _context4.next = 19;
3972
+ _context8.next = 19;
4501
3973
  break;
4502
3974
  case 15:
4503
- _context4.prev = 15;
4504
- _context4.t0 = _context4["catch"](1);
4505
- _loggerProxy.default.logger.error("Meeting:index#receiveTranscription --> ".concat(_context4.t0));
3975
+ _context8.prev = 15;
3976
+ _context8.t0 = _context8["catch"](1);
3977
+ _loggerProxy.default.logger.error("Meeting:index#receiveTranscription --> ".concat(_context8.t0));
4506
3978
  _metrics.default.sendBehavioralMetric(_constants2.default.RECEIVE_TRANSCRIPTION_FAILURE, {
4507
3979
  correlation_id: this.correlationId,
4508
- reason: _context4.t0.message,
4509
- stack: _context4.t0.stack
3980
+ reason: _context8.t0.message,
3981
+ stack: _context8.t0.stack
4510
3982
  });
4511
3983
  case 19:
4512
3984
  case "end":
4513
- return _context4.stop();
3985
+ return _context8.stop();
4514
3986
  }
4515
- }, _callee4, this, [[1, 15]]);
3987
+ }, _callee8, this, [[1, 15]]);
4516
3988
  }));
4517
3989
  function receiveTranscription() {
4518
3990
  return _receiveTranscription.apply(this, arguments);
@@ -4570,7 +4042,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4570
4042
  }, {
4571
4043
  key: "join",
4572
4044
  value: function join() {
4573
- var _this34 = this;
4045
+ var _this28 = this;
4574
4046
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4575
4047
  // @ts-ignore - fix type
4576
4048
  if (!this.webex.meetings.registered) {
@@ -4654,21 +4126,17 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4654
4126
  this.deferJoin = undefined;
4655
4127
  return _promise.default.reject(_error);
4656
4128
  }
4657
- this.mediaProperties.setLocalQualityLevel(options.meetingQuality);
4658
4129
  this.mediaProperties.setRemoteQualityLevel(options.meetingQuality);
4659
4130
  }
4660
4131
  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");
4132
+ if (!_constants.QUALITY_LEVELS[options.meetingQuality.remote]) {
4133
+ var _errorMessage2 = "Meeting:index#join --> ".concat(options.meetingQuality.remote, " not defined");
4663
4134
  _loggerProxy.default.logger.error(_errorMessage2);
4664
4135
  var _error2 = new Error(_errorMessage2);
4665
4136
  joinFailed(_error2);
4666
4137
  this.deferJoin = undefined;
4667
4138
  return _promise.default.reject(new Error(_errorMessage2));
4668
4139
  }
4669
- if (options.meetingQuality.local) {
4670
- this.mediaProperties.setLocalQualityLevel(options.meetingQuality.local);
4671
- }
4672
4140
  if (options.meetingQuality.remote) {
4673
4141
  this.mediaProperties.setRemoteQualityLevel(options.meetingQuality.remote);
4674
4142
  }
@@ -4676,83 +4144,83 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4676
4144
  }
4677
4145
  this.isMultistream = !!options.enableMultistream;
4678
4146
  return _util.default.joinMeetingOptions(this, options).then(function (join) {
4679
- _this34.meetingFiniteStateMachine.join();
4147
+ _this28.meetingFiniteStateMachine.join();
4680
4148
  _loggerProxy.default.logger.log('Meeting:index#join --> Success');
4681
4149
  return join;
4682
4150
  }).then(function (join) {
4683
4151
  joinSuccess(join);
4684
- _this34.deferJoin = undefined;
4152
+ _this28.deferJoin = undefined;
4685
4153
  _metrics.default.sendBehavioralMetric(_constants2.default.JOIN_SUCCESS, {
4686
- correlation_id: _this34.correlationId
4154
+ correlation_id: _this28.correlationId
4687
4155
  });
4688
4156
  return join;
4689
4157
  }).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) {
4158
+ var _ref19 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(join) {
4159
+ return _regenerator.default.wrap(function _callee9$(_context9) {
4160
+ while (1) switch (_context9.prev = _context9.next) {
4693
4161
  case 0:
4694
- if (!_this34.config.enableAutomaticLLM) {
4695
- _context5.next = 3;
4162
+ if (!_this28.config.enableAutomaticLLM) {
4163
+ _context9.next = 3;
4696
4164
  break;
4697
4165
  }
4698
- _context5.next = 3;
4699
- return _this34.updateLLMConnection();
4166
+ _context9.next = 3;
4167
+ return _this28.updateLLMConnection();
4700
4168
  case 3:
4701
- return _context5.abrupt("return", join);
4169
+ return _context9.abrupt("return", join);
4702
4170
  case 4:
4703
4171
  case "end":
4704
- return _context5.stop();
4172
+ return _context9.stop();
4705
4173
  }
4706
- }, _callee5);
4174
+ }, _callee9);
4707
4175
  }));
4708
- return function (_x3) {
4709
- return _ref22.apply(this, arguments);
4176
+ return function (_x7) {
4177
+ return _ref19.apply(this, arguments);
4710
4178
  };
4711
4179
  }()).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) {
4180
+ var _ref20 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(join) {
4181
+ return _regenerator.default.wrap(function _callee10$(_context10) {
4182
+ while (1) switch (_context10.prev = _context10.next) {
4715
4183
  case 0:
4716
4184
  if (!isBrowser) {
4717
- _context6.next = 8;
4185
+ _context10.next = 8;
4718
4186
  break;
4719
4187
  }
4720
- if (!(_this34.config.receiveTranscription || options.receiveTranscription)) {
4721
- _context6.next = 6;
4188
+ if (!(_this28.config.receiveTranscription || options.receiveTranscription)) {
4189
+ _context10.next = 6;
4722
4190
  break;
4723
4191
  }
4724
- if (!_this34.isTranscriptionSupported()) {
4725
- _context6.next = 6;
4192
+ if (!_this28.isTranscriptionSupported()) {
4193
+ _context10.next = 6;
4726
4194
  break;
4727
4195
  }
4728
- _context6.next = 5;
4729
- return _this34.receiveTranscription();
4196
+ _context10.next = 5;
4197
+ return _this28.receiveTranscription();
4730
4198
  case 5:
4731
4199
  _loggerProxy.default.logger.info('Meeting:index#join --> enabled to recieve transcription!');
4732
4200
  case 6:
4733
- _context6.next = 9;
4201
+ _context10.next = 9;
4734
4202
  break;
4735
4203
  case 8:
4736
4204
  _loggerProxy.default.logger.error('Meeting:index#join --> Receving transcription is not supported on this platform');
4737
4205
  case 9:
4738
- return _context6.abrupt("return", join);
4206
+ return _context10.abrupt("return", join);
4739
4207
  case 10:
4740
4208
  case "end":
4741
- return _context6.stop();
4209
+ return _context10.stop();
4742
4210
  }
4743
- }, _callee6);
4211
+ }, _callee10);
4744
4212
  }));
4745
- return function (_x4) {
4746
- return _ref23.apply(this, arguments);
4213
+ return function (_x8) {
4214
+ return _ref20.apply(this, arguments);
4747
4215
  };
4748
4216
  }()).catch(function (error) {
4749
4217
  var _error$error;
4750
- _this34.meetingFiniteStateMachine.fail(error);
4218
+ _this28.meetingFiniteStateMachine.fail(error);
4751
4219
  _loggerProxy.default.logger.error('Meeting:index#join --> Failed', error);
4752
4220
  _metrics.default.postEvent({
4753
4221
  event: _config.eventType.LOCUS_JOIN_RESPONSE,
4754
- meeting: _this34,
4755
- meetingId: _this34.id,
4222
+ meeting: _this28,
4223
+ meetingId: _this28.id,
4756
4224
  data: {
4757
4225
  errors: [_metrics.default.parseLocusError(error.error, true)]
4758
4226
  }
@@ -4760,18 +4228,18 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4760
4228
 
4761
4229
  // TODO: change this to error codes and pre defined dictionary
4762
4230
  _metrics.default.sendBehavioralMetric(_constants2.default.JOIN_FAILURE, {
4763
- correlation_id: _this34.correlationId,
4231
+ correlation_id: _this28.correlationId,
4764
4232
  reason: (_error$error = error.error) === null || _error$error === void 0 ? void 0 : _error$error.message,
4765
4233
  stack: error.stack
4766
4234
  });
4767
4235
 
4768
4236
  // Upload logs on join Failure
4769
- _triggerProxy.default.trigger(_this34, {
4237
+ _triggerProxy.default.trigger(_this28, {
4770
4238
  file: 'meeting/index',
4771
4239
  function: 'join'
4772
- }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this34);
4240
+ }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this28);
4773
4241
  joinFailed(error);
4774
- _this34.deferJoin = undefined;
4242
+ _this28.deferJoin = undefined;
4775
4243
  return _promise.default.reject(error);
4776
4244
  });
4777
4245
  }
@@ -4785,50 +4253,50 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4785
4253
  }, {
4786
4254
  key: "updateLLMConnection",
4787
4255
  value: function () {
4788
- var _updateLLMConnection = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
4789
- var _this35 = this;
4256
+ var _updateLLMConnection = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
4257
+ var _this29 = this;
4790
4258
  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) {
4259
+ return _regenerator.default.wrap(function _callee11$(_context11) {
4260
+ while (1) switch (_context11.prev = _context11.next) {
4793
4261
  case 0:
4794
4262
  // @ts-ignore - Fix type
4795
4263
  _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
4264
  isJoined = this.joinedWith && this.joinedWith.state === 'JOINED'; // @ts-ignore - Fix type
4797
4265
  if (!this.webex.internal.llm.isConnected()) {
4798
- _context7.next = 8;
4266
+ _context11.next = 8;
4799
4267
  break;
4800
4268
  }
4801
4269
  if (!(url === this.webex.internal.llm.getLocusUrl() && isJoined)) {
4802
- _context7.next = 5;
4270
+ _context11.next = 5;
4803
4271
  break;
4804
4272
  }
4805
- return _context7.abrupt("return", undefined);
4273
+ return _context11.abrupt("return", undefined);
4806
4274
  case 5:
4807
- _context7.next = 7;
4275
+ _context11.next = 7;
4808
4276
  return this.webex.internal.llm.disconnectLLM();
4809
4277
  case 7:
4810
4278
  // @ts-ignore - Fix type
4811
4279
  this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
4812
4280
  case 8:
4813
4281
  if (isJoined) {
4814
- _context7.next = 10;
4282
+ _context11.next = 10;
4815
4283
  break;
4816
4284
  }
4817
- return _context7.abrupt("return", undefined);
4285
+ return _context11.abrupt("return", undefined);
4818
4286
  case 10:
4819
- return _context7.abrupt("return", this.webex.internal.llm.registerAndConnect(url, datachannelUrl).then(function (registerAndConnectResult) {
4287
+ return _context11.abrupt("return", this.webex.internal.llm.registerAndConnect(url, datachannelUrl).then(function (registerAndConnectResult) {
4820
4288
  // @ts-ignore - Fix type
4821
- _this35.webex.internal.llm.off('event:relay.event', _this35.processRelayEvent);
4289
+ _this29.webex.internal.llm.off('event:relay.event', _this29.processRelayEvent);
4822
4290
  // @ts-ignore - Fix type
4823
- _this35.webex.internal.llm.on('event:relay.event', _this35.processRelayEvent);
4291
+ _this29.webex.internal.llm.on('event:relay.event', _this29.processRelayEvent);
4824
4292
  _loggerProxy.default.logger.info('Meeting:index#updateLLMConnection --> enabled to receive relay events!');
4825
4293
  return _promise.default.resolve(registerAndConnectResult);
4826
4294
  }));
4827
4295
  case 11:
4828
4296
  case "end":
4829
- return _context7.stop();
4297
+ return _context11.stop();
4830
4298
  }
4831
- }, _callee7, this);
4299
+ }, _callee11, this);
4832
4300
  }));
4833
4301
  function updateLLMConnection() {
4834
4302
  return _updateLLMConnection.apply(this, arguments);
@@ -4873,7 +4341,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4873
4341
  }, {
4874
4342
  key: "dialInPstn",
4875
4343
  value: function dialInPstn() {
4876
- var _this36 = this;
4344
+ var _this30 = this;
4877
4345
  if (this.isPhoneProvisioned(this.dialInDeviceStatus)) return _promise.default.resolve(); // prevent multiple dial in devices from being provisioned
4878
4346
 
4879
4347
  var correlationId = this.correlationId,
@@ -4889,10 +4357,10 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4889
4357
  }).catch(function (error) {
4890
4358
  var _error$error2;
4891
4359
  _metrics.default.sendBehavioralMetric(_constants2.default.ADD_DIAL_IN_FAILURE, {
4892
- correlation_id: _this36.correlationId,
4893
- dial_in_url: _this36.dialInUrl,
4360
+ correlation_id: _this30.correlationId,
4361
+ dial_in_url: _this30.dialInUrl,
4894
4362
  locus_id: locusUrl.split('/').pop(),
4895
- client_url: _this36.deviceUrl,
4363
+ client_url: _this30.deviceUrl,
4896
4364
  reason: (_error$error2 = error.error) === null || _error$error2 === void 0 ? void 0 : _error$error2.message,
4897
4365
  stack: error.stack
4898
4366
  });
@@ -4910,7 +4378,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4910
4378
  }, {
4911
4379
  key: "dialOutPstn",
4912
4380
  value: function dialOutPstn(phoneNumber) {
4913
- var _this37 = this;
4381
+ var _this31 = this;
4914
4382
  if (this.isPhoneProvisioned(this.dialOutDeviceStatus)) return _promise.default.resolve(); // prevent multiple dial out devices from being provisioned
4915
4383
 
4916
4384
  var correlationId = this.correlationId,
@@ -4927,10 +4395,10 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4927
4395
  }).catch(function (error) {
4928
4396
  var _error$error3;
4929
4397
  _metrics.default.sendBehavioralMetric(_constants2.default.ADD_DIAL_OUT_FAILURE, {
4930
- correlation_id: _this37.correlationId,
4931
- dial_out_url: _this37.dialOutUrl,
4398
+ correlation_id: _this31.correlationId,
4399
+ dial_out_url: _this31.dialOutUrl,
4932
4400
  locus_id: locusUrl.split('/').pop(),
4933
- client_url: _this37.deviceUrl,
4401
+ client_url: _this31.deviceUrl,
4934
4402
  reason: (_error$error3 = error.error) === null || _error$error3 === void 0 ? void 0 : _error$error3.message,
4935
4403
  stack: error.stack
4936
4404
  });
@@ -4961,7 +4429,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4961
4429
  }, {
4962
4430
  key: "moveTo",
4963
4431
  value: function moveTo(resourceId) {
4964
- var _this38 = this;
4432
+ var _this32 = this;
4965
4433
  if (!resourceId) {
4966
4434
  throw new _parameter.default('Cannot move call without a resourceId.');
4967
4435
  }
@@ -4991,18 +4459,18 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
4991
4459
  event: _config.eventType.MOVE_MEDIA,
4992
4460
  meeting: this
4993
4461
  });
4994
- this.locusInfo.once(_constants.LOCUSINFO.EVENTS.SELF_OBSERVING, /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
4462
+ this.locusInfo.once(_constants.LOCUSINFO.EVENTS.SELF_OBSERVING, /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
4995
4463
  var mediaSettings;
4996
- return _regenerator.default.wrap(function _callee8$(_context8) {
4997
- while (1) switch (_context8.prev = _context8.next) {
4464
+ return _regenerator.default.wrap(function _callee12$(_context12) {
4465
+ while (1) switch (_context12.prev = _context12.next) {
4998
4466
  case 0:
4999
- _context8.prev = 0;
5000
- if (!_this38.isSharing) {
5001
- _context8.next = 4;
4467
+ _context12.prev = 0;
4468
+ if (!_this32.isSharing) {
4469
+ _context12.next = 4;
5002
4470
  break;
5003
4471
  }
5004
- _context8.next = 4;
5005
- return _this38.releaseScreenShareFloor();
4472
+ _context12.next = 4;
4473
+ return _this32.releaseScreenShareFloor();
5006
4474
  case 4:
5007
4475
  mediaSettings = {
5008
4476
  mediaDirection: {
@@ -5013,55 +4481,48 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5013
4481
  sendShare: false,
5014
4482
  receiveShare: true
5015
4483
  }
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();
4484
+ };
4485
+ _this32.cleanupLocalTracks();
4486
+ _this32.mediaProperties.setMediaDirection(mediaSettings.mediaDirection);
4487
+ _this32.mediaProperties.unsetRemoteMedia();
5027
4488
 
5028
4489
  // 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
4490
  // once the DX answers we establish connection back the media server with only receiveShare enabled
5030
4491
  // @ts-ignore - reconnectMedia does not accept any argument
5031
- _context8.next = 13;
5032
- return _this38.reconnectionManager.reconnectMedia(mediaSettings).then(function () {
4492
+ _context12.next = 10;
4493
+ return _this32.reconnectionManager.reconnectMedia(mediaSettings).then(function () {
5033
4494
  _metrics.default.sendBehavioralMetric(_constants2.default.MOVE_TO_SUCCESS);
5034
4495
  });
5035
- case 13:
5036
- _context8.next = 19;
4496
+ case 10:
4497
+ _context12.next = 16;
5037
4498
  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);
4499
+ case 12:
4500
+ _context12.prev = 12;
4501
+ _context12.t0 = _context12["catch"](0);
4502
+ _loggerProxy.default.logger.error('Meeting:index#moveTo --> Failed to moveTo resourceId', _context12.t0);
5042
4503
  _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
4504
+ correlation_id: _this32.correlationId,
4505
+ locus_id: _this32.locusUrl.split('/').pop(),
4506
+ reason: _context12.t0.message,
4507
+ stack: _context12.t0.stack
5047
4508
  });
5048
- case 19:
4509
+ case 16:
5049
4510
  case "end":
5050
- return _context8.stop();
4511
+ return _context12.stop();
5051
4512
  }
5052
- }, _callee8, null, [[0, 15]]);
4513
+ }, _callee12, null, [[0, 12]]);
5053
4514
  })));
5054
4515
  _loggerProxy.default.logger.info('Meeting:index#moveTo --> Initated moved to using resourceId', resourceId);
5055
4516
  return _util.default.joinMeetingOptions(this, {
5056
4517
  resourceId: resourceId,
5057
4518
  moveToResource: true
5058
4519
  }).then(function () {
5059
- _this38.meetingFiniteStateMachine.join();
4520
+ _this32.meetingFiniteStateMachine.join();
5060
4521
  }).catch(function (error) {
5061
- _this38.meetingFiniteStateMachine.fail(error);
4522
+ _this32.meetingFiniteStateMachine.fail(error);
5062
4523
  _metrics.default.sendBehavioralMetric(_constants2.default.MOVE_TO_FAILURE, {
5063
- correlation_id: _this38.correlationId,
5064
- locus_id: _this38.locusUrl.split('/').pop(),
4524
+ correlation_id: _this32.correlationId,
4525
+ locus_id: _this32.locusUrl.split('/').pop(),
5065
4526
  reason: error.message,
5066
4527
  stack: error.stack
5067
4528
  });
@@ -5080,7 +4541,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5080
4541
  }, {
5081
4542
  key: "moveFrom",
5082
4543
  value: function moveFrom(resourceId) {
5083
- var _this39 = this;
4544
+ var _this33 = this;
5084
4545
  // On moveFrom ask the developer to re capture it moveFrom then updateMedia
5085
4546
  if (!resourceId) {
5086
4547
  throw new _parameter.default('Cannot move call without a resourceId.');
@@ -5091,19 +4552,19 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5091
4552
  meeting: this
5092
4553
  });
5093
4554
  return _util.default.joinMeetingOptions(this).then(function () {
5094
- return _util.default.leaveMeeting(_this39, {
4555
+ return _util.default.leaveMeeting(_this33, {
5095
4556
  resourceId: resourceId,
5096
4557
  correlationId: oldCorrelationId,
5097
4558
  moveMeeting: true
5098
4559
  }).then(function () {
5099
- _this39.resourceId = '';
4560
+ _this33.resourceId = '';
5100
4561
  _metrics.default.sendBehavioralMetric(_constants2.default.MOVE_FROM_SUCCESS);
5101
4562
  });
5102
4563
  }).catch(function (error) {
5103
- _this39.meetingFiniteStateMachine.fail(error);
4564
+ _this33.meetingFiniteStateMachine.fail(error);
5104
4565
  _metrics.default.sendBehavioralMetric(_constants2.default.MOVE_FROM_FAILURE, {
5105
- correlation_id: _this39.correlationId,
5106
- locus_id: _this39.locusUrl.split('/').pop(),
4566
+ correlation_id: _this33.correlationId,
4567
+ locus_id: _this33.locusUrl.split('/').pop(),
5107
4568
  reason: error.message,
5108
4569
  stack: error.stack
5109
4570
  });
@@ -5113,17 +4574,10 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5113
4574
  }
5114
4575
 
5115
4576
  /**
5116
- * Get local media streams based on options passed
4577
+ * Handles ROAP_FAILURE event from the webrtc media connection
5117
4578
  *
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
4579
+ * @param {Error} error
4580
+ * @returns {void}
5127
4581
  */
5128
4582
  }, {
5129
4583
  key: "getMediaConnectionDebugId",
@@ -5132,7 +4586,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5132
4586
  }
5133
4587
 
5134
4588
  /**
5135
- * Creates a webrtc media connection
4589
+ * Creates a webrtc media connection and publishes tracks to it
5136
4590
  *
5137
4591
  * @param {Object} turnServerInfo TURN server information
5138
4592
  * @param {BundlePolicy} [bundlePolicy] Bundle policy settings
@@ -5140,22 +4594,60 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5140
4594
  */
5141
4595
  }, {
5142
4596
  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
- }
4597
+ value: function () {
4598
+ var _createMediaConnection = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(turnServerInfo, bundlePolicy) {
4599
+ var mc;
4600
+ return _regenerator.default.wrap(function _callee13$(_context13) {
4601
+ while (1) switch (_context13.prev = _context13.next) {
4602
+ case 0:
4603
+ // create the actual media connection
4604
+ mc = _media.default.createMediaConnection(this.isMultistream, this.getMediaConnectionDebugId(), {
4605
+ mediaProperties: this.mediaProperties,
4606
+ remoteQualityLevel: this.mediaProperties.remoteQualityLevel,
4607
+ // @ts-ignore - config coming from registerPlugin
4608
+ enableRtx: this.config.enableRtx,
4609
+ // @ts-ignore - config coming from registerPlugin
4610
+ enableExtmap: this.config.enableExtmap,
4611
+ turnServerInfo: turnServerInfo,
4612
+ bundlePolicy: bundlePolicy
4613
+ });
4614
+ this.mediaProperties.setMediaPeerConnection(mc);
4615
+ this.setupMediaConnectionListeners();
5158
4616
 
4617
+ // publish the tracks
4618
+ if (!this.mediaProperties.audioTrack) {
4619
+ _context13.next = 6;
4620
+ break;
4621
+ }
4622
+ _context13.next = 6;
4623
+ return this.publishTrack(this.mediaProperties.audioTrack);
4624
+ case 6:
4625
+ if (!this.mediaProperties.videoTrack) {
4626
+ _context13.next = 9;
4627
+ break;
4628
+ }
4629
+ _context13.next = 9;
4630
+ return this.publishTrack(this.mediaProperties.videoTrack);
4631
+ case 9:
4632
+ if (!this.mediaProperties.shareTrack) {
4633
+ _context13.next = 12;
4634
+ break;
4635
+ }
4636
+ _context13.next = 12;
4637
+ return this.publishTrack(this.mediaProperties.shareTrack);
4638
+ case 12:
4639
+ return _context13.abrupt("return", mc);
4640
+ case 13:
4641
+ case "end":
4642
+ return _context13.stop();
4643
+ }
4644
+ }, _callee13, this);
4645
+ }));
4646
+ function createMediaConnection(_x9, _x10) {
4647
+ return _createMediaConnection.apply(this, arguments);
4648
+ }
4649
+ return createMediaConnection;
4650
+ }()
5159
4651
  /**
5160
4652
  * Listens for an event emitted by eventEmitter and emits it from the meeting object
5161
4653
  *
@@ -5168,9 +4660,9 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5168
4660
  }, {
5169
4661
  key: "forwardEvent",
5170
4662
  value: function forwardEvent(eventEmitter, eventTypeToForward, meetingEventType) {
5171
- var _this40 = this;
4663
+ var _this34 = this;
5172
4664
  eventEmitter.on(eventTypeToForward, function (data) {
5173
- return _triggerProxy.default.trigger(_this40, {
4665
+ return _triggerProxy.default.trigger(_this34, {
5174
4666
  file: 'meetings',
5175
4667
  function: 'addMedia'
5176
4668
  }, meetingEventType, data);
@@ -5178,14 +4670,9 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5178
4670
  }
5179
4671
 
5180
4672
  /**
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
4673
+ * Creates a media connection to the server. Media connection is required for sending or receiving any audio/video.
4674
+ *
4675
+ * @param {AddMediaOptions} options
5189
4676
  * @returns {Promise}
5190
4677
  * @public
5191
4678
  * @memberof Meeting
@@ -5193,11 +4680,13 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5193
4680
  }, {
5194
4681
  key: "addMedia",
5195
4682
  value: function addMedia() {
5196
- var _this41 = this;
4683
+ var _localTracks$screenSh,
4684
+ _this35 = this;
5197
4685
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5198
4686
  var LOG_HEADER = 'Meeting:index#addMedia -->';
5199
4687
  var turnDiscoverySkippedReason;
5200
4688
  var turnServerUsed = false;
4689
+ _loggerProxy.default.logger.info("".concat(LOG_HEADER, " called with: ").concat((0, _stringify.default)(options)));
5201
4690
  if (this.meetingState !== _constants.FULL_STATE.ACTIVE) {
5202
4691
  return _promise.default.reject(new _webexErrors.MeetingNotActiveError());
5203
4692
  }
@@ -5209,12 +4698,15 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5209
4698
  if (this.isUserUnadmitted && !this.wirelessShare) {
5210
4699
  return _promise.default.reject(new _webexErrors.UserInLobbyError());
5211
4700
  }
5212
- var localStream = options.localStream,
5213
- localShare = options.localShare,
5214
- mediaSettings = options.mediaSettings,
4701
+ var localTracks = options.localTracks,
4702
+ _options$audioEnabled = options.audioEnabled,
4703
+ audioEnabled = _options$audioEnabled === void 0 ? true : _options$audioEnabled,
4704
+ _options$videoEnabled = options.videoEnabled,
4705
+ videoEnabled = _options$videoEnabled === void 0 ? true : _options$videoEnabled,
4706
+ _options$receiveShare = options.receiveShare,
4707
+ receiveShare = _options$receiveShare === void 0 ? true : _options$receiveShare,
5215
4708
  remoteMediaManagerConfig = options.remoteMediaManagerConfig,
5216
4709
  bundlePolicy = options.bundlePolicy;
5217
- _loggerProxy.default.logger.info("".concat(LOG_HEADER, " Adding Media."));
5218
4710
  _metrics.default.postEvent({
5219
4711
  event: _config.eventType.MEDIA_CAPABILITIES,
5220
4712
  meeting: this,
@@ -5237,58 +4729,103 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5237
4729
  }
5238
4730
  }
5239
4731
  });
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
- }, {
4732
+
4733
+ // when audioEnabled/videoEnabled is true, we set sendAudio/sendVideo to true even before any tracks are published
4734
+ // to avoid doing an extra SDP exchange when they are published for the first time
4735
+ this.mediaProperties.setMediaDirection({
4736
+ sendAudio: audioEnabled,
4737
+ sendVideo: videoEnabled,
4738
+ sendShare: false,
4739
+ receiveAudio: audioEnabled,
4740
+ receiveVideo: videoEnabled,
4741
+ receiveShare: receiveShare
4742
+ });
4743
+ this.locusMediaRequest = new _locusMediaRequest.LocusMediaRequest({
4744
+ correlationId: this.correlationId,
4745
+ device: {
4746
+ url: this.deviceUrl,
5250
4747
  // @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();
4748
+ deviceType: this.config.deviceType
4749
+ },
4750
+ preferTranscoding: !this.isMultistream
4751
+ }, {
4752
+ // @ts-ignore
4753
+ parent: this.webex
4754
+ });
4755
+ this.audio = (0, _muteState.createMuteState)(_constants.AUDIO, this, audioEnabled);
4756
+ this.video = (0, _muteState.createMuteState)(_constants.VIDEO, this, videoEnabled);
4757
+ this.annotationInfo = localTracks === null || localTracks === void 0 ? void 0 : localTracks.annotationInfo;
4758
+ var promises = [];
4759
+
4760
+ // setup all the references to local tracks in this.mediaProperties before creating media connection
4761
+ // and before TURN discovery, so that the correct mute state is sent with TURN discovery roap messages
4762
+ if (localTracks !== null && localTracks !== void 0 && localTracks.microphone) {
4763
+ promises.push(this.setLocalAudioTrack(localTracks.microphone));
4764
+ }
4765
+ if (localTracks !== null && localTracks !== void 0 && localTracks.camera) {
4766
+ promises.push(this.setLocalVideoTrack(localTracks.camera));
4767
+ }
4768
+ if (localTracks !== null && localTracks !== void 0 && (_localTracks$screenSh = localTracks.screenShare) !== null && _localTracks$screenSh !== void 0 && _localTracks$screenSh.video) {
4769
+ promises.push(this.setLocalShareTrack(localTracks.screenShare.video));
4770
+ }
4771
+ return _promise.default.all(promises).then(function () {
4772
+ return _this35.roap.doTurnDiscovery(_this35, false);
4773
+ }).then( /*#__PURE__*/function () {
4774
+ var _ref22 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(turnDiscoveryObject) {
4775
+ var turnServerInfo, mc;
4776
+ return _regenerator.default.wrap(function _callee14$(_context14) {
4777
+ while (1) switch (_context14.prev = _context14.next) {
4778
+ case 0:
4779
+ turnDiscoverySkippedReason = turnDiscoveryObject.turnDiscoverySkippedReason;
4780
+ turnServerUsed = !turnDiscoverySkippedReason;
4781
+ turnServerInfo = turnDiscoveryObject.turnServerInfo;
4782
+ _context14.next = 5;
4783
+ return _this35.createMediaConnection(turnServerInfo, bundlePolicy);
4784
+ case 5:
4785
+ mc = _context14.sent;
4786
+ if (!_this35.isMultistream) {
4787
+ _context14.next = 13;
4788
+ break;
4789
+ }
4790
+ _this35.remoteMediaManager = new _remoteMediaManager.RemoteMediaManager(_this35.receiveSlotManager, _this35.mediaRequestManagers, remoteMediaManagerConfig);
4791
+ _this35.forwardEvent(_this35.remoteMediaManager, _remoteMediaManager.Event.AudioCreated, _constants.EVENT_TRIGGERS.REMOTE_MEDIA_AUDIO_CREATED);
4792
+ _this35.forwardEvent(_this35.remoteMediaManager, _remoteMediaManager.Event.ScreenShareAudioCreated, _constants.EVENT_TRIGGERS.REMOTE_MEDIA_SCREEN_SHARE_AUDIO_CREATED);
4793
+ _this35.forwardEvent(_this35.remoteMediaManager, _remoteMediaManager.Event.VideoLayoutChanged, _constants.EVENT_TRIGGERS.REMOTE_MEDIA_VIDEO_LAYOUT_CHANGED);
4794
+ _context14.next = 13;
4795
+ return _this35.remoteMediaManager.start();
4796
+ case 13:
4797
+ _context14.next = 15;
4798
+ return mc.initiateOffer();
4799
+ case 15:
4800
+ case "end":
4801
+ return _context14.stop();
4802
+ }
4803
+ }, _callee14);
4804
+ }));
4805
+ return function (_x11) {
4806
+ return _ref22.apply(this, arguments);
4807
+ };
4808
+ }()).then(function () {
4809
+ _this35.setMercuryListener();
5273
4810
  }).then(function () {
5274
- return _this41.getDevices().then(function (devices) {
4811
+ return (0, _mediaHelpers.getDevices)().then(function (devices) {
5275
4812
  _util.default.handleDeviceLogging(devices);
5276
4813
  });
5277
4814
  }).then(function () {
5278
- _this41.handleMediaLogging(_this41.mediaProperties);
4815
+ _this35.handleMediaLogging(_this35.mediaProperties);
5279
4816
  _loggerProxy.default.logger.info("".concat(LOG_HEADER, " media connection created"));
5280
4817
 
5281
4818
  // @ts-ignore - config coming from registerPlugin
5282
- if (_this41.config.stats.enableStatsAnalyzer) {
4819
+ if (_this35.config.stats.enableStatsAnalyzer) {
5283
4820
  // @ts-ignore - config coming from registerPlugin
5284
- _this41.networkQualityMonitor = new _networkQualityMonitor.default(_this41.config.stats);
5285
- _this41.statsAnalyzer = new _statsAnalyzer.StatsAnalyzer(
4821
+ _this35.networkQualityMonitor = new _networkQualityMonitor.default(_this35.config.stats);
4822
+ _this35.statsAnalyzer = new _statsAnalyzer.StatsAnalyzer(
5286
4823
  // @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));
4824
+ _this35.config.stats, function (ssrc) {
4825
+ return _this35.receiveSlotManager.findReceiveSlotBySsrc(ssrc);
4826
+ }, _this35.networkQualityMonitor);
4827
+ _this35.setupStatsAnalyzerEventHandlers();
4828
+ _this35.networkQualityMonitor.on(_constants.EVENT_TRIGGERS.NETWORK_QUALITY, _this35.sendNetworkQualityEvent.bind(_this35));
5292
4829
  }
5293
4830
  }).catch(function (error) {
5294
4831
  _loggerProxy.default.logger.error("".concat(LOG_HEADER, " Error adding media , setting up peerconnection, "), error);
@@ -5299,12 +4836,12 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5299
4836
 
5300
4837
  // eslint-disable-next-line func-names
5301
4838
  // eslint-disable-next-line prefer-arrow-callback
5302
- if (_this41.type === _constants._CALL_) {
4839
+ if (_this35.type === _constants._CALL_ || _this35.meetingState === _constants.FULL_STATE.ACTIVE) {
5303
4840
  resolve();
5304
4841
  }
5305
4842
  var joiningTimer = setInterval(function () {
5306
4843
  timerCount += 1;
5307
- if (_this41.meetingState === _constants.FULL_STATE.ACTIVE) {
4844
+ if (_this35.meetingState === _constants.FULL_STATE.ACTIVE) {
5308
4845
  clearInterval(joiningTimer);
5309
4846
  resolve();
5310
4847
  }
@@ -5315,62 +4852,74 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5315
4852
  }, 1000);
5316
4853
  });
5317
4854
  }).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));
4855
+ return _this35.mediaProperties.waitForMediaConnectionConnected().catch(function () {
4856
+ throw new Error("Timed out waiting for media connection to be connected, correlationId=".concat(_this35.correlationId));
5320
4857
  });
5321
4858
  }).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;
4859
+ var _localTracks$screenSh2;
4860
+ if (localTracks !== null && localTracks !== void 0 && (_localTracks$screenSh2 = localTracks.screenShare) !== null && _localTracks$screenSh2 !== void 0 && _localTracks$screenSh2.video) {
4861
+ _this35.enqueueMediaUpdate(MEDIA_UPDATE_TYPE.LAMBDA, {
4862
+ lambda: function () {
4863
+ var _lambda = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15() {
4864
+ return _regenerator.default.wrap(function _callee15$(_context15) {
4865
+ while (1) switch (_context15.prev = _context15.next) {
4866
+ case 0:
4867
+ return _context15.abrupt("return", _this35.requestScreenShareFloor());
4868
+ case 1:
4869
+ case "end":
4870
+ return _context15.stop();
4871
+ }
4872
+ }, _callee15);
4873
+ }));
4874
+ function lambda() {
4875
+ return _lambda.apply(this, arguments);
4876
+ }
4877
+ return lambda;
4878
+ }()
4879
+ });
5330
4880
  }
5331
- return {};
5332
4881
  }).then(function () {
5333
- return _this41.mediaProperties.getCurrentConnectionType();
4882
+ return _this35.mediaProperties.getCurrentConnectionType();
5334
4883
  }).then(function (connectionType) {
5335
4884
  _metrics.default.sendBehavioralMetric(_constants2.default.ADD_MEDIA_SUCCESS, {
5336
- correlation_id: _this41.correlationId,
5337
- locus_id: _this41.locusUrl.split('/').pop(),
4885
+ correlation_id: _this35.correlationId,
4886
+ locus_id: _this35.locusUrl.split('/').pop(),
5338
4887
  connectionType: connectionType,
5339
- isMultistream: _this41.isMultistream
4888
+ isMultistream: _this35.isMultistream
5340
4889
  });
5341
4890
  }).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;
4891
+ 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
4892
  _metrics.default.sendBehavioralMetric(_constants2.default.ADD_MEDIA_FAILURE, {
5344
- correlation_id: _this41.correlationId,
5345
- locus_id: _this41.locusUrl.split('/').pop(),
4893
+ correlation_id: _this35.correlationId,
4894
+ locus_id: _this35.locusUrl.split('/').pop(),
5346
4895
  reason: error.message,
5347
4896
  stack: error.stack,
5348
4897
  code: error.code,
5349
4898
  turnDiscoverySkippedReason: turnDiscoverySkippedReason,
5350
4899
  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'
4900
+ isMultistream: _this35.isMultistream,
4901
+ 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',
4902
+ 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',
4903
+ 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
4904
  });
5356
4905
 
5357
4906
  // Clean up stats analyzer, peer connection, and turn off listeners
5358
- var stopStatsAnalyzer = _this41.statsAnalyzer ? _this41.statsAnalyzer.stopAnalyzer() : _promise.default.resolve();
4907
+ var stopStatsAnalyzer = _this35.statsAnalyzer ? _this35.statsAnalyzer.stopAnalyzer() : _promise.default.resolve();
5359
4908
  return stopStatsAnalyzer.then(function () {
5360
- _this41.statsAnalyzer = null;
5361
- if (_this41.mediaProperties.webrtcMediaConnection) {
5362
- _this41.closePeerConnections();
5363
- _this41.unsetPeerConnections();
4909
+ _this35.statsAnalyzer = null;
4910
+ if (_this35.mediaProperties.webrtcMediaConnection) {
4911
+ _this35.closePeerConnections();
4912
+ _this35.unsetPeerConnections();
5364
4913
  }
5365
4914
  _loggerProxy.default.logger.error("".concat(LOG_HEADER, " Error adding media failed to initiate PC and send request, "), error);
5366
4915
 
5367
4916
  // Upload logs on error while adding media
5368
- _triggerProxy.default.trigger(_this41, {
4917
+ _triggerProxy.default.trigger(_this35, {
5369
4918
  file: 'meeting/index',
5370
4919
  function: 'addMedia'
5371
- }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this41);
4920
+ }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this35);
5372
4921
  if (error instanceof _internalMediaCore.Errors.SdpError) {
5373
- _this41.leave({
4922
+ _this35.leave({
5374
4923
  reason: _constants.MEETING_REMOVED_REASON.MEETING_CONNECTION_FAILED
5375
4924
  });
5376
4925
  }
@@ -5403,7 +4952,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5403
4952
  }, {
5404
4953
  key: "enqueueMediaUpdate",
5405
4954
  value: function enqueueMediaUpdate(mediaUpdateType, options) {
5406
- var _this42 = this;
4955
+ var _this36 = this;
5407
4956
  if (mediaUpdateType === MEDIA_UPDATE_TYPE.LAMBDA && typeof (options === null || options === void 0 ? void 0 : options.lambda) !== 'function') {
5408
4957
  return _promise.default.reject(new Error('lambda must be specified when enqueuing MEDIA_UPDATE_TYPE.LAMBDA'));
5409
4958
  }
@@ -5416,9 +4965,9 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5416
4965
  options: options
5417
4966
  };
5418
4967
  _loggerProxy.default.logger.log("Meeting:index#enqueueMediaUpdate --> enqueuing media update type=".concat(mediaUpdateType));
5419
- _this42.queuedMediaUpdates.push(queueItem);
4968
+ _this36.queuedMediaUpdates.push(queueItem);
5420
4969
  if (canUpdateMediaNow) {
5421
- _this42.processNextQueuedMediaUpdate();
4970
+ _this36.processNextQueuedMediaUpdate();
5422
4971
  }
5423
4972
  });
5424
4973
  }
@@ -5433,367 +4982,93 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5433
4982
  key: "updateMedia",
5434
4983
  value:
5435
4984
  /**
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()
4985
+ * Updates the media connection - it allows to enable/disable all audio/video/share in the meeting.
4986
+ * This does not affect the published tracks, so for example if a microphone track is published and
4987
+ * updateMedia({audioEnabled: false}) is called, the audio will not be sent or received anymore,
4988
+ * but the track's "published" state is not changed and when updateMedia({audioEnabled: true}) is called,
4989
+ * the sending of the audio from the same track will resume.
5520
4990
  *
5521
4991
  * @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
4992
+ * @param {boolean} options.audioEnabled [optional] enables/disables receiving and sending of main audio in the meeting
4993
+ * @param {boolean} options.videoEnabled [optional] enables/disables receiving and sending of main video in the meeting
4994
+ * @param {boolean} options.shareEnabled [optional] enables/disables receiving and sending of screen share in the meeting
5525
4995
  * @returns {Promise}
5526
4996
  * @public
5527
4997
  * @memberof Meeting
5528
4998
  */
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) {
4999
+ function () {
5000
+ var _updateMedia = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16(options) {
5001
+ var audioEnabled, videoEnabled, receiveShare;
5002
+ return _regenerator.default.wrap(function _callee16$(_context16) {
5003
+ while (1) switch (_context16.prev = _context16.next) {
5537
5004
  case 0:
5538
- if (!this.isMultistream) {
5539
- _context9.next = 2;
5005
+ this.checkMediaConnection();
5006
+ audioEnabled = options.audioEnabled, videoEnabled = options.videoEnabled, receiveShare = options.receiveShare;
5007
+ _loggerProxy.default.logger.log("Meeting:index#updateMedia --> called with options=".concat((0, _stringify.default)(options)));
5008
+ if (this.canUpdateMedia()) {
5009
+ _context16.next = 5;
5540
5010
  break;
5541
5011
  }
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;
5012
+ return _context16.abrupt("return", this.enqueueMediaUpdate(MEDIA_UPDATE_TYPE.UPDATE_MEDIA, options));
5013
+ case 5:
5014
+ if (!this.isMultistream) {
5015
+ _context16.next = 10;
5546
5016
  break;
5547
5017
  }
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;
5018
+ if (!(videoEnabled !== undefined)) {
5019
+ _context16.next = 8;
5554
5020
  break;
5555
5021
  }
5556
- return _context9.abrupt("return", _promise.default.reject(new _parameter.default('Pass sendAudio and receiveAudio parameter')));
5022
+ throw new Error('enabling/disabling video in a meeting is not supported for multistream, it can only be done upfront when calling addMedia()');
5557
5023
  case 8:
5558
- if (this.mediaProperties.webrtcMediaConnection) {
5559
- _context9.next = 10;
5024
+ if (!(receiveShare !== undefined)) {
5025
+ _context16.next = 10;
5560
5026
  break;
5561
5027
  }
5562
- return _context9.abrupt("return", _promise.default.reject(new Error('media connection not established, call addMedia() first')));
5028
+ 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
5029
  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);
5030
+ if (audioEnabled !== undefined) {
5031
+ this.mediaProperties.mediaDirection.sendAudio = audioEnabled;
5032
+ this.mediaProperties.mediaDirection.receiveAudio = audioEnabled;
5033
+ this.audio.enable(this, audioEnabled);
5034
+ }
5035
+ if (videoEnabled !== undefined) {
5036
+ this.mediaProperties.mediaDirection.sendVideo = videoEnabled;
5037
+ this.mediaProperties.mediaDirection.receiveVideo = videoEnabled;
5038
+ this.video.enable(this, videoEnabled);
5039
+ }
5040
+ if (receiveShare !== undefined) {
5041
+ this.mediaProperties.mediaDirection.receiveShare = receiveShare;
5042
+ }
5043
+ if (!this.isMultistream) {
5044
+ _context16.next = 19;
5045
+ break;
5753
5046
  }
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');
5047
+ if (!(audioEnabled !== undefined)) {
5048
+ _context16.next = 17;
5049
+ break;
5050
+ }
5051
+ _context16.next = 17;
5052
+ return this.mediaProperties.webrtcMediaConnection.enableMultistreamAudio(audioEnabled);
5053
+ case 17:
5054
+ _context16.next = 21;
5055
+ break;
5056
+ case 19:
5057
+ _context16.next = 21;
5058
+ return this.updateTranscodedMediaConnection();
5059
+ case 21:
5060
+ return _context16.abrupt("return", undefined);
5061
+ case 22:
5062
+ case "end":
5063
+ return _context16.stop();
5064
+ }
5065
+ }, _callee16, this);
5066
+ }));
5067
+ function updateMedia(_x12) {
5068
+ return _updateMedia.apply(this, arguments);
5793
5069
  }
5794
- this.setLocalShareTrack(_util.default.getTrack(localShare).videoTrack);
5795
- }
5796
-
5070
+ return updateMedia;
5071
+ }()
5797
5072
  /**
5798
5073
  * Acknowledge the meeting, outgoing or incoming
5799
5074
  * @param {String} type
@@ -5804,7 +5079,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5804
5079
  }, {
5805
5080
  key: "acknowledge",
5806
5081
  value: function acknowledge(type) {
5807
- var _this47 = this;
5082
+ var _this37 = this;
5808
5083
  if (!type) {
5809
5084
  return _promise.default.reject(new _parameter.default('Type must be set to acknowledge the meeting.'));
5810
5085
  }
@@ -5816,10 +5091,10 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5816
5091
  }).then(function (response) {
5817
5092
  return _promise.default.resolve(response);
5818
5093
  }).then(function (response) {
5819
- _this47.meetingFiniteStateMachine.ring(type);
5094
+ _this37.meetingFiniteStateMachine.ring(type);
5820
5095
  _metrics.default.postEvent({
5821
5096
  event: _config.eventType.ALERT_DISPLAYED,
5822
- meeting: _this47
5097
+ meeting: _this37
5823
5098
  });
5824
5099
  return _promise.default.resolve({
5825
5100
  response: response
@@ -5843,12 +5118,12 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5843
5118
  }, {
5844
5119
  key: "decline",
5845
5120
  value: function decline(reason) {
5846
- var _this48 = this;
5121
+ var _this38 = this;
5847
5122
  return _util.default.declineMeeting(this, reason).then(function (decline) {
5848
- _this48.meetingFiniteStateMachine.decline();
5123
+ _this38.meetingFiniteStateMachine.decline();
5849
5124
  return _promise.default.resolve(decline);
5850
5125
  }).catch(function (error) {
5851
- _this48.meetingFiniteStateMachine.fail(error);
5126
+ _this38.meetingFiniteStateMachine.fail(error);
5852
5127
  return _promise.default.reject(error);
5853
5128
  });
5854
5129
  }
@@ -5864,7 +5139,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5864
5139
  }, {
5865
5140
  key: "leave",
5866
5141
  value: function leave() {
5867
- var _this49 = this;
5142
+ var _this39 = this;
5868
5143
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5869
5144
  var leaveReason = options.reason || _constants.MEETING_REMOVED_REASON.CLIENT_LEAVE_REQUEST;
5870
5145
  _metrics.default.postEvent({
@@ -5878,39 +5153,39 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5878
5153
  });
5879
5154
  _loggerProxy.default.logger.log('Meeting:index#leave --> Leaving a meeting');
5880
5155
  return _util.default.leaveMeeting(this, options).then(function (leave) {
5881
- _this49.meetingFiniteStateMachine.leave();
5882
- _this49.clearMeetingData();
5156
+ _this39.meetingFiniteStateMachine.leave();
5157
+ _this39.clearMeetingData();
5883
5158
 
5884
5159
  // upload logs on leave irrespective of meeting delete
5885
- _triggerProxy.default.trigger(_this49, {
5160
+ _triggerProxy.default.trigger(_this39, {
5886
5161
  file: 'meeting/index',
5887
5162
  function: 'leave'
5888
- }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this49);
5163
+ }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this39);
5889
5164
 
5890
5165
  // TODO: more testing before we remove this code, we are not sure the scenarios for destroy here
5891
- if (_this49.wirelessShare || _this49.guest) {
5166
+ if (_this39.wirelessShare || _this39.guest) {
5892
5167
  // If screen sharing clean the meeting object
5893
- _triggerProxy.default.trigger(_this49, {
5168
+ _triggerProxy.default.trigger(_this39, {
5894
5169
  file: 'meeting/index',
5895
5170
  function: 'leave'
5896
5171
  }, _constants.EVENTS.DESTROY_MEETING, {
5897
5172
  reason: options.reason,
5898
- meetingId: _this49.id
5173
+ meetingId: _this39.id
5899
5174
  });
5900
5175
  }
5901
5176
  _loggerProxy.default.logger.log('Meeting:index#leave --> LEAVE REASON ', leaveReason);
5902
5177
  return leave;
5903
5178
  }).catch(function (error) {
5904
- _this49.meetingFiniteStateMachine.fail(error);
5179
+ _this39.meetingFiniteStateMachine.fail(error);
5905
5180
  _loggerProxy.default.logger.error('Meeting:index#leave --> Failed to leave ', error);
5906
5181
  // upload logs on leave irrespective of meeting delete
5907
- _triggerProxy.default.trigger(_this49, {
5182
+ _triggerProxy.default.trigger(_this39, {
5908
5183
  file: 'meeting/index',
5909
5184
  function: 'leave'
5910
- }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this49);
5185
+ }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this39);
5911
5186
  _metrics.default.sendBehavioralMetric(_constants2.default.MEETING_LEAVE_FAILURE, {
5912
- correlation_id: _this49.correlationId,
5913
- locus_id: _this49.locusUrl.split('/').pop(),
5187
+ correlation_id: _this39.correlationId,
5188
+ locus_id: _this39.locusUrl.split('/').pop(),
5914
5189
  reason: error.message,
5915
5190
  stack: error.stack,
5916
5191
  code: error.code
@@ -5930,7 +5205,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5930
5205
  }, {
5931
5206
  key: "startWhiteboardShare",
5932
5207
  value: function startWhiteboardShare(channelUrl, resourceToken) {
5933
- var _this50 = this;
5208
+ var _this40 = this;
5934
5209
  var whiteboard = this.locusInfo.mediaShares.find(function (element) {
5935
5210
  return element.name === 'whiteboard';
5936
5211
  });
@@ -5953,13 +5228,13 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5953
5228
  body.resourceToken = resourceToken;
5954
5229
  }
5955
5230
  return this.meetingRequest.changeMeetingFloor(body).then(function () {
5956
- _this50.isSharing = false;
5231
+ _this40.isSharing = false;
5957
5232
  return _promise.default.resolve();
5958
5233
  }).catch(function (error) {
5959
5234
  _loggerProxy.default.logger.error('Meeting:index#startWhiteboardShare --> Error ', error);
5960
5235
  _metrics.default.sendBehavioralMetric(_constants2.default.MEETING_START_WHITEBOARD_SHARE_FAILURE, {
5961
- correlation_id: _this50.correlationId,
5962
- locus_id: _this50.locusUrl.split('/').pop(),
5236
+ correlation_id: _this40.correlationId,
5237
+ locus_id: _this40.locusUrl.split('/').pop(),
5963
5238
  reason: error.message,
5964
5239
  stack: error.stack,
5965
5240
  board: {
@@ -5982,7 +5257,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5982
5257
  }, {
5983
5258
  key: "stopWhiteboardShare",
5984
5259
  value: function stopWhiteboardShare(channelUrl) {
5985
- var _this51 = this;
5260
+ var _this41 = this;
5986
5261
  var whiteboard = this.locusInfo.mediaShares.find(function (element) {
5987
5262
  return element.name === 'whiteboard';
5988
5263
  });
@@ -6001,8 +5276,8 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6001
5276
  _metrics.default.sendBehavioralMetric(
6002
5277
  // @ts-ignore - check if STOP_WHITEBOARD_SHARE_FAILURE exists
6003
5278
  _constants2.default.STOP_WHITEBOARD_SHARE_FAILURE, {
6004
- correlation_id: _this51.correlationId,
6005
- locus_id: _this51.locusUrl.split('/').pop(),
5279
+ correlation_id: _this41.correlationId,
5280
+ locus_id: _this41.locusUrl.split('/').pop(),
6006
5281
  reason: error.message,
6007
5282
  stack: error.stack,
6008
5283
  board: {
@@ -6024,55 +5299,62 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6024
5299
  }, {
6025
5300
  key: "requestScreenShareFloor",
6026
5301
  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
5302
+ var _this42 = this;
5303
+ if (!this.mediaProperties.shareTrack || !this.mediaProperties.mediaDirection.sendShare) {
5304
+ _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, ")"));
5305
+ return _promise.default.resolve({});
5306
+ }
5307
+ if (this.state === _constants.MEETING_STATE.STATES.JOINED) {
5308
+ var content = this.locusInfo.mediaShares.find(function (element) {
5309
+ return element.name === _constants.CONTENT;
6035
5310
  });
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
5311
+ if (content && this.shareStatus !== _constants.SHARE_STATUS.LOCAL_SHARE_ACTIVE) {
5312
+ _metrics.default.postEvent({
5313
+ event: _config.eventType.SHARE_INITIATED,
5314
+ meeting: this
6053
5315
  });
6054
- return _promise.default.reject(error);
6055
- });
5316
+ return this.meetingRequest.changeMeetingFloor({
5317
+ disposition: _constants.FLOOR_ACTION.GRANTED,
5318
+ personUrl: this.locusInfo.self.url,
5319
+ deviceUrl: this.deviceUrl,
5320
+ uri: content.url,
5321
+ resourceUrl: this.resourceUrl,
5322
+ annotationInfo: this.annotationInfo
5323
+ }).then(function () {
5324
+ _this42.isSharing = true;
5325
+ return _promise.default.resolve();
5326
+ }).catch(function (error) {
5327
+ _loggerProxy.default.logger.error('Meeting:index#share --> Error ', error);
5328
+ _metrics.default.sendBehavioralMetric(_constants2.default.MEETING_SHARE_FAILURE, {
5329
+ correlation_id: _this42.correlationId,
5330
+ locus_id: _this42.locusUrl.split('/').pop(),
5331
+ reason: error.message,
5332
+ stack: error.stack
5333
+ });
5334
+ return _promise.default.reject(error);
5335
+ });
5336
+ }
5337
+ return _promise.default.reject(new _parameter.default('Cannot share without content.'));
6056
5338
  }
6057
- return _promise.default.reject(new _parameter.default('Cannot share without content.'));
5339
+ this.floorGrantPending = true;
5340
+ return _promise.default.resolve({});
6058
5341
  }
6059
5342
 
6060
5343
  /**
6061
- * Stops the screen share
6062
- * @returns {Promise} see #updateShare
6063
- * @public
6064
- * @memberof Meeting
5344
+ * Requests screen share floor if such request is pending.
5345
+ * It should be called whenever meeting state changes to JOINED
5346
+ *
5347
+ * @returns {void}
6065
5348
  */
6066
- // Internal only, temporarily allows optional params
6067
- // eslint-disable-next-line valid-jsdoc
6068
5349
  }, {
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));
5350
+ key: "requestScreenShareFloorIfPending",
5351
+ value: function requestScreenShareFloorIfPending() {
5352
+ var _this43 = this;
5353
+ if (this.floorGrantPending && this.state === _constants.MEETING_STATE.STATES.JOINED) {
5354
+ this.requestScreenShareFloor().then(function () {
5355
+ _this43.floorGrantPending = false;
5356
+ });
5357
+ }
6076
5358
  }
6077
5359
 
6078
5360
  /**
@@ -6084,16 +5366,17 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6084
5366
  }, {
6085
5367
  key: "releaseScreenShareFloor",
6086
5368
  value: function releaseScreenShareFloor() {
6087
- var _this53 = this;
5369
+ var _this44 = this;
6088
5370
  var content = this.locusInfo.mediaShares.find(function (element) {
6089
5371
  return element.name === _constants.CONTENT;
6090
5372
  });
6091
- if (content && this.mediaProperties.mediaDirection.sendShare) {
5373
+ if (content) {
5374
+ var _content$floor;
6092
5375
  _metrics.default.postEvent({
6093
5376
  event: _config.eventType.SHARE_STOPPED,
6094
5377
  meeting: this
6095
5378
  });
6096
- if (content.floor.beneficiary.id !== this.selfId) {
5379
+ if (((_content$floor = content.floor) === null || _content$floor === void 0 ? void 0 : _content$floor.beneficiary.id) !== this.selfId) {
6097
5380
  // remote participant started sharing and caused our sharing to stop, we don't want to send any floor action request in that case
6098
5381
  this.isSharing = false;
6099
5382
  return _promise.default.resolve();
@@ -6107,17 +5390,20 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6107
5390
  }).catch(function (error) {
6108
5391
  _loggerProxy.default.logger.error('Meeting:index#releaseScreenShareFloor --> Error ', error);
6109
5392
  _metrics.default.sendBehavioralMetric(_constants2.default.STOP_FLOOR_REQUEST_FAILURE, {
6110
- correlation_id: _this53.correlationId,
6111
- locus_id: _this53.locusUrl.split('/').pop(),
5393
+ correlation_id: _this44.correlationId,
5394
+ locus_id: _this44.locusUrl.split('/').pop(),
6112
5395
  reason: error.message,
6113
5396
  stack: error.stack
6114
5397
  });
6115
5398
  return _promise.default.reject(error);
6116
5399
  }).finally(function () {
6117
- _this53.isSharing = false;
5400
+ _this44.isSharing = false;
6118
5401
  });
6119
5402
  }
6120
- return _promise.default.reject(new _parameter.default('Cannot stop share without content'));
5403
+
5404
+ // according to Locus there is no content, so we don't need to release the floor (it's probably already been released)
5405
+ this.isSharing = false;
5406
+ return _promise.default.resolve();
6121
5407
  }
6122
5408
 
6123
5409
  /**
@@ -6287,14 +5573,14 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6287
5573
  }, {
6288
5574
  key: "changeVideoLayout",
6289
5575
  value: function changeVideoLayout(layoutType) {
6290
- var _this54 = this;
5576
+ var _this45 = this;
6291
5577
  var renderInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6292
5578
  var main = renderInfo.main,
6293
5579
  content = renderInfo.content;
6294
- var _this$mediaProperties7 = this.mediaProperties,
6295
- mediaDirection = _this$mediaProperties7.mediaDirection,
6296
- remoteShare = _this$mediaProperties7.remoteShare,
6297
- remoteVideoTrack = _this$mediaProperties7.remoteVideoTrack;
5580
+ var _this$mediaProperties4 = this.mediaProperties,
5581
+ mediaDirection = _this$mediaProperties4.mediaDirection,
5582
+ remoteShare = _this$mediaProperties4.remoteShare,
5583
+ remoteVideoTrack = _this$mediaProperties4.remoteVideoTrack;
6298
5584
  var layoutInfo = (0, _cloneDeep2.default)(this.lastVideoLayoutInfo);
6299
5585
 
6300
5586
  // TODO: We need a real time value for Audio, Video and Share send indicator
@@ -6341,7 +5627,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6341
5627
  }
6342
5628
  this.lastVideoLayoutInfo = (0, _cloneDeep2.default)(layoutInfo);
6343
5629
  this.locusInfo.once(_constants.LOCUSINFO.EVENTS.CONTROLS_MEETING_LAYOUT_UPDATED, function (envelope) {
6344
- _triggerProxy.default.trigger(_this54, {
5630
+ _triggerProxy.default.trigger(_this45, {
6345
5631
  file: 'meeting/index',
6346
5632
  function: 'changeVideoLayout'
6347
5633
  }, _constants.EVENT_TRIGGERS.MEETING_CONTROLS_LAYOUT_UPDATE, {
@@ -6360,69 +5646,6 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6360
5646
  });
6361
5647
  }
6362
5648
 
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
5649
  /**
6427
5650
  * Sets the quality level of the remote incoming media
6428
5651
  * @param {String} level {LOW|MEDIUM|HIGH}
@@ -6447,112 +5670,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6447
5670
 
6448
5671
  // Set the quality level in properties
6449
5672
  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
- });
5673
+ return this.updateTranscodedMediaConnection();
6556
5674
  }
6557
5675
 
6558
5676
  /**
@@ -6838,7 +5956,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6838
5956
  }, {
6839
5957
  key: "endMeetingForAll",
6840
5958
  value: function endMeetingForAll() {
6841
- var _this58 = this;
5959
+ var _this46 = this;
6842
5960
  _metrics.default.postEvent({
6843
5961
  event: _config.eventType.LEAVE,
6844
5962
  meeting: this,
@@ -6853,25 +5971,25 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6853
5971
  locus_id: this.locusId
6854
5972
  });
6855
5973
  return _util.default.endMeetingForAll(this).then(function (end) {
6856
- _this58.meetingFiniteStateMachine.end();
6857
- _this58.clearMeetingData();
5974
+ _this46.meetingFiniteStateMachine.end();
5975
+ _this46.clearMeetingData();
6858
5976
  // upload logs on leave irrespective of meeting delete
6859
- _triggerProxy.default.trigger(_this58, {
5977
+ _triggerProxy.default.trigger(_this46, {
6860
5978
  file: 'meeting/index',
6861
5979
  function: 'endMeetingForAll'
6862
- }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this58);
5980
+ }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this46);
6863
5981
  return end;
6864
5982
  }).catch(function (error) {
6865
- _this58.meetingFiniteStateMachine.fail(error);
5983
+ _this46.meetingFiniteStateMachine.fail(error);
6866
5984
  _loggerProxy.default.logger.error('Meeting:index#endMeetingForAll --> Failed to end meeting ', error);
6867
5985
  // upload logs on leave irrespective of meeting delete
6868
- _triggerProxy.default.trigger(_this58, {
5986
+ _triggerProxy.default.trigger(_this46, {
6869
5987
  file: 'meeting/index',
6870
5988
  function: 'endMeetingForAll'
6871
- }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this58);
5989
+ }, _constants.EVENTS.REQUEST_UPLOAD_LOGS, _this46);
6872
5990
  _metrics.default.sendBehavioralMetric(_constants2.default.MEETING_END_ALL_FAILURE, {
6873
- correlation_id: _this58.correlationId,
6874
- locus_id: _this58.locusUrl.split('/').pop(),
5991
+ correlation_id: _this46.correlationId,
5992
+ locus_id: _this46.locusUrl.split('/').pop(),
6875
5993
  reason: error.message,
6876
5994
  stack: error.stack,
6877
5995
  code: error.code
@@ -6951,11 +6069,11 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6951
6069
  }, {
6952
6070
  key: "checkMediaConnection",
6953
6071
  value: function checkMediaConnection() {
6954
- var _this$mediaProperties9;
6955
- if ((_this$mediaProperties9 = this.mediaProperties) !== null && _this$mediaProperties9 !== void 0 && _this$mediaProperties9.webrtcMediaConnection) {
6072
+ var _this$mediaProperties5;
6073
+ if ((_this$mediaProperties5 = this.mediaProperties) !== null && _this$mediaProperties5 !== void 0 && _this$mediaProperties5.webrtcMediaConnection) {
6956
6074
  return;
6957
6075
  }
6958
- throw new Error('Webrtc media connection is missing, call addMedia() first');
6076
+ throw new _webexErrors.NoMediaEstablishedYetError();
6959
6077
  }
6960
6078
 
6961
6079
  /**
@@ -6967,43 +6085,171 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6967
6085
  }, {
6968
6086
  key: "enableMusicMode",
6969
6087
  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) {
6088
+ var _enableMusicMode = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(shouldEnableMusicMode) {
6089
+ return _regenerator.default.wrap(function _callee17$(_context17) {
6090
+ while (1) switch (_context17.prev = _context17.next) {
6973
6091
  case 0:
6974
6092
  this.checkMediaConnection();
6975
6093
  if (this.isMultistream) {
6976
- _context12.next = 3;
6094
+ _context17.next = 3;
6977
6095
  break;
6978
6096
  }
6979
6097
  throw new Error('enableMusicMode() only supported with multistream');
6980
6098
  case 3:
6981
6099
  if (!shouldEnableMusicMode) {
6982
- _context12.next = 8;
6100
+ _context17.next = 8;
6983
6101
  break;
6984
6102
  }
6985
- _context12.next = 6;
6103
+ _context17.next = 6;
6986
6104
  return this.mediaProperties.webrtcMediaConnection.setCodecParameters(_internalMediaCore.MediaType.AudioMain, {
6987
6105
  maxaveragebitrate: '64000',
6988
6106
  maxplaybackrate: '48000'
6989
6107
  });
6990
6108
  case 6:
6991
- _context12.next = 10;
6109
+ _context17.next = 10;
6992
6110
  break;
6993
6111
  case 8:
6994
- _context12.next = 10;
6112
+ _context17.next = 10;
6995
6113
  return this.mediaProperties.webrtcMediaConnection.deleteCodecParameters(_internalMediaCore.MediaType.AudioMain, ['maxaveragebitrate', 'maxplaybackrate']);
6996
6114
  case 10:
6997
6115
  case "end":
6998
- return _context12.stop();
6116
+ return _context17.stop();
6999
6117
  }
7000
- }, _callee12, this);
6118
+ }, _callee17, this);
7001
6119
  }));
7002
- function enableMusicMode(_x7) {
6120
+ function enableMusicMode(_x13) {
7003
6121
  return _enableMusicMode.apply(this, arguments);
7004
6122
  }
7005
6123
  return enableMusicMode;
7006
6124
  }()
6125
+ /** Updates the tracks being sent on the transcoded media connection
6126
+ *
6127
+ * @returns {Promise<void>}
6128
+ */
6129
+ }, {
6130
+ key: "updateTranscodedMediaConnection",
6131
+ value: function updateTranscodedMediaConnection() {
6132
+ var _this$mediaProperties6,
6133
+ _this$mediaProperties7,
6134
+ _this$mediaProperties8,
6135
+ _this47 = this;
6136
+ var LOG_HEADER = 'Meeting:index#updateTranscodedMediaConnection -->';
6137
+ _loggerProxy.default.logger.info("".concat(LOG_HEADER, " starting"));
6138
+ if (!this.canUpdateMedia()) {
6139
+ return this.enqueueMediaUpdate(MEDIA_UPDATE_TYPE.TRANSCODED_MEDIA_CONNECTION, {});
6140
+ }
6141
+ return this.mediaProperties.webrtcMediaConnection.update({
6142
+ localTracks: {
6143
+ audio: ((_this$mediaProperties6 = this.mediaProperties.audioTrack) === null || _this$mediaProperties6 === void 0 ? void 0 : _this$mediaProperties6.underlyingTrack) || null,
6144
+ video: ((_this$mediaProperties7 = this.mediaProperties.videoTrack) === null || _this$mediaProperties7 === void 0 ? void 0 : _this$mediaProperties7.underlyingTrack) || null,
6145
+ screenShareVideo: ((_this$mediaProperties8 = this.mediaProperties.shareTrack) === null || _this$mediaProperties8 === void 0 ? void 0 : _this$mediaProperties8.underlyingTrack) || null
6146
+ },
6147
+ direction: {
6148
+ audio: _media.default.getDirection(true, this.mediaProperties.mediaDirection.receiveAudio, this.mediaProperties.mediaDirection.sendAudio),
6149
+ video: _media.default.getDirection(true, this.mediaProperties.mediaDirection.receiveVideo, this.mediaProperties.mediaDirection.sendVideo),
6150
+ screenShareVideo: _media.default.getDirection(false, this.mediaProperties.mediaDirection.receiveShare, this.mediaProperties.mediaDirection.sendShare)
6151
+ },
6152
+ remoteQualityLevel: this.mediaProperties.remoteQualityLevel
6153
+ }).then(function () {
6154
+ _loggerProxy.default.logger.info("".concat(LOG_HEADER, " done"));
6155
+ }).catch(function (error) {
6156
+ _loggerProxy.default.logger.error("".concat(LOG_HEADER, " Error: "), error);
6157
+ _metrics.default.sendBehavioralMetric(_constants2.default.UPDATE_MEDIA_FAILURE, {
6158
+ correlation_id: _this47.correlationId,
6159
+ locus_id: _this47.locusUrl.split('/').pop(),
6160
+ reason: error.message,
6161
+ stack: error.stack
6162
+ });
6163
+ throw error;
6164
+ });
6165
+ }
6166
+
6167
+ /**
6168
+ * Publishes a track.
6169
+ *
6170
+ * @param {LocalTrack} track to publish
6171
+ * @returns {Promise}
6172
+ */
6173
+ }, {
6174
+ key: "publishTrack",
6175
+ value: function () {
6176
+ var _publishTrack = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18(track) {
6177
+ return _regenerator.default.wrap(function _callee18$(_context18) {
6178
+ while (1) switch (_context18.prev = _context18.next) {
6179
+ case 0:
6180
+ if (track) {
6181
+ _context18.next = 2;
6182
+ break;
6183
+ }
6184
+ return _context18.abrupt("return");
6185
+ case 2:
6186
+ if (!this.mediaProperties.webrtcMediaConnection) {
6187
+ _context18.next = 9;
6188
+ break;
6189
+ }
6190
+ if (!this.isMultistream) {
6191
+ _context18.next = 8;
6192
+ break;
6193
+ }
6194
+ _context18.next = 6;
6195
+ return this.mediaProperties.webrtcMediaConnection.publishTrack(track);
6196
+ case 6:
6197
+ _context18.next = 9;
6198
+ break;
6199
+ case 8:
6200
+ track.setPublished(true); // for multistream, this call is done by WCME
6201
+ case 9:
6202
+ case "end":
6203
+ return _context18.stop();
6204
+ }
6205
+ }, _callee18, this);
6206
+ }));
6207
+ function publishTrack(_x14) {
6208
+ return _publishTrack.apply(this, arguments);
6209
+ }
6210
+ return publishTrack;
6211
+ }()
6212
+ /**
6213
+ * Un-publishes a track.
6214
+ *
6215
+ * @param {LocalTrack} track to unpublish
6216
+ * @returns {Promise}
6217
+ */
6218
+ }, {
6219
+ key: "unpublishTrack",
6220
+ value: function () {
6221
+ var _unpublishTrack = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19(track) {
6222
+ return _regenerator.default.wrap(function _callee19$(_context19) {
6223
+ while (1) switch (_context19.prev = _context19.next) {
6224
+ case 0:
6225
+ if (track) {
6226
+ _context19.next = 2;
6227
+ break;
6228
+ }
6229
+ return _context19.abrupt("return");
6230
+ case 2:
6231
+ if (!(this.isMultistream && this.mediaProperties.webrtcMediaConnection)) {
6232
+ _context19.next = 7;
6233
+ break;
6234
+ }
6235
+ _context19.next = 5;
6236
+ return this.mediaProperties.webrtcMediaConnection.unpublishTrack(track);
6237
+ case 5:
6238
+ _context19.next = 8;
6239
+ break;
6240
+ case 7:
6241
+ track.setPublished(false); // for multistream, this call is done by WCME
6242
+ case 8:
6243
+ case "end":
6244
+ return _context19.stop();
6245
+ }
6246
+ }, _callee19, this);
6247
+ }));
6248
+ function unpublishTrack(_x15) {
6249
+ return _unpublishTrack.apply(this, arguments);
6250
+ }
6251
+ return unpublishTrack;
6252
+ }()
7007
6253
  /**
7008
6254
  * Publishes specified local tracks in the meeting
7009
6255
  *
@@ -7013,84 +6259,85 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
7013
6259
  }, {
7014
6260
  key: "publishTracks",
7015
6261
  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) {
6262
+ var _publishTracks = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21(tracks) {
6263
+ var _tracks$screenShare,
6264
+ _tracks$screenShare2,
6265
+ _tracks$screenShare3,
6266
+ _this48 = this;
6267
+ var floorRequestNeeded, _tracks$screenShare4;
6268
+ return _regenerator.default.wrap(function _callee21$(_context21) {
6269
+ while (1) switch (_context21.prev = _context21.next) {
7021
6270
  case 0:
7022
6271
  this.checkMediaConnection();
7023
- if (this.isMultistream) {
7024
- _context13.next = 3;
6272
+ this.annotationInfo = tracks.annotationInfo;
6273
+ 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))) {
6274
+ _context21.next = 4;
7025
6275
  break;
7026
6276
  }
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;
6277
+ return _context21.abrupt("return");
6278
+ case 4:
6279
+ floorRequestNeeded = false;
6280
+ if (!((_tracks$screenShare3 = tracks.screenShare) !== null && _tracks$screenShare3 !== void 0 && _tracks$screenShare3.video)) {
6281
+ _context21.next = 9;
7032
6282
  break;
7033
6283
  }
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:
6284
+ _context21.next = 8;
6285
+ return this.setLocalShareTrack((_tracks$screenShare4 = tracks.screenShare) === null || _tracks$screenShare4 === void 0 ? void 0 : _tracks$screenShare4.video);
6286
+ case 8:
6287
+ floorRequestNeeded = true;
6288
+ case 9:
7048
6289
  if (!tracks.microphone) {
7049
- _context13.next = 25;
6290
+ _context21.next = 12;
7050
6291
  break;
7051
6292
  }
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:
6293
+ _context21.next = 12;
6294
+ return this.setLocalAudioTrack(tracks.microphone);
6295
+ case 12:
7068
6296
  if (!tracks.camera) {
7069
- _context13.next = 35;
6297
+ _context21.next = 15;
7070
6298
  break;
7071
6299
  }
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);
6300
+ _context21.next = 15;
6301
+ return this.setLocalVideoTrack(tracks.camera);
6302
+ case 15:
6303
+ if (this.isMultistream) {
6304
+ _context21.next = 18;
6305
+ break;
6306
+ }
6307
+ _context21.next = 18;
6308
+ return this.updateTranscodedMediaConnection();
6309
+ case 18:
6310
+ if (!floorRequestNeeded) {
6311
+ _context21.next = 21;
6312
+ break;
7083
6313
  }
7084
- _localTrack.on(_mediaHelpers.LocalTrackEvents.Muted, this.localVideoTrackMuteStateHandler);
7085
- _context13.next = 35;
7086
- return this.mediaProperties.webrtcMediaConnection.publishTrack(this.mediaProperties.videoTrack);
7087
- case 35:
6314
+ _context21.next = 21;
6315
+ return this.enqueueMediaUpdate(MEDIA_UPDATE_TYPE.LAMBDA, {
6316
+ lambda: function () {
6317
+ var _lambda2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20() {
6318
+ return _regenerator.default.wrap(function _callee20$(_context20) {
6319
+ while (1) switch (_context20.prev = _context20.next) {
6320
+ case 0:
6321
+ return _context20.abrupt("return", _this48.requestScreenShareFloor());
6322
+ case 1:
6323
+ case "end":
6324
+ return _context20.stop();
6325
+ }
6326
+ }, _callee20);
6327
+ }));
6328
+ function lambda() {
6329
+ return _lambda2.apply(this, arguments);
6330
+ }
6331
+ return lambda;
6332
+ }()
6333
+ });
6334
+ case 21:
7088
6335
  case "end":
7089
- return _context13.stop();
6336
+ return _context21.stop();
7090
6337
  }
7091
- }, _callee13, this);
6338
+ }, _callee21, this);
7092
6339
  }));
7093
- function publishTracks(_x8) {
6340
+ function publishTracks(_x16) {
7094
6341
  return _publishTracks.apply(this, arguments);
7095
6342
  }
7096
6343
  return publishTracks;
@@ -7104,19 +6351,13 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
7104
6351
  }, {
7105
6352
  key: "unpublishTracks",
7106
6353
  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) {
6354
+ var _unpublishTracks = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee22(tracks) {
6355
+ var promises, _iterator, _step, track;
6356
+ return _regenerator.default.wrap(function _callee22$(_context22) {
6357
+ while (1) switch (_context22.prev = _context22.next) {
7111
6358
  case 0:
7112
6359
  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 = [];
6360
+ promises = [];
7120
6361
  _iterator = _createForOfIteratorHelper(tracks.filter(function (t) {
7121
6362
  return !!t;
7122
6363
  }));
@@ -7124,23 +6365,18 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
7124
6365
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
7125
6366
  track = _step.value;
7126
6367
  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));
6368
+ try {
6369
+ this.releaseScreenShareFloor(); // we ignore the returned promise here on purpose
6370
+ } catch (e) {
6371
+ // nothing to do here, error is logged already inside releaseScreenShareFloor()
6372
+ }
6373
+ promises.push(this.setLocalShareTrack(undefined));
7132
6374
  }
7133
6375
  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));
6376
+ promises.push(this.setLocalAudioTrack(undefined));
7138
6377
  }
7139
6378
  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));
6379
+ promises.push(this.setLocalVideoTrack(undefined));
7144
6380
  }
7145
6381
  }
7146
6382
  } catch (err) {
@@ -7148,15 +6384,18 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
7148
6384
  } finally {
7149
6385
  _iterator.f();
7150
6386
  }
7151
- _context14.next = 8;
7152
- return _promise.default.all(unpublishPromises);
7153
- case 8:
6387
+ if (!this.isMultistream) {
6388
+ promises.push(this.updateTranscodedMediaConnection());
6389
+ }
6390
+ _context22.next = 7;
6391
+ return _promise.default.all(promises);
6392
+ case 7:
7154
6393
  case "end":
7155
- return _context14.stop();
6394
+ return _context22.stop();
7156
6395
  }
7157
- }, _callee14, this);
6396
+ }, _callee22, this);
7158
6397
  }));
7159
- function unpublishTracks(_x9) {
6398
+ function unpublishTracks(_x17) {
7160
6399
  return _unpublishTracks.apply(this, arguments);
7161
6400
  }
7162
6401
  return unpublishTracks;