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

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