@webex/plugin-meetings 3.0.0-beta.111 → 3.0.0-beta.113
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.
- package/README.md +45 -1
- package/dist/breakouts/breakout.js +1 -1
- package/dist/breakouts/index.js +1 -1
- package/dist/media/index.js +0 -21
- package/dist/media/index.js.map +1 -1
- package/dist/meeting/index.js +19 -0
- package/dist/meeting/index.js.map +1 -1
- package/dist/meeting/locusMediaRequest.js +288 -0
- package/dist/meeting/locusMediaRequest.js.map +1 -0
- package/dist/meeting/muteState.js +49 -34
- package/dist/meeting/muteState.js.map +1 -1
- package/dist/meeting/request.js +12 -47
- package/dist/meeting/request.js.map +1 -1
- package/dist/meeting/util.js +20 -19
- package/dist/meeting/util.js.map +1 -1
- package/dist/roap/index.js +4 -19
- package/dist/roap/index.js.map +1 -1
- package/dist/roap/request.js +23 -39
- package/dist/roap/request.js.map +1 -1
- package/dist/roap/turnDiscovery.js +2 -10
- package/dist/roap/turnDiscovery.js.map +1 -1
- package/dist/types/meeting/index.d.ts +3 -0
- package/dist/types/meeting/locusMediaRequest.d.ts +68 -0
- package/dist/types/meeting/muteState.d.ts +3 -2
- package/dist/types/meeting/request.d.ts +4 -18
- package/dist/types/roap/request.d.ts +6 -8
- package/dist/types/roap/turnDiscovery.d.ts +4 -1
- package/package.json +19 -19
- package/src/media/index.ts +0 -23
- package/src/meeting/index.ts +22 -0
- package/src/meeting/locusMediaRequest.ts +303 -0
- package/src/meeting/muteState.ts +24 -9
- package/src/meeting/request.ts +15 -51
- package/src/meeting/util.ts +17 -13
- package/src/roap/index.ts +4 -16
- package/src/roap/request.ts +22 -42
- package/src/roap/turnDiscovery.ts +2 -8
- package/test/unit/spec/meeting/locusMediaRequest.ts +414 -0
- package/test/unit/spec/meeting/muteState.js +97 -71
- package/test/unit/spec/meeting/request.js +19 -0
- package/test/unit/spec/meeting/utils.js +31 -37
- package/test/unit/spec/roap/index.ts +2 -37
- package/test/unit/spec/roap/request.ts +27 -57
- package/test/unit/spec/roap/turnDiscovery.ts +3 -5
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Reflect$construct = require("@babel/runtime-corejs2/core-js/reflect/construct");
|
|
4
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
6
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.LocusMediaRequest = void 0;
|
|
10
|
+
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
11
|
+
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
12
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/assertThisInitialized"));
|
|
13
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inherits"));
|
|
14
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/possibleConstructorReturn"));
|
|
15
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
|
|
16
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
|
|
17
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
|
|
18
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
19
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
20
|
+
var _defer2 = _interopRequireDefault(require("lodash/defer"));
|
|
21
|
+
var _common = require("@webex/common");
|
|
22
|
+
var _webexCore = require("@webex/webex-core");
|
|
23
|
+
var _constants = require("../constants");
|
|
24
|
+
var _loggerProxy = _interopRequireDefault(require("../common/logs/logger-proxy"));
|
|
25
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
26
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
27
|
+
/** Class representing a single /media request being sent to Locus */
|
|
28
|
+
var InternalRequestInfo = /*#__PURE__*/function () {
|
|
29
|
+
/** Constructor */
|
|
30
|
+
function InternalRequestInfo(request, pendingPromise, sendRequestFn) {
|
|
31
|
+
(0, _classCallCheck2.default)(this, InternalRequestInfo);
|
|
32
|
+
(0, _defineProperty2.default)(this, "request", void 0);
|
|
33
|
+
(0, _defineProperty2.default)(this, "pendingPromises", void 0);
|
|
34
|
+
(0, _defineProperty2.default)(this, "sendRequestFn", void 0);
|
|
35
|
+
this.request = request;
|
|
36
|
+
this.pendingPromises = [pendingPromise];
|
|
37
|
+
this.sendRequestFn = sendRequestFn;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns the list of pending promises associated with this request
|
|
42
|
+
*/
|
|
43
|
+
(0, _createClass2.default)(InternalRequestInfo, [{
|
|
44
|
+
key: "getPendingPromises",
|
|
45
|
+
value: function getPendingPromises() {
|
|
46
|
+
return this.pendingPromises;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Adds promises to the list of pending promises associated with this request
|
|
51
|
+
*/
|
|
52
|
+
}, {
|
|
53
|
+
key: "addPendingPromises",
|
|
54
|
+
value: function addPendingPromises(pendingPromises) {
|
|
55
|
+
var _this$pendingPromises;
|
|
56
|
+
(_this$pendingPromises = this.pendingPromises).push.apply(_this$pendingPromises, (0, _toConsumableArray2.default)(pendingPromises));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Executes the request. Returned promise is resolved once the request
|
|
61
|
+
* is completed (no matter if it succeeded or failed).
|
|
62
|
+
*/
|
|
63
|
+
}, {
|
|
64
|
+
key: "execute",
|
|
65
|
+
value: function execute() {
|
|
66
|
+
var _this = this;
|
|
67
|
+
return this.sendRequestFn(this.request).then(function (result) {
|
|
68
|
+
// resolve all the pending promises associated with this request
|
|
69
|
+
_this.pendingPromises.forEach(function (d) {
|
|
70
|
+
return d.resolve(result);
|
|
71
|
+
});
|
|
72
|
+
}).catch(function (e) {
|
|
73
|
+
// reject all the pending promises associated with this request
|
|
74
|
+
_this.pendingPromises.forEach(function (d) {
|
|
75
|
+
return d.reject(e);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}]);
|
|
80
|
+
return InternalRequestInfo;
|
|
81
|
+
}();
|
|
82
|
+
/**
|
|
83
|
+
* Returns true if the request is triggering confluence creation in the server
|
|
84
|
+
*/
|
|
85
|
+
function isRequestAffectingConfluenceState(request) {
|
|
86
|
+
return request.type === 'RoapMessage' && request.roapMessage.messageType === _constants.ROAP.ROAP_TYPES.OFFER;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* This class manages all /media API requests to Locus. Every call to that
|
|
91
|
+
* Locus API has to go through this class.
|
|
92
|
+
*/
|
|
93
|
+
var LocusMediaRequest = /*#__PURE__*/function (_WebexPlugin) {
|
|
94
|
+
(0, _inherits2.default)(LocusMediaRequest, _WebexPlugin);
|
|
95
|
+
var _super = _createSuper(LocusMediaRequest);
|
|
96
|
+
/**
|
|
97
|
+
* Constructor
|
|
98
|
+
*/
|
|
99
|
+
function LocusMediaRequest(config, options) {
|
|
100
|
+
var _this2;
|
|
101
|
+
(0, _classCallCheck2.default)(this, LocusMediaRequest);
|
|
102
|
+
_this2 = _super.call(this, {}, options);
|
|
103
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "config", void 0);
|
|
104
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "latestAudioMuted", void 0);
|
|
105
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "latestVideoMuted", void 0);
|
|
106
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "isRequestInProgress", void 0);
|
|
107
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "queuedRequests", void 0);
|
|
108
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this2), "confluenceState", void 0);
|
|
109
|
+
_this2.isRequestInProgress = false;
|
|
110
|
+
_this2.queuedRequests = [];
|
|
111
|
+
_this2.config = config;
|
|
112
|
+
_this2.confluenceState = 'not created';
|
|
113
|
+
return _this2;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Add a request to the internal queue.
|
|
118
|
+
*/
|
|
119
|
+
(0, _createClass2.default)(LocusMediaRequest, [{
|
|
120
|
+
key: "addToQueue",
|
|
121
|
+
value: function addToQueue(info) {
|
|
122
|
+
if (info.request.type === 'LocalMute' && this.queuedRequests.length > 0) {
|
|
123
|
+
// We don't need additional local mute requests in the queue.
|
|
124
|
+
// We only need at most 1 local mute or 1 roap request, because
|
|
125
|
+
// roap requests also include mute state, so whatever request
|
|
126
|
+
// is sent out, it will send the latest local mute state.
|
|
127
|
+
// We only need to store the pendingPromises so that they get resolved
|
|
128
|
+
// when the roap request is sent out.
|
|
129
|
+
this.queuedRequests[0].addPendingPromises(info.getPendingPromises());
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (info.request.type === 'RoapMessage' && this.queuedRequests.length > 0) {
|
|
133
|
+
// remove any LocalMute requests from the queue, because this Roap message
|
|
134
|
+
// will also update the mute status in Locus, so they are redundant
|
|
135
|
+
this.queuedRequests = this.queuedRequests.filter(function (r) {
|
|
136
|
+
if (r.request.type === 'LocalMute') {
|
|
137
|
+
// we need to keep the pending promises from the local mute request
|
|
138
|
+
// that we're removing from the queue
|
|
139
|
+
info.addPendingPromises(r.getPendingPromises());
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
return true;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
this.queuedRequests.push(info);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Takes the next request from the queue and executes it. Once that
|
|
150
|
+
* request is completed, the next one will be taken from the queue
|
|
151
|
+
* and executed and this is repeated until the queue is empty.
|
|
152
|
+
*/
|
|
153
|
+
}, {
|
|
154
|
+
key: "executeNextQueuedRequest",
|
|
155
|
+
value: function executeNextQueuedRequest() {
|
|
156
|
+
var _this3 = this;
|
|
157
|
+
if (this.isRequestInProgress) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
var nextRequest = this.queuedRequests.shift();
|
|
161
|
+
if (nextRequest) {
|
|
162
|
+
this.isRequestInProgress = true;
|
|
163
|
+
nextRequest.execute().then(function () {
|
|
164
|
+
_this3.isRequestInProgress = false;
|
|
165
|
+
_this3.executeNextQueuedRequest();
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Returns latest requested audio and video mute values. If they have never been
|
|
172
|
+
* requested, we assume audio/video to be muted.
|
|
173
|
+
*/
|
|
174
|
+
}, {
|
|
175
|
+
key: "getLatestMuteState",
|
|
176
|
+
value: function getLatestMuteState() {
|
|
177
|
+
var audioMuted = this.latestAudioMuted !== undefined ? this.latestAudioMuted : true;
|
|
178
|
+
var videoMuted = this.latestVideoMuted !== undefined ? this.latestVideoMuted : true;
|
|
179
|
+
return {
|
|
180
|
+
audioMuted: audioMuted,
|
|
181
|
+
videoMuted: videoMuted
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Prepares the uri and body for the media request to be sent to Locus
|
|
187
|
+
*/
|
|
188
|
+
}, {
|
|
189
|
+
key: "sendHttpRequest",
|
|
190
|
+
value: function sendHttpRequest(request) {
|
|
191
|
+
var _this4 = this;
|
|
192
|
+
var uri = "".concat(request.selfUrl, "/").concat(_constants.MEDIA);
|
|
193
|
+
var _this$getLatestMuteSt = this.getLatestMuteState(),
|
|
194
|
+
audioMuted = _this$getLatestMuteSt.audioMuted,
|
|
195
|
+
videoMuted = _this$getLatestMuteSt.videoMuted;
|
|
196
|
+
|
|
197
|
+
// first setup things common to all requests
|
|
198
|
+
var body = {
|
|
199
|
+
device: this.config.device,
|
|
200
|
+
correlationId: this.config.correlationId,
|
|
201
|
+
clientMediaPreferences: {
|
|
202
|
+
preferTranscoding: this.config.preferTranscoding
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
var localMedias = {
|
|
206
|
+
audioMuted: audioMuted,
|
|
207
|
+
videoMuted: videoMuted
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
// now add things specific to request type
|
|
211
|
+
switch (request.type) {
|
|
212
|
+
case 'LocalMute':
|
|
213
|
+
body.respOnlySdp = true;
|
|
214
|
+
body.usingResource = null;
|
|
215
|
+
break;
|
|
216
|
+
case 'RoapMessage':
|
|
217
|
+
localMedias.roapMessage = request.roapMessage;
|
|
218
|
+
localMedias.reachability = request.reachability;
|
|
219
|
+
body.clientMediaPreferences.joinCookie = request.joinCookie;
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
body.localMedias = [{
|
|
223
|
+
localSdp: (0, _stringify.default)(localMedias),
|
|
224
|
+
// this part must be JSON stringified, Locus requires this
|
|
225
|
+
mediaId: request.mediaId
|
|
226
|
+
}];
|
|
227
|
+
_loggerProxy.default.logger.info("Meeting:LocusMediaRequest#sendHttpRequest --> ".concat(request.type, " audioMuted=").concat(audioMuted, " videoMuted=").concat(videoMuted));
|
|
228
|
+
if (isRequestAffectingConfluenceState(request) && this.confluenceState === 'not created') {
|
|
229
|
+
this.confluenceState = 'creation in progress';
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// @ts-ignore
|
|
233
|
+
return this.request({
|
|
234
|
+
method: _constants.HTTP_VERBS.PUT,
|
|
235
|
+
uri: uri,
|
|
236
|
+
body: body
|
|
237
|
+
}).then(function (result) {
|
|
238
|
+
if (isRequestAffectingConfluenceState(request)) {
|
|
239
|
+
_this4.confluenceState = 'created';
|
|
240
|
+
}
|
|
241
|
+
return result;
|
|
242
|
+
}).catch(function (e) {
|
|
243
|
+
if (isRequestAffectingConfluenceState(request) && _this4.confluenceState === 'creation in progress') {
|
|
244
|
+
_this4.confluenceState = 'not created';
|
|
245
|
+
}
|
|
246
|
+
throw e;
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Sends a media request to Locus
|
|
252
|
+
*/
|
|
253
|
+
}, {
|
|
254
|
+
key: "send",
|
|
255
|
+
value: function send(request) {
|
|
256
|
+
var _this5 = this;
|
|
257
|
+
if (request.type === 'LocalMute') {
|
|
258
|
+
var _request$muteOptions = request.muteOptions,
|
|
259
|
+
audioMuted = _request$muteOptions.audioMuted,
|
|
260
|
+
videoMuted = _request$muteOptions.videoMuted;
|
|
261
|
+
if (audioMuted !== undefined) {
|
|
262
|
+
this.latestAudioMuted = audioMuted;
|
|
263
|
+
}
|
|
264
|
+
if (videoMuted !== undefined) {
|
|
265
|
+
this.latestVideoMuted = videoMuted;
|
|
266
|
+
}
|
|
267
|
+
if (this.confluenceState === 'not created') {
|
|
268
|
+
// if there is no confluence, there is no point sending out local mute request
|
|
269
|
+
// as it will fail so we just store the latest audio/video muted values
|
|
270
|
+
// and resolve immediately, so that higher layer (MuteState class) doesn't get blocked
|
|
271
|
+
// and can call us again if user mutes/unmutes again before confluence is created
|
|
272
|
+
_loggerProxy.default.logger.info('Meeting:LocusMediaRequest#send --> called with LocalMute request before confluence creation');
|
|
273
|
+
return _promise.default.resolve({});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
var pendingPromise = new _common.Defer();
|
|
277
|
+
var newRequest = new InternalRequestInfo(request, pendingPromise, this.sendHttpRequest.bind(this));
|
|
278
|
+
this.addToQueue(newRequest);
|
|
279
|
+
(0, _defer2.default)(function () {
|
|
280
|
+
return _this5.executeNextQueuedRequest();
|
|
281
|
+
});
|
|
282
|
+
return pendingPromise.promise;
|
|
283
|
+
}
|
|
284
|
+
}]);
|
|
285
|
+
return LocusMediaRequest;
|
|
286
|
+
}(_webexCore.WebexPlugin);
|
|
287
|
+
exports.LocusMediaRequest = LocusMediaRequest;
|
|
288
|
+
//# sourceMappingURL=locusMediaRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["InternalRequestInfo","request","pendingPromise","sendRequestFn","pendingPromises","push","then","result","forEach","d","resolve","catch","e","reject","isRequestAffectingConfluenceState","type","roapMessage","messageType","ROAP","ROAP_TYPES","OFFER","LocusMediaRequest","config","options","isRequestInProgress","queuedRequests","confluenceState","info","length","addPendingPromises","getPendingPromises","filter","r","nextRequest","shift","execute","executeNextQueuedRequest","audioMuted","latestAudioMuted","undefined","videoMuted","latestVideoMuted","uri","selfUrl","MEDIA","getLatestMuteState","body","device","correlationId","clientMediaPreferences","preferTranscoding","localMedias","respOnlySdp","usingResource","reachability","joinCookie","localSdp","mediaId","LoggerProxy","logger","method","HTTP_VERBS","PUT","muteOptions","Defer","newRequest","sendHttpRequest","bind","addToQueue","promise","WebexPlugin"],"sources":["locusMediaRequest.ts"],"sourcesContent":["/* eslint-disable valid-jsdoc */\nimport {defer} from 'lodash';\nimport {Defer} from '@webex/common';\nimport {WebexPlugin} from '@webex/webex-core';\nimport {MEDIA, HTTP_VERBS, ROAP} from '../constants';\nimport LoggerProxy from '../common/logs/logger-proxy';\n\nexport type MediaRequestType = 'RoapMessage' | 'LocalMute';\nexport type RequestResult = any;\n\nexport type RoapRequest = {\n type: 'RoapMessage';\n selfUrl: string;\n mediaId: string;\n roapMessage: any;\n reachability: any;\n joinCookie: any; // any, because this is opaque to the client, we pass whatever object we got from one backend component (Orpheus) to the other (Locus)\n};\n\nexport type LocalMuteRequest = {\n type: 'LocalMute';\n selfUrl: string;\n mediaId: string;\n muteOptions: {\n audioMuted?: boolean;\n videoMuted?: boolean;\n };\n};\n\nexport type Request = RoapRequest | LocalMuteRequest;\n\n/** Class representing a single /media request being sent to Locus */\nclass InternalRequestInfo {\n public readonly request: Request;\n private pendingPromises: Defer[];\n private sendRequestFn: (request: Request) => Promise<RequestResult>;\n\n /** Constructor */\n constructor(\n request: Request,\n pendingPromise: Defer,\n sendRequestFn: (request: Request) => Promise<RequestResult>\n ) {\n this.request = request;\n this.pendingPromises = [pendingPromise];\n this.sendRequestFn = sendRequestFn;\n }\n\n /**\n * Returns the list of pending promises associated with this request\n */\n public getPendingPromises() {\n return this.pendingPromises;\n }\n\n /**\n * Adds promises to the list of pending promises associated with this request\n */\n public addPendingPromises(pendingPromises: Defer[]) {\n this.pendingPromises.push(...pendingPromises);\n }\n\n /**\n * Executes the request. Returned promise is resolved once the request\n * is completed (no matter if it succeeded or failed).\n */\n public execute(): Promise<void> {\n return this.sendRequestFn(this.request)\n .then((result) => {\n // resolve all the pending promises associated with this request\n this.pendingPromises.forEach((d) => d.resolve(result));\n })\n .catch((e) => {\n // reject all the pending promises associated with this request\n this.pendingPromises.forEach((d) => d.reject(e));\n });\n }\n}\n\nexport type Config = {\n device: {\n url: string;\n deviceType: string;\n };\n correlationId: string;\n preferTranscoding: boolean;\n};\n\n/**\n * Returns true if the request is triggering confluence creation in the server\n */\nfunction isRequestAffectingConfluenceState(request: Request): boolean {\n return (\n request.type === 'RoapMessage' && request.roapMessage.messageType === ROAP.ROAP_TYPES.OFFER\n );\n}\n\n/**\n * This class manages all /media API requests to Locus. Every call to that\n * Locus API has to go through this class.\n */\nexport class LocusMediaRequest extends WebexPlugin {\n private config: Config;\n private latestAudioMuted?: boolean;\n private latestVideoMuted?: boolean;\n private isRequestInProgress: boolean;\n private queuedRequests: InternalRequestInfo[];\n private confluenceState: 'not created' | 'creation in progress' | 'created';\n /**\n * Constructor\n */\n constructor(config: Config, options: any) {\n super({}, options);\n this.isRequestInProgress = false;\n this.queuedRequests = [];\n this.config = config;\n this.confluenceState = 'not created';\n }\n\n /**\n * Add a request to the internal queue.\n */\n private addToQueue(info: InternalRequestInfo) {\n if (info.request.type === 'LocalMute' && this.queuedRequests.length > 0) {\n // We don't need additional local mute requests in the queue.\n // We only need at most 1 local mute or 1 roap request, because\n // roap requests also include mute state, so whatever request\n // is sent out, it will send the latest local mute state.\n // We only need to store the pendingPromises so that they get resolved\n // when the roap request is sent out.\n this.queuedRequests[0].addPendingPromises(info.getPendingPromises());\n\n return;\n }\n\n if (info.request.type === 'RoapMessage' && this.queuedRequests.length > 0) {\n // remove any LocalMute requests from the queue, because this Roap message\n // will also update the mute status in Locus, so they are redundant\n this.queuedRequests = this.queuedRequests.filter((r) => {\n if (r.request.type === 'LocalMute') {\n // we need to keep the pending promises from the local mute request\n // that we're removing from the queue\n info.addPendingPromises(r.getPendingPromises());\n\n return false;\n }\n\n return true;\n });\n }\n\n this.queuedRequests.push(info);\n }\n\n /**\n * Takes the next request from the queue and executes it. Once that\n * request is completed, the next one will be taken from the queue\n * and executed and this is repeated until the queue is empty.\n */\n private executeNextQueuedRequest(): void {\n if (this.isRequestInProgress) {\n return;\n }\n\n const nextRequest = this.queuedRequests.shift();\n\n if (nextRequest) {\n this.isRequestInProgress = true;\n nextRequest.execute().then(() => {\n this.isRequestInProgress = false;\n this.executeNextQueuedRequest();\n });\n }\n }\n\n /**\n * Returns latest requested audio and video mute values. If they have never been\n * requested, we assume audio/video to be muted.\n */\n private getLatestMuteState() {\n const audioMuted = this.latestAudioMuted !== undefined ? this.latestAudioMuted : true;\n const videoMuted = this.latestVideoMuted !== undefined ? this.latestVideoMuted : true;\n\n return {audioMuted, videoMuted};\n }\n\n /**\n * Prepares the uri and body for the media request to be sent to Locus\n */\n private sendHttpRequest(request: Request) {\n const uri = `${request.selfUrl}/${MEDIA}`;\n\n const {audioMuted, videoMuted} = this.getLatestMuteState();\n\n // first setup things common to all requests\n const body: any = {\n device: this.config.device,\n correlationId: this.config.correlationId,\n clientMediaPreferences: {\n preferTranscoding: this.config.preferTranscoding,\n },\n };\n\n const localMedias: any = {\n audioMuted,\n videoMuted,\n };\n\n // now add things specific to request type\n switch (request.type) {\n case 'LocalMute':\n body.respOnlySdp = true;\n body.usingResource = null;\n break;\n\n case 'RoapMessage':\n localMedias.roapMessage = request.roapMessage;\n localMedias.reachability = request.reachability;\n body.clientMediaPreferences.joinCookie = request.joinCookie;\n break;\n }\n\n body.localMedias = [\n {\n localSdp: JSON.stringify(localMedias), // this part must be JSON stringified, Locus requires this\n mediaId: request.mediaId,\n },\n ];\n\n LoggerProxy.logger.info(\n `Meeting:LocusMediaRequest#sendHttpRequest --> ${request.type} audioMuted=${audioMuted} videoMuted=${videoMuted}`\n );\n\n if (isRequestAffectingConfluenceState(request) && this.confluenceState === 'not created') {\n this.confluenceState = 'creation in progress';\n }\n\n // @ts-ignore\n return this.request({\n method: HTTP_VERBS.PUT,\n uri,\n body,\n })\n .then((result) => {\n if (isRequestAffectingConfluenceState(request)) {\n this.confluenceState = 'created';\n }\n\n return result;\n })\n .catch((e) => {\n if (\n isRequestAffectingConfluenceState(request) &&\n this.confluenceState === 'creation in progress'\n ) {\n this.confluenceState = 'not created';\n }\n throw e;\n });\n }\n\n /**\n * Sends a media request to Locus\n */\n public send(request: Request): Promise<RequestResult> {\n if (request.type === 'LocalMute') {\n const {audioMuted, videoMuted} = request.muteOptions;\n\n if (audioMuted !== undefined) {\n this.latestAudioMuted = audioMuted;\n }\n if (videoMuted !== undefined) {\n this.latestVideoMuted = videoMuted;\n }\n\n if (this.confluenceState === 'not created') {\n // if there is no confluence, there is no point sending out local mute request\n // as it will fail so we just store the latest audio/video muted values\n // and resolve immediately, so that higher layer (MuteState class) doesn't get blocked\n // and can call us again if user mutes/unmutes again before confluence is created\n LoggerProxy.logger.info(\n 'Meeting:LocusMediaRequest#send --> called with LocalMute request before confluence creation'\n );\n\n return Promise.resolve({});\n }\n }\n\n const pendingPromise = new Defer();\n\n const newRequest = new InternalRequestInfo(\n request,\n pendingPromise,\n this.sendHttpRequest.bind(this)\n );\n\n this.addToQueue(newRequest);\n\n defer(() => this.executeNextQueuedRequest());\n\n return pendingPromise.promise;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA;AACA;AACA;AACA;AAAsD;AAAA;AA0BtD;AAAA,IACMA,mBAAmB;EAKvB;EACA,6BACEC,OAAgB,EAChBC,cAAqB,EACrBC,aAA2D,EAC3D;IAAA;IAAA;IAAA;IAAA;IACA,IAAI,CAACF,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACG,eAAe,GAAG,CAACF,cAAc,CAAC;IACvC,IAAI,CAACC,aAAa,GAAGA,aAAa;EACpC;;EAEA;AACF;AACA;EAFE;IAAA;IAAA,OAGA,8BAA4B;MAC1B,OAAO,IAAI,CAACC,eAAe;IAC7B;;IAEA;AACF;AACA;EAFE;IAAA;IAAA,OAGA,4BAA0BA,eAAwB,EAAE;MAAA;MAClD,6BAAI,CAACA,eAAe,EAACC,IAAI,+DAAID,eAAe,EAAC;IAC/C;;IAEA;AACF;AACA;AACA;EAHE;IAAA;IAAA,OAIA,mBAAgC;MAAA;MAC9B,OAAO,IAAI,CAACD,aAAa,CAAC,IAAI,CAACF,OAAO,CAAC,CACpCK,IAAI,CAAC,UAACC,MAAM,EAAK;QAChB;QACA,KAAI,CAACH,eAAe,CAACI,OAAO,CAAC,UAACC,CAAC;UAAA,OAAKA,CAAC,CAACC,OAAO,CAACH,MAAM,CAAC;QAAA,EAAC;MACxD,CAAC,CAAC,CACDI,KAAK,CAAC,UAAC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 -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequ
|
|
|
5
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.createMuteState = void 0;
|
|
8
|
+
exports.createMuteState = exports.MuteState = void 0;
|
|
9
9
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
10
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
|
|
11
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
@@ -39,6 +39,8 @@ var createMuteState = function createMuteState(type, meeting, mediaDirection, sd
|
|
|
39
39
|
the last requested state by the client.
|
|
40
40
|
|
|
41
41
|
More info about Locus muting API: https://sqbu-github.cisco.com/pages/WebExSquared/locus/guides/mute.html#
|
|
42
|
+
|
|
43
|
+
This class is exported only for unit tests. It should never be instantiated directly with new MuteState(), instead createMuteState() should be called
|
|
42
44
|
*/
|
|
43
45
|
exports.createMuteState = createMuteState;
|
|
44
46
|
var MuteState = /*#__PURE__*/function () {
|
|
@@ -71,7 +73,7 @@ var MuteState = /*#__PURE__*/function () {
|
|
|
71
73
|
localMute: false
|
|
72
74
|
},
|
|
73
75
|
server: {
|
|
74
|
-
localMute:
|
|
76
|
+
localMute: true,
|
|
75
77
|
// because remoteVideoMuted and unmuteVideoAllowed are updated seperately, they might be undefined
|
|
76
78
|
remoteMute: type === _constants.AUDIO ? meeting.remoteMuted : (_meeting$remoteVideoM = meeting.remoteVideoMuted) !== null && _meeting$remoteVideoM !== void 0 ? _meeting$remoteVideoM : false,
|
|
77
79
|
unmuteAllowed: type === _constants.AUDIO ? meeting.unmuteAllowed : (_meeting$unmuteVideoA = meeting.unmuteVideoAllowed) !== null && _meeting$unmuteVideoA !== void 0 ? _meeting$unmuteVideoA : true
|
|
@@ -92,6 +94,7 @@ var MuteState = /*#__PURE__*/function () {
|
|
|
92
94
|
(0, _createClass2.default)(MuteState, [{
|
|
93
95
|
key: "init",
|
|
94
96
|
value: function init(meeting) {
|
|
97
|
+
var _this = this;
|
|
95
98
|
if (!this.sdkOwnsLocalTrack) {
|
|
96
99
|
var _meeting$mediaPropert, _meeting$mediaPropert2;
|
|
97
100
|
this.applyUnmuteAllowedToTrack(meeting);
|
|
@@ -101,11 +104,22 @@ var MuteState = /*#__PURE__*/function () {
|
|
|
101
104
|
this.muteLocalTrack(meeting, this.state.server.remoteMute, 'remotelyMuted');
|
|
102
105
|
}
|
|
103
106
|
var initialMute = this.type === _constants.AUDIO ? (_meeting$mediaPropert = meeting.mediaProperties.audioTrack) === null || _meeting$mediaPropert === void 0 ? void 0 : _meeting$mediaPropert.muted : (_meeting$mediaPropert2 = meeting.mediaProperties.videoTrack) === null || _meeting$mediaPropert2 === void 0 ? void 0 : _meeting$mediaPropert2.muted;
|
|
104
|
-
_loggerProxy.default.logger.info("Meeting:muteState#
|
|
107
|
+
_loggerProxy.default.logger.info("Meeting:muteState#init --> ".concat(this.type, ": local track initial mute state: ").concat(initialMute));
|
|
105
108
|
if (initialMute !== undefined) {
|
|
106
109
|
this.state.client.localMute = initialMute;
|
|
107
110
|
this.applyClientStateToServer(meeting);
|
|
108
111
|
}
|
|
112
|
+
} else {
|
|
113
|
+
// in the mode where sdkOwnsLocalTrack is false (transcoded meetings),
|
|
114
|
+
// SDK API currently doesn't allow to start with audio/video muted,
|
|
115
|
+
// so we need to apply the initial local mute state (false) to server
|
|
116
|
+
this.state.syncToServerInProgress = true;
|
|
117
|
+
this.sendLocalMuteRequestToServer(meeting).then(function () {
|
|
118
|
+
_this.state.syncToServerInProgress = false;
|
|
119
|
+
}).catch(function () {
|
|
120
|
+
_this.state.syncToServerInProgress = false;
|
|
121
|
+
// not much we can do here...
|
|
122
|
+
});
|
|
109
123
|
}
|
|
110
124
|
}
|
|
111
125
|
|
|
@@ -163,7 +177,7 @@ var MuteState = /*#__PURE__*/function () {
|
|
|
163
177
|
}, {
|
|
164
178
|
key: "handleClientRequest",
|
|
165
179
|
value: function handleClientRequest(meeting, mute) {
|
|
166
|
-
var
|
|
180
|
+
var _this2 = this;
|
|
167
181
|
// todo: this whole method will be removed in SPARK-399695
|
|
168
182
|
_loggerProxy.default.logger.info("Meeting:muteState#handleClientRequest --> ".concat(this.type, ": user requesting new mute state: ").concat(mute));
|
|
169
183
|
if (!mute && !this.state.server.unmuteAllowed) {
|
|
@@ -175,13 +189,13 @@ var MuteState = /*#__PURE__*/function () {
|
|
|
175
189
|
this.state.client.localMute = mute;
|
|
176
190
|
this.applyClientStateLocally(meeting);
|
|
177
191
|
return new _promise.default(function (resolve, reject) {
|
|
178
|
-
if (
|
|
192
|
+
if (_this2.pendingPromiseResolve) {
|
|
179
193
|
// resolve the last promise we returned to the client as the client has issued a new request that has superseded the previous one
|
|
180
|
-
|
|
194
|
+
_this2.pendingPromiseResolve();
|
|
181
195
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
196
|
+
_this2.pendingPromiseResolve = resolve;
|
|
197
|
+
_this2.pendingPromiseReject = reject;
|
|
198
|
+
_this2.applyClientStateToServer(meeting);
|
|
185
199
|
});
|
|
186
200
|
}
|
|
187
201
|
|
|
@@ -243,7 +257,7 @@ var MuteState = /*#__PURE__*/function () {
|
|
|
243
257
|
}, {
|
|
244
258
|
key: "applyClientStateToServer",
|
|
245
259
|
value: function applyClientStateToServer(meeting) {
|
|
246
|
-
var
|
|
260
|
+
var _this3 = this;
|
|
247
261
|
if (this.state.syncToServerInProgress) {
|
|
248
262
|
_loggerProxy.default.logger.info("Meeting:muteState#applyClientStateToServer --> ".concat(this.type, ": request to server in progress, we need to wait for it to complete"));
|
|
249
263
|
return;
|
|
@@ -268,22 +282,22 @@ var MuteState = /*#__PURE__*/function () {
|
|
|
268
282
|
localMuteSyncPromise.then(function () {
|
|
269
283
|
return (
|
|
270
284
|
// then follow it up with remote mute sync
|
|
271
|
-
remoteMuteRequiresSync ?
|
|
285
|
+
remoteMuteRequiresSync ? _this3.sendRemoteMuteRequestToServer(meeting) : _promise.default.resolve()
|
|
272
286
|
);
|
|
273
287
|
}).then(function () {
|
|
274
|
-
|
|
275
|
-
_loggerProxy.default.logger.info("Meeting:muteState#applyClientStateToServer --> ".concat(
|
|
288
|
+
_this3.state.syncToServerInProgress = false;
|
|
289
|
+
_loggerProxy.default.logger.info("Meeting:muteState#applyClientStateToServer --> ".concat(_this3.type, ": sync with server completed"));
|
|
276
290
|
|
|
277
291
|
// need to check if a new sync is required, because this.state.client may have changed while we were doing the current sync
|
|
278
|
-
|
|
292
|
+
_this3.applyClientStateToServer(meeting);
|
|
279
293
|
}).catch(function (e) {
|
|
280
|
-
|
|
281
|
-
if (
|
|
282
|
-
|
|
294
|
+
_this3.state.syncToServerInProgress = false;
|
|
295
|
+
if (_this3.pendingPromiseReject) {
|
|
296
|
+
_this3.pendingPromiseReject(e);
|
|
283
297
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
298
|
+
_this3.pendingPromiseResolve = null;
|
|
299
|
+
_this3.pendingPromiseReject = null;
|
|
300
|
+
_this3.applyServerMuteToLocalTrack(meeting, 'clientRequestFailed');
|
|
287
301
|
});
|
|
288
302
|
}
|
|
289
303
|
|
|
@@ -298,19 +312,19 @@ var MuteState = /*#__PURE__*/function () {
|
|
|
298
312
|
}, {
|
|
299
313
|
key: "sendLocalMuteRequestToServer",
|
|
300
314
|
value: function sendLocalMuteRequestToServer(meeting) {
|
|
301
|
-
var
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
var audioMuted = this.type === _constants.AUDIO ? this.state.client.localMute : (_meeting$audio = meeting.audio) === null || _meeting$audio === void 0 ? void 0 : _meeting$audio.state.client.localMute;
|
|
305
|
-
var videoMuted = this.type === _constants.VIDEO ? this.state.client.localMute : (_meeting$video = meeting.video) === null || _meeting$video === void 0 ? void 0 : _meeting$video.state.client.localMute;
|
|
315
|
+
var _this4 = this;
|
|
316
|
+
var audioMuted = this.type === _constants.AUDIO ? this.state.client.localMute : undefined;
|
|
317
|
+
var videoMuted = this.type === _constants.VIDEO ? this.state.client.localMute : undefined;
|
|
306
318
|
_loggerProxy.default.logger.info("Meeting:muteState#sendLocalMuteRequestToServer --> ".concat(this.type, ": sending local mute (audio=").concat(audioMuted, ", video=").concat(videoMuted, ") to server"));
|
|
307
|
-
return _util.default.remoteUpdateAudioVideo(audioMuted, videoMuted
|
|
308
|
-
_loggerProxy.default.logger.info("Meeting:muteState#sendLocalMuteRequestToServer --> ".concat(
|
|
309
|
-
|
|
310
|
-
|
|
319
|
+
return _util.default.remoteUpdateAudioVideo(meeting, audioMuted, videoMuted).then(function (locus) {
|
|
320
|
+
_loggerProxy.default.logger.info("Meeting:muteState#sendLocalMuteRequestToServer --> ".concat(_this4.type, ": local mute (audio=").concat(audioMuted, ", video=").concat(videoMuted, ") applied to server"));
|
|
321
|
+
_this4.state.server.localMute = _this4.type === _constants.AUDIO ? audioMuted : videoMuted;
|
|
322
|
+
if (locus) {
|
|
323
|
+
meeting.locusInfo.onFullLocus(locus);
|
|
324
|
+
}
|
|
311
325
|
return locus;
|
|
312
326
|
}).catch(function (remoteUpdateError) {
|
|
313
|
-
_loggerProxy.default.logger.warn("Meeting:muteState#sendLocalMuteRequestToServer --> ".concat(
|
|
327
|
+
_loggerProxy.default.logger.warn("Meeting:muteState#sendLocalMuteRequestToServer --> ".concat(_this4.type, ": failed to apply local mute (audio=").concat(audioMuted, ", video=").concat(videoMuted, ") to server: ").concat(remoteUpdateError));
|
|
314
328
|
return _promise.default.reject(remoteUpdateError);
|
|
315
329
|
});
|
|
316
330
|
}
|
|
@@ -326,14 +340,14 @@ var MuteState = /*#__PURE__*/function () {
|
|
|
326
340
|
}, {
|
|
327
341
|
key: "sendRemoteMuteRequestToServer",
|
|
328
342
|
value: function sendRemoteMuteRequestToServer(meeting) {
|
|
329
|
-
var
|
|
343
|
+
var _this5 = this;
|
|
330
344
|
var remoteMute = this.state.client.localMute;
|
|
331
345
|
_loggerProxy.default.logger.info("Meeting:muteState#sendRemoteMuteRequestToServer --> ".concat(this.type, ": sending remote mute:").concat(remoteMute, " to server"));
|
|
332
346
|
return meeting.members.muteMember(meeting.members.selfId, remoteMute, this.type === _constants.AUDIO).then(function () {
|
|
333
|
-
_loggerProxy.default.logger.info("Meeting:muteState#sendRemoteMuteRequestToServer --> ".concat(
|
|
334
|
-
|
|
347
|
+
_loggerProxy.default.logger.info("Meeting:muteState#sendRemoteMuteRequestToServer --> ".concat(_this5.type, ": remote mute:").concat(remoteMute, " applied to server"));
|
|
348
|
+
_this5.state.server.remoteMute = remoteMute;
|
|
335
349
|
}).catch(function (remoteUpdateError) {
|
|
336
|
-
_loggerProxy.default.logger.warn("Meeting:muteState#sendRemoteMuteRequestToServer --> ".concat(
|
|
350
|
+
_loggerProxy.default.logger.warn("Meeting:muteState#sendRemoteMuteRequestToServer --> ".concat(_this5.type, ": failed to apply remote mute ").concat(remoteMute, " to server: ").concat(remoteUpdateError));
|
|
337
351
|
return _promise.default.reject(remoteUpdateError);
|
|
338
352
|
});
|
|
339
353
|
}
|
|
@@ -503,4 +517,5 @@ var MuteState = /*#__PURE__*/function () {
|
|
|
503
517
|
}]);
|
|
504
518
|
return MuteState;
|
|
505
519
|
}();
|
|
520
|
+
exports.MuteState = MuteState;
|
|
506
521
|
//# sourceMappingURL=muteState.js.map
|