@webex/plugin-meetings 3.12.0-next.57 → 3.12.0-next.59

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 (37) hide show
  1. package/dist/aiEnableRequest/index.js +1 -1
  2. package/dist/breakouts/breakout.js +1 -1
  3. package/dist/breakouts/index.js +24 -1
  4. package/dist/breakouts/index.js.map +1 -1
  5. package/dist/config.js +1 -0
  6. package/dist/config.js.map +1 -1
  7. package/dist/interpretation/index.js +1 -1
  8. package/dist/interpretation/siLanguage.js +1 -1
  9. package/dist/media/index.js +3 -1
  10. package/dist/media/index.js.map +1 -1
  11. package/dist/meeting/index.js +37 -10
  12. package/dist/meeting/index.js.map +1 -1
  13. package/dist/meetings/index.js +23 -0
  14. package/dist/meetings/index.js.map +1 -1
  15. package/dist/multistream/codec/constants.js +63 -0
  16. package/dist/multistream/codec/constants.js.map +1 -0
  17. package/dist/multistream/mediaRequestManager.js +62 -15
  18. package/dist/multistream/mediaRequestManager.js.map +1 -1
  19. package/dist/types/config.d.ts +1 -0
  20. package/dist/types/meeting/index.d.ts +9 -0
  21. package/dist/types/meetings/index.d.ts +10 -0
  22. package/dist/types/multistream/codec/constants.d.ts +7 -0
  23. package/dist/types/multistream/mediaRequestManager.d.ts +22 -5
  24. package/dist/webinar/index.js +1 -1
  25. package/package.json +1 -1
  26. package/src/breakouts/index.ts +30 -0
  27. package/src/config.ts +1 -0
  28. package/src/media/index.ts +3 -0
  29. package/src/meeting/index.ts +41 -2
  30. package/src/meetings/index.ts +21 -0
  31. package/src/multistream/codec/constants.ts +58 -0
  32. package/src/multistream/mediaRequestManager.ts +119 -28
  33. package/test/unit/spec/breakouts/index.ts +47 -0
  34. package/test/unit/spec/media/index.ts +31 -0
  35. package/test/unit/spec/meeting/index.js +154 -0
  36. package/test/unit/spec/meetings/index.js +27 -0
  37. package/test/unit/spec/multistream/mediaRequestManager.ts +501 -37
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
+ _Object$defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.H264_CODEC_PARAMETERS = exports.AV1_CODEC_PARAMETERS = void 0;
8
+ var AV1_CODEC_PARAMETERS = exports.AV1_CODEC_PARAMETERS = {
9
+ '90p': {
10
+ levelIdx: 0,
11
+ tier: 0,
12
+ maxWidth: 160,
13
+ maxHeight: 90,
14
+ maxPicSize: 160 * 90,
15
+ maxDecodeRate: 5529600
16
+ },
17
+ '180p': {
18
+ levelIdx: 0,
19
+ tier: 0,
20
+ maxWidth: 320,
21
+ maxHeight: 180,
22
+ maxPicSize: 320 * 180,
23
+ maxDecodeRate: 5529600
24
+ },
25
+ '360p': {
26
+ levelIdx: 1,
27
+ tier: 0,
28
+ maxWidth: 640,
29
+ maxHeight: 360,
30
+ maxPicSize: 640 * 360,
31
+ maxDecodeRate: 10454400
32
+ },
33
+ '540p': {
34
+ levelIdx: 4,
35
+ tier: 0,
36
+ maxWidth: 960,
37
+ maxHeight: 540,
38
+ maxPicSize: 960 * 540,
39
+ maxDecodeRate: 24969600
40
+ },
41
+ '720p': {
42
+ levelIdx: 5,
43
+ tier: 0,
44
+ maxWidth: 1280,
45
+ maxHeight: 720,
46
+ maxPicSize: 1280 * 720,
47
+ maxDecodeRate: 39938400
48
+ },
49
+ '1080p': {
50
+ levelIdx: 8,
51
+ tier: 0,
52
+ maxWidth: 1920,
53
+ maxHeight: 1080,
54
+ maxPicSize: 1920 * 1080,
55
+ maxDecodeRate: 77856768
56
+ }
57
+ };
58
+ var H264_CODEC_PARAMETERS = exports.H264_CODEC_PARAMETERS = {
59
+ maxFs: 8192,
60
+ maxFps: 3000,
61
+ maxMbps: 245760
62
+ };
63
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["AV1_CODEC_PARAMETERS","exports","levelIdx","tier","maxWidth","maxHeight","maxPicSize","maxDecodeRate","H264_CODEC_PARAMETERS","maxFs","maxFps","maxMbps"],"sources":["constants.ts"],"sourcesContent":["import {AV1EncodingParams, SupportedResolution} from '@webex/internal-media-core';\n\nexport const AV1_CODEC_PARAMETERS: Record<SupportedResolution, AV1EncodingParams> = {\n '90p': {\n levelIdx: 0,\n tier: 0,\n maxWidth: 160,\n maxHeight: 90,\n maxPicSize: 160 * 90,\n maxDecodeRate: 5_529_600,\n },\n '180p': {\n levelIdx: 0,\n tier: 0,\n maxWidth: 320,\n maxHeight: 180,\n maxPicSize: 320 * 180,\n maxDecodeRate: 5_529_600,\n },\n '360p': {\n levelIdx: 1,\n tier: 0,\n maxWidth: 640,\n maxHeight: 360,\n maxPicSize: 640 * 360,\n maxDecodeRate: 10_454_400,\n },\n '540p': {\n levelIdx: 4,\n tier: 0,\n maxWidth: 960,\n maxHeight: 540,\n maxPicSize: 960 * 540,\n maxDecodeRate: 24_969_600,\n },\n '720p': {\n levelIdx: 5,\n tier: 0,\n maxWidth: 1280,\n maxHeight: 720,\n maxPicSize: 1280 * 720,\n maxDecodeRate: 39_938_400,\n },\n '1080p': {\n levelIdx: 8,\n tier: 0,\n maxWidth: 1920,\n maxHeight: 1080,\n maxPicSize: 1920 * 1080,\n maxDecodeRate: 77_856_768,\n },\n};\n\nexport const H264_CODEC_PARAMETERS = {\n maxFs: 8192,\n maxFps: 3000,\n maxMbps: 245760,\n};\n"],"mappings":";;;;;;;AAEO,IAAMA,oBAAoE,GAAAC,OAAA,CAAAD,oBAAA,GAAG;EAClF,KAAK,EAAE;IACLE,QAAQ,EAAE,CAAC;IACXC,IAAI,EAAE,CAAC;IACPC,QAAQ,EAAE,GAAG;IACbC,SAAS,EAAE,EAAE;IACbC,UAAU,EAAE,GAAG,GAAG,EAAE;IACpBC,aAAa,EAAE;EACjB,CAAC;EACD,MAAM,EAAE;IACNL,QAAQ,EAAE,CAAC;IACXC,IAAI,EAAE,CAAC;IACPC,QAAQ,EAAE,GAAG;IACbC,SAAS,EAAE,GAAG;IACdC,UAAU,EAAE,GAAG,GAAG,GAAG;IACrBC,aAAa,EAAE;EACjB,CAAC;EACD,MAAM,EAAE;IACNL,QAAQ,EAAE,CAAC;IACXC,IAAI,EAAE,CAAC;IACPC,QAAQ,EAAE,GAAG;IACbC,SAAS,EAAE,GAAG;IACdC,UAAU,EAAE,GAAG,GAAG,GAAG;IACrBC,aAAa,EAAE;EACjB,CAAC;EACD,MAAM,EAAE;IACNL,QAAQ,EAAE,CAAC;IACXC,IAAI,EAAE,CAAC;IACPC,QAAQ,EAAE,GAAG;IACbC,SAAS,EAAE,GAAG;IACdC,UAAU,EAAE,GAAG,GAAG,GAAG;IACrBC,aAAa,EAAE;EACjB,CAAC;EACD,MAAM,EAAE;IACNL,QAAQ,EAAE,CAAC;IACXC,IAAI,EAAE,CAAC;IACPC,QAAQ,EAAE,IAAI;IACdC,SAAS,EAAE,GAAG;IACdC,UAAU,EAAE,IAAI,GAAG,GAAG;IACtBC,aAAa,EAAE;EACjB,CAAC;EACD,OAAO,EAAE;IACPL,QAAQ,EAAE,CAAC;IACXC,IAAI,EAAE,CAAC;IACPC,QAAQ,EAAE,IAAI;IACdC,SAAS,EAAE,IAAI;IACfC,UAAU,EAAE,IAAI,GAAG,IAAI;IACvBC,aAAa,EAAE;EACjB;AACF,CAAC;AAEM,IAAMC,qBAAqB,GAAAP,OAAA,CAAAO,qBAAA,GAAG;EACnCC,KAAK,EAAE,IAAI;EACXC,MAAM,EAAE,IAAI;EACZC,OAAO,EAAE;AACX,CAAC","ignoreList":[]}
@@ -8,6 +8,7 @@ _Object$defineProperty(exports, "__esModule", {
8
8
  exports.MediaRequestManager = void 0;
9
9
  var _values = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/values"));
10
10
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
11
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
11
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
12
13
  var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
13
14
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
@@ -16,22 +17,18 @@ var _lodash = require("lodash");
16
17
  var _loggerProxy = _interopRequireDefault(require("../common/logs/logger-proxy"));
17
18
  var _receiveSlot = require("./receiveSlot");
18
19
  var _remoteMedia = require("./remoteMedia");
20
+ var _constants = require("./codec/constants");
19
21
  /* eslint-disable require-jsdoc */
20
22
 
21
23
  // we'll add AV1 here in the future when it's available
22
24
 
23
- var CODEC_DEFAULTS = {
24
- h264: {
25
- maxFs: 8192,
26
- maxFps: 3000,
27
- maxMbps: 245760
28
- }
29
- };
30
25
  var DEBOUNCED_SOURCE_UPDATE_TIME = 1000;
26
+ var RESOLUTION_BUCKETS = [['90p', _remoteMedia.MAX_FS_VALUES['90p']], ['180p', _remoteMedia.MAX_FS_VALUES['180p']], ['360p', _remoteMedia.MAX_FS_VALUES['360p']], ['540p', _remoteMedia.MAX_FS_VALUES['540p']], ['720p', _remoteMedia.MAX_FS_VALUES['720p']]];
31
27
  var MediaRequestManager = exports.MediaRequestManager = /*#__PURE__*/function () {
32
- function MediaRequestManager(sendMediaRequestsCallback, options) {
28
+ function MediaRequestManager(sendMediaRequestsCallback, getIngressPayloadTypeCallback, options) {
33
29
  (0, _classCallCheck2.default)(this, MediaRequestManager);
34
30
  (0, _defineProperty2.default)(this, "sendMediaRequestsCallback", void 0);
31
+ (0, _defineProperty2.default)(this, "getIngressPayloadTypeCallback", void 0);
35
32
  (0, _defineProperty2.default)(this, "kind", void 0);
36
33
  (0, _defineProperty2.default)(this, "counter", void 0);
37
34
  (0, _defineProperty2.default)(this, "clientRequests", void 0);
@@ -39,9 +36,11 @@ var MediaRequestManager = exports.MediaRequestManager = /*#__PURE__*/function ()
39
36
  (0, _defineProperty2.default)(this, "sourceUpdateListener", void 0);
40
37
  (0, _defineProperty2.default)(this, "debouncedSourceUpdateListener", void 0);
41
38
  (0, _defineProperty2.default)(this, "trimRequestsToNumOfSources", void 0);
39
+ (0, _defineProperty2.default)(this, "enableAv1", void 0);
42
40
  (0, _defineProperty2.default)(this, "numTotalSources", void 0);
43
41
  (0, _defineProperty2.default)(this, "numLiveSources", void 0);
44
42
  this.sendMediaRequestsCallback = sendMediaRequestsCallback;
43
+ this.getIngressPayloadTypeCallback = getIngressPayloadTypeCallback;
45
44
  this.counter = 0;
46
45
  this.numLiveSources = 0;
47
46
  this.numTotalSources = 0;
@@ -49,6 +48,7 @@ var MediaRequestManager = exports.MediaRequestManager = /*#__PURE__*/function ()
49
48
  this.degradationPreferences = options.degradationPreferences;
50
49
  this.kind = options.kind;
51
50
  this.trimRequestsToNumOfSources = options.trimRequestsToNumOfSources;
51
+ this.enableAv1 = options.kind === 'video' && !!options.enableAv1;
52
52
  this.sourceUpdateListener = this.commit.bind(this);
53
53
  this.debouncedSourceUpdateListener = (0, _lodash.debounce)(this.sourceUpdateListener, DEBOUNCED_SOURCE_UPDATE_TIME);
54
54
  }
@@ -69,7 +69,7 @@ var MediaRequestManager = exports.MediaRequestManager = /*#__PURE__*/function ()
69
69
  var totalMacroblocksRequested = 0;
70
70
  (0, _values.default)(clientRequests).forEach(function (mr) {
71
71
  if (mr.codecInfo) {
72
- mr.codecInfo.maxFs = Math.min(mr.preferredMaxFs || CODEC_DEFAULTS.h264.maxFs, mr.codecInfo.maxFs || CODEC_DEFAULTS.h264.maxFs, maxFsLimits[i]);
72
+ mr.codecInfo.maxFs = Math.min(mr.preferredMaxFs || _constants.H264_CODEC_PARAMETERS.maxFs, mr.codecInfo.maxFs || _constants.H264_CODEC_PARAMETERS.maxFs, maxFsLimits[i]);
73
73
  // we only consider sources with "live" state
74
74
  var slotsWithLiveSource = mr.receiveSlots.filter(function (rs) {
75
75
  return rs.sourceState === 'live';
@@ -108,7 +108,7 @@ var MediaRequestManager = exports.MediaRequestManager = /*#__PURE__*/function ()
108
108
  // return mono_music bitrate default if the kind of mediarequest manager is audio:
109
109
  return _internalMediaCore.RecommendedOpusBitrates.FB_MONO_MUSIC;
110
110
  }
111
- return (0, _internalMediaCore.getRecommendedMaxBitrateForFrameSize)(mediaRequest.codecInfo.maxFs || CODEC_DEFAULTS.h264.maxFs);
111
+ return (0, _internalMediaCore.getRecommendedMaxBitrateForFrameSize)(mediaRequest.codecInfo.maxFs || _constants.H264_CODEC_PARAMETERS.maxFs);
112
112
  }
113
113
 
114
114
  /**
@@ -125,12 +125,56 @@ var MediaRequestManager = exports.MediaRequestManager = /*#__PURE__*/function ()
125
125
  key: "getH264MaxMbps",
126
126
  value: function getH264MaxMbps(mediaRequest) {
127
127
  // fallback for maxFps (not needed for maxFs, since there is a fallback already in getDegradedClientRequests)
128
- var maxFps = mediaRequest.codecInfo.maxFps || CODEC_DEFAULTS.h264.maxFps;
128
+ var maxFps = mediaRequest.codecInfo.maxFps || _constants.H264_CODEC_PARAMETERS.maxFps;
129
129
 
130
130
  // divided by 100 since maxFps is 3000 (for 30 frames per seconds)
131
131
  return mediaRequest.codecInfo.maxFs * maxFps / 100;
132
132
  }
133
133
 
134
+ /**
135
+ * Returns the AV1 encoding parameters for a media request
136
+ * @param mediaRequest - The media request to get the AV1 encoding parameters for
137
+ * @returns {AV1EncodingParams} The AV1 encoding parameters
138
+ */
139
+ // eslint-disable-next-line class-methods-use-this
140
+ }, {
141
+ key: "getAv1EncodingParams",
142
+ value: function getAv1EncodingParams(mediaRequest) {
143
+ var _RESOLUTION_BUCKETS$f, _RESOLUTION_BUCKETS$f2;
144
+ var frameSize = mediaRequest.codecInfo.maxFs || _constants.H264_CODEC_PARAMETERS.maxFs;
145
+ var resolution = (_RESOLUTION_BUCKETS$f = (_RESOLUTION_BUCKETS$f2 = RESOLUTION_BUCKETS.find(function (_ref) {
146
+ var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
147
+ maxFs = _ref2[1];
148
+ return frameSize <= maxFs;
149
+ })) === null || _RESOLUTION_BUCKETS$f2 === void 0 ? void 0 : _RESOLUTION_BUCKETS$f2[0]) !== null && _RESOLUTION_BUCKETS$f !== void 0 ? _RESOLUTION_BUCKETS$f : '1080p';
150
+ return _constants.AV1_CODEC_PARAMETERS[resolution];
151
+ }
152
+ }, {
153
+ key: "buildH264CodecInfo",
154
+ value: function buildH264CodecInfo(mr) {
155
+ if (!mr.codecInfo) {
156
+ return undefined;
157
+ }
158
+ var h264PayloadType = this.getIngressPayloadTypeCallback(mr.receiveSlots[0].mediaType, _internalMediaCore.MediaCodecMimeType.H264);
159
+ if (h264PayloadType === undefined) {
160
+ return undefined;
161
+ }
162
+ return _internalMediaCore.CodecInfo.fromH264(h264PayloadType, new _internalMediaCore.H264Codec(mr.codecInfo.maxFs, mr.codecInfo.maxFps || _constants.H264_CODEC_PARAMETERS.maxFps, this.getH264MaxMbps(mr), mr.codecInfo.maxWidth, mr.codecInfo.maxHeight));
163
+ }
164
+ }, {
165
+ key: "buildAv1CodecInfo",
166
+ value: function buildAv1CodecInfo(mr) {
167
+ if (!this.enableAv1 || !mr.codecInfo) {
168
+ return undefined;
169
+ }
170
+ var av1PayloadType = this.getIngressPayloadTypeCallback(mr.receiveSlots[0].mediaType, _internalMediaCore.MediaCodecMimeType.AV1);
171
+ if (av1PayloadType === undefined) {
172
+ return undefined;
173
+ }
174
+ var av1EncodingParams = this.getAv1EncodingParams(mr);
175
+ return _internalMediaCore.CodecInfo.fromAv1(av1PayloadType, new _internalMediaCore.AV1Codec(av1EncodingParams.levelIdx, av1EncodingParams.tier, mr.codecInfo.maxWidth || av1EncodingParams.maxWidth, mr.codecInfo.maxHeight || av1EncodingParams.maxHeight, av1EncodingParams.maxPicSize, av1EncodingParams.maxDecodeRate));
176
+ }
177
+
134
178
  /** Modifies the passed in clientRequests and makes sure that in total they don't ask
135
179
  * for more streams than there are available.
136
180
  *
@@ -222,13 +266,16 @@ var MediaRequestManager = exports.MediaRequestManager = /*#__PURE__*/function ()
222
266
  // map all the client media requests to wcme stream requests
223
267
  (0, _values.default)(clientRequests).forEach(function (mr) {
224
268
  if (mr.receiveSlots.length > 0) {
269
+ var codecInfos = mr.codecInfo ? [_this2.buildH264CodecInfo(mr), _this2.buildAv1CodecInfo(mr)].filter(function (info) {
270
+ return info !== undefined;
271
+ }) : [];
225
272
  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
273
  return receiveSlot.wcmeReceiveSlot;
227
- }), _this2.getMaxPayloadBitsPerSecond(mr), mr.codecInfo && [_internalMediaCore.CodecInfo.fromH264(0x80, new _internalMediaCore.H264Codec(mr.codecInfo.maxFs, mr.codecInfo.maxFps || CODEC_DEFAULTS.h264.maxFps, _this2.getH264MaxMbps(mr), mr.codecInfo.maxWidth, mr.codecInfo.maxHeight))]));
274
+ }), _this2.getMaxPayloadBitsPerSecond(mr), codecInfos));
228
275
  }
229
276
  });
230
277
  this.sendMediaRequestsCallback(streamRequests);
231
- _loggerProxy.default.logger.info("multistream:sendRequests --> media requests sent. ");
278
+ _loggerProxy.default.logger.info("multistream:sendRequests --> media requests sent.");
232
279
  }
233
280
  }, {
234
281
  key: "addRequest",
@@ -238,8 +285,8 @@ var MediaRequestManager = exports.MediaRequestManager = /*#__PURE__*/function ()
238
285
  // eslint-disable-next-line no-plusplus
239
286
  var newId = "".concat(this.counter++);
240
287
  this.clientRequests[newId] = mediaRequest;
241
- var eventHandler = function eventHandler(_ref) {
242
- var maxFs = _ref.maxFs;
288
+ var eventHandler = function eventHandler(_ref3) {
289
+ var maxFs = _ref3.maxFs;
243
290
  mediaRequest.preferredMaxFs = maxFs;
244
291
  _this3.debouncedSourceUpdateListener();
245
292
  };
@@ -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,I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Ac,GAAG,CAAC,CAAC;MACxB,IAAI,CAACD,eAAe,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","_constants","DEBOUNCED_SOURCE_UPDATE_TIME","RESOLUTION_BUCKETS","MAX_FS_VALUES","MediaRequestManager","exports","sendMediaRequestsCallback","getIngressPayloadTypeCallback","options","_classCallCheck2","default","_defineProperty2","counter","numLiveSources","numTotalSources","clientRequests","degradationPreferences","kind","trimRequestsToNumOfSources","enableAv1","sourceUpdateListener","commit","bind","debouncedSourceUpdateListener","debounce","_createClass2","key","value","setDegradationPreferences","sendRequests","getDegradedClientRequests","_this","maxFsLimits","_loop","i","totalMacroblocksRequested","_values","forEach","mr","codecInfo","maxFs","Math","min","preferredMaxFs","H264_CODEC_PARAMETERS","slotsWithLiveSource","receiveSlots","filter","rs","sourceState","length","maxMacroblocksLimit","LoggerProxy","logger","warn","concat","getMaxPayloadBitsPerSecond","mediaRequest","RecommendedOpusBitrates","FB_MONO_MUSIC","getRecommendedMaxBitrateForFrameSize","getH264MaxMbps","maxFps","getAv1EncodingParams","_RESOLUTION_BUCKETS$f","_RESOLUTION_BUCKETS$f2","frameSize","resolution","find","_ref","_ref2","_slicedToArray2","AV1_CODEC_PARAMETERS","buildH264CodecInfo","undefined","h264PayloadType","mediaType","MediaCodecMimeType","H264","WcmeCodecInfo","fromH264","H264Codec","maxWidth","maxHeight","buildAv1CodecInfo","av1PayloadType","AV1","av1EncodingParams","fromAv1","AV1Codec","levelIdx","tier","maxPicSize","maxDecodeRate","trimRequests","preferLiveVideo","getPreferLiveVideo","numStreamsAvailable","sort","a","b","policyInfo","policy","priority","request","trimmedCount","Error","cloneClientRequests","cloneDeepWith","_toConsumableArray2","_this2","streamRequests","codecInfos","info","push","StreamRequest","Policy","ActiveSpeaker","ReceiverSelected","ActiveSpeakerInfo","crossPriorityDuplication","crossPolicyDuplication","namedMediaGroups","ReceiverSelectedInfo","csi","map","receiveSlot","wcmeReceiveSlot","addRequest","_this3","arguments","newId","eventHandler","_ref3","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 AV1Codec,\n SupportedResolution,\n AV1EncodingParams,\n MediaType,\n MediaCodecMimeType,\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';\nimport {AV1_CODEC_PARAMETERS, H264_CODEC_PARAMETERS} from './codec/constants';\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 DEBOUNCED_SOURCE_UPDATE_TIME = 1000;\n\nconst RESOLUTION_BUCKETS: Array<[SupportedResolution, number]> = [\n ['90p', MAX_FS_VALUES['90p']],\n ['180p', MAX_FS_VALUES['180p']],\n ['360p', MAX_FS_VALUES['360p']],\n ['540p', MAX_FS_VALUES['540p']],\n ['720p', MAX_FS_VALUES['720p']],\n];\n\ntype DegradationPreferences = {\n maxMacroblocksLimit: number;\n};\n\ntype SendMediaRequestsCallback = (streamRequests: StreamRequest[]) => void;\ntype GetIngressPayloadTypeCallback = (\n mediaType: MediaType,\n codecMimeType: MediaCodecMimeType\n) => number | undefined;\ntype Kind = 'audio' | 'video';\n\ntype AudioMediaRequestManagerOptions = {\n degradationPreferences: DegradationPreferences;\n kind: 'audio';\n trimRequestsToNumOfSources: boolean; // if enabled, AS speaker requests will be trimmed based on the calls to setNumCurrentSources()\n};\n\ntype VideoMediaRequestManagerOptions = {\n degradationPreferences: DegradationPreferences;\n kind: 'video';\n trimRequestsToNumOfSources: boolean;\n enableAv1?: boolean;\n};\n\ntype Options = AudioMediaRequestManagerOptions | VideoMediaRequestManagerOptions;\n\ntype ClientRequestsMap = {[key: MediaRequestId]: MediaRequest};\n\nexport class MediaRequestManager {\n private sendMediaRequestsCallback: SendMediaRequestsCallback;\n\n private getIngressPayloadTypeCallback: GetIngressPayloadTypeCallback;\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 enableAv1: boolean;\n private numTotalSources: number;\n private numLiveSources: number;\n\n constructor(\n sendMediaRequestsCallback: SendMediaRequestsCallback,\n getIngressPayloadTypeCallback: GetIngressPayloadTypeCallback,\n options: Options\n ) {\n this.sendMediaRequestsCallback = sendMediaRequestsCallback;\n this.getIngressPayloadTypeCallback = getIngressPayloadTypeCallback;\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.enableAv1 = options.kind === 'video' && !!options.enableAv1;\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 || H264_CODEC_PARAMETERS.maxFs,\n mr.codecInfo.maxFs || H264_CODEC_PARAMETERS.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 || H264_CODEC_PARAMETERS.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 || H264_CODEC_PARAMETERS.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 * Returns the AV1 encoding parameters for a media request\n * @param mediaRequest - The media request to get the AV1 encoding parameters for\n * @returns {AV1EncodingParams} The AV1 encoding parameters\n */\n // eslint-disable-next-line class-methods-use-this\n private getAv1EncodingParams(mediaRequest: MediaRequest): AV1EncodingParams {\n const frameSize = mediaRequest.codecInfo.maxFs || H264_CODEC_PARAMETERS.maxFs;\n const resolution = RESOLUTION_BUCKETS.find(([, maxFs]) => frameSize <= maxFs)?.[0] ?? '1080p';\n\n return AV1_CODEC_PARAMETERS[resolution];\n }\n\n private buildH264CodecInfo(mr: MediaRequest): WcmeCodecInfo | undefined {\n if (!mr.codecInfo) {\n return undefined;\n }\n\n const h264PayloadType = this.getIngressPayloadTypeCallback(\n mr.receiveSlots[0].mediaType,\n MediaCodecMimeType.H264\n );\n\n if (h264PayloadType === undefined) {\n return undefined;\n }\n\n return WcmeCodecInfo.fromH264(\n h264PayloadType,\n new H264Codec(\n mr.codecInfo.maxFs,\n mr.codecInfo.maxFps || H264_CODEC_PARAMETERS.maxFps,\n this.getH264MaxMbps(mr),\n mr.codecInfo.maxWidth,\n mr.codecInfo.maxHeight\n )\n );\n }\n\n private buildAv1CodecInfo(mr: MediaRequest): WcmeCodecInfo | undefined {\n if (!this.enableAv1 || !mr.codecInfo) {\n return undefined;\n }\n\n const av1PayloadType = this.getIngressPayloadTypeCallback(\n mr.receiveSlots[0].mediaType,\n MediaCodecMimeType.AV1\n );\n\n if (av1PayloadType === undefined) {\n return undefined;\n }\n\n const av1EncodingParams = this.getAv1EncodingParams(mr);\n\n return WcmeCodecInfo.fromAv1(\n av1PayloadType,\n new AV1Codec(\n av1EncodingParams.levelIdx,\n av1EncodingParams.tier,\n mr.codecInfo.maxWidth || av1EncodingParams.maxWidth,\n mr.codecInfo.maxHeight || av1EncodingParams.maxHeight,\n av1EncodingParams.maxPicSize,\n av1EncodingParams.maxDecodeRate\n )\n );\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 const codecInfos: WcmeCodecInfo[] = mr.codecInfo\n ? [this.buildH264CodecInfo(mr), this.buildAv1CodecInfo(mr)].filter(\n (info): info is WcmeCodecInfo => info !== undefined\n )\n : [];\n\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 codecInfos\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;AAgBA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AAvBA;;AAkDuC;;AAYvC,IAAMO,4BAA4B,GAAG,IAAI;AAEzC,IAAMC,kBAAwD,GAAG,CAC/D,CAAC,KAAK,EAAEC,0BAAa,CAAC,KAAK,CAAC,CAAC,EAC7B,CAAC,MAAM,EAAEA,0BAAa,CAAC,MAAM,CAAC,CAAC,EAC/B,CAAC,MAAM,EAAEA,0BAAa,CAAC,MAAM,CAAC,CAAC,EAC/B,CAAC,MAAM,EAAEA,0BAAa,CAAC,MAAM,CAAC,CAAC,EAC/B,CAAC,MAAM,EAAEA,0BAAa,CAAC,MAAM,CAAC,CAAC,CAChC;AAAC,IA8BWC,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA;EAsB9B,SAAAA,oBACEE,yBAAoD,EACpDC,6BAA4D,EAC5DC,OAAgB,EAChB;IAAA,IAAAC,gBAAA,CAAAC,OAAA,QAAAN,mBAAA;IAAA,IAAAO,gBAAA,CAAAD,OAAA;IAAA,IAAAC,gBAAA,CAAAD,OAAA;IAAA,IAAAC,gBAAA,CAAAD,OAAA;IAAA,IAAAC,gBAAA,CAAAD,OAAA;IAAA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tC,IAAI,CAACD,cAAc,GAAGA,cAAc;MAEpC,IAAI,CAACgB,YAAY,CAAC,CAAC;IACrB;EAAC;AAAA","ignoreList":[]}
@@ -70,6 +70,7 @@ declare const _default: {
70
70
  degradationPreferences: {
71
71
  maxMacroblocksLimit: number;
72
72
  };
73
+ enableAv1SlidesSupport: boolean;
73
74
  iceCandidatesGatheringTimeout: any;
74
75
  backendIpv6NativeSupport: boolean;
75
76
  enableReachabilityChecks: boolean;
@@ -516,6 +516,15 @@ export default class Meeting extends StatelessWebexPlugin {
516
516
  * @memberof Meeting
517
517
  */
518
518
  constructor(attrs: any, options: object, callback: (meeting: Meeting) => void);
519
+ /**
520
+ * Get the ingress payload type for a given media type and codec mime type
521
+ * @param {MediaType} mediaType - The media type
522
+ * @param {MediaCodecMimeType} codecMimeType - The codec mime type
523
+ * @returns {number | undefined} - The ingress payload type
524
+ * @private
525
+ * @memberof Meeting
526
+ */
527
+ private getIngressPayloadTypeCallback;
519
528
  /**
520
529
  * returns meeting is joined
521
530
  * @private
@@ -254,6 +254,16 @@ export default class Meetings extends WebexPlugin {
254
254
  * @returns {undefined}
255
255
  */
256
256
  private _toggleEnableAudioTwccForMultistream;
257
+ /**
258
+ * API to toggle AV1 codec support for video slides in multistream,
259
+ * needs to be called before webex.meetings.joinWithMedia()
260
+ *
261
+ * @param {Boolean} newValue
262
+ * @private
263
+ * @memberof Meetings
264
+ * @returns {undefined}
265
+ */
266
+ private _toggleEnableAv1SlidesSupport;
257
267
  /**
258
268
  * API to toggle stopping ICE Candidates Gathering after first relay candidate,
259
269
  * needs to be called before webex.meetings.joinWithMedia()
@@ -0,0 +1,7 @@
1
+ import { AV1EncodingParams, SupportedResolution } from '@webex/internal-media-core';
2
+ export declare const AV1_CODEC_PARAMETERS: Record<SupportedResolution, AV1EncodingParams>;
3
+ export declare const H264_CODEC_PARAMETERS: {
4
+ maxFs: number;
5
+ maxFps: number;
6
+ maxMbps: number;
7
+ };
@@ -1,4 +1,4 @@
1
- import { StreamRequest, NamedMediaGroup } from '@webex/internal-media-core';
1
+ import { StreamRequest, NamedMediaGroup, MediaType, MediaCodecMimeType } from '@webex/internal-media-core';
2
2
  import { ReceiveSlot } from './receiveSlot';
3
3
  export interface ActiveSpeakerPolicyInfo {
4
4
  policy: 'active-speaker';
@@ -36,14 +36,22 @@ type DegradationPreferences = {
36
36
  maxMacroblocksLimit: number;
37
37
  };
38
38
  type SendMediaRequestsCallback = (streamRequests: StreamRequest[]) => void;
39
- type Kind = 'audio' | 'video';
40
- type Options = {
39
+ type GetIngressPayloadTypeCallback = (mediaType: MediaType, codecMimeType: MediaCodecMimeType) => number | undefined;
40
+ type AudioMediaRequestManagerOptions = {
41
41
  degradationPreferences: DegradationPreferences;
42
- kind: Kind;
42
+ kind: 'audio';
43
43
  trimRequestsToNumOfSources: boolean;
44
44
  };
45
+ type VideoMediaRequestManagerOptions = {
46
+ degradationPreferences: DegradationPreferences;
47
+ kind: 'video';
48
+ trimRequestsToNumOfSources: boolean;
49
+ enableAv1?: boolean;
50
+ };
51
+ type Options = AudioMediaRequestManagerOptions | VideoMediaRequestManagerOptions;
45
52
  export declare class MediaRequestManager {
46
53
  private sendMediaRequestsCallback;
54
+ private getIngressPayloadTypeCallback;
47
55
  private kind;
48
56
  private counter;
49
57
  private clientRequests;
@@ -51,9 +59,10 @@ export declare class MediaRequestManager {
51
59
  private sourceUpdateListener;
52
60
  private debouncedSourceUpdateListener;
53
61
  private trimRequestsToNumOfSources;
62
+ private enableAv1;
54
63
  private numTotalSources;
55
64
  private numLiveSources;
56
- constructor(sendMediaRequestsCallback: SendMediaRequestsCallback, options: Options);
65
+ constructor(sendMediaRequestsCallback: SendMediaRequestsCallback, getIngressPayloadTypeCallback: GetIngressPayloadTypeCallback, options: Options);
57
66
  setDegradationPreferences(degradationPreferences: DegradationPreferences): void;
58
67
  private getDegradedClientRequests;
59
68
  /**
@@ -77,6 +86,14 @@ export declare class MediaRequestManager {
77
86
  * @returns {number} maxMbps
78
87
  */
79
88
  private getH264MaxMbps;
89
+ /**
90
+ * Returns the AV1 encoding parameters for a media request
91
+ * @param mediaRequest - The media request to get the AV1 encoding parameters for
92
+ * @returns {AV1EncodingParams} The AV1 encoding parameters
93
+ */
94
+ private getAv1EncodingParams;
95
+ private buildH264CodecInfo;
96
+ private buildAv1CodecInfo;
80
97
  /** Modifies the passed in clientRequests and makes sure that in total they don't ask
81
98
  * for more streams than there are available.
82
99
  *
@@ -774,7 +774,7 @@ var Webinar = _webexCore.WebexPlugin.extend({
774
774
  }, _callee1);
775
775
  }))();
776
776
  },
777
- version: "3.12.0-next.57"
777
+ version: "3.12.0-next.59"
778
778
  });
779
779
  var _default = exports.default = Webinar;
780
780
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -94,5 +94,5 @@
94
94
  "//": [
95
95
  "TODO: upgrade jwt-decode when moving to node 18"
96
96
  ],
97
- "version": "3.12.0-next.57"
97
+ "version": "3.12.0-next.59"
98
98
  }
@@ -986,6 +986,36 @@ const Breakouts = WebexPlugin.extend({
986
986
  body,
987
987
  });
988
988
  },
989
+ /**
990
+ * Remove participants from their current breakout session back to the main session
991
+ * @param {string[]} participants - participant IDs to remove from breakout
992
+ * @returns {Promise}
993
+ */
994
+ removeFromBreakout(participants: string[]) {
995
+ if (!this.mainGroupId || !this.mainSessionId) {
996
+ throw new Error(
997
+ 'Main group ID and session ID must be available to remove participants from breakout'
998
+ );
999
+ }
1000
+
1001
+ return this.request({
1002
+ method: HTTP_VERBS.POST,
1003
+ uri: `${this.url}/move`,
1004
+ body: {
1005
+ groups: [
1006
+ {
1007
+ id: this.mainGroupId,
1008
+ sessions: [
1009
+ {
1010
+ id: this.mainSessionId,
1011
+ participants,
1012
+ },
1013
+ ],
1014
+ },
1015
+ ],
1016
+ },
1017
+ });
1018
+ },
989
1019
  /**
990
1020
  * trigger ASK_RETURN_TO_MAIN event when main session requested
991
1021
  * @param {Object} breakout
package/src/config.ts CHANGED
@@ -94,6 +94,7 @@ export default {
94
94
  degradationPreferences: {
95
95
  maxMacroblocksLimit: 8192,
96
96
  },
97
+ enableAv1SlidesSupport: false,
97
98
  // This only applies to non-multistream meetings
98
99
  iceCandidatesGatheringTimeout: undefined,
99
100
  backendIpv6NativeSupport: false,
@@ -145,6 +145,7 @@ Media.createMediaConnection = (
145
145
  iceCandidatesTimeout?: number;
146
146
  disableAudioMainDtx?: boolean;
147
147
  enableAudioTwcc?: boolean;
148
+ enableAv1SlidesSupport?: boolean;
148
149
  stopIceGatheringAfterFirstRelayCandidate?: boolean;
149
150
  }
150
151
  ) => {
@@ -159,6 +160,7 @@ Media.createMediaConnection = (
159
160
  iceCandidatesTimeout,
160
161
  disableAudioMainDtx,
161
162
  enableAudioTwcc,
163
+ enableAv1SlidesSupport,
162
164
  stopIceGatheringAfterFirstRelayCandidate,
163
165
  } = options;
164
166
 
@@ -178,6 +180,7 @@ Media.createMediaConnection = (
178
180
  const config: MultistreamConnectionConfig = {
179
181
  iceServers,
180
182
  disableAudioTwcc: !enableAudioTwcc,
183
+ enableAV1SlidesSupport: !!enableAv1SlidesSupport,
181
184
  };
182
185
 
183
186
  if (bundlePolicy) {