@webex/plugin-meetings 3.0.0-beta.17 → 3.0.0-beta.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/dist/breakouts/breakout.js +116 -0
  2. package/dist/breakouts/breakout.js.map +1 -0
  3. package/dist/breakouts/collection.js +23 -0
  4. package/dist/breakouts/collection.js.map +1 -0
  5. package/dist/breakouts/index.js +226 -0
  6. package/dist/breakouts/index.js.map +1 -0
  7. package/dist/config.js +4 -1
  8. package/dist/config.js.map +1 -1
  9. package/dist/constants.js +38 -5
  10. package/dist/constants.js.map +1 -1
  11. package/dist/locus-info/controlsUtils.js +2 -1
  12. package/dist/locus-info/controlsUtils.js.map +1 -1
  13. package/dist/locus-info/index.js +48 -0
  14. package/dist/locus-info/index.js.map +1 -1
  15. package/dist/locus-info/parser.js +1 -0
  16. package/dist/locus-info/parser.js.map +1 -1
  17. package/dist/locus-info/selfUtils.js +19 -11
  18. package/dist/locus-info/selfUtils.js.map +1 -1
  19. package/dist/media/index.js +3 -3
  20. package/dist/media/index.js.map +1 -1
  21. package/dist/media/properties.js +4 -4
  22. package/dist/media/properties.js.map +1 -1
  23. package/dist/meeting/index.js +651 -460
  24. package/dist/meeting/index.js.map +1 -1
  25. package/dist/meeting/request.js +25 -44
  26. package/dist/meeting/request.js.map +1 -1
  27. package/dist/meeting/request.type.js.map +1 -1
  28. package/dist/meeting/util.js +4 -57
  29. package/dist/meeting/util.js.map +1 -1
  30. package/dist/meeting-info/meeting-info-v2.js +2 -0
  31. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  32. package/dist/meetings/index.js +28 -18
  33. package/dist/meetings/index.js.map +1 -1
  34. package/dist/meetings/request.js +14 -12
  35. package/dist/meetings/request.js.map +1 -1
  36. package/dist/member/index.js +9 -0
  37. package/dist/member/index.js.map +1 -1
  38. package/dist/member/util.js +14 -1
  39. package/dist/member/util.js.map +1 -1
  40. package/dist/members/index.js +8 -6
  41. package/dist/members/index.js.map +1 -1
  42. package/dist/members/request.js +3 -1
  43. package/dist/members/request.js.map +1 -1
  44. package/dist/multistream/mediaRequestManager.js +46 -6
  45. package/dist/multistream/mediaRequestManager.js.map +1 -1
  46. package/dist/multistream/multistreamMedia.js +4 -0
  47. package/dist/multistream/multistreamMedia.js.map +1 -1
  48. package/dist/multistream/receiveSlot.js +3 -3
  49. package/dist/multistream/receiveSlot.js.map +1 -1
  50. package/dist/multistream/receiveSlotManager.js +8 -6
  51. package/dist/multistream/receiveSlotManager.js.map +1 -1
  52. package/dist/multistream/remoteMedia.js.map +1 -1
  53. package/dist/multistream/remoteMediaGroup.js.map +1 -1
  54. package/dist/multistream/remoteMediaManager.js +168 -63
  55. package/dist/multistream/remoteMediaManager.js.map +1 -1
  56. package/dist/reachability/index.js +63 -51
  57. package/dist/reachability/index.js.map +1 -1
  58. package/dist/reactions/constants.js +13 -0
  59. package/dist/reactions/constants.js.map +1 -0
  60. package/dist/reactions/reactions.type.js.map +1 -1
  61. package/dist/reconnection-manager/index.js +25 -12
  62. package/dist/reconnection-manager/index.js.map +1 -1
  63. package/dist/recording-controller/enums.js +17 -0
  64. package/dist/recording-controller/enums.js.map +1 -0
  65. package/dist/recording-controller/index.js +343 -0
  66. package/dist/recording-controller/index.js.map +1 -0
  67. package/dist/recording-controller/util.js +63 -0
  68. package/dist/recording-controller/util.js.map +1 -0
  69. package/dist/roap/request.js +88 -68
  70. package/dist/roap/request.js.map +1 -1
  71. package/dist/roap/turnDiscovery.js +72 -47
  72. package/dist/roap/turnDiscovery.js.map +1 -1
  73. package/dist/statsAnalyzer/index.js +3 -3
  74. package/dist/statsAnalyzer/index.js.map +1 -1
  75. package/dist/statsAnalyzer/mqaUtil.js +18 -6
  76. package/dist/statsAnalyzer/mqaUtil.js.map +1 -1
  77. package/package.json +24 -19
  78. package/src/breakouts/README.md +190 -0
  79. package/src/breakouts/breakout.ts +110 -0
  80. package/src/breakouts/collection.ts +19 -0
  81. package/src/breakouts/index.ts +225 -0
  82. package/src/config.ts +4 -1
  83. package/src/constants.ts +35 -1
  84. package/src/locus-info/controlsUtils.ts +2 -0
  85. package/src/locus-info/index.ts +59 -1
  86. package/src/locus-info/parser.ts +1 -0
  87. package/src/locus-info/selfUtils.ts +8 -0
  88. package/src/media/index.ts +1 -2
  89. package/src/media/properties.ts +6 -9
  90. package/src/meeting/index.ts +352 -111
  91. package/src/meeting/request.ts +9 -31
  92. package/src/meeting/request.type.ts +2 -0
  93. package/src/meeting/util.ts +3 -60
  94. package/src/meeting-info/meeting-info-v2.ts +2 -0
  95. package/src/meetings/index.ts +10 -5
  96. package/src/meetings/request.ts +1 -1
  97. package/src/member/index.ts +9 -0
  98. package/src/member/util.ts +14 -1
  99. package/src/members/index.ts +1 -0
  100. package/src/members/request.ts +1 -0
  101. package/src/multistream/mediaRequestManager.ts +79 -15
  102. package/src/multistream/multistreamMedia.ts +4 -0
  103. package/src/multistream/receiveSlot.ts +17 -12
  104. package/src/multistream/receiveSlotManager.ts +22 -21
  105. package/src/multistream/remoteMedia.ts +1 -1
  106. package/src/multistream/remoteMediaGroup.ts +2 -2
  107. package/src/multistream/remoteMediaManager.ts +150 -37
  108. package/src/reachability/index.ts +16 -13
  109. package/src/reactions/constants.ts +4 -0
  110. package/src/reactions/reactions.type.ts +25 -0
  111. package/src/reconnection-manager/index.ts +18 -9
  112. package/src/recording-controller/enums.ts +8 -0
  113. package/src/recording-controller/index.ts +315 -0
  114. package/src/recording-controller/util.ts +58 -0
  115. package/src/roap/request.ts +78 -73
  116. package/src/roap/turnDiscovery.ts +8 -6
  117. package/src/statsAnalyzer/index.ts +4 -4
  118. package/src/statsAnalyzer/mqaUtil.ts +6 -0
  119. package/test/unit/spec/breakouts/breakout.ts +119 -0
  120. package/test/unit/spec/breakouts/collection.ts +15 -0
  121. package/test/unit/spec/breakouts/index.ts +293 -0
  122. package/test/unit/spec/locus-info/controlsUtils.js +20 -0
  123. package/test/unit/spec/locus-info/index.js +103 -0
  124. package/test/unit/spec/locus-info/selfConstant.js +25 -0
  125. package/test/unit/spec/locus-info/selfUtils.js +84 -0
  126. package/test/unit/spec/media/index.ts +1 -1
  127. package/test/unit/spec/media/properties.ts +9 -9
  128. package/test/unit/spec/meeting/effectsState.js +5 -1
  129. package/test/unit/spec/meeting/index.js +235 -50
  130. package/test/unit/spec/meeting/request.js +17 -0
  131. package/test/unit/spec/meeting/utils.js +20 -129
  132. package/test/unit/spec/meetings/index.js +1 -0
  133. package/test/unit/spec/member/util.js +26 -1
  134. package/test/unit/spec/multistream/mediaRequestManager.ts +312 -50
  135. package/test/unit/spec/multistream/receiveSlot.ts +6 -6
  136. package/test/unit/spec/multistream/receiveSlotManager.ts +13 -13
  137. package/test/unit/spec/multistream/remoteMedia.ts +2 -2
  138. package/test/unit/spec/multistream/remoteMediaGroup.ts +5 -5
  139. package/test/unit/spec/multistream/remoteMediaManager.ts +354 -65
  140. package/test/unit/spec/reachability/index.ts +58 -24
  141. package/test/unit/spec/reconnection-manager/index.js +42 -13
  142. package/test/unit/spec/recording-controller/index.js +231 -0
  143. package/test/unit/spec/recording-controller/util.js +102 -0
  144. package/test/unit/spec/roap/index.ts +2 -1
  145. package/test/unit/spec/roap/request.ts +114 -0
  146. package/test/unit/spec/roap/turnDiscovery.ts +45 -29
  147. package/test/unit/spec/stats-analyzer/index.js +2 -2
  148. package/test/utils/webex-test-users.js +1 -0
  149. package/tsconfig.json +6 -0
  150. package/dist/media/internal-media-core-wrapper.js +0 -18
  151. package/dist/media/internal-media-core-wrapper.js.map +0 -1
  152. package/src/media/internal-media-core-wrapper.ts +0 -9
@@ -1 +1 @@
1
- {"version":3,"names":["CODEC_DEFAULTS","h264","maxFs","maxFps","maxMbps","MediaRequestManager","sendMediaRequestsCallback","counter","clientRequests","slotsActiveInLastMediaRequest","activeSlots","forEach","request","receiveSlots","slot","id","slotId","LoggerProxy","logger","info","resetSourceState","wcmeMediaRequests","maxPayloadBitsPerSecond","mr","push","MC","MediaRequest","policyInfo","policy","Policy","ActiveSpeaker","ReceiverSelected","ActiveSpeakerInfo","priority","crossPriorityDuplication","crossPolicyDuplication","preferLiveVideo","ReceiverSelectedInfo","csi","map","receiveSlot","wcmeReceiveSlot","codecInfo","CodecInfo","H264Codec","maxWidth","maxHeight","resetInactiveReceiveSlots","mediaRequest","commit","newId","requestId","sendRequests"],"sources":["mediaRequestManager.ts"],"sourcesContent":["/* eslint-disable require-jsdoc */\nimport {MediaConnection as MC} from '@webex/internal-media-core';\n\nimport LoggerProxy from '../common/logs/logger-proxy';\n\nimport {ReceiveSlot, ReceiveSlotId} from './receiveSlot';\n\nexport interface ActiveSpeakerPolicyInfo {\n policy: 'active-speaker';\n priority: number;\n crossPriorityDuplication: boolean;\n crossPolicyDuplication: boolean;\n preferLiveVideo: boolean;\n}\n\nexport interface ReceiverSelectedPolicyInfo {\n policy: 'receiver-selected';\n csi: number;\n}\n\nexport type PolicyInfo = ActiveSpeakerPolicyInfo | ReceiverSelectedPolicyInfo;\n\nexport interface H264CodecInfo {\n codec: 'h264';\n maxFs?: number;\n maxFps?: number;\n maxMbps?: number;\n maxWidth?: number;\n maxHeight?: number;\n}\n\nexport type CodecInfo = H264CodecInfo; // we'll add AV1 here in the future when it's available\n\nexport interface MediaRequest {\n policyInfo: PolicyInfo;\n receiveSlots: Array<ReceiveSlot>;\n codecInfo?: CodecInfo;\n}\n\nexport type MediaRequestId = string;\n\nconst CODEC_DEFAULTS = {\n h264: {\n maxFs: 8192,\n maxFps: 3000,\n maxMbps: 245760,\n },\n};\n\ntype SendMediaRequestsCallback = (mediaRequests: MC.MediaRequest[]) => void;\n\nexport class MediaRequestManager {\n private sendMediaRequestsCallback: SendMediaRequestsCallback;\n\n private counter;\n\n private clientRequests: {[key: MediaRequestId]: MediaRequest};\n\n private slotsActiveInLastMediaRequest: {[key: ReceiveSlotId]: ReceiveSlot};\n\n constructor(sendMediaRequestsCallback: SendMediaRequestsCallback) {\n this.sendMediaRequestsCallback = sendMediaRequestsCallback;\n this.counter = 0;\n this.clientRequests = {};\n this.slotsActiveInLastMediaRequest = {};\n }\n\n private resetInactiveReceiveSlots() {\n const activeSlots: {[key: ReceiveSlotId]: ReceiveSlot} = {};\n\n // create a map of all currently used slot ids\n Object.values(this.clientRequests).forEach((request) =>\n request.receiveSlots.forEach((slot) => {\n activeSlots[slot.id] = slot;\n })\n );\n\n // when we stop using some receive slots and they are not included in the new media request,\n // we will never get a 'no source' notification for them, so we reset their state,\n // so that the client doesn't try to display their video anymore\n for (const [slotId, slot] of Object.entries(this.slotsActiveInLastMediaRequest)) {\n if (!(slotId in activeSlots)) {\n LoggerProxy.logger.info(\n `multistream:mediaRequestManager --> resetting sourceState to \"no source\" for slot ${slot.id}`\n );\n slot.resetSourceState();\n }\n }\n\n this.slotsActiveInLastMediaRequest = activeSlots;\n }\n\n private sendRequests() {\n const wcmeMediaRequests: MC.MediaRequest[] = [];\n\n // todo: check how many streams we're asking for and what resolution and introduce some limits (spark-377701)\n const maxPayloadBitsPerSecond = 10 * 1000 * 1000;\n\n // map all the client media requests to wcme media requests\n Object.values(this.clientRequests).forEach((mr) => {\n wcmeMediaRequests.push(\n new MC.MediaRequest(\n mr.policyInfo.policy === 'active-speaker'\n ? MC.Policy.ActiveSpeaker\n : MC.Policy.ReceiverSelected,\n mr.policyInfo.policy === 'active-speaker'\n ? new MC.ActiveSpeakerInfo(\n mr.policyInfo.priority,\n mr.policyInfo.crossPriorityDuplication,\n mr.policyInfo.crossPolicyDuplication,\n mr.policyInfo.preferLiveVideo\n )\n : new MC.ReceiverSelectedInfo(mr.policyInfo.csi),\n mr.receiveSlots.map((receiveSlot) => receiveSlot.wcmeReceiveSlot),\n maxPayloadBitsPerSecond,\n mr.codecInfo && [\n new MC.CodecInfo(\n 0x80,\n new MC.H264Codec(\n mr.codecInfo.maxFs || CODEC_DEFAULTS.h264.maxFs,\n mr.codecInfo.maxFps || CODEC_DEFAULTS.h264.maxFps,\n mr.codecInfo.maxMbps || CODEC_DEFAULTS.h264.maxMbps,\n mr.codecInfo.maxWidth,\n mr.codecInfo.maxHeight\n )\n ),\n ]\n )\n );\n });\n\n this.sendMediaRequestsCallback(wcmeMediaRequests);\n\n this.resetInactiveReceiveSlots();\n }\n\n public addRequest(mediaRequest: MediaRequest, commit = true): MediaRequestId {\n // eslint-disable-next-line no-plusplus\n const newId = `${this.counter++}`;\n\n this.clientRequests[newId] = mediaRequest;\n\n if (commit) {\n this.commit();\n }\n\n return newId;\n }\n\n public cancelRequest(requestId: MediaRequestId, commit = true) {\n delete this.clientRequests[requestId];\n\n if (commit) {\n this.commit();\n }\n }\n\n public commit() {\n return this.sendRequests();\n }\n\n public reset() {\n this.clientRequests = {};\n this.slotsActiveInLastMediaRequest = {};\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AACA;AAEA;AAHA;;AAyCA,IAAMA,cAAc,GAAG;EACrBC,IAAI,EAAE;IACJC,KAAK,EAAE,IAAI;IACXC,MAAM,EAAE,IAAI;IACZC,OAAO,EAAE;EACX;AACF,CAAC;AAAC,IAIWC,mBAAmB;EAS9B,6BAAYC,yBAAoD,EAAE;IAAA;IAAA;IAAA;IAAA;IAAA;IAChE,IAAI,CAACA,yBAAyB,GAAGA,yBAAyB;IAC1D,IAAI,CAACC,OAAO,GAAG,CAAC;IAChB,IAAI,CAACC,cAAc,GAAG,CAAC,CAAC;IACxB,IAAI,CAACC,6BAA6B,GAAG,CAAC,CAAC;EACzC;EAAC;IAAA;IAAA,OAED,qCAAoC;MAClC,IAAMC,WAAgD,GAAG,CAAC,CAAC;;MAE3D;MACA,qBAAc,IAAI,CAACF,cAAc,CAAC,CAACG,OAAO,CAAC,UAACC,OAAO;QAAA,OACjDA,OAAO,CAACC,YAAY,CAACF,OAAO,CAAC,UAACG,IAAI,EAAK;UACrCJ,WAAW,CAACI,IAAI,CAACC,EAAE,CAAC,GAAGD,IAAI;QAC7B,CAAC,CAAC;MAAA,EACH;;MAED;MACA;MACA;MACA,mCAA6B,sBAAe,IAAI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AS,CACdrB,EAAE,CAACmB,SAAS,CAACxC,KAAK,IAAIF,cAAc,CAACC,IAAI,CAACC,KAAK,EAC/CqB,EAAE,CAACmB,SAAS,CAACvC,MAAM,IAAIH,cAAc,CAACC,IAAI,CAACE,MAAM,EACjDoB,EAAE,CAACmB,SAAS,CAACtC,OAAO,IAAIJ,cAAc,CAACC,IAAI,CAACG,OAAO,EACnDmB,EAAE,CAACmB,SAAS,CAACG,QAAQ,EACrBtB,EAAE,CAACmB,SAAS,CAACI,SAAS,CACvB,CACF,CACF,CACF,CACF;MACH,CAAC,CAAC;MAEF,IAAI,CAACxC,yBAAyB,CAACe,iBAAiB,CAAC;MAEjD,IAAI,CAAC0B,yBAAyB,EAAE;IAClC;EAAC;IAAA;IAAA,OAED,oBAAkBC,YAA0B,EAAiC;MAAA,IAA/BC,MAAM,uEAAG,IAAI;MACzD;MACA,IAAMC,KAAK,aAAM,IAAI,CAAC3C,OAAO,EAAE,CAAE;MAEjC,IAAI,CAACC,cAAc,CAAC0C,KAAK,CAAC,GAAGF,YAAY;MAEzC,IAAIC,MAAM,EAAE;QACV,IAAI,CAACA,MAAM,EAAE;MACf;MAEA,OAAOC,KAAK;IACd;EAAC;IAAA;IAAA,OAED,uBAAqBC,SAAyB,EAAiB;MAAA,IAAfF,MAAM,uEAAG,IAAI;MAC3D,OAAO,IAAI,CAACzC,cAAc,CAAC2C,SAAS,CAAC;MAErC,IAAIF,MAAM,EAAE;QACV,IAAI,CAACA,MAAM,EAAE;MACf;IACF;EAAC;IAAA;IAAA,OAED,kBAAgB;MACd,OAAO,IAAI,CAACG,YAAY,EAAE;IAC5B;EAAC;IAAA;IAAA,OAED,iBAAe;MACb,IAAI,CAAC5C,cAAc,GAAG,CAAC,CAAC;MACxB,IAAI,CAACC,6BAA6B,GAAG,CAAC,CAAC;IACzC;EAAC;EAAA;AAAA;AAAA"}
1
+ {"version":3,"names":["CODEC_DEFAULTS","h264","maxFs","maxFps","maxMbps","MediaRequestManager","degradationPreferences","sendMediaRequestsCallback","counter","clientRequests","slotsActiveInLastMediaRequest","activeSlots","forEach","request","receiveSlots","slot","id","slotId","LoggerProxy","logger","info","resetSourceState","sendRequests","maxFsLimits","getMaxFs","totalMacroblocksRequested","mr","codecInfo","Math","min","i","length","maxMacroblocksLimit","warn","wcmeMediaRequests","getDegradedClientRequests","maxPayloadBitsPerSecond","push","WcmeMediaRequest","policyInfo","policy","Policy","ActiveSpeaker","ReceiverSelected","ActiveSpeakerInfo","priority","crossPriorityDuplication","crossPolicyDuplication","preferLiveVideo","ReceiverSelectedInfo","csi","map","receiveSlot","wcmeReceiveSlot","WcmeCodecInfo","H264Codec","maxWidth","maxHeight","resetInactiveReceiveSlots","mediaRequest","commit","newId","requestId"],"sources":["mediaRequestManager.ts"],"sourcesContent":["/* eslint-disable require-jsdoc */\nimport {\n MediaRequest as WcmeMediaRequest,\n Policy,\n ActiveSpeakerInfo,\n ReceiverSelectedInfo,\n CodecInfo as WcmeCodecInfo,\n H264Codec,\n} from '@webex/internal-media-core';\nimport {cloneDeep} from 'lodash';\n\nimport LoggerProxy from '../common/logs/logger-proxy';\n\nimport {ReceiveSlot, ReceiveSlotId} from './receiveSlot';\nimport {getMaxFs} from './remoteMedia';\n\nexport interface ActiveSpeakerPolicyInfo {\n policy: 'active-speaker';\n priority: number;\n crossPriorityDuplication: boolean;\n crossPolicyDuplication: boolean;\n preferLiveVideo: boolean;\n}\n\nexport interface ReceiverSelectedPolicyInfo {\n policy: 'receiver-selected';\n csi: number;\n}\n\nexport type PolicyInfo = ActiveSpeakerPolicyInfo | ReceiverSelectedPolicyInfo;\n\nexport interface H264CodecInfo {\n codec: 'h264';\n maxFs?: number;\n maxFps?: number;\n maxMbps?: number;\n maxWidth?: number;\n maxHeight?: number;\n}\n\nexport type CodecInfo = H264CodecInfo; // we'll add AV1 here in the future when it's available\n\nexport interface MediaRequest {\n policyInfo: PolicyInfo;\n receiveSlots: Array<ReceiveSlot>;\n codecInfo?: CodecInfo;\n}\n\nexport type MediaRequestId = string;\n\nconst CODEC_DEFAULTS = {\n h264: {\n maxFs: 8192,\n maxFps: 3000,\n maxMbps: 245760,\n },\n};\n\ntype DegradationPreferences = {\n maxMacroblocksLimit: number;\n};\n\ntype SendMediaRequestsCallback = (mediaRequests: WcmeMediaRequest[]) => void;\n\nexport class MediaRequestManager {\n private sendMediaRequestsCallback: SendMediaRequestsCallback;\n\n private counter: number;\n\n private clientRequests: {[key: MediaRequestId]: MediaRequest};\n\n private slotsActiveInLastMediaRequest: {[key: ReceiveSlotId]: ReceiveSlot};\n\n private degradationPreferences: DegradationPreferences;\n\n constructor(\n degradationPreferences: DegradationPreferences,\n sendMediaRequestsCallback: SendMediaRequestsCallback\n ) {\n this.sendMediaRequestsCallback = sendMediaRequestsCallback;\n this.counter = 0;\n this.clientRequests = {};\n this.slotsActiveInLastMediaRequest = {};\n this.degradationPreferences = degradationPreferences;\n }\n\n private resetInactiveReceiveSlots() {\n const activeSlots: {[key: ReceiveSlotId]: ReceiveSlot} = {};\n\n // create a map of all currently used slot ids\n Object.values(this.clientRequests).forEach((request) =>\n request.receiveSlots.forEach((slot) => {\n activeSlots[slot.id] = slot;\n })\n );\n\n // when we stop using some receive slots and they are not included in the new media request,\n // we will never get a 'no source' notification for them, so we reset their state,\n // so that the client doesn't try to display their video anymore\n for (const [slotId, slot] of Object.entries(this.slotsActiveInLastMediaRequest)) {\n if (!(slotId in activeSlots)) {\n LoggerProxy.logger.info(\n `multistream:mediaRequestManager --> resetting sourceState to \"no source\" for slot ${slot.id}`\n );\n slot.resetSourceState();\n }\n }\n\n this.slotsActiveInLastMediaRequest = activeSlots;\n }\n\n public setDegradationPreferences(degradationPreferences: DegradationPreferences) {\n this.degradationPreferences = degradationPreferences;\n this.sendRequests(); // re-send requests after preferences are set\n }\n\n private getDegradedClientRequests() {\n const clientRequests = cloneDeep(this.clientRequests);\n const maxFsLimits = [\n getMaxFs('best'),\n getMaxFs('large'),\n getMaxFs('medium'),\n getMaxFs('small'),\n getMaxFs('very small'),\n getMaxFs('thumbnail'),\n ];\n\n // reduce max-fs until total macroblocks is below limit\n for (let i = 0; i < maxFsLimits.length; i += 1) {\n let totalMacroblocksRequested = 0;\n Object.values(clientRequests).forEach((mr) => {\n if (mr.codecInfo) {\n mr.codecInfo.maxFs = Math.min(\n mr.codecInfo.maxFs || CODEC_DEFAULTS.h264.maxFs,\n maxFsLimits[i]\n );\n totalMacroblocksRequested += mr.codecInfo.maxFs * mr.receiveSlots.length;\n }\n });\n if (totalMacroblocksRequested <= this.degradationPreferences.maxMacroblocksLimit) {\n if (i !== 0) {\n LoggerProxy.logger.warn(\n `multistream:mediaRequestManager --> too many requests with high max-fs, frame size will be limited to ${maxFsLimits[i]}`\n );\n }\n break;\n } else if (i === maxFsLimits.length - 1) {\n LoggerProxy.logger.warn(\n `multistream:mediaRequestManager --> even with frame size limited to ${maxFsLimits[i]} you are still requesting too many streams, consider reducing the number of requests`\n );\n }\n }\n\n return clientRequests;\n }\n\n private sendRequests() {\n const wcmeMediaRequests: WcmeMediaRequest[] = [];\n\n const clientRequests = this.getDegradedClientRequests();\n const maxPayloadBitsPerSecond = 10 * 1000 * 1000;\n\n // map all the client media requests to wcme media requests\n Object.values(clientRequests).forEach((mr) => {\n wcmeMediaRequests.push(\n new WcmeMediaRequest(\n mr.policyInfo.policy === 'active-speaker'\n ? Policy.ActiveSpeaker\n : Policy.ReceiverSelected,\n mr.policyInfo.policy === 'active-speaker'\n ? new ActiveSpeakerInfo(\n mr.policyInfo.priority,\n mr.policyInfo.crossPriorityDuplication,\n mr.policyInfo.crossPolicyDuplication,\n mr.policyInfo.preferLiveVideo\n )\n : new ReceiverSelectedInfo(mr.policyInfo.csi),\n mr.receiveSlots.map((receiveSlot) => receiveSlot.wcmeReceiveSlot),\n maxPayloadBitsPerSecond,\n mr.codecInfo && [\n new WcmeCodecInfo(\n 0x80,\n new H264Codec(\n mr.codecInfo.maxFs,\n mr.codecInfo.maxFps || CODEC_DEFAULTS.h264.maxFps,\n mr.codecInfo.maxMbps || CODEC_DEFAULTS.h264.maxMbps,\n mr.codecInfo.maxWidth,\n mr.codecInfo.maxHeight\n )\n ),\n ]\n )\n );\n });\n\n this.sendMediaRequestsCallback(wcmeMediaRequests);\n\n this.resetInactiveReceiveSlots();\n }\n\n public addRequest(mediaRequest: MediaRequest, commit = true): MediaRequestId {\n // eslint-disable-next-line no-plusplus\n const newId = `${this.counter++}`;\n\n this.clientRequests[newId] = mediaRequest;\n\n if (commit) {\n this.commit();\n }\n\n return newId;\n }\n\n public cancelRequest(requestId: MediaRequestId, commit = true) {\n delete this.clientRequests[requestId];\n\n if (commit) {\n this.commit();\n }\n }\n\n public commit() {\n return this.sendRequests();\n }\n\n public reset() {\n this.clientRequests = {};\n this.slotsActiveInLastMediaRequest = {};\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AACA;AAUA;AAGA;AAdA;;AAkDA,IAAMA,cAAc,GAAG;EACrBC,IAAI,EAAE;IACJC,KAAK,EAAE,IAAI;IACXC,MAAM,EAAE,IAAI;IACZC,OAAO,EAAE;EACX;AACF,CAAC;AAAC,IAQWC,mBAAmB;EAW9B,6BACEC,sBAA8C,EAC9CC,yBAAoD,EACpD;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IACA,IAAI,CAACA,yBAAyB,GAAGA,yBAAyB;IAC1D,IAAI,CAACC,OAAO,GAAG,CAAC;IAChB,IAAI,CAACC,cAAc,GAAG,CAAC,CAAC;IACxB,IAAI,CAACC,6BAA6B,GAAG,CAAC,CAAC;IACvC,IAAI,CAACJ,sBAAsB,GAAGA,sBAAsB;EACtD;EAAC;IAAA;IAAA,OAED,qCAAoC;MAClC,IAAMK,WAAgD,GAAG,CAAC,CAAC;;MAE3D;MACA,qBAAc,IAAI,CAACF,cAAc,CAAC,CAACG,OAAO,CAAC,UAACC,OAAO;QAAA,OACjDA,OAAO,CAACC,YAAY,CAACF,OAAO,CAAC,UAACG,IAAI,EAAK;UACrCJ,WAAW,CAACI,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,kBAAgB;MACd,OAAO,IAAI,CAACtC,YAAY,EAAE;IAC5B;EAAC;IAAA;IAAA,OAED,iBAAe;MACb,IAAI,CAACb,cAAc,GAAG,CAAC,CAAC;MACxB,IAAI,CAACC,6BAA6B,GAAG,CAAC,CAAC;IACzC;EAAC;EAAA;AAAA;AAAA"}
@@ -61,12 +61,14 @@ var MultistreamMedia = /*#__PURE__*/function () {
61
61
  // todo: depending on how muting is done with Local tracks, this code here might need to change...
62
62
 
63
63
  if (track.kind === 'audio') {
64
+ // @ts-ignore
64
65
  this.meeting.setLocalAudioTrack(track);
65
66
  this.meeting.mediaProperties.mediaDirection.sendAudio = true;
66
67
 
67
68
  // audio state could be undefined if you have not sent audio before
68
69
  this.meeting.audio = this.meeting.audio || (0, _muteState.default)(_constants.AUDIO, this.meeting, this.meeting.mediaProperties.mediaDirection);
69
70
  } else if (track.kind === 'video') {
71
+ // @ts-ignore
70
72
  this.meeting.setLocalVideoTrack(track);
71
73
  this.meeting.mediaProperties.mediaDirection.sendVideo = true;
72
74
 
@@ -90,9 +92,11 @@ var MultistreamMedia = /*#__PURE__*/function () {
90
92
  // muting etc
91
93
 
92
94
  if (track.kind === 'audio') {
95
+ // @ts-ignore
93
96
  this.meeting.setLocalVideoTrack(null);
94
97
  this.meeting.mediaProperties.mediaDirection.sendAudio = false;
95
98
  } else if (track.kind === 'video') {
99
+ // @ts-ignore
96
100
  this.meeting.setLocalAudioTrack(null);
97
101
  this.meeting.mediaProperties.mediaDirection.sendVideo = false;
98
102
  }
@@ -1 +1 @@
1
- {"version":3,"names":["MultistreamMedia","meeting","mediaProperties","webrtcMediaConnection","Error","track","checkMediaConnection","kind","setLocalAudioTrack","mediaDirection","sendAudio","audio","createMuteState","AUDIO","setLocalVideoTrack","sendVideo","video","VIDEO","publishTrack","unpublishTrack"],"sources":["multistreamMedia.ts"],"sourcesContent":["/* eslint-disable import/prefer-default-export */\n\nimport {AUDIO, VIDEO} from '../constants';\nimport createMuteState from '../meeting/muteState';\nimport Meeting from '../meeting';\n\n/**\n * Class wrapping all the multistream specific APIs that need to be exposed at meeting level.\n *\n */\nexport class MultistreamMedia {\n private meeting: Meeting;\n\n /**\n * Constructor\n * @param {Meeting} meeting\n */\n constructor(meeting: Meeting) {\n this.meeting = meeting;\n }\n\n // eslint-disable-next-line valid-jsdoc\n /**\n * throws if we don't have a media connection created\n */\n private checkMediaConnection() {\n if (this.meeting?.mediaProperties?.webrtcMediaConnection) {\n return;\n }\n throw new Error('Webrtc media connection is missing');\n }\n\n /**\n * Publishes a local track in the meeting\n *\n * @param {MediaStreamTrack} track\n * @returns {Promise}\n */\n publishTrack(track: MediaStreamTrack): Promise<void> {\n this.checkMediaConnection();\n\n /* todo: for now we don't support screen share (waiting for server to support bundling, see SPARK-377812)\n for sharing:\n we have to call meeting.stopFloorRequest() before unpublishing a track\n we have to call meeting.share() after publishing a track\n */\n\n // todo: depending on how muting is done with Local tracks, this code here might need to change...\n\n if (track.kind === 'audio') {\n this.meeting.setLocalAudioTrack(track);\n this.meeting.mediaProperties.mediaDirection.sendAudio = true;\n\n // audio state could be undefined if you have not sent audio before\n this.meeting.audio =\n this.meeting.audio ||\n createMuteState(AUDIO, this.meeting, this.meeting.mediaProperties.mediaDirection);\n } else if (track.kind === 'video') {\n this.meeting.setLocalVideoTrack(track);\n this.meeting.mediaProperties.mediaDirection.sendVideo = true;\n\n // video state could be undefined if you have not sent video before\n this.meeting.video =\n this.meeting.video ||\n createMuteState(VIDEO, this.meeting, this.meeting.mediaProperties.mediaDirection);\n }\n\n return this.meeting.mediaProperties.webrtcMediaConnection.publishTrack(track);\n }\n\n /**\n * Unpublishes a local track in the meeting\n *\n * @param {MediaStreamTrack} track\n * @returns {Promise}\n */\n unpublishTrack(track: MediaStreamTrack): Promise<void> {\n // todo: see todos in publishTrack() - they all apply here too:\n // screen sharing - SPARK-377812\n // muting etc\n\n if (track.kind === 'audio') {\n this.meeting.setLocalVideoTrack(null);\n this.meeting.mediaProperties.mediaDirection.sendAudio = false;\n } else if (track.kind === 'video') {\n this.meeting.setLocalAudioTrack(null);\n this.meeting.mediaProperties.mediaDirection.sendVideo = false;\n }\n this.checkMediaConnection();\n\n return this.meeting.mediaProperties.webrtcMediaConnection.unpublishTrack(track);\n }\n}\n"],"mappings":";;;;;;;;;;;AAEA;AACA;AAHA;AAMA;AACA;AACA;AACA;AAHA,IAIaA,gBAAgB;EAG3B;AACF;AACA;AACA;EACE,0BAAYC,OAAgB,EAAE;IAAA;IAAA;IAC5B,IAAI,CAACA,OAAO,GAAGA,OAAO;EACxB;;EAEA;EACA;AACF;AACA;EAFE;IAAA;IAAA,OAGA,gCAA+B;MAAA;MAC7B,qBAAI,IAAI,CAACA,OAAO,mEAAZ,cAAcC,eAAe,kDAA7B,sBAA+BC,qBAAqB,EAAE;QACxD;MACF;MACA,MAAM,IAAIC,KAAK,CAAC,oCAAoC,CAAC;IACvD;;IAEA;AACF;AACA;AACA;AACA;AACA;EALE;IAAA;IAAA,OAMA,sBAAaC,KAAuB,EAAiB;MACnD,IAAI,CAACC,oBAAoB,EAAE;;MAE3B;AACJ;AACA;AACA;AACA;;MAEI;;MAEA,IAAID,KAAK,CAACE,IAAI,KAAK,OAAO,EAAE;QAC1B,IAAI,CAACN,OAAO,CAACO,kBAAkB,CAACH,KAAK,CAAC;QACtC,IAAI,CAACJ,OAAO,CAACC,eAAe,CAACO,cAAc,CAACC,SAAS,GAAG,IAAI;;QAE5D;QACA,IAAI,CAACT,OAAO,CAACU,KAAK,GAChB,IAAI,CAACV,OAAO,CAACU,KAAK,IAClB,IAAAC,kBAAe,EAACC,gBAAK,EAAE,IAAI,CAACZ,OAAO,EAAE,IAAI,CAACA,OAAO,CAACC,eAAe,CAACO,cAAc,CAAC;MACrF,CAAC,MAAM,IAAIJ,KAAK,CAACE,IAAI,KAAK,OAAO,EAAE;QACjC,IAAI,CAACN,OAAO,CAACa,kBAAkB,CAACT,KAAK,CAAC;QACtC,IAAI,CAACJ,OAAO,CAACC,eAAe,CAACO,cAAc,CAACM,SAAS,GAAG,IAAI;;QAE5D;QACA,IAAI,CAACd,OAAO,CAACe,KAAK,GAChB,IAAI,CAACf,OAAO,CAACe,KAAK,IAClB,IAAAJ,kBAAe,EAACK,gBAAK,EAAE,IAAI,CAAChB,OAAO,EAAE,IAAI,CAACA,OAAO,CAACC,eAAe,CAACO,cAAc,CAAC;MACrF;MAEA,OAAO,IAAI,CAACR,OAAO,CAACC,eAAe,CAACC,qBAAqB,CAACe,YAAY,CAACb,KAAK,CAAC;IAC/E;;IAEA;AACF;AACA;AACA;AACA;AACA;EALE;IAAA;IAAA,OAMA,wBAAeA,KAAuB,EAAiB;MACrD;MACA;MACA;;MAEA,IAAIA,KAAK,CAACE,IAAI,KAAK,OAAO,EAAE;QAC1B,IAAI,CAACN,OAAO,CAACa,kBAAkB,CAAC,IAAI,CAAC;QACrC,IAAI,CAACb,OAAO,CAACC,eAAe,CAACO,cAAc,CAACC,SAAS,GAAG,KAAK;MAC/D,CAAC,MAAM,IAAIL,KAAK,CAACE,IAAI,KAAK,OAAO,EAAE;QACjC,IAAI,CAACN,OAAO,CAACO,kBAAkB,CAAC,IAAI,CAAC;QACrC,IAAI,CAACP,OAAO,CAACC,eAAe,CAACO,cAAc,CAACM,SAAS,GAAG,KAAK;MAC/D;MACA,IAAI,CAACT,oBAAoB,EAAE;MAE3B,OAAO,IAAI,CAACL,OAAO,CAACC,eAAe,CAACC,qBAAqB,CAACgB,cAAc,CAACd,KAAK,CAAC;IACjF;EAAC;EAAA;AAAA;AAAA"}
1
+ {"version":3,"names":["MultistreamMedia","meeting","mediaProperties","webrtcMediaConnection","Error","track","checkMediaConnection","kind","setLocalAudioTrack","mediaDirection","sendAudio","audio","createMuteState","AUDIO","setLocalVideoTrack","sendVideo","video","VIDEO","publishTrack","unpublishTrack"],"sources":["multistreamMedia.ts"],"sourcesContent":["/* eslint-disable import/prefer-default-export */\n\nimport {AUDIO, VIDEO} from '../constants';\nimport createMuteState from '../meeting/muteState';\nimport Meeting from '../meeting';\n\n/**\n * Class wrapping all the multistream specific APIs that need to be exposed at meeting level.\n *\n */\nexport class MultistreamMedia {\n private meeting: Meeting;\n\n /**\n * Constructor\n * @param {Meeting} meeting\n */\n constructor(meeting: Meeting) {\n this.meeting = meeting;\n }\n\n // eslint-disable-next-line valid-jsdoc\n /**\n * throws if we don't have a media connection created\n */\n private checkMediaConnection() {\n if (this.meeting?.mediaProperties?.webrtcMediaConnection) {\n return;\n }\n throw new Error('Webrtc media connection is missing');\n }\n\n /**\n * Publishes a local track in the meeting\n *\n * @param {MediaStreamTrack} track\n * @returns {Promise}\n */\n publishTrack(track: MediaStreamTrack): Promise<void> {\n this.checkMediaConnection();\n\n /* todo: for now we don't support screen share (waiting for server to support bundling, see SPARK-377812)\n for sharing:\n we have to call meeting.stopFloorRequest() before unpublishing a track\n we have to call meeting.share() after publishing a track\n */\n\n // todo: depending on how muting is done with Local tracks, this code here might need to change...\n\n if (track.kind === 'audio') {\n // @ts-ignore\n this.meeting.setLocalAudioTrack(track);\n this.meeting.mediaProperties.mediaDirection.sendAudio = true;\n\n // audio state could be undefined if you have not sent audio before\n this.meeting.audio =\n this.meeting.audio ||\n createMuteState(AUDIO, this.meeting, this.meeting.mediaProperties.mediaDirection);\n } else if (track.kind === 'video') {\n // @ts-ignore\n this.meeting.setLocalVideoTrack(track);\n this.meeting.mediaProperties.mediaDirection.sendVideo = true;\n\n // video state could be undefined if you have not sent video before\n this.meeting.video =\n this.meeting.video ||\n createMuteState(VIDEO, this.meeting, this.meeting.mediaProperties.mediaDirection);\n }\n\n return this.meeting.mediaProperties.webrtcMediaConnection.publishTrack(track);\n }\n\n /**\n * Unpublishes a local track in the meeting\n *\n * @param {MediaStreamTrack} track\n * @returns {Promise}\n */\n unpublishTrack(track: MediaStreamTrack): Promise<void> {\n // todo: see todos in publishTrack() - they all apply here too:\n // screen sharing - SPARK-377812\n // muting etc\n\n if (track.kind === 'audio') {\n // @ts-ignore\n this.meeting.setLocalVideoTrack(null);\n this.meeting.mediaProperties.mediaDirection.sendAudio = false;\n } else if (track.kind === 'video') {\n // @ts-ignore\n this.meeting.setLocalAudioTrack(null);\n this.meeting.mediaProperties.mediaDirection.sendVideo = false;\n }\n this.checkMediaConnection();\n\n return this.meeting.mediaProperties.webrtcMediaConnection.unpublishTrack(track);\n }\n}\n"],"mappings":";;;;;;;;;;;AAEA;AACA;AAHA;AAMA;AACA;AACA;AACA;AAHA,IAIaA,gBAAgB;EAG3B;AACF;AACA;AACA;EACE,0BAAYC,OAAgB,EAAE;IAAA;IAAA;IAC5B,IAAI,CAACA,OAAO,GAAGA,OAAO;EACxB;;EAEA;EACA;AACF;AACA;EAFE;IAAA;IAAA,OAGA,gCAA+B;MAAA;MAC7B,qBAAI,IAAI,CAACA,OAAO,mEAAZ,cAAcC,eAAe,kDAA7B,sBAA+BC,qBAAqB,EAAE;QACxD;MACF;MACA,MAAM,IAAIC,KAAK,CAAC,oCAAoC,CAAC;IACvD;;IAEA;AACF;AACA;AACA;AACA;AACA;EALE;IAAA;IAAA,OAMA,sBAAaC,KAAuB,EAAiB;MACnD,IAAI,CAACC,oBAAoB,EAAE;;MAE3B;AACJ;AACA;AACA;AACA;;MAEI;;MAEA,IAAID,KAAK,CAACE,IAAI,KAAK,OAAO,EAAE;QAC1B;QACA,IAAI,CAACN,OAAO,CAACO,kBAAkB,CAACH,KAAK,CAAC;QACtC,IAAI,CAACJ,OAAO,CAACC,eAAe,CAACO,cAAc,CAACC,SAAS,GAAG,IAAI;;QAE5D;QACA,IAAI,CAACT,OAAO,CAACU,KAAK,GAChB,IAAI,CAACV,OAAO,CAACU,KAAK,IAClB,IAAAC,kBAAe,EAACC,gBAAK,EAAE,IAAI,CAACZ,OAAO,EAAE,IAAI,CAACA,OAAO,CAACC,eAAe,CAACO,cAAc,CAAC;MACrF,CAAC,MAAM,IAAIJ,KAAK,CAACE,IAAI,KAAK,OAAO,EAAE;QACjC;QACA,IAAI,CAACN,OAAO,CAACa,kBAAkB,CAACT,KAAK,CAAC;QACtC,IAAI,CAACJ,OAAO,CAACC,eAAe,CAACO,cAAc,CAACM,SAAS,GAAG,IAAI;;QAE5D;QACA,IAAI,CAACd,OAAO,CAACe,KAAK,GAChB,IAAI,CAACf,OAAO,CAACe,KAAK,IAClB,IAAAJ,kBAAe,EAACK,gBAAK,EAAE,IAAI,CAAChB,OAAO,EAAE,IAAI,CAACA,OAAO,CAACC,eAAe,CAACO,cAAc,CAAC;MACrF;MAEA,OAAO,IAAI,CAACR,OAAO,CAACC,eAAe,CAACC,qBAAqB,CAACe,YAAY,CAACb,KAAK,CAAC;IAC/E;;IAEA;AACF;AACA;AACA;AACA;AACA;EALE;IAAA;IAAA,OAMA,wBAAeA,KAAuB,EAAiB;MACrD;MACA;MACA;;MAEA,IAAIA,KAAK,CAACE,IAAI,KAAK,OAAO,EAAE;QAC1B;QACA,IAAI,CAACN,OAAO,CAACa,kBAAkB,CAAC,IAAI,CAAC;QACrC,IAAI,CAACb,OAAO,CAACC,eAAe,CAACO,cAAc,CAACC,SAAS,GAAG,KAAK;MAC/D,CAAC,MAAM,IAAIL,KAAK,CAACE,IAAI,KAAK,OAAO,EAAE;QACjC;QACA,IAAI,CAACN,OAAO,CAACO,kBAAkB,CAAC,IAAI,CAAC;QACrC,IAAI,CAACP,OAAO,CAACC,eAAe,CAACO,cAAc,CAACM,SAAS,GAAG,KAAK;MAC/D;MACA,IAAI,CAACT,oBAAoB,EAAE;MAE3B,OAAO,IAAI,CAACL,OAAO,CAACC,eAAe,CAACC,qBAAqB,CAACgB,cAAc,CAACd,KAAK,CAAC;IACjF;EAAC;EAAA;AAAA;AAAA"}
@@ -43,8 +43,8 @@ var ReceiveSlot = /*#__PURE__*/function (_EventsScope) {
43
43
  * constructor - don't use it directly, you should always use meeting.receiveSlotManager.allocateSlot()
44
44
  * to create any receive slots
45
45
  *
46
- * @param {MC.MediaType} mediaType
47
- * @param {MC.ReceiveSlot} mcReceiveSlot
46
+ * @param {MediaType} mediaType
47
+ * @param {ReceiveSlot} mcReceiveSlot
48
48
  * @param {FindMemberIdCallback} findMemberIdCallback callback for finding memberId for given CSI
49
49
  */
50
50
  function ReceiveSlot(mediaType, mcReceiveSlot, findMemberIdCallback) {
@@ -115,7 +115,7 @@ var ReceiveSlot = /*#__PURE__*/function (_EventsScope) {
115
115
  file: 'meeting/receiveSlot',
116
116
  function: 'setupEventListeners'
117
117
  };
118
- this.mcReceiveSlot.on(_internalMediaCore.MediaConnection.ReceiveSlotEvents.SourceUpdate, function (state, csi) {
118
+ this.mcReceiveSlot.on(_internalMediaCore.ReceiveSlotEvents.SourceUpdate, function (state, csi) {
119
119
  _loggerProxy.default.logger.log("ReceiveSlot#setupEventListeners --> got source update on receive slot ".concat(_this2.id, ", mediaType=").concat(_this2.mediaType, ", csi=").concat(csi, ", state=").concat(state));
120
120
  (0, _classPrivateFieldSet2.default)(_this2, _memberId, csi ? _this2.findMemberIdCallback(csi) : undefined);
121
121
  (0, _classPrivateFieldSet2.default)(_this2, _csi, csi);
@@ -1 +1 @@
1
- {"version":3,"names":["ReceiveSlotEvents","SourceUpdate","receiveSlotCounter","ReceiveSlot","mediaType","mcReceiveSlot","findMemberIdCallback","id","setupEventListeners","scope","file","function","on","MC","state","csi","LoggerProxy","logger","log","undefined","emit","memberId","stream","EventsScope"],"sources":["receiveSlot.ts"],"sourcesContent":["/* eslint-disable valid-jsdoc */\nimport {MediaConnection as MC} from '@webex/internal-media-core';\n\nimport LoggerProxy from '../common/logs/logger-proxy';\nimport EventsScope from '../common/events/events-scope';\n\nexport const ReceiveSlotEvents = {\n SourceUpdate: 'sourceUpdate',\n};\n\nexport type SourceState = MC.SourceState;\nexport type CSI = number;\nexport type MemberId = string;\nexport type ReceiveSlotId = string;\n\nlet receiveSlotCounter = 0;\n\nexport type FindMemberIdCallback = (csi: CSI) => MemberId | undefined;\n\n/**\n * Class representing a receive slot. A single receive slot is able to receive a single track\n * for example some participant's main video or audio\n */\nexport class ReceiveSlot extends EventsScope {\n private readonly mcReceiveSlot: MC.ReceiveSlot;\n\n private readonly findMemberIdCallback: FindMemberIdCallback;\n\n public readonly id: ReceiveSlotId;\n\n public readonly mediaType: MC.MediaType;\n\n #memberId?: MemberId;\n\n #csi?: CSI;\n\n #sourceState: MC.SourceState;\n\n /**\n * constructor - don't use it directly, you should always use meeting.receiveSlotManager.allocateSlot()\n * to create any receive slots\n *\n * @param {MC.MediaType} mediaType\n * @param {MC.ReceiveSlot} mcReceiveSlot\n * @param {FindMemberIdCallback} findMemberIdCallback callback for finding memberId for given CSI\n */\n constructor(\n mediaType: MC.MediaType,\n mcReceiveSlot: MC.ReceiveSlot,\n findMemberIdCallback: FindMemberIdCallback\n ) {\n super();\n\n receiveSlotCounter += 1;\n\n this.findMemberIdCallback = findMemberIdCallback;\n this.mediaType = mediaType;\n this.mcReceiveSlot = mcReceiveSlot;\n this.#sourceState = 'no source';\n this.id = `r${receiveSlotCounter}`;\n\n this.setupEventListeners();\n }\n\n /**\n * Getter for memberId\n */\n public get memberId() {\n return this.#memberId;\n }\n\n /**\n * Getter for csi\n */\n public get csi() {\n return this.#csi;\n }\n\n /**\n * Getter for sourceState\n */\n public get sourceState() {\n return this.#sourceState;\n }\n\n /**\n * registers event handlers with the underlying ReceiveSlot\n */\n setupEventListeners() {\n const scope = {\n file: 'meeting/receiveSlot',\n function: 'setupEventListeners',\n };\n\n this.mcReceiveSlot.on(\n MC.ReceiveSlotEvents.SourceUpdate,\n (state: MC.SourceState, csi?: number) => {\n LoggerProxy.logger.log(\n `ReceiveSlot#setupEventListeners --> got source update on receive slot ${this.id}, mediaType=${this.mediaType}, csi=${csi}, state=${state}`\n );\n this.#memberId = csi ? this.findMemberIdCallback(csi) : undefined;\n this.#csi = csi;\n this.#sourceState = state;\n\n this.emit(scope, ReceiveSlotEvents.SourceUpdate, {\n state: this.#sourceState,\n csi: this.#csi,\n memberId: this.#memberId,\n });\n }\n );\n }\n\n /**\n * The MediaStream object associated with this slot.\n *\n * @returns {MediaStream} The MediaStreamTrack.\n */\n get stream(): MediaStream {\n return this.mcReceiveSlot.stream;\n }\n\n /**\n * The underlying WCME receive slot\n */\n get wcmeReceiveSlot(): MC.ReceiveSlot {\n return this.mcReceiveSlot;\n }\n\n /**\n * Resets the source state to the default 'no source' value.\n * This function should be called on receive slots that are\n * no longer part of a media request. It's needed because WCME\n * does not send any more events on such slots, so the sourceState\n * value would not represent the truth anymore.\n */\n public resetSourceState() {\n this.#sourceState = 'no source';\n this.#csi = undefined;\n this.#memberId = undefined;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AACA;AAEA;AACA;AAAwD;AAAA;AAAA;AAAA;AAEjD,IAAMA,iBAAiB,GAAG;EAC/BC,YAAY,EAAE;AAChB,CAAC;AAAC;AAOF,IAAIC,kBAAkB,GAAG,CAAC;AAAC;AAAA;AAAA;AAI3B;AACA;AACA;AACA;AAHA,IAIaC,WAAW;EAAA;EAAA;EAetB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,qBACEC,SAAuB,EACvBC,aAA6B,EAC7BC,oBAA0C,EAC1C;IAAA;IAAA;IACA;IAAQ;IAAA;IAAA;IAAA;IAAA;MAAA;MAAA;IAAA;IAAA;MAAA;MAAA;IAAA;IAAA;MAAA;MAAA;IAAA;IAERJ,kBAAkB,IAAI,CAAC;IAEvB,MAAKI,oBAAoB,GAAGA,oBAAoB;IAChD,MAAKF,SAAS,GAAGA,SAAS;IAC1B,MAAKC,aAAa,GAAGA,aAAa;IAClC,+FAAoB,WAAW;IAC/B,MAAKE,EAAE,cAAOL,kBAAkB,CAAE;IAElC,MAAKM,mBAAmB,EAAE;IAAC;EAC7B;;EAEA;AACF;AACA;EAFE;IAAA;IAAA,KAGA,eAAsB;MACpB,2CAAO,IAAI;IACb;;IAEA;AACF;AACA;EAFE;IAAA;IAAA,KAGA,eAAiB;MACf,2CAAO,IAAI;IACb;;IAEA;AACF;AACA;EAFE;IAAA;IAAA,KAGA,eAAyB;MACvB,2CAAO,IAAI;IACb;;IAEA;AACF;AACA;EAFE;IAAA;IAAA,OAGA,+BAAsB;MAAA;MACpB,IAAMC,KAAK,GAAG;QACZC,IAAI,EAAE,qBAAqB;QAC3BC,QAAQ,EAAE;MACZ,CAAC;MAED,IAAI,CAACN,aAAa,CAACO,EAAE,CACnBC,kCAAE,CAACb,iBAAiB,CAACC,YAAY,EACjC,UAACa,KAAqB,EAAEC,GAAY,EAAK;QACvCC,oBAAW,CAACC,MAAM,CAACC,GAAG,iFACqD,MAAI,CAACX,EAAE,yBAAe,MAAI,CAACH,SAAS,mBAASW,GAAG,qBAAWD,KAAK,EAC1I;QACD,0CAAI,aAAaC,GAAG,GAAG,MAAI,CAACT,oBAAoB,CAACS,GAAG,CAAC,GAAGI,SAAS;QACjE,0CAAI,QAAQJ,GAAG;QACf,0CAAI,gBAAgBD,KAAK;QAEzB,MAAI,CAACM,IAAI,CAACX,KAAK,EAAET,iBAAiB,CAACC,YAAY,EAAE;UAC/Ca,KAAK,sCAAE,MAAI,eAAa;UACxBC,GAAG,sCAAE,MAAI,OAAK;UACdM,QAAQ,sCAAE,MAAI;QAChB,CAAC,CAAC;MACJ,CAAC,CACF;IACH;;IAEA;AACF;AACA;AACA;AACA;EAJE;IAAA;IAAA,KAKA,eAA0B;MACxB,OAAO,IAAI,CAAChB,aAAa,CAACiB,MAAM;IAClC;;IAEA;AACF;AACA;EAFE;IAAA;IAAA,KAGA,eAAsC;MACpC,OAAO,IAAI,CAACjB,aAAa;IAC3B;;IAEA;AACF;AACA;AACA;AACA;AACA;AACA;EANE;IAAA;IAAA,OAOA,4BAA0B;MACxB,wCAAI,gBAAgB,WAAW;MAC/B,wCAAI,QAAQc,SAAS;MACrB,wCAAI,aAAaA,SAAS;IAC5B;EAAC;EAAA;AAAA,EArH8BI,oBAAW;AAAA"}
1
+ {"version":3,"names":["ReceiveSlotEvents","SourceUpdate","receiveSlotCounter","ReceiveSlot","mediaType","mcReceiveSlot","findMemberIdCallback","id","setupEventListeners","scope","file","function","on","WcmeReceiveSlotEvents","state","csi","LoggerProxy","logger","log","undefined","emit","memberId","stream","EventsScope"],"sources":["receiveSlot.ts"],"sourcesContent":["/* eslint-disable valid-jsdoc */\nimport {\n MediaType,\n ReceiveSlot as WcmeReceiveSlot,\n ReceiveSlotEvents as WcmeReceiveSlotEvents,\n SourceState,\n} from '@webex/internal-media-core';\n\nimport LoggerProxy from '../common/logs/logger-proxy';\nimport EventsScope from '../common/events/events-scope';\n\nexport const ReceiveSlotEvents = {\n SourceUpdate: 'sourceUpdate',\n};\n\nexport type {SourceState} from '@webex/internal-media-core';\nexport type CSI = number;\nexport type MemberId = string;\nexport type ReceiveSlotId = string;\n\nlet receiveSlotCounter = 0;\n\nexport type FindMemberIdCallback = (csi: CSI) => MemberId | undefined;\n\n/**\n * Class representing a receive slot. A single receive slot is able to receive a single track\n * for example some participant's main video or audio\n */\nexport class ReceiveSlot extends EventsScope {\n private readonly mcReceiveSlot: WcmeReceiveSlot;\n\n private readonly findMemberIdCallback: FindMemberIdCallback;\n\n public readonly id: ReceiveSlotId;\n\n public readonly mediaType: MediaType;\n\n #memberId?: MemberId;\n\n #csi?: CSI;\n\n #sourceState: SourceState;\n\n /**\n * constructor - don't use it directly, you should always use meeting.receiveSlotManager.allocateSlot()\n * to create any receive slots\n *\n * @param {MediaType} mediaType\n * @param {ReceiveSlot} mcReceiveSlot\n * @param {FindMemberIdCallback} findMemberIdCallback callback for finding memberId for given CSI\n */\n constructor(\n mediaType: MediaType,\n mcReceiveSlot: WcmeReceiveSlot,\n findMemberIdCallback: FindMemberIdCallback\n ) {\n super();\n\n receiveSlotCounter += 1;\n\n this.findMemberIdCallback = findMemberIdCallback;\n this.mediaType = mediaType;\n this.mcReceiveSlot = mcReceiveSlot;\n this.#sourceState = 'no source';\n this.id = `r${receiveSlotCounter}`;\n\n this.setupEventListeners();\n }\n\n /**\n * Getter for memberId\n */\n public get memberId() {\n return this.#memberId;\n }\n\n /**\n * Getter for csi\n */\n public get csi() {\n return this.#csi;\n }\n\n /**\n * Getter for sourceState\n */\n public get sourceState() {\n return this.#sourceState;\n }\n\n /**\n * registers event handlers with the underlying ReceiveSlot\n */\n setupEventListeners() {\n const scope = {\n file: 'meeting/receiveSlot',\n function: 'setupEventListeners',\n };\n\n this.mcReceiveSlot.on(\n WcmeReceiveSlotEvents.SourceUpdate,\n (state: SourceState, csi?: number) => {\n LoggerProxy.logger.log(\n `ReceiveSlot#setupEventListeners --> got source update on receive slot ${this.id}, mediaType=${this.mediaType}, csi=${csi}, state=${state}`\n );\n this.#memberId = csi ? this.findMemberIdCallback(csi) : undefined;\n this.#csi = csi;\n this.#sourceState = state;\n\n this.emit(scope, ReceiveSlotEvents.SourceUpdate, {\n state: this.#sourceState,\n csi: this.#csi,\n memberId: this.#memberId,\n });\n }\n );\n }\n\n /**\n * The MediaStream object associated with this slot.\n *\n * @returns {MediaStream} The MediaStreamTrack.\n */\n get stream(): MediaStream {\n return this.mcReceiveSlot.stream;\n }\n\n /**\n * The underlying WCME receive slot\n */\n get wcmeReceiveSlot(): WcmeReceiveSlot {\n return this.mcReceiveSlot;\n }\n\n /**\n * Resets the source state to the default 'no source' value.\n * This function should be called on receive slots that are\n * no longer part of a media request. It's needed because WCME\n * does not send any more events on such slots, so the sourceState\n * value would not represent the truth anymore.\n */\n public resetSourceState() {\n this.#sourceState = 'no source';\n this.#csi = undefined;\n this.#memberId = undefined;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AACA;AAOA;AACA;AAAwD;AAAA;AAAA;AAAA;AAEjD,IAAMA,iBAAiB,GAAG;EAC/BC,YAAY,EAAE;AAChB,CAAC;AAAC;AAOF,IAAIC,kBAAkB,GAAG,CAAC;AAAC;AAAA;AAAA;AAI3B;AACA;AACA;AACA;AAHA,IAIaC,WAAW;EAAA;EAAA;EAetB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACE,qBACEC,SAAoB,EACpBC,aAA8B,EAC9BC,oBAA0C,EAC1C;IAAA;IAAA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AC,CAAC;MACJ,CAAC,CACF;IACH;;IAEA;AACF;AACA;AACA;AACA;EAJE;IAAA;IAAA,KAKA,eAA0B;MACxB,OAAO,IAAI,CAAChB,aAAa,CAACiB,MAAM;IAClC;;IAEA;AACF;AACA;EAFE;IAAA;IAAA,KAGA,eAAuC;MACrC,OAAO,IAAI,CAACjB,aAAa;IAC3B;;IAEA;AACF;AACA;AACA;AACA;AACA;AACA;EANE;IAAA;IAAA,OAOA,4BAA0B;MACxB,wCAAI,gBAAgB,WAAW;MAC/B,wCAAI,QAAQc,SAAS;MACrB,wCAAI,aAAaA,SAAS;IAC5B;EAAC;EAAA;AAAA,EArH8BI,oBAAW;AAAA"}
@@ -33,15 +33,15 @@ var ReceiveSlotManager = /*#__PURE__*/function () {
33
33
  (0, _defineProperty2.default)(this, "allocatedSlots", void 0);
34
34
  (0, _defineProperty2.default)(this, "freeSlots", void 0);
35
35
  (0, _defineProperty2.default)(this, "meeting", void 0);
36
- this.allocatedSlots = (_this$allocatedSlots = {}, (0, _defineProperty2.default)(_this$allocatedSlots, _internalMediaCore.MediaConnection.MediaType.AudioMain, []), (0, _defineProperty2.default)(_this$allocatedSlots, _internalMediaCore.MediaConnection.MediaType.VideoMain, []), (0, _defineProperty2.default)(_this$allocatedSlots, _internalMediaCore.MediaConnection.MediaType.AudioSlides, []), (0, _defineProperty2.default)(_this$allocatedSlots, _internalMediaCore.MediaConnection.MediaType.VideoSlides, []), _this$allocatedSlots);
37
- this.freeSlots = (_this$freeSlots = {}, (0, _defineProperty2.default)(_this$freeSlots, _internalMediaCore.MediaConnection.MediaType.AudioMain, []), (0, _defineProperty2.default)(_this$freeSlots, _internalMediaCore.MediaConnection.MediaType.VideoMain, []), (0, _defineProperty2.default)(_this$freeSlots, _internalMediaCore.MediaConnection.MediaType.AudioSlides, []), (0, _defineProperty2.default)(_this$freeSlots, _internalMediaCore.MediaConnection.MediaType.VideoSlides, []), _this$freeSlots);
36
+ this.allocatedSlots = (_this$allocatedSlots = {}, (0, _defineProperty2.default)(_this$allocatedSlots, _internalMediaCore.MediaType.AudioMain, []), (0, _defineProperty2.default)(_this$allocatedSlots, _internalMediaCore.MediaType.VideoMain, []), (0, _defineProperty2.default)(_this$allocatedSlots, _internalMediaCore.MediaType.AudioSlides, []), (0, _defineProperty2.default)(_this$allocatedSlots, _internalMediaCore.MediaType.VideoSlides, []), _this$allocatedSlots);
37
+ this.freeSlots = (_this$freeSlots = {}, (0, _defineProperty2.default)(_this$freeSlots, _internalMediaCore.MediaType.AudioMain, []), (0, _defineProperty2.default)(_this$freeSlots, _internalMediaCore.MediaType.VideoMain, []), (0, _defineProperty2.default)(_this$freeSlots, _internalMediaCore.MediaType.AudioSlides, []), (0, _defineProperty2.default)(_this$freeSlots, _internalMediaCore.MediaType.VideoSlides, []), _this$freeSlots);
38
38
  this.meeting = meeting;
39
39
  }
40
40
 
41
41
  /**
42
42
  * Creates a new receive slot or returns one from the existing pool of free slots
43
43
  *
44
- * @param {MC.MediaType} mediaType
44
+ * @param {MediaType} mediaType
45
45
  * @returns {Promise<ReceiveSlot>}
46
46
  */
47
47
  (0, _createClass2.default)(ReceiveSlotManager, [{
@@ -75,7 +75,9 @@ var ReceiveSlotManager = /*#__PURE__*/function () {
75
75
  return this.meeting.mediaProperties.webrtcMediaConnection.createReceiveSlot(mediaType);
76
76
  case 9:
77
77
  wcmeReceiveSlot = _context.sent;
78
- receiveSlot = new _receiveSlot.ReceiveSlot(mediaType, wcmeReceiveSlot, function (csi) {
78
+ receiveSlot = new _receiveSlot.ReceiveSlot(mediaType, wcmeReceiveSlot,
79
+ // @ts-ignore
80
+ function (csi) {
79
81
  var _this$meeting$members;
80
82
  return (_this$meeting$members = _this.meeting.members.findMemberByCsi(csi)) === null || _this$meeting$members === void 0 ? void 0 : _this$meeting$members.id;
81
83
  });
@@ -119,8 +121,8 @@ var ReceiveSlotManager = /*#__PURE__*/function () {
119
121
  key: "reset",
120
122
  value: function reset() {
121
123
  var _this$allocatedSlots2, _this$freeSlots2;
122
- this.allocatedSlots = (_this$allocatedSlots2 = {}, (0, _defineProperty2.default)(_this$allocatedSlots2, _internalMediaCore.MediaConnection.MediaType.AudioMain, []), (0, _defineProperty2.default)(_this$allocatedSlots2, _internalMediaCore.MediaConnection.MediaType.VideoMain, []), (0, _defineProperty2.default)(_this$allocatedSlots2, _internalMediaCore.MediaConnection.MediaType.AudioSlides, []), (0, _defineProperty2.default)(_this$allocatedSlots2, _internalMediaCore.MediaConnection.MediaType.VideoSlides, []), _this$allocatedSlots2);
123
- this.freeSlots = (_this$freeSlots2 = {}, (0, _defineProperty2.default)(_this$freeSlots2, _internalMediaCore.MediaConnection.MediaType.AudioMain, []), (0, _defineProperty2.default)(_this$freeSlots2, _internalMediaCore.MediaConnection.MediaType.VideoMain, []), (0, _defineProperty2.default)(_this$freeSlots2, _internalMediaCore.MediaConnection.MediaType.AudioSlides, []), (0, _defineProperty2.default)(_this$freeSlots2, _internalMediaCore.MediaConnection.MediaType.VideoSlides, []), _this$freeSlots2);
124
+ this.allocatedSlots = (_this$allocatedSlots2 = {}, (0, _defineProperty2.default)(_this$allocatedSlots2, _internalMediaCore.MediaType.AudioMain, []), (0, _defineProperty2.default)(_this$allocatedSlots2, _internalMediaCore.MediaType.VideoMain, []), (0, _defineProperty2.default)(_this$allocatedSlots2, _internalMediaCore.MediaType.AudioSlides, []), (0, _defineProperty2.default)(_this$allocatedSlots2, _internalMediaCore.MediaType.VideoSlides, []), _this$allocatedSlots2);
125
+ this.freeSlots = (_this$freeSlots2 = {}, (0, _defineProperty2.default)(_this$freeSlots2, _internalMediaCore.MediaType.AudioMain, []), (0, _defineProperty2.default)(_this$freeSlots2, _internalMediaCore.MediaType.VideoMain, []), (0, _defineProperty2.default)(_this$freeSlots2, _internalMediaCore.MediaType.AudioSlides, []), (0, _defineProperty2.default)(_this$freeSlots2, _internalMediaCore.MediaType.VideoSlides, []), _this$freeSlots2);
124
126
  }
125
127
 
126
128
  /**
@@ -1 +1 @@
1
- {"version":3,"names":["ReceiveSlotManager","meeting","allocatedSlots","MC","MediaType","AudioMain","VideoMain","AudioSlides","VideoSlides","freeSlots","mediaType","mediaProperties","webrtcMediaConnection","reject","Error","availableSlot","pop","push","LoggerProxy","logger","log","id","createReceiveSlot","wcmeReceiveSlot","receiveSlot","ReceiveSlot","csi","members","findMemberByCsi","slot","idx","findIndex","allocatedSlot","splice","warn","numAllocatedSlots","numFreeSlots","forEach","key","length"],"sources":["receiveSlotManager.ts"],"sourcesContent":["/* eslint-disable valid-jsdoc */\n/* eslint-disable import/prefer-default-export */\nimport {MediaConnection as MC} from '@webex/internal-media-core';\n\nimport LoggerProxy from '../common/logs/logger-proxy';\nimport Meeting from '../meeting';\n\nimport {CSI, ReceiveSlot} from './receiveSlot';\n\n/**\n * Manages all receive slots used by a meeting. WMCE receive slots cannot be ever deleted,\n * so this manager has a pool in order to re-use the slots that were released earlier.\n */\nexport class ReceiveSlotManager {\n private allocatedSlots: {[key in MC.MediaType]: ReceiveSlot[]};\n\n private freeSlots: {[key in MC.MediaType]: ReceiveSlot[]};\n\n private meeting: Meeting;\n\n /**\n * Constructor\n * @param {Meeting} meeting\n */\n constructor(meeting) {\n this.allocatedSlots = {\n [MC.MediaType.AudioMain]: [],\n [MC.MediaType.VideoMain]: [],\n [MC.MediaType.AudioSlides]: [],\n [MC.MediaType.VideoSlides]: [],\n };\n this.freeSlots = {\n [MC.MediaType.AudioMain]: [],\n [MC.MediaType.VideoMain]: [],\n [MC.MediaType.AudioSlides]: [],\n [MC.MediaType.VideoSlides]: [],\n };\n this.meeting = meeting;\n }\n\n /**\n * Creates a new receive slot or returns one from the existing pool of free slots\n *\n * @param {MC.MediaType} mediaType\n * @returns {Promise<ReceiveSlot>}\n */\n async allocateSlot(mediaType: MC.MediaType): Promise<ReceiveSlot> {\n if (!this.meeting?.mediaProperties?.webrtcMediaConnection) {\n return Promise.reject(new Error('Webrtc media connection is missing'));\n }\n\n // try to use one of the free ones\n const availableSlot = this.freeSlots[mediaType].pop();\n\n if (availableSlot) {\n this.allocatedSlots[mediaType].push(availableSlot);\n\n LoggerProxy.logger.log(`receive slot re-used: ${availableSlot.id}`);\n\n return availableSlot;\n }\n\n // we have to create a new one\n const wcmeReceiveSlot =\n await this.meeting.mediaProperties.webrtcMediaConnection.createReceiveSlot(mediaType);\n\n const receiveSlot = new ReceiveSlot(\n mediaType,\n wcmeReceiveSlot,\n (csi: CSI) => this.meeting.members.findMemberByCsi(csi)?.id\n );\n\n this.allocatedSlots[mediaType].push(receiveSlot);\n LoggerProxy.logger.log(`new receive slot allocated: ${receiveSlot.id}`);\n\n return receiveSlot;\n }\n\n /**\n * Releases the slot back to the pool so it can be re-used by others in the future\n * @param {ReceiveSlot} slot\n */\n releaseSlot(slot: ReceiveSlot) {\n const idx = this.allocatedSlots[slot.mediaType].findIndex(\n (allocatedSlot) => allocatedSlot === slot\n );\n\n if (idx >= 0) {\n this.allocatedSlots[slot.mediaType].splice(idx, 1);\n this.freeSlots[slot.mediaType].push(slot);\n LoggerProxy.logger.log(`receive slot released: ${slot.id}`);\n } else {\n LoggerProxy.logger.warn(\n 'ReceiveSlotManager#releaseSlot --> trying to release a slot that is not managed by this ReceiveSlotManager'\n );\n }\n }\n\n /**\n * Resets the slot manager - this method should be called when the media connection is torn down\n */\n reset() {\n this.allocatedSlots = {\n [MC.MediaType.AudioMain]: [],\n [MC.MediaType.VideoMain]: [],\n [MC.MediaType.AudioSlides]: [],\n [MC.MediaType.VideoSlides]: [],\n };\n this.freeSlots = {\n [MC.MediaType.AudioMain]: [],\n [MC.MediaType.VideoMain]: [],\n [MC.MediaType.AudioSlides]: [],\n [MC.MediaType.VideoSlides]: [],\n };\n }\n\n /**\n * Returns statistics about the managed slots\n *\n * @returns {Object}\n */\n getStats() {\n const numAllocatedSlots = {};\n const numFreeSlots = {};\n\n Object.keys(this.allocatedSlots).forEach((key) => {\n if (this.allocatedSlots[key].length > 0) {\n numAllocatedSlots[key] = this.allocatedSlots[key].length;\n }\n });\n\n Object.keys(this.freeSlots).forEach((key) => {\n if (this.freeSlots[key].length > 0) {\n numFreeSlots[key] = this.freeSlots[key].length;\n }\n });\n\n return {\n numAllocatedSlots,\n numFreeSlots,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAEA;AAEA;AAGA;AAPA;AACA;AAQA;AACA;AACA;AACA;AAHA,IAIaA,kBAAkB;EAO7B;AACF;AACA;AACA;EACE,4BAAYC,OAAO,EAAE;IAAA;IAAA;IAAA;IAAA;IAAA;IACnB,IAAI,CAACC,cAAc,mFAChBC,kCAAE,CAACC,SAAS,CAACC,SAAS,EAAG,EAAE,uDAC3BF,kCAAE,CAACC,SAAS,CAACE,SAAS,EAAG,EAAE,uDAC3BH,kCAAE,CAACC,SAAS,CAACG,WAAW,EAAG,EAAE,uDAC7BJ,kCAAE,CAACC,SAAS,CAACI,WAAW,EAAG,EAAE,wBAC/B;IACD,IAAI,CAACC,SAAS,yEACXN,kCAAE,CAACC,SAAS,CAACC,SAAS,EAAG,EAAE,kDAC3BF,kCAAE,CAACC,SAAS,CAACE,SAAS,EAAG,EAAE,kDAC3BH,kCAAE,CAACC,SAAS,CAACG,WAAW,EAAG,EAAE,kDAC7BJ,kCAAE,CAACC,SAAS,CAACI,WAAW,EAAG,EAAE,mBAC/B;IACD,IAAI,CAACP,OAAO,GAAGA,OAAO;EACxB;;EAEA;AACF;AACA;AACA;AACA;AACA;EALE;IAAA;IAAA;MAAA,4FAMA,iBAAmBS,SAAuB;QAAA;UAAA;UAAA;QAAA;QAAA;UAAA;YAAA;cAAA,qBACnC,IAAI,CAACT,OAAO,mEAAZ,cAAcU,eAAe,kDAA7B,sBAA+BC,qBAAqB;gBAAA;gBAAA;cAAA;cAAA,iCAChD,iBAAQC,MAAM,CAAC,IAAIC,KAAK,CAAC,oCAAoC,CAAC,CAAC;YAAA;cAGxE;cACMC,aAAa,GAAG,IAAI,CAACN,SAAS,CAACC,SAAS,CAAC,CAACM,GAAG,EAAE;cAAA,KAEjDD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MAAM,GAAG,CAAC,EAAE;UAClCH,YAAY,CAACE,GAAG,CAAC,GAAG,MAAI,CAAC7B,SAAS,CAAC6B,GAAG,CAAC,CAACC,MAAM;QAChD;MACF,CAAC,CAAC;MAEF,OAAO;QACLJ,iBAAiB,EAAjBA,iBAAiB;QACjBC,YAAY,EAAZA;MACF,CAAC;IACH;EAAC;EAAA;AAAA;AAAA"}
1
+ {"version":3,"names":["ReceiveSlotManager","meeting","allocatedSlots","MediaType","AudioMain","VideoMain","AudioSlides","VideoSlides","freeSlots","mediaType","mediaProperties","webrtcMediaConnection","reject","Error","availableSlot","pop","push","LoggerProxy","logger","log","id","createReceiveSlot","wcmeReceiveSlot","receiveSlot","ReceiveSlot","csi","members","findMemberByCsi","slot","idx","findIndex","allocatedSlot","splice","warn","numAllocatedSlots","numFreeSlots","forEach","key","length"],"sources":["receiveSlotManager.ts"],"sourcesContent":["/* eslint-disable valid-jsdoc */\n/* eslint-disable import/prefer-default-export */\nimport {MediaType} from '@webex/internal-media-core';\n\nimport LoggerProxy from '../common/logs/logger-proxy';\nimport Meeting from '../meeting';\n\nimport {CSI, ReceiveSlot} from './receiveSlot';\n\n/**\n * Manages all receive slots used by a meeting. WMCE receive slots cannot be ever deleted,\n * so this manager has a pool in order to re-use the slots that were released earlier.\n */\nexport class ReceiveSlotManager {\n private allocatedSlots: {[key in MediaType]: ReceiveSlot[]};\n\n private freeSlots: {[key in MediaType]: ReceiveSlot[]};\n\n private meeting: Meeting;\n\n /**\n * Constructor\n * @param {Meeting} meeting\n */\n constructor(meeting) {\n this.allocatedSlots = {\n [MediaType.AudioMain]: [],\n [MediaType.VideoMain]: [],\n [MediaType.AudioSlides]: [],\n [MediaType.VideoSlides]: [],\n };\n this.freeSlots = {\n [MediaType.AudioMain]: [],\n [MediaType.VideoMain]: [],\n [MediaType.AudioSlides]: [],\n [MediaType.VideoSlides]: [],\n };\n this.meeting = meeting;\n }\n\n /**\n * Creates a new receive slot or returns one from the existing pool of free slots\n *\n * @param {MediaType} mediaType\n * @returns {Promise<ReceiveSlot>}\n */\n async allocateSlot(mediaType: MediaType): Promise<ReceiveSlot> {\n if (!this.meeting?.mediaProperties?.webrtcMediaConnection) {\n return Promise.reject(new Error('Webrtc media connection is missing'));\n }\n\n // try to use one of the free ones\n const availableSlot = this.freeSlots[mediaType].pop();\n\n if (availableSlot) {\n this.allocatedSlots[mediaType].push(availableSlot);\n\n LoggerProxy.logger.log(`receive slot re-used: ${availableSlot.id}`);\n\n return availableSlot;\n }\n\n // we have to create a new one\n const wcmeReceiveSlot =\n await this.meeting.mediaProperties.webrtcMediaConnection.createReceiveSlot(mediaType);\n\n const receiveSlot = new ReceiveSlot(\n mediaType,\n wcmeReceiveSlot,\n // @ts-ignore\n (csi: CSI) => this.meeting.members.findMemberByCsi(csi)?.id\n );\n\n this.allocatedSlots[mediaType].push(receiveSlot);\n LoggerProxy.logger.log(`new receive slot allocated: ${receiveSlot.id}`);\n\n return receiveSlot;\n }\n\n /**\n * Releases the slot back to the pool so it can be re-used by others in the future\n * @param {ReceiveSlot} slot\n */\n releaseSlot(slot: ReceiveSlot) {\n const idx = this.allocatedSlots[slot.mediaType].findIndex(\n (allocatedSlot) => allocatedSlot === slot\n );\n\n if (idx >= 0) {\n this.allocatedSlots[slot.mediaType].splice(idx, 1);\n this.freeSlots[slot.mediaType].push(slot);\n LoggerProxy.logger.log(`receive slot released: ${slot.id}`);\n } else {\n LoggerProxy.logger.warn(\n 'ReceiveSlotManager#releaseSlot --> trying to release a slot that is not managed by this ReceiveSlotManager'\n );\n }\n }\n\n /**\n * Resets the slot manager - this method should be called when the media connection is torn down\n */\n reset() {\n this.allocatedSlots = {\n [MediaType.AudioMain]: [],\n [MediaType.VideoMain]: [],\n [MediaType.AudioSlides]: [],\n [MediaType.VideoSlides]: [],\n };\n this.freeSlots = {\n [MediaType.AudioMain]: [],\n [MediaType.VideoMain]: [],\n [MediaType.AudioSlides]: [],\n [MediaType.VideoSlides]: [],\n };\n }\n\n /**\n * Returns statistics about the managed slots\n *\n * @returns {Object}\n */\n getStats() {\n const numAllocatedSlots = {};\n const numFreeSlots = {};\n\n Object.keys(this.allocatedSlots).forEach((key) => {\n if (this.allocatedSlots[key].length > 0) {\n numAllocatedSlots[key] = this.allocatedSlots[key].length;\n }\n });\n\n Object.keys(this.freeSlots).forEach((key) => {\n if (this.freeSlots[key].length > 0) {\n numFreeSlots[key] = this.freeSlots[key].length;\n }\n });\n\n return {\n numAllocatedSlots,\n numFreeSlots,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAEA;AAEA;AAGA;AAPA;AACA;AAQA;AACA;AACA;AACA;AAHA,IAIaA,kBAAkB;EAO7B;AACF;AACA;AACA;EACE,4BAAYC,OAAO,EAAE;IAAA;IAAA;IAAA;IAAA;IAAA;IACnB,IAAI,CAACC,cAAc,mFAChBC,4BAAS,CAACC,SAAS,EAAG,EAAE,uDACxBD,4BAAS,CAACE,SAAS,EAAG,EAAE,uDACxBF,4BAAS,CAACG,WAAW,EAAG,EAAE,uDAC1BH,4BAAS,CAACI,WAAW,EAAG,EAAE,wBAC5B;IACD,IAAI,CAACC,SAAS,yEACXL,4BAAS,CAACC,SAAS,EAAG,EAAE,kDACxBD,4BAAS,CAACE,SAAS,EAAG,EAAE,kDACxBF,4BAAS,CAACG,WAAW,EAAG,EAAE,kDAC1BH,4BAAS,CAACI,WAAW,EAAG,EAAE,mBAC5B;IACD,IAAI,CAACN,OAAO,GAAGA,OAAO;EACxB;;EAEA;AACF;AACA;AACA;AACA;AACA;EALE;IAAA;IAAA;MAAA,4FAMA,iBAAmBQ,SAAoB;QAAA;UAAA;UAAA;QAAA;QAAA;UAAA;YAAA;cAAA,qBAChC,IAAI,CAACR,OAAO,mEAAZ,cAAcS,eAAe,kDAA7B,sBAA+BC,qBAAqB;gBAAA;gBAAA;cAAA;cAAA,iCAChD,iBAAQC,MAAM,CAAC,IAAIC,KAAK,CAAC,oCAAoC,CAAC,CAAC;YAAA;cAGxE;cACMC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AAE;UAClCH,YAAY,CAACE,GAAG,CAAC,GAAG,MAAI,CAAC7B,SAAS,CAAC6B,GAAG,CAAC,CAACC,MAAM;QAChD;MACF,CAAC,CAAC;MAEF,OAAO;QACLJ,iBAAiB,EAAjBA,iBAAiB;QACjBC,YAAY,EAAZA;MACF,CAAC;IACH;EAAC;EAAA;AAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":["RemoteMediaEvents","SourceUpdate","ReceiveSlotEvents","Stopped","getMaxFs","paneSize","maxFs","LoggerProxy","logger","warn","remoteMediaCounter","RemoteMedia","receiveSlot","mediaRequestManager","options","setupEventListeners","id","commit","cancelMediaRequest","removeAllListeners","undefined","emit","file","function","csi","mediaRequestId","Error","addRequest","policyInfo","policy","receiveSlots","codecInfo","resolution","codec","cancelRequest","scope","on","data","mediaType","memberId","sourceState","stream","EventsScope"],"sources":["remoteMedia.ts"],"sourcesContent":["/* eslint-disable valid-jsdoc */\nimport LoggerProxy from '../common/logs/logger-proxy';\nimport EventsScope from '../common/events/events-scope';\n\nimport {MediaRequestId, MediaRequestManager} from './mediaRequestManager';\nimport {CSI, ReceiveSlot, ReceiveSlotEvents} from './receiveSlot';\n\nexport const RemoteMediaEvents = {\n SourceUpdate: ReceiveSlotEvents.SourceUpdate,\n Stopped: 'stopped',\n};\n\nexport type RemoteVideoResolution =\n | 'thumbnail' // the smallest possible resolution, 90p or less\n | 'very small' // 180p or less\n | 'small' // 360p or less\n | 'medium' // 720p or less\n | 'large' // 1080p or less\n | 'best'; // highest possible resolution\n\n/**\n * Converts pane size into h264 maxFs\n * @param {PaneSize} paneSize\n * @returns {number}\n */\nexport function getMaxFs(paneSize: RemoteVideoResolution): number {\n let maxFs;\n\n switch (paneSize) {\n case 'thumbnail':\n maxFs = 60;\n break;\n case 'very small':\n maxFs = 240;\n break;\n case 'small':\n maxFs = 920;\n break;\n case 'medium':\n maxFs = 3600;\n break;\n case 'large':\n maxFs = 8192;\n break;\n case 'best':\n maxFs = 8192; // for now 'best' is 1080p, so same as 'large'\n break;\n default:\n LoggerProxy.logger.warn(\n `RemoteMedia#getMaxFs --> unsupported paneSize: ${paneSize}, using \"medium\" instead`\n );\n maxFs = 3600;\n }\n\n return maxFs;\n}\n\ntype Options = {\n resolution?: RemoteVideoResolution; // applies only to groups of type MC.MediaType.VideoMain and MC.MediaType.VideoSlides\n};\n\nexport type RemoteMediaId = string;\n\nlet remoteMediaCounter = 0;\n\n/**\n * Class representing a remote audio/video stream.\n *\n * Internally it is associated with a specific receive slot\n * and a media request for it.\n */\nexport class RemoteMedia extends EventsScope {\n private receiveSlot?: ReceiveSlot;\n\n private readonly mediaRequestManager: MediaRequestManager;\n\n private readonly options: Options;\n\n private mediaRequestId?: MediaRequestId;\n\n public readonly id: RemoteMediaId;\n\n /**\n * Constructs RemoteMedia instance\n *\n * @param receiveSlot\n * @param mediaRequestManager\n * @param options\n */\n constructor(\n receiveSlot: ReceiveSlot,\n mediaRequestManager: MediaRequestManager,\n options?: Options\n ) {\n super();\n remoteMediaCounter += 1;\n this.receiveSlot = receiveSlot;\n this.mediaRequestManager = mediaRequestManager;\n this.options = options || {};\n this.setupEventListeners();\n this.id = `RM${remoteMediaCounter}-${this.receiveSlot.id}`;\n }\n\n /**\n * Invalidates the remote media by clearing the reference to a receive slot and\n * cancelling the media request.\n * After this call the remote media is unusable.\n *\n * @param {boolean} commit - whether to commit the cancellation of the media request\n * @internal\n */\n public stop(commit = true) {\n this.cancelMediaRequest(commit);\n this.receiveSlot?.removeAllListeners();\n this.receiveSlot = undefined;\n this.emit(\n {\n file: 'multistream/remoteMedia',\n function: 'stop',\n },\n RemoteMediaEvents.Stopped,\n {}\n );\n }\n\n /**\n * Sends a new media request. This method can only be used for receiver-selected policy,\n * because only in that policy we have a 1-1 relationship between RemoteMedia and MediaRequest\n * and the request id is then stored in this RemoteMedia instance.\n * For active-speaker policy, the same request is shared among many RemoteMedia instances,\n * so it's managed through RemoteMediaGroup\n *\n * @internal\n */\n public sendMediaRequest(csi: CSI, commit: boolean) {\n if (this.mediaRequestId) {\n this.cancelMediaRequest(false);\n }\n\n if (!this.receiveSlot) {\n throw new Error('sendMediaRequest() called on an invalidated RemoteMedia instance');\n }\n\n this.mediaRequestId = this.mediaRequestManager.addRequest(\n {\n policyInfo: {\n policy: 'receiver-selected',\n csi,\n },\n receiveSlots: [this.receiveSlot],\n codecInfo: this.options.resolution && {\n codec: 'h264',\n maxFs: getMaxFs(this.options.resolution),\n },\n },\n commit\n );\n }\n\n /**\n * @internal\n */\n public cancelMediaRequest(commit: boolean) {\n if (this.mediaRequestId) {\n this.mediaRequestManager.cancelRequest(this.mediaRequestId, commit);\n this.mediaRequestId = undefined;\n }\n }\n\n /**\n * registers event listeners on the receive slot and forwards all the events\n */\n private setupEventListeners() {\n if (this.receiveSlot) {\n const scope = {\n file: 'multistream/remoteMedia',\n function: 'setupEventListeners',\n };\n\n this.receiveSlot.on(ReceiveSlotEvents.SourceUpdate, (data) => {\n this.emit(scope, RemoteMediaEvents.SourceUpdate, data);\n });\n }\n }\n\n /**\n * Getter for mediaType\n */\n public get mediaType() {\n return this.receiveSlot?.mediaType;\n }\n\n /**\n * Getter for memberId\n */\n public get memberId() {\n return this.receiveSlot?.memberId;\n }\n\n /**\n * Getter for csi\n */\n public get csi() {\n return this.receiveSlot?.csi;\n }\n\n /**\n * Getter for source state\n */\n public get sourceState() {\n return this.receiveSlot?.sourceState;\n }\n\n /**\n * Getter for remote media stream\n */\n public get stream() {\n return this.receiveSlot?.stream;\n }\n\n /**\n * @internal\n * @returns {ReceiveSlot}\n */\n public getUnderlyingReceiveSlot() {\n return this.receiveSlot;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AACA;AACA;AAGA;AAAkE;AAAA;AAE3D,IAAMA,iBAAiB,GAAG;EAC/BC,YAAY,EAAEC,8BAAiB,CAACD,YAAY;EAC5CE,OAAO,EAAE;AACX,CAAC;AAAC;AAQU;;AAEZ;AACA;AACA;AACA;AACA;AACO,SAASC,QAAQ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I,CAACX,WAAW,CAACwB,EAAE,CAAClC,8BAAiB,CAACD,YAAY,EAAE,UAACoC,IAAI,EAAK;UAC5D,MAAI,CAAChB,IAAI,CAACc,KAAK,EAAEnC,iBAAiB,CAACC,YAAY,EAAEoC,IAAI,CAAC;QACxD,CAAC,CAAC;MACJ;IACF;;IAEA;AACF;AACA;EAFE;IAAA;IAAA,KAGA,eAAuB;MAAA;MACrB,6BAAO,IAAI,CAACzB,WAAW,uDAAhB,mBAAkB0B,SAAS;IACpC;;IAEA;AACF;AACA;EAFE;IAAA;IAAA,KAGA,eAAsB;MAAA;MACpB,6BAAO,IAAI,CAAC1B,WAAW,uDAAhB,mBAAkB2B,QAAQ;IACnC;;IAEA;AACF;AACA;EAFE;IAAA;IAAA,KAGA,eAAiB;MAAA;MACf,6BAAO,IAAI,CAAC3B,WAAW,uDAAhB,mBAAkBY,GAAG;IAC9B;;IAEA;AACF;AACA;EAFE;IAAA;IAAA,KAGA,eAAyB;MAAA;MACvB,6BAAO,IAAI,CAACZ,WAAW,uDAAhB,mBAAkB4B,WAAW;IACtC;;IAEA;AACF;AACA;EAFE;IAAA;IAAA,KAGA,eAAoB;MAAA;MAClB,6BAAO,IAAI,CAAC5B,WAAW,uDAAhB,mBAAkB6B,MAAM;IACjC;;IAEA;AACF;AACA;AACA;EAHE;IAAA;IAAA,OAIA,oCAAkC;MAChC,OAAO,IAAI,CAAC7B,WAAW;IACzB;EAAC;EAAA;AAAA,EA3J8B8B,oBAAW;AAAA"}
1
+ {"version":3,"names":["RemoteMediaEvents","SourceUpdate","ReceiveSlotEvents","Stopped","getMaxFs","paneSize","maxFs","LoggerProxy","logger","warn","remoteMediaCounter","RemoteMedia","receiveSlot","mediaRequestManager","options","setupEventListeners","id","commit","cancelMediaRequest","removeAllListeners","undefined","emit","file","function","csi","mediaRequestId","Error","addRequest","policyInfo","policy","receiveSlots","codecInfo","resolution","codec","cancelRequest","scope","on","data","mediaType","memberId","sourceState","stream","EventsScope"],"sources":["remoteMedia.ts"],"sourcesContent":["/* eslint-disable valid-jsdoc */\nimport LoggerProxy from '../common/logs/logger-proxy';\nimport EventsScope from '../common/events/events-scope';\n\nimport {MediaRequestId, MediaRequestManager} from './mediaRequestManager';\nimport {CSI, ReceiveSlot, ReceiveSlotEvents} from './receiveSlot';\n\nexport const RemoteMediaEvents = {\n SourceUpdate: ReceiveSlotEvents.SourceUpdate,\n Stopped: 'stopped',\n};\n\nexport type RemoteVideoResolution =\n | 'thumbnail' // the smallest possible resolution, 90p or less\n | 'very small' // 180p or less\n | 'small' // 360p or less\n | 'medium' // 720p or less\n | 'large' // 1080p or less\n | 'best'; // highest possible resolution\n\n/**\n * Converts pane size into h264 maxFs\n * @param {PaneSize} paneSize\n * @returns {number}\n */\nexport function getMaxFs(paneSize: RemoteVideoResolution): number {\n let maxFs;\n\n switch (paneSize) {\n case 'thumbnail':\n maxFs = 60;\n break;\n case 'very small':\n maxFs = 240;\n break;\n case 'small':\n maxFs = 920;\n break;\n case 'medium':\n maxFs = 3600;\n break;\n case 'large':\n maxFs = 8192;\n break;\n case 'best':\n maxFs = 8192; // for now 'best' is 1080p, so same as 'large'\n break;\n default:\n LoggerProxy.logger.warn(\n `RemoteMedia#getMaxFs --> unsupported paneSize: ${paneSize}, using \"medium\" instead`\n );\n maxFs = 3600;\n }\n\n return maxFs;\n}\n\ntype Options = {\n resolution?: RemoteVideoResolution; // applies only to groups of type MediaType.VideoMain and MediaType.VideoSlides\n};\n\nexport type RemoteMediaId = string;\n\nlet remoteMediaCounter = 0;\n\n/**\n * Class representing a remote audio/video stream.\n *\n * Internally it is associated with a specific receive slot\n * and a media request for it.\n */\nexport class RemoteMedia extends EventsScope {\n private receiveSlot?: ReceiveSlot;\n\n private readonly mediaRequestManager: MediaRequestManager;\n\n private readonly options: Options;\n\n private mediaRequestId?: MediaRequestId;\n\n public readonly id: RemoteMediaId;\n\n /**\n * Constructs RemoteMedia instance\n *\n * @param receiveSlot\n * @param mediaRequestManager\n * @param options\n */\n constructor(\n receiveSlot: ReceiveSlot,\n mediaRequestManager: MediaRequestManager,\n options?: Options\n ) {\n super();\n remoteMediaCounter += 1;\n this.receiveSlot = receiveSlot;\n this.mediaRequestManager = mediaRequestManager;\n this.options = options || {};\n this.setupEventListeners();\n this.id = `RM${remoteMediaCounter}-${this.receiveSlot.id}`;\n }\n\n /**\n * Invalidates the remote media by clearing the reference to a receive slot and\n * cancelling the media request.\n * After this call the remote media is unusable.\n *\n * @param {boolean} commit - whether to commit the cancellation of the media request\n * @internal\n */\n public stop(commit = true) {\n this.cancelMediaRequest(commit);\n this.receiveSlot?.removeAllListeners();\n this.receiveSlot = undefined;\n this.emit(\n {\n file: 'multistream/remoteMedia',\n function: 'stop',\n },\n RemoteMediaEvents.Stopped,\n {}\n );\n }\n\n /**\n * Sends a new media request. This method can only be used for receiver-selected policy,\n * because only in that policy we have a 1-1 relationship between RemoteMedia and MediaRequest\n * and the request id is then stored in this RemoteMedia instance.\n * For active-speaker policy, the same request is shared among many RemoteMedia instances,\n * so it's managed through RemoteMediaGroup\n *\n * @internal\n */\n public sendMediaRequest(csi: CSI, commit: boolean) {\n if (this.mediaRequestId) {\n this.cancelMediaRequest(false);\n }\n\n if (!this.receiveSlot) {\n throw new Error('sendMediaRequest() called on an invalidated RemoteMedia instance');\n }\n\n this.mediaRequestId = this.mediaRequestManager.addRequest(\n {\n policyInfo: {\n policy: 'receiver-selected',\n csi,\n },\n receiveSlots: [this.receiveSlot],\n codecInfo: this.options.resolution && {\n codec: 'h264',\n maxFs: getMaxFs(this.options.resolution),\n },\n },\n commit\n );\n }\n\n /**\n * @internal\n */\n public cancelMediaRequest(commit: boolean) {\n if (this.mediaRequestId) {\n this.mediaRequestManager.cancelRequest(this.mediaRequestId, commit);\n this.mediaRequestId = undefined;\n }\n }\n\n /**\n * registers event listeners on the receive slot and forwards all the events\n */\n private setupEventListeners() {\n if (this.receiveSlot) {\n const scope = {\n file: 'multistream/remoteMedia',\n function: 'setupEventListeners',\n };\n\n this.receiveSlot.on(ReceiveSlotEvents.SourceUpdate, (data) => {\n this.emit(scope, RemoteMediaEvents.SourceUpdate, data);\n });\n }\n }\n\n /**\n * Getter for mediaType\n */\n public get mediaType() {\n return this.receiveSlot?.mediaType;\n }\n\n /**\n * Getter for memberId\n */\n public get memberId() {\n return this.receiveSlot?.memberId;\n }\n\n /**\n * Getter for csi\n */\n public get csi() {\n return this.receiveSlot?.csi;\n }\n\n /**\n * Getter for source state\n */\n public get sourceState() {\n return this.receiveSlot?.sourceState;\n }\n\n /**\n * Getter for remote media stream\n */\n public get stream() {\n return this.receiveSlot?.stream;\n }\n\n /**\n * @internal\n * @returns {ReceiveSlot}\n */\n public getUnderlyingReceiveSlot() {\n return this.receiveSlot;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AACA;AACA;AAGA;AAAkE;AAAA;AAE3D,IAAMA,iBAAiB,GAAG;EAC/BC,YAAY,EAAEC,8BAAiB,CAACD,YAAY;EAC5CE,OAAO,EAAE;AACX,CAAC;AAAC;AAQU;;AAEZ;AACA;AACA;AACA;AACA;AACO,SAASC,QAAQ,CAACC,QAA+B,EAAU;EAChE,IAAIC,KAAK;EAET,QAAQD,QAAQ;IACd,KAAK,WAAW;MACdC,KAAK,GAAG,EAAE;MACV;IACF,KAAK,YAAY;MACfA,KAAK,GAAG,GAAG;MACX;IACF,KAAK,OAAO;MACVA,KAAK,GAAG,GAAG;MACX;IACF,KAAK,QAAQ;MACXA,KAAK,GAAG,IAAI;MACZ;IACF,KAAK,OAAO;MACVA,KAAK,GAAG,IAAI;MACZ;IACF,KAAK,MAAM;MACTA,KAAK,GAAG,IAAI,CAAC,CAAC;MACd;IACF;MACEC,oBAAW,CAACC,MAAM,CAACC,IAAI,0DAC6BJ,QAAQ,gCAC3D;MACDC,KAAK,GAAG,IAAI;EAAC;EAGjB,OAAOA,KAAK;AACd;AAQA,IAAII,kBAAkB,GAAG,CAAC;;AAE1B;AACA;AACA;AACA;AACA;AACA;AALA,IAMaC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9B;;IAEA;AACF;AACA;EAFE;IAAA;IAAA,KAGA,eAAyB;MAAA;MACvB,6BAAO,IAAI,CAACZ,WAAW,uDAAhB,mBAAkB4B,WAAW;IACtC;;IAEA;AACF;AACA;EAFE;IAAA;IAAA,KAGA,eAAoB;MAAA;MAClB,6BAAO,IAAI,CAAC5B,WAAW,uDAAhB,mBAAkB6B,MAAM;IACjC;;IAEA;AACF;AACA;AACA;EAHE;IAAA;IAAA,OAIA,oCAAkC;MAChC,OAAO,IAAI,CAAC7B,WAAW;IACzB;EAAC;EAAA;AAAA,EA3J8B8B,oBAAW;AAAA"}
@@ -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","mediaRequestId","addRequest","policyInfo","policy","crossPriorityDuplication","crossPolicyDuplication","preferLiveVideo","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 MC.MediaType.VideoMain and MC.MediaType.VideoSlides\n preferLiveVideo?: boolean; // applies only to groups of type MC.MediaType.VideoMain and MC.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 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,Q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APE;IAAA;IAAA,OAQA,gBAA2B;MAAA,IAAff,MAAM,uEAAG,IAAI;MACvB,IAAI,CAACtB,mBAAmB,CAACsC,OAAO,CAAC,UAAC9B,WAAW;QAAA,OAAKA,WAAW,CAAC+B,IAAI,CAAC,KAAK,CAAC;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","remoteMedia","csi","targetCsi","Error","id","indexOf","LoggerProxy","logger","log","idx","splice","push","cancelActiveSpeakerMediaRequest","sendMediaRequest","commit","cancelMediaRequest","mediaRequestId","addRequest","policyInfo","policy","crossPriorityDuplication","crossPolicyDuplication","preferLiveVideo","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 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,0BAAqE;MAAA,IAA/CS,MAAqC,uEAAG,KAAK;MACjE,IAAIA,MAAM,KAAK,UAAU,EAAE;QACzB;QACA,wCAAW,IAAI,CAACP,mBAAmB;MACrC;MACA,IAAIO,MAAM,KAAK,QAAQ,EAAE;QACvB;QACA,wCAAW,IAAI,CAACF,iBAAiB;MACnC;MAEA,kDAAW,IAAI,CAACL,mBAAmB,oCAAK,IAAI,CAACK,iBAAiB;IAChE;;IAEA;AACF;AACA;AACA;AAC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