@webex/plugin-meetings 3.0.0-beta.147 → 3.0.0-beta.149

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.
@@ -10,11 +10,9 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2
10
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
11
11
  var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
12
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
13
+ var _forEach2 = _interopRequireDefault(require("lodash/forEach"));
13
14
  var _loggerProxy = _interopRequireDefault(require("../common/logs/logger-proxy"));
14
15
  var _remoteMedia = require("./remoteMedia");
15
- /* eslint-disable valid-jsdoc */
16
- /* eslint-disable require-jsdoc */
17
- /* eslint-disable import/prefer-default-export */
18
16
  var RemoteMediaGroup = /*#__PURE__*/function () {
19
17
  // id of the "active-speaker" media request id
20
18
 
@@ -61,6 +59,52 @@ var RemoteMediaGroup = /*#__PURE__*/function () {
61
59
  return [].concat((0, _toConsumableArray2.default)(this.unpinnedRemoteMedia), (0, _toConsumableArray2.default)(this.pinnedRemoteMedia));
62
60
  }
63
61
 
62
+ /**
63
+ * Sets CSIs for multiple RemoteMedia instances belonging to this RemoteMediaGroup.
64
+ * For each entry in the remoteMediaCsis array:
65
+ * - if csi is specified, the RemoteMedia instance is pinned to that CSI
66
+ * - if csi is undefined, the RemoteMedia instance is unpinned
67
+ * @internal
68
+ */
69
+ }, {
70
+ key: "setActiveSpeakerCsis",
71
+ value: function setActiveSpeakerCsis(remoteMediaCsis) {
72
+ var _this2 = this;
73
+ var commit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
74
+ (0, _forEach2.default)(remoteMediaCsis, function (_ref) {
75
+ var csi = _ref.csi,
76
+ remoteMedia = _ref.remoteMedia;
77
+ if (csi) {
78
+ if (!(_this2.pinnedRemoteMedia.indexOf(remoteMedia) >= 0)) {
79
+ var unpinId = _this2.unpinnedRemoteMedia.indexOf(remoteMedia);
80
+ if (unpinId >= 0) {
81
+ _this2.unpinnedRemoteMedia.splice(unpinId, 1);
82
+ _this2.pinnedRemoteMedia.push(remoteMedia);
83
+ } else {
84
+ throw new Error("failed to pin a remote media object ".concat(remoteMedia.id, ", because it is not found in this remote media group"));
85
+ }
86
+ }
87
+ remoteMedia.sendMediaRequest(csi, false);
88
+ } else {
89
+ if (!(_this2.unpinnedRemoteMedia.indexOf(remoteMedia) >= 0)) {
90
+ var pinId = _this2.pinnedRemoteMedia.indexOf(remoteMedia);
91
+ if (pinId >= 0) {
92
+ _this2.pinnedRemoteMedia.splice(pinId, 1);
93
+ _this2.unpinnedRemoteMedia.push(remoteMedia);
94
+ } else {
95
+ throw new Error("failed to unpin a remote media object ".concat(remoteMedia.id, ", because it is not found in this remote media group"));
96
+ }
97
+ }
98
+ remoteMedia.cancelMediaRequest(false);
99
+ }
100
+ });
101
+ this.cancelActiveSpeakerMediaRequest(false);
102
+ this.sendActiveSpeakerMediaRequest(false);
103
+ if (commit) {
104
+ this.mediaRequestManager.commit();
105
+ }
106
+ }
107
+
64
108
  /**
65
109
  * Pins a specific remote media instance to a specfic CSI, so the media will
66
110
  * no longer come from active speaker, but from that CSI.
@@ -128,6 +172,11 @@ var RemoteMediaGroup = /*#__PURE__*/function () {
128
172
  }
129
173
  throw new Error("remote media object ".concat(remoteMedia.id, " not found in the group"));
130
174
  }
175
+
176
+ /**
177
+ * setPreferLiveVideo - sets preferLiveVideo to true/false
178
+ * @internal
179
+ */
131
180
  }, {
132
181
  key: "setPreferLiveVideo",
133
182
  value: function setPreferLiveVideo(preferLiveVideo, commit) {
@@ -1 +1 @@
1
- {"version":3,"names":["RemoteMediaGroup","mediaRequestManager","receiveSlots","priority","commitMediaRequest","options","unpinnedRemoteMedia","map","slot","RemoteMedia","resolution","pinnedRemoteMedia","sendActiveSpeakerMediaRequest","filter","remoteMedia","csi","targetCsi","Error","id","indexOf","LoggerProxy","logger","log","idx","splice","push","cancelActiveSpeakerMediaRequest","sendMediaRequest","commit","cancelMediaRequest","preferLiveVideo","mediaRequestId","addRequest","policyInfo","policy","crossPriorityDuplication","crossPolicyDuplication","getUnderlyingReceiveSlot","codecInfo","codec","maxFs","getMaxFs","cancelRequest","undefined","forEach","stop","includes"],"sources":["remoteMediaGroup.ts"],"sourcesContent":["/* eslint-disable valid-jsdoc */\n/* eslint-disable require-jsdoc */\n/* eslint-disable import/prefer-default-export */\nimport LoggerProxy from '../common/logs/logger-proxy';\n\nimport {getMaxFs, RemoteMedia, RemoteVideoResolution} from './remoteMedia';\nimport {MediaRequestId, MediaRequestManager} from './mediaRequestManager';\nimport {CSI, ReceiveSlot} from './receiveSlot';\n\ntype Options = {\n resolution?: RemoteVideoResolution; // applies only to groups of type MediaType.VideoMain and MediaType.VideoSlides\n preferLiveVideo?: boolean; // applies only to groups of type MediaType.VideoMain and MediaType.VideoSlides\n};\n\nexport class RemoteMediaGroup {\n private mediaRequestManager: MediaRequestManager;\n\n private priority: number;\n\n private options: Options;\n\n private unpinnedRemoteMedia: RemoteMedia[];\n\n private mediaRequestId?: MediaRequestId; // id of the \"active-speaker\" media request id\n\n private pinnedRemoteMedia: RemoteMedia[];\n\n constructor(\n mediaRequestManager: MediaRequestManager,\n receiveSlots: ReceiveSlot[],\n priority: number,\n commitMediaRequest: boolean,\n options: Options = {}\n ) {\n this.mediaRequestManager = mediaRequestManager;\n this.priority = priority;\n this.options = options;\n\n this.unpinnedRemoteMedia = receiveSlots.map(\n (slot) =>\n new RemoteMedia(slot, this.mediaRequestManager, {\n resolution: this.options.resolution,\n })\n );\n this.pinnedRemoteMedia = [];\n\n this.sendActiveSpeakerMediaRequest(commitMediaRequest);\n }\n\n /**\n * Gets the array of remote media elements from the group\n *\n * @param {string} filter - 'all' (default) returns both pinned and unpinned\n * @returns {Array<RemoteMedia>}\n */\n public getRemoteMedia(filter: 'all' | 'pinned' | 'unpinned' = 'all') {\n if (filter === 'unpinned') {\n // return a shallow copy so that the client cannot modify this.unpinnedRemoteMedia array\n return [...this.unpinnedRemoteMedia];\n }\n if (filter === 'pinned') {\n // return a shallow copy so that the client cannot modify this.pinnedRemoteMedia array\n return [...this.pinnedRemoteMedia];\n }\n\n return [...this.unpinnedRemoteMedia, ...this.pinnedRemoteMedia];\n }\n\n /**\n * Pins a specific remote media instance to a specfic CSI, so the media will\n * no longer come from active speaker, but from that CSI.\n * If no CSI is given, the current CSI value is used.\n *\n */\n public pin(remoteMedia: RemoteMedia, csi?: CSI): void {\n // if csi is not specified, use the current one\n const targetCsi = csi || remoteMedia.csi;\n\n if (!targetCsi) {\n throw new Error(\n `failed to pin a remote media object ${remoteMedia.id}, because it has no CSI set and no CSI value was given`\n );\n }\n\n if (this.pinnedRemoteMedia.indexOf(remoteMedia) >= 0) {\n if (targetCsi === remoteMedia.csi) {\n // remote media already pinned to target CSI, nothing to do\n LoggerProxy.logger.log(\n `RemoteMediaGroup#pin --> remote media ${remoteMedia.id} already pinned`\n );\n\n return;\n }\n } else {\n const idx = this.unpinnedRemoteMedia.indexOf(remoteMedia);\n\n if (idx < 0) {\n throw new Error(\n `failed to pin a remote media object ${remoteMedia.id}, because it is not found in this remote media group`\n );\n }\n\n this.unpinnedRemoteMedia.splice(idx, 1);\n this.pinnedRemoteMedia.push(remoteMedia);\n\n this.cancelActiveSpeakerMediaRequest(false);\n this.sendActiveSpeakerMediaRequest(false);\n }\n\n remoteMedia.sendMediaRequest(targetCsi, false);\n this.mediaRequestManager.commit();\n }\n\n /**\n * Unpins a remote media instance, so that it will again provide media from active speakers\n *\n */\n public unpin(remoteMedia: RemoteMedia) {\n if (this.unpinnedRemoteMedia.indexOf(remoteMedia) >= 0) {\n LoggerProxy.logger.log(\n `RemoteMediaGroup#pin --> remote media ${remoteMedia.id} already unpinned`\n );\n\n return;\n }\n const idx = this.pinnedRemoteMedia.indexOf(remoteMedia);\n\n if (idx < 0) {\n throw new Error(\n `failed to unpin a remote media object ${remoteMedia.id}, because it is not found in this remote media group`\n );\n }\n\n this.pinnedRemoteMedia.splice(idx, 1);\n this.unpinnedRemoteMedia.push(remoteMedia);\n\n remoteMedia.cancelMediaRequest(false);\n this.cancelActiveSpeakerMediaRequest(false);\n this.sendActiveSpeakerMediaRequest(false);\n this.mediaRequestManager.commit();\n }\n\n public isPinned(remoteMedia: RemoteMedia) {\n if (this.unpinnedRemoteMedia.indexOf(remoteMedia) >= 0) {\n return false;\n }\n if (this.pinnedRemoteMedia.indexOf(remoteMedia) >= 0) {\n return true;\n }\n\n throw new Error(`remote media object ${remoteMedia.id} not found in the group`);\n }\n\n public setPreferLiveVideo(preferLiveVideo: boolean, commit: boolean) {\n if (this.options.preferLiveVideo !== preferLiveVideo) {\n this.options.preferLiveVideo = preferLiveVideo;\n this.sendActiveSpeakerMediaRequest(commit);\n }\n }\n\n private sendActiveSpeakerMediaRequest(commit: boolean) {\n this.cancelActiveSpeakerMediaRequest(false);\n\n this.mediaRequestId = this.mediaRequestManager.addRequest(\n {\n policyInfo: {\n policy: 'active-speaker',\n priority: this.priority,\n crossPriorityDuplication: false,\n crossPolicyDuplication: false,\n preferLiveVideo: !!this.options?.preferLiveVideo,\n },\n receiveSlots: this.unpinnedRemoteMedia.map((remoteMedia) =>\n remoteMedia.getUnderlyingReceiveSlot()\n ) as ReceiveSlot[],\n codecInfo: this.options.resolution && {\n codec: 'h264',\n maxFs: getMaxFs(this.options.resolution),\n },\n },\n commit\n );\n }\n\n private cancelActiveSpeakerMediaRequest(commit: boolean) {\n if (this.mediaRequestId) {\n this.mediaRequestManager.cancelRequest(this.mediaRequestId, commit);\n this.mediaRequestId = undefined;\n }\n }\n\n /**\n * Invalidates the remote media group by clearing the references to the receive slots\n * used by all remote media from that group and cancelling all media requests.\n * After this call the remote media group is unusable.\n *\n * @param{boolean} commit whether to commit the cancellation of media requests\n * @internal\n */\n public stop(commit = true) {\n this.unpinnedRemoteMedia.forEach((remoteMedia) => remoteMedia.stop(false));\n this.pinnedRemoteMedia.forEach((remoteMedia) => remoteMedia.stop(false));\n this.cancelActiveSpeakerMediaRequest(false);\n\n if (commit) {\n this.mediaRequestManager.commit();\n }\n }\n\n /**\n * Checks if a given RemoteMedia instance belongs to this group.\n *\n * @param remoteMedia RemoteMedia instance to check\n * @param filter controls which remote media from the group to check\n * @returns true if remote media is found\n */\n public includes(\n remoteMedia: RemoteMedia,\n filter: 'all' | 'pinned' | 'unpinned' = 'all'\n ): boolean {\n if (filter === 'pinned') {\n return this.pinnedRemoteMedia.includes(remoteMedia);\n }\n if (filter === 'unpinned') {\n return this.unpinnedRemoteMedia.includes(remoteMedia);\n }\n\n return (\n this.unpinnedRemoteMedia.includes(remoteMedia) || this.pinnedRemoteMedia.includes(remoteMedia)\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AAGA;AAEA;AALA;AACA;AACA;AAAA,IAYaA,gBAAgB;EASc;;EAIzC,0BACEC,mBAAwC,EACxCC,YAA2B,EAC3BC,QAAgB,EAChBC,kBAA2B,EAE3B;IAAA;IAAA,IADAC,OAAgB,uEAAG,CAAC,CAAC;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAErB,IAAI,CAACJ,mBAAmB,GAAGA,mBAAmB;IAC9C,IAAI,CAACE,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACE,OAAO,GAAGA,OAAO;IAEtB,IAAI,CAACC,mBAAmB,GAAGJ,YAAY,CAACK,GAAG,CACzC,UAACC,IAAI;MAAA,OACH,IAAIC,wBAAW,CAACD,IAAI,EAAE,KAAI,CAACP,mBAAmB,EAAE;QAC9CS,UAAU,EAAE,KAAI,CAACL,OAAO,CAACK;MAC3B,CAAC,CAAC;IAAA,EACL;IACD,IAAI,CAACC,iBAAiB,GAAG,EAAE;IAE3B,IAAI,CAACC,6BAA6B,CAACR,kBAAkB,CAAC;EACxD;;EAEA;AACF;AACA;AACA;AACA;AACA;EALE;IAAA;IAAA,OAMA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AC;MAAA,EAAC;MAC1E,IAAI,CAAClC,iBAAiB,CAACiC,OAAO,CAAC,UAAC9B,WAAW;QAAA,OAAKA,WAAW,CAAC+B,IAAI,CAAC,KAAK,CAAC;MAAA,EAAC;MACxE,IAAI,CAACnB,+BAA+B,CAAC,KAAK,CAAC;MAE3C,IAAIE,MAAM,EAAE;QACV,IAAI,CAAC3B,mBAAmB,CAAC2B,MAAM,EAAE;MACnC;IACF;;IAEA;AACF;AACA;AACA;AACA;AACA;AACA;EANE;IAAA;IAAA,OAOA,kBACEd,WAAwB,EAEf;MAAA,IADTD,MAAqC,uEAAG,KAAK;MAE7C,IAAIA,MAAM,KAAK,QAAQ,EAAE;QACvB,OAAO,IAAI,CAACF,iBAAiB,CAACmC,QAAQ,CAAChC,WAAW,CAAC;MACrD;MACA,IAAID,MAAM,KAAK,UAAU,EAAE;QACzB,OAAO,IAAI,CAACP,mBAAmB,CAACwC,QAAQ,CAAChC,WAAW,CAAC;MACvD;MAEA,OACE,IAAI,CAACR,mBAAmB,CAACwC,QAAQ,CAAChC,WAAW,CAAC,IAAI,IAAI,CAACH,iBAAiB,CAACmC,QAAQ,CAAChC,WAAW,CAAC;IAElG;EAAC;EAAA;AAAA;AAAA"}
1
+ {"version":3,"names":["RemoteMediaGroup","mediaRequestManager","receiveSlots","priority","commitMediaRequest","options","unpinnedRemoteMedia","map","slot","RemoteMedia","resolution","pinnedRemoteMedia","sendActiveSpeakerMediaRequest","filter","remoteMediaCsis","commit","csi","remoteMedia","indexOf","unpinId","splice","push","Error","id","sendMediaRequest","pinId","cancelMediaRequest","cancelActiveSpeakerMediaRequest","targetCsi","LoggerProxy","logger","log","idx","preferLiveVideo","mediaRequestId","addRequest","policyInfo","policy","crossPriorityDuplication","crossPolicyDuplication","getUnderlyingReceiveSlot","codecInfo","codec","maxFs","getMaxFs","cancelRequest","undefined","forEach","stop","includes"],"sources":["remoteMediaGroup.ts"],"sourcesContent":["/* eslint-disable valid-jsdoc */\n/* eslint-disable require-jsdoc */\n/* eslint-disable import/prefer-default-export */\nimport {forEach} from 'lodash';\nimport LoggerProxy from '../common/logs/logger-proxy';\n\nimport {getMaxFs, RemoteMedia, RemoteVideoResolution} from './remoteMedia';\nimport {MediaRequestId, MediaRequestManager} from './mediaRequestManager';\nimport {CSI, ReceiveSlot} from './receiveSlot';\n\ntype Options = {\n resolution?: RemoteVideoResolution; // applies only to groups of type MediaType.VideoMain and MediaType.VideoSlides\n preferLiveVideo?: boolean; // applies only to groups of type MediaType.VideoMain and MediaType.VideoSlides\n};\n\nexport class RemoteMediaGroup {\n private mediaRequestManager: MediaRequestManager;\n\n private priority: number;\n\n private options: Options;\n\n private unpinnedRemoteMedia: RemoteMedia[];\n\n private mediaRequestId?: MediaRequestId; // id of the \"active-speaker\" media request id\n\n private pinnedRemoteMedia: RemoteMedia[];\n\n constructor(\n mediaRequestManager: MediaRequestManager,\n receiveSlots: ReceiveSlot[],\n priority: number,\n commitMediaRequest: boolean,\n options: Options = {}\n ) {\n this.mediaRequestManager = mediaRequestManager;\n this.priority = priority;\n this.options = options;\n\n this.unpinnedRemoteMedia = receiveSlots.map(\n (slot) =>\n new RemoteMedia(slot, this.mediaRequestManager, {\n resolution: this.options.resolution,\n })\n );\n this.pinnedRemoteMedia = [];\n\n this.sendActiveSpeakerMediaRequest(commitMediaRequest);\n }\n\n /**\n * Gets the array of remote media elements from the group\n *\n * @param {string} filter - 'all' (default) returns both pinned and unpinned\n * @returns {Array<RemoteMedia>}\n */\n public getRemoteMedia(filter: 'all' | 'pinned' | 'unpinned' = 'all') {\n if (filter === 'unpinned') {\n // return a shallow copy so that the client cannot modify this.unpinnedRemoteMedia array\n return [...this.unpinnedRemoteMedia];\n }\n if (filter === 'pinned') {\n // return a shallow copy so that the client cannot modify this.pinnedRemoteMedia array\n return [...this.pinnedRemoteMedia];\n }\n\n return [...this.unpinnedRemoteMedia, ...this.pinnedRemoteMedia];\n }\n\n /**\n * Sets CSIs for multiple RemoteMedia instances belonging to this RemoteMediaGroup.\n * For each entry in the remoteMediaCsis array:\n * - if csi is specified, the RemoteMedia instance is pinned to that CSI\n * - if csi is undefined, the RemoteMedia instance is unpinned\n * @internal\n */\n public setActiveSpeakerCsis(\n remoteMediaCsis: {remoteMedia: RemoteMedia; csi?: number}[],\n commit = true\n ): void {\n forEach(remoteMediaCsis, ({csi, remoteMedia}) => {\n if (csi) {\n if (!(this.pinnedRemoteMedia.indexOf(remoteMedia) >= 0)) {\n const unpinId = this.unpinnedRemoteMedia.indexOf(remoteMedia);\n if (unpinId >= 0) {\n this.unpinnedRemoteMedia.splice(unpinId, 1);\n this.pinnedRemoteMedia.push(remoteMedia);\n } else {\n throw new Error(\n `failed to pin a remote media object ${remoteMedia.id}, because it is not found in this remote media group`\n );\n }\n }\n remoteMedia.sendMediaRequest(csi, false);\n } else {\n if (!(this.unpinnedRemoteMedia.indexOf(remoteMedia) >= 0)) {\n const pinId = this.pinnedRemoteMedia.indexOf(remoteMedia);\n if (pinId >= 0) {\n this.pinnedRemoteMedia.splice(pinId, 1);\n this.unpinnedRemoteMedia.push(remoteMedia);\n } else {\n throw new Error(\n `failed to unpin a remote media object ${remoteMedia.id}, because it is not found in this remote media group`\n );\n }\n }\n remoteMedia.cancelMediaRequest(false);\n }\n });\n this.cancelActiveSpeakerMediaRequest(false);\n this.sendActiveSpeakerMediaRequest(false);\n if (commit) {\n this.mediaRequestManager.commit();\n }\n }\n\n /**\n * Pins a specific remote media instance to a specfic CSI, so the media will\n * no longer come from active speaker, but from that CSI.\n * If no CSI is given, the current CSI value is used.\n *\n */\n public pin(remoteMedia: RemoteMedia, csi?: CSI): void {\n // if csi is not specified, use the current one\n const targetCsi = csi || remoteMedia.csi;\n\n if (!targetCsi) {\n throw new Error(\n `failed to pin a remote media object ${remoteMedia.id}, because it has no CSI set and no CSI value was given`\n );\n }\n\n if (this.pinnedRemoteMedia.indexOf(remoteMedia) >= 0) {\n if (targetCsi === remoteMedia.csi) {\n // remote media already pinned to target CSI, nothing to do\n LoggerProxy.logger.log(\n `RemoteMediaGroup#pin --> remote media ${remoteMedia.id} already pinned`\n );\n\n return;\n }\n } else {\n const idx = this.unpinnedRemoteMedia.indexOf(remoteMedia);\n\n if (idx < 0) {\n throw new Error(\n `failed to pin a remote media object ${remoteMedia.id}, because it is not found in this remote media group`\n );\n }\n\n this.unpinnedRemoteMedia.splice(idx, 1);\n this.pinnedRemoteMedia.push(remoteMedia);\n\n this.cancelActiveSpeakerMediaRequest(false);\n this.sendActiveSpeakerMediaRequest(false);\n }\n\n remoteMedia.sendMediaRequest(targetCsi, false);\n this.mediaRequestManager.commit();\n }\n\n /**\n * Unpins a remote media instance, so that it will again provide media from active speakers\n *\n */\n public unpin(remoteMedia: RemoteMedia) {\n if (this.unpinnedRemoteMedia.indexOf(remoteMedia) >= 0) {\n LoggerProxy.logger.log(\n `RemoteMediaGroup#pin --> remote media ${remoteMedia.id} already unpinned`\n );\n\n return;\n }\n const idx = this.pinnedRemoteMedia.indexOf(remoteMedia);\n\n if (idx < 0) {\n throw new Error(\n `failed to unpin a remote media object ${remoteMedia.id}, because it is not found in this remote media group`\n );\n }\n\n this.pinnedRemoteMedia.splice(idx, 1);\n this.unpinnedRemoteMedia.push(remoteMedia);\n\n remoteMedia.cancelMediaRequest(false);\n this.cancelActiveSpeakerMediaRequest(false);\n this.sendActiveSpeakerMediaRequest(false);\n this.mediaRequestManager.commit();\n }\n\n public isPinned(remoteMedia: RemoteMedia) {\n if (this.unpinnedRemoteMedia.indexOf(remoteMedia) >= 0) {\n return false;\n }\n if (this.pinnedRemoteMedia.indexOf(remoteMedia) >= 0) {\n return true;\n }\n\n throw new Error(`remote media object ${remoteMedia.id} not found in the group`);\n }\n\n /**\n * setPreferLiveVideo - sets preferLiveVideo to true/false\n * @internal\n */\n public setPreferLiveVideo(preferLiveVideo: boolean, commit: boolean) {\n if (this.options.preferLiveVideo !== preferLiveVideo) {\n this.options.preferLiveVideo = preferLiveVideo;\n this.sendActiveSpeakerMediaRequest(commit);\n }\n }\n\n private sendActiveSpeakerMediaRequest(commit: boolean) {\n this.cancelActiveSpeakerMediaRequest(false);\n\n this.mediaRequestId = this.mediaRequestManager.addRequest(\n {\n policyInfo: {\n policy: 'active-speaker',\n priority: this.priority,\n crossPriorityDuplication: false,\n crossPolicyDuplication: false,\n preferLiveVideo: !!this.options?.preferLiveVideo,\n },\n receiveSlots: this.unpinnedRemoteMedia.map((remoteMedia) =>\n remoteMedia.getUnderlyingReceiveSlot()\n ) as ReceiveSlot[],\n codecInfo: this.options.resolution && {\n codec: 'h264',\n maxFs: getMaxFs(this.options.resolution),\n },\n },\n commit\n );\n }\n\n private cancelActiveSpeakerMediaRequest(commit: boolean) {\n if (this.mediaRequestId) {\n this.mediaRequestManager.cancelRequest(this.mediaRequestId, commit);\n this.mediaRequestId = undefined;\n }\n }\n\n /**\n * Invalidates the remote media group by clearing the references to the receive slots\n * used by all remote media from that group and cancelling all media requests.\n * After this call the remote media group is unusable.\n *\n * @param{boolean} commit whether to commit the cancellation of media requests\n * @internal\n */\n public stop(commit = true) {\n this.unpinnedRemoteMedia.forEach((remoteMedia) => remoteMedia.stop(false));\n this.pinnedRemoteMedia.forEach((remoteMedia) => remoteMedia.stop(false));\n this.cancelActiveSpeakerMediaRequest(false);\n\n if (commit) {\n this.mediaRequestManager.commit();\n }\n }\n\n /**\n * Checks if a given RemoteMedia instance belongs to this group.\n *\n * @param remoteMedia RemoteMedia instance to check\n * @param filter controls which remote media from the group to check\n * @returns true if remote media is found\n */\n public includes(\n remoteMedia: RemoteMedia,\n filter: 'all' | 'pinned' | 'unpinned' = 'all'\n ): boolean {\n if (filter === 'pinned') {\n return this.pinnedRemoteMedia.includes(remoteMedia);\n }\n if (filter === 'unpinned') {\n return this.unpinnedRemoteMedia.includes(remoteMedia);\n }\n\n return (\n this.unpinnedRemoteMedia.includes(remoteMedia) || this.pinnedRemoteMedia.includes(remoteMedia)\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAIA;AAEA;AAA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KAAK;MAE7C,IAAIA,MAAM,KAAK,QAAQ,EAAE;QACvB,OAAO,IAAI,CAACF,iBAAiB,CAACsC,QAAQ,CAAChC,WAAW,CAAC;MACrD;MACA,IAAIJ,MAAM,KAAK,UAAU,EAAE;QACzB,OAAO,IAAI,CAACP,mBAAmB,CAAC2C,QAAQ,CAAChC,WAAW,CAAC;MACvD;MAEA,OACE,IAAI,CAACX,mBAAmB,CAAC2C,QAAQ,CAAChC,WAAW,CAAC,IAAI,IAAI,CAACN,iBAAiB,CAACsC,QAAQ,CAAChC,WAAW,CAAC;IAElG;EAAC;EAAA;AAAA;AAAA"}
@@ -481,6 +481,27 @@ var RemoteMediaManager = /*#__PURE__*/function (_EventsScope) {
481
481
  this.mediaRequestManagers.video.commit();
482
482
  }
483
483
 
484
+ /**
485
+ * Sets CSIs for multiple RemoteMedia instances belonging to RemoteMediaGroup.
486
+ * For each entry in the remoteMediaCsis array:
487
+ * - if csi is specified, the RemoteMedia instance is pinned to that CSI
488
+ * - if csi is undefined, the RemoteMedia instance is unpinned
489
+ */
490
+ }, {
491
+ key: "setActiveSpeakerCsis",
492
+ value: function setActiveSpeakerCsis(remoteMediaCsis) {
493
+ (0, _values.default)(this.media.video.activeSpeakerGroups).forEach(function (remoteMediaGroup) {
494
+ var groupRemoteMediaCsis = remoteMediaCsis.filter(function (_ref) {
495
+ var remoteMedia = _ref.remoteMedia;
496
+ return remoteMediaGroup.includes(remoteMedia);
497
+ });
498
+ if (groupRemoteMediaCsis.length > 0) {
499
+ remoteMediaGroup.setActiveSpeakerCsis(groupRemoteMediaCsis, false);
500
+ }
501
+ });
502
+ this.mediaRequestManagers.video.commit();
503
+ }
504
+
484
505
  /**
485
506
  * Creates the audio slots
486
507
  */
@@ -1 +1 @@
1
- {"version":3,"names":["AllEqualLayout","activeSpeakerVideoPaneGroups","id","numPanes","size","priority","SingleLayout","OnePlusFiveLayout","TwoMainPlusSixSmallLayout","RemoteScreenShareWithSmallThumbnailsLayout","screenShareVideo","Stage2x2With6ThumbnailsLayout","memberVideoPanes","csi","undefined","DefaultConfiguration","audio","numOfActiveSpeakerStreams","numOfScreenShareStreams","video","preferLiveVideo","initialLayoutId","layouts","AllEqual","OnePlusFive","Single","Stage","ScreenShareView","Event","RemoteMediaManager","receiveSlotManager","mediaRequestManagers","config","started","media","activeSpeakerGroups","memberPanes","screenShare","checkConfigValidity","slots","unused","activeSpeaker","receiverSelected","receiveSlotAllocations","LoggerProxy","logger","log","Error","forEach","layout","groupIds","paneIds","groupPriorites","group","pane","createAudioMedia","createScreenShareReceiveSlots","createScreenShareAudioMedia","preallocateVideoReceiveSlots","setLayout","invalidateCurrentRemoteMedia","screenShareAudio","commit","slot","releaseSlot","length","push","releaseUnusedVideoSlots","currentLayout","currentLayoutId","activeSpeakerCount","reduce","sum","paneGroup","receiverSelectedCount","maxNumVideoPanesRequired","maxValue","Math","max","getRequiredNumVideoSlotsForLayout","allocateSlot","MediaType","VideoMain","layoutId","updateVideoReceiveSlots","updateVideoRemoteMediaObjects","updateScreenShareVideoRemoteMediaObject","emitVideoLayoutChangedEvent","activeSpeakerGroup","setPreferLiveVideo","i","AudioMain","RemoteMediaGroup","emit","file","function","AudioCreated","AudioSlides","isAnyLayoutContainingScreenShareVideo","some","VideoSlides","ScreenShareAudioCreated","requiredCsis","memberVideoPane","isCsiNeededByCurrentLayout","notNeededReceiverSelectedSlots","sort","a","b","paneIndex","freeSlot","shift","memberPane","existingSlot","find","isExistingSlotAlreadyAllocated","includes","pop","requiredNumSlots","totalNumSlots","numSlotsToCreate","logMessage","groupName","map","logString","join","key","trimActiveSpeakerSlots","trimReceiverSelectedSlots","refillRequiredSlotsIfNeeded","allocateSlotsToActiveSpeakerPaneGroups","allocateSlotsToReceiverSelectedVideoPaneGroups","logReceieveSlots","groupId","paneGroupInCurrentLayout","groupInLayout","mediaGroup","resolution","warn","paneId","paneInCurrentLayout","paneInLayout","remoteMedia","RemoteMedia","sendMediaRequest","options","stop","remoteMediaGroup","VideoLayoutChanged","activeSpeakerVideoPanes","getRemoteMedia","cancelMediaRequest","newPane","receiveSlot","reject","resolve","getUnderlyingReceiveSlot","index","indexOf","splice","pin","unpin","isPinned","EventsScope"],"sources":["remoteMediaManager.ts"],"sourcesContent":["/* eslint-disable valid-jsdoc */\nimport {cloneDeep, forEach, remove} from 'lodash';\nimport {EventMap} from 'typed-emitter';\nimport {MediaType} from '@webex/internal-media-core';\n\nimport LoggerProxy from '../common/logs/logger-proxy';\nimport EventsScope from '../common/events/events-scope';\n\nimport {RemoteMedia, RemoteVideoResolution} from './remoteMedia';\nimport {ReceiveSlot, CSI} from './receiveSlot';\nimport {ReceiveSlotManager} from './receiveSlotManager';\nimport {RemoteMediaGroup} from './remoteMediaGroup';\nimport {MediaRequestManager} from './mediaRequestManager';\n\nexport type PaneSize = RemoteVideoResolution;\nexport type LayoutId = string;\nexport type PaneId = string;\nexport type PaneGroupId = string;\n\nexport interface ActiveSpeakerVideoPaneGroup {\n id: PaneGroupId;\n numPanes: number; // maximum number of panes in the group (actual number may be lower, if there are not enough participants in the meeting)\n size: PaneSize; // preferred size for all panes in the group\n priority: number; // 0-255 (255 = highest priority), each group must have a different priority from all other groups\n}\n\nexport interface MemberVideoPane {\n id: PaneId;\n size: PaneSize;\n csi?: CSI;\n}\n\nexport interface VideoLayout {\n screenShareVideo?: {\n size: PaneSize;\n };\n activeSpeakerVideoPaneGroups?: ActiveSpeakerVideoPaneGroup[]; // list of active speaker video pane groups\n memberVideoPanes?: MemberVideoPane[]; // list of video panes for specific members, CSI values can be changed later via setVideoPaneCsi()\n}\n\nexport interface Configuration {\n audio: {\n numOfActiveSpeakerStreams: number; // number of audio streams we want to receive\n numOfScreenShareStreams: number; // 1 should be enough, because in webex only 1 person at a time can be presenting screen share\n };\n video: {\n preferLiveVideo: boolean; // applies to all pane groups with active speaker policy\n initialLayoutId: LayoutId;\n\n layouts: {[key: LayoutId]: VideoLayout}; // a map of all available layouts, a layout can be set via setLayout() method\n };\n}\n\n/* Predefined layouts: */\n\n// An \"all equal\" grid, with size up to 3 x 3 = 9:\nconst AllEqualLayout: VideoLayout = {\n activeSpeakerVideoPaneGroups: [\n {\n id: 'main',\n numPanes: 9,\n size: 'best',\n priority: 255,\n },\n ],\n};\n\n// A layout with just a single remote active speaker video pane:\nconst SingleLayout: VideoLayout = {\n activeSpeakerVideoPaneGroups: [\n {\n id: 'main',\n numPanes: 1,\n size: 'best',\n priority: 255,\n },\n ],\n};\n\n// A layout with 1 big pane for the highest priority active speaker and 5 small panes for other active speakers:\nconst OnePlusFiveLayout: VideoLayout = {\n activeSpeakerVideoPaneGroups: [\n {\n id: 'mainBigOne',\n numPanes: 1,\n size: 'large',\n priority: 255,\n },\n {\n id: 'secondarySetOfSmallPanes',\n numPanes: 5,\n size: 'very small',\n priority: 254,\n },\n ],\n};\n\n// A layout with 2 big panes for 2 main active speakers and a strip of 6 small panes for other active speakers:\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst TwoMainPlusSixSmallLayout: VideoLayout = {\n activeSpeakerVideoPaneGroups: [\n {\n id: 'mainGroupWith2BigPanes',\n numPanes: 2,\n size: 'large',\n priority: 255,\n },\n {\n id: 'secondaryGroupOfSmallPanes',\n numPanes: 6,\n size: 'small',\n priority: 254,\n },\n ],\n};\n\n// A strip of 8 small video panes (thumbnails) displayed at the top of a remote screenshare:\nconst RemoteScreenShareWithSmallThumbnailsLayout: VideoLayout = {\n screenShareVideo: {size: 'best'},\n activeSpeakerVideoPaneGroups: [\n {\n id: 'thumbnails',\n numPanes: 8,\n size: 'thumbnail',\n priority: 255,\n },\n ],\n};\n\n// A staged layout with 4 pre-selected meeting participants in the main 2x2 grid and 6 small panes for other active speakers at the top:\nconst Stage2x2With6ThumbnailsLayout: VideoLayout = {\n activeSpeakerVideoPaneGroups: [\n {\n id: 'thumbnails',\n numPanes: 6,\n size: 'thumbnail',\n priority: 255,\n },\n ],\n memberVideoPanes: [\n {id: 'stage-1', size: 'medium', csi: undefined},\n {id: 'stage-2', size: 'medium', csi: undefined},\n {id: 'stage-3', size: 'medium', csi: undefined},\n {id: 'stage-4', size: 'medium', csi: undefined},\n ],\n};\n\n/**\n * Default configuration:\n * - uses 3 audio streams\n * - prefers active speakers with live video (e.g. are not audio only or video muted) over active speakers without live video\n * - has a few layouts defined, including 1 that contains remote screen share (ScreenShareView)\n */\nexport const DefaultConfiguration: Configuration = {\n audio: {\n numOfActiveSpeakerStreams: 3,\n numOfScreenShareStreams: 1,\n },\n video: {\n preferLiveVideo: true,\n initialLayoutId: 'AllEqual',\n\n layouts: {\n AllEqual: AllEqualLayout,\n OnePlusFive: OnePlusFiveLayout,\n Single: SingleLayout,\n Stage: Stage2x2With6ThumbnailsLayout,\n ScreenShareView: RemoteScreenShareWithSmallThumbnailsLayout,\n },\n },\n};\n\nexport enum Event {\n // events for audio streams\n AudioCreated = 'AudioCreated',\n ScreenShareAudioCreated = 'ScreenShareAudioCreated',\n\n // events for video streams\n VideoLayoutChanged = 'VideoLayoutChanged',\n}\n\nexport interface VideoLayoutChangedEventData {\n layoutId: LayoutId;\n activeSpeakerVideoPanes: {\n [key: PaneGroupId]: RemoteMediaGroup;\n };\n memberVideoPanes: {[key: PaneId]: RemoteMedia};\n screenShareVideo?: RemoteMedia;\n}\nexport interface Events extends EventMap {\n // audio\n [Event.AudioCreated]: (audio: RemoteMediaGroup) => void;\n [Event.ScreenShareAudioCreated]: (screenShareAudio: RemoteMediaGroup) => void;\n\n // video\n [Event.VideoLayoutChanged]: (data: VideoLayoutChangedEventData) => void;\n}\n\n/**\n * A helper class that manages all remote audio/video streams in order to achieve a predefined set of layouts.\n * It also creates a fixed number of audio streams and these don't change during the meeting.\n *\n * Things that RemoteMediaManager does:\n * - owns the receive slots (creates them when needed, and re-uses them when switching layouts)\n * - constructs appropriate RemoteMedia and RemoteMediaGroup objects and sends appropriate mediaRequests\n */\nexport class RemoteMediaManager extends EventsScope {\n private config: Configuration;\n\n private started: boolean;\n\n private receiveSlotManager: ReceiveSlotManager;\n\n private mediaRequestManagers: {\n audio: MediaRequestManager;\n video: MediaRequestManager;\n screenShareAudio: MediaRequestManager;\n screenShareVideo: MediaRequestManager;\n };\n\n private currentLayout?: VideoLayout;\n\n private slots: {\n audio: ReceiveSlot[];\n screenShare: {\n audio: ReceiveSlot[];\n video?: ReceiveSlot;\n };\n video: {\n unused: ReceiveSlot[];\n activeSpeaker: ReceiveSlot[];\n receiverSelected: ReceiveSlot[];\n };\n };\n\n private media: {\n audio?: RemoteMediaGroup;\n video: {\n activeSpeakerGroups: {\n [key: PaneGroupId]: RemoteMediaGroup;\n };\n memberPanes: {[key: PaneId]: RemoteMedia};\n };\n screenShare: {\n audio?: RemoteMediaGroup;\n video?: RemoteMediaGroup;\n };\n };\n\n private receiveSlotAllocations: {\n activeSpeaker: {[key: PaneGroupId]: {slots: ReceiveSlot[]}};\n receiverSelected: {[key: PaneId]: ReceiveSlot};\n };\n\n private currentLayoutId?: LayoutId;\n\n /**\n * Constructor\n *\n * @param {ReceiveSlotManager} receiveSlotManager\n * @param {{audio: MediaRequestManager, video: mediaRequestManagers}} mediaRequestManagers\n * @param {Configuration} config Configuration describing what video layouts to use during the meeting\n */\n constructor(\n receiveSlotManager: ReceiveSlotManager,\n mediaRequestManagers: {\n audio: MediaRequestManager;\n video: MediaRequestManager;\n screenShareAudio: MediaRequestManager;\n screenShareVideo: MediaRequestManager;\n },\n config: Configuration = DefaultConfiguration\n ) {\n super();\n this.started = false;\n this.config = config;\n this.receiveSlotManager = receiveSlotManager;\n this.mediaRequestManagers = mediaRequestManagers;\n this.media = {\n audio: undefined,\n video: {\n activeSpeakerGroups: {},\n memberPanes: {},\n },\n screenShare: {\n audio: undefined,\n video: undefined,\n },\n };\n\n this.checkConfigValidity();\n\n this.slots = {\n audio: [],\n screenShare: {\n audio: [],\n video: undefined,\n },\n video: {\n unused: [],\n activeSpeaker: [],\n receiverSelected: [],\n },\n };\n\n this.receiveSlotAllocations = {activeSpeaker: {}, receiverSelected: {}};\n\n LoggerProxy.logger.log(\n `RemoteMediaManager#constructor --> RemoteMediaManager created with config: ${JSON.stringify(\n this.config\n )}`\n );\n }\n\n /**\n * Checks if configuration is valid, throws an error if it's not\n */\n private checkConfigValidity() {\n if (!(this.config.video.initialLayoutId in this.config.video.layouts)) {\n throw new Error(\n `invalid config: initialLayoutId \"${this.config.video.initialLayoutId}\" doesn't match any of the layouts`\n );\n }\n\n // check if each layout is valid\n Object.values(this.config.video.layouts).forEach((layout) => {\n const groupIds = {};\n const paneIds = {};\n const groupPriorites = {};\n\n layout.activeSpeakerVideoPaneGroups?.forEach((group) => {\n if (groupIds[group.id]) {\n throw new Error(\n `invalid config: duplicate active speaker video pane group id: ${group.id}`\n );\n }\n groupIds[group.id] = true;\n\n if (groupPriorites[group.priority]) {\n throw new Error(\n `invalid config: multiple active speaker video pane groups have same priority: ${group.priority}`\n );\n }\n groupPriorites[group.priority] = true;\n });\n\n layout.memberVideoPanes?.forEach((pane) => {\n if (paneIds[pane.id]) {\n throw new Error(`invalid config: duplicate member video pane id: ${pane.id}`);\n }\n paneIds[pane.id] = true;\n });\n });\n }\n\n /**\n * Starts the RemoteMediaManager.\n *\n * @returns {Promise}\n */\n public async start() {\n if (this.started) {\n throw new Error('start() failure: already started');\n }\n this.started = true;\n\n await this.createAudioMedia();\n\n await this.createScreenShareReceiveSlots();\n this.createScreenShareAudioMedia();\n\n await this.preallocateVideoReceiveSlots();\n\n await this.setLayout(this.config.video.initialLayoutId);\n }\n\n /**\n * Releases all the used resources (like allocated receive slots). This function needs\n * to be called when we leave the meeting, etc.\n */\n public stop() {\n // invalidate all remoteMedia objects\n this.invalidateCurrentRemoteMedia({\n audio: true,\n video: true,\n screenShareAudio: true,\n screenShareVideo: true,\n commit: true,\n });\n\n // release all audio receive slots\n this.slots.audio.forEach((slot) => this.receiveSlotManager.releaseSlot(slot));\n this.slots.audio.length = 0;\n\n // release screen share slots\n this.slots.screenShare.audio.forEach((slot) => this.receiveSlotManager.releaseSlot(slot));\n this.slots.screenShare.audio.length = 0;\n if (this.slots.screenShare.video) {\n this.receiveSlotManager.releaseSlot(this.slots.screenShare.video);\n this.slots.screenShare.video = undefined;\n }\n\n // release video slots\n this.receiveSlotAllocations = {activeSpeaker: {}, receiverSelected: {}};\n\n this.slots.video.unused.push(...this.slots.video.activeSpeaker);\n this.slots.video.activeSpeaker.length = 0;\n\n this.slots.video.unused.push(...this.slots.video.receiverSelected);\n this.slots.video.receiverSelected.length = 0;\n\n this.releaseUnusedVideoSlots();\n\n this.currentLayout = undefined;\n this.currentLayoutId = undefined;\n this.started = false;\n }\n\n /**\n * Returns the total number of main video panes required for a given layout\n *\n * @param {VideoLayout} layout\n * @returns {number}\n */\n private getRequiredNumVideoSlotsForLayout(layout?: VideoLayout) {\n if (!layout) {\n return 0;\n }\n\n const activeSpeakerCount =\n layout.activeSpeakerVideoPaneGroups?.reduce(\n (sum, paneGroup) => sum + paneGroup.numPanes,\n 0\n ) || 0;\n\n const receiverSelectedCount = layout.memberVideoPanes?.length || 0;\n\n return activeSpeakerCount + receiverSelectedCount;\n }\n\n /**\n * Allocates the maximum number of panes that any of the configured layouts will require.\n * We do this at the beginning, because it's more efficient (much faster) then allocating receive slots\n * later, after the SDP exchange was done.\n */\n private async preallocateVideoReceiveSlots() {\n const maxNumVideoPanesRequired = Object.values(this.config.video.layouts).reduce(\n (maxValue, layout) => Math.max(maxValue, this.getRequiredNumVideoSlotsForLayout(layout)),\n 0\n );\n\n while (this.slots.video.unused.length < maxNumVideoPanesRequired) {\n // eslint-disable-next-line no-await-in-loop\n this.slots.video.unused.push(\n // eslint-disable-next-line no-await-in-loop\n await this.receiveSlotManager.allocateSlot(MediaType.VideoMain)\n );\n }\n }\n\n /**\n * Changes the layout (triggers Event.VideoLayoutChanged)\n *\n * @param {LayoutId} layoutId new layout id\n * @returns {Promise}\n */\n public async setLayout(layoutId: LayoutId) {\n if (!(layoutId in this.config.video.layouts)) {\n throw new Error(\n `invalid layoutId: \"${layoutId}\" doesn't match any of the configured layouts`\n );\n }\n if (!this.started) {\n throw new Error('setLayout() called before start()');\n }\n this.currentLayoutId = layoutId;\n this.currentLayout = cloneDeep(this.config.video.layouts[this.currentLayoutId]);\n\n await this.updateVideoReceiveSlots();\n this.updateVideoRemoteMediaObjects();\n this.updateScreenShareVideoRemoteMediaObject();\n this.emitVideoLayoutChangedEvent();\n }\n\n /**\n * Returns the currently selected layout id\n *\n * @returns {LayoutId}\n */\n public getLayoutId(): LayoutId | undefined {\n return this.currentLayoutId;\n }\n\n /**\n * sets the preferLiveVideo\n */\n public setPreferLiveVideo(preferLiveVideo: boolean) {\n LoggerProxy.logger.log(\n `RemoteMediaManager#setPreferLiveVideo --> setPreferLiveVideo is called to set preferLiveVideo to ${preferLiveVideo}`\n );\n this.config.video.preferLiveVideo = preferLiveVideo;\n Object.values(this.media.video.activeSpeakerGroups).forEach((activeSpeakerGroup) => {\n activeSpeakerGroup.setPreferLiveVideo(preferLiveVideo, false);\n });\n this.mediaRequestManagers.video.commit();\n }\n\n /**\n * Creates the audio slots\n */\n private async createAudioMedia() {\n // create the audio receive slots\n for (let i = 0; i < this.config.audio.numOfActiveSpeakerStreams; i += 1) {\n // eslint-disable-next-line no-await-in-loop\n const slot = await this.receiveSlotManager.allocateSlot(MediaType.AudioMain);\n\n this.slots.audio.push(slot);\n }\n\n // create a remote media group\n this.media.audio = new RemoteMediaGroup(\n this.mediaRequestManagers.audio,\n this.slots.audio,\n 255,\n true\n );\n\n this.emit(\n {file: 'multistream/remoteMediaManager', function: 'createAudioMedia'},\n Event.AudioCreated,\n this.media.audio\n );\n }\n\n /**\n * Creates receive slots required for receiving screen share audio and video\n */\n private async createScreenShareReceiveSlots() {\n // audio\n for (let i = 0; i < this.config.audio.numOfScreenShareStreams; i += 1) {\n // eslint-disable-next-line no-await-in-loop\n const slot = await this.receiveSlotManager.allocateSlot(MediaType.AudioSlides);\n\n this.slots.screenShare.audio.push(slot);\n }\n\n // video\n const isAnyLayoutContainingScreenShareVideo = Object.values(this.config.video.layouts).some(\n (layout) => !!layout.screenShareVideo\n );\n\n if (isAnyLayoutContainingScreenShareVideo) {\n this.slots.screenShare.video = await this.receiveSlotManager.allocateSlot(\n MediaType.VideoSlides\n );\n }\n }\n\n /**\n * Creates RemoteMedia objects for screen share\n */\n private createScreenShareAudioMedia() {\n if (this.slots.screenShare.audio.length > 0) {\n this.media.screenShare.audio = new RemoteMediaGroup(\n this.mediaRequestManagers.screenShareAudio,\n this.slots.screenShare.audio,\n 255,\n true\n );\n\n this.emit(\n {file: 'multistream/remoteMediaManager', function: 'createScreenShareAudioMedia'},\n Event.ScreenShareAudioCreated,\n this.media.screenShare.audio\n );\n }\n }\n\n /**\n * Goes over all receiver-selected slots and keeps only the ones that are required by a given layout,\n * the rest are all moved to the \"unused\" list\n */\n private trimReceiverSelectedSlots() {\n const requiredCsis = {};\n\n // fill requiredCsis with all the CSIs that the given layout requires\n this.currentLayout?.memberVideoPanes?.forEach((memberVideoPane) => {\n if (memberVideoPane.csi !== undefined) {\n requiredCsis[memberVideoPane.csi] = true;\n }\n });\n\n const isCsiNeededByCurrentLayout = (csi?: CSI): boolean => {\n if (csi === undefined) {\n return false;\n }\n\n return !!requiredCsis[csi];\n };\n\n // keep receiverSelected slots that match our new requiredCsis, move the rest of receiverSelected slots to unused\n const notNeededReceiverSelectedSlots = remove(\n this.slots.video.receiverSelected,\n (slot) => isCsiNeededByCurrentLayout(slot.csi) === false\n );\n\n this.slots.video.unused.push(...notNeededReceiverSelectedSlots);\n }\n\n /**\n * Releases all the \"unused\" video slots.\n */\n private releaseUnusedVideoSlots() {\n this.slots.video.unused.forEach((slot) => this.receiveSlotManager.releaseSlot(slot));\n this.slots.video.unused.length = 0;\n }\n\n /**\n * Allocates receive slots to all active speaker video panes\n * in the current selected layout.\n *\n * Allocation tries to keep the same order of the slots between the previous\n * layout and the new one. Sorting helps making sure that highest priority slots\n * go in the same order in the new layout.\n */\n private allocateSlotsToActiveSpeakerPaneGroups() {\n this.currentLayout?.activeSpeakerVideoPaneGroups\n // sorting in descending order based on group priority\n ?.sort((a, b) => (a.priority < b.priority ? 1 : -1))\n ?.forEach((group) => {\n this.receiveSlotAllocations.activeSpeaker[group.id] = {slots: []};\n\n for (let paneIndex = 0; paneIndex < group.numPanes; paneIndex += 1) {\n // allocate a slot from the \"unused\" list, by grabbing in same order (shift) as previous layout\n const freeSlot = this.slots.video.unused.shift();\n\n if (freeSlot) {\n this.slots.video.activeSpeaker.push(freeSlot);\n this.receiveSlotAllocations.activeSpeaker[group.id].slots.push(freeSlot);\n }\n }\n });\n }\n\n /**\n * Allocates receive slots to all receiver selected video panes\n * in the current selected layout\n */\n private allocateSlotsToReceiverSelectedVideoPaneGroups() {\n this.currentLayout?.memberVideoPanes?.forEach((memberPane) => {\n // check if there is existing slot for this csi\n const existingSlot = this.slots.video.receiverSelected.find(\n (slot) => slot.csi === memberPane.csi\n );\n\n const isExistingSlotAlreadyAllocated = Object.values(\n this.receiveSlotAllocations.receiverSelected\n ).includes(existingSlot);\n\n if (memberPane.csi !== undefined && existingSlot && !isExistingSlotAlreadyAllocated) {\n // found it, so use it\n this.receiveSlotAllocations.receiverSelected[memberPane.id] = existingSlot;\n } else {\n // allocate a slot from the \"unused\" list\n const freeSlot = this.slots.video.unused.pop();\n\n if (freeSlot) {\n this.slots.video.receiverSelected.push(freeSlot);\n this.receiveSlotAllocations.receiverSelected[memberPane.id] = freeSlot;\n }\n }\n });\n }\n\n /**\n * Ensures that we have enough slots for the current layout.\n */\n private async refillRequiredSlotsIfNeeded() {\n const requiredNumSlots = this.getRequiredNumVideoSlotsForLayout(this.currentLayout);\n const totalNumSlots =\n this.slots.video.unused.length +\n this.slots.video.activeSpeaker.length +\n this.slots.video.receiverSelected.length;\n\n if (totalNumSlots < requiredNumSlots) {\n let numSlotsToCreate = requiredNumSlots - totalNumSlots;\n\n while (numSlotsToCreate > 0) {\n // eslint-disable-next-line no-await-in-loop\n this.slots.video.unused.push(\n // eslint-disable-next-line no-await-in-loop\n await this.receiveSlotManager.allocateSlot(MediaType.VideoMain)\n );\n numSlotsToCreate -= 1;\n }\n }\n }\n\n /**\n * Move all active speaker slots to \"unused\"\n */\n private trimActiveSpeakerSlots() {\n this.slots.video.unused.push(...this.slots.video.activeSpeaker);\n this.slots.video.activeSpeaker.length = 0;\n }\n\n /**\n * Logs the state of the receive slots\n */\n private logReceieveSlots() {\n let logMessage = '';\n forEach(this.receiveSlotAllocations.activeSpeaker, (group, groupName) => {\n logMessage += `group: ${groupName}\\n${group.slots.map((slot) => slot.logString).join(' ')}`;\n });\n\n logMessage += '\\nreceiverSelected:\\n';\n forEach(this.receiveSlotAllocations.receiverSelected, (slot, key) => {\n logMessage += ` ${key}: ${slot.logString}\\n`;\n });\n\n LoggerProxy.logger.log(\n `RemoteMediaManager#updateVideoReceiveSlots --> receive slots updated: unused=${this.slots.video.unused.length}, activeSpeaker=${this.slots.video.activeSpeaker.length}, receiverSelected=${this.slots.video.receiverSelected.length}\\n${logMessage}`\n );\n }\n\n /**\n * Makes sure we have the right number of receive slots created for the current layout\n * and allocates them to the right video panes / pane groups\n *\n * @returns {Promise}\n */\n private async updateVideoReceiveSlots() {\n // move all active speaker slots to \"unused\"\n this.trimActiveSpeakerSlots();\n\n // move all no longer needed receiver-selected slots to \"unused\"\n this.trimReceiverSelectedSlots();\n\n // ensure we have enough total slots for current layout\n await this.refillRequiredSlotsIfNeeded();\n\n // allocate the slots to the right panes / pane groups\n // reset allocations\n this.receiveSlotAllocations = {activeSpeaker: {}, receiverSelected: {}};\n // allocate active speaker\n this.allocateSlotsToActiveSpeakerPaneGroups();\n // allocate receiver selected\n this.allocateSlotsToReceiverSelectedVideoPaneGroups();\n\n this.logReceieveSlots();\n\n // If this is the initial layout, there may be some \"unused\" slots left because of the preallocation\n // done in this.preallocateVideoReceiveSlots(), so release them now\n this.releaseUnusedVideoSlots();\n }\n\n /**\n * Creates new RemoteMedia and RemoteMediaGroup objects for the current layout\n * and sends the media requests for all of them.\n */\n private updateVideoRemoteMediaObjects() {\n // invalidate all the previous remote media objects and cancel their media requests\n this.invalidateCurrentRemoteMedia({\n audio: false,\n video: true,\n screenShareAudio: false,\n screenShareVideo: false,\n commit: false,\n });\n\n // create new remoteMediaGroup objects\n this.media.video.activeSpeakerGroups = {};\n this.media.video.memberPanes = {};\n\n for (const [groupId, group] of Object.entries(this.receiveSlotAllocations.activeSpeaker)) {\n const paneGroupInCurrentLayout = this.currentLayout?.activeSpeakerVideoPaneGroups?.find(\n (groupInLayout) => groupInLayout.id === groupId\n );\n\n if (paneGroupInCurrentLayout) {\n const mediaGroup = new RemoteMediaGroup(\n this.mediaRequestManagers.video,\n group.slots,\n paneGroupInCurrentLayout.priority,\n false,\n {\n preferLiveVideo: this.config.video.preferLiveVideo,\n resolution: paneGroupInCurrentLayout.size,\n }\n );\n\n this.media.video.activeSpeakerGroups[groupId] = mediaGroup;\n } else {\n // this should never happen, because this.receiveSlotAllocations are created based on current layout configuration\n LoggerProxy.logger.warn(\n `a group id ${groupId} from this.receiveSlotAllocations.activeSpeaker cannot be found in the current layout configuration`\n );\n }\n }\n\n // create new remoteMedia objects\n for (const [paneId, slot] of Object.entries(this.receiveSlotAllocations.receiverSelected)) {\n const paneInCurrentLayout = this.currentLayout?.memberVideoPanes?.find(\n (paneInLayout) => paneInLayout.id === paneId\n );\n\n if (paneInCurrentLayout) {\n const remoteMedia = new RemoteMedia(slot, this.mediaRequestManagers.video, {\n resolution: paneInCurrentLayout.size,\n });\n\n if (paneInCurrentLayout.csi) {\n remoteMedia.sendMediaRequest(paneInCurrentLayout.csi, false);\n }\n\n this.media.video.memberPanes[paneId] = remoteMedia;\n } else {\n // this should never happen, because this.receiveSlotAllocations are created based on current layout configuration\n LoggerProxy.logger.warn(\n `a pane id ${paneId} from this.receiveSlotAllocations.receiverSelected cannot be found in the current layout configuration`\n );\n }\n }\n\n this.mediaRequestManagers.video.commit();\n }\n\n /**\n * Checks if current layout requires a screen share.\n * If it does, it creates new RemoteMediaGroup object for screen share\n * and sends the media requests for it.\n * If it doesn't, it makes sure we clean up any RemoteMediaGroup objects\n * created earlier for screen share (for previous layout).\n */\n private updateScreenShareVideoRemoteMediaObject() {\n this.invalidateCurrentRemoteMedia({\n audio: false,\n video: false,\n screenShareAudio: false,\n screenShareVideo: true,\n commit: false,\n });\n\n this.media.screenShare.video = undefined;\n\n if (this.currentLayout?.screenShareVideo) {\n // we create a group of 1, because for screen share we need to use the \"active speaker\" policy\n this.media.screenShare.video = new RemoteMediaGroup(\n this.mediaRequestManagers.screenShareVideo,\n [this.slots.screenShare.video],\n 255,\n false,\n {resolution: this.currentLayout.screenShareVideo.size}\n );\n }\n\n this.mediaRequestManagers.screenShareVideo.commit();\n }\n\n /**\n * Invalidates all remote media objects belonging to currently selected layout\n */\n private invalidateCurrentRemoteMedia(options: {\n audio: boolean;\n video: boolean;\n screenShareAudio: boolean;\n screenShareVideo: boolean;\n commit: boolean;\n }) {\n const {audio, video, screenShareAudio, screenShareVideo, commit} = options;\n\n if (audio && this.media.audio) {\n this.media.audio.stop(commit);\n }\n if (video) {\n Object.values(this.media.video.activeSpeakerGroups).forEach((remoteMediaGroup) => {\n remoteMediaGroup.stop(false);\n });\n Object.values(this.media.video.memberPanes).forEach((remoteMedia) => {\n remoteMedia.stop(false);\n });\n if (commit) {\n this.mediaRequestManagers.video.commit();\n }\n }\n\n if (screenShareAudio && this.media.screenShare.audio) {\n this.media.screenShare.audio.stop(commit);\n }\n if (screenShareVideo && this.media.screenShare.video) {\n this.media.screenShare.video.stop(commit);\n }\n }\n\n /** emits Event.VideoLayoutChanged */\n private emitVideoLayoutChangedEvent() {\n // todo: at this point the receive slots might still be showing a participant from previous layout, we should\n // wait for our media requests to be fulfilled, but there is no API for that right now (we could wait for source updates\n // but in some cases they might never come, or would need to always make sure to use a new set of receiver slots)\n // for now it's fine to have it like this, we will re-evaluate if it needs improving after more testing\n\n this.emit(\n {\n file: 'multistream/remoteMediaManager',\n function: 'emitVideoLayoutChangedEvent',\n },\n Event.VideoLayoutChanged,\n {\n layoutId: this.currentLayoutId,\n activeSpeakerVideoPanes: this.media.video.activeSpeakerGroups,\n memberVideoPanes: this.media.video.memberPanes,\n screenShareVideo: this.media.screenShare.video?.getRemoteMedia()[0],\n }\n );\n }\n\n /**\n * Sets a new CSI on a given remote media object\n *\n * @param {RemoteMedia} remoteMedia remote Media object to modify\n * @param {CSI} csi new CSI value, can be null if we want to stop receiving media\n */\n public setRemoteVideoCsi(remoteMedia: RemoteMedia, csi: CSI | null) {\n if (!Object.values(this.media.video.memberPanes).includes(remoteMedia)) {\n throw new Error('remoteMedia not found');\n }\n\n if (csi) {\n remoteMedia.sendMediaRequest(csi, true);\n } else {\n remoteMedia.cancelMediaRequest(true);\n }\n }\n\n /**\n * Adds a new member video pane to the currently selected layout.\n *\n * Changes to the layout are lost after a layout change.\n *\n * @param {MemberVideoPane} newPane\n * @returns {Promise<RemoteMedia>}\n */\n public async addMemberVideoPane(newPane: MemberVideoPane): Promise<RemoteMedia> {\n if (!this.currentLayout) {\n throw new Error('There is no current layout selected, call start() first');\n }\n\n if (!this.currentLayout?.memberVideoPanes) {\n this.currentLayout.memberVideoPanes = [];\n }\n\n if (newPane.id in this.currentLayout.memberVideoPanes) {\n throw new Error(\n `duplicate pane id ${newPane.id} - this pane already exists in current layout's memberVideoPanes`\n );\n }\n\n this.currentLayout.memberVideoPanes.push(newPane);\n\n const receiveSlot = await this.receiveSlotManager.allocateSlot(MediaType.VideoMain);\n\n this.slots.video.receiverSelected.push(receiveSlot);\n\n const remoteMedia = new RemoteMedia(receiveSlot, this.mediaRequestManagers.video, {\n resolution: newPane.size,\n });\n\n if (newPane.csi) {\n remoteMedia.sendMediaRequest(newPane.csi, true);\n }\n\n this.media.video.memberPanes[newPane.id] = remoteMedia;\n\n return remoteMedia;\n }\n\n /**\n * Removes a member video pane from the currently selected layout.\n *\n * Changes to the layout are lost after a layout change.\n *\n * @param {PaneId} paneId pane id of the pane to remove\n * @returns {Promise<void>}\n */\n public removeMemberVideoPane(paneId: PaneId): Promise<void> {\n if (!this.currentLayout) {\n return Promise.reject(new Error('There is no current layout selected, call start() first'));\n }\n\n if (!this.currentLayout.memberVideoPanes?.find((pane) => pane.id === paneId)) {\n // pane id doesn't exist, so nothing to do\n LoggerProxy.logger.log(\n `RemoteMediaManager#removeMemberVideoPane --> removeMemberVideoPane() called for a non-existent paneId: ${paneId} (pane not found in currentLayout.memberVideoPanes)`\n );\n\n return Promise.resolve();\n }\n\n if (!this.media.video.memberPanes[paneId]) {\n // pane id doesn't exist, so nothing to do\n LoggerProxy.logger.log(\n `RemoteMediaManager#removeMemberVideoPane --> removeMemberVideoPane() called for a non-existent paneId: ${paneId} (pane not found in this.media.video.memberPanes)`\n );\n\n return Promise.resolve();\n }\n\n const remoteMedia = this.media.video.memberPanes[paneId];\n\n const receiveSlot = remoteMedia.getUnderlyingReceiveSlot();\n\n if (receiveSlot) {\n this.receiveSlotManager.releaseSlot(receiveSlot);\n\n const index = this.slots.video.receiverSelected.indexOf(receiveSlot);\n\n if (index >= 0) {\n this.slots.video.receiverSelected.splice(index, 1);\n }\n }\n remoteMedia.stop();\n\n delete this.media.video.memberPanes[paneId];\n delete this.currentLayout.memberVideoPanes?.[paneId];\n\n return Promise.resolve();\n }\n\n /**\n * Pins an active speaker remote media object to the given CSI value. From that moment\n * onwards the remote media will only play audio/video from that specific CSI until\n * unpinActiveSpeakerVideoPane() is called or current layout is changed.\n *\n * @param {RemoteMedia} remoteMedia remote media object reference\n * @param {CSI} csi CSI value to pin to, if undefined, then current CSI value is used\n */\n public pinActiveSpeakerVideoPane(remoteMedia: RemoteMedia, csi?: CSI): void {\n const remoteMediaGroup = Object.values(this.media.video.activeSpeakerGroups).find((group) =>\n group.includes(remoteMedia, 'unpinned')\n );\n\n if (!remoteMediaGroup) {\n throw new Error(\n 'remoteMedia not found among the unpinned remote media from any active speaker group'\n );\n }\n\n remoteMediaGroup.pin(remoteMedia, csi);\n }\n\n /**\n * Unpins a remote media object from the fixed CSI value it was pinned to.\n *\n * @param {RemoteMedia} remoteMedia remote media object reference\n */\n public unpinActiveSpeakerVideoPane(remoteMedia: RemoteMedia) {\n const remoteMediaGroup = Object.values(this.media.video.activeSpeakerGroups).find((group) =>\n group.includes(remoteMedia, 'pinned')\n );\n\n if (!remoteMediaGroup) {\n throw new Error(\n 'remoteMedia not found among the pinned remote media from any active speaker group'\n );\n }\n\n remoteMediaGroup.unpin(remoteMedia);\n }\n\n /**\n * Returns true if a given remote media object belongs to an active speaker group and has been pinned.\n * Throws an error if the remote media object doesn't belong to any active speaker remote media group.\n *\n * @param {RemoteMedia} remoteMedia remote media object\n * @returns {boolean}\n */\n public isPinned(remoteMedia: RemoteMedia) {\n const remoteMediaGroup = Object.values(this.media.video.activeSpeakerGroups).find((group) =>\n group.includes(remoteMedia)\n );\n\n if (!remoteMediaGroup) {\n throw new Error(\n 'remoteMedia not found among any remote media (pinned or unpinned) from any active speaker group'\n );\n }\n\n return remoteMediaGroup.isPinned(remoteMedia);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;AAEA;AACA;AAEA;AAGA;AAAoD;AAAA;AA0CpD;;AAEA;AACA,IAAMA,cAA2B,GAAG;EAClCC,4BAA4B,EAAE,CAC5B;IACEC,EAAE,EAAE,MAAM;IACVC,QAAQ,EAAE,CAAC;IACXC,IAAI,EAAE,MAAM;IACZC,QAAQ,EAAE;EACZ,CAAC;AAEL,CAAC;;AAED;AACA,IAAMC,YAAyB,GAAG;EAChCL,4BAA4B,EAAE,CAC5B;IACEC,EAAE,EAAE,MAAM;IACVC,QAAQ,EAAE,CAAC;IACXC,IAAI,EAAE,MAAM;IACZC,QAAQ,EAAE;EACZ,CAAC;AAEL,CAAC;;AAED;AACA,IAAME,iBAA8B,GAAG;EACrCN,4BAA4B,EAAE,CAC5B;IACEC,EAAE,EAAE,YAAY;IAChBC,QAAQ,EAAE,CAAC;IACXC,IAAI,EAAE,OAAO;IACbC,QAAQ,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F;AACA;AACA;AACA;EAJE;IAAA;IAAA,OAKA,qCAAmCiI,WAAwB,EAAE;MAC3D,IAAMK,gBAAgB,GAAG,qBAAc,IAAI,CAACjH,KAAK,CAACf,KAAK,CAACgB,mBAAmB,CAAC,CAAC+E,IAAI,CAAC,UAAC7D,KAAK;QAAA,OACtFA,KAAK,CAAC+D,QAAQ,CAAC0B,WAAW,EAAE,QAAQ,CAAC;MAAA,EACtC;MAED,IAAI,CAACK,gBAAgB,EAAE;QACrB,MAAM,IAAIpG,KAAK,CACb,mFAAmF,CACpF;MACH;MAEAoG,gBAAgB,CAACc,KAAK,CAACnB,WAAW,CAAC;IACrC;;IAEA;AACF;AACA;AACA;AACA;AACA;AACA;EANE;IAAA;IAAA,OAOA,kBAAgBA,WAAwB,EAAE;MACxC,IAAMK,gBAAgB,GAAG,qBAAc,IAAI,CAACjH,KAAK,CAACf,KAAK,CAACgB,mBAAmB,CAAC,CAAC+E,IAAI,CAAC,UAAC7D,KAAK;QAAA,OACtFA,KAAK,CAAC+D,QAAQ,CAAC0B,WAAW,CAAC;MAAA,EAC5B;MAED,IAAI,CAACK,gBAAgB,EAAE;QACrB,MAAM,IAAIpG,KAAK,CACb,iGAAiG,CAClG;MACH;MAEA,OAAOoG,gBAAgB,CAACe,QAAQ,CAACpB,WAAW,CAAC;IAC/C;EAAC;EAAA;AAAA,EAl3BqCqB,oBAAW;AAAA"}
1
+ {"version":3,"names":["AllEqualLayout","activeSpeakerVideoPaneGroups","id","numPanes","size","priority","SingleLayout","OnePlusFiveLayout","TwoMainPlusSixSmallLayout","RemoteScreenShareWithSmallThumbnailsLayout","screenShareVideo","Stage2x2With6ThumbnailsLayout","memberVideoPanes","csi","undefined","DefaultConfiguration","audio","numOfActiveSpeakerStreams","numOfScreenShareStreams","video","preferLiveVideo","initialLayoutId","layouts","AllEqual","OnePlusFive","Single","Stage","ScreenShareView","Event","RemoteMediaManager","receiveSlotManager","mediaRequestManagers","config","started","media","activeSpeakerGroups","memberPanes","screenShare","checkConfigValidity","slots","unused","activeSpeaker","receiverSelected","receiveSlotAllocations","LoggerProxy","logger","log","Error","forEach","layout","groupIds","paneIds","groupPriorites","group","pane","createAudioMedia","createScreenShareReceiveSlots","createScreenShareAudioMedia","preallocateVideoReceiveSlots","setLayout","invalidateCurrentRemoteMedia","screenShareAudio","commit","slot","releaseSlot","length","push","releaseUnusedVideoSlots","currentLayout","currentLayoutId","activeSpeakerCount","reduce","sum","paneGroup","receiverSelectedCount","maxNumVideoPanesRequired","maxValue","Math","max","getRequiredNumVideoSlotsForLayout","allocateSlot","MediaType","VideoMain","layoutId","updateVideoReceiveSlots","updateVideoRemoteMediaObjects","updateScreenShareVideoRemoteMediaObject","emitVideoLayoutChangedEvent","activeSpeakerGroup","setPreferLiveVideo","remoteMediaCsis","remoteMediaGroup","groupRemoteMediaCsis","filter","remoteMedia","includes","setActiveSpeakerCsis","i","AudioMain","RemoteMediaGroup","emit","file","function","AudioCreated","AudioSlides","isAnyLayoutContainingScreenShareVideo","some","VideoSlides","ScreenShareAudioCreated","requiredCsis","memberVideoPane","isCsiNeededByCurrentLayout","notNeededReceiverSelectedSlots","sort","a","b","paneIndex","freeSlot","shift","memberPane","existingSlot","find","isExistingSlotAlreadyAllocated","pop","requiredNumSlots","totalNumSlots","numSlotsToCreate","logMessage","groupName","map","logString","join","key","trimActiveSpeakerSlots","trimReceiverSelectedSlots","refillRequiredSlotsIfNeeded","allocateSlotsToActiveSpeakerPaneGroups","allocateSlotsToReceiverSelectedVideoPaneGroups","logReceieveSlots","groupId","paneGroupInCurrentLayout","groupInLayout","mediaGroup","resolution","warn","paneId","paneInCurrentLayout","paneInLayout","RemoteMedia","sendMediaRequest","options","stop","VideoLayoutChanged","activeSpeakerVideoPanes","getRemoteMedia","cancelMediaRequest","newPane","receiveSlot","reject","resolve","getUnderlyingReceiveSlot","index","indexOf","splice","pin","unpin","isPinned","EventsScope"],"sources":["remoteMediaManager.ts"],"sourcesContent":["/* eslint-disable valid-jsdoc */\nimport {cloneDeep, forEach, remove} from 'lodash';\nimport {EventMap} from 'typed-emitter';\nimport {MediaType} from '@webex/internal-media-core';\n\nimport LoggerProxy from '../common/logs/logger-proxy';\nimport EventsScope from '../common/events/events-scope';\n\nimport {RemoteMedia, RemoteVideoResolution} from './remoteMedia';\nimport {ReceiveSlot, CSI} from './receiveSlot';\nimport {ReceiveSlotManager} from './receiveSlotManager';\nimport {RemoteMediaGroup} from './remoteMediaGroup';\nimport {MediaRequestManager} from './mediaRequestManager';\n\nexport type PaneSize = RemoteVideoResolution;\nexport type LayoutId = string;\nexport type PaneId = string;\nexport type PaneGroupId = string;\n\nexport interface ActiveSpeakerVideoPaneGroup {\n id: PaneGroupId;\n numPanes: number; // maximum number of panes in the group (actual number may be lower, if there are not enough participants in the meeting)\n size: PaneSize; // preferred size for all panes in the group\n priority: number; // 0-255 (255 = highest priority), each group must have a different priority from all other groups\n}\n\nexport interface MemberVideoPane {\n id: PaneId;\n size: PaneSize;\n csi?: CSI;\n}\n\nexport interface VideoLayout {\n screenShareVideo?: {\n size: PaneSize;\n };\n activeSpeakerVideoPaneGroups?: ActiveSpeakerVideoPaneGroup[]; // list of active speaker video pane groups\n memberVideoPanes?: MemberVideoPane[]; // list of video panes for specific members, CSI values can be changed later via setVideoPaneCsi()\n}\n\nexport interface Configuration {\n audio: {\n numOfActiveSpeakerStreams: number; // number of audio streams we want to receive\n numOfScreenShareStreams: number; // 1 should be enough, because in webex only 1 person at a time can be presenting screen share\n };\n video: {\n preferLiveVideo: boolean; // applies to all pane groups with active speaker policy\n initialLayoutId: LayoutId;\n\n layouts: {[key: LayoutId]: VideoLayout}; // a map of all available layouts, a layout can be set via setLayout() method\n };\n}\n\n/* Predefined layouts: */\n\n// An \"all equal\" grid, with size up to 3 x 3 = 9:\nconst AllEqualLayout: VideoLayout = {\n activeSpeakerVideoPaneGroups: [\n {\n id: 'main',\n numPanes: 9,\n size: 'best',\n priority: 255,\n },\n ],\n};\n\n// A layout with just a single remote active speaker video pane:\nconst SingleLayout: VideoLayout = {\n activeSpeakerVideoPaneGroups: [\n {\n id: 'main',\n numPanes: 1,\n size: 'best',\n priority: 255,\n },\n ],\n};\n\n// A layout with 1 big pane for the highest priority active speaker and 5 small panes for other active speakers:\nconst OnePlusFiveLayout: VideoLayout = {\n activeSpeakerVideoPaneGroups: [\n {\n id: 'mainBigOne',\n numPanes: 1,\n size: 'large',\n priority: 255,\n },\n {\n id: 'secondarySetOfSmallPanes',\n numPanes: 5,\n size: 'very small',\n priority: 254,\n },\n ],\n};\n\n// A layout with 2 big panes for 2 main active speakers and a strip of 6 small panes for other active speakers:\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst TwoMainPlusSixSmallLayout: VideoLayout = {\n activeSpeakerVideoPaneGroups: [\n {\n id: 'mainGroupWith2BigPanes',\n numPanes: 2,\n size: 'large',\n priority: 255,\n },\n {\n id: 'secondaryGroupOfSmallPanes',\n numPanes: 6,\n size: 'small',\n priority: 254,\n },\n ],\n};\n\n// A strip of 8 small video panes (thumbnails) displayed at the top of a remote screenshare:\nconst RemoteScreenShareWithSmallThumbnailsLayout: VideoLayout = {\n screenShareVideo: {size: 'best'},\n activeSpeakerVideoPaneGroups: [\n {\n id: 'thumbnails',\n numPanes: 8,\n size: 'thumbnail',\n priority: 255,\n },\n ],\n};\n\n// A staged layout with 4 pre-selected meeting participants in the main 2x2 grid and 6 small panes for other active speakers at the top:\nconst Stage2x2With6ThumbnailsLayout: VideoLayout = {\n activeSpeakerVideoPaneGroups: [\n {\n id: 'thumbnails',\n numPanes: 6,\n size: 'thumbnail',\n priority: 255,\n },\n ],\n memberVideoPanes: [\n {id: 'stage-1', size: 'medium', csi: undefined},\n {id: 'stage-2', size: 'medium', csi: undefined},\n {id: 'stage-3', size: 'medium', csi: undefined},\n {id: 'stage-4', size: 'medium', csi: undefined},\n ],\n};\n\n/**\n * Default configuration:\n * - uses 3 audio streams\n * - prefers active speakers with live video (e.g. are not audio only or video muted) over active speakers without live video\n * - has a few layouts defined, including 1 that contains remote screen share (ScreenShareView)\n */\nexport const DefaultConfiguration: Configuration = {\n audio: {\n numOfActiveSpeakerStreams: 3,\n numOfScreenShareStreams: 1,\n },\n video: {\n preferLiveVideo: true,\n initialLayoutId: 'AllEqual',\n\n layouts: {\n AllEqual: AllEqualLayout,\n OnePlusFive: OnePlusFiveLayout,\n Single: SingleLayout,\n Stage: Stage2x2With6ThumbnailsLayout,\n ScreenShareView: RemoteScreenShareWithSmallThumbnailsLayout,\n },\n },\n};\n\nexport enum Event {\n // events for audio streams\n AudioCreated = 'AudioCreated',\n ScreenShareAudioCreated = 'ScreenShareAudioCreated',\n\n // events for video streams\n VideoLayoutChanged = 'VideoLayoutChanged',\n}\n\nexport interface VideoLayoutChangedEventData {\n layoutId: LayoutId;\n activeSpeakerVideoPanes: {\n [key: PaneGroupId]: RemoteMediaGroup;\n };\n memberVideoPanes: {[key: PaneId]: RemoteMedia};\n screenShareVideo?: RemoteMedia;\n}\nexport interface Events extends EventMap {\n // audio\n [Event.AudioCreated]: (audio: RemoteMediaGroup) => void;\n [Event.ScreenShareAudioCreated]: (screenShareAudio: RemoteMediaGroup) => void;\n\n // video\n [Event.VideoLayoutChanged]: (data: VideoLayoutChangedEventData) => void;\n}\n\n/**\n * A helper class that manages all remote audio/video streams in order to achieve a predefined set of layouts.\n * It also creates a fixed number of audio streams and these don't change during the meeting.\n *\n * Things that RemoteMediaManager does:\n * - owns the receive slots (creates them when needed, and re-uses them when switching layouts)\n * - constructs appropriate RemoteMedia and RemoteMediaGroup objects and sends appropriate mediaRequests\n */\nexport class RemoteMediaManager extends EventsScope {\n private config: Configuration;\n\n private started: boolean;\n\n private receiveSlotManager: ReceiveSlotManager;\n\n private mediaRequestManagers: {\n audio: MediaRequestManager;\n video: MediaRequestManager;\n screenShareAudio: MediaRequestManager;\n screenShareVideo: MediaRequestManager;\n };\n\n private currentLayout?: VideoLayout;\n\n private slots: {\n audio: ReceiveSlot[];\n screenShare: {\n audio: ReceiveSlot[];\n video?: ReceiveSlot;\n };\n video: {\n unused: ReceiveSlot[];\n activeSpeaker: ReceiveSlot[];\n receiverSelected: ReceiveSlot[];\n };\n };\n\n private media: {\n audio?: RemoteMediaGroup;\n video: {\n activeSpeakerGroups: {\n [key: PaneGroupId]: RemoteMediaGroup;\n };\n memberPanes: {[key: PaneId]: RemoteMedia};\n };\n screenShare: {\n audio?: RemoteMediaGroup;\n video?: RemoteMediaGroup;\n };\n };\n\n private receiveSlotAllocations: {\n activeSpeaker: {[key: PaneGroupId]: {slots: ReceiveSlot[]}};\n receiverSelected: {[key: PaneId]: ReceiveSlot};\n };\n\n private currentLayoutId?: LayoutId;\n\n /**\n * Constructor\n *\n * @param {ReceiveSlotManager} receiveSlotManager\n * @param {{audio: MediaRequestManager, video: mediaRequestManagers}} mediaRequestManagers\n * @param {Configuration} config Configuration describing what video layouts to use during the meeting\n */\n constructor(\n receiveSlotManager: ReceiveSlotManager,\n mediaRequestManagers: {\n audio: MediaRequestManager;\n video: MediaRequestManager;\n screenShareAudio: MediaRequestManager;\n screenShareVideo: MediaRequestManager;\n },\n config: Configuration = DefaultConfiguration\n ) {\n super();\n this.started = false;\n this.config = config;\n this.receiveSlotManager = receiveSlotManager;\n this.mediaRequestManagers = mediaRequestManagers;\n this.media = {\n audio: undefined,\n video: {\n activeSpeakerGroups: {},\n memberPanes: {},\n },\n screenShare: {\n audio: undefined,\n video: undefined,\n },\n };\n\n this.checkConfigValidity();\n\n this.slots = {\n audio: [],\n screenShare: {\n audio: [],\n video: undefined,\n },\n video: {\n unused: [],\n activeSpeaker: [],\n receiverSelected: [],\n },\n };\n\n this.receiveSlotAllocations = {activeSpeaker: {}, receiverSelected: {}};\n\n LoggerProxy.logger.log(\n `RemoteMediaManager#constructor --> RemoteMediaManager created with config: ${JSON.stringify(\n this.config\n )}`\n );\n }\n\n /**\n * Checks if configuration is valid, throws an error if it's not\n */\n private checkConfigValidity() {\n if (!(this.config.video.initialLayoutId in this.config.video.layouts)) {\n throw new Error(\n `invalid config: initialLayoutId \"${this.config.video.initialLayoutId}\" doesn't match any of the layouts`\n );\n }\n\n // check if each layout is valid\n Object.values(this.config.video.layouts).forEach((layout) => {\n const groupIds = {};\n const paneIds = {};\n const groupPriorites = {};\n\n layout.activeSpeakerVideoPaneGroups?.forEach((group) => {\n if (groupIds[group.id]) {\n throw new Error(\n `invalid config: duplicate active speaker video pane group id: ${group.id}`\n );\n }\n groupIds[group.id] = true;\n\n if (groupPriorites[group.priority]) {\n throw new Error(\n `invalid config: multiple active speaker video pane groups have same priority: ${group.priority}`\n );\n }\n groupPriorites[group.priority] = true;\n });\n\n layout.memberVideoPanes?.forEach((pane) => {\n if (paneIds[pane.id]) {\n throw new Error(`invalid config: duplicate member video pane id: ${pane.id}`);\n }\n paneIds[pane.id] = true;\n });\n });\n }\n\n /**\n * Starts the RemoteMediaManager.\n *\n * @returns {Promise}\n */\n public async start() {\n if (this.started) {\n throw new Error('start() failure: already started');\n }\n this.started = true;\n\n await this.createAudioMedia();\n\n await this.createScreenShareReceiveSlots();\n this.createScreenShareAudioMedia();\n\n await this.preallocateVideoReceiveSlots();\n\n await this.setLayout(this.config.video.initialLayoutId);\n }\n\n /**\n * Releases all the used resources (like allocated receive slots). This function needs\n * to be called when we leave the meeting, etc.\n */\n public stop() {\n // invalidate all remoteMedia objects\n this.invalidateCurrentRemoteMedia({\n audio: true,\n video: true,\n screenShareAudio: true,\n screenShareVideo: true,\n commit: true,\n });\n\n // release all audio receive slots\n this.slots.audio.forEach((slot) => this.receiveSlotManager.releaseSlot(slot));\n this.slots.audio.length = 0;\n\n // release screen share slots\n this.slots.screenShare.audio.forEach((slot) => this.receiveSlotManager.releaseSlot(slot));\n this.slots.screenShare.audio.length = 0;\n if (this.slots.screenShare.video) {\n this.receiveSlotManager.releaseSlot(this.slots.screenShare.video);\n this.slots.screenShare.video = undefined;\n }\n\n // release video slots\n this.receiveSlotAllocations = {activeSpeaker: {}, receiverSelected: {}};\n\n this.slots.video.unused.push(...this.slots.video.activeSpeaker);\n this.slots.video.activeSpeaker.length = 0;\n\n this.slots.video.unused.push(...this.slots.video.receiverSelected);\n this.slots.video.receiverSelected.length = 0;\n\n this.releaseUnusedVideoSlots();\n\n this.currentLayout = undefined;\n this.currentLayoutId = undefined;\n this.started = false;\n }\n\n /**\n * Returns the total number of main video panes required for a given layout\n *\n * @param {VideoLayout} layout\n * @returns {number}\n */\n private getRequiredNumVideoSlotsForLayout(layout?: VideoLayout) {\n if (!layout) {\n return 0;\n }\n\n const activeSpeakerCount =\n layout.activeSpeakerVideoPaneGroups?.reduce(\n (sum, paneGroup) => sum + paneGroup.numPanes,\n 0\n ) || 0;\n\n const receiverSelectedCount = layout.memberVideoPanes?.length || 0;\n\n return activeSpeakerCount + receiverSelectedCount;\n }\n\n /**\n * Allocates the maximum number of panes that any of the configured layouts will require.\n * We do this at the beginning, because it's more efficient (much faster) then allocating receive slots\n * later, after the SDP exchange was done.\n */\n private async preallocateVideoReceiveSlots() {\n const maxNumVideoPanesRequired = Object.values(this.config.video.layouts).reduce(\n (maxValue, layout) => Math.max(maxValue, this.getRequiredNumVideoSlotsForLayout(layout)),\n 0\n );\n\n while (this.slots.video.unused.length < maxNumVideoPanesRequired) {\n // eslint-disable-next-line no-await-in-loop\n this.slots.video.unused.push(\n // eslint-disable-next-line no-await-in-loop\n await this.receiveSlotManager.allocateSlot(MediaType.VideoMain)\n );\n }\n }\n\n /**\n * Changes the layout (triggers Event.VideoLayoutChanged)\n *\n * @param {LayoutId} layoutId new layout id\n * @returns {Promise}\n */\n public async setLayout(layoutId: LayoutId) {\n if (!(layoutId in this.config.video.layouts)) {\n throw new Error(\n `invalid layoutId: \"${layoutId}\" doesn't match any of the configured layouts`\n );\n }\n if (!this.started) {\n throw new Error('setLayout() called before start()');\n }\n this.currentLayoutId = layoutId;\n this.currentLayout = cloneDeep(this.config.video.layouts[this.currentLayoutId]);\n\n await this.updateVideoReceiveSlots();\n this.updateVideoRemoteMediaObjects();\n this.updateScreenShareVideoRemoteMediaObject();\n this.emitVideoLayoutChangedEvent();\n }\n\n /**\n * Returns the currently selected layout id\n *\n * @returns {LayoutId}\n */\n public getLayoutId(): LayoutId | undefined {\n return this.currentLayoutId;\n }\n\n /**\n * sets the preferLiveVideo\n */\n public setPreferLiveVideo(preferLiveVideo: boolean) {\n LoggerProxy.logger.log(\n `RemoteMediaManager#setPreferLiveVideo --> setPreferLiveVideo is called to set preferLiveVideo to ${preferLiveVideo}`\n );\n this.config.video.preferLiveVideo = preferLiveVideo;\n Object.values(this.media.video.activeSpeakerGroups).forEach((activeSpeakerGroup) => {\n activeSpeakerGroup.setPreferLiveVideo(preferLiveVideo, false);\n });\n this.mediaRequestManagers.video.commit();\n }\n\n /**\n * Sets CSIs for multiple RemoteMedia instances belonging to RemoteMediaGroup.\n * For each entry in the remoteMediaCsis array:\n * - if csi is specified, the RemoteMedia instance is pinned to that CSI\n * - if csi is undefined, the RemoteMedia instance is unpinned\n */\n public setActiveSpeakerCsis(remoteMediaCsis: {remoteMedia: RemoteMedia; csi?: number}[]) {\n Object.values(this.media.video.activeSpeakerGroups).forEach((remoteMediaGroup) => {\n const groupRemoteMediaCsis = remoteMediaCsis.filter(({remoteMedia}) =>\n remoteMediaGroup.includes(remoteMedia)\n );\n if (groupRemoteMediaCsis.length > 0) {\n remoteMediaGroup.setActiveSpeakerCsis(groupRemoteMediaCsis, false);\n }\n });\n this.mediaRequestManagers.video.commit();\n }\n\n /**\n * Creates the audio slots\n */\n private async createAudioMedia() {\n // create the audio receive slots\n for (let i = 0; i < this.config.audio.numOfActiveSpeakerStreams; i += 1) {\n // eslint-disable-next-line no-await-in-loop\n const slot = await this.receiveSlotManager.allocateSlot(MediaType.AudioMain);\n\n this.slots.audio.push(slot);\n }\n\n // create a remote media group\n this.media.audio = new RemoteMediaGroup(\n this.mediaRequestManagers.audio,\n this.slots.audio,\n 255,\n true\n );\n\n this.emit(\n {file: 'multistream/remoteMediaManager', function: 'createAudioMedia'},\n Event.AudioCreated,\n this.media.audio\n );\n }\n\n /**\n * Creates receive slots required for receiving screen share audio and video\n */\n private async createScreenShareReceiveSlots() {\n // audio\n for (let i = 0; i < this.config.audio.numOfScreenShareStreams; i += 1) {\n // eslint-disable-next-line no-await-in-loop\n const slot = await this.receiveSlotManager.allocateSlot(MediaType.AudioSlides);\n\n this.slots.screenShare.audio.push(slot);\n }\n\n // video\n const isAnyLayoutContainingScreenShareVideo = Object.values(this.config.video.layouts).some(\n (layout) => !!layout.screenShareVideo\n );\n\n if (isAnyLayoutContainingScreenShareVideo) {\n this.slots.screenShare.video = await this.receiveSlotManager.allocateSlot(\n MediaType.VideoSlides\n );\n }\n }\n\n /**\n * Creates RemoteMedia objects for screen share\n */\n private createScreenShareAudioMedia() {\n if (this.slots.screenShare.audio.length > 0) {\n this.media.screenShare.audio = new RemoteMediaGroup(\n this.mediaRequestManagers.screenShareAudio,\n this.slots.screenShare.audio,\n 255,\n true\n );\n\n this.emit(\n {file: 'multistream/remoteMediaManager', function: 'createScreenShareAudioMedia'},\n Event.ScreenShareAudioCreated,\n this.media.screenShare.audio\n );\n }\n }\n\n /**\n * Goes over all receiver-selected slots and keeps only the ones that are required by a given layout,\n * the rest are all moved to the \"unused\" list\n */\n private trimReceiverSelectedSlots() {\n const requiredCsis = {};\n\n // fill requiredCsis with all the CSIs that the given layout requires\n this.currentLayout?.memberVideoPanes?.forEach((memberVideoPane) => {\n if (memberVideoPane.csi !== undefined) {\n requiredCsis[memberVideoPane.csi] = true;\n }\n });\n\n const isCsiNeededByCurrentLayout = (csi?: CSI): boolean => {\n if (csi === undefined) {\n return false;\n }\n\n return !!requiredCsis[csi];\n };\n\n // keep receiverSelected slots that match our new requiredCsis, move the rest of receiverSelected slots to unused\n const notNeededReceiverSelectedSlots = remove(\n this.slots.video.receiverSelected,\n (slot) => isCsiNeededByCurrentLayout(slot.csi) === false\n );\n\n this.slots.video.unused.push(...notNeededReceiverSelectedSlots);\n }\n\n /**\n * Releases all the \"unused\" video slots.\n */\n private releaseUnusedVideoSlots() {\n this.slots.video.unused.forEach((slot) => this.receiveSlotManager.releaseSlot(slot));\n this.slots.video.unused.length = 0;\n }\n\n /**\n * Allocates receive slots to all active speaker video panes\n * in the current selected layout.\n *\n * Allocation tries to keep the same order of the slots between the previous\n * layout and the new one. Sorting helps making sure that highest priority slots\n * go in the same order in the new layout.\n */\n private allocateSlotsToActiveSpeakerPaneGroups() {\n this.currentLayout?.activeSpeakerVideoPaneGroups\n // sorting in descending order based on group priority\n ?.sort((a, b) => (a.priority < b.priority ? 1 : -1))\n ?.forEach((group) => {\n this.receiveSlotAllocations.activeSpeaker[group.id] = {slots: []};\n\n for (let paneIndex = 0; paneIndex < group.numPanes; paneIndex += 1) {\n // allocate a slot from the \"unused\" list, by grabbing in same order (shift) as previous layout\n const freeSlot = this.slots.video.unused.shift();\n\n if (freeSlot) {\n this.slots.video.activeSpeaker.push(freeSlot);\n this.receiveSlotAllocations.activeSpeaker[group.id].slots.push(freeSlot);\n }\n }\n });\n }\n\n /**\n * Allocates receive slots to all receiver selected video panes\n * in the current selected layout\n */\n private allocateSlotsToReceiverSelectedVideoPaneGroups() {\n this.currentLayout?.memberVideoPanes?.forEach((memberPane) => {\n // check if there is existing slot for this csi\n const existingSlot = this.slots.video.receiverSelected.find(\n (slot) => slot.csi === memberPane.csi\n );\n\n const isExistingSlotAlreadyAllocated = Object.values(\n this.receiveSlotAllocations.receiverSelected\n ).includes(existingSlot);\n\n if (memberPane.csi !== undefined && existingSlot && !isExistingSlotAlreadyAllocated) {\n // found it, so use it\n this.receiveSlotAllocations.receiverSelected[memberPane.id] = existingSlot;\n } else {\n // allocate a slot from the \"unused\" list\n const freeSlot = this.slots.video.unused.pop();\n\n if (freeSlot) {\n this.slots.video.receiverSelected.push(freeSlot);\n this.receiveSlotAllocations.receiverSelected[memberPane.id] = freeSlot;\n }\n }\n });\n }\n\n /**\n * Ensures that we have enough slots for the current layout.\n */\n private async refillRequiredSlotsIfNeeded() {\n const requiredNumSlots = this.getRequiredNumVideoSlotsForLayout(this.currentLayout);\n const totalNumSlots =\n this.slots.video.unused.length +\n this.slots.video.activeSpeaker.length +\n this.slots.video.receiverSelected.length;\n\n if (totalNumSlots < requiredNumSlots) {\n let numSlotsToCreate = requiredNumSlots - totalNumSlots;\n\n while (numSlotsToCreate > 0) {\n // eslint-disable-next-line no-await-in-loop\n this.slots.video.unused.push(\n // eslint-disable-next-line no-await-in-loop\n await this.receiveSlotManager.allocateSlot(MediaType.VideoMain)\n );\n numSlotsToCreate -= 1;\n }\n }\n }\n\n /**\n * Move all active speaker slots to \"unused\"\n */\n private trimActiveSpeakerSlots() {\n this.slots.video.unused.push(...this.slots.video.activeSpeaker);\n this.slots.video.activeSpeaker.length = 0;\n }\n\n /**\n * Logs the state of the receive slots\n */\n private logReceieveSlots() {\n let logMessage = '';\n forEach(this.receiveSlotAllocations.activeSpeaker, (group, groupName) => {\n logMessage += `group: ${groupName}\\n${group.slots.map((slot) => slot.logString).join(' ')}`;\n });\n\n logMessage += '\\nreceiverSelected:\\n';\n forEach(this.receiveSlotAllocations.receiverSelected, (slot, key) => {\n logMessage += ` ${key}: ${slot.logString}\\n`;\n });\n\n LoggerProxy.logger.log(\n `RemoteMediaManager#updateVideoReceiveSlots --> receive slots updated: unused=${this.slots.video.unused.length}, activeSpeaker=${this.slots.video.activeSpeaker.length}, receiverSelected=${this.slots.video.receiverSelected.length}\\n${logMessage}`\n );\n }\n\n /**\n * Makes sure we have the right number of receive slots created for the current layout\n * and allocates them to the right video panes / pane groups\n *\n * @returns {Promise}\n */\n private async updateVideoReceiveSlots() {\n // move all active speaker slots to \"unused\"\n this.trimActiveSpeakerSlots();\n\n // move all no longer needed receiver-selected slots to \"unused\"\n this.trimReceiverSelectedSlots();\n\n // ensure we have enough total slots for current layout\n await this.refillRequiredSlotsIfNeeded();\n\n // allocate the slots to the right panes / pane groups\n // reset allocations\n this.receiveSlotAllocations = {activeSpeaker: {}, receiverSelected: {}};\n // allocate active speaker\n this.allocateSlotsToActiveSpeakerPaneGroups();\n // allocate receiver selected\n this.allocateSlotsToReceiverSelectedVideoPaneGroups();\n\n this.logReceieveSlots();\n\n // If this is the initial layout, there may be some \"unused\" slots left because of the preallocation\n // done in this.preallocateVideoReceiveSlots(), so release them now\n this.releaseUnusedVideoSlots();\n }\n\n /**\n * Creates new RemoteMedia and RemoteMediaGroup objects for the current layout\n * and sends the media requests for all of them.\n */\n private updateVideoRemoteMediaObjects() {\n // invalidate all the previous remote media objects and cancel their media requests\n this.invalidateCurrentRemoteMedia({\n audio: false,\n video: true,\n screenShareAudio: false,\n screenShareVideo: false,\n commit: false,\n });\n\n // create new remoteMediaGroup objects\n this.media.video.activeSpeakerGroups = {};\n this.media.video.memberPanes = {};\n\n for (const [groupId, group] of Object.entries(this.receiveSlotAllocations.activeSpeaker)) {\n const paneGroupInCurrentLayout = this.currentLayout?.activeSpeakerVideoPaneGroups?.find(\n (groupInLayout) => groupInLayout.id === groupId\n );\n\n if (paneGroupInCurrentLayout) {\n const mediaGroup = new RemoteMediaGroup(\n this.mediaRequestManagers.video,\n group.slots,\n paneGroupInCurrentLayout.priority,\n false,\n {\n preferLiveVideo: this.config.video.preferLiveVideo,\n resolution: paneGroupInCurrentLayout.size,\n }\n );\n\n this.media.video.activeSpeakerGroups[groupId] = mediaGroup;\n } else {\n // this should never happen, because this.receiveSlotAllocations are created based on current layout configuration\n LoggerProxy.logger.warn(\n `a group id ${groupId} from this.receiveSlotAllocations.activeSpeaker cannot be found in the current layout configuration`\n );\n }\n }\n\n // create new remoteMedia objects\n for (const [paneId, slot] of Object.entries(this.receiveSlotAllocations.receiverSelected)) {\n const paneInCurrentLayout = this.currentLayout?.memberVideoPanes?.find(\n (paneInLayout) => paneInLayout.id === paneId\n );\n\n if (paneInCurrentLayout) {\n const remoteMedia = new RemoteMedia(slot, this.mediaRequestManagers.video, {\n resolution: paneInCurrentLayout.size,\n });\n\n if (paneInCurrentLayout.csi) {\n remoteMedia.sendMediaRequest(paneInCurrentLayout.csi, false);\n }\n\n this.media.video.memberPanes[paneId] = remoteMedia;\n } else {\n // this should never happen, because this.receiveSlotAllocations are created based on current layout configuration\n LoggerProxy.logger.warn(\n `a pane id ${paneId} from this.receiveSlotAllocations.receiverSelected cannot be found in the current layout configuration`\n );\n }\n }\n\n this.mediaRequestManagers.video.commit();\n }\n\n /**\n * Checks if current layout requires a screen share.\n * If it does, it creates new RemoteMediaGroup object for screen share\n * and sends the media requests for it.\n * If it doesn't, it makes sure we clean up any RemoteMediaGroup objects\n * created earlier for screen share (for previous layout).\n */\n private updateScreenShareVideoRemoteMediaObject() {\n this.invalidateCurrentRemoteMedia({\n audio: false,\n video: false,\n screenShareAudio: false,\n screenShareVideo: true,\n commit: false,\n });\n\n this.media.screenShare.video = undefined;\n\n if (this.currentLayout?.screenShareVideo) {\n // we create a group of 1, because for screen share we need to use the \"active speaker\" policy\n this.media.screenShare.video = new RemoteMediaGroup(\n this.mediaRequestManagers.screenShareVideo,\n [this.slots.screenShare.video],\n 255,\n false,\n {resolution: this.currentLayout.screenShareVideo.size}\n );\n }\n\n this.mediaRequestManagers.screenShareVideo.commit();\n }\n\n /**\n * Invalidates all remote media objects belonging to currently selected layout\n */\n private invalidateCurrentRemoteMedia(options: {\n audio: boolean;\n video: boolean;\n screenShareAudio: boolean;\n screenShareVideo: boolean;\n commit: boolean;\n }) {\n const {audio, video, screenShareAudio, screenShareVideo, commit} = options;\n\n if (audio && this.media.audio) {\n this.media.audio.stop(commit);\n }\n if (video) {\n Object.values(this.media.video.activeSpeakerGroups).forEach((remoteMediaGroup) => {\n remoteMediaGroup.stop(false);\n });\n Object.values(this.media.video.memberPanes).forEach((remoteMedia) => {\n remoteMedia.stop(false);\n });\n if (commit) {\n this.mediaRequestManagers.video.commit();\n }\n }\n\n if (screenShareAudio && this.media.screenShare.audio) {\n this.media.screenShare.audio.stop(commit);\n }\n if (screenShareVideo && this.media.screenShare.video) {\n this.media.screenShare.video.stop(commit);\n }\n }\n\n /** emits Event.VideoLayoutChanged */\n private emitVideoLayoutChangedEvent() {\n // todo: at this point the receive slots might still be showing a participant from previous layout, we should\n // wait for our media requests to be fulfilled, but there is no API for that right now (we could wait for source updates\n // but in some cases they might never come, or would need to always make sure to use a new set of receiver slots)\n // for now it's fine to have it like this, we will re-evaluate if it needs improving after more testing\n\n this.emit(\n {\n file: 'multistream/remoteMediaManager',\n function: 'emitVideoLayoutChangedEvent',\n },\n Event.VideoLayoutChanged,\n {\n layoutId: this.currentLayoutId,\n activeSpeakerVideoPanes: this.media.video.activeSpeakerGroups,\n memberVideoPanes: this.media.video.memberPanes,\n screenShareVideo: this.media.screenShare.video?.getRemoteMedia()[0],\n }\n );\n }\n\n /**\n * Sets a new CSI on a given remote media object\n *\n * @param {RemoteMedia} remoteMedia remote Media object to modify\n * @param {CSI} csi new CSI value, can be null if we want to stop receiving media\n */\n public setRemoteVideoCsi(remoteMedia: RemoteMedia, csi: CSI | null) {\n if (!Object.values(this.media.video.memberPanes).includes(remoteMedia)) {\n throw new Error('remoteMedia not found');\n }\n\n if (csi) {\n remoteMedia.sendMediaRequest(csi, true);\n } else {\n remoteMedia.cancelMediaRequest(true);\n }\n }\n\n /**\n * Adds a new member video pane to the currently selected layout.\n *\n * Changes to the layout are lost after a layout change.\n *\n * @param {MemberVideoPane} newPane\n * @returns {Promise<RemoteMedia>}\n */\n public async addMemberVideoPane(newPane: MemberVideoPane): Promise<RemoteMedia> {\n if (!this.currentLayout) {\n throw new Error('There is no current layout selected, call start() first');\n }\n\n if (!this.currentLayout?.memberVideoPanes) {\n this.currentLayout.memberVideoPanes = [];\n }\n\n if (newPane.id in this.currentLayout.memberVideoPanes) {\n throw new Error(\n `duplicate pane id ${newPane.id} - this pane already exists in current layout's memberVideoPanes`\n );\n }\n\n this.currentLayout.memberVideoPanes.push(newPane);\n\n const receiveSlot = await this.receiveSlotManager.allocateSlot(MediaType.VideoMain);\n\n this.slots.video.receiverSelected.push(receiveSlot);\n\n const remoteMedia = new RemoteMedia(receiveSlot, this.mediaRequestManagers.video, {\n resolution: newPane.size,\n });\n\n if (newPane.csi) {\n remoteMedia.sendMediaRequest(newPane.csi, true);\n }\n\n this.media.video.memberPanes[newPane.id] = remoteMedia;\n\n return remoteMedia;\n }\n\n /**\n * Removes a member video pane from the currently selected layout.\n *\n * Changes to the layout are lost after a layout change.\n *\n * @param {PaneId} paneId pane id of the pane to remove\n * @returns {Promise<void>}\n */\n public removeMemberVideoPane(paneId: PaneId): Promise<void> {\n if (!this.currentLayout) {\n return Promise.reject(new Error('There is no current layout selected, call start() first'));\n }\n\n if (!this.currentLayout.memberVideoPanes?.find((pane) => pane.id === paneId)) {\n // pane id doesn't exist, so nothing to do\n LoggerProxy.logger.log(\n `RemoteMediaManager#removeMemberVideoPane --> removeMemberVideoPane() called for a non-existent paneId: ${paneId} (pane not found in currentLayout.memberVideoPanes)`\n );\n\n return Promise.resolve();\n }\n\n if (!this.media.video.memberPanes[paneId]) {\n // pane id doesn't exist, so nothing to do\n LoggerProxy.logger.log(\n `RemoteMediaManager#removeMemberVideoPane --> removeMemberVideoPane() called for a non-existent paneId: ${paneId} (pane not found in this.media.video.memberPanes)`\n );\n\n return Promise.resolve();\n }\n\n const remoteMedia = this.media.video.memberPanes[paneId];\n\n const receiveSlot = remoteMedia.getUnderlyingReceiveSlot();\n\n if (receiveSlot) {\n this.receiveSlotManager.releaseSlot(receiveSlot);\n\n const index = this.slots.video.receiverSelected.indexOf(receiveSlot);\n\n if (index >= 0) {\n this.slots.video.receiverSelected.splice(index, 1);\n }\n }\n remoteMedia.stop();\n\n delete this.media.video.memberPanes[paneId];\n delete this.currentLayout.memberVideoPanes?.[paneId];\n\n return Promise.resolve();\n }\n\n /**\n * Pins an active speaker remote media object to the given CSI value. From that moment\n * onwards the remote media will only play audio/video from that specific CSI until\n * unpinActiveSpeakerVideoPane() is called or current layout is changed.\n *\n * @param {RemoteMedia} remoteMedia remote media object reference\n * @param {CSI} csi CSI value to pin to, if undefined, then current CSI value is used\n */\n public pinActiveSpeakerVideoPane(remoteMedia: RemoteMedia, csi?: CSI): void {\n const remoteMediaGroup = Object.values(this.media.video.activeSpeakerGroups).find((group) =>\n group.includes(remoteMedia, 'unpinned')\n );\n\n if (!remoteMediaGroup) {\n throw new Error(\n 'remoteMedia not found among the unpinned remote media from any active speaker group'\n );\n }\n\n remoteMediaGroup.pin(remoteMedia, csi);\n }\n\n /**\n * Unpins a remote media object from the fixed CSI value it was pinned to.\n *\n * @param {RemoteMedia} remoteMedia remote media object reference\n */\n public unpinActiveSpeakerVideoPane(remoteMedia: RemoteMedia) {\n const remoteMediaGroup = Object.values(this.media.video.activeSpeakerGroups).find((group) =>\n group.includes(remoteMedia, 'pinned')\n );\n\n if (!remoteMediaGroup) {\n throw new Error(\n 'remoteMedia not found among the pinned remote media from any active speaker group'\n );\n }\n\n remoteMediaGroup.unpin(remoteMedia);\n }\n\n /**\n * Returns true if a given remote media object belongs to an active speaker group and has been pinned.\n * Throws an error if the remote media object doesn't belong to any active speaker remote media group.\n *\n * @param {RemoteMedia} remoteMedia remote media object\n * @returns {boolean}\n */\n public isPinned(remoteMedia: RemoteMedia) {\n const remoteMediaGroup = Object.values(this.media.video.activeSpeakerGroups).find((group) =>\n group.includes(remoteMedia)\n );\n\n if (!remoteMediaGroup) {\n throw new Error(\n 'remoteMedia not found among any remote media (pinned or unpinned) from any active speaker group'\n );\n }\n\n return remoteMediaGroup.isPinned(remoteMedia);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;AAEA;AACA;AAEA;AAGA;AAAoD;AAAA;AA0CpD;;AAEA;AACA,IAAMA,cAA2B,GAAG;EAClCC,4BAA4B,EAAE,CAC5B;IACEC,EAAE,EAAE,MAAM;IACVC,QAAQ,EAAE,CAAC;IACXC,IAAI,EAAE,MAAM;IACZC,QAAQ,EAAE;EACZ,CAAC;AAEL,CAAC;;AAED;AACA,IAAMC,YAAyB,GAAG;EAChCL,4BAA4B,EA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AACvE,WAAW,CAAC;IACrC;;IAEA;AACF;AACA;AACA;AACA;AACA;AACA;EANE;IAAA;IAAA,OAOA,kBAAgBA,WAAwB,EAAE;MACxC,IAAMH,gBAAgB,GAAG,qBAAc,IAAI,CAACzD,KAAK,CAACf,KAAK,CAACgB,mBAAmB,CAAC,CAACsF,IAAI,CAAC,UAACpE,KAAK;QAAA,OACtFA,KAAK,CAAC0C,QAAQ,CAACD,WAAW,CAAC;MAAA,EAC5B;MAED,IAAI,CAACH,gBAAgB,EAAE;QACrB,MAAM,IAAI5C,KAAK,CACb,iGAAiG,CAClG;MACH;MAEA,OAAO4C,gBAAgB,CAAC2E,QAAQ,CAACxE,WAAW,CAAC;IAC/C;EAAC;EAAA;AAAA,EAp4BqCyE,oBAAW;AAAA"}
@@ -582,6 +582,13 @@ export default class Meeting extends StatelessWebexPlugin {
582
582
  * @memberof Meeting
583
583
  */
584
584
  private setupLocusControlsListener;
585
+ /**
586
+ * Trigger annotation info update event
587
+ @returns {undefined}
588
+ @param {object} contentShare
589
+ @param {object} previousContentShare
590
+ */
591
+ private triggerAnnotationInfoEvent;
585
592
  /**
586
593
  * Set up the locus info media shares listener
587
594
  * update content and whiteboard sharing id value for members, and updates the member
@@ -33,7 +33,6 @@ export declare class RemoteMediaGroup {
33
33
  */
34
34
  unpin(remoteMedia: RemoteMedia): void;
35
35
  isPinned(remoteMedia: RemoteMedia): boolean;
36
- setPreferLiveVideo(preferLiveVideo: boolean, commit: boolean): void;
37
36
  private sendActiveSpeakerMediaRequest;
38
37
  private cancelActiveSpeakerMediaRequest;
39
38
  /**
@@ -143,6 +143,16 @@ export declare class RemoteMediaManager extends EventsScope {
143
143
  * sets the preferLiveVideo
144
144
  */
145
145
  setPreferLiveVideo(preferLiveVideo: boolean): void;
146
+ /**
147
+ * Sets CSIs for multiple RemoteMedia instances belonging to RemoteMediaGroup.
148
+ * For each entry in the remoteMediaCsis array:
149
+ * - if csi is specified, the RemoteMedia instance is pinned to that CSI
150
+ * - if csi is undefined, the RemoteMedia instance is unpinned
151
+ */
152
+ setActiveSpeakerCsis(remoteMediaCsis: {
153
+ remoteMedia: RemoteMedia;
154
+ csi?: number;
155
+ }[]): void;
146
156
  /**
147
157
  * Creates the audio slots
148
158
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webex/plugin-meetings",
3
- "version": "3.0.0-beta.147",
3
+ "version": "3.0.0-beta.149",
4
4
  "description": "",
5
5
  "license": "Cisco EULA (https://www.cisco.com/c/en/us/products/end-user-license-agreement.html)",
6
6
  "contributors": [
@@ -32,12 +32,12 @@
32
32
  "build": "yarn run -T tsc --declaration true --declarationDir ./dist/types"
33
33
  },
34
34
  "devDependencies": {
35
- "@webex/plugin-meetings": "3.0.0-beta.147",
36
- "@webex/test-helper-chai": "3.0.0-beta.147",
37
- "@webex/test-helper-mocha": "3.0.0-beta.147",
38
- "@webex/test-helper-mock-webex": "3.0.0-beta.147",
39
- "@webex/test-helper-retry": "3.0.0-beta.147",
40
- "@webex/test-helper-test-users": "3.0.0-beta.147",
35
+ "@webex/plugin-meetings": "3.0.0-beta.149",
36
+ "@webex/test-helper-chai": "3.0.0-beta.149",
37
+ "@webex/test-helper-mocha": "3.0.0-beta.149",
38
+ "@webex/test-helper-mock-webex": "3.0.0-beta.149",
39
+ "@webex/test-helper-retry": "3.0.0-beta.149",
40
+ "@webex/test-helper-test-users": "3.0.0-beta.149",
41
41
  "chai": "^4.3.4",
42
42
  "chai-as-promised": "^7.1.1",
43
43
  "jsdom-global": "3.0.2",
@@ -46,19 +46,19 @@
46
46
  "typescript": "^4.7.4"
47
47
  },
48
48
  "dependencies": {
49
- "@webex/common": "3.0.0-beta.147",
49
+ "@webex/common": "3.0.0-beta.149",
50
50
  "@webex/internal-media-core": "1.38.3",
51
- "@webex/internal-plugin-conversation": "3.0.0-beta.147",
52
- "@webex/internal-plugin-device": "3.0.0-beta.147",
53
- "@webex/internal-plugin-llm": "3.0.0-beta.147",
54
- "@webex/internal-plugin-mercury": "3.0.0-beta.147",
55
- "@webex/internal-plugin-metrics": "3.0.0-beta.147",
56
- "@webex/internal-plugin-support": "3.0.0-beta.147",
57
- "@webex/internal-plugin-user": "3.0.0-beta.147",
58
- "@webex/media-helpers": "3.0.0-beta.147",
59
- "@webex/plugin-people": "3.0.0-beta.147",
60
- "@webex/plugin-rooms": "3.0.0-beta.147",
61
- "@webex/webex-core": "3.0.0-beta.147",
51
+ "@webex/internal-plugin-conversation": "3.0.0-beta.149",
52
+ "@webex/internal-plugin-device": "3.0.0-beta.149",
53
+ "@webex/internal-plugin-llm": "3.0.0-beta.149",
54
+ "@webex/internal-plugin-mercury": "3.0.0-beta.149",
55
+ "@webex/internal-plugin-metrics": "3.0.0-beta.149",
56
+ "@webex/internal-plugin-support": "3.0.0-beta.149",
57
+ "@webex/internal-plugin-user": "3.0.0-beta.149",
58
+ "@webex/media-helpers": "3.0.0-beta.149",
59
+ "@webex/plugin-people": "3.0.0-beta.149",
60
+ "@webex/plugin-rooms": "3.0.0-beta.149",
61
+ "@webex/webex-core": "3.0.0-beta.149",
62
62
  "ampersand-collection": "^2.0.2",
63
63
  "bowser": "^2.11.0",
64
64
  "btoa": "^1.2.1",
@@ -85,7 +85,6 @@ class AnnotationChannel extends WebexPlugin implements IAnnotationChannel {
85
85
  payload: e.data.approval,
86
86
  }
87
87
  );
88
- this.seqNum = (e?.sequenceNumber || 0) + 1;
89
88
  }
90
89
  }
91
90
 
@@ -96,7 +95,6 @@ class AnnotationChannel extends WebexPlugin implements IAnnotationChannel {
96
95
  private eventDataProcessor(e) {
97
96
  switch (e?.data?.relayType) {
98
97
  case ANNOTATION_RELAY_TYPES.ANNOTATION_CLIENT:
99
- this.seqNum = (e?.sequenceNumber || 0) + 1;
100
98
  this.processStrokeMessage(e.data);
101
99
  break;
102
100
  default: