@webex/plugin-meetings 3.0.0-beta.35 → 3.0.0-beta.36

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 (52) hide show
  1. package/dist/breakouts/breakout.js +1 -1
  2. package/dist/breakouts/edit-lock-error.js +52 -0
  3. package/dist/breakouts/edit-lock-error.js.map +1 -0
  4. package/dist/breakouts/index.js +86 -2
  5. package/dist/breakouts/index.js.map +1 -1
  6. package/dist/constants.js +12 -1
  7. package/dist/constants.js.map +1 -1
  8. package/dist/media/index.js +4 -18
  9. package/dist/media/index.js.map +1 -1
  10. package/dist/media/properties.js +3 -3
  11. package/dist/media/properties.js.map +1 -1
  12. package/dist/meeting/index.js +194 -306
  13. package/dist/meeting/index.js.map +1 -1
  14. package/dist/meeting/muteState.js +7 -2
  15. package/dist/meeting/muteState.js.map +1 -1
  16. package/dist/meeting/util.js +2 -2
  17. package/dist/meeting/util.js.map +1 -1
  18. package/dist/metrics/constants.js +0 -4
  19. package/dist/metrics/constants.js.map +1 -1
  20. package/dist/reconnection-manager/index.js +1 -2
  21. package/dist/reconnection-manager/index.js.map +1 -1
  22. package/dist/types/breakouts/edit-lock-error.d.ts +15 -0
  23. package/dist/types/constants.d.ts +11 -0
  24. package/dist/types/media/properties.d.ts +7 -6
  25. package/dist/types/meeting/index.d.ts +11 -36
  26. package/dist/types/metrics/constants.d.ts +0 -4
  27. package/package.json +19 -19
  28. package/src/breakouts/README.md +8 -2
  29. package/src/breakouts/edit-lock-error.ts +25 -0
  30. package/src/breakouts/index.ts +73 -0
  31. package/src/constants.ts +11 -0
  32. package/src/media/index.ts +14 -24
  33. package/src/media/properties.ts +16 -10
  34. package/src/meeting/index.ts +122 -204
  35. package/src/meeting/muteState.ts +5 -5
  36. package/src/meeting/util.ts +5 -4
  37. package/src/metrics/constants.ts +0 -4
  38. package/src/reconnection-manager/index.ts +1 -1
  39. package/test/integration/spec/converged-space-meetings.js +3 -3
  40. package/test/integration/spec/journey.js +3 -3
  41. package/test/unit/spec/breakouts/edit-lock-error.ts +30 -0
  42. package/test/unit/spec/breakouts/index.ts +92 -1
  43. package/test/unit/spec/media/index.ts +8 -6
  44. package/test/unit/spec/meeting/index.js +87 -114
  45. package/test/unit/spec/meeting/muteState.js +21 -22
  46. package/test/unit/spec/meeting/utils.js +3 -1
  47. package/test/utils/testUtils.js +30 -25
  48. package/dist/meeting/effectsState.js +0 -262
  49. package/dist/meeting/effectsState.js.map +0 -1
  50. package/dist/types/meeting/effectsState.d.ts +0 -42
  51. package/src/meeting/effectsState.ts +0 -211
  52. package/test/unit/spec/meeting/effectsState.js +0 -285
@@ -19,8 +19,8 @@ describe('plugin-meetings', () => {
19
19
  beforeEach(() => {
20
20
  meeting = {
21
21
  mediaProperties: {
22
- audioTrack: 'fake audio track',
23
- videoTrack: 'fake video track',
22
+ audioTrack: {id: 'fake audio track', setMuted: sinon.stub()},
23
+ videoTrack: {id: 'fake video track', setMuted: sinon.stub()},
24
24
  },
25
25
  remoteMuted: false,
26
26
  unmuteAllowed: true,
@@ -38,7 +38,6 @@ describe('plugin-meetings', () => {
38
38
  originalRemoteUpdateAudioVideo = MeetingUtil.remoteUpdateAudioVideo;
39
39
 
40
40
  MeetingUtil.remoteUpdateAudioVideo = sinon.stub().resolves(fakeLocus);
41
- Media.setLocalTrack = sinon.stub();
42
41
  });
43
42
 
44
43
  afterEach(() => {
@@ -110,8 +109,8 @@ describe('plugin-meetings', () => {
110
109
  audio.handleServerLocalUnmuteRequired(meeting);
111
110
  await testUtils.flushPromises();
112
111
 
113
- // check that local track was enabled
114
- assert.calledWith(Media.setLocalTrack, true, meeting.mediaProperties.audioTrack);
112
+ // check that local track was unmuted
113
+ assert.calledWith(meeting.mediaProperties.audioTrack.setMuted, false);
115
114
 
116
115
  // and local unmute was sent to server
117
116
  assert.calledOnce(MeetingUtil.remoteUpdateAudioVideo);
@@ -161,8 +160,8 @@ describe('plugin-meetings', () => {
161
160
  assert.calledOnce(MeetingUtil.remoteUpdateAudioVideo);
162
161
  assert.calledWith(MeetingUtil.remoteUpdateAudioVideo, false, undefined, meeting);
163
162
 
164
- // and local track should be enabled
165
- assert.calledWith(Media.setLocalTrack, true, meeting.mediaProperties.audioTrack);
163
+ // and local track should be unmuted
164
+ assert.calledWith(meeting.mediaProperties.audioTrack.setMuted, false);
166
165
 
167
166
  assert.isFalse(audio.isMuted());
168
167
  assert.isFalse(audio.isSelf());
@@ -183,37 +182,37 @@ describe('plugin-meetings', () => {
183
182
  it('disables/enables the local audio track when audio is muted/unmuted', async () => {
184
183
  // mute
185
184
  audio.handleClientRequest(meeting, true);
186
- assert.calledWith(Media.setLocalTrack, false, meeting.mediaProperties.audioTrack);
185
+ assert.calledWith(meeting.mediaProperties.audioTrack.setMuted, true);
187
186
 
188
- // even when calling mute when it's already muted should still call setLocalTrack
187
+ // even when calling mute when it's already muted should still call setMuted
189
188
  audio.handleClientRequest(meeting, true);
190
- assert.calledWith(Media.setLocalTrack, false, meeting.mediaProperties.audioTrack);
189
+ assert.calledWith(meeting.mediaProperties.audioTrack.setMuted, true);
191
190
 
192
191
  // unmute
193
192
  audio.handleClientRequest(meeting, false);
194
- assert.calledWith(Media.setLocalTrack, true, meeting.mediaProperties.audioTrack);
193
+ assert.calledWith(meeting.mediaProperties.audioTrack.setMuted, false);
195
194
 
196
- // even when calling unmute when it's already unmuted should still call setLocalTrack
195
+ // even when calling unmute when it's already unmuted should still call setMuted
197
196
  audio.handleClientRequest(meeting, false);
198
- assert.calledWith(Media.setLocalTrack, true, meeting.mediaProperties.audioTrack);
197
+ assert.calledWith(meeting.mediaProperties.audioTrack.setMuted, false);
199
198
  });
200
199
 
201
200
  it('disables/enables the local video track when video is muted/unmuted', async () => {
202
201
  // mute
203
202
  video.handleClientRequest(meeting, true);
204
- assert.calledWith(Media.setLocalTrack, false, meeting.mediaProperties.videoTrack);
203
+ assert.calledWith(meeting.mediaProperties.videoTrack.setMuted, true);
205
204
 
206
- // even when calling mute when it's already muted should still call setLocalTrack
205
+ // even when calling mute when it's already muted should still call setMuted
207
206
  video.handleClientRequest(meeting, false);
208
- assert.calledWith(Media.setLocalTrack, false, meeting.mediaProperties.videoTrack);
207
+ assert.calledWith(meeting.mediaProperties.videoTrack.setMuted, true);
209
208
 
210
209
  // unmute
211
210
  video.handleClientRequest(meeting, false);
212
- assert.calledWith(Media.setLocalTrack, true, meeting.mediaProperties.videoTrack);
211
+ assert.calledWith(meeting.mediaProperties.videoTrack.setMuted, false);
213
212
 
214
- // even when calling unmute when it's already unmuted should still call setLocalTrack
213
+ // even when calling unmute when it's already unmuted should still call setMuted
215
214
  video.handleClientRequest(meeting, false);
216
- assert.calledWith(Media.setLocalTrack, true, meeting.mediaProperties.videoTrack);
215
+ assert.calledWith(meeting.mediaProperties.videoTrack.setMuted, false);
217
216
  });
218
217
 
219
218
  it('returns correct value in isMuted()/isSelf() methods after client mute/unmute requests', async () => {
@@ -389,11 +388,11 @@ describe('plugin-meetings', () => {
389
388
  assert.isTrue(video.isSelf());
390
389
 
391
390
  // check local mute is done, but not remote one
392
- assert.calledWith(Media.setLocalTrack, false, meeting.mediaProperties.videoTrack);
391
+ assert.calledWith(meeting.mediaProperties.videoTrack.setMuted, true);
393
392
  assert.calledWith(MeetingUtil.remoteUpdateAudioVideo, undefined, true, meeting);
394
393
  assert.notCalled(meeting.members.muteMember);
395
394
 
396
- Media.setLocalTrack.resetHistory();
395
+ meeting.mediaProperties.videoTrack.setMuted.resetHistory();
397
396
  MeetingUtil.remoteUpdateAudioVideo.resetHistory();
398
397
  meeting.members.muteMember.resetHistory();
399
398
 
@@ -403,7 +402,7 @@ describe('plugin-meetings', () => {
403
402
  assert.isFalse(video.isMuted());
404
403
  assert.isFalse(video.isSelf());
405
404
 
406
- assert.calledWith(Media.setLocalTrack, true, meeting.mediaProperties.videoTrack);
405
+ assert.calledWith(meeting.mediaProperties.videoTrack.setMuted, false);
407
406
  assert.calledWith(MeetingUtil.remoteUpdateAudioVideo, undefined, false, meeting);
408
407
  assert.notCalled(meeting.members.muteMember);
409
408
  });
@@ -71,7 +71,9 @@ describe('plugin-meetings', () => {
71
71
  });
72
72
 
73
73
  const mockTrack = {
74
- getSettings: fakeDevice,
74
+ underlyingTrack: {
75
+ getSettings: fakeDevice,
76
+ }
75
77
  };
76
78
 
77
79
  it('#log - should log [info, warn, error, log] to console', () => {
@@ -195,7 +195,7 @@ const delayedTest = (callback, timeout) =>
195
195
  }, timeout);
196
196
  });
197
197
 
198
- const addMedia = (user, options = {}) => {
198
+ const addMedia = async (user, options = {}) => {
199
199
  const mediaReadyPromises = Array.isArray(options.expectedMediaReadyTypes)
200
200
  ? options.expectedMediaReadyTypes.reduce((output, expectedMediaReadyType) => {
201
201
  if (typeof expectedMediaReadyType !== 'string') {
@@ -219,31 +219,36 @@ const addMedia = (user, options = {}) => {
219
219
 
220
220
  user.meeting.on('media:ready', mediaReady);
221
221
 
222
- return user.meeting
223
- .getMediaStreams({
224
- sendAudio: true,
225
- sendVideo: true,
226
- sendShare: false,
227
- })
228
- .then(([localStream, localShare]) =>
229
- user.meeting.addMedia({
230
- mediaSettings: {
231
- sendAudio: true,
232
- sendVideo: true,
233
- sendShare: false,
234
- receiveShare: true,
235
- receiveAudio: true,
236
- receiveVideo: true,
237
- },
238
- localShare,
239
- localStream,
240
- })
241
- )
242
- .then(() => Promise.all(Object.values(mediaReadyPromises).map((defer) => defer.promise)))
243
- .then(() => {
244
- assert.exists(user.meeting.mediaProperties.audioTrack, 'audioTrack not present');
245
- assert.exists(user.meeting.mediaProperties.videoTrack, 'videoTrack not present');
222
+ const [localStream, localShare] = await user.meeting
223
+ .getMediaStreams({
224
+ sendAudio: true,
225
+ sendVideo: true,
226
+ sendShare: false,
227
+ });
228
+
229
+ if (options.multistream) {
230
+ await user.meeting.addMedia({});
231
+
232
+ await user.meeting.publishTracks({microphone: localStream.getAudioTracks()[0], camera: localStream.getVideoTracks()[0]})
233
+ } else {
234
+ await user.meeting.addMedia({
235
+ mediaSettings: {
236
+ sendAudio: true,
237
+ sendVideo: true,
238
+ sendShare: false,
239
+ receiveShare: true,
240
+ receiveAudio: true,
241
+ receiveVideo: true,
242
+ },
243
+ localShare,
244
+ localStream,
246
245
  });
246
+ }
247
+
248
+ await Promise.all(Object.values(mediaReadyPromises).map((defer) => defer.promise));
249
+
250
+ assert.exists(user.meeting.mediaProperties.audioTrack, 'audioTrack not present');
251
+ assert.exists(user.meeting.mediaProperties.videoTrack, 'videoTrack not present');
247
252
  };
248
253
 
249
254
  const waitUntil = (waitTime) =>
@@ -1,262 +0,0 @@
1
- "use strict";
2
-
3
- var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
- var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
5
- _Object$defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
10
- var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
11
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
13
- var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
14
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
15
- var _internalMediaCore = require("@webex/internal-media-core");
16
- var _constants = _interopRequireDefault(require("../metrics/constants"));
17
- var _metrics = _interopRequireDefault(require("../metrics"));
18
- var _util = _interopRequireDefault(require("../media/util"));
19
- var _loggerProxy = _interopRequireDefault(require("../common/logs/logger-proxy"));
20
- var _constants2 = require("../constants");
21
- /* eslint-disable no-param-reassign */
22
-
23
- var createEffectsState = function createEffectsState(type) {
24
- _loggerProxy.default.logger.info("Meeting:effectState#createEffectsState --> creating effectsState for effect ".concat(type));
25
- return new EffectsState(type);
26
- };
27
-
28
- /* The purpose of this class is to manage the effects state(for eg., BNR).
29
- */
30
- var EffectsState = /*#__PURE__*/function () {
31
- function EffectsState(type) {
32
- (0, _classCallCheck2.default)(this, EffectsState);
33
- (0, _defineProperty2.default)(this, "effectType", void 0);
34
- (0, _defineProperty2.default)(this, "pendingPromiseReject", void 0);
35
- (0, _defineProperty2.default)(this, "pendingPromiseResolve", void 0);
36
- (0, _defineProperty2.default)(this, "state", void 0);
37
- this.effectType = type;
38
- this.state = {
39
- bnr: {
40
- enabled: _constants2.BNR_STATUS.NOT_ENABLED
41
- },
42
- callToWebrtcBNRInProgress: false
43
- };
44
- // these 2 hold the resolve, reject methods for the promise we returned to the client in last handleClientRequest() call
45
- this.pendingPromiseResolve = null;
46
- this.pendingPromiseReject = null;
47
- }
48
-
49
- /**
50
- * @memberof EffectsState
51
- * @param {Boolean} [isEnable] true for enableBNR, false for disableBNR request
52
- * @param {Object} [meeting] the meeting object
53
- * @returns {Promise}
54
- */
55
- (0, _createClass2.default)(EffectsState, [{
56
- key: "handleClientRequest",
57
- value: function () {
58
- var _handleClientRequest = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(isEnable, meeting) {
59
- var _this = this;
60
- return _regenerator.default.wrap(function _callee$(_context) {
61
- while (1) switch (_context.prev = _context.next) {
62
- case 0:
63
- return _context.abrupt("return", new _promise.default(function (resolve, reject) {
64
- if (_this.pendingPromiseResolve) {
65
- // resolve the last promise we returned to the client as the client has issued a new request that has superseded the previous one
66
- _this.pendingPromiseResolve();
67
- }
68
- _this.pendingPromiseResolve = resolve;
69
- _this.pendingPromiseReject = reject;
70
- if (isEnable) _this.enableBNR(meeting);else _this.disableBNR(meeting);
71
- }));
72
- case 1:
73
- case "end":
74
- return _context.stop();
75
- }
76
- }, _callee);
77
- }));
78
- function handleClientRequest(_x, _x2) {
79
- return _handleClientRequest.apply(this, arguments);
80
- }
81
- return handleClientRequest;
82
- }()
83
- /**
84
- * Internal API to return status of BNR
85
- * @memberof EffectsState
86
- * @returns {Boolean}
87
- * @public
88
- * @memberof Meeting
89
- */
90
- }, {
91
- key: "isBnrEnabled",
92
- value: function isBnrEnabled() {
93
- return this.state.bnr.enabled === _constants2.BNR_STATUS.ENABLED;
94
- }
95
- }, {
96
- key: "resolvePromise",
97
- value: function resolvePromise() {
98
- if (this.pendingPromiseResolve) {
99
- this.pendingPromiseResolve(true);
100
- }
101
- this.pendingPromiseResolve = null;
102
- this.pendingPromiseReject = null;
103
- }
104
- }, {
105
- key: "rejectPromise",
106
- value: function rejectPromise(e) {
107
- if (this.pendingPromiseReject) {
108
- this.pendingPromiseReject(e);
109
- }
110
- this.pendingPromiseResolve = null;
111
- this.pendingPromiseReject = null;
112
- }
113
-
114
- /**
115
- * enableBNR API
116
- * @param {Object} meeting the meeting object
117
- * @returns {Promise<Boolean>}
118
- * @public
119
- * @memberof EffectsState
120
- */
121
- }, {
122
- key: "enableBNR",
123
- value: function () {
124
- var _enableBNR = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(meeting) {
125
- var bnr, audioStream;
126
- return _regenerator.default.wrap(function _callee2$(_context2) {
127
- while (1) switch (_context2.prev = _context2.next) {
128
- case 0:
129
- _loggerProxy.default.logger.info('Meeting:effectState#enableBNR. Enable BNR called');
130
- if (!this.isBnrEnabled()) {
131
- _context2.next = 4;
132
- break;
133
- }
134
- _loggerProxy.default.logger.warn('Meeting:index#enableBNR. BNR is already enabled');
135
- return _context2.abrupt("return", this.resolvePromise());
136
- case 4:
137
- if (!this.state.callToWebrtcBNRInProgress) {
138
- _context2.next = 7;
139
- break;
140
- }
141
- _loggerProxy.default.logger.warn('Meeting:effectState#enableBNR. Call to WebRTC in progress, we need to wait for it to complete');
142
- return _context2.abrupt("return", this.resolvePromise());
143
- case 7:
144
- bnr = this.state.bnr;
145
- _context2.prev = 8;
146
- bnr.enabled = _constants2.BNR_STATUS.SHOULD_ENABLE;
147
- this.state.callToWebrtcBNRInProgress = true;
148
- audioStream = _util.default.createMediaStream([meeting.mediaProperties.audioTrack]);
149
- _loggerProxy.default.logger.info('Meeting:effectState#enableBNR. MediaStream created from meeting & sent to updateAudio');
150
- _context2.next = 15;
151
- return meeting.updateAudio({
152
- sendAudio: true,
153
- receiveAudio: meeting.mediaProperties.mediaDirection.receiveAudio,
154
- stream: audioStream
155
- });
156
- case 15:
157
- _loggerProxy.default.logger.info('Meeting:effectState#enableBNR. Updated meeting audio with bnr enabled track');
158
- bnr.enabled = _constants2.BNR_STATUS.ENABLED;
159
- this.state.callToWebrtcBNRInProgress = false;
160
- _metrics.default.sendBehavioralMetric(_constants.default.ENABLE_BNR_SUCCESS);
161
- _context2.next = 29;
162
- break;
163
- case 21:
164
- _context2.prev = 21;
165
- _context2.t0 = _context2["catch"](8);
166
- bnr.enabled = _constants2.BNR_STATUS.NOT_ENABLED;
167
- this.state.callToWebrtcBNRInProgress = false;
168
- _loggerProxy.default.logger.error('Meeting:index#enableBNR.', _context2.t0);
169
- _metrics.default.sendBehavioralMetric(_constants.default.ENABLE_BNR_FAILURE, {
170
- reason: _context2.t0.message,
171
- stack: _context2.t0.stack
172
- });
173
- this.rejectPromise(_context2.t0);
174
- throw _context2.t0;
175
- case 29:
176
- return _context2.abrupt("return", this.resolvePromise());
177
- case 30:
178
- case "end":
179
- return _context2.stop();
180
- }
181
- }, _callee2, this, [[8, 21]]);
182
- }));
183
- function enableBNR(_x3) {
184
- return _enableBNR.apply(this, arguments);
185
- }
186
- return enableBNR;
187
- }()
188
- /**
189
- * disableBNR API
190
- * @param {Object} meeting the meeting object
191
- * @returns {Promise<Boolean>}
192
- * @public
193
- * @memberof EffectsState
194
- */
195
- }, {
196
- key: "disableBNR",
197
- value: function () {
198
- var _disableBNR = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(meeting) {
199
- var bnr, audioTrack, audioStream;
200
- return _regenerator.default.wrap(function _callee3$(_context3) {
201
- while (1) switch (_context3.prev = _context3.next) {
202
- case 0:
203
- _loggerProxy.default.logger.info('Meeting:effectState#disableBNR. Disable BNR called');
204
- bnr = this.state.bnr;
205
- _context3.prev = 2;
206
- if (!this.state.callToWebrtcBNRInProgress) {
207
- _context3.next = 6;
208
- break;
209
- }
210
- _loggerProxy.default.logger.info('Meeting:effectState#disableBNR. Call to WebRTC in progress, we need to wait for it to complete');
211
- return _context3.abrupt("return", this.resolvePromise());
212
- case 6:
213
- bnr.enabled = _constants2.BNR_STATUS.SHOULD_DISABLE;
214
- this.state.callToWebrtcBNRInProgress = true;
215
-
216
- // @ts-ignore - disableBNR does not expect an argument
217
- audioTrack = _internalMediaCore.Media.Effects.BNR.disableBNR(meeting.mediaProperties.audioTrack);
218
- audioStream = _util.default.createMediaStream([audioTrack]);
219
- _loggerProxy.default.logger.info('Meeting:effectState#disableBNR. Raw media track obtained from WebRTC & sent to updateAudio');
220
- _context3.next = 13;
221
- return meeting.updateAudio({
222
- sendAudio: true,
223
- receiveAudio: meeting.mediaProperties.mediaDirection.receiveAudio,
224
- stream: audioStream
225
- });
226
- case 13:
227
- bnr.enabled = _constants2.BNR_STATUS.NOT_ENABLED;
228
- this.state.callToWebrtcBNRInProgress = false;
229
- _metrics.default.sendBehavioralMetric(_constants.default.DISABLE_BNR_SUCCESS);
230
- _context3.next = 26;
231
- break;
232
- case 18:
233
- _context3.prev = 18;
234
- _context3.t0 = _context3["catch"](2);
235
- bnr.enabled = _constants2.BNR_STATUS.ENABLED;
236
- this.state.callToWebrtcBNRInProgress = false;
237
- _loggerProxy.default.logger.error("Meeting:index#disableBNR. ".concat(_context3.t0));
238
- _metrics.default.sendBehavioralMetric(_constants.default.DISABLE_BNR_FAILURE, {
239
- reason: _context3.t0.message,
240
- stack: _context3.t0.stack
241
- });
242
- this.rejectPromise(_context3.t0);
243
- throw _context3.t0;
244
- case 26:
245
- return _context3.abrupt("return", this.resolvePromise());
246
- case 27:
247
- case "end":
248
- return _context3.stop();
249
- }
250
- }, _callee3, this, [[2, 18]]);
251
- }));
252
- function disableBNR(_x4) {
253
- return _disableBNR.apply(this, arguments);
254
- }
255
- return disableBNR;
256
- }()
257
- }]);
258
- return EffectsState;
259
- }();
260
- var _default = createEffectsState;
261
- exports.default = _default;
262
- //# sourceMappingURL=effectsState.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["createEffectsState","type","LoggerProxy","logger","info","EffectsState","effectType","state","bnr","enabled","BNR_STATUS","NOT_ENABLED","callToWebrtcBNRInProgress","pendingPromiseResolve","pendingPromiseReject","isEnable","meeting","resolve","reject","enableBNR","disableBNR","ENABLED","e","isBnrEnabled","warn","resolvePromise","SHOULD_ENABLE","audioStream","MediaUtil","createMediaStream","mediaProperties","audioTrack","updateAudio","sendAudio","receiveAudio","mediaDirection","stream","Metrics","sendBehavioralMetric","BEHAVIORAL_METRICS","ENABLE_BNR_SUCCESS","error","ENABLE_BNR_FAILURE","reason","message","stack","rejectPromise","SHOULD_DISABLE","WebRTCMedia","Effects","BNR","DISABLE_BNR_SUCCESS","DISABLE_BNR_FAILURE"],"sources":["effectsState.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport {Media as WebRTCMedia} from '@webex/internal-media-core';\n\nimport BEHAVIORAL_METRICS from '../metrics/constants';\nimport Metrics from '../metrics';\nimport MediaUtil from '../media/util';\nimport LoggerProxy from '../common/logs/logger-proxy';\nimport {BNR_STATUS} from '../constants';\n\nconst createEffectsState = (type: any) => {\n LoggerProxy.logger.info(\n `Meeting:effectState#createEffectsState --> creating effectsState for effect ${type}`\n );\n\n return new EffectsState(type);\n};\n\n/* The purpose of this class is to manage the effects state(for eg., BNR).\n */\nclass EffectsState {\n effectType: any;\n pendingPromiseReject: any;\n pendingPromiseResolve: any;\n state: any;\n\n constructor(type: any) {\n this.effectType = type;\n this.state = {\n bnr: {\n enabled: BNR_STATUS.NOT_ENABLED,\n },\n callToWebrtcBNRInProgress: false,\n };\n // these 2 hold the resolve, reject methods for the promise we returned to the client in last handleClientRequest() call\n this.pendingPromiseResolve = null;\n this.pendingPromiseReject = null;\n }\n\n /**\n * @memberof EffectsState\n * @param {Boolean} [isEnable] true for enableBNR, false for disableBNR request\n * @param {Object} [meeting] the meeting object\n * @returns {Promise}\n */\n async handleClientRequest(isEnable?: boolean, meeting?: object) {\n return new Promise((resolve, reject) => {\n if (this.pendingPromiseResolve) {\n // resolve the last promise we returned to the client as the client has issued a new request that has superseded the previous one\n this.pendingPromiseResolve();\n }\n this.pendingPromiseResolve = resolve;\n this.pendingPromiseReject = reject;\n\n if (isEnable) this.enableBNR(meeting);\n else this.disableBNR(meeting);\n });\n }\n\n /**\n * Internal API to return status of BNR\n * @memberof EffectsState\n * @returns {Boolean}\n * @public\n * @memberof Meeting\n */\n public isBnrEnabled() {\n return this.state.bnr.enabled === BNR_STATUS.ENABLED;\n }\n\n resolvePromise() {\n if (this.pendingPromiseResolve) {\n this.pendingPromiseResolve(true);\n }\n this.pendingPromiseResolve = null;\n this.pendingPromiseReject = null;\n }\n\n rejectPromise(e) {\n if (this.pendingPromiseReject) {\n this.pendingPromiseReject(e);\n }\n this.pendingPromiseResolve = null;\n this.pendingPromiseReject = null;\n }\n\n /**\n * enableBNR API\n * @param {Object} meeting the meeting object\n * @returns {Promise<Boolean>}\n * @public\n * @memberof EffectsState\n */\n public async enableBNR(meeting: any) {\n LoggerProxy.logger.info('Meeting:effectState#enableBNR. Enable BNR called');\n\n if (this.isBnrEnabled()) {\n LoggerProxy.logger.warn('Meeting:index#enableBNR. BNR is already enabled');\n\n return this.resolvePromise();\n }\n\n if (this.state.callToWebrtcBNRInProgress) {\n LoggerProxy.logger.warn(\n 'Meeting:effectState#enableBNR. Call to WebRTC in progress, we need to wait for it to complete'\n );\n\n return this.resolvePromise();\n }\n\n const {bnr} = this.state;\n\n try {\n bnr.enabled = BNR_STATUS.SHOULD_ENABLE;\n this.state.callToWebrtcBNRInProgress = true;\n const audioStream = MediaUtil.createMediaStream([meeting.mediaProperties.audioTrack]);\n\n LoggerProxy.logger.info(\n 'Meeting:effectState#enableBNR. MediaStream created from meeting & sent to updateAudio'\n );\n await meeting.updateAudio({\n sendAudio: true,\n receiveAudio: meeting.mediaProperties.mediaDirection.receiveAudio,\n stream: audioStream,\n });\n\n LoggerProxy.logger.info(\n 'Meeting:effectState#enableBNR. Updated meeting audio with bnr enabled track'\n );\n bnr.enabled = BNR_STATUS.ENABLED;\n this.state.callToWebrtcBNRInProgress = false;\n Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.ENABLE_BNR_SUCCESS);\n } catch (error) {\n bnr.enabled = BNR_STATUS.NOT_ENABLED;\n this.state.callToWebrtcBNRInProgress = false;\n LoggerProxy.logger.error('Meeting:index#enableBNR.', error);\n\n Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.ENABLE_BNR_FAILURE, {\n reason: error.message,\n stack: error.stack,\n });\n this.rejectPromise(error);\n\n throw error;\n }\n\n return this.resolvePromise();\n }\n\n /**\n * disableBNR API\n * @param {Object} meeting the meeting object\n * @returns {Promise<Boolean>}\n * @public\n * @memberof EffectsState\n */\n public async disableBNR(meeting: any) {\n LoggerProxy.logger.info('Meeting:effectState#disableBNR. Disable BNR called');\n\n const {bnr} = this.state;\n\n try {\n if (this.state.callToWebrtcBNRInProgress) {\n LoggerProxy.logger.info(\n 'Meeting:effectState#disableBNR. Call to WebRTC in progress, we need to wait for it to complete'\n );\n\n return this.resolvePromise();\n }\n\n bnr.enabled = BNR_STATUS.SHOULD_DISABLE;\n this.state.callToWebrtcBNRInProgress = true;\n\n // @ts-ignore - disableBNR does not expect an argument\n const audioTrack = WebRTCMedia.Effects.BNR.disableBNR(meeting.mediaProperties.audioTrack);\n\n const audioStream = MediaUtil.createMediaStream([audioTrack]);\n\n LoggerProxy.logger.info(\n 'Meeting:effectState#disableBNR. Raw media track obtained from WebRTC & sent to updateAudio'\n );\n\n await meeting.updateAudio({\n sendAudio: true,\n receiveAudio: meeting.mediaProperties.mediaDirection.receiveAudio,\n stream: audioStream,\n });\n\n bnr.enabled = BNR_STATUS.NOT_ENABLED;\n\n this.state.callToWebrtcBNRInProgress = false;\n\n Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.DISABLE_BNR_SUCCESS);\n } catch (error) {\n bnr.enabled = BNR_STATUS.ENABLED;\n this.state.callToWebrtcBNRInProgress = false;\n LoggerProxy.logger.error(`Meeting:index#disableBNR. ${error}`);\n\n Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.DISABLE_BNR_FAILURE, {\n reason: error.message,\n stack: error.stack,\n });\n this.rejectPromise(error);\n\n throw error;\n }\n\n return this.resolvePromise();\n }\n}\n\nexport default createEffectsState;\n"],"mappings":";;;;;;;;;;;;;;AACA;AAEA;AACA;AACA;AACA;AACA;AAPA;;AASA,IAAMA,kBAAkB,GAAG,SAArBA,kBAAkB,CAAIC,IAAS,EAAK;EACxCC,oBAAW,CAACC,MAAM,CAACC,IAAI,uFAC0DH,IAAI,EACpF;EAED,OAAO,IAAII,YAAY,CAACJ,IAAI,CAAC;AAC/B,CAAC;;AAED;AACA;AADA,IAEMI,YAAY;EAMhB,sBAAYJ,IAAS,EAAE;IAAA;IAAA;IAAA;IAAA;IAAA;IACrB,IAAI,CAACK,UAAU,GAAGL,IAAI;IACtB,IAAI,CAACM,KAAK,GAAG;MACXC,GAAG,EAAE;QACHC,OAAO,EAAEC,sBAAU,CAACC;MACtB,CAAC;MACDC,yBAAyB,EAAE;IAC7B,CAAC;IACD;IACA,IAAI,CAACC,qBAAqB,GAAG,IAAI;IACjC,IAAI,CAACC,oBAAoB,GAAG,IAAI;EAClC;;EAEA;AACF;AACA;AACA;AACA;AACA;EALE;IAAA;IAAA;MAAA,mGAMA,iBAA0BC,QAAkB,EAAEC,OAAgB;QAAA;QAAA;UAAA;YAAA;cAAA,iCACrD,qBAAY,UAACC,OAAO,EAAEC,MAAM,EAAK;gBACtC,IAAI,KAAI,CAACL,qBAAqB,EAAE;kBAC9B;kBACA,KAAI,CAACA,qBAAqB,EAAE;gBAC9B;gBACA,KAAI,CAACA,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C,GAAG,CAACC,OAAO,GAAGC,sBAAU,CAACW,OAAO;cAChC,IAAI,CAACd,KAAK,CAACK,yBAAyB,GAAG,KAAK;cAC5CV,oBAAW,CAACC,MAAM,CAACsC,KAAK,mDAAsC;cAE9DJ,gBAAO,CAACC,oBAAoB,CAACC,kBAAkB,CAACa,mBAAmB,EAAE;gBACnET,MAAM,EAAE,aAAMC,OAAO;gBACrBC,KAAK,EAAE,aAAMA;cACf,CAAC,CAAC;cACF,IAAI,CAACC,aAAa,cAAO;cAAC;YAAA;cAAA,kCAKrB,IAAI,CAACrB,cAAc,EAAE;YAAA;YAAA;cAAA;UAAA;QAAA;MAAA,CAC7B;MAAA;QAAA;MAAA;MAAA;IAAA;EAAA;EAAA;AAAA;AAAA,eAGYzB,kBAAkB;AAAA"}
@@ -1,42 +0,0 @@
1
- declare const createEffectsState: (type: any) => EffectsState;
2
- declare class EffectsState {
3
- effectType: any;
4
- pendingPromiseReject: any;
5
- pendingPromiseResolve: any;
6
- state: any;
7
- constructor(type: any);
8
- /**
9
- * @memberof EffectsState
10
- * @param {Boolean} [isEnable] true for enableBNR, false for disableBNR request
11
- * @param {Object} [meeting] the meeting object
12
- * @returns {Promise}
13
- */
14
- handleClientRequest(isEnable?: boolean, meeting?: object): Promise<unknown>;
15
- /**
16
- * Internal API to return status of BNR
17
- * @memberof EffectsState
18
- * @returns {Boolean}
19
- * @public
20
- * @memberof Meeting
21
- */
22
- isBnrEnabled(): boolean;
23
- resolvePromise(): void;
24
- rejectPromise(e: any): void;
25
- /**
26
- * enableBNR API
27
- * @param {Object} meeting the meeting object
28
- * @returns {Promise<Boolean>}
29
- * @public
30
- * @memberof EffectsState
31
- */
32
- enableBNR(meeting: any): Promise<void>;
33
- /**
34
- * disableBNR API
35
- * @param {Object} meeting the meeting object
36
- * @returns {Promise<Boolean>}
37
- * @public
38
- * @memberof EffectsState
39
- */
40
- disableBNR(meeting: any): Promise<void>;
41
- }
42
- export default createEffectsState;