@webex/plugin-meetings 3.0.0-beta.1 → 3.0.0-beta.104

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 (548) hide show
  1. package/UPGRADING.md +9 -9
  2. package/browsers.js +19 -24
  3. package/dist/annotation/annotation.types.js +7 -0
  4. package/dist/annotation/annotation.types.js.map +1 -0
  5. package/dist/annotation/constants.js +48 -0
  6. package/dist/annotation/constants.js.map +1 -0
  7. package/dist/annotation/index.js +357 -0
  8. package/dist/annotation/index.js.map +1 -0
  9. package/dist/breakouts/breakout.js +176 -0
  10. package/dist/breakouts/breakout.js.map +1 -0
  11. package/dist/breakouts/collection.js +23 -0
  12. package/dist/breakouts/collection.js.map +1 -0
  13. package/dist/breakouts/edit-lock-error.js +52 -0
  14. package/dist/breakouts/edit-lock-error.js.map +1 -0
  15. package/dist/breakouts/events.js +43 -0
  16. package/dist/breakouts/events.js.map +1 -0
  17. package/dist/breakouts/index.js +919 -0
  18. package/dist/breakouts/index.js.map +1 -0
  19. package/dist/breakouts/request.js +78 -0
  20. package/dist/breakouts/request.js.map +1 -0
  21. package/dist/breakouts/utils.js +67 -0
  22. package/dist/breakouts/utils.js.map +1 -0
  23. package/dist/common/browser-detection.js +1 -20
  24. package/dist/common/browser-detection.js.map +1 -1
  25. package/dist/common/collection.js +5 -20
  26. package/dist/common/collection.js.map +1 -1
  27. package/dist/common/config.js +0 -7
  28. package/dist/common/config.js.map +1 -1
  29. package/dist/common/errors/captcha-error.js +10 -24
  30. package/dist/common/errors/captcha-error.js.map +1 -1
  31. package/dist/common/errors/intent-to-join.js +11 -24
  32. package/dist/common/errors/intent-to-join.js.map +1 -1
  33. package/dist/common/errors/join-meeting.js +12 -25
  34. package/dist/common/errors/join-meeting.js.map +1 -1
  35. package/dist/common/errors/media.js +10 -24
  36. package/dist/common/errors/media.js.map +1 -1
  37. package/dist/common/errors/parameter.js +5 -33
  38. package/dist/common/errors/parameter.js.map +1 -1
  39. package/dist/common/errors/password-error.js +10 -24
  40. package/dist/common/errors/password-error.js.map +1 -1
  41. package/dist/common/errors/permission.js +9 -23
  42. package/dist/common/errors/permission.js.map +1 -1
  43. package/dist/common/errors/reconnection-in-progress.js +0 -17
  44. package/dist/common/errors/reconnection-in-progress.js.map +1 -1
  45. package/dist/common/errors/reconnection.js +10 -24
  46. package/dist/common/errors/reconnection.js.map +1 -1
  47. package/dist/common/errors/stats.js +10 -24
  48. package/dist/common/errors/stats.js.map +1 -1
  49. package/dist/common/errors/webex-errors.js +10 -69
  50. package/dist/common/errors/webex-errors.js.map +1 -1
  51. package/dist/common/errors/webex-meetings-error.js +5 -25
  52. package/dist/common/errors/webex-meetings-error.js.map +1 -1
  53. package/dist/common/events/events-scope.js +0 -22
  54. package/dist/common/events/events-scope.js.map +1 -1
  55. package/dist/common/events/events.js +0 -23
  56. package/dist/common/events/events.js.map +1 -1
  57. package/dist/common/events/trigger-proxy.js +0 -12
  58. package/dist/common/events/trigger-proxy.js.map +1 -1
  59. package/dist/common/events/util.js +0 -15
  60. package/dist/common/events/util.js.map +1 -1
  61. package/dist/common/logs/logger-config.js +0 -4
  62. package/dist/common/logs/logger-config.js.map +1 -1
  63. package/dist/common/logs/logger-proxy.js +1 -8
  64. package/dist/common/logs/logger-proxy.js.map +1 -1
  65. package/dist/common/logs/request.js +37 -60
  66. package/dist/common/logs/request.js.map +1 -1
  67. package/dist/common/queue.js +4 -14
  68. package/dist/common/queue.js.map +1 -1
  69. package/dist/config.js +7 -6
  70. package/dist/config.js.map +1 -1
  71. package/dist/constants.js +184 -122
  72. package/dist/constants.js.map +1 -1
  73. package/dist/controls-options-manager/constants.js +14 -0
  74. package/dist/controls-options-manager/constants.js.map +1 -0
  75. package/dist/controls-options-manager/enums.js +25 -0
  76. package/dist/controls-options-manager/enums.js.map +1 -0
  77. package/dist/controls-options-manager/index.js +297 -0
  78. package/dist/controls-options-manager/index.js.map +1 -0
  79. package/dist/controls-options-manager/types.js +7 -0
  80. package/dist/controls-options-manager/types.js.map +1 -0
  81. package/dist/controls-options-manager/util.js +250 -0
  82. package/dist/controls-options-manager/util.js.map +1 -0
  83. package/dist/index.js +72 -17
  84. package/dist/index.js.map +1 -1
  85. package/dist/locus-info/controlsUtils.js +56 -29
  86. package/dist/locus-info/controlsUtils.js.map +1 -1
  87. package/dist/locus-info/embeddedAppsUtils.js +3 -26
  88. package/dist/locus-info/embeddedAppsUtils.js.map +1 -1
  89. package/dist/locus-info/fullState.js +0 -15
  90. package/dist/locus-info/fullState.js.map +1 -1
  91. package/dist/locus-info/hostUtils.js +4 -12
  92. package/dist/locus-info/hostUtils.js.map +1 -1
  93. package/dist/locus-info/index.js +362 -208
  94. package/dist/locus-info/index.js.map +1 -1
  95. package/dist/locus-info/infoUtils.js +3 -37
  96. package/dist/locus-info/infoUtils.js.map +1 -1
  97. package/dist/locus-info/mediaSharesUtils.js +12 -38
  98. package/dist/locus-info/mediaSharesUtils.js.map +1 -1
  99. package/dist/locus-info/parser.js +92 -118
  100. package/dist/locus-info/parser.js.map +1 -1
  101. package/dist/locus-info/selfUtils.js +99 -91
  102. package/dist/locus-info/selfUtils.js.map +1 -1
  103. package/dist/media/index.js +113 -337
  104. package/dist/media/index.js.map +1 -1
  105. package/dist/media/properties.js +96 -135
  106. package/dist/media/properties.js.map +1 -1
  107. package/dist/media/util.js +1 -35
  108. package/dist/media/util.js.map +1 -1
  109. package/dist/mediaQualityMetrics/config.js +505 -495
  110. package/dist/mediaQualityMetrics/config.js.map +1 -1
  111. package/dist/meeting/in-meeting-actions.js +59 -14
  112. package/dist/meeting/in-meeting-actions.js.map +1 -1
  113. package/dist/meeting/index.js +2909 -2398
  114. package/dist/meeting/index.js.map +1 -1
  115. package/dist/meeting/muteState.js +257 -112
  116. package/dist/meeting/muteState.js.map +1 -1
  117. package/dist/meeting/request.js +330 -264
  118. package/dist/meeting/request.js.map +1 -1
  119. package/dist/meeting/request.type.js +7 -0
  120. package/dist/meeting/request.type.js.map +1 -0
  121. package/dist/meeting/state.js +21 -31
  122. package/dist/meeting/state.js.map +1 -1
  123. package/dist/meeting/util.js +63 -261
  124. package/dist/meeting/util.js.map +1 -1
  125. package/dist/meeting-info/collection.js +6 -25
  126. package/dist/meeting-info/collection.js.map +1 -1
  127. package/dist/meeting-info/index.js +14 -32
  128. package/dist/meeting-info/index.js.map +1 -1
  129. package/dist/meeting-info/meeting-info-v2.js +273 -280
  130. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  131. package/dist/meeting-info/request.js +3 -15
  132. package/dist/meeting-info/request.js.map +1 -1
  133. package/dist/meeting-info/util.js +98 -183
  134. package/dist/meeting-info/util.js.map +1 -1
  135. package/dist/meeting-info/utilv2.js +155 -232
  136. package/dist/meeting-info/utilv2.js.map +1 -1
  137. package/dist/meetings/collection.js +26 -19
  138. package/dist/meetings/collection.js.map +1 -1
  139. package/dist/meetings/index.js +741 -548
  140. package/dist/meetings/index.js.map +1 -1
  141. package/dist/meetings/request.js +26 -41
  142. package/dist/meetings/request.js.map +1 -1
  143. package/dist/meetings/util.js +194 -149
  144. package/dist/meetings/util.js.map +1 -1
  145. package/dist/member/index.js +100 -85
  146. package/dist/member/index.js.map +1 -1
  147. package/dist/member/types.js +15 -0
  148. package/dist/member/types.js.map +1 -0
  149. package/dist/member/util.js +90 -68
  150. package/dist/member/util.js.map +1 -1
  151. package/dist/members/collection.js +13 -12
  152. package/dist/members/collection.js.map +1 -1
  153. package/dist/members/index.js +227 -188
  154. package/dist/members/index.js.map +1 -1
  155. package/dist/members/request.js +54 -39
  156. package/dist/members/request.js.map +1 -1
  157. package/dist/members/types.js +15 -0
  158. package/dist/members/types.js.map +1 -0
  159. package/dist/members/util.js +107 -44
  160. package/dist/members/util.js.map +1 -1
  161. package/dist/metrics/config.js +5 -14
  162. package/dist/metrics/config.js.map +1 -1
  163. package/dist/metrics/constants.js +3 -7
  164. package/dist/metrics/constants.js.map +1 -1
  165. package/dist/metrics/index.js +67 -159
  166. package/dist/metrics/index.js.map +1 -1
  167. package/dist/multistream/mediaRequestManager.js +250 -0
  168. package/dist/multistream/mediaRequestManager.js.map +1 -0
  169. package/dist/multistream/receiveSlot.js +202 -0
  170. package/dist/multistream/receiveSlot.js.map +1 -0
  171. package/dist/multistream/receiveSlotManager.js +176 -0
  172. package/dist/multistream/receiveSlotManager.js.map +1 -0
  173. package/dist/multistream/remoteMedia.js +270 -0
  174. package/dist/multistream/remoteMedia.js.map +1 -0
  175. package/dist/multistream/remoteMediaGroup.js +209 -0
  176. package/dist/multistream/remoteMediaGroup.js.map +1 -0
  177. package/dist/multistream/remoteMediaManager.js +1137 -0
  178. package/dist/multistream/remoteMediaManager.js.map +1 -0
  179. package/dist/networkQualityMonitor/index.js +40 -59
  180. package/dist/networkQualityMonitor/index.js.map +1 -1
  181. package/dist/personal-meeting-room/index.js +21 -45
  182. package/dist/personal-meeting-room/index.js.map +1 -1
  183. package/dist/personal-meeting-room/request.js +1 -31
  184. package/dist/personal-meeting-room/request.js.map +1 -1
  185. package/dist/personal-meeting-room/util.js +0 -13
  186. package/dist/personal-meeting-room/util.js.map +1 -1
  187. package/dist/reachability/index.js +192 -191
  188. package/dist/reachability/index.js.map +1 -1
  189. package/dist/reachability/request.js +15 -23
  190. package/dist/reachability/request.js.map +1 -1
  191. package/dist/reactions/constants.js +13 -0
  192. package/dist/reactions/constants.js.map +1 -0
  193. package/dist/reactions/reactions.js +109 -0
  194. package/dist/reactions/reactions.js.map +1 -0
  195. package/dist/reactions/reactions.type.js +36 -0
  196. package/dist/reactions/reactions.type.js.map +1 -0
  197. package/dist/reconnection-manager/index.js +386 -527
  198. package/dist/reconnection-manager/index.js.map +1 -1
  199. package/dist/recording-controller/enums.js +17 -0
  200. package/dist/recording-controller/enums.js.map +1 -0
  201. package/dist/recording-controller/index.js +343 -0
  202. package/dist/recording-controller/index.js.map +1 -0
  203. package/dist/recording-controller/util.js +63 -0
  204. package/dist/recording-controller/util.js.map +1 -0
  205. package/dist/roap/index.js +84 -286
  206. package/dist/roap/index.js.map +1 -1
  207. package/dist/roap/request.js +138 -238
  208. package/dist/roap/request.js.map +1 -1
  209. package/dist/roap/turnDiscovery.js +164 -102
  210. package/dist/roap/turnDiscovery.js.map +1 -1
  211. package/dist/statsAnalyzer/global.js +1 -93
  212. package/dist/statsAnalyzer/global.js.map +1 -1
  213. package/dist/statsAnalyzer/index.js +399 -470
  214. package/dist/statsAnalyzer/index.js.map +1 -1
  215. package/dist/statsAnalyzer/mqaUtil.js +143 -87
  216. package/dist/statsAnalyzer/mqaUtil.js.map +1 -1
  217. package/dist/transcription/index.js +22 -47
  218. package/dist/transcription/index.js.map +1 -1
  219. package/dist/types/annotation/annotation.types.d.ts +34 -0
  220. package/dist/types/annotation/constants.d.ts +31 -0
  221. package/dist/types/annotation/index.d.ts +124 -0
  222. package/dist/types/breakouts/breakout.d.ts +8 -0
  223. package/dist/types/breakouts/collection.d.ts +5 -0
  224. package/dist/types/breakouts/edit-lock-error.d.ts +15 -0
  225. package/dist/types/breakouts/events.d.ts +2 -0
  226. package/dist/types/breakouts/index.d.ts +5 -0
  227. package/dist/types/breakouts/request.d.ts +22 -0
  228. package/dist/types/breakouts/utils.d.ts +15 -0
  229. package/dist/types/common/browser-detection.d.ts +9 -0
  230. package/dist/types/common/collection.d.ts +48 -0
  231. package/dist/types/common/config.d.ts +2 -0
  232. package/dist/types/common/errors/captcha-error.d.ts +15 -0
  233. package/dist/types/common/errors/intent-to-join.d.ts +16 -0
  234. package/dist/types/common/errors/join-meeting.d.ts +17 -0
  235. package/dist/types/common/errors/media.d.ts +15 -0
  236. package/dist/types/common/errors/parameter.d.ts +15 -0
  237. package/dist/types/common/errors/password-error.d.ts +15 -0
  238. package/dist/types/common/errors/permission.d.ts +14 -0
  239. package/dist/types/common/errors/reconnection-in-progress.d.ts +9 -0
  240. package/dist/types/common/errors/reconnection.d.ts +15 -0
  241. package/dist/types/common/errors/stats.d.ts +15 -0
  242. package/dist/types/common/errors/webex-errors.d.ts +69 -0
  243. package/dist/types/common/errors/webex-meetings-error.d.ts +20 -0
  244. package/dist/types/common/events/events-scope.d.ts +17 -0
  245. package/dist/types/common/events/events.d.ts +12 -0
  246. package/dist/types/common/events/trigger-proxy.d.ts +2 -0
  247. package/dist/types/common/events/util.d.ts +2 -0
  248. package/dist/types/common/logs/logger-config.d.ts +2 -0
  249. package/dist/types/common/logs/logger-proxy.d.ts +2 -0
  250. package/dist/types/common/logs/request.d.ts +34 -0
  251. package/dist/types/common/queue.d.ts +32 -0
  252. package/dist/types/config.d.ts +78 -0
  253. package/dist/types/constants.d.ts +968 -0
  254. package/dist/types/controls-options-manager/constants.d.ts +4 -0
  255. package/dist/types/controls-options-manager/enums.d.ts +13 -0
  256. package/dist/types/controls-options-manager/index.d.ts +136 -0
  257. package/dist/types/controls-options-manager/types.d.ts +37 -0
  258. package/dist/types/controls-options-manager/util.d.ts +1 -0
  259. package/dist/types/index.d.ts +7 -0
  260. package/dist/types/locus-info/controlsUtils.d.ts +2 -0
  261. package/dist/types/locus-info/embeddedAppsUtils.d.ts +2 -0
  262. package/dist/types/locus-info/fullState.d.ts +2 -0
  263. package/dist/types/locus-info/hostUtils.d.ts +2 -0
  264. package/dist/types/locus-info/index.d.ts +315 -0
  265. package/dist/types/locus-info/infoUtils.d.ts +2 -0
  266. package/dist/types/locus-info/mediaSharesUtils.d.ts +2 -0
  267. package/dist/types/locus-info/parser.d.ts +212 -0
  268. package/dist/types/locus-info/selfUtils.d.ts +2 -0
  269. package/dist/types/media/index.d.ts +34 -0
  270. package/dist/types/media/properties.d.ts +108 -0
  271. package/dist/types/media/util.d.ts +2 -0
  272. package/dist/types/mediaQualityMetrics/config.d.ts +365 -0
  273. package/dist/types/meeting/in-meeting-actions.d.ts +129 -0
  274. package/dist/types/meeting/index.d.ts +1748 -0
  275. package/dist/types/meeting/muteState.d.ts +185 -0
  276. package/dist/types/meeting/request.d.ts +275 -0
  277. package/dist/types/meeting/request.type.d.ts +11 -0
  278. package/dist/types/meeting/state.d.ts +9 -0
  279. package/dist/types/meeting/util.d.ts +2 -0
  280. package/dist/types/meeting-info/collection.d.ts +20 -0
  281. package/dist/types/meeting-info/index.d.ts +57 -0
  282. package/dist/types/meeting-info/meeting-info-v2.d.ts +112 -0
  283. package/dist/types/meeting-info/request.d.ts +22 -0
  284. package/dist/types/meeting-info/util.d.ts +2 -0
  285. package/dist/types/meeting-info/utilv2.d.ts +2 -0
  286. package/dist/types/meetings/collection.d.ts +31 -0
  287. package/dist/types/meetings/index.d.ts +345 -0
  288. package/dist/types/meetings/request.d.ts +27 -0
  289. package/dist/types/meetings/util.d.ts +18 -0
  290. package/dist/types/member/index.d.ts +156 -0
  291. package/dist/types/member/types.d.ts +21 -0
  292. package/dist/types/member/util.d.ts +2 -0
  293. package/dist/types/members/collection.d.ts +29 -0
  294. package/dist/types/members/index.d.ts +353 -0
  295. package/dist/types/members/request.d.ts +69 -0
  296. package/dist/types/members/types.d.ts +24 -0
  297. package/dist/types/members/util.d.ts +2 -0
  298. package/dist/types/metrics/config.d.ts +172 -0
  299. package/dist/types/metrics/constants.d.ts +54 -0
  300. package/dist/types/metrics/index.d.ts +152 -0
  301. package/dist/types/multistream/mediaRequestManager.d.ts +101 -0
  302. package/dist/types/multistream/receiveSlot.d.ts +68 -0
  303. package/dist/types/multistream/receiveSlotManager.d.ts +56 -0
  304. package/dist/types/multistream/remoteMedia.d.ts +72 -0
  305. package/dist/types/multistream/remoteMediaGroup.d.ts +47 -0
  306. package/dist/types/multistream/remoteMediaManager.d.ts +263 -0
  307. package/dist/types/networkQualityMonitor/index.d.ts +70 -0
  308. package/dist/types/personal-meeting-room/index.d.ts +47 -0
  309. package/dist/types/personal-meeting-room/request.d.ts +14 -0
  310. package/dist/types/personal-meeting-room/util.d.ts +2 -0
  311. package/dist/types/reachability/index.d.ts +152 -0
  312. package/dist/types/reachability/request.d.ts +37 -0
  313. package/dist/types/reactions/constants.d.ts +3 -0
  314. package/dist/types/reactions/reactions.d.ts +4 -0
  315. package/dist/types/reactions/reactions.type.d.ts +52 -0
  316. package/dist/types/reconnection-manager/index.d.ts +126 -0
  317. package/dist/types/recording-controller/enums.d.ts +7 -0
  318. package/dist/types/recording-controller/index.d.ts +193 -0
  319. package/dist/types/recording-controller/util.d.ts +13 -0
  320. package/dist/types/roap/index.d.ts +77 -0
  321. package/dist/types/roap/request.d.ts +38 -0
  322. package/dist/types/roap/turnDiscovery.d.ts +88 -0
  323. package/dist/types/statsAnalyzer/global.d.ts +36 -0
  324. package/dist/types/statsAnalyzer/index.d.ts +200 -0
  325. package/dist/types/statsAnalyzer/mqaUtil.d.ts +24 -0
  326. package/dist/types/transcription/index.d.ts +64 -0
  327. package/internal-README.md +7 -6
  328. package/package.json +29 -21
  329. package/src/annotation/annotation.types.ts +41 -0
  330. package/src/annotation/constants.ts +36 -0
  331. package/src/annotation/index.ts +339 -0
  332. package/src/breakouts/README.md +219 -0
  333. package/src/breakouts/breakout.ts +141 -0
  334. package/src/breakouts/collection.ts +19 -0
  335. package/src/breakouts/edit-lock-error.ts +25 -0
  336. package/src/breakouts/events.ts +37 -0
  337. package/src/breakouts/index.ts +823 -0
  338. package/src/breakouts/request.ts +55 -0
  339. package/src/breakouts/utils.ts +57 -0
  340. package/src/common/{browser-detection.js → browser-detection.ts} +9 -6
  341. package/src/common/collection.ts +9 -7
  342. package/src/common/{config.js → config.ts} +1 -1
  343. package/src/common/errors/{captcha-error.js → captcha-error.ts} +11 -7
  344. package/src/common/errors/{intent-to-join.js → intent-to-join.ts} +12 -7
  345. package/src/common/errors/{join-meeting.js → join-meeting.ts} +17 -8
  346. package/src/common/errors/{media.js → media.ts} +11 -7
  347. package/src/common/errors/parameter.ts +11 -7
  348. package/src/common/errors/{password-error.js → password-error.ts} +11 -7
  349. package/src/common/errors/{permission.js → permission.ts} +10 -6
  350. package/src/common/errors/{reconnection.js → reconnection.ts} +11 -7
  351. package/src/common/errors/{stats.js → stats.ts} +11 -7
  352. package/src/common/errors/{webex-errors.js → webex-errors.ts} +8 -25
  353. package/src/common/errors/{webex-meetings-error.js → webex-meetings-error.ts} +4 -2
  354. package/src/common/events/{events-scope.js → events-scope.ts} +6 -2
  355. package/src/common/events/{events.js → events.ts} +5 -1
  356. package/src/common/events/{trigger-proxy.js → trigger-proxy.ts} +9 -5
  357. package/src/common/events/{util.js → util.ts} +2 -3
  358. package/src/common/logs/{logger-config.js → logger-config.ts} +1 -2
  359. package/src/common/logs/logger-proxy.ts +44 -0
  360. package/src/common/logs/{request.js → request.ts} +22 -9
  361. package/src/common/queue.ts +1 -2
  362. package/src/{config.js → config.ts} +18 -12
  363. package/src/constants.ts +256 -183
  364. package/src/controls-options-manager/constants.ts +5 -0
  365. package/src/controls-options-manager/enums.ts +16 -0
  366. package/src/controls-options-manager/index.ts +278 -0
  367. package/src/controls-options-manager/types.ts +49 -0
  368. package/src/controls-options-manager/util.ts +229 -0
  369. package/src/index.ts +33 -0
  370. package/src/locus-info/controlsUtils.ts +169 -0
  371. package/src/locus-info/{embeddedAppsUtils.js → embeddedAppsUtils.ts} +5 -6
  372. package/src/locus-info/{fullState.js → fullState.ts} +16 -12
  373. package/src/locus-info/{hostUtils.js → hostUtils.ts} +9 -8
  374. package/src/locus-info/{index.js → index.ts} +331 -80
  375. package/src/locus-info/{infoUtils.js → infoUtils.ts} +19 -8
  376. package/src/locus-info/{mediaSharesUtils.js → mediaSharesUtils.ts} +17 -17
  377. package/src/locus-info/{parser.js → parser.ts} +67 -79
  378. package/src/locus-info/{selfUtils.js → selfUtils.ts} +196 -67
  379. package/src/media/index.ts +488 -0
  380. package/src/media/{properties.js → properties.ts} +67 -54
  381. package/src/media/util.ts +16 -0
  382. package/src/mediaQualityMetrics/config.ts +384 -0
  383. package/src/meeting/in-meeting-actions.ts +123 -3
  384. package/src/meeting/{index.js → index.ts} +3334 -1775
  385. package/src/meeting/muteState.ts +526 -0
  386. package/src/meeting/{request.js → request.ts} +350 -142
  387. package/src/meeting/request.type.ts +13 -0
  388. package/src/meeting/{state.js → state.ts} +50 -35
  389. package/src/meeting/{util.js → util.ts} +126 -159
  390. package/src/meeting-info/{collection.js → collection.ts} +6 -2
  391. package/src/meeting-info/{index.js → index.ts} +42 -36
  392. package/src/meeting-info/meeting-info-v2.ts +345 -0
  393. package/src/meeting-info/{request.js → request.ts} +14 -4
  394. package/src/meeting-info/{util.js → util.ts} +60 -51
  395. package/src/meeting-info/{utilv2.js → utilv2.ts} +76 -60
  396. package/src/meetings/{collection.js → collection.ts} +26 -3
  397. package/src/meetings/index.ts +1394 -0
  398. package/src/meetings/{request.js → request.ts} +34 -25
  399. package/src/meetings/util.ts +288 -0
  400. package/src/member/{index.js → index.ts} +124 -56
  401. package/src/member/types.ts +24 -0
  402. package/src/member/{util.js → util.ts} +105 -25
  403. package/src/members/{collection.js → collection.ts} +10 -2
  404. package/src/members/{index.js → index.ts} +359 -139
  405. package/src/members/request.ts +215 -0
  406. package/src/members/types.ts +28 -0
  407. package/src/members/{util.js → util.ts} +145 -54
  408. package/src/metrics/{config.js → config.ts} +256 -92
  409. package/src/metrics/{constants.js → constants.ts} +1 -6
  410. package/src/metrics/{index.js → index.ts} +116 -97
  411. package/src/multistream/mediaRequestManager.ts +324 -0
  412. package/src/multistream/receiveSlot.ts +184 -0
  413. package/src/multistream/receiveSlotManager.ts +166 -0
  414. package/src/multistream/remoteMedia.ts +254 -0
  415. package/src/multistream/remoteMediaGroup.ts +225 -0
  416. package/src/multistream/remoteMediaManager.ts +1075 -0
  417. package/src/networkQualityMonitor/{index.js → index.ts} +41 -29
  418. package/src/personal-meeting-room/{index.js → index.ts} +28 -19
  419. package/src/personal-meeting-room/{request.js → request.ts} +13 -4
  420. package/src/personal-meeting-room/{util.js → util.ts} +4 -4
  421. package/src/reachability/{index.js → index.ts} +157 -94
  422. package/src/reachability/request.ts +46 -35
  423. package/src/reactions/constants.ts +4 -0
  424. package/src/reactions/reactions.ts +104 -0
  425. package/src/reactions/reactions.type.ts +62 -0
  426. package/src/reconnection-manager/{index.js → index.ts} +261 -163
  427. package/src/recording-controller/enums.ts +8 -0
  428. package/src/recording-controller/index.ts +315 -0
  429. package/src/recording-controller/util.ts +58 -0
  430. package/src/roap/index.ts +241 -0
  431. package/src/roap/request.ts +172 -0
  432. package/src/roap/turnDiscovery.ts +127 -53
  433. package/src/statsAnalyzer/global.ts +37 -0
  434. package/src/statsAnalyzer/index.ts +1273 -0
  435. package/src/statsAnalyzer/mqaUtil.ts +291 -0
  436. package/src/transcription/{index.js → index.ts} +46 -39
  437. package/test/integration/spec/converged-space-meetings.js +177 -0
  438. package/test/integration/spec/journey.js +666 -464
  439. package/test/integration/spec/space-meeting.js +321 -206
  440. package/test/integration/spec/transcription.js +7 -8
  441. package/test/unit/spec/annotation/index.ts +435 -0
  442. package/test/unit/spec/breakouts/breakout.ts +184 -0
  443. package/test/unit/spec/breakouts/collection.ts +15 -0
  444. package/test/unit/spec/breakouts/edit-lock-error.ts +30 -0
  445. package/test/unit/spec/breakouts/events.ts +77 -0
  446. package/test/unit/spec/breakouts/index.ts +1504 -0
  447. package/test/unit/spec/breakouts/request.ts +104 -0
  448. package/test/unit/spec/breakouts/utils.js +72 -0
  449. package/test/unit/spec/common/browser-detection.js +9 -28
  450. package/test/unit/spec/controls-options-manager/index.js +287 -0
  451. package/test/unit/spec/controls-options-manager/util.js +403 -0
  452. package/test/unit/spec/fixture/locus.js +92 -90
  453. package/test/unit/spec/locus-info/controlsUtils.js +177 -32
  454. package/test/unit/spec/locus-info/embeddedAppsUtils.js +8 -6
  455. package/test/unit/spec/locus-info/index.js +493 -3
  456. package/test/unit/spec/locus-info/infoUtils.js +41 -32
  457. package/test/unit/spec/locus-info/lib/BasicSeqCmp.json +88 -430
  458. package/test/unit/spec/locus-info/lib/SeqCmp.json +513 -685
  459. package/test/unit/spec/locus-info/parser.js +3 -9
  460. package/test/unit/spec/locus-info/selfConstant.js +110 -103
  461. package/test/unit/spec/locus-info/selfUtils.js +236 -12
  462. package/test/unit/spec/media/index.ts +303 -0
  463. package/test/unit/spec/media/properties.ts +73 -82
  464. package/test/unit/spec/meeting/in-meeting-actions.ts +58 -3
  465. package/test/unit/spec/meeting/index.js +3127 -975
  466. package/test/unit/spec/meeting/muteState.js +375 -70
  467. package/test/unit/spec/meeting/request.js +217 -43
  468. package/test/unit/spec/meeting/utils.js +205 -163
  469. package/test/unit/spec/meeting-info/meetinginfov2.js +268 -74
  470. package/test/unit/spec/meeting-info/request.js +7 -9
  471. package/test/unit/spec/meeting-info/util.js +11 -12
  472. package/test/unit/spec/meeting-info/utilv2.js +131 -74
  473. package/test/unit/spec/meetings/collection.js +15 -1
  474. package/test/unit/spec/meetings/index.js +1052 -333
  475. package/test/unit/spec/meetings/utils.js +163 -14
  476. package/test/unit/spec/member/index.js +24 -1
  477. package/test/unit/spec/member/util.js +359 -32
  478. package/test/unit/spec/members/index.js +547 -37
  479. package/test/unit/spec/members/request.js +76 -20
  480. package/test/unit/spec/members/utils.js +191 -4
  481. package/test/unit/spec/metrics/index.js +46 -20
  482. package/test/unit/spec/multistream/mediaRequestManager.ts +1060 -0
  483. package/test/unit/spec/multistream/receiveSlot.ts +163 -0
  484. package/test/unit/spec/multistream/receiveSlotManager.ts +203 -0
  485. package/test/unit/spec/multistream/remoteMedia.ts +255 -0
  486. package/test/unit/spec/multistream/remoteMediaGroup.ts +396 -0
  487. package/test/unit/spec/multistream/remoteMediaManager.ts +1793 -0
  488. package/test/unit/spec/networkQualityMonitor/index.js +24 -18
  489. package/test/unit/spec/personal-meeting-room/personal-meeting-room.js +2 -7
  490. package/test/unit/spec/reachability/index.ts +176 -27
  491. package/test/unit/spec/reachability/request.js +66 -0
  492. package/test/unit/spec/reconnection-manager/index.js +106 -9
  493. package/test/unit/spec/recording-controller/index.js +231 -0
  494. package/test/unit/spec/recording-controller/util.js +102 -0
  495. package/test/unit/spec/roap/index.ts +78 -45
  496. package/test/unit/spec/roap/request.ts +217 -0
  497. package/test/unit/spec/roap/turnDiscovery.ts +93 -49
  498. package/test/unit/spec/stats-analyzer/index.js +118 -65
  499. package/test/utils/cmr.js +44 -42
  500. package/test/utils/constants.js +9 -0
  501. package/test/utils/integrationTestUtils.js +64 -0
  502. package/test/utils/testUtils.js +63 -99
  503. package/test/utils/webex-config.js +22 -18
  504. package/test/utils/webex-test-users.js +57 -50
  505. package/tsconfig.json +6 -0
  506. package/dist/meeting/effectsState.js +0 -327
  507. package/dist/meeting/effectsState.js.map +0 -1
  508. package/dist/peer-connection-manager/index.js +0 -794
  509. package/dist/peer-connection-manager/index.js.map +0 -1
  510. package/dist/peer-connection-manager/util.js +0 -124
  511. package/dist/peer-connection-manager/util.js.map +0 -1
  512. package/dist/roap/collection.js +0 -73
  513. package/dist/roap/collection.js.map +0 -1
  514. package/dist/roap/handler.js +0 -337
  515. package/dist/roap/handler.js.map +0 -1
  516. package/dist/roap/state.js +0 -164
  517. package/dist/roap/state.js.map +0 -1
  518. package/dist/roap/util.js +0 -102
  519. package/dist/roap/util.js.map +0 -1
  520. package/src/common/logs/logger-proxy.js +0 -33
  521. package/src/index.js +0 -15
  522. package/src/locus-info/controlsUtils.js +0 -102
  523. package/src/media/index.js +0 -593
  524. package/src/media/util.js +0 -38
  525. package/src/mediaQualityMetrics/config.js +0 -382
  526. package/src/meeting/effectsState.js +0 -205
  527. package/src/meeting/muteState.js +0 -318
  528. package/src/meeting-info/meeting-info-v2.js +0 -255
  529. package/src/meetings/index.js +0 -986
  530. package/src/meetings/util.js +0 -176
  531. package/src/members/request.js +0 -131
  532. package/src/peer-connection-manager/index.js +0 -723
  533. package/src/peer-connection-manager/util.ts +0 -117
  534. package/src/roap/collection.js +0 -63
  535. package/src/roap/handler.js +0 -252
  536. package/src/roap/index.js +0 -380
  537. package/src/roap/request.js +0 -198
  538. package/src/roap/state.js +0 -149
  539. package/src/roap/util.js +0 -93
  540. package/src/statsAnalyzer/global.js +0 -131
  541. package/src/statsAnalyzer/index.js +0 -1020
  542. package/src/statsAnalyzer/mqaUtil.js +0 -173
  543. package/test/unit/spec/meeting/effectsState.js +0 -293
  544. package/test/unit/spec/peerconnection-manager/index.js +0 -188
  545. package/test/unit/spec/peerconnection-manager/utils.js +0 -48
  546. package/test/unit/spec/peerconnection-manager/utils.test-fixtures.ts +0 -389
  547. package/test/unit/spec/roap/util.js +0 -30
  548. /package/src/common/errors/{reconnection-in-progress.js → reconnection-in-progress.ts} +0 -0
@@ -0,0 +1,1075 @@
1
+ /* eslint-disable valid-jsdoc */
2
+ import {cloneDeep, forEach, remove} from 'lodash';
3
+ import {EventMap} from 'typed-emitter';
4
+ import {MediaType} from '@webex/internal-media-core';
5
+
6
+ import LoggerProxy from '../common/logs/logger-proxy';
7
+ import EventsScope from '../common/events/events-scope';
8
+
9
+ import {RemoteMedia, RemoteVideoResolution} from './remoteMedia';
10
+ import {ReceiveSlot, CSI} from './receiveSlot';
11
+ import {ReceiveSlotManager} from './receiveSlotManager';
12
+ import {RemoteMediaGroup} from './remoteMediaGroup';
13
+ import {MediaRequestManager} from './mediaRequestManager';
14
+
15
+ export type PaneSize = RemoteVideoResolution;
16
+ export type LayoutId = string;
17
+ export type PaneId = string;
18
+ export type PaneGroupId = string;
19
+
20
+ export interface ActiveSpeakerVideoPaneGroup {
21
+ id: PaneGroupId;
22
+ numPanes: number; // maximum number of panes in the group (actual number may be lower, if there are not enough participants in the meeting)
23
+ size: PaneSize; // preferred size for all panes in the group
24
+ priority: number; // 0-255 (255 = highest priority), each group must have a different priority from all other groups
25
+ }
26
+
27
+ export interface MemberVideoPane {
28
+ id: PaneId;
29
+ size: PaneSize;
30
+ csi?: CSI;
31
+ }
32
+
33
+ export interface VideoLayout {
34
+ screenShareVideo?: {
35
+ size: PaneSize;
36
+ };
37
+ activeSpeakerVideoPaneGroups?: ActiveSpeakerVideoPaneGroup[]; // list of active speaker video pane groups
38
+ memberVideoPanes?: MemberVideoPane[]; // list of video panes for specific members, CSI values can be changed later via setVideoPaneCsi()
39
+ }
40
+
41
+ export interface Configuration {
42
+ audio: {
43
+ numOfActiveSpeakerStreams: number; // number of audio streams we want to receive
44
+ numOfScreenShareStreams: number; // 1 should be enough, because in webex only 1 person at a time can be presenting screen share
45
+ };
46
+ video: {
47
+ preferLiveVideo: boolean; // applies to all pane groups with active speaker policy
48
+ initialLayoutId: LayoutId;
49
+
50
+ layouts: {[key: LayoutId]: VideoLayout}; // a map of all available layouts, a layout can be set via setLayout() method
51
+ };
52
+ }
53
+
54
+ /* Predefined layouts: */
55
+
56
+ // An "all equal" grid, with size up to 3 x 3 = 9:
57
+ const AllEqualLayout: VideoLayout = {
58
+ activeSpeakerVideoPaneGroups: [
59
+ {
60
+ id: 'main',
61
+ numPanes: 9,
62
+ size: 'best',
63
+ priority: 255,
64
+ },
65
+ ],
66
+ };
67
+
68
+ // A layout with just a single remote active speaker video pane:
69
+ const SingleLayout: VideoLayout = {
70
+ activeSpeakerVideoPaneGroups: [
71
+ {
72
+ id: 'main',
73
+ numPanes: 1,
74
+ size: 'best',
75
+ priority: 255,
76
+ },
77
+ ],
78
+ };
79
+
80
+ // A layout with 1 big pane for the highest priority active speaker and 5 small panes for other active speakers:
81
+ const OnePlusFiveLayout: VideoLayout = {
82
+ activeSpeakerVideoPaneGroups: [
83
+ {
84
+ id: 'mainBigOne',
85
+ numPanes: 1,
86
+ size: 'large',
87
+ priority: 255,
88
+ },
89
+ {
90
+ id: 'secondarySetOfSmallPanes',
91
+ numPanes: 5,
92
+ size: 'very small',
93
+ priority: 254,
94
+ },
95
+ ],
96
+ };
97
+
98
+ // A layout with 2 big panes for 2 main active speakers and a strip of 6 small panes for other active speakers:
99
+ const TwoMainPlusSixSmallLayout: VideoLayout = {
100
+ activeSpeakerVideoPaneGroups: [
101
+ {
102
+ id: 'mainGroupWith2BigPanes',
103
+ numPanes: 2,
104
+ size: 'large',
105
+ priority: 255,
106
+ },
107
+ {
108
+ id: 'secondaryGroupOfSmallPanes',
109
+ numPanes: 6,
110
+ size: 'small',
111
+ priority: 254,
112
+ },
113
+ ],
114
+ };
115
+
116
+ // A strip of 8 small video panes (thumbnails) displayed at the top of a remote screenshare:
117
+ const RemoteScreenShareWithSmallThumbnailsLayout: VideoLayout = {
118
+ screenShareVideo: {size: 'best'},
119
+ activeSpeakerVideoPaneGroups: [
120
+ {
121
+ id: 'thumbnails',
122
+ numPanes: 8,
123
+ size: 'thumbnail',
124
+ priority: 255,
125
+ },
126
+ ],
127
+ };
128
+
129
+ // A staged layout with 4 pre-selected meeting participants in the main 2x2 grid and 6 small panes for other active speakers at the top:
130
+ const Stage2x2With6ThumbnailsLayout: VideoLayout = {
131
+ activeSpeakerVideoPaneGroups: [
132
+ {
133
+ id: 'thumbnails',
134
+ numPanes: 6,
135
+ size: 'thumbnail',
136
+ priority: 255,
137
+ },
138
+ ],
139
+ memberVideoPanes: [
140
+ {id: 'stage-1', size: 'medium', csi: undefined},
141
+ {id: 'stage-2', size: 'medium', csi: undefined},
142
+ {id: 'stage-3', size: 'medium', csi: undefined},
143
+ {id: 'stage-4', size: 'medium', csi: undefined},
144
+ ],
145
+ };
146
+
147
+ /**
148
+ * Default configuration:
149
+ * - uses 3 audio streams
150
+ * - prefers active speakers with live video (e.g. are not audio only or video muted) over active speakers without live video
151
+ * - has a few layouts defined, including 1 that contains remote screen share (ScreenShareView)
152
+ */
153
+ export const DefaultConfiguration: Configuration = {
154
+ audio: {
155
+ numOfActiveSpeakerStreams: 3,
156
+ numOfScreenShareStreams: 1,
157
+ },
158
+ video: {
159
+ preferLiveVideo: true,
160
+ initialLayoutId: 'AllEqual',
161
+
162
+ layouts: {
163
+ AllEqual: AllEqualLayout,
164
+ OnePlusFive: OnePlusFiveLayout,
165
+ Single: SingleLayout,
166
+ Stage: Stage2x2With6ThumbnailsLayout,
167
+ ScreenShareView: RemoteScreenShareWithSmallThumbnailsLayout,
168
+ },
169
+ },
170
+ };
171
+
172
+ export enum Event {
173
+ // events for audio streams
174
+ AudioCreated = 'AudioCreated',
175
+ ScreenShareAudioCreated = 'ScreenShareAudioCreated',
176
+
177
+ // events for video streams
178
+ VideoLayoutChanged = 'VideoLayoutChanged',
179
+ }
180
+
181
+ export interface VideoLayoutChangedEventData {
182
+ layoutId: LayoutId;
183
+ activeSpeakerVideoPanes: {
184
+ [key: PaneGroupId]: RemoteMediaGroup;
185
+ };
186
+ memberVideoPanes: {[key: PaneId]: RemoteMedia};
187
+ screenShareVideo?: RemoteMedia;
188
+ }
189
+ export interface Events extends EventMap {
190
+ // audio
191
+ [Event.AudioCreated]: (audio: RemoteMediaGroup) => void;
192
+ [Event.ScreenShareAudioCreated]: (screenShareAudio: RemoteMediaGroup) => void;
193
+
194
+ // video
195
+ [Event.VideoLayoutChanged]: (data: VideoLayoutChangedEventData) => void;
196
+ }
197
+
198
+ /**
199
+ * A helper class that manages all remote audio/video streams in order to achieve a predefined set of layouts.
200
+ * It also creates a fixed number of audio streams and these don't change during the meeting.
201
+ *
202
+ * Things that RemoteMediaManager does:
203
+ * - owns the receive slots (creates them when needed, and re-uses them when switching layouts)
204
+ * - constructs appropriate RemoteMedia and RemoteMediaGroup objects and sends appropriate mediaRequests
205
+ */
206
+ export class RemoteMediaManager extends EventsScope {
207
+ private config: Configuration;
208
+
209
+ private started: boolean;
210
+
211
+ private receiveSlotManager: ReceiveSlotManager;
212
+
213
+ private mediaRequestManagers: {
214
+ audio: MediaRequestManager;
215
+ video: MediaRequestManager;
216
+ screenShareAudio: MediaRequestManager;
217
+ screenShareVideo: MediaRequestManager;
218
+ };
219
+
220
+ private currentLayout?: VideoLayout;
221
+
222
+ private slots: {
223
+ audio: ReceiveSlot[];
224
+ screenShare: {
225
+ audio: ReceiveSlot[];
226
+ video?: ReceiveSlot;
227
+ };
228
+ video: {
229
+ unused: ReceiveSlot[];
230
+ activeSpeaker: ReceiveSlot[];
231
+ receiverSelected: ReceiveSlot[];
232
+ };
233
+ };
234
+
235
+ private media: {
236
+ audio?: RemoteMediaGroup;
237
+ video: {
238
+ activeSpeakerGroups: {
239
+ [key: PaneGroupId]: RemoteMediaGroup;
240
+ };
241
+ memberPanes: {[key: PaneId]: RemoteMedia};
242
+ };
243
+ screenShare: {
244
+ audio?: RemoteMediaGroup;
245
+ video?: RemoteMediaGroup;
246
+ };
247
+ };
248
+
249
+ private receiveSlotAllocations: {
250
+ activeSpeaker: {[key: PaneGroupId]: {slots: ReceiveSlot[]}};
251
+ receiverSelected: {[key: PaneId]: ReceiveSlot};
252
+ };
253
+
254
+ private currentLayoutId?: LayoutId;
255
+
256
+ /**
257
+ * Constructor
258
+ *
259
+ * @param {ReceiveSlotManager} receiveSlotManager
260
+ * @param {{audio: MediaRequestManager, video: mediaRequestManagers}} mediaRequestManagers
261
+ * @param {Configuration} config Configuration describing what video layouts to use during the meeting
262
+ */
263
+ constructor(
264
+ receiveSlotManager: ReceiveSlotManager,
265
+ mediaRequestManagers: {
266
+ audio: MediaRequestManager;
267
+ video: MediaRequestManager;
268
+ screenShareAudio: MediaRequestManager;
269
+ screenShareVideo: MediaRequestManager;
270
+ },
271
+ config: Configuration = DefaultConfiguration
272
+ ) {
273
+ super();
274
+ this.started = false;
275
+ this.config = config;
276
+ this.receiveSlotManager = receiveSlotManager;
277
+ this.mediaRequestManagers = mediaRequestManagers;
278
+ this.media = {
279
+ audio: undefined,
280
+ video: {
281
+ activeSpeakerGroups: {},
282
+ memberPanes: {},
283
+ },
284
+ screenShare: {
285
+ audio: undefined,
286
+ video: undefined,
287
+ },
288
+ };
289
+
290
+ this.checkConfigValidity();
291
+
292
+ this.slots = {
293
+ audio: [],
294
+ screenShare: {
295
+ audio: [],
296
+ video: undefined,
297
+ },
298
+ video: {
299
+ unused: [],
300
+ activeSpeaker: [],
301
+ receiverSelected: [],
302
+ },
303
+ };
304
+
305
+ this.receiveSlotAllocations = {activeSpeaker: {}, receiverSelected: {}};
306
+
307
+ LoggerProxy.logger.log(
308
+ `RemoteMediaManager#constructor --> RemoteMediaManager created with config: ${JSON.stringify(
309
+ this.config
310
+ )}`
311
+ );
312
+ }
313
+
314
+ /**
315
+ * Checks if configuration is valid, throws an error if it's not
316
+ */
317
+ private checkConfigValidity() {
318
+ if (!(this.config.video.initialLayoutId in this.config.video.layouts)) {
319
+ throw new Error(
320
+ `invalid config: initialLayoutId "${this.config.video.initialLayoutId}" doesn't match any of the layouts`
321
+ );
322
+ }
323
+
324
+ // check if each layout is valid
325
+ Object.values(this.config.video.layouts).forEach((layout) => {
326
+ const groupIds = {};
327
+ const paneIds = {};
328
+ const groupPriorites = {};
329
+
330
+ layout.activeSpeakerVideoPaneGroups?.forEach((group) => {
331
+ if (groupIds[group.id]) {
332
+ throw new Error(
333
+ `invalid config: duplicate active speaker video pane group id: ${group.id}`
334
+ );
335
+ }
336
+ groupIds[group.id] = true;
337
+
338
+ if (groupPriorites[group.priority]) {
339
+ throw new Error(
340
+ `invalid config: multiple active speaker video pane groups have same priority: ${group.priority}`
341
+ );
342
+ }
343
+ groupPriorites[group.priority] = true;
344
+ });
345
+
346
+ layout.memberVideoPanes?.forEach((pane) => {
347
+ if (paneIds[pane.id]) {
348
+ throw new Error(`invalid config: duplicate member video pane id: ${pane.id}`);
349
+ }
350
+ paneIds[pane.id] = true;
351
+ });
352
+ });
353
+ }
354
+
355
+ /**
356
+ * Starts the RemoteMediaManager.
357
+ *
358
+ * @returns {Promise}
359
+ */
360
+ public async start() {
361
+ if (this.started) {
362
+ throw new Error('start() failure: already started');
363
+ }
364
+ this.started = true;
365
+
366
+ await this.createAudioMedia();
367
+
368
+ await this.createScreenShareReceiveSlots();
369
+ this.createScreenShareAudioMedia();
370
+
371
+ await this.preallocateVideoReceiveSlots();
372
+
373
+ await this.setLayout(this.config.video.initialLayoutId);
374
+ }
375
+
376
+ /**
377
+ * Releases all the used resources (like allocated receive slots). This function needs
378
+ * to be called when we leave the meeting, etc.
379
+ */
380
+ public stop() {
381
+ // invalidate all remoteMedia objects
382
+ this.invalidateCurrentRemoteMedia({
383
+ audio: true,
384
+ video: true,
385
+ screenShareAudio: true,
386
+ screenShareVideo: true,
387
+ commit: true,
388
+ });
389
+
390
+ // release all audio receive slots
391
+ this.slots.audio.forEach((slot) => this.receiveSlotManager.releaseSlot(slot));
392
+ this.slots.audio.length = 0;
393
+
394
+ // release screen share slots
395
+ this.slots.screenShare.audio.forEach((slot) => this.receiveSlotManager.releaseSlot(slot));
396
+ this.slots.screenShare.audio.length = 0;
397
+ if (this.slots.screenShare.video) {
398
+ this.receiveSlotManager.releaseSlot(this.slots.screenShare.video);
399
+ this.slots.screenShare.video = undefined;
400
+ }
401
+
402
+ // release video slots
403
+ this.receiveSlotAllocations = {activeSpeaker: {}, receiverSelected: {}};
404
+
405
+ this.slots.video.unused.push(...this.slots.video.activeSpeaker);
406
+ this.slots.video.activeSpeaker.length = 0;
407
+
408
+ this.slots.video.unused.push(...this.slots.video.receiverSelected);
409
+ this.slots.video.receiverSelected.length = 0;
410
+
411
+ this.releaseUnusedVideoSlots();
412
+
413
+ this.currentLayout = undefined;
414
+ this.currentLayoutId = undefined;
415
+ this.started = false;
416
+ }
417
+
418
+ /**
419
+ * Returns the total number of main video panes required for a given layout
420
+ *
421
+ * @param {VideoLayout} layout
422
+ * @returns {number}
423
+ */
424
+ private getRequiredNumVideoSlotsForLayout(layout?: VideoLayout) {
425
+ if (!layout) {
426
+ return 0;
427
+ }
428
+
429
+ const activeSpeakerCount =
430
+ layout.activeSpeakerVideoPaneGroups?.reduce(
431
+ (sum, paneGroup) => sum + paneGroup.numPanes,
432
+ 0
433
+ ) || 0;
434
+
435
+ const receiverSelectedCount = layout.memberVideoPanes?.length || 0;
436
+
437
+ return activeSpeakerCount + receiverSelectedCount;
438
+ }
439
+
440
+ /**
441
+ * Allocates the maximum number of panes that any of the configured layouts will require.
442
+ * We do this at the beginning, because it's more efficient (much faster) then allocating receive slots
443
+ * later, after the SDP exchange was done.
444
+ */
445
+ private async preallocateVideoReceiveSlots() {
446
+ const maxNumVideoPanesRequired = Object.values(this.config.video.layouts).reduce(
447
+ (maxValue, layout) => Math.max(maxValue, this.getRequiredNumVideoSlotsForLayout(layout)),
448
+ 0
449
+ );
450
+
451
+ while (this.slots.video.unused.length < maxNumVideoPanesRequired) {
452
+ // eslint-disable-next-line no-await-in-loop
453
+ this.slots.video.unused.push(
454
+ // eslint-disable-next-line no-await-in-loop
455
+ await this.receiveSlotManager.allocateSlot(MediaType.VideoMain)
456
+ );
457
+ }
458
+ }
459
+
460
+ /**
461
+ * Changes the layout (triggers Event.VideoLayoutChanged)
462
+ *
463
+ * @param {LayoutId} layoutId new layout id
464
+ * @returns {Promise}
465
+ */
466
+ public async setLayout(layoutId: LayoutId) {
467
+ if (!(layoutId in this.config.video.layouts)) {
468
+ throw new Error(
469
+ `invalid layoutId: "${layoutId}" doesn't match any of the configured layouts`
470
+ );
471
+ }
472
+ if (!this.started) {
473
+ throw new Error('setLayout() called before start()');
474
+ }
475
+ this.currentLayoutId = layoutId;
476
+ this.currentLayout = cloneDeep(this.config.video.layouts[this.currentLayoutId]);
477
+
478
+ await this.updateVideoReceiveSlots();
479
+ this.updateVideoRemoteMediaObjects();
480
+ this.updateScreenShareVideoRemoteMediaObject();
481
+ this.emitVideoLayoutChangedEvent();
482
+ }
483
+
484
+ /**
485
+ * Returns the currently selected layout id
486
+ *
487
+ * @returns {LayoutId}
488
+ */
489
+ public getLayoutId(): LayoutId | undefined {
490
+ return this.currentLayoutId;
491
+ }
492
+
493
+ /**
494
+ * Creates the audio slots
495
+ */
496
+ private async createAudioMedia() {
497
+ // create the audio receive slots
498
+ for (let i = 0; i < this.config.audio.numOfActiveSpeakerStreams; i += 1) {
499
+ // eslint-disable-next-line no-await-in-loop
500
+ const slot = await this.receiveSlotManager.allocateSlot(MediaType.AudioMain);
501
+
502
+ this.slots.audio.push(slot);
503
+ }
504
+
505
+ // create a remote media group
506
+ this.media.audio = new RemoteMediaGroup(
507
+ this.mediaRequestManagers.audio,
508
+ this.slots.audio,
509
+ 255,
510
+ true
511
+ );
512
+
513
+ this.emit(
514
+ {file: 'multistream/remoteMediaManager', function: 'createAudioMedia'},
515
+ Event.AudioCreated,
516
+ this.media.audio
517
+ );
518
+ }
519
+
520
+ /**
521
+ * Creates receive slots required for receiving screen share audio and video
522
+ */
523
+ private async createScreenShareReceiveSlots() {
524
+ // audio
525
+ for (let i = 0; i < this.config.audio.numOfScreenShareStreams; i += 1) {
526
+ // eslint-disable-next-line no-await-in-loop
527
+ const slot = await this.receiveSlotManager.allocateSlot(MediaType.AudioSlides);
528
+
529
+ this.slots.screenShare.audio.push(slot);
530
+ }
531
+
532
+ // video
533
+ const isAnyLayoutContainingScreenShareVideo = Object.values(this.config.video.layouts).some(
534
+ (layout) => !!layout.screenShareVideo
535
+ );
536
+
537
+ if (isAnyLayoutContainingScreenShareVideo) {
538
+ this.slots.screenShare.video = await this.receiveSlotManager.allocateSlot(
539
+ MediaType.VideoSlides
540
+ );
541
+ }
542
+ }
543
+
544
+ /**
545
+ * Creates RemoteMedia objects for screen share
546
+ */
547
+ private createScreenShareAudioMedia() {
548
+ if (this.slots.screenShare.audio.length > 0) {
549
+ this.media.screenShare.audio = new RemoteMediaGroup(
550
+ this.mediaRequestManagers.screenShareAudio,
551
+ this.slots.screenShare.audio,
552
+ 255,
553
+ true
554
+ );
555
+
556
+ this.emit(
557
+ {file: 'multistream/remoteMediaManager', function: 'createScreenShareAudioMedia'},
558
+ Event.ScreenShareAudioCreated,
559
+ this.media.screenShare.audio
560
+ );
561
+ }
562
+ }
563
+
564
+ /**
565
+ * Goes over all receiver-selected slots and keeps only the ones that are required by a given layout,
566
+ * the rest are all moved to the "unused" list
567
+ */
568
+ private trimReceiverSelectedSlots() {
569
+ const requiredCsis = {};
570
+
571
+ // fill requiredCsis with all the CSIs that the given layout requires
572
+ this.currentLayout?.memberVideoPanes?.forEach((memberVideoPane) => {
573
+ if (memberVideoPane.csi !== undefined) {
574
+ requiredCsis[memberVideoPane.csi] = true;
575
+ }
576
+ });
577
+
578
+ const isCsiNeededByCurrentLayout = (csi?: CSI): boolean => {
579
+ if (csi === undefined) {
580
+ return false;
581
+ }
582
+
583
+ return !!requiredCsis[csi];
584
+ };
585
+
586
+ // keep receiverSelected slots that match our new requiredCsis, move the rest of receiverSelected slots to unused
587
+ const notNeededReceiverSelectedSlots = remove(
588
+ this.slots.video.receiverSelected,
589
+ (slot) => isCsiNeededByCurrentLayout(slot.csi) === false
590
+ );
591
+
592
+ this.slots.video.unused.push(...notNeededReceiverSelectedSlots);
593
+ }
594
+
595
+ /**
596
+ * Releases all the "unused" video slots.
597
+ */
598
+ private releaseUnusedVideoSlots() {
599
+ this.slots.video.unused.forEach((slot) => this.receiveSlotManager.releaseSlot(slot));
600
+ this.slots.video.unused.length = 0;
601
+ }
602
+
603
+ /**
604
+ * Allocates receive slots to all active speaker video panes
605
+ * in the current selected layout.
606
+ *
607
+ * Allocation tries to keep the same order of the slots between the previous
608
+ * layout and the new one. Sorting helps making sure that highest priority slots
609
+ * go in the same order in the new layout.
610
+ */
611
+ private allocateSlotsToActiveSpeakerPaneGroups() {
612
+ this.currentLayout?.activeSpeakerVideoPaneGroups
613
+ // sorting in descending order based on group priority
614
+ ?.sort((a, b) => (a.priority < b.priority ? 1 : -1))
615
+ ?.forEach((group) => {
616
+ this.receiveSlotAllocations.activeSpeaker[group.id] = {slots: []};
617
+
618
+ for (let paneIndex = 0; paneIndex < group.numPanes; paneIndex += 1) {
619
+ // allocate a slot from the "unused" list, by grabbing in same order (shift) as previous layout
620
+ const freeSlot = this.slots.video.unused.shift();
621
+
622
+ if (freeSlot) {
623
+ this.slots.video.activeSpeaker.push(freeSlot);
624
+ this.receiveSlotAllocations.activeSpeaker[group.id].slots.push(freeSlot);
625
+ }
626
+ }
627
+ });
628
+ }
629
+
630
+ /**
631
+ * Allocates receive slots to all receiver selected video panes
632
+ * in the current selected layout
633
+ */
634
+ private allocateSlotsToReceiverSelectedVideoPaneGroups() {
635
+ this.currentLayout?.memberVideoPanes?.forEach((memberPane) => {
636
+ // check if there is existing slot for this csi
637
+ const existingSlot = this.slots.video.receiverSelected.find(
638
+ (slot) => slot.csi === memberPane.csi
639
+ );
640
+
641
+ const isExistingSlotAlreadyAllocated = Object.values(
642
+ this.receiveSlotAllocations.receiverSelected
643
+ ).includes(existingSlot);
644
+
645
+ if (memberPane.csi !== undefined && existingSlot && !isExistingSlotAlreadyAllocated) {
646
+ // found it, so use it
647
+ this.receiveSlotAllocations.receiverSelected[memberPane.id] = existingSlot;
648
+ } else {
649
+ // allocate a slot from the "unused" list
650
+ const freeSlot = this.slots.video.unused.pop();
651
+
652
+ if (freeSlot) {
653
+ this.slots.video.receiverSelected.push(freeSlot);
654
+ this.receiveSlotAllocations.receiverSelected[memberPane.id] = freeSlot;
655
+ }
656
+ }
657
+ });
658
+ }
659
+
660
+ /**
661
+ * Ensures that we have enough slots for the current layout.
662
+ */
663
+ private async refillRequiredSlotsIfNeeded() {
664
+ const requiredNumSlots = this.getRequiredNumVideoSlotsForLayout(this.currentLayout);
665
+ const totalNumSlots =
666
+ this.slots.video.unused.length +
667
+ this.slots.video.activeSpeaker.length +
668
+ this.slots.video.receiverSelected.length;
669
+
670
+ if (totalNumSlots < requiredNumSlots) {
671
+ let numSlotsToCreate = requiredNumSlots - totalNumSlots;
672
+
673
+ while (numSlotsToCreate > 0) {
674
+ // eslint-disable-next-line no-await-in-loop
675
+ this.slots.video.unused.push(
676
+ // eslint-disable-next-line no-await-in-loop
677
+ await this.receiveSlotManager.allocateSlot(MediaType.VideoMain)
678
+ );
679
+ numSlotsToCreate -= 1;
680
+ }
681
+ }
682
+ }
683
+
684
+ /**
685
+ * Move all active speaker slots to "unused"
686
+ */
687
+ private trimActiveSpeakerSlots() {
688
+ this.slots.video.unused.push(...this.slots.video.activeSpeaker);
689
+ this.slots.video.activeSpeaker.length = 0;
690
+ }
691
+
692
+ /**
693
+ * Logs the state of the receive slots
694
+ */
695
+ private logReceieveSlots() {
696
+ let logMessage = '';
697
+ forEach(this.receiveSlotAllocations.activeSpeaker, (group, groupName) => {
698
+ logMessage += `group: ${groupName}\n${group.slots.map((slot) => slot.logString).join(' ')}`;
699
+ });
700
+
701
+ logMessage += '\nreceiverSelected:\n';
702
+ forEach(this.receiveSlotAllocations.receiverSelected, (slot, key) => {
703
+ logMessage += ` ${key}: ${slot.logString}\n`;
704
+ });
705
+
706
+ LoggerProxy.logger.log(
707
+ `RemoteMediaManager#updateVideoReceiveSlots --> receive slots updated: unused=${this.slots.video.unused.length}, activeSpeaker=${this.slots.video.activeSpeaker.length}, receiverSelected=${this.slots.video.receiverSelected.length}\n${logMessage}`
708
+ );
709
+ }
710
+
711
+ /**
712
+ * Makes sure we have the right number of receive slots created for the current layout
713
+ * and allocates them to the right video panes / pane groups
714
+ *
715
+ * @returns {Promise}
716
+ */
717
+ private async updateVideoReceiveSlots() {
718
+ // move all active speaker slots to "unused"
719
+ this.trimActiveSpeakerSlots();
720
+
721
+ // move all no longer needed receiver-selected slots to "unused"
722
+ this.trimReceiverSelectedSlots();
723
+
724
+ // ensure we have enough total slots for current layout
725
+ await this.refillRequiredSlotsIfNeeded();
726
+
727
+ // allocate the slots to the right panes / pane groups
728
+ // reset allocations
729
+ this.receiveSlotAllocations = {activeSpeaker: {}, receiverSelected: {}};
730
+ // allocate active speaker
731
+ this.allocateSlotsToActiveSpeakerPaneGroups();
732
+ // allocate receiver selected
733
+ this.allocateSlotsToReceiverSelectedVideoPaneGroups();
734
+
735
+ this.logReceieveSlots();
736
+
737
+ // If this is the initial layout, there may be some "unused" slots left because of the preallocation
738
+ // done in this.preallocateVideoReceiveSlots(), so release them now
739
+ this.releaseUnusedVideoSlots();
740
+ }
741
+
742
+ /**
743
+ * Creates new RemoteMedia and RemoteMediaGroup objects for the current layout
744
+ * and sends the media requests for all of them.
745
+ */
746
+ private updateVideoRemoteMediaObjects() {
747
+ // invalidate all the previous remote media objects and cancel their media requests
748
+ this.invalidateCurrentRemoteMedia({
749
+ audio: false,
750
+ video: true,
751
+ screenShareAudio: false,
752
+ screenShareVideo: false,
753
+ commit: false,
754
+ });
755
+
756
+ // create new remoteMediaGroup objects
757
+ this.media.video.activeSpeakerGroups = {};
758
+ this.media.video.memberPanes = {};
759
+
760
+ for (const [groupId, group] of Object.entries(this.receiveSlotAllocations.activeSpeaker)) {
761
+ const paneGroupInCurrentLayout = this.currentLayout?.activeSpeakerVideoPaneGroups?.find(
762
+ (groupInLayout) => groupInLayout.id === groupId
763
+ );
764
+
765
+ if (paneGroupInCurrentLayout) {
766
+ const mediaGroup = new RemoteMediaGroup(
767
+ this.mediaRequestManagers.video,
768
+ group.slots,
769
+ paneGroupInCurrentLayout.priority,
770
+ false,
771
+ {
772
+ preferLiveVideo: this.config.video.preferLiveVideo,
773
+ resolution: paneGroupInCurrentLayout.size,
774
+ }
775
+ );
776
+
777
+ this.media.video.activeSpeakerGroups[groupId] = mediaGroup;
778
+ } else {
779
+ // this should never happen, because this.receiveSlotAllocations are created based on current layout configuration
780
+ LoggerProxy.logger.warn(
781
+ `a group id ${groupId} from this.receiveSlotAllocations.activeSpeaker cannot be found in the current layout configuration`
782
+ );
783
+ }
784
+ }
785
+
786
+ // create new remoteMedia objects
787
+ for (const [paneId, slot] of Object.entries(this.receiveSlotAllocations.receiverSelected)) {
788
+ const paneInCurrentLayout = this.currentLayout?.memberVideoPanes?.find(
789
+ (paneInLayout) => paneInLayout.id === paneId
790
+ );
791
+
792
+ if (paneInCurrentLayout) {
793
+ const remoteMedia = new RemoteMedia(slot, this.mediaRequestManagers.video, {
794
+ resolution: paneInCurrentLayout.size,
795
+ });
796
+
797
+ if (paneInCurrentLayout.csi) {
798
+ remoteMedia.sendMediaRequest(paneInCurrentLayout.csi, false);
799
+ }
800
+
801
+ this.media.video.memberPanes[paneId] = remoteMedia;
802
+ } else {
803
+ // this should never happen, because this.receiveSlotAllocations are created based on current layout configuration
804
+ LoggerProxy.logger.warn(
805
+ `a pane id ${paneId} from this.receiveSlotAllocations.receiverSelected cannot be found in the current layout configuration`
806
+ );
807
+ }
808
+ }
809
+
810
+ this.mediaRequestManagers.video.commit();
811
+ }
812
+
813
+ /**
814
+ * Checks if current layout requires a screen share.
815
+ * If it does, it creates new RemoteMediaGroup object for screen share
816
+ * and sends the media requests for it.
817
+ * If it doesn't, it makes sure we clean up any RemoteMediaGroup objects
818
+ * created earlier for screen share (for previous layout).
819
+ */
820
+ private updateScreenShareVideoRemoteMediaObject() {
821
+ this.invalidateCurrentRemoteMedia({
822
+ audio: false,
823
+ video: false,
824
+ screenShareAudio: false,
825
+ screenShareVideo: true,
826
+ commit: false,
827
+ });
828
+
829
+ this.media.screenShare.video = undefined;
830
+
831
+ if (this.currentLayout?.screenShareVideo) {
832
+ // we create a group of 1, because for screen share we need to use the "active speaker" policy
833
+ this.media.screenShare.video = new RemoteMediaGroup(
834
+ this.mediaRequestManagers.screenShareVideo,
835
+ [this.slots.screenShare.video],
836
+ 255,
837
+ false,
838
+ {resolution: this.currentLayout.screenShareVideo.size}
839
+ );
840
+ }
841
+
842
+ this.mediaRequestManagers.screenShareVideo.commit();
843
+ }
844
+
845
+ /**
846
+ * Invalidates all remote media objects belonging to currently selected layout
847
+ */
848
+ private invalidateCurrentRemoteMedia(options: {
849
+ audio: boolean;
850
+ video: boolean;
851
+ screenShareAudio: boolean;
852
+ screenShareVideo: boolean;
853
+ commit: boolean;
854
+ }) {
855
+ const {audio, video, screenShareAudio, screenShareVideo, commit} = options;
856
+
857
+ if (audio && this.media.audio) {
858
+ this.media.audio.stop(commit);
859
+ }
860
+ if (video) {
861
+ Object.values(this.media.video.activeSpeakerGroups).forEach((remoteMediaGroup) => {
862
+ remoteMediaGroup.stop(false);
863
+ });
864
+ Object.values(this.media.video.memberPanes).forEach((remoteMedia) => {
865
+ remoteMedia.stop(false);
866
+ });
867
+ if (commit) {
868
+ this.mediaRequestManagers.video.commit();
869
+ }
870
+ }
871
+
872
+ if (screenShareAudio && this.media.screenShare.audio) {
873
+ this.media.screenShare.audio.stop(commit);
874
+ }
875
+ if (screenShareVideo && this.media.screenShare.video) {
876
+ this.media.screenShare.video.stop(commit);
877
+ }
878
+ }
879
+
880
+ /** emits Event.VideoLayoutChanged */
881
+ private emitVideoLayoutChangedEvent() {
882
+ // todo: at this point the receive slots might still be showing a participant from previous layout, we should
883
+ // wait for our media requests to be fulfilled, but there is no API for that right now (we could wait for source updates
884
+ // but in some cases they might never come, or would need to always make sure to use a new set of receiver slots)
885
+ // for now it's fine to have it like this, we will re-evaluate if it needs improving after more testing
886
+
887
+ this.emit(
888
+ {
889
+ file: 'multistream/remoteMediaManager',
890
+ function: 'emitVideoLayoutChangedEvent',
891
+ },
892
+ Event.VideoLayoutChanged,
893
+ {
894
+ layoutId: this.currentLayoutId,
895
+ activeSpeakerVideoPanes: this.media.video.activeSpeakerGroups,
896
+ memberVideoPanes: this.media.video.memberPanes,
897
+ screenShareVideo: this.media.screenShare.video?.getRemoteMedia()[0],
898
+ }
899
+ );
900
+ }
901
+
902
+ /**
903
+ * Sets a new CSI on a given remote media object
904
+ *
905
+ * @param {RemoteMedia} remoteMedia remote Media object to modify
906
+ * @param {CSI} csi new CSI value, can be null if we want to stop receiving media
907
+ */
908
+ public setRemoteVideoCsi(remoteMedia: RemoteMedia, csi: CSI | null) {
909
+ if (!Object.values(this.media.video.memberPanes).includes(remoteMedia)) {
910
+ throw new Error('remoteMedia not found');
911
+ }
912
+
913
+ if (csi) {
914
+ remoteMedia.sendMediaRequest(csi, true);
915
+ } else {
916
+ remoteMedia.cancelMediaRequest(true);
917
+ }
918
+ }
919
+
920
+ /**
921
+ * Adds a new member video pane to the currently selected layout.
922
+ *
923
+ * Changes to the layout are lost after a layout change.
924
+ *
925
+ * @param {MemberVideoPane} newPane
926
+ * @returns {Promise<RemoteMedia>}
927
+ */
928
+ public async addMemberVideoPane(newPane: MemberVideoPane): Promise<RemoteMedia> {
929
+ if (!this.currentLayout) {
930
+ throw new Error('There is no current layout selected, call start() first');
931
+ }
932
+
933
+ if (!this.currentLayout?.memberVideoPanes) {
934
+ this.currentLayout.memberVideoPanes = [];
935
+ }
936
+
937
+ if (newPane.id in this.currentLayout.memberVideoPanes) {
938
+ throw new Error(
939
+ `duplicate pane id ${newPane.id} - this pane already exists in current layout's memberVideoPanes`
940
+ );
941
+ }
942
+
943
+ this.currentLayout.memberVideoPanes.push(newPane);
944
+
945
+ const receiveSlot = await this.receiveSlotManager.allocateSlot(MediaType.VideoMain);
946
+
947
+ this.slots.video.receiverSelected.push(receiveSlot);
948
+
949
+ const remoteMedia = new RemoteMedia(receiveSlot, this.mediaRequestManagers.video, {
950
+ resolution: newPane.size,
951
+ });
952
+
953
+ if (newPane.csi) {
954
+ remoteMedia.sendMediaRequest(newPane.csi, true);
955
+ }
956
+
957
+ this.media.video.memberPanes[newPane.id] = remoteMedia;
958
+
959
+ return remoteMedia;
960
+ }
961
+
962
+ /**
963
+ * Removes a member video pane from the currently selected layout.
964
+ *
965
+ * Changes to the layout are lost after a layout change.
966
+ *
967
+ * @param {PaneId} paneId pane id of the pane to remove
968
+ * @returns {Promise<void>}
969
+ */
970
+ public removeMemberVideoPane(paneId: PaneId): Promise<void> {
971
+ if (!this.currentLayout) {
972
+ return Promise.reject(new Error('There is no current layout selected, call start() first'));
973
+ }
974
+
975
+ if (!this.currentLayout.memberVideoPanes?.find((pane) => pane.id === paneId)) {
976
+ // pane id doesn't exist, so nothing to do
977
+ LoggerProxy.logger.log(
978
+ `RemoteMediaManager#removeMemberVideoPane --> removeMemberVideoPane() called for a non-existent paneId: ${paneId} (pane not found in currentLayout.memberVideoPanes)`
979
+ );
980
+
981
+ return Promise.resolve();
982
+ }
983
+
984
+ if (!this.media.video.memberPanes[paneId]) {
985
+ // pane id doesn't exist, so nothing to do
986
+ LoggerProxy.logger.log(
987
+ `RemoteMediaManager#removeMemberVideoPane --> removeMemberVideoPane() called for a non-existent paneId: ${paneId} (pane not found in this.media.video.memberPanes)`
988
+ );
989
+
990
+ return Promise.resolve();
991
+ }
992
+
993
+ const remoteMedia = this.media.video.memberPanes[paneId];
994
+
995
+ const receiveSlot = remoteMedia.getUnderlyingReceiveSlot();
996
+
997
+ if (receiveSlot) {
998
+ this.receiveSlotManager.releaseSlot(receiveSlot);
999
+
1000
+ const index = this.slots.video.receiverSelected.indexOf(receiveSlot);
1001
+
1002
+ if (index >= 0) {
1003
+ this.slots.video.receiverSelected.splice(index, 1);
1004
+ }
1005
+ }
1006
+ remoteMedia.stop();
1007
+
1008
+ delete this.media.video.memberPanes[paneId];
1009
+ delete this.currentLayout.memberVideoPanes?.[paneId];
1010
+
1011
+ return Promise.resolve();
1012
+ }
1013
+
1014
+ /**
1015
+ * Pins an active speaker remote media object to the given CSI value. From that moment
1016
+ * onwards the remote media will only play audio/video from that specific CSI until
1017
+ * unpinActiveSpeakerVideoPane() is called or current layout is changed.
1018
+ *
1019
+ * @param {RemoteMedia} remoteMedia remote media object reference
1020
+ * @param {CSI} csi CSI value to pin to, if undefined, then current CSI value is used
1021
+ */
1022
+ public pinActiveSpeakerVideoPane(remoteMedia: RemoteMedia, csi?: CSI): void {
1023
+ const remoteMediaGroup = Object.values(this.media.video.activeSpeakerGroups).find((group) =>
1024
+ group.includes(remoteMedia, 'unpinned')
1025
+ );
1026
+
1027
+ if (!remoteMediaGroup) {
1028
+ throw new Error(
1029
+ 'remoteMedia not found among the unpinned remote media from any active speaker group'
1030
+ );
1031
+ }
1032
+
1033
+ remoteMediaGroup.pin(remoteMedia, csi);
1034
+ }
1035
+
1036
+ /**
1037
+ * Unpins a remote media object from the fixed CSI value it was pinned to.
1038
+ *
1039
+ * @param {RemoteMedia} remoteMedia remote media object reference
1040
+ */
1041
+ public unpinActiveSpeakerVideoPane(remoteMedia: RemoteMedia) {
1042
+ const remoteMediaGroup = Object.values(this.media.video.activeSpeakerGroups).find((group) =>
1043
+ group.includes(remoteMedia, 'pinned')
1044
+ );
1045
+
1046
+ if (!remoteMediaGroup) {
1047
+ throw new Error(
1048
+ 'remoteMedia not found among the pinned remote media from any active speaker group'
1049
+ );
1050
+ }
1051
+
1052
+ remoteMediaGroup.unpin(remoteMedia);
1053
+ }
1054
+
1055
+ /**
1056
+ * Returns true if a given remote media object belongs to an active speaker group and has been pinned.
1057
+ * Throws an error if the remote media object doesn't belong to any active speaker remote media group.
1058
+ *
1059
+ * @param {RemoteMedia} remoteMedia remote media object
1060
+ * @returns {boolean}
1061
+ */
1062
+ public isPinned(remoteMedia: RemoteMedia) {
1063
+ const remoteMediaGroup = Object.values(this.media.video.activeSpeakerGroups).find((group) =>
1064
+ group.includes(remoteMedia)
1065
+ );
1066
+
1067
+ if (!remoteMediaGroup) {
1068
+ throw new Error(
1069
+ 'remoteMedia not found among any remote media (pinned or unpinned) from any active speaker group'
1070
+ );
1071
+ }
1072
+
1073
+ return remoteMediaGroup.isPinned(remoteMedia);
1074
+ }
1075
+ }