@webex/plugin-meetings 3.0.0-beta.34 → 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 (71) 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 +14 -2
  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/request.js +135 -85
  17. package/dist/meeting/request.js.map +1 -1
  18. package/dist/meeting/util.js +2 -2
  19. package/dist/meeting/util.js.map +1 -1
  20. package/dist/metrics/constants.js +0 -4
  21. package/dist/metrics/constants.js.map +1 -1
  22. package/dist/reachability/index.js +25 -17
  23. package/dist/reachability/index.js.map +1 -1
  24. package/dist/reachability/request.js +12 -5
  25. package/dist/reachability/request.js.map +1 -1
  26. package/dist/reconnection-manager/index.js +1 -2
  27. package/dist/reconnection-manager/index.js.map +1 -1
  28. package/dist/roap/request.js +114 -83
  29. package/dist/roap/request.js.map +1 -1
  30. package/dist/types/breakouts/edit-lock-error.d.ts +15 -0
  31. package/dist/types/constants.d.ts +13 -1
  32. package/dist/types/media/properties.d.ts +7 -6
  33. package/dist/types/meeting/index.d.ts +11 -36
  34. package/dist/types/meeting/request.d.ts +10 -0
  35. package/dist/types/metrics/constants.d.ts +0 -4
  36. package/dist/types/reachability/request.d.ts +5 -3
  37. package/dist/types/roap/request.d.ts +6 -3
  38. package/package.json +19 -19
  39. package/src/breakouts/README.md +8 -2
  40. package/src/breakouts/edit-lock-error.ts +25 -0
  41. package/src/breakouts/index.ts +73 -0
  42. package/src/constants.ts +13 -1
  43. package/src/media/index.ts +14 -24
  44. package/src/media/properties.ts +16 -10
  45. package/src/meeting/index.ts +122 -204
  46. package/src/meeting/muteState.ts +5 -5
  47. package/src/meeting/request.ts +35 -1
  48. package/src/meeting/util.ts +5 -4
  49. package/src/metrics/constants.ts +0 -4
  50. package/src/reachability/index.ts +12 -4
  51. package/src/reachability/request.ts +10 -5
  52. package/src/reconnection-manager/index.ts +1 -1
  53. package/src/roap/request.ts +93 -78
  54. package/test/integration/spec/converged-space-meetings.js +3 -3
  55. package/test/integration/spec/journey.js +3 -3
  56. package/test/unit/spec/breakouts/edit-lock-error.ts +30 -0
  57. package/test/unit/spec/breakouts/index.ts +92 -1
  58. package/test/unit/spec/media/index.ts +8 -6
  59. package/test/unit/spec/meeting/index.js +87 -114
  60. package/test/unit/spec/meeting/muteState.js +21 -22
  61. package/test/unit/spec/meeting/request.js +27 -0
  62. package/test/unit/spec/meeting/utils.js +3 -1
  63. package/test/unit/spec/reachability/index.ts +18 -7
  64. package/test/unit/spec/reachability/request.js +66 -0
  65. package/test/unit/spec/roap/request.ts +187 -84
  66. package/test/utils/testUtils.js +30 -25
  67. package/dist/meeting/effectsState.js +0 -262
  68. package/dist/meeting/effectsState.js.map +0 -1
  69. package/dist/types/meeting/effectsState.d.ts +0 -42
  70. package/src/meeting/effectsState.ts +0 -211
  71. package/test/unit/spec/meeting/effectsState.js +0 -285
@@ -1,114 +1,217 @@
1
- import {assert} from '@webex/test-helper-chai';
2
1
  import sinon from 'sinon';
2
+ import {assert} from '@webex/test-helper-chai';
3
3
  import MockWebex from '@webex/test-helper-mock-webex';
4
- import Metrics from '@webex/plugin-meetings/src/metrics';
5
-
4
+ import Meetings from '@webex/plugin-meetings';
6
5
  import RoapRequest from '@webex/plugin-meetings/src/roap/request';
7
-
8
-
9
- describe('RoapRequest', () => {
10
- describe('attachRechabilityData', () => {
11
- let webex;
12
-
13
- beforeEach(() => {
14
- webex = new MockWebex();
6
+ import Metrics from '@webex/plugin-meetings/src/metrics';
7
+ import {REACHABILITY} from '@webex/plugin-meetings/src/constants';
8
+
9
+ describe('plugin-meetings/roap', () => {
10
+ let roapRequest;
11
+ let webex;
12
+ const locusUrl = 'locusUrl';
13
+
14
+ beforeEach(async () => {
15
+ webex = new MockWebex({
16
+ children: {
17
+ meetings: Meetings,
18
+ },
15
19
  });
16
-
17
- it('attaches the reachability data when it exists', async () => {
18
- // @ts-ignore
19
- const roapRequest = new RoapRequest({}, {parent: webex});
20
20
 
21
- const sdp = {some: 'attribute'};
21
+ webex.meetings.clientRegion = {
22
+ countryCode: 'US',
23
+ regionCode: 'WEST-COAST',
24
+ };
25
+
26
+ webex.internal = {
27
+ services: {
28
+ get: sinon.mock().returns(locusUrl),
29
+ waitForCatalog: sinon.mock().returns(Promise.resolve({})),
30
+ },
31
+ device: {
32
+ url: 'url',
33
+ },
34
+ };
35
+
36
+ // @ts-ignore
37
+ roapRequest = new RoapRequest({webex});
38
+
39
+ roapRequest.request = sinon.mock().returns(
40
+ Promise.resolve({
41
+ body: {
42
+ locus: {
43
+ roapSeq: '',
44
+ id: '',
45
+ url: 'url/path',
46
+ fullState: {
47
+ lastActive: 'lastActive',
48
+ },
49
+ },
50
+ },
51
+ })
52
+ );
22
53
 
23
- const reachabilitData = {reachability: 'data'};
54
+ Metrics.postEvent = sinon.stub().returns();
24
55
 
25
- await webex.boundedStorage.put(
26
- 'Reachability',
27
- 'reachability.result',
28
- JSON.stringify(reachabilitData)
29
- );
56
+ await webex.boundedStorage.put(
57
+ REACHABILITY.namespace,
58
+ REACHABILITY.localStorageJoinCookie,
59
+ JSON.stringify({
60
+ anycastEntryPoint: 'aws-eu-west-1',
61
+ })
62
+ );
63
+ await webex.boundedStorage.put(
64
+ REACHABILITY.namespace,
65
+ REACHABILITY.localStorageResult,
66
+ JSON.stringify({
67
+ clusterId: {
68
+ udp: 'test',
69
+ },
70
+ })
71
+ );
72
+ });
30
73
 
31
- const newSdp = await roapRequest.attachRechabilityData(sdp);
74
+ describe('#attachReachabilityData', () => {
75
+ it('returns the correct reachability data', async () => {
76
+ const res = await roapRequest.attachReachabilityData({});
32
77
 
33
- assert.deepEqual(newSdp, {
34
- some: 'attribute',
35
- reachability: reachabilitData
36
- })
78
+ assert.deepEqual(res.localSdp, {
79
+ reachability: {
80
+ clusterId: {
81
+ udp: 'test',
82
+ },
83
+ },
84
+ });
85
+ assert.deepEqual(res.joinCookie, {
86
+ anycastEntryPoint: 'aws-eu-west-1',
87
+ });
37
88
  });
38
-
39
- it('handles the case when realiability data does not exist', async () => {
40
- // @ts-ignore
41
- const roapRequest = new RoapRequest({}, {parent: webex});
42
89
 
43
- const sdp = {some: 'attribute'};
90
+ it('handles the case when reachability data does not exist', async () => {
91
+ await webex.boundedStorage.del(REACHABILITY.namespace, REACHABILITY.localStorageJoinCookie);
44
92
 
45
- const newSdp = await roapRequest.attachRechabilityData(sdp);
93
+ await webex.boundedStorage.del(REACHABILITY.namespace, REACHABILITY.localStorageResult);
94
+ const sdp = {
95
+ some: 'attribute',
96
+ };
97
+
98
+ const result = await roapRequest.attachReachabilityData(sdp);
46
99
 
47
- assert.deepEqual(newSdp, sdp);
100
+ assert.deepEqual(result, {
101
+ joinCookie: undefined,
102
+ localSdp: {
103
+ some: 'attribute',
104
+ },
105
+ });
48
106
  });
49
107
  });
50
108
 
51
109
  describe('sendRoap', () => {
52
- let webex;
110
+ it('includes joinCookie in the request correctly', async () => {
111
+ await roapRequest.sendRoap({
112
+ locusSelfUrl: locusUrl,
113
+ mediaId: 'mediaId',
114
+ roapMessage: {
115
+ seq: 'seq',
116
+ },
117
+ });
53
118
 
54
- beforeEach(() => {
55
- webex = new MockWebex();
119
+ const requestParams = roapRequest.request.getCall(0).args[0];
120
+ assert.equal(requestParams.method, 'PUT');
121
+ assert.equal(requestParams.uri, `${locusUrl}/media`);
122
+ assert.deepEqual(requestParams.body.localMedias, [
123
+ {
124
+ localSdp:
125
+ '{"roapMessage":{"seq":"seq"},"audioMuted":false,"videoMuted":false,"reachability":{"clusterId":{"udp":"test"}}}',
126
+ mediaId: 'mediaId',
127
+ },
128
+ ]);
129
+ assert.deepEqual(requestParams.body.clientMediaPreferences, {
130
+ joinCookie: {
131
+ anycastEntryPoint: 'aws-eu-west-1',
132
+ },
133
+ preferTranscoding: true,
134
+ });
56
135
  });
136
+ });
57
137
 
58
- it('calls attachReliabilityData', async () => {
59
- Metrics.postEvent = sinon.stub();
60
-
61
- // @ts-ignore
62
- const roapRequest = new RoapRequest({}, {parent: webex});
63
-
64
- const newSdp = {new: 'sdp'}
138
+ it('calls attachReachabilityData when sendRoap', async () => {
139
+ const newSdp = {
140
+ new: 'sdp',
141
+ };
65
142
 
66
- roapRequest.attachRechabilityData = sinon.stub().returns(Promise.resolve(newSdp));
67
- webex.request.returns(Promise.resolve({
143
+ roapRequest.attachReachabilityData = sinon.stub().returns(
144
+ Promise.resolve({
145
+ localSdp: newSdp,
146
+ joinCookie: {
147
+ anycastEntryPoint: 'aws-eu-west-1',
148
+ },
149
+ })
150
+ );
151
+ webex.request.returns(
152
+ Promise.resolve({
68
153
  body: {
69
- locus: {}
70
- }
71
- }))
154
+ locus: {},
155
+ },
156
+ })
157
+ );
158
+
159
+ const result = await roapRequest.sendRoap({
160
+ roapMessage: {
161
+ seq: 1,
162
+ },
163
+ locusSelfUrl: 'locusSelfUrl',
164
+ mediaId: 'mediaId',
165
+ correlationId: 'correlationId',
166
+ audioMuted: true,
167
+ videoMuted: true,
168
+ meetingId: 'meetingId',
169
+ preferTranscoding: true,
170
+ });
72
171
 
73
- const result = await roapRequest.sendRoap({
74
- roapMessage: {seq: 1},
75
- locusSelfUrl: 'locusSelfUrl',
76
- mediaId: 'mediaId',
77
- correlationId: 'correlationId',
78
- audioMuted: true,
79
- videoMuted: true,
80
- meetingId: 'meetingId',
81
- preferTranscoding: true
82
- });
172
+ const requestParams = roapRequest.request.getCall(0).args[0];
83
173
 
84
- assert.calledOnceWithExactly(webex.request, {
85
- uri: 'locusSelfUrl/media',
86
- method: 'PUT',
87
- body: {
88
- device: {
89
- url: undefined,
90
- deviceType: undefined,
91
- },
92
- correlationId: 'correlationId',
93
- localMedias: [{
174
+ assert.deepEqual(requestParams, {
175
+ uri: 'locusSelfUrl/media',
176
+ method: 'PUT',
177
+ body: {
178
+ device: {
179
+ url: 'url',
180
+ deviceType: undefined,
181
+ },
182
+ correlationId: 'correlationId',
183
+ localMedias: [
184
+ {
94
185
  localSdp: JSON.stringify(newSdp),
95
- mediaId: 'mediaId'
96
- }],
97
- clientMediaPreferences: {preferTranscoding: true}
186
+ mediaId: 'mediaId',
187
+ },
188
+ ],
189
+ clientMediaPreferences: {
190
+ joinCookie: {
191
+ anycastEntryPoint: 'aws-eu-west-1',
192
+ },
193
+ preferTranscoding: true,
98
194
  },
99
- });
195
+ },
196
+ });
100
197
 
101
- assert.calledOnceWithExactly(roapRequest.attachRechabilityData, {
102
- roapMessage: {seq: 1},
103
- audioMuted: true,
104
- videoMuted: true
105
- })
198
+ assert.calledOnceWithExactly(roapRequest.attachReachabilityData, {
199
+ roapMessage: {
200
+ seq: 1,
201
+ },
202
+ audioMuted: true,
203
+ videoMuted: true,
204
+ });
106
205
 
107
- assert.deepEqual(result, {
108
- locus: {
109
- roapSeq: 1
110
- }
111
- });
206
+ assert.deepEqual(result, {
207
+ locus: {
208
+ fullState: {
209
+ lastActive: 'lastActive',
210
+ },
211
+ id: '',
212
+ roapSeq: 1,
213
+ url: 'url/path',
214
+ }
112
215
  });
113
- })
216
+ });
114
217
  });
@@ -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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