@webex/plugin-meetings 3.12.0-next.9 → 3.12.0-task-refactor.1
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/dist/annotation/index.js +5 -14
- package/dist/annotation/index.js.map +1 -1
- package/dist/breakouts/breakout.js +1 -1
- package/dist/breakouts/index.js +1 -1
- package/dist/config.js +2 -8
- package/dist/config.js.map +1 -1
- package/dist/constants.js +6 -29
- package/dist/constants.js.map +1 -1
- package/dist/hashTree/hashTreeParser.js +29 -1563
- package/dist/hashTree/hashTreeParser.js.map +1 -1
- package/dist/hashTree/types.js +3 -13
- package/dist/hashTree/types.js.map +1 -1
- package/dist/index.js +2 -11
- package/dist/index.js.map +1 -1
- package/dist/interceptors/index.js +0 -7
- package/dist/interceptors/index.js.map +1 -1
- package/dist/interceptors/locusRouteToken.js +5 -27
- package/dist/interceptors/locusRouteToken.js.map +1 -1
- package/dist/interpretation/index.js +2 -2
- package/dist/interpretation/index.js.map +1 -1
- package/dist/interpretation/siLanguage.js +1 -1
- package/dist/locus-info/controlsUtils.js +3 -7
- package/dist/locus-info/controlsUtils.js.map +1 -1
- package/dist/locus-info/index.js +247 -642
- package/dist/locus-info/index.js.map +1 -1
- package/dist/locus-info/selfUtils.js +0 -1
- package/dist/locus-info/selfUtils.js.map +1 -1
- package/dist/locus-info/types.js.map +1 -1
- package/dist/media/MediaConnectionAwaiter.js +1 -57
- package/dist/media/MediaConnectionAwaiter.js.map +1 -1
- package/dist/media/properties.js +2 -4
- package/dist/media/properties.js.map +1 -1
- package/dist/meeting/in-meeting-actions.js +1 -7
- package/dist/meeting/in-meeting-actions.js.map +1 -1
- package/dist/meeting/index.js +1036 -1481
- package/dist/meeting/index.js.map +1 -1
- package/dist/meeting/request.js +0 -50
- package/dist/meeting/request.js.map +1 -1
- package/dist/meeting/request.type.js.map +1 -1
- package/dist/meeting/util.js +3 -133
- package/dist/meeting/util.js.map +1 -1
- package/dist/meetings/index.js +59 -142
- package/dist/meetings/index.js.map +1 -1
- package/dist/meetings/util.js +7 -11
- package/dist/meetings/util.js.map +1 -1
- package/dist/member/index.js +0 -10
- package/dist/member/index.js.map +1 -1
- package/dist/member/util.js +0 -10
- package/dist/member/util.js.map +1 -1
- package/dist/metrics/constants.js +1 -7
- package/dist/metrics/constants.js.map +1 -1
- package/dist/multistream/mediaRequestManager.js +60 -9
- package/dist/multistream/mediaRequestManager.js.map +1 -1
- package/dist/multistream/remoteMediaManager.js +0 -11
- package/dist/multistream/remoteMediaManager.js.map +1 -1
- package/dist/multistream/sendSlotManager.js +2 -116
- package/dist/multistream/sendSlotManager.js.map +1 -1
- package/dist/reachability/clusterReachability.js +18 -171
- package/dist/reachability/clusterReachability.js.map +1 -1
- package/dist/reachability/index.js +11 -21
- package/dist/reachability/index.js.map +1 -1
- package/dist/reachability/reachabilityPeerConnection.js +1 -1
- package/dist/reachability/reachabilityPeerConnection.js.map +1 -1
- package/dist/reactions/reactions.type.js.map +1 -1
- package/dist/reconnection-manager/index.js +1 -0
- package/dist/reconnection-manager/index.js.map +1 -1
- package/dist/types/common/browser-detection.d.ts +0 -1
- package/dist/types/common/events/events-scope.d.ts +0 -1
- package/dist/types/common/events/events.d.ts +0 -1
- package/dist/types/config.d.ts +0 -5
- package/dist/types/constants.d.ts +1 -24
- package/dist/types/hashTree/hashTreeParser.d.ts +11 -260
- package/dist/types/hashTree/types.d.ts +0 -20
- package/dist/types/index.d.ts +0 -1
- package/dist/types/interceptors/index.d.ts +1 -2
- package/dist/types/interceptors/locusRouteToken.d.ts +0 -2
- package/dist/types/locus-info/index.d.ts +47 -68
- package/dist/types/locus-info/types.d.ts +12 -28
- package/dist/types/media/MediaConnectionAwaiter.d.ts +1 -10
- package/dist/types/media/properties.d.ts +1 -2
- package/dist/types/meeting/in-meeting-actions.d.ts +0 -6
- package/dist/types/meeting/index.d.ts +7 -86
- package/dist/types/meeting/request.d.ts +1 -16
- package/dist/types/meeting/request.type.d.ts +0 -5
- package/dist/types/meeting/util.d.ts +0 -31
- package/dist/types/meeting-info/util.d.ts +0 -1
- package/dist/types/meeting-info/utilv2.d.ts +0 -1
- package/dist/types/meetings/index.d.ts +2 -4
- package/dist/types/member/index.d.ts +0 -1
- package/dist/types/member/types.d.ts +4 -4
- package/dist/types/member/util.d.ts +0 -5
- package/dist/types/metrics/constants.d.ts +0 -6
- package/dist/types/multistream/mediaRequestManager.d.ts +23 -0
- package/dist/types/multistream/sendSlotManager.d.ts +1 -23
- package/dist/types/reachability/clusterReachability.d.ts +3 -30
- package/dist/types/reactions/reactions.type.d.ts +0 -1
- package/dist/types/recording-controller/util.d.ts +5 -5
- package/dist/types/roap/index.d.ts +1 -1
- package/dist/webinar/index.js +163 -438
- package/dist/webinar/index.js.map +1 -1
- package/package.json +24 -26
- package/src/annotation/index.ts +7 -27
- package/src/config.ts +0 -5
- package/src/constants.ts +1 -30
- package/src/hashTree/hashTreeParser.ts +25 -1523
- package/src/hashTree/types.ts +1 -24
- package/src/index.ts +1 -8
- package/src/interceptors/index.ts +1 -2
- package/src/interceptors/locusRouteToken.ts +5 -22
- package/src/interpretation/index.ts +2 -2
- package/src/locus-info/controlsUtils.ts +0 -17
- package/src/locus-info/index.ts +213 -707
- package/src/locus-info/selfUtils.ts +0 -1
- package/src/locus-info/types.ts +12 -27
- package/src/media/MediaConnectionAwaiter.ts +1 -41
- package/src/media/properties.ts +1 -3
- package/src/meeting/in-meeting-actions.ts +0 -12
- package/src/meeting/index.ts +84 -461
- package/src/meeting/request.ts +0 -42
- package/src/meeting/request.type.ts +0 -6
- package/src/meeting/util.ts +2 -160
- package/src/meetings/index.ts +60 -180
- package/src/meetings/util.ts +9 -10
- package/src/member/index.ts +0 -10
- package/src/member/util.ts +0 -12
- package/src/metrics/constants.ts +0 -7
- package/src/multistream/mediaRequestManager.ts +54 -4
- package/src/multistream/remoteMediaManager.ts +0 -13
- package/src/multistream/sendSlotManager.ts +3 -97
- package/src/reachability/clusterReachability.ts +27 -153
- package/src/reachability/index.ts +1 -15
- package/src/reachability/reachabilityPeerConnection.ts +1 -3
- package/src/reactions/reactions.type.ts +0 -1
- package/src/reconnection-manager/index.ts +1 -0
- package/src/webinar/index.ts +6 -265
- package/test/unit/spec/annotation/index.ts +7 -69
- package/test/unit/spec/interceptors/locusRouteToken.ts +0 -44
- package/test/unit/spec/locus-info/controlsUtils.js +1 -56
- package/test/unit/spec/locus-info/index.js +90 -1457
- package/test/unit/spec/media/MediaConnectionAwaiter.ts +1 -41
- package/test/unit/spec/media/properties.ts +3 -12
- package/test/unit/spec/meeting/in-meeting-actions.ts +2 -8
- package/test/unit/spec/meeting/index.js +128 -981
- package/test/unit/spec/meeting/request.js +0 -70
- package/test/unit/spec/meeting/utils.js +26 -438
- package/test/unit/spec/meetings/index.js +33 -845
- package/test/unit/spec/meetings/utils.js +1 -51
- package/test/unit/spec/member/index.js +4 -28
- package/test/unit/spec/member/util.js +27 -65
- package/test/unit/spec/multistream/mediaRequestManager.ts +85 -2
- package/test/unit/spec/multistream/remoteMediaManager.ts +0 -30
- package/test/unit/spec/multistream/sendSlotManager.ts +36 -135
- package/test/unit/spec/reachability/clusterReachability.ts +1 -125
- package/test/unit/spec/reachability/index.ts +3 -26
- package/test/unit/spec/reconnection-manager/index.js +8 -4
- package/test/unit/spec/webinar/index.ts +37 -534
- package/dist/aiEnableRequest/index.js +0 -184
- package/dist/aiEnableRequest/index.js.map +0 -1
- package/dist/aiEnableRequest/utils.js +0 -36
- package/dist/aiEnableRequest/utils.js.map +0 -1
- package/dist/hashTree/constants.js +0 -22
- package/dist/hashTree/constants.js.map +0 -1
- package/dist/hashTree/hashTree.js +0 -533
- package/dist/hashTree/hashTree.js.map +0 -1
- package/dist/hashTree/utils.js +0 -69
- package/dist/hashTree/utils.js.map +0 -1
- package/dist/interceptors/constant.js +0 -12
- package/dist/interceptors/constant.js.map +0 -1
- package/dist/interceptors/dataChannelAuthToken.js +0 -290
- package/dist/interceptors/dataChannelAuthToken.js.map +0 -1
- package/dist/interceptors/utils.js +0 -27
- package/dist/interceptors/utils.js.map +0 -1
- package/dist/types/aiEnableRequest/index.d.ts +0 -5
- package/dist/types/aiEnableRequest/utils.d.ts +0 -2
- package/dist/types/hashTree/constants.d.ts +0 -9
- package/dist/types/hashTree/hashTree.d.ts +0 -136
- package/dist/types/hashTree/utils.d.ts +0 -22
- package/dist/types/interceptors/constant.d.ts +0 -5
- package/dist/types/interceptors/dataChannelAuthToken.d.ts +0 -43
- package/dist/types/interceptors/utils.d.ts +0 -1
- package/dist/types/webinar/utils.d.ts +0 -6
- package/dist/webinar/utils.js +0 -25
- package/dist/webinar/utils.js.map +0 -1
- package/src/aiEnableRequest/README.md +0 -84
- package/src/aiEnableRequest/index.ts +0 -170
- package/src/aiEnableRequest/utils.ts +0 -25
- package/src/hashTree/constants.ts +0 -10
- package/src/hashTree/hashTree.ts +0 -480
- package/src/hashTree/utils.ts +0 -62
- package/src/interceptors/constant.ts +0 -6
- package/src/interceptors/dataChannelAuthToken.ts +0 -170
- package/src/interceptors/utils.ts +0 -16
- package/src/webinar/utils.ts +0 -16
- package/test/unit/spec/aiEnableRequest/index.ts +0 -981
- package/test/unit/spec/aiEnableRequest/utils.ts +0 -130
- package/test/unit/spec/hashTree/hashTree.ts +0 -721
- package/test/unit/spec/hashTree/hashTreeParser.ts +0 -3670
- package/test/unit/spec/hashTree/utils.ts +0 -140
- package/test/unit/spec/interceptors/dataChannelAuthToken.ts +0 -210
- package/test/unit/spec/interceptors/utils.ts +0 -75
- package/test/unit/spec/webinar/utils.ts +0 -39
|
@@ -7,6 +7,7 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.MediaRequestManager = void 0;
|
|
9
9
|
var _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/values"));
|
|
10
|
+
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
10
11
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
|
|
11
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
|
|
12
13
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
@@ -38,6 +39,7 @@ var MediaRequestManager = exports.MediaRequestManager = /*#__PURE__*/function ()
|
|
|
38
39
|
(0, _defineProperty2.default)(this, "degradationPreferences", void 0);
|
|
39
40
|
(0, _defineProperty2.default)(this, "sourceUpdateListener", void 0);
|
|
40
41
|
(0, _defineProperty2.default)(this, "debouncedSourceUpdateListener", void 0);
|
|
42
|
+
(0, _defineProperty2.default)(this, "previousStreamRequests", []);
|
|
41
43
|
(0, _defineProperty2.default)(this, "trimRequestsToNumOfSources", void 0);
|
|
42
44
|
(0, _defineProperty2.default)(this, "numTotalSources", void 0);
|
|
43
45
|
(0, _defineProperty2.default)(this, "numLiveSources", void 0);
|
|
@@ -91,6 +93,36 @@ var MediaRequestManager = exports.MediaRequestManager = /*#__PURE__*/function ()
|
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Returns true if two stream requests are the same, false otherwise.
|
|
98
|
+
*
|
|
99
|
+
* @param {StreamRequest} streamRequestA - Stream request A for comparison.
|
|
100
|
+
* @param {StreamRequest} streamRequestB - Stream request B for comparison.
|
|
101
|
+
* @returns {boolean} - Whether they are equal.
|
|
102
|
+
*/
|
|
103
|
+
// eslint-disable-next-line class-methods-use-this
|
|
104
|
+
}, {
|
|
105
|
+
key: "isEqual",
|
|
106
|
+
value: function isEqual(streamRequestA, streamRequestB) {
|
|
107
|
+
return (0, _stringify.default)(streamRequestA._toJmpStreamRequest()) === (0, _stringify.default)(streamRequestB._toJmpStreamRequest());
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Compares new stream requests to previous ones and determines
|
|
112
|
+
* if they are the same.
|
|
113
|
+
*
|
|
114
|
+
* @param {StreamRequest[]} newRequests - Array with new requests.
|
|
115
|
+
* @returns {boolean} - True if they are equal, false otherwise.
|
|
116
|
+
*/
|
|
117
|
+
}, {
|
|
118
|
+
key: "checkIsNewRequestsEqualToPrev",
|
|
119
|
+
value: function checkIsNewRequestsEqualToPrev(newRequests) {
|
|
120
|
+
var _this2 = this;
|
|
121
|
+
return !(0, _lodash.isEmpty)(this.previousStreamRequests) && this.previousStreamRequests.length === newRequests.length && this.previousStreamRequests.every(function (req, idx) {
|
|
122
|
+
return _this2.isEqual(req, newRequests[idx]);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
94
126
|
/**
|
|
95
127
|
* Returns the maxPayloadBitsPerSecond per Stream
|
|
96
128
|
*
|
|
@@ -131,6 +163,17 @@ var MediaRequestManager = exports.MediaRequestManager = /*#__PURE__*/function ()
|
|
|
131
163
|
return mediaRequest.codecInfo.maxFs * maxFps / 100;
|
|
132
164
|
}
|
|
133
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Clears the previous stream requests.
|
|
168
|
+
*
|
|
169
|
+
* @returns {void}
|
|
170
|
+
*/
|
|
171
|
+
}, {
|
|
172
|
+
key: "clearPreviousRequests",
|
|
173
|
+
value: function clearPreviousRequests() {
|
|
174
|
+
this.previousStreamRequests = [];
|
|
175
|
+
}
|
|
176
|
+
|
|
134
177
|
/** Modifies the passed in clientRequests and makes sure that in total they don't ask
|
|
135
178
|
* for more streams than there are available.
|
|
136
179
|
*
|
|
@@ -211,7 +254,7 @@ var MediaRequestManager = exports.MediaRequestManager = /*#__PURE__*/function ()
|
|
|
211
254
|
}, {
|
|
212
255
|
key: "sendRequests",
|
|
213
256
|
value: function sendRequests() {
|
|
214
|
-
var
|
|
257
|
+
var _this3 = this;
|
|
215
258
|
var streamRequests = [];
|
|
216
259
|
|
|
217
260
|
// clone the requests so that any modifications we do to them don't affect the original ones
|
|
@@ -224,16 +267,24 @@ var MediaRequestManager = exports.MediaRequestManager = /*#__PURE__*/function ()
|
|
|
224
267
|
if (mr.receiveSlots.length > 0) {
|
|
225
268
|
streamRequests.push(new _internalMediaCore.StreamRequest(mr.policyInfo.policy === 'active-speaker' ? _internalMediaCore.Policy.ActiveSpeaker : _internalMediaCore.Policy.ReceiverSelected, mr.policyInfo.policy === 'active-speaker' ? new _internalMediaCore.ActiveSpeakerInfo(mr.policyInfo.priority, mr.policyInfo.crossPriorityDuplication, mr.policyInfo.crossPolicyDuplication, mr.policyInfo.preferLiveVideo, mr.policyInfo.namedMediaGroups) : new _internalMediaCore.ReceiverSelectedInfo(mr.policyInfo.csi), mr.receiveSlots.map(function (receiveSlot) {
|
|
226
269
|
return receiveSlot.wcmeReceiveSlot;
|
|
227
|
-
}),
|
|
270
|
+
}), _this3.getMaxPayloadBitsPerSecond(mr), mr.codecInfo && [new _internalMediaCore.CodecInfo(0x80, new _internalMediaCore.H264Codec(mr.codecInfo.maxFs, mr.codecInfo.maxFps || CODEC_DEFAULTS.h264.maxFps, _this3.getH264MaxMbps(mr), mr.codecInfo.maxWidth, mr.codecInfo.maxHeight))]));
|
|
228
271
|
}
|
|
229
272
|
});
|
|
230
|
-
|
|
231
|
-
|
|
273
|
+
|
|
274
|
+
//! IMPORTANT: this is only a temporary fix. This will soon be done in the jmp layer (@webex/json-multistream)
|
|
275
|
+
// https://jira-eng-gpk2.cisco.com/jira/browse/WEBEX-326713
|
|
276
|
+
if (!this.checkIsNewRequestsEqualToPrev(streamRequests)) {
|
|
277
|
+
this.sendMediaRequestsCallback(streamRequests);
|
|
278
|
+
this.previousStreamRequests = streamRequests;
|
|
279
|
+
_loggerProxy.default.logger.info("multistream:sendRequests --> media requests sent. ");
|
|
280
|
+
} else {
|
|
281
|
+
_loggerProxy.default.logger.info("multistream:sendRequests --> detected duplicate WCME requests, skipping them... ");
|
|
282
|
+
}
|
|
232
283
|
}
|
|
233
284
|
}, {
|
|
234
285
|
key: "addRequest",
|
|
235
286
|
value: function addRequest(mediaRequest) {
|
|
236
|
-
var
|
|
287
|
+
var _this4 = this;
|
|
237
288
|
var commit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
238
289
|
// eslint-disable-next-line no-plusplus
|
|
239
290
|
var newId = "".concat(this.counter++);
|
|
@@ -241,11 +292,11 @@ var MediaRequestManager = exports.MediaRequestManager = /*#__PURE__*/function ()
|
|
|
241
292
|
var eventHandler = function eventHandler(_ref) {
|
|
242
293
|
var maxFs = _ref.maxFs;
|
|
243
294
|
mediaRequest.preferredMaxFs = maxFs;
|
|
244
|
-
|
|
295
|
+
_this4.debouncedSourceUpdateListener();
|
|
245
296
|
};
|
|
246
297
|
mediaRequest.handleMaxFs = eventHandler;
|
|
247
298
|
mediaRequest.receiveSlots.forEach(function (rs) {
|
|
248
|
-
rs.on(_receiveSlot.ReceiveSlotEvents.SourceUpdate,
|
|
299
|
+
rs.on(_receiveSlot.ReceiveSlotEvents.SourceUpdate, _this4.sourceUpdateListener);
|
|
249
300
|
rs.on(_receiveSlot.ReceiveSlotEvents.MaxFsUpdate, mediaRequest.handleMaxFs);
|
|
250
301
|
});
|
|
251
302
|
if (commit) {
|
|
@@ -256,11 +307,11 @@ var MediaRequestManager = exports.MediaRequestManager = /*#__PURE__*/function ()
|
|
|
256
307
|
}, {
|
|
257
308
|
key: "cancelRequest",
|
|
258
309
|
value: function cancelRequest(requestId) {
|
|
259
|
-
var
|
|
310
|
+
var _this5 = this;
|
|
260
311
|
var commit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
261
312
|
var mediaRequest = this.clientRequests[requestId];
|
|
262
313
|
mediaRequest === null || mediaRequest === void 0 ? void 0 : mediaRequest.receiveSlots.forEach(function (rs) {
|
|
263
|
-
rs.off(_receiveSlot.ReceiveSlotEvents.SourceUpdate,
|
|
314
|
+
rs.off(_receiveSlot.ReceiveSlotEvents.SourceUpdate, _this5.sourceUpdateListener);
|
|
264
315
|
rs.off(_receiveSlot.ReceiveSlotEvents.MaxFsUpdate, mediaRequest.handleMaxFs);
|
|
265
316
|
});
|
|
266
317
|
delete this.clientRequests[requestId];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_internalMediaCore","require","_lodash","_loggerProxy","_interopRequireDefault","_receiveSlot","_remoteMedia","CODEC_DEFAULTS","h264","maxFs","maxFps","maxMbps","DEBOUNCED_SOURCE_UPDATE_TIME","MediaRequestManager","exports","sendMediaRequestsCallback","options","_classCallCheck2","default","_defineProperty2","counter","numLiveSources","numTotalSources","clientRequests","degradationPreferences","kind","trimRequestsToNumOfSources","sourceUpdateListener","commit","bind","debouncedSourceUpdateListener","debounce","_createClass2","key","value","setDegradationPreferences","sendRequests","getDegradedClientRequests","_this","maxFsLimits","MAX_FS_VALUES","_loop","i","totalMacroblocksRequested","_values","forEach","mr","codecInfo","Math","min","preferredMaxFs","slotsWithLiveSource","receiveSlots","filter","rs","sourceState","length","maxMacroblocksLimit","LoggerProxy","logger","warn","concat","getMaxPayloadBitsPerSecond","mediaRequest","RecommendedOpusBitrates","FB_MONO_MUSIC","getRecommendedMaxBitrateForFrameSize","getH264MaxMbps","trimRequests","preferLiveVideo","getPreferLiveVideo","undefined","numStreamsAvailable","sort","a","b","policyInfo","policy","priority","request","trimmedCount","Error","cloneClientRequests","cloneDeepWith","_toConsumableArray2","_this2","streamRequests","push","StreamRequest","Policy","ActiveSpeaker","ReceiverSelected","ActiveSpeakerInfo","crossPriorityDuplication","crossPolicyDuplication","namedMediaGroups","ReceiverSelectedInfo","csi","map","receiveSlot","wcmeReceiveSlot","WcmeCodecInfo","fromH264","H264Codec","maxWidth","maxHeight","info","addRequest","_this3","arguments","newId","eventHandler","_ref","handleMaxFs","on","ReceiveSlotEvents","SourceUpdate","MaxFsUpdate","cancelRequest","requestId","_this4","off","reset","setNumCurrentSources"],"sources":["mediaRequestManager.ts"],"sourcesContent":["/* eslint-disable require-jsdoc */\nimport {\n StreamRequest,\n Policy,\n ActiveSpeakerInfo,\n ReceiverSelectedInfo,\n CodecInfo as WcmeCodecInfo,\n H264Codec,\n getRecommendedMaxBitrateForFrameSize,\n RecommendedOpusBitrates,\n NamedMediaGroup,\n} from '@webex/internal-media-core';\nimport {cloneDeepWith, debounce} from 'lodash';\n\nimport LoggerProxy from '../common/logs/logger-proxy';\n\nimport {ReceiveSlot, ReceiveSlotEvents} from './receiveSlot';\nimport {MAX_FS_VALUES} from './remoteMedia';\n\nexport interface ActiveSpeakerPolicyInfo {\n policy: 'active-speaker';\n priority: number;\n crossPriorityDuplication: boolean;\n crossPolicyDuplication: boolean;\n preferLiveVideo: boolean;\n namedMediaGroups?: NamedMediaGroup[];\n}\n\nexport interface ReceiverSelectedPolicyInfo {\n policy: 'receiver-selected';\n csi: number;\n}\n\nexport type PolicyInfo = ActiveSpeakerPolicyInfo | ReceiverSelectedPolicyInfo;\n\nexport interface H264CodecInfo {\n codec: 'h264';\n maxFs?: number;\n maxFps?: number;\n maxMbps?: number;\n maxWidth?: number;\n maxHeight?: number;\n}\n\nexport type CodecInfo = H264CodecInfo; // we'll add AV1 here in the future when it's available\n\nexport interface MediaRequest {\n policyInfo: PolicyInfo;\n receiveSlots: Array<ReceiveSlot>;\n codecInfo?: CodecInfo;\n preferredMaxFs?: number;\n handleMaxFs?: ({maxFs}: {maxFs: number}) => void;\n}\n\nexport type MediaRequestId = string;\n\nconst CODEC_DEFAULTS = {\n h264: {\n maxFs: 8192,\n maxFps: 3000,\n maxMbps: 245760,\n },\n};\n\nconst DEBOUNCED_SOURCE_UPDATE_TIME = 1000;\n\ntype DegradationPreferences = {\n maxMacroblocksLimit: number;\n};\n\ntype SendMediaRequestsCallback = (streamRequests: StreamRequest[]) => void;\ntype Kind = 'audio' | 'video';\n\ntype Options = {\n degradationPreferences: DegradationPreferences;\n kind: Kind;\n trimRequestsToNumOfSources: boolean; // if enabled, AS speaker requests will be trimmed based on the calls to setNumCurrentSources()\n};\n\ntype ClientRequestsMap = {[key: MediaRequestId]: MediaRequest};\n\nexport class MediaRequestManager {\n private sendMediaRequestsCallback: SendMediaRequestsCallback;\n\n private kind: Kind;\n\n private counter: number;\n\n private clientRequests: ClientRequestsMap;\n\n private degradationPreferences: DegradationPreferences;\n\n private sourceUpdateListener: () => void;\n\n private debouncedSourceUpdateListener: () => void;\n\n private trimRequestsToNumOfSources: boolean;\n private numTotalSources: number;\n private numLiveSources: number;\n\n constructor(sendMediaRequestsCallback: SendMediaRequestsCallback, options: Options) {\n this.sendMediaRequestsCallback = sendMediaRequestsCallback;\n this.counter = 0;\n this.numLiveSources = 0;\n this.numTotalSources = 0;\n this.clientRequests = {};\n this.degradationPreferences = options.degradationPreferences;\n this.kind = options.kind;\n this.trimRequestsToNumOfSources = options.trimRequestsToNumOfSources;\n this.sourceUpdateListener = this.commit.bind(this);\n this.debouncedSourceUpdateListener = debounce(\n this.sourceUpdateListener,\n DEBOUNCED_SOURCE_UPDATE_TIME\n );\n }\n\n public setDegradationPreferences(degradationPreferences: DegradationPreferences) {\n this.degradationPreferences = degradationPreferences;\n this.sendRequests(); // re-send requests after preferences are set\n }\n\n private getDegradedClientRequests(clientRequests: ClientRequestsMap) {\n const maxFsLimits = [\n MAX_FS_VALUES['1080p'],\n MAX_FS_VALUES['720p'],\n MAX_FS_VALUES['540p'],\n MAX_FS_VALUES['360p'],\n MAX_FS_VALUES['180p'],\n MAX_FS_VALUES['90p'],\n ];\n\n // reduce max-fs until total macroblocks is below limit\n for (let i = 0; i < maxFsLimits.length; i += 1) {\n let totalMacroblocksRequested = 0;\n Object.values(clientRequests).forEach((mr) => {\n if (mr.codecInfo) {\n mr.codecInfo.maxFs = Math.min(\n mr.preferredMaxFs || CODEC_DEFAULTS.h264.maxFs,\n mr.codecInfo.maxFs || CODEC_DEFAULTS.h264.maxFs,\n maxFsLimits[i]\n );\n // we only consider sources with \"live\" state\n const slotsWithLiveSource = mr.receiveSlots.filter((rs) => rs.sourceState === 'live');\n totalMacroblocksRequested += mr.codecInfo.maxFs * slotsWithLiveSource.length;\n }\n });\n if (totalMacroblocksRequested <= this.degradationPreferences.maxMacroblocksLimit) {\n if (i !== 0) {\n LoggerProxy.logger.warn(\n `multistream:mediaRequestManager --> too many streams with high max-fs, frame size will be limited to ${maxFsLimits[i]}`\n );\n }\n break;\n } else if (i === maxFsLimits.length - 1) {\n LoggerProxy.logger.warn(\n `multistream:mediaRequestManager --> even with frame size limited to ${maxFsLimits[i]} you are still requesting too many streams, consider reducing the number of requests`\n );\n }\n }\n }\n\n /**\n * Returns the maxPayloadBitsPerSecond per Stream\n *\n * If MediaRequestManager kind is \"audio\", a constant bitrate will be returned.\n * If MediaRequestManager kind is \"video\", the bitrate will be calculated based\n * on maxFs (default h264 maxFs as fallback if maxFs is not defined)\n *\n * @param {MediaRequest} mediaRequest - mediaRequest to take data from\n * @returns {number} maxPayloadBitsPerSecond\n */\n private getMaxPayloadBitsPerSecond(mediaRequest: MediaRequest): number {\n if (this.kind === 'audio') {\n // return mono_music bitrate default if the kind of mediarequest manager is audio:\n return RecommendedOpusBitrates.FB_MONO_MUSIC;\n }\n\n return getRecommendedMaxBitrateForFrameSize(\n mediaRequest.codecInfo.maxFs || CODEC_DEFAULTS.h264.maxFs\n );\n }\n\n /**\n * Returns the max Macro Blocks per second (maxMbps) per H264 Stream\n *\n * The maxMbps will be calculated based on maxFs and maxFps\n * (default h264 maxFps as fallback if maxFps is not defined)\n *\n * @param {MediaRequest} mediaRequest - mediaRequest to take data from\n * @returns {number} maxMbps\n */\n // eslint-disable-next-line class-methods-use-this\n private getH264MaxMbps(mediaRequest: MediaRequest): number {\n // fallback for maxFps (not needed for maxFs, since there is a fallback already in getDegradedClientRequests)\n const maxFps = mediaRequest.codecInfo.maxFps || CODEC_DEFAULTS.h264.maxFps;\n\n // divided by 100 since maxFps is 3000 (for 30 frames per seconds)\n return (mediaRequest.codecInfo.maxFs * maxFps) / 100;\n }\n\n /** Modifies the passed in clientRequests and makes sure that in total they don't ask\n * for more streams than there are available.\n *\n * @param {Object} clientRequests\n * @returns {void}\n */\n private trimRequests(clientRequests: ClientRequestsMap) {\n const preferLiveVideo = this.getPreferLiveVideo();\n\n if (!this.trimRequestsToNumOfSources) {\n return;\n }\n\n // preferLiveVideo being undefined means that there are no active-speaker requests so we don't need to do any trimming\n if (preferLiveVideo === undefined) {\n return;\n }\n\n let numStreamsAvailable = preferLiveVideo ? this.numLiveSources : this.numTotalSources;\n\n Object.values(clientRequests)\n .sort((a, b) => {\n // we have to count how many streams we're asking for\n // and should not ask for more than numStreamsAvailable in total,\n // so we might need to trim active-speaker requests and first ones to trim should be\n // the ones with lowest priority\n\n // receiver-selected requests have priority over active-speakers\n if (a.policyInfo.policy === 'receiver-selected') {\n return -1;\n }\n if (b.policyInfo.policy === 'receiver-selected') {\n return 1;\n }\n\n // and active-speakers are sorted by descending priority\n return b.policyInfo.priority - a.policyInfo.priority;\n })\n .forEach((request) => {\n // we only trim active-speaker requests\n if (request.policyInfo.policy === 'active-speaker') {\n const trimmedCount = Math.min(numStreamsAvailable, request.receiveSlots.length);\n\n request.receiveSlots.length = trimmedCount;\n\n numStreamsAvailable -= trimmedCount;\n } else {\n numStreamsAvailable -= request.receiveSlots.length;\n }\n\n if (numStreamsAvailable < 0) {\n numStreamsAvailable = 0;\n }\n });\n }\n\n private getPreferLiveVideo(): boolean | undefined {\n let preferLiveVideo;\n\n Object.values(this.clientRequests).forEach((mr) => {\n if (mr.policyInfo.policy === 'active-speaker') {\n // take the value from first encountered active speaker request\n if (preferLiveVideo === undefined) {\n preferLiveVideo = mr.policyInfo.preferLiveVideo;\n }\n\n if (mr.policyInfo.preferLiveVideo !== preferLiveVideo) {\n throw new Error(\n 'a mix of active-speaker groups with different values for preferLiveVideo is not supported'\n );\n }\n }\n });\n\n return preferLiveVideo;\n }\n\n private cloneClientRequests(): ClientRequestsMap {\n // we clone the client requests but without cloning the ReceiveSlots that they reference\n return cloneDeepWith(this.clientRequests, (value, key) => {\n if (key === 'receiveSlots') {\n return [...value];\n }\n\n return undefined;\n });\n }\n\n private sendRequests() {\n const streamRequests: StreamRequest[] = [];\n\n // clone the requests so that any modifications we do to them don't affect the original ones\n const clientRequests = this.cloneClientRequests();\n\n this.trimRequests(clientRequests);\n this.getDegradedClientRequests(clientRequests);\n\n // map all the client media requests to wcme stream requests\n Object.values(clientRequests).forEach((mr) => {\n if (mr.receiveSlots.length > 0) {\n streamRequests.push(\n new StreamRequest(\n mr.policyInfo.policy === 'active-speaker'\n ? Policy.ActiveSpeaker\n : Policy.ReceiverSelected,\n mr.policyInfo.policy === 'active-speaker'\n ? new ActiveSpeakerInfo(\n mr.policyInfo.priority,\n mr.policyInfo.crossPriorityDuplication,\n mr.policyInfo.crossPolicyDuplication,\n mr.policyInfo.preferLiveVideo,\n mr.policyInfo.namedMediaGroups\n )\n : new ReceiverSelectedInfo(mr.policyInfo.csi),\n mr.receiveSlots.map((receiveSlot) => receiveSlot.wcmeReceiveSlot),\n this.getMaxPayloadBitsPerSecond(mr),\n mr.codecInfo && [\n WcmeCodecInfo.fromH264(\n 0x80,\n new H264Codec(\n mr.codecInfo.maxFs,\n mr.codecInfo.maxFps || CODEC_DEFAULTS.h264.maxFps,\n this.getH264MaxMbps(mr),\n mr.codecInfo.maxWidth,\n mr.codecInfo.maxHeight\n )\n ),\n ]\n )\n );\n }\n });\n\n this.sendMediaRequestsCallback(streamRequests);\n LoggerProxy.logger.info(`multistream:sendRequests --> media requests sent. `);\n }\n\n public addRequest(mediaRequest: MediaRequest, commit = true): MediaRequestId {\n // eslint-disable-next-line no-plusplus\n const newId = `${this.counter++}`;\n\n this.clientRequests[newId] = mediaRequest;\n\n const eventHandler = ({maxFs}) => {\n mediaRequest.preferredMaxFs = maxFs;\n this.debouncedSourceUpdateListener();\n };\n mediaRequest.handleMaxFs = eventHandler;\n\n mediaRequest.receiveSlots.forEach((rs) => {\n rs.on(ReceiveSlotEvents.SourceUpdate, this.sourceUpdateListener);\n rs.on(ReceiveSlotEvents.MaxFsUpdate, mediaRequest.handleMaxFs);\n });\n\n if (commit) {\n this.commit();\n }\n\n return newId;\n }\n\n public cancelRequest(requestId: MediaRequestId, commit = true) {\n const mediaRequest = this.clientRequests[requestId];\n\n mediaRequest?.receiveSlots.forEach((rs) => {\n rs.off(ReceiveSlotEvents.SourceUpdate, this.sourceUpdateListener);\n rs.off(ReceiveSlotEvents.MaxFsUpdate, mediaRequest.handleMaxFs);\n });\n\n delete this.clientRequests[requestId];\n\n if (commit) {\n this.commit();\n }\n }\n\n public commit() {\n return this.sendRequests();\n }\n\n public reset() {\n this.clientRequests = {};\n this.numTotalSources = 0;\n this.numLiveSources = 0;\n }\n\n public setNumCurrentSources(numTotalSources: number, numLiveSources: number) {\n this.numTotalSources = numTotalSources;\n this.numLiveSources = numLiveSources;\n\n this.sendRequests();\n }\n}\n"],"mappings":";;;;;;;;;;;;;AACA,IAAAA,kBAAA,GAAAC,OAAA;AAWA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AAjBA;;AA4CuC;;AAYvC,IAAMM,cAAc,GAAG;EACrBC,IAAI,EAAE;IACJC,KAAK,EAAE,IAAI;IACXC,MAAM,EAAE,IAAI;IACZC,OAAO,EAAE;EACX;AACF,CAAC;AAED,IAAMC,4BAA4B,GAAG,IAAI;AAAC,IAiB7BC,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA;EAmB9B,SAAAA,oBAAYE,yBAAoD,EAAEC,OAAgB,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA,QAAAL,mBAAA;IAAA,IAAAM,gBAAA,CAAAD,OAAA;IAAA,IAAAC,gBAAA,CAAAD,OAAA;IAAA,IAAAC,gBAAA,CAAAD,OAAA;IAAA,IAAAC,gBAAA,CAAAD,OAAA;IAAA,IAAAC,gBAAA,CAAAD,OAAA;IAAA,IAAAC,gBAAA,CAAAD,OAAA;IAAA,IAAAC,gBAAA,CAAAD,OAAA;IAAA,IAAAC,gBAAA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GAAG,CAAC;MACxB,IAAI,CAACD,cAAc,GAAG,CAAC;IACzB;EAAC;IAAAY,GAAA;IAAAC,KAAA,EAED,SAAOyF,oBAAoBA,CAACrG,eAAuB,EAAED,cAAsB,EAAE;MAC3E,IAAI,CAACC,eAAe,GAAGA,eAAe;MACtC,IAAI,CAACD,cAAc,GAAGA,cAAc;MAEpC,IAAI,CAACe,YAAY,CAAC,CAAC;IACrB;EAAC;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_internalMediaCore","require","_lodash","_loggerProxy","_interopRequireDefault","_receiveSlot","_remoteMedia","CODEC_DEFAULTS","h264","maxFs","maxFps","maxMbps","DEBOUNCED_SOURCE_UPDATE_TIME","MediaRequestManager","exports","sendMediaRequestsCallback","options","_classCallCheck2","default","_defineProperty2","counter","numLiveSources","numTotalSources","clientRequests","degradationPreferences","kind","trimRequestsToNumOfSources","sourceUpdateListener","commit","bind","debouncedSourceUpdateListener","debounce","_createClass2","key","value","setDegradationPreferences","sendRequests","getDegradedClientRequests","_this","maxFsLimits","MAX_FS_VALUES","_loop","i","totalMacroblocksRequested","_values","forEach","mr","codecInfo","Math","min","preferredMaxFs","slotsWithLiveSource","receiveSlots","filter","rs","sourceState","length","maxMacroblocksLimit","LoggerProxy","logger","warn","concat","isEqual","streamRequestA","streamRequestB","_stringify","_toJmpStreamRequest","checkIsNewRequestsEqualToPrev","newRequests","_this2","isEmpty","previousStreamRequests","every","req","idx","getMaxPayloadBitsPerSecond","mediaRequest","RecommendedOpusBitrates","FB_MONO_MUSIC","getRecommendedMaxBitrateForFrameSize","getH264MaxMbps","clearPreviousRequests","trimRequests","preferLiveVideo","getPreferLiveVideo","undefined","numStreamsAvailable","sort","a","b","policyInfo","policy","priority","request","trimmedCount","Error","cloneClientRequests","cloneDeepWith","_toConsumableArray2","_this3","streamRequests","push","StreamRequest","Policy","ActiveSpeaker","ReceiverSelected","ActiveSpeakerInfo","crossPriorityDuplication","crossPolicyDuplication","namedMediaGroups","ReceiverSelectedInfo","csi","map","receiveSlot","wcmeReceiveSlot","WcmeCodecInfo","H264Codec","maxWidth","maxHeight","info","addRequest","_this4","arguments","newId","eventHandler","_ref","handleMaxFs","on","ReceiveSlotEvents","SourceUpdate","MaxFsUpdate","cancelRequest","requestId","_this5","off","reset","setNumCurrentSources"],"sources":["mediaRequestManager.ts"],"sourcesContent":["/* eslint-disable require-jsdoc */\nimport {\n StreamRequest,\n Policy,\n ActiveSpeakerInfo,\n ReceiverSelectedInfo,\n CodecInfo as WcmeCodecInfo,\n H264Codec,\n getRecommendedMaxBitrateForFrameSize,\n RecommendedOpusBitrates,\n NamedMediaGroup,\n} from '@webex/internal-media-core';\nimport {cloneDeepWith, debounce, isEmpty} from 'lodash';\n\nimport LoggerProxy from '../common/logs/logger-proxy';\n\nimport {ReceiveSlot, ReceiveSlotEvents} from './receiveSlot';\nimport {MAX_FS_VALUES} from './remoteMedia';\n\nexport interface ActiveSpeakerPolicyInfo {\n policy: 'active-speaker';\n priority: number;\n crossPriorityDuplication: boolean;\n crossPolicyDuplication: boolean;\n preferLiveVideo: boolean;\n namedMediaGroups?: NamedMediaGroup[];\n}\n\nexport interface ReceiverSelectedPolicyInfo {\n policy: 'receiver-selected';\n csi: number;\n}\n\nexport type PolicyInfo = ActiveSpeakerPolicyInfo | ReceiverSelectedPolicyInfo;\n\nexport interface H264CodecInfo {\n codec: 'h264';\n maxFs?: number;\n maxFps?: number;\n maxMbps?: number;\n maxWidth?: number;\n maxHeight?: number;\n}\n\nexport type CodecInfo = H264CodecInfo; // we'll add AV1 here in the future when it's available\n\nexport interface MediaRequest {\n policyInfo: PolicyInfo;\n receiveSlots: Array<ReceiveSlot>;\n codecInfo?: CodecInfo;\n preferredMaxFs?: number;\n handleMaxFs?: ({maxFs}: {maxFs: number}) => void;\n}\n\nexport type MediaRequestId = string;\n\nconst CODEC_DEFAULTS = {\n h264: {\n maxFs: 8192,\n maxFps: 3000,\n maxMbps: 245760,\n },\n};\n\nconst DEBOUNCED_SOURCE_UPDATE_TIME = 1000;\n\ntype DegradationPreferences = {\n maxMacroblocksLimit: number;\n};\n\ntype SendMediaRequestsCallback = (streamRequests: StreamRequest[]) => void;\ntype Kind = 'audio' | 'video';\n\ntype Options = {\n degradationPreferences: DegradationPreferences;\n kind: Kind;\n trimRequestsToNumOfSources: boolean; // if enabled, AS speaker requests will be trimmed based on the calls to setNumCurrentSources()\n};\n\ntype ClientRequestsMap = {[key: MediaRequestId]: MediaRequest};\n\nexport class MediaRequestManager {\n private sendMediaRequestsCallback: SendMediaRequestsCallback;\n\n private kind: Kind;\n\n private counter: number;\n\n private clientRequests: ClientRequestsMap;\n\n private degradationPreferences: DegradationPreferences;\n\n private sourceUpdateListener: () => void;\n\n private debouncedSourceUpdateListener: () => void;\n\n private previousStreamRequests: Array<StreamRequest> = [];\n\n private trimRequestsToNumOfSources: boolean;\n private numTotalSources: number;\n private numLiveSources: number;\n\n constructor(sendMediaRequestsCallback: SendMediaRequestsCallback, options: Options) {\n this.sendMediaRequestsCallback = sendMediaRequestsCallback;\n this.counter = 0;\n this.numLiveSources = 0;\n this.numTotalSources = 0;\n this.clientRequests = {};\n this.degradationPreferences = options.degradationPreferences;\n this.kind = options.kind;\n this.trimRequestsToNumOfSources = options.trimRequestsToNumOfSources;\n this.sourceUpdateListener = this.commit.bind(this);\n this.debouncedSourceUpdateListener = debounce(\n this.sourceUpdateListener,\n DEBOUNCED_SOURCE_UPDATE_TIME\n );\n }\n\n public setDegradationPreferences(degradationPreferences: DegradationPreferences) {\n this.degradationPreferences = degradationPreferences;\n this.sendRequests(); // re-send requests after preferences are set\n }\n\n private getDegradedClientRequests(clientRequests: ClientRequestsMap) {\n const maxFsLimits = [\n MAX_FS_VALUES['1080p'],\n MAX_FS_VALUES['720p'],\n MAX_FS_VALUES['540p'],\n MAX_FS_VALUES['360p'],\n MAX_FS_VALUES['180p'],\n MAX_FS_VALUES['90p'],\n ];\n\n // reduce max-fs until total macroblocks is below limit\n for (let i = 0; i < maxFsLimits.length; i += 1) {\n let totalMacroblocksRequested = 0;\n Object.values(clientRequests).forEach((mr) => {\n if (mr.codecInfo) {\n mr.codecInfo.maxFs = Math.min(\n mr.preferredMaxFs || CODEC_DEFAULTS.h264.maxFs,\n mr.codecInfo.maxFs || CODEC_DEFAULTS.h264.maxFs,\n maxFsLimits[i]\n );\n // we only consider sources with \"live\" state\n const slotsWithLiveSource = mr.receiveSlots.filter((rs) => rs.sourceState === 'live');\n totalMacroblocksRequested += mr.codecInfo.maxFs * slotsWithLiveSource.length;\n }\n });\n if (totalMacroblocksRequested <= this.degradationPreferences.maxMacroblocksLimit) {\n if (i !== 0) {\n LoggerProxy.logger.warn(\n `multistream:mediaRequestManager --> too many streams with high max-fs, frame size will be limited to ${maxFsLimits[i]}`\n );\n }\n break;\n } else if (i === maxFsLimits.length - 1) {\n LoggerProxy.logger.warn(\n `multistream:mediaRequestManager --> even with frame size limited to ${maxFsLimits[i]} you are still requesting too many streams, consider reducing the number of requests`\n );\n }\n }\n }\n\n /**\n * Returns true if two stream requests are the same, false otherwise.\n *\n * @param {StreamRequest} streamRequestA - Stream request A for comparison.\n * @param {StreamRequest} streamRequestB - Stream request B for comparison.\n * @returns {boolean} - Whether they are equal.\n */\n // eslint-disable-next-line class-methods-use-this\n public isEqual(streamRequestA: StreamRequest, streamRequestB: StreamRequest) {\n return (\n JSON.stringify(streamRequestA._toJmpStreamRequest()) ===\n JSON.stringify(streamRequestB._toJmpStreamRequest())\n );\n }\n\n /**\n * Compares new stream requests to previous ones and determines\n * if they are the same.\n *\n * @param {StreamRequest[]} newRequests - Array with new requests.\n * @returns {boolean} - True if they are equal, false otherwise.\n */\n private checkIsNewRequestsEqualToPrev(newRequests: StreamRequest[]) {\n return (\n !isEmpty(this.previousStreamRequests) &&\n this.previousStreamRequests.length === newRequests.length &&\n this.previousStreamRequests.every((req, idx) => this.isEqual(req, newRequests[idx]))\n );\n }\n\n /**\n * Returns the maxPayloadBitsPerSecond per Stream\n *\n * If MediaRequestManager kind is \"audio\", a constant bitrate will be returned.\n * If MediaRequestManager kind is \"video\", the bitrate will be calculated based\n * on maxFs (default h264 maxFs as fallback if maxFs is not defined)\n *\n * @param {MediaRequest} mediaRequest - mediaRequest to take data from\n * @returns {number} maxPayloadBitsPerSecond\n */\n private getMaxPayloadBitsPerSecond(mediaRequest: MediaRequest): number {\n if (this.kind === 'audio') {\n // return mono_music bitrate default if the kind of mediarequest manager is audio:\n return RecommendedOpusBitrates.FB_MONO_MUSIC;\n }\n\n return getRecommendedMaxBitrateForFrameSize(\n mediaRequest.codecInfo.maxFs || CODEC_DEFAULTS.h264.maxFs\n );\n }\n\n /**\n * Returns the max Macro Blocks per second (maxMbps) per H264 Stream\n *\n * The maxMbps will be calculated based on maxFs and maxFps\n * (default h264 maxFps as fallback if maxFps is not defined)\n *\n * @param {MediaRequest} mediaRequest - mediaRequest to take data from\n * @returns {number} maxMbps\n */\n // eslint-disable-next-line class-methods-use-this\n private getH264MaxMbps(mediaRequest: MediaRequest): number {\n // fallback for maxFps (not needed for maxFs, since there is a fallback already in getDegradedClientRequests)\n const maxFps = mediaRequest.codecInfo.maxFps || CODEC_DEFAULTS.h264.maxFps;\n\n // divided by 100 since maxFps is 3000 (for 30 frames per seconds)\n return (mediaRequest.codecInfo.maxFs * maxFps) / 100;\n }\n\n /**\n * Clears the previous stream requests.\n *\n * @returns {void}\n */\n public clearPreviousRequests(): void {\n this.previousStreamRequests = [];\n }\n\n /** Modifies the passed in clientRequests and makes sure that in total they don't ask\n * for more streams than there are available.\n *\n * @param {Object} clientRequests\n * @returns {void}\n */\n private trimRequests(clientRequests: ClientRequestsMap) {\n const preferLiveVideo = this.getPreferLiveVideo();\n\n if (!this.trimRequestsToNumOfSources) {\n return;\n }\n\n // preferLiveVideo being undefined means that there are no active-speaker requests so we don't need to do any trimming\n if (preferLiveVideo === undefined) {\n return;\n }\n\n let numStreamsAvailable = preferLiveVideo ? this.numLiveSources : this.numTotalSources;\n\n Object.values(clientRequests)\n .sort((a, b) => {\n // we have to count how many streams we're asking for\n // and should not ask for more than numStreamsAvailable in total,\n // so we might need to trim active-speaker requests and first ones to trim should be\n // the ones with lowest priority\n\n // receiver-selected requests have priority over active-speakers\n if (a.policyInfo.policy === 'receiver-selected') {\n return -1;\n }\n if (b.policyInfo.policy === 'receiver-selected') {\n return 1;\n }\n\n // and active-speakers are sorted by descending priority\n return b.policyInfo.priority - a.policyInfo.priority;\n })\n .forEach((request) => {\n // we only trim active-speaker requests\n if (request.policyInfo.policy === 'active-speaker') {\n const trimmedCount = Math.min(numStreamsAvailable, request.receiveSlots.length);\n\n request.receiveSlots.length = trimmedCount;\n\n numStreamsAvailable -= trimmedCount;\n } else {\n numStreamsAvailable -= request.receiveSlots.length;\n }\n\n if (numStreamsAvailable < 0) {\n numStreamsAvailable = 0;\n }\n });\n }\n\n private getPreferLiveVideo(): boolean | undefined {\n let preferLiveVideo;\n\n Object.values(this.clientRequests).forEach((mr) => {\n if (mr.policyInfo.policy === 'active-speaker') {\n // take the value from first encountered active speaker request\n if (preferLiveVideo === undefined) {\n preferLiveVideo = mr.policyInfo.preferLiveVideo;\n }\n\n if (mr.policyInfo.preferLiveVideo !== preferLiveVideo) {\n throw new Error(\n 'a mix of active-speaker groups with different values for preferLiveVideo is not supported'\n );\n }\n }\n });\n\n return preferLiveVideo;\n }\n\n private cloneClientRequests(): ClientRequestsMap {\n // we clone the client requests but without cloning the ReceiveSlots that they reference\n return cloneDeepWith(this.clientRequests, (value, key) => {\n if (key === 'receiveSlots') {\n return [...value];\n }\n\n return undefined;\n });\n }\n\n private sendRequests() {\n const streamRequests: StreamRequest[] = [];\n\n // clone the requests so that any modifications we do to them don't affect the original ones\n const clientRequests = this.cloneClientRequests();\n\n this.trimRequests(clientRequests);\n this.getDegradedClientRequests(clientRequests);\n\n // map all the client media requests to wcme stream requests\n Object.values(clientRequests).forEach((mr) => {\n if (mr.receiveSlots.length > 0) {\n streamRequests.push(\n new StreamRequest(\n mr.policyInfo.policy === 'active-speaker'\n ? Policy.ActiveSpeaker\n : Policy.ReceiverSelected,\n mr.policyInfo.policy === 'active-speaker'\n ? new ActiveSpeakerInfo(\n mr.policyInfo.priority,\n mr.policyInfo.crossPriorityDuplication,\n mr.policyInfo.crossPolicyDuplication,\n mr.policyInfo.preferLiveVideo,\n mr.policyInfo.namedMediaGroups\n )\n : new ReceiverSelectedInfo(mr.policyInfo.csi),\n mr.receiveSlots.map((receiveSlot) => receiveSlot.wcmeReceiveSlot),\n this.getMaxPayloadBitsPerSecond(mr),\n mr.codecInfo && [\n new WcmeCodecInfo(\n 0x80,\n new H264Codec(\n mr.codecInfo.maxFs,\n mr.codecInfo.maxFps || CODEC_DEFAULTS.h264.maxFps,\n this.getH264MaxMbps(mr),\n mr.codecInfo.maxWidth,\n mr.codecInfo.maxHeight\n )\n ),\n ]\n )\n );\n }\n });\n\n //! IMPORTANT: this is only a temporary fix. This will soon be done in the jmp layer (@webex/json-multistream)\n // https://jira-eng-gpk2.cisco.com/jira/browse/WEBEX-326713\n if (!this.checkIsNewRequestsEqualToPrev(streamRequests)) {\n this.sendMediaRequestsCallback(streamRequests);\n this.previousStreamRequests = streamRequests;\n LoggerProxy.logger.info(`multistream:sendRequests --> media requests sent. `);\n } else {\n LoggerProxy.logger.info(\n `multistream:sendRequests --> detected duplicate WCME requests, skipping them... `\n );\n }\n }\n\n public addRequest(mediaRequest: MediaRequest, commit = true): MediaRequestId {\n // eslint-disable-next-line no-plusplus\n const newId = `${this.counter++}`;\n\n this.clientRequests[newId] = mediaRequest;\n\n const eventHandler = ({maxFs}) => {\n mediaRequest.preferredMaxFs = maxFs;\n this.debouncedSourceUpdateListener();\n };\n mediaRequest.handleMaxFs = eventHandler;\n\n mediaRequest.receiveSlots.forEach((rs) => {\n rs.on(ReceiveSlotEvents.SourceUpdate, this.sourceUpdateListener);\n rs.on(ReceiveSlotEvents.MaxFsUpdate, mediaRequest.handleMaxFs);\n });\n\n if (commit) {\n this.commit();\n }\n\n return newId;\n }\n\n public cancelRequest(requestId: MediaRequestId, commit = true) {\n const mediaRequest = this.clientRequests[requestId];\n\n mediaRequest?.receiveSlots.forEach((rs) => {\n rs.off(ReceiveSlotEvents.SourceUpdate, this.sourceUpdateListener);\n rs.off(ReceiveSlotEvents.MaxFsUpdate, mediaRequest.handleMaxFs);\n });\n\n delete this.clientRequests[requestId];\n\n if (commit) {\n this.commit();\n }\n }\n\n public commit() {\n return this.sendRequests();\n }\n\n public reset() {\n this.clientRequests = {};\n this.numTotalSources = 0;\n this.numLiveSources = 0;\n }\n\n public setNumCurrentSources(numTotalSources: number, numLiveSources: number) {\n this.numTotalSources = numTotalSources;\n this.numLiveSources = numLiveSources;\n\n this.sendRequests();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AACA,IAAAA,kBAAA,GAAAC,OAAA;AAWA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AAjBA;;AA4CuC;;AAYvC,IAAMM,cAAc,GAAG;EACrBC,IAAI,EAAE;IACJC,KAAK,EAAE,IAAI;IACXC,MAAM,EAAE,IAAI;IACZC,OAAO,EAAE;EACX;AACF,CAAC;AAED,IAAMC,4BAA4B,GAAG,IAAI;AAAC,IAiB7BC,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA;EAqB9B,SAAAA,oBAAYE,yBAAoD,EAAEC,OAAgB,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA,QAAAL,mBAAA;IAAA,IAAAM,gBAAA,CAAAD,OAAA;IAAA,IAAAC,gBAAA,CAAAD,OAAA;IAAA,IAAAC,gBAAA,CAAAD,OAAA;IAAA,IAAAC,gBAAA,CAAAD,OAAA;IAAA,IAAAC,gBAAA,CAAAD,OAAA;IAAA,IAAAC,gBAAA,CAAAD,OAAA;IAAA,IAAAC,gBAAA,CAAAD,OAAA;IAAA,IAAAC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ClH,eAAuB,EAAED,cAAsB,EAAE;MAC3E,IAAI,CAACC,eAAe,GAAGA,eAAe;MACtC,IAAI,CAACD,cAAc,GAAGA,cAAc;MAEpC,IAAI,CAACe,YAAY,CAAC,CAAC;IACrB;EAAC;AAAA","ignoreList":[]}
|
|
@@ -42,16 +42,6 @@ var AllEqualLayout = {
|
|
|
42
42
|
}]
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
// An "all equal" grid, with size up to 5 x 5 = 25:
|
|
46
|
-
var AllEqual25Layout = {
|
|
47
|
-
activeSpeakerVideoPaneGroups: [{
|
|
48
|
-
id: 'main',
|
|
49
|
-
numPanes: 25,
|
|
50
|
-
size: 'best',
|
|
51
|
-
priority: 255
|
|
52
|
-
}]
|
|
53
|
-
};
|
|
54
|
-
|
|
55
45
|
// A layout with just a single remote active speaker video pane:
|
|
56
46
|
var SingleLayout = {
|
|
57
47
|
activeSpeakerVideoPaneGroups: [{
|
|
@@ -149,7 +139,6 @@ var DefaultConfiguration = exports.DefaultConfiguration = {
|
|
|
149
139
|
initialLayoutId: 'AllEqual',
|
|
150
140
|
layouts: {
|
|
151
141
|
AllEqual: AllEqualLayout,
|
|
152
|
-
AllEqual25: AllEqual25Layout,
|
|
153
142
|
OnePlusFive: OnePlusFiveLayout,
|
|
154
143
|
Single: SingleLayout,
|
|
155
144
|
Stage: Stage2x2With6ThumbnailsLayout,
|