@webex/plugin-meetings 3.12.0 → 3.13.0-next.10

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 (354) hide show
  1. package/.sdd/manifest.json +1312 -0
  2. package/.sdd/templates/.source.json +30 -0
  3. package/.sdd/templates/component-repo/module-docs/module-spec-quality.md +111 -0
  4. package/.sdd/templates/component-repo/module-docs/module-spec.template.md +321 -0
  5. package/.sdd/templates/component-repo/reference-docs/adr/_adr-example.md +59 -0
  6. package/.sdd/templates/component-repo/reference-docs/patterns/_pattern-example.md +49 -0
  7. package/.sdd/templates/component-repo/reference-docs/rules/_rule-example.md +42 -0
  8. package/.sdd/templates/component-repo/standing-docs/AGENTS.template.md +120 -0
  9. package/.sdd/templates/component-repo/standing-docs/ARCHITECTURE.template.md +206 -0
  10. package/.sdd/templates/component-repo/standing-docs/CONTRACTS.template.md +90 -0
  11. package/.sdd/templates/component-repo/standing-docs/DATA_MODEL.template.md +68 -0
  12. package/.sdd/templates/component-repo/standing-docs/GETTING_STARTED.template.md +111 -0
  13. package/.sdd/templates/component-repo/standing-docs/GLOSSARY.template.md +57 -0
  14. package/.sdd/templates/component-repo/standing-docs/REVIEW_CHECKLIST.template.md +69 -0
  15. package/.sdd/templates/component-repo/standing-docs/RULES.template.md +96 -0
  16. package/.sdd/templates/component-repo/standing-docs/SECURITY.template.md +84 -0
  17. package/.sdd/templates/component-repo/standing-docs/SERVICE_STATE.template.md +82 -0
  18. package/.sdd/templates/component-repo/standing-docs/SPEC_INDEX.template.md +94 -0
  19. package/.sdd/templates/component-repo/standing-docs/TEST_INDEX.template.md +64 -0
  20. package/.sdd/templates/component-repo/template-map.json +112 -0
  21. package/AGENTS.md +135 -0
  22. package/ai-docs/ARCHITECTURE.md +208 -0
  23. package/ai-docs/CONTRACTS.md +267 -0
  24. package/ai-docs/DATA_MODEL.md +64 -0
  25. package/ai-docs/GETTING_STARTED.md +73 -0
  26. package/ai-docs/GLOSSARY.md +56 -0
  27. package/ai-docs/REVIEW_CHECKLIST.md +45 -0
  28. package/ai-docs/RULES.md +79 -0
  29. package/ai-docs/SECURITY.md +74 -0
  30. package/ai-docs/SERVICE_STATE.md +59 -0
  31. package/ai-docs/SPEC_INDEX.md +85 -0
  32. package/ai-docs/TEST_INDEX.md +45 -0
  33. package/ai-docs/adr/0001-migrate-existing-docs-into-sdd.md +61 -0
  34. package/ai-docs/patterns/defensive-error-propagation.md +55 -0
  35. package/ai-docs/patterns/event-scope-emission.md +46 -0
  36. package/ai-docs/patterns/source-to-test-path-mirroring.md +45 -0
  37. package/ai-docs/patterns/stateless-plugin-request-classes.md +53 -0
  38. package/ai-docs/patterns/typed-constants-and-enum-values.md +47 -0
  39. package/assets/README.md +28 -0
  40. package/assets/e2ee-0.0.1.js +2 -0
  41. package/assets/e2ee-0.0.1.wasm +0 -0
  42. package/babel.config.js +17 -1
  43. package/dist/aiEnableRequest/index.js +15 -2
  44. package/dist/aiEnableRequest/index.js.map +1 -1
  45. package/dist/annotation/index.js +55 -19
  46. package/dist/annotation/index.js.map +1 -1
  47. package/dist/assets/e2ee-0.0.1.js +2 -0
  48. package/dist/assets/e2ee-0.0.1.wasm +0 -0
  49. package/dist/breakouts/breakout.js +8 -3
  50. package/dist/breakouts/breakout.js.map +1 -1
  51. package/dist/breakouts/events.js +29 -14
  52. package/dist/breakouts/events.js.map +1 -1
  53. package/dist/breakouts/index.js +128 -7
  54. package/dist/breakouts/index.js.map +1 -1
  55. package/dist/common/errors/webex-errors.js +54 -5
  56. package/dist/common/errors/webex-errors.js.map +1 -1
  57. package/dist/common/wasm-loader.js +174 -0
  58. package/dist/common/wasm-loader.js.map +1 -0
  59. package/dist/config.js +5 -2
  60. package/dist/config.js.map +1 -1
  61. package/dist/constants.js +39 -11
  62. package/dist/constants.js.map +1 -1
  63. package/dist/controls-options-manager/constants.js +11 -1
  64. package/dist/controls-options-manager/constants.js.map +1 -1
  65. package/dist/controls-options-manager/index.js +67 -29
  66. package/dist/controls-options-manager/index.js.map +1 -1
  67. package/dist/controls-options-manager/util.js +91 -0
  68. package/dist/controls-options-manager/util.js.map +1 -1
  69. package/dist/e2ee/E2eeManager.js +91 -0
  70. package/dist/e2ee/E2eeManager.js.map +1 -0
  71. package/dist/e2ee/E2eeSignaling.js +200 -0
  72. package/dist/e2ee/E2eeSignaling.js.map +1 -0
  73. package/dist/e2ee/MediaEncryptionService.js +75 -0
  74. package/dist/e2ee/MediaEncryptionService.js.map +1 -0
  75. package/dist/e2ee/mls.js +558 -0
  76. package/dist/e2ee/mls.js.map +1 -0
  77. package/dist/e2ee/types.js +59 -0
  78. package/dist/e2ee/types.js.map +1 -0
  79. package/dist/e2ee/wasm.d.js +7 -0
  80. package/dist/e2ee/wasm.d.js.map +1 -0
  81. package/dist/hashTree/constants.js +13 -1
  82. package/dist/hashTree/constants.js.map +1 -1
  83. package/dist/hashTree/hashTreeParser.js +1245 -404
  84. package/dist/hashTree/hashTreeParser.js.map +1 -1
  85. package/dist/hashTree/utils.js +42 -0
  86. package/dist/hashTree/utils.js.map +1 -1
  87. package/dist/index.js +8 -0
  88. package/dist/index.js.map +1 -1
  89. package/dist/interceptors/dataChannelAuthToken.js +58 -16
  90. package/dist/interceptors/dataChannelAuthToken.js.map +1 -1
  91. package/dist/interceptors/locusRetry.js +24 -9
  92. package/dist/interceptors/locusRetry.js.map +1 -1
  93. package/dist/interpretation/index.js +55 -12
  94. package/dist/interpretation/index.js.map +1 -1
  95. package/dist/interpretation/interpretation.types.js +7 -0
  96. package/dist/interpretation/interpretation.types.js.map +1 -0
  97. package/dist/interpretation/siLanguage.js +1 -1
  98. package/dist/locus-info/controlsUtils.js +4 -1
  99. package/dist/locus-info/controlsUtils.js.map +1 -1
  100. package/dist/locus-info/index.js +914 -196
  101. package/dist/locus-info/index.js.map +1 -1
  102. package/dist/locus-info/infoUtils.js +36 -5
  103. package/dist/locus-info/infoUtils.js.map +1 -1
  104. package/dist/locus-info/types.js +20 -0
  105. package/dist/locus-info/types.js.map +1 -1
  106. package/dist/media/MediaConnectionAwaiter.js +229 -166
  107. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  108. package/dist/media/index.js +8 -2
  109. package/dist/media/index.js.map +1 -1
  110. package/dist/media/properties.js +4 -5
  111. package/dist/media/properties.js.map +1 -1
  112. package/dist/meeting/in-meeting-actions.js +5 -1
  113. package/dist/meeting/in-meeting-actions.js.map +1 -1
  114. package/dist/meeting/index.js +1931 -887
  115. package/dist/meeting/index.js.map +1 -1
  116. package/dist/meeting/locusMediaRequest.js +229 -82
  117. package/dist/meeting/locusMediaRequest.js.map +1 -1
  118. package/dist/meeting/muteState.js +10 -1
  119. package/dist/meeting/muteState.js.map +1 -1
  120. package/dist/meeting/request.js +5 -2
  121. package/dist/meeting/request.js.map +1 -1
  122. package/dist/meeting/util.js +42 -3
  123. package/dist/meeting/util.js.map +1 -1
  124. package/dist/meeting/voicea-meeting.js +2 -1
  125. package/dist/meeting/voicea-meeting.js.map +1 -1
  126. package/dist/meeting-info/meeting-info-v2.js +12 -5
  127. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  128. package/dist/meetings/index.js +342 -129
  129. package/dist/meetings/index.js.map +1 -1
  130. package/dist/meetings/meetings.types.js +6 -1
  131. package/dist/meetings/meetings.types.js.map +1 -1
  132. package/dist/meetings/request.js +39 -0
  133. package/dist/meetings/request.js.map +1 -1
  134. package/dist/meetings/util.js +116 -18
  135. package/dist/meetings/util.js.map +1 -1
  136. package/dist/member/index.js +10 -0
  137. package/dist/member/index.js.map +1 -1
  138. package/dist/member/types.js.map +1 -1
  139. package/dist/member/util.js +30 -0
  140. package/dist/member/util.js.map +1 -1
  141. package/dist/members/index.js +101 -43
  142. package/dist/members/index.js.map +1 -1
  143. package/dist/members/util.js +8 -1
  144. package/dist/members/util.js.map +1 -1
  145. package/dist/metrics/constants.js +11 -1
  146. package/dist/metrics/constants.js.map +1 -1
  147. package/dist/multistream/codec/constants.js +63 -0
  148. package/dist/multistream/codec/constants.js.map +1 -0
  149. package/dist/multistream/mediaRequestManager.js +62 -15
  150. package/dist/multistream/mediaRequestManager.js.map +1 -1
  151. package/dist/multistream/receiveSlot.js +9 -0
  152. package/dist/multistream/receiveSlot.js.map +1 -1
  153. package/dist/multistream/remoteMediaManager.js +32 -4
  154. package/dist/multistream/remoteMediaManager.js.map +1 -1
  155. package/dist/multistream/sendSlotManager.js +127 -3
  156. package/dist/multistream/sendSlotManager.js.map +1 -1
  157. package/dist/reachability/clusterReachability.js.map +1 -1
  158. package/dist/reachability/index.js +121 -83
  159. package/dist/reachability/index.js.map +1 -1
  160. package/dist/reachability/reachability.types.js +2 -0
  161. package/dist/reachability/reachability.types.js.map +1 -1
  162. package/dist/reachability/util.js +45 -0
  163. package/dist/reachability/util.js.map +1 -1
  164. package/dist/reactions/reactions.type.js.map +1 -1
  165. package/dist/recording-controller/index.js +1 -3
  166. package/dist/recording-controller/index.js.map +1 -1
  167. package/dist/roap/turnDiscovery.js +8 -1
  168. package/dist/roap/turnDiscovery.js.map +1 -1
  169. package/dist/types/annotation/index.d.ts +19 -0
  170. package/dist/types/common/errors/webex-errors.d.ts +36 -2
  171. package/dist/types/common/wasm-loader.d.ts +55 -0
  172. package/dist/types/config.d.ts +5 -2
  173. package/dist/types/constants.d.ts +15 -2
  174. package/dist/types/controls-options-manager/constants.d.ts +6 -1
  175. package/dist/types/controls-options-manager/index.d.ts +16 -0
  176. package/dist/types/e2ee/E2eeManager.d.ts +23 -0
  177. package/dist/types/e2ee/E2eeSignaling.d.ts +94 -0
  178. package/dist/types/e2ee/MediaEncryptionService.d.ts +27 -0
  179. package/dist/types/e2ee/mls.d.ts +191 -0
  180. package/dist/types/e2ee/types.d.ts +104 -0
  181. package/dist/types/hashTree/constants.d.ts +2 -0
  182. package/dist/types/hashTree/hashTreeParser.d.ts +230 -18
  183. package/dist/types/hashTree/utils.d.ts +18 -0
  184. package/dist/types/index.d.ts +4 -0
  185. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  186. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  187. package/dist/types/locus-info/index.d.ts +151 -15
  188. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  189. package/dist/types/locus-info/types.d.ts +28 -1
  190. package/dist/types/media/MediaConnectionAwaiter.d.ts +66 -49
  191. package/dist/types/media/properties.d.ts +6 -2
  192. package/dist/types/meeting/in-meeting-actions.d.ts +4 -0
  193. package/dist/types/meeting/index.d.ts +247 -13
  194. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  195. package/dist/types/meeting/request.d.ts +1 -0
  196. package/dist/types/meeting/util.d.ts +12 -1
  197. package/dist/types/meeting-info/meeting-info-v2.d.ts +1 -0
  198. package/dist/types/meetings/index.d.ts +44 -19
  199. package/dist/types/meetings/meetings.types.d.ts +15 -0
  200. package/dist/types/meetings/request.d.ts +14 -0
  201. package/dist/types/member/index.d.ts +1 -0
  202. package/dist/types/member/types.d.ts +1 -0
  203. package/dist/types/member/util.d.ts +9 -0
  204. package/dist/types/members/index.d.ts +15 -2
  205. package/dist/types/members/util.d.ts +1 -5
  206. package/dist/types/metrics/constants.d.ts +10 -0
  207. package/dist/types/multistream/codec/constants.d.ts +7 -0
  208. package/dist/types/multistream/mediaRequestManager.d.ts +22 -5
  209. package/dist/types/multistream/remoteMediaManager.d.ts +18 -0
  210. package/dist/types/multistream/sendSlotManager.d.ts +28 -2
  211. package/dist/types/reachability/clusterReachability.d.ts +3 -3
  212. package/dist/types/reachability/index.d.ts +10 -3
  213. package/dist/types/reachability/reachability.types.d.ts +7 -0
  214. package/dist/types/reachability/util.d.ts +17 -0
  215. package/dist/types/reactions/reactions.type.d.ts +3 -0
  216. package/dist/webinar/index.js +539 -245
  217. package/dist/webinar/index.js.map +1 -1
  218. package/package.json +26 -24
  219. package/src/aiEnableRequest/ai-docs/ai-enable-request-spec.md +223 -0
  220. package/src/aiEnableRequest/index.ts +16 -0
  221. package/src/annotation/ai-docs/annotation-spec.md +236 -0
  222. package/src/annotation/index.ts +61 -29
  223. package/src/breakouts/ai-docs/breakouts-spec.md +324 -0
  224. package/src/breakouts/breakout.ts +3 -1
  225. package/src/breakouts/events.ts +33 -11
  226. package/src/breakouts/index.ts +145 -3
  227. package/src/common/errors/webex-errors.ts +56 -3
  228. package/src/common/wasm-loader.ts +124 -0
  229. package/src/config.ts +9 -3
  230. package/src/constants.ts +23 -4
  231. package/src/controls-options-manager/ai-docs/controls-options-manager-spec.md +243 -0
  232. package/src/controls-options-manager/constants.ts +14 -1
  233. package/src/controls-options-manager/index.ts +87 -28
  234. package/src/controls-options-manager/util.ts +81 -1
  235. package/src/e2ee/E2eeManager.ts +58 -0
  236. package/src/e2ee/E2eeSignaling.ts +215 -0
  237. package/src/e2ee/MediaEncryptionService.ts +41 -0
  238. package/src/e2ee/mls.ts +548 -0
  239. package/src/e2ee/types.ts +114 -0
  240. package/src/e2ee/wasm.d.ts +153 -0
  241. package/src/hashTree/ai-docs/hash-tree-spec.md +267 -0
  242. package/src/hashTree/constants.ts +16 -0
  243. package/src/hashTree/hashTreeParser.ts +1021 -214
  244. package/src/hashTree/utils.ts +36 -0
  245. package/src/index.ts +7 -0
  246. package/src/interceptors/ai-docs/interceptors-spec.md +247 -0
  247. package/src/interceptors/dataChannelAuthToken.ts +59 -12
  248. package/src/interceptors/locusRetry.ts +26 -5
  249. package/src/interpretation/ai-docs/interpretation-spec.md +256 -0
  250. package/src/interpretation/index.ts +65 -10
  251. package/src/interpretation/interpretation.types.ts +11 -0
  252. package/src/locus-info/ai-docs/locus-info-spec.md +293 -0
  253. package/src/locus-info/controlsUtils.ts +3 -1
  254. package/src/locus-info/index.ts +907 -184
  255. package/src/locus-info/infoUtils.ts +41 -6
  256. package/src/locus-info/types.ts +33 -1
  257. package/src/media/MediaConnectionAwaiter.ts +229 -196
  258. package/src/media/ai-docs/media-spec.md +267 -0
  259. package/src/media/index.ts +10 -1
  260. package/src/media/properties.ts +8 -3
  261. package/src/meeting/ai-docs/meeting-spec.md +404 -0
  262. package/src/meeting/in-meeting-actions.ts +8 -0
  263. package/src/meeting/index.ts +1237 -254
  264. package/src/meeting/locusMediaRequest.ts +106 -6
  265. package/src/meeting/muteState.ts +10 -1
  266. package/src/meeting/request.ts +11 -0
  267. package/src/meeting/util.ts +53 -8
  268. package/src/meeting/voicea-meeting.ts +1 -1
  269. package/src/meeting-info/ai-docs/meeting-info-spec.md +261 -0
  270. package/src/meeting-info/meeting-info-v2.ts +11 -4
  271. package/src/meetings/ai-docs/meetings-spec.md +298 -0
  272. package/src/meetings/index.ts +242 -80
  273. package/src/meetings/meetings.types.ts +19 -0
  274. package/src/meetings/request.ts +43 -0
  275. package/src/meetings/util.ts +117 -4
  276. package/src/member/ai-docs/member-spec.md +196 -0
  277. package/src/member/index.ts +10 -0
  278. package/src/member/types.ts +1 -0
  279. package/src/member/util.ts +29 -0
  280. package/src/members/ai-docs/members-spec.md +256 -0
  281. package/src/members/index.ts +70 -7
  282. package/src/members/util.ts +12 -4
  283. package/src/metrics/ai-docs/metrics-spec.md +185 -0
  284. package/src/metrics/constants.ts +11 -0
  285. package/src/multistream/ai-docs/multistream-spec.md +295 -0
  286. package/src/multistream/codec/constants.ts +58 -0
  287. package/src/multistream/mediaRequestManager.ts +119 -28
  288. package/src/multistream/receiveSlot.ts +18 -0
  289. package/src/multistream/remoteMediaManager.ts +23 -1
  290. package/src/multistream/sendSlotManager.ts +112 -4
  291. package/src/personal-meeting-room/ai-docs/personal-meeting-room-spec.md +234 -0
  292. package/src/reachability/ai-docs/reachability-spec.md +261 -0
  293. package/src/reachability/clusterReachability.ts +3 -2
  294. package/src/reachability/index.ts +47 -16
  295. package/src/reachability/reachability.types.ts +11 -0
  296. package/src/reachability/util.ts +36 -0
  297. package/src/reactions/ai-docs/reactions-spec.md +198 -0
  298. package/src/reactions/reactions.type.ts +3 -0
  299. package/src/reconnection-manager/ai-docs/reconnection-manager-spec.md +272 -0
  300. package/src/recording-controller/ai-docs/recording-controller-spec.md +223 -0
  301. package/src/recording-controller/index.ts +1 -2
  302. package/src/roap/ai-docs/roap-spec.md +241 -0
  303. package/src/roap/turnDiscovery.ts +9 -1
  304. package/src/webinar/ai-docs/webinar-spec.md +243 -0
  305. package/src/webinar/index.ts +333 -73
  306. package/test/unit/spec/aiEnableRequest/index.ts +86 -0
  307. package/test/unit/spec/annotation/index.ts +214 -182
  308. package/test/unit/spec/breakouts/breakout.ts +9 -3
  309. package/test/unit/spec/breakouts/events.ts +120 -2
  310. package/test/unit/spec/breakouts/index.ts +336 -15
  311. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  312. package/test/unit/spec/common/wasm-loader.ts +171 -0
  313. package/test/unit/spec/controls-options-manager/index.js +244 -29
  314. package/test/unit/spec/controls-options-manager/util.js +165 -0
  315. package/test/unit/spec/e2ee/E2eeManager.ts +82 -0
  316. package/test/unit/spec/e2ee/E2eeSignaling.ts +172 -0
  317. package/test/unit/spec/e2ee/MediaEncryptionService.ts +43 -0
  318. package/test/unit/spec/e2ee/mls.ts +765 -0
  319. package/test/unit/spec/hashTree/hashTreeParser.ts +3126 -238
  320. package/test/unit/spec/hashTree/utils.ts +125 -1
  321. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +179 -1
  322. package/test/unit/spec/interceptors/locusRetry.ts +234 -5
  323. package/test/unit/spec/interpretation/index.ts +119 -4
  324. package/test/unit/spec/locus-info/controlsUtils.js +172 -57
  325. package/test/unit/spec/locus-info/index.js +1880 -136
  326. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  327. package/test/unit/spec/media/MediaConnectionAwaiter.ts +479 -17
  328. package/test/unit/spec/media/index.ts +92 -0
  329. package/test/unit/spec/media/properties.ts +26 -26
  330. package/test/unit/spec/meeting/in-meeting-actions.ts +4 -0
  331. package/test/unit/spec/meeting/index.js +3697 -501
  332. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  333. package/test/unit/spec/meeting/muteState.js +81 -0
  334. package/test/unit/spec/meeting/request.js +12 -0
  335. package/test/unit/spec/meeting/utils.js +206 -16
  336. package/test/unit/spec/meeting/voicea-meeting.ts +85 -1
  337. package/test/unit/spec/meeting-info/index.js +2 -3
  338. package/test/unit/spec/meeting-info/meetinginfov2.js +88 -11
  339. package/test/unit/spec/meetings/index.js +606 -53
  340. package/test/unit/spec/meetings/request.js +141 -0
  341. package/test/unit/spec/meetings/utils.js +402 -51
  342. package/test/unit/spec/member/index.js +7 -0
  343. package/test/unit/spec/member/util.js +89 -0
  344. package/test/unit/spec/members/index.js +216 -0
  345. package/test/unit/spec/members/request.js +37 -1
  346. package/test/unit/spec/members/utils.js +63 -0
  347. package/test/unit/spec/multistream/mediaRequestManager.ts +501 -37
  348. package/test/unit/spec/multistream/remoteMediaManager.ts +46 -0
  349. package/test/unit/spec/multistream/sendSlotManager.ts +165 -38
  350. package/test/unit/spec/reachability/index.ts +128 -46
  351. package/test/unit/spec/reachability/util.ts +31 -0
  352. package/test/unit/spec/recording-controller/index.js +9 -8
  353. package/test/unit/spec/roap/turnDiscovery.ts +20 -0
  354. package/test/unit/spec/webinar/index.ts +982 -328
@@ -30,10 +30,11 @@ import {
30
30
  NetworkQualityMonitor,
31
31
  StatsMonitor,
32
32
  StatsMonitorEventNames,
33
- InboundAudioIssueSubTypes,
33
+ MediaCodecMimeType,
34
34
  } from '@webex/internal-media-core';
35
35
 
36
- import {DataChannelTokenType} from '@webex/internal-plugin-llm';
36
+ import {DataChannelTokenType, type RegisterAndConnectTiming} from '@webex/internal-plugin-llm';
37
+ import type LLMChannel from '@webex/internal-plugin-llm';
37
38
 
38
39
  import {
39
40
  LocalStream,
@@ -50,6 +51,7 @@ import {
50
51
  EVENT_TRIGGERS as VOICEAEVENTS,
51
52
  TURN_ON_CAPTION_STATUS,
52
53
  type MeetingTranscriptPayload,
54
+ type VoiceaChannel,
53
55
  } from '@webex/internal-plugin-voicea';
54
56
 
55
57
  import {
@@ -57,6 +59,7 @@ import {
57
59
  isBrowserMediaError,
58
60
  isBrowserMediaErrorName,
59
61
  } from '@webex/internal-plugin-metrics/src/call-diagnostic/call-diagnostic-metrics.util';
62
+ import type {MetricEventMeetingJoinPhase} from '@webex/internal-plugin-metrics/src/metrics.types';
60
63
  import {CapabilityState, WebCapabilities} from '@webex/web-capabilities';
61
64
  import {processNewCaptions} from './voicea-meeting';
62
65
 
@@ -66,6 +69,7 @@ import {
66
69
  NoMediaEstablishedYetError,
67
70
  UserNotJoinedError,
68
71
  AddMediaFailed,
72
+ MediaConnectionTimedOutError,
69
73
  SdpResponseTimeoutError,
70
74
  } from '../common/errors/webex-errors';
71
75
 
@@ -76,6 +80,7 @@ import Roap, {type TurnDiscoveryResult, type TurnDiscoverySkipReason} from '../r
76
80
  import {type TurnServerInfo} from '../roap/types';
77
81
  import Media, {type BundlePolicy} from '../media';
78
82
  import MediaProperties from '../media/properties';
83
+ import {type FailureResult as MediaConnectionAwaiterFailureResult} from '../media/MediaConnectionAwaiter';
79
84
  import MeetingStateMachine from './state';
80
85
  import {createMuteState} from './muteState';
81
86
  import LocusInfo, {LocusLLMEvent} from '../locus-info';
@@ -153,6 +158,7 @@ import {
153
158
  Configuration as RemoteMediaManagerConfiguration,
154
159
  RemoteMediaManager,
155
160
  Event as RemoteMediaManagerEvent,
161
+ getRemoteMediaManagerConfigForLogging,
156
162
  } from '../multistream/remoteMediaManager';
157
163
  import {
158
164
  Reaction,
@@ -181,14 +187,15 @@ import JoinForbiddenError from '../common/errors/join-forbidden-error';
181
187
  import {ReachabilityMetrics} from '../reachability/reachability.types';
182
188
  import {SetStageOptions, SetStageVideoLayout, UnsetStageVideoLayout} from './request.type';
183
189
  import {Invitee} from './type';
184
- import {DataSet, Metadata} from '../hashTree/hashTreeParser';
185
- import {LocusDTO} from '../locus-info/types';
190
+ import {DataSet, HashTreeMessage, Metadata} from '../hashTree/hashTreeParser';
191
+ import {LocusDTO, LocusErrorCodes} from '../locus-info/types';
186
192
  import AIEnableRequest from '../aiEnableRequest';
187
193
 
188
194
  // default callback so we don't call an undefined function, but in practice it should never be used
189
195
  const DEFAULT_ICE_PHASE_CALLBACK = () => 'JOIN_MEETING_FINAL';
190
196
 
191
197
  const LLM_HEALTHCHECK_TIMER_MS = 3 * 60 * 1000;
198
+ const JOIN_WITH_MEDIA_RETRY_MAX_COUNT = 2;
192
199
 
193
200
  const logRequest = (request: any, {logText = ''}) => {
194
201
  LoggerProxy.logger.info(`${logText} - sending request`);
@@ -272,6 +279,7 @@ export type CallStateForMetrics = {
272
279
  userNameInput?: string;
273
280
  emailInput?: string;
274
281
  pstnCorrelationId?: string;
282
+ meetingJoinPhase?: MetricEventMeetingJoinPhase;
275
283
  };
276
284
 
277
285
  export const MEDIA_UPDATE_TYPE = {
@@ -568,6 +576,34 @@ type MediaReachabilityMetrics = ReachabilityMetrics & {
568
576
  * @memberof Meeting
569
577
  */
570
578
 
579
+ /**
580
+ * Stores an event so all events can be later retrieved via a console command for debugging.
581
+ * @param {string} type
582
+ * @param {Object} data
583
+ * @returns {void}
584
+ */
585
+ export function storeEventForDebugging(
586
+ type: string,
587
+ data: {
588
+ eventType: any;
589
+ stateElementsMessage?: HashTreeMessage;
590
+ }
591
+ ) {
592
+ if ((window as any)?.locusEvents) {
593
+ // only store non-heartbeat hash tree messages
594
+ if (
595
+ data.eventType === LOCUSEVENT.HASH_TREE_DATA_UPDATED &&
596
+ data.stateElementsMessage?.locusStateElements
597
+ ) {
598
+ (window as any).locusEvents.push({
599
+ ...data,
600
+ timestamp: new Date().toLocaleString(),
601
+ type,
602
+ });
603
+ }
604
+ }
605
+ }
606
+
571
607
  /**
572
608
  * @description Meeting is the crux of the plugin
573
609
  * @export
@@ -583,7 +619,7 @@ export default class Meeting extends StatelessWebexPlugin {
583
619
  webinar: any;
584
620
  conversationUrl: string;
585
621
  callStateForMetrics: CallStateForMetrics;
586
- destination: string;
622
+ destination: string | LocusDTO;
587
623
  destinationType: DESTINATION_TYPE;
588
624
  deviceUrl: string;
589
625
  hostId: string;
@@ -622,6 +658,8 @@ export default class Meeting extends StatelessWebexPlugin {
622
658
  floorGrantPending: boolean;
623
659
  hasJoinedOnce: boolean;
624
660
  hasWebsocketConnected: boolean;
661
+ private mercuryOnlineHandler?: () => void;
662
+ private mercuryOfflineHandler?: () => void;
625
663
  inMeetingActions: InMeetingActions;
626
664
  isLocalShareLive: boolean;
627
665
  isRoapInProgress: boolean;
@@ -633,6 +671,7 @@ export default class Meeting extends StatelessWebexPlugin {
633
671
  joinedWith?: any;
634
672
  selfId?: string;
635
673
  roles: any[];
674
+ canNotViewTheParticipantList?: boolean;
636
675
  // ... there is more ... see SelfUtils.parse()
637
676
  // end of the group
638
677
  locusMediaRequest?: LocusMediaRequest;
@@ -703,13 +742,36 @@ export default class Meeting extends StatelessWebexPlugin {
703
742
  turnDiscoverySkippedReason: TurnDiscoverySkipReason;
704
743
  turnServerUsed: boolean;
705
744
  areVoiceaEventsSetup = false;
745
+ /**
746
+ * Returns the initial transcription object shape.
747
+ * Used by constructor and reset paths to ensure consistent initialization.
748
+ * @private
749
+ * @returns {Transcription}
750
+ */
751
+ private getInitialTranscription(): Transcription {
752
+ return {
753
+ captions: [],
754
+ isListening: false,
755
+ commandText: '',
756
+ languageOptions: {currentSpokenLanguage: 'en'},
757
+ showCaptionBox: false,
758
+ transcribingRequestStatus: 'INACTIVE',
759
+ isCaptioning: false,
760
+ interimCaptions: {} as Map<string, CaptionData>,
761
+ speakerProxy: {} as Map<string, any>,
762
+ } as Transcription;
763
+ }
764
+
706
765
  isMoveToInProgress = false;
707
766
  registrationIdStatus: string;
708
767
  brbState: BrbState;
768
+ private emittedBreakoutJoinResponseMoveIds: Set<string> = new Set();
769
+ private promisesWaitingForPropUpdate: Record<string, Defer> = {};
709
770
 
710
771
  voiceaListenerCallbacks: object = {
711
772
  [VOICEAEVENTS.VOICEA_ANNOUNCEMENT]: (payload: Transcription['languageOptions']) => {
712
773
  this.transcription.languageOptions = payload;
774
+ const eventPayload = {...payload};
713
775
 
714
776
  LoggerProxy.logger.debug(
715
777
  `${EventsUtil.getScopeLog({
@@ -719,11 +781,11 @@ export default class Meeting extends StatelessWebexPlugin {
719
781
  );
720
782
 
721
783
  if (this.getCurUserType() !== 'host') {
722
- delete payload.spokenLanguages;
784
+ delete eventPayload.spokenLanguages;
723
785
  }
724
786
 
725
787
  // @ts-ignore
726
- this.trigger(EVENT_TRIGGERS.MEETING_STARTED_RECEIVING_TRANSCRIPTION, payload);
788
+ this.trigger(EVENT_TRIGGERS.MEETING_STARTED_RECEIVING_TRANSCRIPTION, eventPayload);
727
789
  },
728
790
  [VOICEAEVENTS.CAPTIONS_TURNED_ON]: () => {
729
791
  this.transcription.status = TURN_ON_CAPTION_STATUS.ENABLED;
@@ -755,13 +817,20 @@ export default class Meeting extends StatelessWebexPlugin {
755
817
  private addMediaData: {
756
818
  retriedWithTurnServer: boolean;
757
819
  icePhaseCallback: () => string;
820
+ iceTransportPolicy?: RTCIceTransportPolicy;
758
821
  };
759
822
 
760
823
  private sendSlotManager: SendSlotManager = new SendSlotManager(LoggerProxy);
761
824
  private deferSDPAnswer?: Defer; // used for waiting for a response
762
825
  private sdpResponseTimer?: ReturnType<typeof setTimeout>;
763
826
  private hasMediaConnectionConnectedAtLeastOnce: boolean;
764
- private joinWithMediaRetryInfo?: {isRetry: boolean; prevJoinResponse?: any};
827
+ private joinWithMediaRetryInfo: {
828
+ retryCount: number;
829
+ prevJoinResponse?: any;
830
+ firstError?: Error;
831
+ prevError?: Error;
832
+ };
833
+
765
834
  private connectionStateHandler?: ConnectionStateHandler;
766
835
  private iceCandidateErrors: Map<string, number>;
767
836
  private iceCandidatesCount: number;
@@ -771,6 +840,22 @@ export default class Meeting extends StatelessWebexPlugin {
771
840
  private mediaServerIp: string;
772
841
  private llmHealthCheckTimer?: ReturnType<typeof setTimeout>;
773
842
 
843
+ /**
844
+ * The LLM channel owned by this meeting for datachannel communication.
845
+ * Created in updateLLMConnection, cleaned up in cleanupLLMConneciton.
846
+ */
847
+ private llmChannel?: LLMChannel;
848
+
849
+ /**
850
+ * The Voicea channel for transcription/captions, bound to this meeting's LLM channel.
851
+ */
852
+ voiceaChannel?: VoiceaChannel;
853
+
854
+ /**
855
+ * Pending datachannel token saved from join response, used when creating the LLM channel.
856
+ */
857
+ private _pendingDatachannelToken?: string;
858
+
774
859
  /**
775
860
  * @param {Object} attrs
776
861
  * @param {Object} options
@@ -906,7 +991,7 @@ export default class Meeting extends StatelessWebexPlugin {
906
991
  this.simultaneousInterpretation = new SimultaneousInterpretation({}, {parent: this.webex});
907
992
 
908
993
  // @ts-ignore
909
- this.aiEnableRequest = new AIEnableRequest({}, {parent: this.webex});
994
+ this.aiEnableRequest = new AIEnableRequest({locusUrl: this.locusUrl}, {parent: this.webex});
910
995
 
911
996
  /**
912
997
  * @instance
@@ -924,6 +1009,16 @@ export default class Meeting extends StatelessWebexPlugin {
924
1009
  */
925
1010
  // @ts-ignore
926
1011
  this.webinar = new Webinar({meetingId: this.id}, {parent: this.webex});
1012
+ /**
1013
+ * VoiceaChannel for transcription/captions. Created without llmChannel;
1014
+ * switchLLMChannel() is called in updateLLMConnection() when LLM connects.
1015
+ * @instance
1016
+ * @type {VoiceaChannel}
1017
+ * @public
1018
+ * @memberof Meeting
1019
+ */
1020
+ // @ts-ignore - Fix type
1021
+ this.voiceaChannel = this.webex.internal.voicea.createChannel();
927
1022
  /**
928
1023
  * helper class for managing receive slots (for multistream media connections)
929
1024
  */
@@ -937,6 +1032,7 @@ export default class Meeting extends StatelessWebexPlugin {
937
1032
  },
938
1033
  (csi: CSI) => (this.members.findMemberByCsi(csi) as any)?.id
939
1034
  );
1035
+
940
1036
  /**
941
1037
  * Object containing helper classes for managing media requests for audio/video/screenshare (for multistream media connections)
942
1038
  * All multistream media requests sent out for this meeting have to go through them.
@@ -956,6 +1052,7 @@ export default class Meeting extends StatelessWebexPlugin {
956
1052
  mediaRequests
957
1053
  );
958
1054
  },
1055
+ this.getIngressPayloadTypeCallback.bind(this),
959
1056
  {
960
1057
  // @ts-ignore - config coming from registerPlugin
961
1058
  degradationPreferences: this.config.degradationPreferences,
@@ -977,6 +1074,7 @@ export default class Meeting extends StatelessWebexPlugin {
977
1074
  mediaRequests
978
1075
  );
979
1076
  },
1077
+ this.getIngressPayloadTypeCallback.bind(this),
980
1078
  {
981
1079
  // @ts-ignore - config coming from registerPlugin
982
1080
  degradationPreferences: this.config.degradationPreferences,
@@ -998,6 +1096,7 @@ export default class Meeting extends StatelessWebexPlugin {
998
1096
  mediaRequests
999
1097
  );
1000
1098
  },
1099
+ this.getIngressPayloadTypeCallback.bind(this),
1001
1100
  {
1002
1101
  // @ts-ignore - config coming from registerPlugin
1003
1102
  degradationPreferences: this.config.degradationPreferences,
@@ -1019,11 +1118,14 @@ export default class Meeting extends StatelessWebexPlugin {
1019
1118
  mediaRequests
1020
1119
  );
1021
1120
  },
1121
+ this.getIngressPayloadTypeCallback.bind(this),
1022
1122
  {
1023
1123
  // @ts-ignore - config coming from registerPlugin
1024
1124
  degradationPreferences: this.config.degradationPreferences,
1025
1125
  kind: 'video',
1026
1126
  trimRequestsToNumOfSources: false,
1127
+ // @ts-ignore - config coming from registerPlugin
1128
+ enableAv1: this.config.enableAv1SlidesSupport,
1027
1129
  }
1028
1130
  ),
1029
1131
  };
@@ -1343,7 +1445,48 @@ export default class Meeting extends StatelessWebexPlugin {
1343
1445
  * @memberof Meeting
1344
1446
  */
1345
1447
  // @ts-ignore - Fix type
1346
- this.locusInfo = new LocusInfo(this.updateMeetingObject.bind(this), this.webex, this.id);
1448
+ this.locusInfo = new LocusInfo(
1449
+ {
1450
+ updateMeeting: this.updateMeetingObject.bind(this),
1451
+ syncLatencyTracker: {
1452
+ // Compute/store latency timestamps live on CallDiagnosticLatencies, while
1453
+ // submitting the client.locus.sync.complete CA event is owned by the metrics
1454
+ // facade. Wire each method to the layer that owns that responsibility.
1455
+ saveLatency: (...args) =>
1456
+ // @ts-ignore
1457
+ this.webex.internal.newMetrics.callDiagnosticLatencies.saveLatency(...args),
1458
+ saveTimestamp: (saveTimestampOptions: {
1459
+ key: string;
1460
+ value?: number;
1461
+ options: {meetingId: string; dataSetName: string; trackingId?: string};
1462
+ }) => {
1463
+ // @ts-ignore
1464
+ this.webex.internal.newMetrics.callDiagnosticLatencies.saveTimestamp(
1465
+ saveTimestampOptions
1466
+ );
1467
+
1468
+ // The /sync response is one of the two milestones (the other is the LLM message) that
1469
+ // complete client.locus.sync.complete. Try to complete now: the metric is emitted only
1470
+ // once both the LLM message and the /sync response have arrived (either can come first).
1471
+ if (
1472
+ saveTimestampOptions.key === 'internal.client.locus.sync.response' &&
1473
+ saveTimestampOptions.options?.trackingId
1474
+ ) {
1475
+ this.tryCompleteLocusSyncLatency(
1476
+ saveTimestampOptions.options.meetingId,
1477
+ saveTimestampOptions.options.trackingId
1478
+ );
1479
+ }
1480
+ },
1481
+ clearLocusSyncLatency: (...args) =>
1482
+ // @ts-ignore
1483
+ this.webex.internal.newMetrics.callDiagnosticLatencies.clearLocusSyncLatency(...args),
1484
+ },
1485
+ },
1486
+ // @ts-ignore
1487
+ this.webex,
1488
+ this.id
1489
+ );
1347
1490
 
1348
1491
  // We had to add listeners first before setting up the locus instance
1349
1492
  /**
@@ -1399,17 +1542,7 @@ export default class Meeting extends StatelessWebexPlugin {
1399
1542
  * @private
1400
1543
  * @memberof Meeting
1401
1544
  */
1402
- this.transcription = {
1403
- captions: [],
1404
- isListening: false,
1405
- commandText: '',
1406
- languageOptions: {currentSpokenLanguage: 'en'},
1407
- showCaptionBox: false,
1408
- transcribingRequestStatus: 'INACTIVE',
1409
- isCaptioning: false,
1410
- interimCaptions: {} as Map<string, CaptionData>,
1411
- speakerProxy: {} as Map<string, any>,
1412
- } as Transcription;
1545
+ this.transcription = this.getInitialTranscription();
1413
1546
 
1414
1547
  /**
1415
1548
  * Password status. If it's PASSWORD_STATUS.REQUIRED then verifyPassword() needs to be called
@@ -1528,6 +1661,8 @@ export default class Meeting extends StatelessWebexPlugin {
1528
1661
  this.controlsOptionsManager = new ControlsOptionsManager(this.meetingRequest, {
1529
1662
  locusUrl: this.locusInfo?.url,
1530
1663
  displayHints: [],
1664
+ getControls: () => this.locusInfo?.controls,
1665
+ isWebinar: () => this.locusInfo?.info?.isWebinar,
1531
1666
  });
1532
1667
 
1533
1668
  this.setUpLocusInfoListeners();
@@ -1626,11 +1761,11 @@ export default class Meeting extends StatelessWebexPlugin {
1626
1761
  /**
1627
1762
  * Information needed for a retry of a call to joinWithMedia
1628
1763
  * @instance
1629
- * @type {{isRetry: boolean; prevJoinResponse?: any}}
1764
+ * @type {{retryCount: number; prevJoinResponse?: any}}
1630
1765
  * @private
1631
1766
  * @memberof Meeting
1632
1767
  */
1633
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
1768
+ this.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
1634
1769
 
1635
1770
  /**
1636
1771
  * Connection state handler
@@ -1684,6 +1819,37 @@ export default class Meeting extends StatelessWebexPlugin {
1684
1819
  this.mediaServerIp = undefined;
1685
1820
  }
1686
1821
 
1822
+ /**
1823
+ * Get the ingress payload type for a given media type and codec mime type
1824
+ * @param {MediaType} mediaType - The media type
1825
+ * @param {MediaCodecMimeType} codecMimeType - The codec mime type
1826
+ * @returns {number | undefined} - The ingress payload type
1827
+ * @private
1828
+ * @memberof Meeting
1829
+ */
1830
+ private getIngressPayloadTypeCallback(
1831
+ mediaType: MediaType,
1832
+ codecMimeType: MediaCodecMimeType
1833
+ ): number | undefined {
1834
+ if (this.isMultistream) {
1835
+ try {
1836
+ return this.mediaProperties.webrtcMediaConnection.getIngressPayloadType(
1837
+ mediaType,
1838
+ codecMimeType
1839
+ );
1840
+ } catch (error) {
1841
+ LoggerProxy.logger.info(
1842
+ `Meeting:index#mediaRequestManager --> failed to get ingress payload type for mediaType=${mediaType}, codecMimeType=${codecMimeType}`,
1843
+ error
1844
+ );
1845
+
1846
+ return undefined;
1847
+ }
1848
+ }
1849
+
1850
+ return undefined;
1851
+ }
1852
+
1687
1853
  /**
1688
1854
  * Temporary func to return webex object,
1689
1855
  * in order to access internal plugin metrics
@@ -1964,7 +2130,7 @@ export default class Meeting extends StatelessWebexPlugin {
1964
2130
  this.config.installedOrgID,
1965
2131
  this.locusId,
1966
2132
  extraParams,
1967
- {meetingId: this.id, sendCAevents},
2133
+ {meetingId: this.id, sendCAevents, correlationId: this.correlationId},
1968
2134
  registrationId,
1969
2135
  null,
1970
2136
  classificationId
@@ -2296,6 +2462,89 @@ export default class Meeting extends StatelessWebexPlugin {
2296
2462
  });
2297
2463
  }
2298
2464
 
2465
+ /**
2466
+ * Handles the LLM state-update message that resulted from a Locus /sync. Records the LLM arrival
2467
+ * time (the milestone that gates client.locus.sync.complete - the metric is emitted only for LLM
2468
+ * flows) and then tries to complete the metric.
2469
+ * @param {string} meetingId meeting id
2470
+ * @param {string} trackingId sync tracking id echoed back on the LLM message
2471
+ * @returns {void}
2472
+ * @private
2473
+ * @memberof Meeting
2474
+ */
2475
+ private onLocusSyncLlmMessage(meetingId: string, trackingId: string) {
2476
+ // @ts-ignore
2477
+ this.webex.internal.newMetrics.callDiagnosticLatencies.recordLocusSyncMessageReceived(
2478
+ meetingId,
2479
+ trackingId
2480
+ );
2481
+
2482
+ this.tryCompleteLocusSyncLatency(meetingId, trackingId);
2483
+ }
2484
+
2485
+ /**
2486
+ * Attempts to complete the Locus sync latency metric and emit client.locus.sync.complete. The
2487
+ * metric is emitted only once BOTH the /sync response and the resulting LLM message have arrived
2488
+ * (in either order); until then the record is kept so the missing milestone can still land. Both
2489
+ * trigger points (the LLM message handler and the /sync response timestamp) call this, so the
2490
+ * metric fires as soon as the second milestone is in.
2491
+ * @param {string} meetingId meeting id
2492
+ * @param {string} trackingId sync tracking id used to match the pending record
2493
+ * @returns {void}
2494
+ * @private
2495
+ * @memberof Meeting
2496
+ */
2497
+ private tryCompleteLocusSyncLatency(meetingId: string, trackingId: string) {
2498
+ const completed =
2499
+ // @ts-ignore
2500
+ this.webex.internal.newMetrics.callDiagnosticLatencies.completeLocusSyncLatency(
2501
+ meetingId,
2502
+ trackingId
2503
+ );
2504
+
2505
+ if (completed) {
2506
+ this.emitLocusSyncCompleteMetric(meetingId, completed);
2507
+ }
2508
+ }
2509
+
2510
+ /**
2511
+ * Submits the client.locus.sync.complete Call Analyzer event for a completed Locus sync latency
2512
+ * measurement.
2513
+ * @param {string} meetingId meeting id
2514
+ * @param {object} completed completed sync latency payload from the metrics plugin
2515
+ * @returns {void}
2516
+ * @private
2517
+ * @memberof Meeting
2518
+ */
2519
+ private emitLocusSyncCompleteMetric(
2520
+ meetingId: string,
2521
+ completed: {dataSet: string; syncLatency: object}
2522
+ ) {
2523
+ // @ts-ignore
2524
+ const llmWebsocketUrl = this.webex.internal.llm?.getWebSocketUrl?.() || undefined;
2525
+
2526
+ // Per the LLM sync-latency spec, the event carries the LLM websocket url identifier,
2527
+ // the llmInfo.dataSet (main, atd-active or atd-unmuted) and the syncLatency block.
2528
+ const clientEvent = {
2529
+ name: 'client.locus.sync.complete',
2530
+ payload: {
2531
+ identifiers: {
2532
+ llmWebsocketUrl,
2533
+ },
2534
+ llmInfo: {
2535
+ dataSet: completed.dataSet,
2536
+ },
2537
+ syncLatency: completed.syncLatency,
2538
+ },
2539
+ options: {
2540
+ meetingId,
2541
+ },
2542
+ };
2543
+
2544
+ // @ts-ignore
2545
+ this.webex.internal.newMetrics.submitClientEvent(clientEvent);
2546
+ }
2547
+
2299
2548
  /**
2300
2549
  * Proxy function for all the listener set ups
2301
2550
  * @returns {undefined}
@@ -2455,29 +2704,28 @@ export default class Meeting extends StatelessWebexPlugin {
2455
2704
  * @memberof Meeting
2456
2705
  */
2457
2706
  private setUpVoiceaListeners() {
2458
- // @ts-ignore
2459
- this.webex.internal.voicea.listenToEvents();
2707
+ if (!this.voiceaChannel) {
2708
+ LoggerProxy.logger.warn('Meeting:index#setUpVoiceaListeners --> voiceaChannel not available');
2460
2709
 
2461
- // @ts-ignore
2462
- this.webex.internal.voicea.on(
2710
+ return;
2711
+ }
2712
+
2713
+ this.voiceaChannel.on(
2463
2714
  VOICEAEVENTS.VOICEA_ANNOUNCEMENT,
2464
2715
  this.voiceaListenerCallbacks[VOICEAEVENTS.VOICEA_ANNOUNCEMENT]
2465
2716
  );
2466
2717
 
2467
- // @ts-ignore
2468
- this.webex.internal.voicea.on(
2718
+ this.voiceaChannel.on(
2469
2719
  VOICEAEVENTS.CAPTIONS_TURNED_ON,
2470
2720
  this.voiceaListenerCallbacks[VOICEAEVENTS.CAPTIONS_TURNED_ON]
2471
2721
  );
2472
2722
 
2473
- // @ts-ignore
2474
- this.webex.internal.voicea.on(
2723
+ this.voiceaChannel.on(
2475
2724
  VOICEAEVENTS.EVA_COMMAND,
2476
2725
  this.voiceaListenerCallbacks[VOICEAEVENTS.EVA_COMMAND]
2477
2726
  );
2478
2727
 
2479
- // @ts-ignore
2480
- this.webex.internal.voicea.on(
2728
+ this.voiceaChannel.on(
2481
2729
  VOICEAEVENTS.NEW_CAPTION,
2482
2730
  this.voiceaListenerCallbacks[VOICEAEVENTS.NEW_CAPTION]
2483
2731
  );
@@ -2760,7 +3008,7 @@ export default class Meeting extends StatelessWebexPlugin {
2760
3008
  private setupLocusControlsListener() {
2761
3009
  this.locusInfo.on(
2762
3010
  LOCUSINFO.EVENTS.CONTROLS_RECORDING_UPDATED,
2763
- ({state, modifiedBy, lastModified}) => {
3011
+ ({state, modifiedBy, lastModified, modifiedByServiceAppName, modifiedByServiceAppId}) => {
2764
3012
  let event;
2765
3013
 
2766
3014
  switch (state) {
@@ -2786,6 +3034,8 @@ export default class Meeting extends StatelessWebexPlugin {
2786
3034
  state: state === RECORDING_STATE.RESUMED ? RECORDING_STATE.RECORDING : state,
2787
3035
  modifiedBy,
2788
3036
  lastModified,
3037
+ modifiedByServiceAppName,
3038
+ modifiedByServiceAppId,
2789
3039
  };
2790
3040
  Trigger.trigger(
2791
3041
  this,
@@ -2820,18 +3070,22 @@ export default class Meeting extends StatelessWebexPlugin {
2820
3070
  // user need to be joined to start the llm and receive transcription
2821
3071
  if (this.isJoined()) {
2822
3072
  // @ts-ignore - config coming from registerPlugin
2823
- if (transcribing && !this.transcription) {
2824
- this.startTranscription();
2825
- } else if (!transcribing && this.transcription) {
2826
- Trigger.trigger(
2827
- this,
2828
- {
2829
- file: 'meeting/index',
2830
- function: 'setupLocusControlsListener',
2831
- },
2832
- EVENT_TRIGGERS.MEETING_STOPPED_RECEIVING_TRANSCRIPTION,
2833
- {caption, transcribing}
2834
- );
3073
+ if (transcribing && !this.areVoiceaEventsSetup) {
3074
+ if (this.voiceaChannel?.isLLMConnected()) {
3075
+ this.startTranscription();
3076
+ }
3077
+ } else if (!transcribing) {
3078
+ if (this.areVoiceaEventsSetup) {
3079
+ Trigger.trigger(
3080
+ this,
3081
+ {
3082
+ file: 'meeting/index',
3083
+ function: 'setupLocusControlsListener',
3084
+ },
3085
+ EVENT_TRIGGERS.MEETING_STOPPED_RECEIVING_TRANSCRIPTION,
3086
+ {caption, transcribing}
3087
+ );
3088
+ }
2835
3089
  }
2836
3090
  }
2837
3091
  }
@@ -2844,8 +3098,7 @@ export default class Meeting extends StatelessWebexPlugin {
2844
3098
  if (this.transcription?.languageOptions) {
2845
3099
  this.transcription.languageOptions.currentSpokenLanguage = spokenLanguage;
2846
3100
  }
2847
- // @ts-ignore
2848
- this.webex.internal.voicea.onSpokenLanguageUpdate(spokenLanguage, this.id);
3101
+ this.voiceaChannel?.onSpokenLanguageUpdate(spokenLanguage, this.id);
2849
3102
 
2850
3103
  Trigger.trigger(
2851
3104
  this,
@@ -2874,8 +3127,7 @@ export default class Meeting extends StatelessWebexPlugin {
2874
3127
 
2875
3128
  this.locusInfo.on(LOCUSINFO.EVENTS.CONTROLS_MEETING_HESIOD_LLM_ID_UPDATED, ({hesiodLlmId}) => {
2876
3129
  if (hesiodLlmId) {
2877
- // @ts-ignore
2878
- this.webex.internal.voicea.onCaptionServiceIdUpdate(hesiodLlmId);
3130
+ this.voiceaChannel?.onCaptionServiceIdUpdate(hesiodLlmId);
2879
3131
  }
2880
3132
  });
2881
3133
 
@@ -3184,7 +3436,7 @@ export default class Meeting extends StatelessWebexPlugin {
3184
3436
  }
3185
3437
 
3186
3438
  LoggerProxy.logger.info(
3187
- `Meeting:index#setUpLocusInfoMediaInactiveListener --> this.shareStatus=${this.shareStatus} newShareStatus=${newShareStatus}`
3439
+ `Meeting:index#setUpLocusMediaSharesListener --> this.shareStatus=${this.shareStatus} newShareStatus=${newShareStatus}`
3188
3440
  );
3189
3441
 
3190
3442
  if (newShareStatus !== this.shareStatus) {
@@ -3430,13 +3682,12 @@ export default class Meeting extends StatelessWebexPlugin {
3430
3682
  this.breakouts.locusUrlUpdate(url);
3431
3683
  this.simultaneousInterpretation.locusUrlUpdate(url);
3432
3684
  this.annotation.locusUrlUpdate(url);
3685
+ this.aiEnableRequest.locusUrlUpdate(url);
3433
3686
  this.locusUrl = url;
3434
3687
  this.locusId = this.locusUrl?.split('/').pop();
3435
3688
  this.recordingController.setLocusUrl(this.locusUrl);
3436
3689
  this.controlsOptionsManager.setLocusUrl(this.locusUrl, !!isMainLocus);
3437
3690
  this.webinar.locusUrlUpdate(url);
3438
- // @ts-ignore
3439
- this.webex.internal.llm.setRefreshHandler(() => this.refreshDataChannelToken());
3440
3691
 
3441
3692
  Trigger.trigger(
3442
3693
  this,
@@ -3731,6 +3982,16 @@ export default class Meeting extends StatelessWebexPlugin {
3731
3982
  });
3732
3983
  }
3733
3984
  this.rtcMetrics?.sendNextMetrics();
3985
+
3986
+ try {
3987
+ await this.ensureDefaultDatachannelTokenAfterAdmit();
3988
+ } catch (error) {
3989
+ LoggerProxy.logger.warn(
3990
+ `Meeting:index#setUpLocusInfoSelfListener --> failed post-admit token prefetch flow: ${
3991
+ error?.message || String(error)
3992
+ }`
3993
+ );
3994
+ }
3734
3995
  this.updateLLMConnection();
3735
3996
  });
3736
3997
 
@@ -3775,6 +4036,9 @@ export default class Meeting extends StatelessWebexPlugin {
3775
4036
  });
3776
4037
 
3777
4038
  this.locusInfo.on(LOCUSINFO.EVENTS.SELF_CANNOT_VIEW_PARTICIPANT_LIST_CHANGE, (payload) => {
4039
+ // canViewTheParticipantList meeting action depends on this value, so we need to update meeting actions
4040
+ this.updateMeetingActions();
4041
+
3778
4042
  Trigger.trigger(
3779
4043
  this,
3780
4044
  {
@@ -3969,7 +4233,14 @@ export default class Meeting extends StatelessWebexPlugin {
3969
4233
  // is not changed by any delta event
3970
4234
  if (object && Object.keys(object).length) {
3971
4235
  Object.keys(object).forEach((key) => {
4236
+ const previousValue = this[key];
4237
+
3972
4238
  this[key] = object[key];
4239
+
4240
+ if (this.promisesWaitingForPropUpdate[key] && previousValue !== object[key]) {
4241
+ this.promisesWaitingForPropUpdate[key].resolve();
4242
+ delete this.promisesWaitingForPropUpdate[key];
4243
+ }
3973
4244
  });
3974
4245
  }
3975
4246
  }
@@ -4107,7 +4378,12 @@ export default class Meeting extends StatelessWebexPlugin {
4107
4378
  }
4108
4379
 
4109
4380
  /**
4110
- * Transfer the moderator role to another eligible member
4381
+ * Transfer the moderator role to another eligible member.
4382
+ *
4383
+ * If the target member is currently joined in the current session, the request is
4384
+ * sent against the current locus. Otherwise, we search the breakout sessions and,
4385
+ * when the member is found in one, we send the request against that breakout
4386
+ * session's locus url instead.
4111
4387
  * @param {String} memberId
4112
4388
  * @param {Boolean} moderator
4113
4389
  * @returns {Promise} see #members.transferHostToMember
@@ -4115,7 +4391,21 @@ export default class Meeting extends StatelessWebexPlugin {
4115
4391
  * @memberof Meeting
4116
4392
  */
4117
4393
  public transfer(memberId: string, moderator = true) {
4118
- return this.members.transferHostToMember(memberId, moderator);
4394
+ const targetMember = this.members.membersCollection.get(memberId);
4395
+
4396
+ if (targetMember?.isInMeeting) {
4397
+ return this.members.transferHostToMember(memberId, moderator);
4398
+ }
4399
+
4400
+ const breakout = this.breakouts?.breakouts?.models?.find((bo: any) => {
4401
+ const breakoutMember = bo.members?.membersCollection?.get(memberId);
4402
+
4403
+ return breakoutMember?.isInMeeting;
4404
+ });
4405
+
4406
+ const breakoutLocusUrl = breakout?.breakoutRosterLocus?.url;
4407
+
4408
+ return this.members.transferHostToMember(memberId, moderator, breakoutLocusUrl);
4119
4409
  }
4120
4410
 
4121
4411
  /**
@@ -4573,6 +4863,13 @@ export default class Meeting extends StatelessWebexPlugin {
4573
4863
  ),
4574
4864
  isAttendeeRequestAiAssistantDeclinedAll:
4575
4865
  MeetingUtil.attendeeRequestAiAssistantDeclinedAll(this.userDisplayHints),
4866
+ isAnonymizeDisplayNamesEnabled: MeetingUtil.isAnonymizeDisplayNamesEnabled(
4867
+ this.userDisplayHints
4868
+ ),
4869
+ canViewTheParticipantList: MeetingUtil.canViewTheParticipantList(
4870
+ this.userDisplayHints,
4871
+ this.canNotViewTheParticipantList ?? false
4872
+ ),
4576
4873
  }) || changed;
4577
4874
  }
4578
4875
  if (changed) {
@@ -4621,6 +4918,34 @@ export default class Meeting extends StatelessWebexPlugin {
4621
4918
  this.sipUri = sipUri;
4622
4919
  }
4623
4920
 
4921
+ /**
4922
+ * After initial locus setup, refreshes destination with synced locus data and optionally
4923
+ * performs deferred meeting info fetch when initial locus was incomplete.
4924
+ * @param {LocusDTO} locus
4925
+ * @returns {void}
4926
+ */
4927
+ public async finalizeMeetingAfterInitialLocusSetup(locus: LocusDTO): Promise<void> {
4928
+ if (locus && this?.destinationType === DESTINATION_TYPE.LOCUS_ID) {
4929
+ // destination is initialized from the initial locus snapshot in constructor,
4930
+ // so refresh it after locus sync to avoid stale partial hash-tree data.
4931
+ this.destination = locus;
4932
+ }
4933
+ if (
4934
+ (!this.meetingInfo || isEmpty(this.meetingInfo)) &&
4935
+ (this.destination as LocusDTO)?.info &&
4936
+ !this.fetchMeetingInfoTimeoutId &&
4937
+ !MeetingsUtil.isOneOnOneCall(locus)
4938
+ ) {
4939
+ try {
4940
+ await this.fetchMeetingInfo({});
4941
+ } catch (error: any) {
4942
+ LoggerProxy.logger.info(
4943
+ `Meeting:index#finalizeMeetingAfterInitialLocusSetup --> deferred fetchMeetingInfo failed: ${error.message}`
4944
+ );
4945
+ }
4946
+ }
4947
+ }
4948
+
4624
4949
  /**
4625
4950
  * Set the locus info the class instance. Should be called with the parsed locus
4626
4951
  * we got in the join response.
@@ -5092,8 +5417,7 @@ export default class Meeting extends StatelessWebexPlugin {
5092
5417
  public setMercuryListener() {
5093
5418
  // Client will have a socket manager and handle reconnecting to mercury, when we reconnect to mercury
5094
5419
  // if the meeting has active peer connections, it should try to reconnect.
5095
- // @ts-ignore
5096
- this.webex.internal.mercury.on(ONLINE, () => {
5420
+ this.mercuryOnlineHandler = () => {
5097
5421
  LoggerProxy.logger.info('Meeting:index#setMercuryListener --> Web socket online');
5098
5422
 
5099
5423
  // Only send restore event when it was disconnected before and for connected later
@@ -5103,15 +5427,47 @@ export default class Meeting extends StatelessWebexPlugin {
5103
5427
  });
5104
5428
  }
5105
5429
  this.hasWebsocketConnected = true;
5106
- });
5430
+ };
5107
5431
 
5108
- // @ts-ignore
5109
- this.webex.internal.mercury.on(OFFLINE, () => {
5432
+ this.mercuryOfflineHandler = () => {
5110
5433
  LoggerProxy.logger.error('Meeting:index#setMercuryListener --> Web socket offline');
5111
5434
  Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.MERCURY_CONNECTION_FAILURE, {
5112
5435
  correlation_id: this.correlationId,
5113
5436
  });
5114
- });
5437
+ };
5438
+
5439
+ // @ts-ignore
5440
+ this.webex.internal.mercury.on(ONLINE, this.mercuryOnlineHandler);
5441
+ // @ts-ignore
5442
+ this.webex.internal.mercury.on(OFFLINE, this.mercuryOfflineHandler);
5443
+ }
5444
+
5445
+ /**
5446
+ * Removes this meeting's Mercury ONLINE/OFFLINE event listeners registered
5447
+ * by setMercuryListener(). Must be called before Locus /leave to avoid
5448
+ * unnecessary syncs/metrics triggered by events received while leaving
5449
+ * (per Locus team recommendation).
5450
+ *
5451
+ * Mercury is a process-wide singleton shared with other plugins, so we
5452
+ * pass the bound handler refs to .off() to avoid clearing every listener
5453
+ * for ONLINE/OFFLINE on the shared emitter.
5454
+ *
5455
+ * Idempotent: subsequent calls are no-ops because the handler refs are
5456
+ * cleared after detaching.
5457
+ * @private
5458
+ * @returns {void}
5459
+ */
5460
+ private stopListeningForMercuryEvents() {
5461
+ if (this.mercuryOnlineHandler) {
5462
+ // @ts-ignore
5463
+ this.webex.internal.mercury.off(ONLINE, this.mercuryOnlineHandler);
5464
+ this.mercuryOnlineHandler = undefined;
5465
+ }
5466
+ if (this.mercuryOfflineHandler) {
5467
+ // @ts-ignore
5468
+ this.webex.internal.mercury.off(OFFLINE, this.mercuryOfflineHandler);
5469
+ this.mercuryOfflineHandler = undefined;
5470
+ }
5115
5471
  }
5116
5472
 
5117
5473
  /**
@@ -5135,9 +5491,14 @@ export default class Meeting extends StatelessWebexPlugin {
5135
5491
  );
5136
5492
 
5137
5493
  this.receiveSlotManager.reset();
5494
+
5495
+ // Unpublish/reset send slots while the connection is still open, so each slot's
5496
+ // internal "stop sending" negotiation (and its stream-listener detachment) completes
5497
+ // cleanly instead of racing the connection close below.
5498
+ this.sendSlotManager.reset();
5499
+
5138
5500
  this.mediaProperties.webrtcMediaConnection.close();
5139
5501
  this.mediaProperties.unsetPeerConnection();
5140
- this.sendSlotManager.reset();
5141
5502
  this.setNetworkStatus(undefined);
5142
5503
  }
5143
5504
 
@@ -5422,7 +5783,7 @@ export default class Meeting extends StatelessWebexPlugin {
5422
5783
  } = {}
5423
5784
  ) {
5424
5785
  const {mediaOptions, joinOptions = {}} = options;
5425
- const {isRetry, prevJoinResponse} = this.joinWithMediaRetryInfo;
5786
+ const {retryCount, prevJoinResponse, prevError} = this.joinWithMediaRetryInfo;
5426
5787
 
5427
5788
  if (!mediaOptions?.allowMediaInLobby) {
5428
5789
  return Promise.reject(
@@ -5433,9 +5794,6 @@ export default class Meeting extends StatelessWebexPlugin {
5433
5794
 
5434
5795
  LoggerProxy.logger.info('Meeting:index#joinWithMedia called');
5435
5796
 
5436
- let joined = false;
5437
- let joinResponse = prevJoinResponse;
5438
-
5439
5797
  /* Before we do anything, check if RTCPeerConnection is available. Normally this is checked
5440
5798
  by addMediaInternal() itself when creating the media connection, but since joinWithMedia()
5441
5799
  is a convenience method that does both join() and addMedia(), we want to fail fast here
@@ -5448,12 +5806,28 @@ export default class Meeting extends StatelessWebexPlugin {
5448
5806
  );
5449
5807
  }
5450
5808
 
5809
+ /* While we're trying to join, we may fail and be doing a retry. In that case,
5810
+ we sometimes get dropped by Locus as a result of the 1st failed attempt.
5811
+ That notification from Locus needs to be ignored, otherwise it causes the meeting to be
5812
+ cleaned up and prevents the retry from running correctly.
5813
+ */
5814
+ this.locusInfo.suspendDestroyMeeting(true);
5815
+
5816
+ let joined = false;
5817
+ let joinResponse = prevJoinResponse;
5818
+
5819
+ const shouldJoin =
5820
+ !joinResponse || // first try, when the join response is empty
5821
+ (prevError && prevError instanceof UserNotJoinedError) || // last try failed with UserNotJoinedError
5822
+ this.isErrorMeaningLocusDroppedUs(prevError) ||
5823
+ MeetingUtil.isUserInLeftState(this.locusInfo); // locus dropped the connection before we can re-try addMedia
5824
+
5451
5825
  try {
5452
5826
  let turnServerInfo;
5453
5827
  let turnDiscoverySkippedReason;
5454
5828
  let forceTurnDiscovery = false;
5455
5829
 
5456
- if (!joinResponse) {
5830
+ if (shouldJoin) {
5457
5831
  // This is the 1st attempt or a retry after join request failed -> we need to do a join with TURN discovery
5458
5832
 
5459
5833
  const turnDiscoveryRequest = await this.roap.generateTurnDiscoveryRequestMessage(
@@ -5492,16 +5866,24 @@ export default class Meeting extends StatelessWebexPlugin {
5492
5866
  joined = true;
5493
5867
  }
5494
5868
 
5869
+ const shouldRetryMediaWithOnlyTurnTLS = await this.shouldRetryMediaWithOnlyTurnTLS(prevError);
5870
+
5495
5871
  const mediaResponse = await this.addMediaInternal(
5496
5872
  () => {
5497
- return this.joinWithMediaRetryInfo.isRetry ? 'JOIN_MEETING_FINAL' : 'JOIN_MEETING_RETRY';
5873
+ // callback is not called when UserNotJoinedError is thrown
5874
+ return this.joinWithMediaRetryInfo.retryCount >= 1
5875
+ ? 'JOIN_MEETING_FINAL'
5876
+ : 'JOIN_MEETING_RETRY';
5498
5877
  },
5499
- turnServerInfo,
5500
5878
  forceTurnDiscovery,
5879
+ turnServerInfo,
5880
+ shouldRetryMediaWithOnlyTurnTLS ? 'relay' : undefined,
5501
5881
  mediaOptions
5502
5882
  );
5503
5883
 
5504
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
5884
+ this.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
5885
+
5886
+ this.locusInfo.suspendDestroyMeeting(false);
5505
5887
 
5506
5888
  return {
5507
5889
  join: joinResponse,
@@ -5515,15 +5897,21 @@ export default class Meeting extends StatelessWebexPlugin {
5515
5897
 
5516
5898
  this.roap.abortTurnDiscovery();
5517
5899
 
5518
- // if this was the first attempt, let's do a retry
5519
- let shouldRetry = !isRetry;
5900
+ // let's do a retry (but not on 1-1 calls, because the flow would get too complicated)
5901
+ let shouldRetry =
5902
+ !MeetingsUtil.isOneOnOneCall(this.locusInfo.parsedLocus) &&
5903
+ (retryCount < 1 ||
5904
+ ((error instanceof UserNotJoinedError || this.isErrorMeaningLocusDroppedUs(error)) &&
5905
+ retryCount < JOIN_WITH_MEDIA_RETRY_MAX_COUNT));
5520
5906
 
5521
5907
  if (
5522
5908
  CallDiagnosticUtils.isSdpOfferCreationError(error) ||
5523
- CallDiagnosticUtils.isWebrtcApiNotAvailableError(error)
5909
+ CallDiagnosticUtils.isWebrtcApiNotAvailableError(error) ||
5910
+ this.isLocusUserFullError(error)
5524
5911
  ) {
5525
5912
  // errors related to offer creation (for example missing H264 codec) will happen again no matter how many times we try,
5526
5913
  // so there is no point doing a retry
5914
+ // when the locus is full, we also don't want to retry, because it will just fail again
5527
5915
  shouldRetry = false;
5528
5916
  }
5529
5917
 
@@ -5541,8 +5929,8 @@ export default class Meeting extends StatelessWebexPlugin {
5541
5929
  });
5542
5930
  }
5543
5931
 
5544
- // we only want to call leave if join was successful and this was a retry or we won't be doing any more retries
5545
- if (joined && (isRetry || !shouldRetry)) {
5932
+ // we only want to call leave if join was successful, and we won't be doing any more retries
5933
+ if (joined && !shouldRetry) {
5546
5934
  try {
5547
5935
  await this.leave({resourceId: joinOptions?.resourceId, reason: 'joinWithMedia failure'});
5548
5936
  } catch (e) {
@@ -5559,7 +5947,7 @@ export default class Meeting extends StatelessWebexPlugin {
5559
5947
  reason: error.message,
5560
5948
  stack: error.stack,
5561
5949
  leaveErrorReason: leaveError?.message,
5562
- isRetry,
5950
+ isRetry: retryCount > 0,
5563
5951
  },
5564
5952
  {
5565
5953
  type: error.name,
@@ -5568,15 +5956,30 @@ export default class Meeting extends StatelessWebexPlugin {
5568
5956
 
5569
5957
  if (shouldRetry) {
5570
5958
  LoggerProxy.logger.warn('Meeting:index#joinWithMedia --> retrying call to joinWithMedia');
5571
- this.joinWithMediaRetryInfo.isRetry = true;
5959
+ this.joinWithMediaRetryInfo.retryCount = retryCount + 1;
5572
5960
  this.joinWithMediaRetryInfo.prevJoinResponse = joinResponse;
5961
+ this.joinWithMediaRetryInfo.prevError = error;
5962
+ if (!this.joinWithMediaRetryInfo.firstError) {
5963
+ this.joinWithMediaRetryInfo.firstError = error;
5964
+ }
5573
5965
 
5574
5966
  return this.joinWithMedia(options);
5575
5967
  }
5576
5968
 
5577
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
5969
+ const {firstError} = this.joinWithMediaRetryInfo;
5578
5970
 
5579
- throw error;
5971
+ this.joinWithMediaRetryInfo = {
5972
+ retryCount: 0,
5973
+ prevJoinResponse: undefined,
5974
+ firstError: undefined,
5975
+ prevError: undefined,
5976
+ };
5977
+
5978
+ this.locusInfo.suspendDestroyMeeting(false);
5979
+
5980
+ // LOCUS_USER_FULL is a definitive capacity error the client must surface, so it takes
5981
+ // precedence over any earlier retryable error stored in firstError.
5982
+ throw this.isLocusUserFullError(error) ? error : firstError ?? error;
5580
5983
  }
5581
5984
  }
5582
5985
 
@@ -5681,8 +6084,7 @@ export default class Meeting extends StatelessWebexPlugin {
5681
6084
 
5682
6085
  try {
5683
6086
  const voiceaListenerCaptionUpdate = (payload) => {
5684
- // @ts-ignore
5685
- this.webex.internal.voicea.off(
6087
+ this.voiceaChannel?.off(
5686
6088
  VOICEAEVENTS.CAPTION_LANGUAGE_UPDATE,
5687
6089
  voiceaListenerCaptionUpdate
5688
6090
  );
@@ -5698,13 +6100,8 @@ export default class Meeting extends StatelessWebexPlugin {
5698
6100
  reject(payload);
5699
6101
  }
5700
6102
  };
5701
- // @ts-ignore
5702
- this.webex.internal.voicea.on(
5703
- VOICEAEVENTS.CAPTION_LANGUAGE_UPDATE,
5704
- voiceaListenerCaptionUpdate
5705
- );
5706
- // @ts-ignore
5707
- this.webex.internal.voicea.requestLanguage(language);
6103
+ this.voiceaChannel?.on(VOICEAEVENTS.CAPTION_LANGUAGE_UPDATE, voiceaListenerCaptionUpdate);
6104
+ this.voiceaChannel?.requestLanguage(language);
5708
6105
  } catch (error) {
5709
6106
  LoggerProxy.logger.error(`Meeting:index#setCaptionLanguage --> ${error}`);
5710
6107
 
@@ -5738,8 +6135,7 @@ export default class Meeting extends StatelessWebexPlugin {
5738
6135
 
5739
6136
  try {
5740
6137
  const voiceaListenerLanguageUpdate = (payload) => {
5741
- // @ts-ignore
5742
- this.webex.internal.voicea.off(
6138
+ this.voiceaChannel?.off(
5743
6139
  VOICEAEVENTS.SPOKEN_LANGUAGE_UPDATE,
5744
6140
  voiceaListenerLanguageUpdate
5745
6141
  );
@@ -5756,14 +6152,9 @@ export default class Meeting extends StatelessWebexPlugin {
5756
6152
  }
5757
6153
  };
5758
6154
 
5759
- // @ts-ignore
5760
- this.webex.internal.voicea.on(
5761
- VOICEAEVENTS.SPOKEN_LANGUAGE_UPDATE,
5762
- voiceaListenerLanguageUpdate
5763
- );
6155
+ this.voiceaChannel?.on(VOICEAEVENTS.SPOKEN_LANGUAGE_UPDATE, voiceaListenerLanguageUpdate);
5764
6156
 
5765
- // @ts-ignore
5766
- this.webex.internal.voicea.setSpokenLanguage(language);
6157
+ this.voiceaChannel?.setSpokenLanguage(language);
5767
6158
  } catch (error) {
5768
6159
  LoggerProxy.logger.error(`Meeting:index#setSpokenLanguage --> ${error}`);
5769
6160
 
@@ -5785,12 +6176,18 @@ export default class Meeting extends StatelessWebexPlugin {
5785
6176
  );
5786
6177
 
5787
6178
  try {
6179
+ if (!this.voiceaChannel) {
6180
+ LoggerProxy.logger.warn(
6181
+ 'Meeting:index#startTranscription --> voiceaChannel not available'
6182
+ );
6183
+
6184
+ return;
6185
+ }
6186
+
5788
6187
  if (!this.areVoiceaEventsSetup) {
5789
6188
  this.setUpVoiceaListeners();
5790
6189
  }
5791
-
5792
- // @ts-ignore
5793
- await this.webex.internal.voicea.turnOnCaptions(options?.spokenLanguage);
6190
+ await this.voiceaChannel.turnOnCaptions(options?.spokenLanguage);
5794
6191
  } catch (error) {
5795
6192
  LoggerProxy.logger.error(`Meeting:index#startTranscription --> ${error}`);
5796
6193
  Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.RECEIVE_TRANSCRIPTION_FAILURE, {
@@ -5807,6 +6204,22 @@ export default class Meeting extends StatelessWebexPlugin {
5807
6204
  }
5808
6205
  }
5809
6206
 
6207
+ /**
6208
+ * Starts transcription when requested by the current Locus controls and an
6209
+ * active LLM channel is ready.
6210
+ * @internal
6211
+ * @returns {void}
6212
+ */
6213
+ public startTranscriptionIfNeeded(): void {
6214
+ if (
6215
+ this.locusInfo.controls?.transcribe?.transcribing &&
6216
+ !this.areVoiceaEventsSetup &&
6217
+ this.voiceaChannel?.isLLMConnected()
6218
+ ) {
6219
+ this.startTranscription();
6220
+ }
6221
+ }
6222
+
5810
6223
  /** Handles Locus LLM events
5811
6224
  *
5812
6225
  * @param {LocusLLMEvent} event - The Locus LLM event to process
@@ -5814,7 +6227,23 @@ export default class Meeting extends StatelessWebexPlugin {
5814
6227
  */
5815
6228
  private processLocusLLMEvent = (event: LocusLLMEvent): void => {
5816
6229
  if (event.data.eventType === LOCUSEVENT.HASH_TREE_DATA_UPDATED) {
5817
- this.locusInfo.parse(this, event.data);
6230
+ // @ts-ignore
6231
+ if (this.config.experimental.storeLocusHashTreeEventsForDebugging) {
6232
+ storeEventForDebugging('llm', event.data);
6233
+ }
6234
+
6235
+ const {trackingId} = event;
6236
+
6237
+ this.locusInfo.parse(this, event.data);
6238
+
6239
+ // Only the client whose /sync request tracking id matches the tracking id echoed back on this
6240
+ // LLM message should emit client.locus.sync.complete. The tracking id lives at the top level
6241
+ // of the received LLM event envelope. When it is absent there is nothing to correlate, so
6242
+ // skip. onLocusSyncLlmMessage records the LLM arrival time and is a no-op unless a stored
6243
+ // record for this meeting matches the tracking id.
6244
+ if (trackingId) {
6245
+ this.onLocusSyncLlmMessage(this.id, trackingId);
6246
+ }
5818
6247
  } else {
5819
6248
  LoggerProxy.logger.warn(
5820
6249
  `Meeting:index#processLocusLLMEvent --> Unknown event type: ${event.data.eventType}`
@@ -5822,6 +6251,35 @@ export default class Meeting extends StatelessWebexPlugin {
5822
6251
  }
5823
6252
  };
5824
6253
 
6254
+ /**
6255
+ * Verifies the relay event was delivered for the active LLM session binding.
6256
+ * With the factory pattern, each meeting owns its channel, so we just verify
6257
+ * the route matches our channel's binding or the practice session binding.
6258
+ * @param {RelayEvent} event Event object coming from LLM Connection
6259
+ * @returns {boolean}
6260
+ */
6261
+ private isRelayEventRouteValid(event: RelayEvent): boolean {
6262
+ const route = event?.headers?.route;
6263
+
6264
+ if (!route) {
6265
+ return true;
6266
+ }
6267
+
6268
+ // With the factory pattern, both channels may be connected simultaneously.
6269
+ // Determine which session is "active" based on whether PS channel is connected.
6270
+ const isPracticeSession = this.webinar?.isPracticeSessionLLMChannelConnected() ?? false;
6271
+
6272
+ const expectedBinding = isPracticeSession
6273
+ ? this.webinar?.getPracticeSessionBinding()
6274
+ : this.llmChannel?.getBinding();
6275
+
6276
+ if (!expectedBinding || route === expectedBinding) {
6277
+ return true;
6278
+ }
6279
+
6280
+ return false;
6281
+ }
6282
+
5825
6283
  /**
5826
6284
  * Callback called when a relay event is received from meeting LLM Connection
5827
6285
  * @param {RelayEvent} e Event object coming from LLM Connection
@@ -5829,11 +6287,15 @@ export default class Meeting extends StatelessWebexPlugin {
5829
6287
  * @returns {void}
5830
6288
  */
5831
6289
  private processRelayEvent = (e: RelayEvent): void => {
6290
+ if (!this.isRelayEventRouteValid(e)) {
6291
+ return;
6292
+ }
5832
6293
  switch (e.data.relayType) {
5833
6294
  case REACTION_RELAY_TYPES.REACTION:
6295
+ // @ts-ignore - config coming from registerPlugin
5834
6296
  if (
5835
6297
  // @ts-ignore - config coming from registerPlugin
5836
- (this.config.receiveReactions || options.receiveReactions) &&
6298
+ this.config.receiveReactions &&
5837
6299
  this.isReactionsSupported()
5838
6300
  ) {
5839
6301
  const member = this.members.membersCollection.get(e.data.sender.participantId);
@@ -5874,37 +6336,30 @@ export default class Meeting extends StatelessWebexPlugin {
5874
6336
  * @returns {void}
5875
6337
  */
5876
6338
  stopTranscription() {
5877
- if (this.transcription) {
5878
- // @ts-ignore
5879
- this.webex.internal.voicea.off(
5880
- VOICEAEVENTS.VOICEA_ANNOUNCEMENT,
5881
- this.voiceaListenerCallbacks[VOICEAEVENTS.VOICEA_ANNOUNCEMENT]
5882
- );
6339
+ this.voiceaChannel?.off(
6340
+ VOICEAEVENTS.VOICEA_ANNOUNCEMENT,
6341
+ this.voiceaListenerCallbacks[VOICEAEVENTS.VOICEA_ANNOUNCEMENT]
6342
+ );
5883
6343
 
5884
- // @ts-ignore
5885
- this.webex.internal.voicea.off(
5886
- VOICEAEVENTS.CAPTIONS_TURNED_ON,
5887
- this.voiceaListenerCallbacks[VOICEAEVENTS.CAPTIONS_TURNED_ON]
5888
- );
6344
+ this.voiceaChannel?.off(
6345
+ VOICEAEVENTS.CAPTIONS_TURNED_ON,
6346
+ this.voiceaListenerCallbacks[VOICEAEVENTS.CAPTIONS_TURNED_ON]
6347
+ );
5889
6348
 
5890
- // @ts-ignore
5891
- this.webex.internal.voicea.off(
5892
- VOICEAEVENTS.EVA_COMMAND,
5893
- this.voiceaListenerCallbacks[VOICEAEVENTS.EVA_COMMAND]
5894
- );
6349
+ this.voiceaChannel?.off(
6350
+ VOICEAEVENTS.EVA_COMMAND,
6351
+ this.voiceaListenerCallbacks[VOICEAEVENTS.EVA_COMMAND]
6352
+ );
5895
6353
 
5896
- // @ts-ignore
5897
- this.webex.internal.voicea.off(
5898
- VOICEAEVENTS.NEW_CAPTION,
5899
- this.voiceaListenerCallbacks[VOICEAEVENTS.NEW_CAPTION]
5900
- );
6354
+ this.voiceaChannel?.off(
6355
+ VOICEAEVENTS.NEW_CAPTION,
6356
+ this.voiceaListenerCallbacks[VOICEAEVENTS.NEW_CAPTION]
6357
+ );
5901
6358
 
5902
- // @ts-ignore
5903
- this.webex.internal.voicea.deregisterEvents();
6359
+ this.voiceaChannel?.deregisterEvents();
5904
6360
 
5905
- this.areVoiceaEventsSetup = false;
5906
- this.triggerStopReceivingTranscriptionEvent();
5907
- }
6361
+ this.areVoiceaEventsSetup = false;
6362
+ this.triggerStopReceivingTranscriptionEvent();
5908
6363
  }
5909
6364
 
5910
6365
  /**
@@ -5928,6 +6383,28 @@ export default class Meeting extends StatelessWebexPlugin {
5928
6383
  );
5929
6384
  }
5930
6385
 
6386
+ /**
6387
+ * Restores LLM subchannel subscriptions after reconnect when captions are active.
6388
+ * @returns {void}
6389
+ */
6390
+ private restoreLLMSubscriptionsIfNeeded(): void {
6391
+ try {
6392
+ const keepTranscriptionSubscribed = this.voiceaChannel?.getKeepTranscriptionSubscribed();
6393
+
6394
+ if (!keepTranscriptionSubscribed) {
6395
+ return;
6396
+ }
6397
+
6398
+ this.voiceaChannel?.updateSubchannelSubscriptions({subscribe: ['transcription']});
6399
+ } catch (error) {
6400
+ const msg = error?.message || String(error);
6401
+
6402
+ LoggerProxy.logger.warn(
6403
+ `Meeting:index#restoreLLMSubscriptionsIfNeeded --> failed to restore subscriptions after LLM online: ${msg}`
6404
+ );
6405
+ }
6406
+ }
6407
+
5931
6408
  /**
5932
6409
  * This is a callback for the LLM event that is triggered when it comes online
5933
6410
  * This method in turn will trigger an event to the developers that the LLM is connected
@@ -5936,8 +6413,9 @@ export default class Meeting extends StatelessWebexPlugin {
5936
6413
  * @returns {null}
5937
6414
  */
5938
6415
  private handleLLMOnline = (): void => {
5939
- // @ts-ignore
5940
- this.webex.internal.llm.off('online', this.handleLLMOnline);
6416
+ this.restoreLLMSubscriptionsIfNeeded();
6417
+ this.locusInfo.syncAllHashTreeDatasets({onlyLLM: true});
6418
+
5941
6419
  Trigger.trigger(
5942
6420
  this,
5943
6421
  {
@@ -6165,11 +6643,10 @@ export default class Meeting extends StatelessWebexPlugin {
6165
6643
  return Promise.reject(error);
6166
6644
  })
6167
6645
  .then((join) => {
6646
+ this.saveDataChannelToken(join);
6168
6647
  // @ts-ignore - config coming from registerPlugin
6169
6648
  if (this.config.enableAutomaticLLM) {
6170
- // @ts-ignore
6171
- this.webex.internal.llm.on('online', this.handleLLMOnline);
6172
- this.updateLLMConnection()
6649
+ this.updateLLMConnection({isInitialJoinPhase: true})
6173
6650
  .catch((error) => {
6174
6651
  LoggerProxy.logger.error(
6175
6652
  'Meeting:index#join --> Transcription Socket Connection Failed',
@@ -6203,12 +6680,10 @@ export default class Meeting extends StatelessWebexPlugin {
6203
6680
  this.clearLLMHealthCheckTimer();
6204
6681
 
6205
6682
  this.llmHealthCheckTimer = setTimeout(() => {
6206
- // @ts-ignore
6207
- const isConnected = this.webex.internal.llm.isConnected();
6683
+ const isConnected = this.llmChannel?.isConnected() ?? false;
6208
6684
 
6209
6685
  if (!isConnected) {
6210
- // @ts-ignore
6211
- const {hasEverConnected} = this.webex.internal.llm;
6686
+ const hasEverConnected = this.llmChannel?.hasEverConnected ?? false;
6212
6687
 
6213
6688
  // only send metric if not connected - to avoid too many metrics
6214
6689
  Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.LLM_HEALTHCHECK_FAILURE, {
@@ -6234,28 +6709,88 @@ export default class Meeting extends StatelessWebexPlugin {
6234
6709
  }
6235
6710
 
6236
6711
  /**
6237
- * Disconnects and cleans up the default LLM session listeners/timers.
6712
+ * Removes LLM event listeners and clears the health check timer.
6713
+ * Must be called before Locus /leave to avoid unnecessary syncs triggered
6714
+ * by events received while leaving (per Locus team recommendation).
6715
+ * Idempotent: safe to call multiple times; .off() is a no-op when no
6716
+ * matching listener is registered.
6717
+ * @private
6718
+ * @returns {void}
6719
+ */
6720
+ private stopListeningForLLMEvents() {
6721
+ this.llmChannel?.off('event:relay.event', this.processRelayEvent);
6722
+ this.llmChannel?.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6723
+ this.llmChannel?.off('online', this.handleLLMOnline);
6724
+ this.breakouts?.unregisterLLMChannel();
6725
+ // voiceaChannel persists across LLM reconnects; switchLLMChannel() handles re-subscribing
6726
+ this.clearLLMHealthCheckTimer();
6727
+ }
6728
+
6729
+ /**
6730
+ * Stops listening on every event bus (LLM, Mercury, voicea/transcription,
6731
+ * annotation) that could otherwise deliver events to this meeting while
6732
+ * Locus is processing /leave or /end. Per the Locus team recommendation,
6733
+ * this must run before the Locus request is dispatched to avoid
6734
+ * unnecessary syncs triggered by in-flight events.
6735
+ *
6736
+ * Voicea (transcription) subscribes to llm 'event:relay.event' internally,
6737
+ * and the annotation plugin subscribes to both mercury and llm, so both
6738
+ * must be torn down alongside the direct LLM/Mercury listeners.
6739
+ *
6740
+ * Idempotent: safe to call multiple times; .off() is a no-op when no
6741
+ * matching listener is registered, and stopTranscription is guarded.
6742
+ * @private
6743
+ * @returns {void}
6744
+ */
6745
+ private stopListeningForMeetingEvents() {
6746
+ this.stopListeningForLLMEvents();
6747
+ this.stopListeningForMercuryEvents();
6748
+ if (this.areVoiceaEventsSetup) {
6749
+ this.stopTranscription();
6750
+ }
6751
+ // Reset to initial shape instead of null - transcription is always a valid object
6752
+ this.transcription = this.getInitialTranscription();
6753
+ this.annotation.deregisterEvents();
6754
+ }
6755
+
6756
+ /**
6757
+ * Disconnects and cleans up the LLM channel owned by this meeting.
6758
+ *
6238
6759
  * @param {Object} options
6239
- * @param {boolean} [options.removeOnlineListener=true] removes the one-time online listener
6240
6760
  * @param {boolean} [options.throwOnError=true] rethrows disconnect errors when true
6761
+ * @param {boolean} [options.preserveVoiceaChannel=false] when true, keeps voiceaChannel for switchLLMChannel() during reconnects
6241
6762
  * @returns {Promise<void>}
6242
6763
  */
6243
6764
  private cleanupLLMConneciton = async ({
6244
- removeOnlineListener = true,
6245
6765
  throwOnError = true,
6766
+ preserveVoiceaChannel = false,
6246
6767
  }: {
6247
- removeOnlineListener?: boolean;
6248
6768
  throwOnError?: boolean;
6769
+ preserveVoiceaChannel?: boolean;
6249
6770
  } = {}): Promise<void> => {
6771
+ // Always clear the timer, even if there's no channel
6772
+ this.clearLLMHealthCheckTimer();
6773
+
6774
+ // Permanent cleanup must deregister voiceaChannel regardless of LLM presence.
6775
+ // When a transient reconnect fails (LLM registration error), llmChannel is undefined
6776
+ // but voiceaChannel may still exist with listeners attached to the old emitter.
6777
+ if (!preserveVoiceaChannel) {
6778
+ this.voiceaChannel?.deregisterEvents();
6779
+ this.voiceaChannel = undefined;
6780
+ }
6781
+
6782
+ if (!this.llmChannel) {
6783
+ return;
6784
+ }
6785
+
6250
6786
  try {
6251
- // @ts-ignore - Fix type
6252
- await this.webex.internal.llm.disconnectLLM({
6787
+ await this.llmChannel.disconnect({
6253
6788
  code: 3050,
6254
6789
  reason: 'done (permanent)',
6255
6790
  });
6256
6791
  } catch (error) {
6257
6792
  LoggerProxy.logger.error(
6258
- 'Meeting:index#cleanupLLMConneciton --> Failed to disconnect default LLM session',
6793
+ 'Meeting:index#cleanupLLMConneciton --> Failed to disconnect LLM channel',
6259
6794
  error
6260
6795
  );
6261
6796
 
@@ -6263,88 +6798,321 @@ export default class Meeting extends StatelessWebexPlugin {
6263
6798
  throw error;
6264
6799
  }
6265
6800
  } finally {
6266
- if (removeOnlineListener) {
6267
- // @ts-ignore - Fix type
6268
- this.webex.internal.llm.off('online', this.handleLLMOnline);
6801
+ this.stopListeningForLLMEvents();
6802
+ this.llmChannel = undefined;
6803
+ }
6804
+ };
6805
+
6806
+ /**
6807
+ * Sets the datachannel token on the meeting's LLM channel.
6808
+ * Used by the DataChannelAuthTokenInterceptor after refreshing tokens.
6809
+ * @param {string} token - The new datachannel token
6810
+ * @returns {void}
6811
+ */
6812
+ setLLMChannelDataToken(token: string): void {
6813
+ this.llmChannel?.setDatachannelToken(token);
6814
+ }
6815
+
6816
+ /**
6817
+ * Saves the data channel tokens from the join response.
6818
+ * Default session token is stored on this.llmChannel when available.
6819
+ * Practice session token is stored on the webinar's practice LLM channel.
6820
+ * @param {Object} join - The parsed join response (from MeetingUtil.parseLocusJoin)
6821
+ * @returns {void}
6822
+ */
6823
+ saveDataChannelToken(join: any): void {
6824
+ const datachannelToken = join?.locus?.self?.datachannelToken;
6825
+ const practiceSessionDatachannelToken = join?.locus?.self?.practiceSessionDatachannelToken;
6826
+
6827
+ // Store default session token on our LLM channel if it exists
6828
+ if (datachannelToken && this.llmChannel) {
6829
+ this.llmChannel.setDatachannelToken(datachannelToken);
6830
+ }
6831
+
6832
+ // Store the token temporarily for use when channel is created
6833
+ if (datachannelToken) {
6834
+ this._pendingDatachannelToken = datachannelToken;
6835
+ }
6836
+
6837
+ // Practice session token is handled by webinar
6838
+ if (practiceSessionDatachannelToken) {
6839
+ this.webinar.setPracticeSessionDatachannelToken(practiceSessionDatachannelToken);
6840
+ }
6841
+ }
6842
+
6843
+ /**
6844
+ * Ensures default-session data channel token exists after lobby admission.
6845
+ * Some lobby users do not receive a token until they are admitted.
6846
+ * @returns {Promise<boolean>} true when a new token is fetched and cached
6847
+ */
6848
+ private async ensureDefaultDatachannelTokenAfterAdmit(): Promise<boolean> {
6849
+ try {
6850
+ const datachannelToken =
6851
+ this.llmChannel?.getDatachannelToken() ?? this._pendingDatachannelToken;
6852
+ // @ts-ignore
6853
+ const isDataChannelTokenEnabled = await this.webex.internal.llm.isDataChannelTokenEnabled();
6854
+
6855
+ if (!isDataChannelTokenEnabled || datachannelToken) {
6856
+ return false;
6269
6857
  }
6270
- // @ts-ignore - fix types
6271
- this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6272
- // @ts-ignore - Fix type
6273
- this.webex.internal.llm.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6274
6858
 
6275
- this.clearLLMHealthCheckTimer();
6859
+ const response = await this.meetingRequest.fetchDatachannelToken({
6860
+ locusUrl: this.locusUrl,
6861
+ requestingParticipantId: this.members.selfId,
6862
+ isPracticeSession: false,
6863
+ });
6864
+ const fetchedDatachannelToken = response?.body?.datachannelToken;
6865
+
6866
+ if (!fetchedDatachannelToken) {
6867
+ return false;
6868
+ }
6869
+
6870
+ // Store on channel if exists, otherwise save as pending
6871
+ if (this.llmChannel) {
6872
+ this.llmChannel.setDatachannelToken(fetchedDatachannelToken);
6873
+ } else {
6874
+ this._pendingDatachannelToken = fetchedDatachannelToken;
6875
+ }
6876
+
6877
+ return true;
6878
+ } catch (error) {
6879
+ const msg = error?.message || String(error);
6880
+
6881
+ LoggerProxy.logger.warn(
6882
+ `Meeting:index#ensureDefaultDatachannelTokenAfterAdmit --> failed to proactively fetch default data channel token after admit: ${msg}`,
6883
+ {statusCode: error?.statusCode}
6884
+ );
6885
+
6886
+ return false;
6276
6887
  }
6277
- };
6888
+ }
6278
6889
 
6279
6890
  /**
6280
6891
  * Connects to low latency mercury and reconnects if the address has changed
6281
6892
  * It will also disconnect if called when the meeting has ended
6282
- * @param {String} datachannelUrl
6893
+ * @param {Object} [options]
6894
+ * @param {boolean} [options.isInitialJoinPhase] true when called from initial join flow
6283
6895
  * @returns {Promise}
6284
6896
  */
6285
- async updateLLMConnection() {
6897
+ async updateLLMConnection({isInitialJoinPhase = false}: {isInitialJoinPhase?: boolean} = {}) {
6286
6898
  // @ts-ignore - Fix type
6287
- const {
6288
- url = undefined,
6289
- info: {datachannelUrl = undefined} = {},
6290
- self: {datachannelToken = undefined} = {},
6291
- } = this.locusInfo || {};
6899
+ const {url = undefined, info: {datachannelUrl = undefined} = {}} = this.locusInfo || {};
6292
6900
 
6293
6901
  const isJoined = this.isJoined();
6902
+ const dataChannelUrl = datachannelUrl;
6294
6903
 
6295
- // @ts-ignore
6296
- const currentToken = this.webex.internal.llm.getDatachannelToken(DataChannelTokenType.Default);
6297
-
6298
- const finalToken = currentToken ?? datachannelToken;
6299
-
6300
- if (!currentToken && datachannelToken) {
6301
- // @ts-ignore
6302
- this.webex.internal.llm.setDatachannelToken(datachannelToken, DataChannelTokenType.Default);
6303
- }
6904
+ // If we have an existing channel, check if we should reuse it or clean it up
6905
+ if (this.llmChannel) {
6906
+ const isSameUrls =
6907
+ url === this.llmChannel.getLocusUrl() &&
6908
+ dataChannelUrl === this.llmChannel.getDatachannelUrl();
6304
6909
 
6305
- // webinar panelist should use new data channel in practice session
6306
- const dataChannelUrl = datachannelUrl;
6910
+ // If already connected to same URLs, skip reconnect
6911
+ if (this.llmChannel.isConnected() && isSameUrls && isJoined) {
6912
+ return undefined;
6913
+ }
6307
6914
 
6308
- // @ts-ignore - Fix type
6309
- if (this.webex.internal.llm.isConnected()) {
6310
- if (
6311
- // @ts-ignore - Fix type
6312
- url === this.webex.internal.llm.getLocusUrl() &&
6313
- // @ts-ignore - Fix type
6314
- dataChannelUrl === this.webex.internal.llm.getDatachannelUrl() &&
6315
- isJoined
6316
- ) {
6915
+ // If currently connecting to same URLs, wait for that to complete
6916
+ if (this.llmChannel.isConnecting() && isSameUrls && isJoined) {
6317
6917
  return undefined;
6318
6918
  }
6319
- await this.cleanupLLMConneciton({removeOnlineListener: false});
6919
+
6920
+ // URLs changed or not joined, disconnect existing channel
6921
+ await this.cleanupLLMConneciton({preserveVoiceaChannel: true});
6320
6922
  }
6321
6923
 
6322
- if (!isJoined) {
6924
+ if (!isJoined || !url || !dataChannelUrl) {
6925
+ // Either not joined, or locusInfo hasn't synced url/datachannelUrl yet
6926
+ // (SELF_UNADMITTED_GUEST/SELF_ADMITTED_GUEST can fire before datachannelUrl is
6927
+ // populated on rejoin). Any stale channel was already disconnected above; don't
6928
+ // create/register a new one with an empty URL. handleDataChannelUrlChange() will
6929
+ // re-invoke this once MEETING_INFO_UPDATED delivers the real datachannelUrl.
6323
6930
  return undefined;
6324
6931
  }
6325
6932
 
6933
+ // Create a new LLM channel for this meeting
6326
6934
  // @ts-ignore - Fix type
6327
- return this.webex.internal.llm
6328
- .registerAndConnect(url, dataChannelUrl, finalToken)
6935
+ this.llmChannel = this.webex.internal.llm.createChannel();
6936
+
6937
+ // Get token from pending (saved from join response) or channel
6938
+ const datachannelToken = this._pendingDatachannelToken ?? this.llmChannel.getDatachannelToken();
6939
+
6940
+ // Set up refresh handler before registration so interceptor-triggered token
6941
+ // refresh during register POST can resolve a valid handler.
6942
+ this.llmChannel.setRefreshHandler(() => this.refreshDataChannelToken());
6943
+
6944
+ // If we have a pending token, store it on the channel
6945
+ if (this._pendingDatachannelToken) {
6946
+ this.llmChannel.setDatachannelToken(this._pendingDatachannelToken);
6947
+ this._pendingDatachannelToken = undefined;
6948
+ }
6949
+
6950
+ return this.llmChannel
6951
+ .registerAndConnect(url, dataChannelUrl, datachannelToken)
6329
6952
  .then((registerAndConnectResult) => {
6330
- // @ts-ignore - Fix type
6331
- this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6332
- // @ts-ignore - Fix type
6333
- this.webex.internal.llm.on('event:relay.event', this.processRelayEvent);
6334
- // @ts-ignore - Fix type
6335
- this.webex.internal.llm.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6336
- // @ts-ignore - Fix type
6337
- this.webex.internal.llm.on(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6953
+ this.locusInfo.syncAllHashTreeDatasets({onlyLLM: true});
6954
+
6955
+ // Register event listeners on the channel
6956
+ this.llmChannel.off('event:relay.event', this.processRelayEvent);
6957
+ this.llmChannel.on('event:relay.event', this.processRelayEvent);
6958
+ this.llmChannel.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6959
+ this.llmChannel.on(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6960
+ this.llmChannel.off('online', this.handleLLMOnline);
6961
+ this.llmChannel.on('online', this.handleLLMOnline);
6962
+
6963
+ // Register annotation channel only if not in practice session
6964
+ // (practice session manages its own annotation channel via updatePSDataChannel)
6965
+ if (!this.webinar?.isJoinPracticeSessionDataChannel()) {
6966
+ this.annotation.registerChannel(this.llmChannel);
6967
+ }
6968
+
6969
+ // Register breakouts channel
6970
+ this.breakouts.registerLLMChannel(this.llmChannel);
6971
+
6338
6972
  LoggerProxy.logger.info(
6339
6973
  'Meeting:index#updateLLMConnection --> enabled to receive relay events!'
6340
6974
  );
6341
-
6342
6975
  this.startLLMHealthCheckTimer();
6343
6976
 
6977
+ // Switch voiceaChannel to use the new LLM channel (preserves transcription state).
6978
+ // Skip if practice session is active - practice session manages its own voicea binding
6979
+ // via updatePSDataChannel, and switching here would break practice session captions.
6980
+ const isPracticeSessionActive =
6981
+ this.webinar?.isPracticeSessionLLMChannelConnected() ?? false;
6982
+
6983
+ if (!this.voiceaChannel) {
6984
+ // @ts-ignore - Fix type
6985
+ this.voiceaChannel = this.webex.internal.voicea.createChannel();
6986
+ }
6987
+
6988
+ if (!isPracticeSessionActive) {
6989
+ // Fire-and-forget: caption restoration shouldn't block LLM connection result.
6990
+ // transcription is always initialized (reset to initial shape, never null),
6991
+ // so no re-init needed here.
6992
+ this.voiceaChannel
6993
+ .switchLLMChannel(this.llmChannel)
6994
+ .then(() => {
6995
+ this.startTranscriptionIfNeeded();
6996
+ })
6997
+ .catch((error) => {
6998
+ LoggerProxy.logger.warn(
6999
+ 'Meeting:index#updateLLMConnection --> failed to switch voicea channel:',
7000
+ error
7001
+ );
7002
+ });
7003
+ }
7004
+
7005
+ if (registerAndConnectResult) {
7006
+ if (isInitialJoinPhase) {
7007
+ this.sendLLMConnectMetric(registerAndConnectResult);
7008
+ }
7009
+
7010
+ this.breakouts?.trigger(BREAKOUTS.EVENTS.LLM_CONNECT_RESPONSE, {
7011
+ meeting: this,
7012
+ llmLatency: registerAndConnectResult,
7013
+ });
7014
+ }
7015
+
6344
7016
  return Promise.resolve(registerAndConnectResult);
7017
+ })
7018
+ .catch((error) => {
7019
+ // Prefer the partial timing registerAndConnect attaches when register succeeded but the
7020
+ // websocket connect() failed, so a ws failure isn't misreported as register never completing.
7021
+ const llmLatency = {
7022
+ clientLLMDatachannelResponseTime: error?.timing?.clientLLMDatachannelResponseTime ?? 0,
7023
+ clientLLMWebSocketConnectTime: 0,
7024
+ };
7025
+
7026
+ if (isInitialJoinPhase) {
7027
+ this.sendLLMConnectMetric(llmLatency, error);
7028
+ }
7029
+
7030
+ this.breakouts?.trigger(BREAKOUTS.EVENTS.LLM_CONNECT_RESPONSE, {
7031
+ meeting: this,
7032
+ llmLatency,
7033
+ error,
7034
+ });
7035
+
7036
+ // Clean up the channel on failure
7037
+ this.llmChannel = undefined;
7038
+
7039
+ return Promise.reject(error);
6345
7040
  });
6346
7041
  }
6347
7042
 
7043
+ /**
7044
+ * Ensures breakout join response metric with LLM latency is emitted only once per breakout move id.
7045
+ * @param {string | undefined} breakoutMoveId
7046
+ * @param {boolean} [hasLLMLatency=false]
7047
+ * @returns {boolean}
7048
+ */
7049
+ private shouldEmitBreakoutJoinResponseMetric(
7050
+ breakoutMoveId?: string,
7051
+ hasLLMLatency = false
7052
+ ): boolean {
7053
+ if (!breakoutMoveId) {
7054
+ return false;
7055
+ }
7056
+
7057
+ if (!hasLLMLatency) {
7058
+ // When automatic LLM is enabled, updateLLMConnection will emit this same breakout join
7059
+ // response after the LLM connection finishes, including llmLatency and llmWebsocketUrl.
7060
+ // Suppress the earlier non-LLM event to avoid sending two events for the same move id,
7061
+ // where the first one would be missing the LLM-specific fields we want to validate.
7062
+ // @ts-ignore - config coming from registerPlugin
7063
+ return !this.config.enableAutomaticLLM;
7064
+ }
7065
+
7066
+ if (this.emittedBreakoutJoinResponseMoveIds.has(breakoutMoveId)) {
7067
+ return false;
7068
+ }
7069
+
7070
+ this.emittedBreakoutJoinResponseMoveIds.add(breakoutMoveId);
7071
+
7072
+ return true;
7073
+ }
7074
+
7075
+ /**
7076
+ * Sends LLM connect latencies for initial join flow.
7077
+ * @param {RegisterAndConnectTiming} timings
7078
+ * @param {any} [error]
7079
+ * @returns {void}
7080
+ */
7081
+ private sendLLMConnectMetric(timings: RegisterAndConnectTiming, error?: any) {
7082
+ // @ts-ignore
7083
+ const llmWebsocketUrl = this.webex.internal.llm.getWebSocketUrl?.() || undefined;
7084
+ const {clientLLMDatachannelResponseTime = 0, clientLLMWebSocketConnectTime} = timings || {};
7085
+
7086
+ const llmLatency: any = {
7087
+ clientLLMDatachannelResponseTime,
7088
+ };
7089
+
7090
+ if (clientLLMWebSocketConnectTime !== undefined) {
7091
+ llmLatency.clientLLMWebSocketConnectTime = clientLLMWebSocketConnectTime;
7092
+ }
7093
+
7094
+ const payload: any = {
7095
+ identifiers: {
7096
+ llmWebsocketUrl,
7097
+ },
7098
+ llmLatency,
7099
+ };
7100
+
7101
+ const options: any = {
7102
+ meetingId: this.id,
7103
+ ...(error && {rawError: error}),
7104
+ };
7105
+
7106
+ const metricEvent = {
7107
+ name: 'client.llm.connect.response',
7108
+ payload,
7109
+ options,
7110
+ };
7111
+
7112
+ // @ts-ignore
7113
+ this.webex.internal.newMetrics.submitClientEvent(metricEvent);
7114
+ }
7115
+
6348
7116
  /**
6349
7117
  * Use phone for meeting audio
6350
7118
  * @param {String} phoneNumber If provided, it will dial-out using this number. If not provided, dial-in will be used
@@ -6772,16 +7540,32 @@ export default class Meeting extends StatelessWebexPlugin {
6772
7540
  // @ts-ignore
6773
7541
  const cdl = this.webex.internal.newMetrics.callDiagnosticLatencies;
6774
7542
 
7543
+ // Compute the offer->answer latency from when the local SDP offer was generated up to now,
7544
+ // rather than from the stored remote-sdp-received timestamp. That stored timestamp uses
7545
+ // saveFirstTimestampOnly, so if waitForRemoteSDPAnswer() already timed out and submitted a
7546
+ // remote-sdp-received event, the stored value would be pinned to the timeout time and would
7547
+ // under-report an answer that arrives late. This handler fires exactly when the answer is
7548
+ // processed, so Date.now() is the accurate "received" time.
7549
+ // (submitClientEvent below still records the remote-sdp-received timestamp used by the CA
7550
+ // join-time metric, so we don't need to save it here.)
7551
+ const localSdpGeneratedTimestamp = cdl.latencyTimestamps.get(
7552
+ 'client.media-engine.local-sdp-generated'
7553
+ );
7554
+ const localSDPGenRemoteSDPRecv =
7555
+ localSdpGeneratedTimestamp !== undefined
7556
+ ? Date.now() - localSdpGeneratedTimestamp
7557
+ : undefined;
7558
+
6775
7559
  // @ts-ignore
6776
7560
  this.webex.internal.newMetrics.submitClientEvent({
6777
7561
  name: 'client.media-engine.remote-sdp-received',
7562
+ payload: {
7563
+ eventData: {
7564
+ localSDPGenRemoteSDPRecv,
7565
+ },
7566
+ },
6778
7567
  options: {meetingId: this.id},
6779
7568
  });
6780
- Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.ROAP_OFFER_TO_ANSWER_LATENCY, {
6781
- correlation_id: this.correlationId,
6782
- latency: cdl.getLocalSDPGenRemoteSDPRecv(),
6783
- meetingId: this.id,
6784
- });
6785
7569
 
6786
7570
  if (this.deferSDPAnswer) {
6787
7571
  this.deferSDPAnswer.resolve();
@@ -7367,23 +8151,108 @@ export default class Meeting extends StatelessWebexPlugin {
7367
8151
  }
7368
8152
  }
7369
8153
  });
8154
+ this.statsAnalyzer.on(StatsAnalyzerEventNames.STATS_UPDATE, (data) => {
8155
+ // Extract srtpCipher from transport stats
8156
+ let srtpCipher: string | undefined;
8157
+ for (const stats of data.stats.values()) {
8158
+ if (stats.type === 'transport' && stats.srtpCipher) {
8159
+ srtpCipher = stats.srtpCipher as string;
8160
+ break;
8161
+ }
8162
+ }
8163
+
8164
+ // Only emit event if srtpCipher has changed
8165
+ if (srtpCipher && srtpCipher !== this.mediaProperties.srtpCipher) {
8166
+ LoggerProxy.logger.info(
8167
+ `Meeting:index#setupStatsAnalyzerEventHandlers --> SRTP cipher changed from ${this.mediaProperties.srtpCipher} to ${srtpCipher}`
8168
+ );
8169
+ this.mediaProperties.srtpCipher = srtpCipher;
8170
+ Trigger.trigger(
8171
+ this,
8172
+ {
8173
+ file: 'meeting/index',
8174
+ function: 'setupStatsAnalyzerEventHandlers',
8175
+ },
8176
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
8177
+ {srtpCipher}
8178
+ );
8179
+ }
8180
+ });
7370
8181
  };
7371
8182
 
7372
8183
  getMediaConnectionDebugId() {
7373
8184
  return `MC-${this.id.substring(0, 4)}`;
7374
8185
  }
7375
8186
 
8187
+ /**
8188
+ * Checks if the error indicates that Locus dropped us from the meeting,
8189
+ * either directly on the error or wrapped inside an AddMediaFailed cause.
8190
+ * This method is meant to be called only with errors thrown by Meeting.addMediaInternal()
8191
+ *
8192
+ * @param {Error} error
8193
+ * @returns {boolean}
8194
+ */
8195
+ private isErrorMeaningLocusDroppedUs(error: Error | undefined): boolean {
8196
+ const statusCode = (error as any)?.statusCode;
8197
+ const causeStatusCode = (error as any)?.cause?.statusCode;
8198
+
8199
+ return (
8200
+ statusCode === 409 || statusCode === 403 || causeStatusCode === 409 || causeStatusCode === 403
8201
+ );
8202
+ }
8203
+
8204
+ private isLocusUserFullError(error: Error | undefined): boolean {
8205
+ return (error as any)?.error?.body?.errorCode === LocusErrorCodes.LOCUS_USER_FULL;
8206
+ }
8207
+
8208
+ /**
8209
+ * Determines if the next media attempt should use only TURN-TLS (iceTransportPolicy='relay').
8210
+ * We do this in the hope that it will minimize the chance of Homer sending DTLS packets on a wrong
8211
+ * transport (as there will be only 1 transport) and dealing with firewalls that let STUN packets through, but block
8212
+ * other UDP traffic.
8213
+ *
8214
+ * For clients landing on video mesh nodes (VMN), reachability might still have successful TLS (to public nodes)
8215
+ * but TURN discovery will result in empty TURN urls array and iceTransportPolicy='relay' will still be overriden to undefined,
8216
+ * see the code in establishMediaConnection()
8217
+ *
8218
+ * @param {Error} prevError - The error from the previous addMedia attempt
8219
+ * @returns {Promise<boolean>}
8220
+ */
8221
+ private async shouldRetryMediaWithOnlyTurnTLS(prevError: Error | undefined): Promise<boolean> {
8222
+ if (
8223
+ this.isMultistream &&
8224
+ prevError instanceof AddMediaFailed &&
8225
+ prevError.isDtlsHandshakeFailure &&
8226
+ prevError.connectionType === 'UDP'
8227
+ ) {
8228
+ const hasTlsReachability =
8229
+ // @ts-ignore
8230
+ await this.webex.meetings.reachability.isAnyClusterReachableViaProtocol('xtls');
8231
+
8232
+ if (hasTlsReachability) {
8233
+ LoggerProxy.logger.info(
8234
+ 'Meeting:index#shouldRetryMediaWithOnlyTurnTLS --> previous attempt failed due to DTLS handshake failure over UDP and TLS reachability is available'
8235
+ );
8236
+
8237
+ return true;
8238
+ }
8239
+ }
8240
+
8241
+ return false;
8242
+ }
8243
+
7376
8244
  /**
7377
8245
  * Creates a webrtc media connection and publishes streams to it
7378
8246
  *
7379
8247
  * @param {Object} turnServerInfo TURN server information
7380
8248
  * @param {BundlePolicy} [bundlePolicy] Bundle policy settings
7381
- * @param {AddMediaOptions} [options] Options for enabling/disabling audio/video
8249
+ * @param {RTCIceTransportPolicy} [iceTransportPolicy] ICE transport policy override
7382
8250
  * @returns {RoapMediaConnection | MultistreamRoapMediaConnection}
7383
8251
  */
7384
8252
  private async createMediaConnection(
7385
8253
  turnServerInfo?: TurnServerInfo,
7386
- bundlePolicy?: BundlePolicy
8254
+ bundlePolicy?: BundlePolicy,
8255
+ iceTransportPolicy?: RTCIceTransportPolicy
7387
8256
  ) {
7388
8257
  this.rtcMetrics = this.isMultistream
7389
8258
  ? // @ts-ignore
@@ -7407,12 +8276,15 @@ export default class Meeting extends StatelessWebexPlugin {
7407
8276
  enableExtmap: this.config.enableExtmap,
7408
8277
  turnServerInfo,
7409
8278
  bundlePolicy,
8279
+ iceTransportPolicy,
7410
8280
  // @ts-ignore - config coming from registerPlugin
7411
8281
  iceCandidatesTimeout: this.config.iceCandidatesGatheringTimeout,
7412
8282
  // @ts-ignore - config coming from registerPlugin
7413
8283
  disableAudioMainDtx: this.config.experimental.disableAudioMainDtx,
7414
8284
  // @ts-ignore - config coming from registerPlugin
7415
8285
  enableAudioTwcc: this.config.enableAudioTwccForMultistream,
8286
+ // @ts-ignore - config coming from registerPlugin
8287
+ enableAv1SlidesSupport: this.config.enableAv1SlidesSupport,
7416
8288
  stopIceGatheringAfterFirstRelayCandidate:
7417
8289
  // @ts-ignore - config coming from registerPlugin
7418
8290
  this.config.stopIceGatheringAfterFirstRelayCandidate,
@@ -7432,6 +8304,7 @@ export default class Meeting extends StatelessWebexPlugin {
7432
8304
  this.mediaProperties.mediaDirection.receiveShare,
7433
8305
  ];
7434
8306
 
8307
+ this.sendSlotManager.reset();
7435
8308
  this.sendSlotManager.createSlot(mc, MediaType.VideoMain, videoEnabled);
7436
8309
  this.sendSlotManager.createSlot(mc, MediaType.AudioMain, audioEnabled);
7437
8310
  this.sendSlotManager.createSlot(mc, MediaType.VideoSlides, shareEnabled);
@@ -7531,7 +8404,7 @@ export default class Meeting extends StatelessWebexPlugin {
7531
8404
  try {
7532
8405
  await this.mediaProperties.waitForMediaConnectionConnected(this.correlationId);
7533
8406
  } catch (error) {
7534
- const {iceConnected} = error;
8407
+ const {iceConnected} = error as MediaConnectionAwaiterFailureResult;
7535
8408
 
7536
8409
  if (!this.hasMediaConnectionConnectedAtLeastOnce) {
7537
8410
  // Only send CA event for join flow if we haven't successfully connected media yet
@@ -7571,13 +8444,12 @@ export default class Meeting extends StatelessWebexPlugin {
7571
8444
  });
7572
8445
  }
7573
8446
 
7574
- const timedOutError = new Error(
7575
- `Timed out waiting for media connection to be connected, correlationId=${this.correlationId}`
8447
+ throw new MediaConnectionTimedOutError(
8448
+ `Timed out waiting for media connection to be connected, correlationId=${this.correlationId}`,
8449
+ iceConnected,
8450
+ // keep reference to the original rejected result (which is the object the SDK reports to CA as rawError above)
8451
+ error
7576
8452
  );
7577
-
7578
- timedOutError.cause = error;
7579
-
7580
- throw timedOutError;
7581
8453
  }
7582
8454
  }
7583
8455
 
@@ -7623,12 +8495,12 @@ export default class Meeting extends StatelessWebexPlugin {
7623
8495
  return !member.isSelf && !member.isPairedWithSelf && !member.isAudioMuted;
7624
8496
  });
7625
8497
 
7626
- if (atLeastOneUnmutedOtherMember) {
7627
- this.mediaProperties.sendMediaIssueMetric(
7628
- 'inbound_audio',
7629
- data.issueSubType,
7630
- this.correlationId
7631
- );
8498
+ // we also ignore any issues while we're waiting in the lobby, as we're not receiving any audio yet
8499
+ if (atLeastOneUnmutedOtherMember && !this.isUserUnadmitted) {
8500
+ this.mediaProperties.sendMediaIssueMetric('inbound_audio', data.issueSubType, {
8501
+ correlationId: this.correlationId,
8502
+ isMultistream: this.isMultistream,
8503
+ });
7632
8504
 
7633
8505
  Trigger.trigger(
7634
8506
  this,
@@ -7790,7 +8662,20 @@ export default class Meeting extends StatelessWebexPlugin {
7790
8662
  error
7791
8663
  );
7792
8664
 
7793
- throw new AddMediaFailed(error);
8665
+ const {connectionType, selectedCandidatePairChanges, numTransports} =
8666
+ await this.mediaProperties.getCurrentConnectionInfo();
8667
+
8668
+ const iceConnected = error instanceof MediaConnectionTimedOutError && error.iceConnected;
8669
+
8670
+ throw new AddMediaFailed({
8671
+ cause: error,
8672
+ connectionType,
8673
+ selectedCandidatePairChanges,
8674
+ numTransports,
8675
+ iceConnected,
8676
+ iceConnectedAtLeastOnce:
8677
+ error instanceof MediaConnectionTimedOutError ? error.iceConnectedAtLeastOnce : undefined,
8678
+ });
7794
8679
  }
7795
8680
  }
7796
8681
 
@@ -7865,7 +8750,21 @@ export default class Meeting extends StatelessWebexPlugin {
7865
8750
  ({turnServerInfo} = await this.doTurnDiscovery(isReconnecting, isForced));
7866
8751
  }
7867
8752
 
7868
- const mc = await this.createMediaConnection(turnServerInfo, bundlePolicy);
8753
+ if (
8754
+ (!turnServerInfo || !turnServerInfo.urls?.length) &&
8755
+ this.addMediaData.iceTransportPolicy === 'relay'
8756
+ ) {
8757
+ LoggerProxy.logger.info(
8758
+ `${LOG_HEADER} cannot do iceTransportPolicy=relay, because there is no turn server info available`
8759
+ );
8760
+ // drop the forced relay policy and use the default, because we don't have a TURN server
8761
+ this.addMediaData.iceTransportPolicy = undefined;
8762
+ }
8763
+ const mediaConnection = await this.createMediaConnection(
8764
+ turnServerInfo,
8765
+ bundlePolicy,
8766
+ this.addMediaData.iceTransportPolicy
8767
+ );
7869
8768
 
7870
8769
  LoggerProxy.logger.info(
7871
8770
  `${LOG_HEADER} media connection created this.isMultistream=${this.isMultistream}`
@@ -7902,7 +8801,7 @@ export default class Meeting extends StatelessWebexPlugin {
7902
8801
  await this.remoteMediaManager.start();
7903
8802
  }
7904
8803
 
7905
- await mc.initiateOffer();
8804
+ await mediaConnection.initiateOffer();
7906
8805
 
7907
8806
  await this.waitForRemoteSDPAnswer();
7908
8807
 
@@ -7970,6 +8869,9 @@ export default class Meeting extends StatelessWebexPlugin {
7970
8869
 
7971
8870
  this.isMultistream = false;
7972
8871
 
8872
+ // reset iceTransportPolicy, because it's only applied for multistream media connections
8873
+ this.addMediaData.iceTransportPolicy = undefined;
8874
+
7973
8875
  if (this.mediaProperties.webrtcMediaConnection) {
7974
8876
  // close peer connection, but don't reset mute state information, because we will want to use it on the retry
7975
8877
  this.closePeerConnections(false);
@@ -8050,6 +8952,8 @@ export default class Meeting extends StatelessWebexPlugin {
8050
8952
  regionCode: this.webex.meetings.geoHintInfo?.regionCode,
8051
8953
  },
8052
8954
  preferTranscoding: !this.isMultistream,
8955
+ getCurrentSelfUrl: () => this.selfUrl,
8956
+ waitForSelfUrlChange: () => this.waitForSelfUrlChange(),
8053
8957
  },
8054
8958
  {
8055
8959
  // @ts-ignore
@@ -8058,6 +8962,41 @@ export default class Meeting extends StatelessWebexPlugin {
8058
8962
  );
8059
8963
  }
8060
8964
 
8965
+ /**
8966
+ * Waits for LocusInfo to update meeting.selfUrl, with a timeout fallback.
8967
+ * @returns {Promise<void>}
8968
+ * @private
8969
+ * @memberof Meeting
8970
+ */
8971
+ private waitForSelfUrlChange(): Promise<void> {
8972
+ if (this.joinWithMediaRetryInfo.retryCount > 0) {
8973
+ /* During joinWithMedia() retries we can get 403/409 from Locus and it doesn't mean
8974
+ * that the selfUrl will change, it is usually caused by Locus dropping us as a result of
8975
+ * media connection failure during joinWithMedia's earlier media connection attempt,
8976
+ * so we don't want to wait for selfUrl change as this would only slow down the join process. */
8977
+ LoggerProxy.logger.info(
8978
+ 'Meeting:index#waitForSelfUrlChange --> joinWithMedia retry in progress, will not wait for selfUrl change'
8979
+ );
8980
+
8981
+ return Promise.resolve();
8982
+ }
8983
+
8984
+ if (!this.promisesWaitingForPropUpdate.selfUrl) {
8985
+ const pendingSelfUrlUpdate = new Defer();
8986
+
8987
+ this.promisesWaitingForPropUpdate.selfUrl = pendingSelfUrlUpdate;
8988
+
8989
+ setTimeout(() => {
8990
+ if (this.promisesWaitingForPropUpdate.selfUrl === pendingSelfUrlUpdate) {
8991
+ delete this.promisesWaitingForPropUpdate.selfUrl;
8992
+ pendingSelfUrlUpdate.resolve();
8993
+ }
8994
+ }, 5000);
8995
+ }
8996
+
8997
+ return this.promisesWaitingForPropUpdate.selfUrl.promise;
8998
+ }
8999
+
8061
9000
  /**
8062
9001
  * Creates a media connection to the server. Media connection is required for sending or receiving any audio/video.
8063
9002
  *
@@ -8069,8 +9008,9 @@ export default class Meeting extends StatelessWebexPlugin {
8069
9008
  addMedia(options: AddMediaOptions = {}): Promise<void> {
8070
9009
  return this.addMediaInternal(
8071
9010
  () => (this.turnServerUsed ? 'JOIN_MEETING_FINAL' : 'JOIN_MEETING_RETRY'),
8072
- undefined,
8073
9011
  false,
9012
+ undefined /* turnServerInfo - it will be fetched via doTurnDiscovery() */,
9013
+ undefined /* iceTransportPolicy - we're relying on the default value */,
8074
9014
  options
8075
9015
  );
8076
9016
  }
@@ -8079,8 +9019,9 @@ export default class Meeting extends StatelessWebexPlugin {
8079
9019
  * Internal version of addMedia() with some more arguments for finer control of its behavior
8080
9020
  *
8081
9021
  * @param {Function} icePhaseCallback - callback to determine the icePhase for CA "client.ice.end" failure events
8082
- * @param {TurnServerInfo} turnServerInfo - TURN server information
8083
9022
  * @param {boolean} forceTurnDiscovery - if true, TURN discovery will be done
9023
+ * @param {TurnServerInfo} turnServerInfo - TURN server information
9024
+ * @param {RTCIceTransportPolicy} [iceTransportPolicy] - ICE transport policy override
8084
9025
  * @param {AddMediaOptions} options - same as options of the public addMedia() method
8085
9026
  * @returns {Promise<void>}
8086
9027
  * @protected
@@ -8088,21 +9029,30 @@ export default class Meeting extends StatelessWebexPlugin {
8088
9029
  */
8089
9030
  protected async addMediaInternal(
8090
9031
  icePhaseCallback: () => string,
8091
- turnServerInfo: TurnServerInfo,
8092
- forceTurnDiscovery,
9032
+ forceTurnDiscovery: boolean,
9033
+ turnServerInfo?: TurnServerInfo,
9034
+ iceTransportPolicy?: RTCIceTransportPolicy,
8093
9035
  options: AddMediaOptions = {}
8094
9036
  ): Promise<void> {
8095
9037
  this.addMediaData.retriedWithTurnServer = false;
8096
9038
  this.addMediaData.icePhaseCallback = icePhaseCallback;
9039
+ this.addMediaData.iceTransportPolicy = iceTransportPolicy;
8097
9040
 
8098
9041
  this.hasMediaConnectionConnectedAtLeastOnce = false;
8099
9042
  const LOG_HEADER = 'Meeting:index#addMedia -->';
9043
+ const optionsForLogging = {
9044
+ ...options,
9045
+ remoteMediaManagerConfig: getRemoteMediaManagerConfigForLogging(
9046
+ options.remoteMediaManagerConfig
9047
+ ),
9048
+ };
9049
+
8100
9050
  LoggerProxy.logger.info(
8101
9051
  `${LOG_HEADER} called with: options=${JSON.stringify(
8102
- options
9052
+ optionsForLogging
8103
9053
  )}, turnServerInfo=${JSON.stringify(
8104
9054
  turnServerInfo
8105
- )}, forceTurnDiscovery=${forceTurnDiscovery}`
9055
+ )}, forceTurnDiscovery=${forceTurnDiscovery}, iceTransportPolicy=${iceTransportPolicy}`
8106
9056
  );
8107
9057
 
8108
9058
  if (options.allowMediaInLobby !== true && this.meetingState !== FULL_STATE.ACTIVE) {
@@ -8216,12 +9166,7 @@ export default class Meeting extends StatelessWebexPlugin {
8216
9166
 
8217
9167
  // Establish new media connection with forced TURN discovery
8218
9168
  // We need to do TURN discovery again, because backend will be creating a new confluence, so it might land on a different node or cluster
8219
- await this.establishMediaConnection(
8220
- remoteMediaManagerConfig,
8221
- bundlePolicy,
8222
- true,
8223
- undefined
8224
- );
9169
+ await this.establishMediaConnection(remoteMediaManagerConfig, bundlePolicy, true);
8225
9170
  } else {
8226
9171
  throw error;
8227
9172
  }
@@ -8250,7 +9195,8 @@ export default class Meeting extends StatelessWebexPlugin {
8250
9195
  numTransports,
8251
9196
  isMultistream: this.isMultistream,
8252
9197
  retriedWithTurnServer: this.addMediaData.retriedWithTurnServer,
8253
- isJoinWithMediaRetry: this.joinWithMediaRetryInfo.isRetry,
9198
+ isJoinWithMediaRetry: this.joinWithMediaRetryInfo.retryCount > 0,
9199
+ iceTransportPolicy: this.addMediaData.iceTransportPolicy || 'all',
8254
9200
  ...reachabilityMetrics,
8255
9201
  ...iceCandidateErrors,
8256
9202
  iceCandidatesCount: this.iceCandidatesCount,
@@ -8272,14 +9218,16 @@ export default class Meeting extends StatelessWebexPlugin {
8272
9218
  // We can log ReceiveSlot SSRCs only after the SDP exchange, so doing it here:
8273
9219
  this.remoteMediaManager?.logAllReceiveSlots();
8274
9220
  this.startPeriodicLogUpload();
8275
- } catch (error) {
9221
+ } catch (error: any) {
8276
9222
  LoggerProxy.logger.error(`${LOG_HEADER} failed to establish media connection: `, error);
8277
9223
 
8278
9224
  // @ts-ignore
8279
9225
  const reachabilityMetrics = await this.getMediaReachabilityMetricFields();
8280
9226
 
8281
- const {selectedCandidatePairChanges, numTransports} =
8282
- await this.mediaProperties.getCurrentConnectionInfo();
9227
+ const {connectionType, selectedCandidatePairChanges, numTransports} =
9228
+ error instanceof AddMediaFailed
9229
+ ? error
9230
+ : await this.mediaProperties.getCurrentConnectionInfo();
8283
9231
 
8284
9232
  const iceCandidateErrors = Object.fromEntries(this.iceCandidateErrors);
8285
9233
 
@@ -8295,7 +9243,8 @@ export default class Meeting extends StatelessWebexPlugin {
8295
9243
  turnServerUsed: this.turnServerUsed,
8296
9244
  retriedWithTurnServer: this.addMediaData.retriedWithTurnServer,
8297
9245
  isMultistream: this.isMultistream,
8298
- isJoinWithMediaRetry: this.joinWithMediaRetryInfo.isRetry,
9246
+ isJoinWithMediaRetry: this.joinWithMediaRetryInfo.retryCount > 0,
9247
+ iceTransportPolicy: this.addMediaData.iceTransportPolicy || 'all',
8299
9248
  signalingState:
8300
9249
  this.mediaProperties.webrtcMediaConnection?.multistreamConnection?.pc?.pc
8301
9250
  ?.signalingState ||
@@ -8311,6 +9260,7 @@ export default class Meeting extends StatelessWebexPlugin {
8311
9260
  ?.iceConnectionState ||
8312
9261
  this.mediaProperties.webrtcMediaConnection?.mediaConnection?.pc?.iceConnectionState ||
8313
9262
  'unknown',
9263
+ connectionType,
8314
9264
  ...reachabilityMetrics,
8315
9265
  ...iceCandidateErrors,
8316
9266
  iceCandidatesCount: this.iceCandidatesCount,
@@ -8659,6 +9609,7 @@ export default class Meeting extends StatelessWebexPlugin {
8659
9609
  options: {meetingId: this.id},
8660
9610
  });
8661
9611
  LoggerProxy.logger.log('Meeting:index#leave --> Leaving a meeting');
9612
+ this.stopListeningForMeetingEvents();
8662
9613
 
8663
9614
  return MeetingUtil.leaveMeeting(this, options)
8664
9615
  .then(async (leave) => {
@@ -9524,6 +10475,8 @@ export default class Meeting extends StatelessWebexPlugin {
9524
10475
  locus_id: this.locusId,
9525
10476
  });
9526
10477
 
10478
+ this.stopListeningForMeetingEvents();
10479
+
9527
10480
  return MeetingUtil.endMeetingForAll(this)
9528
10481
  .then(async (end) => {
9529
10482
  this.meetingFiniteStateMachine.end();
@@ -9585,14 +10538,14 @@ export default class Meeting extends StatelessWebexPlugin {
9585
10538
  }
9586
10539
  this.queuedMediaUpdates = [];
9587
10540
 
9588
- if (this.transcription) {
9589
- this.stopTranscription();
9590
- this.transcription = undefined;
9591
- }
9592
-
9593
- this.annotation.deregisterEvents();
10541
+ // Listener teardown (transcription, annotation, llm/mercury) runs in
10542
+ // stopListeningForMeetingEvents() before /leave and /end so events
10543
+ // received mid-teardown do not trigger Locus syncs.
10544
+ // Token cleanup happens automatically when cleanupLLMConneciton destroys the channel.
10545
+ // A new voiceaChannel is created on the next join. In-session LLM reconnects and
10546
+ // practice-session transitions use their own cleanup paths and preserve the channel.
9594
10547
 
9595
- await this.cleanupLLMConneciton({throwOnError: false});
10548
+ await this.cleanupLLMConneciton({throwOnError: false, preserveVoiceaChannel: false});
9596
10549
  };
9597
10550
 
9598
10551
  /**
@@ -9668,15 +10621,12 @@ export default class Meeting extends StatelessWebexPlugin {
9668
10621
  * @public
9669
10622
  * @memberof Meeting
9670
10623
  */
9671
- public sendReaction(reactionType: ReactionServerType, skinToneType?: SkinToneType) {
10624
+ public sendReaction(reactionType: string, skinToneType?: SkinToneType) {
9672
10625
  const reactionChannelUrl = this.locusInfo?.controls?.reactions?.reactionChannelUrl as string;
9673
10626
  const participantId = this.members.selfId;
9674
10627
 
9675
- const reactionData = Reactions[reactionType];
10628
+ const reactionData = Reactions[reactionType] || {type: reactionType};
9676
10629
 
9677
- if (!reactionData) {
9678
- return Promise.reject(new Error(`${reactionType} is not a valid reaction.`));
9679
- }
9680
10630
  const skinToneData = SkinTones[skinToneType] || SkinTones.normal;
9681
10631
  const reaction: Reaction = {
9682
10632
  ...reactionData,
@@ -9785,15 +10735,20 @@ export default class Meeting extends StatelessWebexPlugin {
9785
10735
  }
9786
10736
 
9787
10737
  if (shouldEnableMusicMode) {
9788
- await this.sendSlotManager.setCodecParameters(MediaType.AudioMain, {
9789
- maxaveragebitrate: '64000',
9790
- maxplaybackrate: '48000',
9791
- });
10738
+ await this.sendSlotManager.setCustomCodecParameters(
10739
+ MediaType.AudioMain,
10740
+ MediaCodecMimeType.OPUS,
10741
+ {
10742
+ maxaveragebitrate: '64000',
10743
+ maxplaybackrate: '48000',
10744
+ }
10745
+ );
9792
10746
  } else {
9793
- await this.sendSlotManager.deleteCodecParameters(MediaType.AudioMain, [
9794
- 'maxaveragebitrate',
9795
- 'maxplaybackrate',
9796
- ]);
10747
+ await this.sendSlotManager.markCustomCodecParametersForDeletion(
10748
+ MediaType.AudioMain,
10749
+ MediaCodecMimeType.OPUS,
10750
+ ['maxaveragebitrate', 'maxplaybackrate']
10751
+ );
9797
10752
  }
9798
10753
  }
9799
10754
 
@@ -10326,6 +11281,34 @@ export default class Meeting extends StatelessWebexPlugin {
10326
11281
  }
10327
11282
  }
10328
11283
 
11284
+ /**
11285
+ * Checks if the LLM channel is connected.
11286
+ * Handles practice session context automatically - returns practice session
11287
+ * LLM channel status when in practice session, main LLM channel status otherwise.
11288
+ * @returns {boolean} True if the appropriate LLM channel is connected
11289
+ */
11290
+ public isLLMConnected(): boolean {
11291
+ if (this.webinar?.isJoinPracticeSessionDataChannel()) {
11292
+ return this.webinar.isPracticeSessionLLMChannelConnected();
11293
+ }
11294
+
11295
+ return this.llmChannel?.isConnected() ?? false;
11296
+ }
11297
+
11298
+ /**
11299
+ * Gets the locus URL from the LLM channel.
11300
+ * Handles practice session context automatically - returns practice session
11301
+ * LLM channel's locus URL when in practice session, main LLM channel's locus URL otherwise.
11302
+ * @returns {string | undefined} The locus URL or undefined
11303
+ */
11304
+ public getLLMLocusUrl(): string | undefined {
11305
+ if (this.webinar?.isJoinPracticeSessionDataChannel()) {
11306
+ return this.webinar.getPracticeSessionLocusUrl();
11307
+ }
11308
+
11309
+ return this.llmChannel?.getLocusUrl();
11310
+ }
11311
+
10329
11312
  /**
10330
11313
  * Determines the current data channel token type based on the meeting state.
10331
11314
  *