@webex/plugin-meetings 3.11.0 → 3.12.0-llmrefactor.1

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 (294) hide show
  1. package/AGENTS.md +9 -0
  2. package/dist/aiEnableRequest/index.js +197 -0
  3. package/dist/aiEnableRequest/index.js.map +1 -0
  4. package/dist/aiEnableRequest/utils.js +36 -0
  5. package/dist/aiEnableRequest/utils.js.map +1 -0
  6. package/dist/annotation/index.js +58 -13
  7. package/dist/annotation/index.js.map +1 -1
  8. package/dist/breakouts/breakout.js +8 -3
  9. package/dist/breakouts/breakout.js.map +1 -1
  10. package/dist/breakouts/events.js +29 -14
  11. package/dist/breakouts/events.js.map +1 -1
  12. package/dist/breakouts/index.js +124 -7
  13. package/dist/breakouts/index.js.map +1 -1
  14. package/dist/common/errors/webex-errors.js +49 -5
  15. package/dist/common/errors/webex-errors.js.map +1 -1
  16. package/dist/config.js +8 -3
  17. package/dist/config.js.map +1 -1
  18. package/dist/constants.js +60 -11
  19. package/dist/constants.js.map +1 -1
  20. package/dist/controls-options-manager/constants.js +11 -1
  21. package/dist/controls-options-manager/constants.js.map +1 -1
  22. package/dist/controls-options-manager/index.js +67 -29
  23. package/dist/controls-options-manager/index.js.map +1 -1
  24. package/dist/controls-options-manager/util.js +91 -0
  25. package/dist/controls-options-manager/util.js.map +1 -1
  26. package/dist/hashTree/constants.js +16 -2
  27. package/dist/hashTree/constants.js.map +1 -1
  28. package/dist/hashTree/hashTree.js +18 -0
  29. package/dist/hashTree/hashTree.js.map +1 -1
  30. package/dist/hashTree/hashTreeParser.js +1655 -538
  31. package/dist/hashTree/hashTreeParser.js.map +1 -1
  32. package/dist/hashTree/types.js +4 -2
  33. package/dist/hashTree/types.js.map +1 -1
  34. package/dist/hashTree/utils.js +52 -0
  35. package/dist/hashTree/utils.js.map +1 -1
  36. package/dist/index.js +18 -2
  37. package/dist/index.js.map +1 -1
  38. package/dist/interceptors/constant.js +12 -0
  39. package/dist/interceptors/constant.js.map +1 -0
  40. package/dist/interceptors/dataChannelAuthToken.js +332 -0
  41. package/dist/interceptors/dataChannelAuthToken.js.map +1 -0
  42. package/dist/interceptors/index.js +7 -0
  43. package/dist/interceptors/index.js.map +1 -1
  44. package/dist/interceptors/locusRetry.js +23 -8
  45. package/dist/interceptors/locusRetry.js.map +1 -1
  46. package/dist/interceptors/utils.js +27 -0
  47. package/dist/interceptors/utils.js.map +1 -0
  48. package/dist/interpretation/index.js +11 -2
  49. package/dist/interpretation/index.js.map +1 -1
  50. package/dist/interpretation/interpretation.types.js +7 -0
  51. package/dist/interpretation/interpretation.types.js.map +1 -0
  52. package/dist/interpretation/siLanguage.js +1 -1
  53. package/dist/locus-info/controlsUtils.js +9 -4
  54. package/dist/locus-info/controlsUtils.js.map +1 -1
  55. package/dist/locus-info/index.js +914 -212
  56. package/dist/locus-info/index.js.map +1 -1
  57. package/dist/locus-info/infoUtils.js +36 -5
  58. package/dist/locus-info/infoUtils.js.map +1 -1
  59. package/dist/locus-info/selfUtils.js +1 -0
  60. package/dist/locus-info/selfUtils.js.map +1 -1
  61. package/dist/locus-info/types.js +19 -0
  62. package/dist/locus-info/types.js.map +1 -1
  63. package/dist/media/MediaConnectionAwaiter.js +72 -3
  64. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  65. package/dist/media/index.js +8 -2
  66. package/dist/media/index.js.map +1 -1
  67. package/dist/media/properties.js +8 -7
  68. package/dist/media/properties.js.map +1 -1
  69. package/dist/meeting/in-meeting-actions.js +11 -1
  70. package/dist/meeting/in-meeting-actions.js.map +1 -1
  71. package/dist/meeting/index.js +2287 -1118
  72. package/dist/meeting/index.js.map +1 -1
  73. package/dist/meeting/locusMediaRequest.js +229 -82
  74. package/dist/meeting/locusMediaRequest.js.map +1 -1
  75. package/dist/meeting/muteState.js +10 -1
  76. package/dist/meeting/muteState.js.map +1 -1
  77. package/dist/meeting/request.js +55 -2
  78. package/dist/meeting/request.js.map +1 -1
  79. package/dist/meeting/request.type.js.map +1 -1
  80. package/dist/meeting/util.js +168 -5
  81. package/dist/meeting/util.js.map +1 -1
  82. package/dist/meeting-info/meeting-info-v2.js +2 -2
  83. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  84. package/dist/meetings/index.js +369 -162
  85. package/dist/meetings/index.js.map +1 -1
  86. package/dist/meetings/meetings.types.js +6 -1
  87. package/dist/meetings/meetings.types.js.map +1 -1
  88. package/dist/meetings/request.js +39 -0
  89. package/dist/meetings/request.js.map +1 -1
  90. package/dist/meetings/util.js +116 -18
  91. package/dist/meetings/util.js.map +1 -1
  92. package/dist/member/index.js +20 -0
  93. package/dist/member/index.js.map +1 -1
  94. package/dist/member/types.js.map +1 -1
  95. package/dist/member/util.js +40 -0
  96. package/dist/member/util.js.map +1 -1
  97. package/dist/members/index.js +101 -43
  98. package/dist/members/index.js.map +1 -1
  99. package/dist/members/util.js +8 -1
  100. package/dist/members/util.js.map +1 -1
  101. package/dist/metrics/constants.js +12 -1
  102. package/dist/metrics/constants.js.map +1 -1
  103. package/dist/multistream/codec/constants.js +63 -0
  104. package/dist/multistream/codec/constants.js.map +1 -0
  105. package/dist/multistream/mediaRequestManager.js +64 -68
  106. package/dist/multistream/mediaRequestManager.js.map +1 -1
  107. package/dist/multistream/receiveSlot.js +9 -0
  108. package/dist/multistream/receiveSlot.js.map +1 -1
  109. package/dist/multistream/remoteMediaManager.js +11 -0
  110. package/dist/multistream/remoteMediaManager.js.map +1 -1
  111. package/dist/multistream/sendSlotManager.js +116 -2
  112. package/dist/multistream/sendSlotManager.js.map +1 -1
  113. package/dist/reachability/clusterReachability.js.map +1 -1
  114. package/dist/reachability/index.js +139 -93
  115. package/dist/reachability/index.js.map +1 -1
  116. package/dist/reachability/reachability.types.js +2 -0
  117. package/dist/reachability/reachability.types.js.map +1 -1
  118. package/dist/reachability/util.js +45 -0
  119. package/dist/reachability/util.js.map +1 -1
  120. package/dist/reactions/reactions.type.js.map +1 -1
  121. package/dist/reconnection-manager/index.js +0 -1
  122. package/dist/reconnection-manager/index.js.map +1 -1
  123. package/dist/recording-controller/index.js +1 -3
  124. package/dist/recording-controller/index.js.map +1 -1
  125. package/dist/roap/turnDiscovery.js +8 -1
  126. package/dist/roap/turnDiscovery.js.map +1 -1
  127. package/dist/types/aiEnableRequest/index.d.ts +5 -0
  128. package/dist/types/aiEnableRequest/utils.d.ts +2 -0
  129. package/dist/types/annotation/index.d.ts +19 -0
  130. package/dist/types/common/errors/webex-errors.d.ts +32 -2
  131. package/dist/types/config.d.ts +6 -2
  132. package/dist/types/constants.d.ts +35 -1
  133. package/dist/types/controls-options-manager/constants.d.ts +6 -1
  134. package/dist/types/controls-options-manager/index.d.ts +16 -0
  135. package/dist/types/hashTree/constants.d.ts +3 -0
  136. package/dist/types/hashTree/hashTree.d.ts +7 -0
  137. package/dist/types/hashTree/hashTreeParser.d.ts +315 -30
  138. package/dist/types/hashTree/types.d.ts +3 -0
  139. package/dist/types/hashTree/utils.d.ts +24 -0
  140. package/dist/types/index.d.ts +4 -0
  141. package/dist/types/interceptors/constant.d.ts +5 -0
  142. package/dist/types/interceptors/dataChannelAuthToken.d.ts +43 -0
  143. package/dist/types/interceptors/index.d.ts +2 -1
  144. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  145. package/dist/types/interceptors/utils.d.ts +1 -0
  146. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  147. package/dist/types/locus-info/index.d.ts +126 -15
  148. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  149. package/dist/types/locus-info/types.d.ts +28 -1
  150. package/dist/types/media/MediaConnectionAwaiter.d.ts +20 -2
  151. package/dist/types/media/properties.d.ts +8 -3
  152. package/dist/types/meeting/in-meeting-actions.d.ts +10 -0
  153. package/dist/types/meeting/index.d.ts +271 -16
  154. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  155. package/dist/types/meeting/request.d.ts +17 -1
  156. package/dist/types/meeting/request.type.d.ts +5 -0
  157. package/dist/types/meeting/util.d.ts +40 -0
  158. package/dist/types/meetings/index.d.ts +42 -20
  159. package/dist/types/meetings/meetings.types.d.ts +15 -0
  160. package/dist/types/meetings/request.d.ts +14 -0
  161. package/dist/types/member/index.d.ts +2 -0
  162. package/dist/types/member/types.d.ts +1 -0
  163. package/dist/types/member/util.d.ts +14 -0
  164. package/dist/types/members/index.d.ts +15 -2
  165. package/dist/types/members/util.d.ts +1 -5
  166. package/dist/types/metrics/constants.d.ts +11 -0
  167. package/dist/types/multistream/codec/constants.d.ts +7 -0
  168. package/dist/types/multistream/mediaRequestManager.d.ts +20 -26
  169. package/dist/types/multistream/sendSlotManager.d.ts +23 -1
  170. package/dist/types/reachability/clusterReachability.d.ts +3 -3
  171. package/dist/types/reachability/index.d.ts +10 -3
  172. package/dist/types/reachability/reachability.types.d.ts +7 -0
  173. package/dist/types/reachability/util.d.ts +17 -0
  174. package/dist/types/reactions/reactions.type.d.ts +4 -0
  175. package/dist/types/webinar/utils.d.ts +6 -0
  176. package/dist/webinar/index.js +611 -164
  177. package/dist/webinar/index.js.map +1 -1
  178. package/dist/webinar/utils.js +25 -0
  179. package/dist/webinar/utils.js.map +1 -0
  180. package/package.json +24 -23
  181. package/src/aiEnableRequest/README.md +84 -0
  182. package/src/aiEnableRequest/index.ts +186 -0
  183. package/src/aiEnableRequest/utils.ts +25 -0
  184. package/src/annotation/index.ts +62 -12
  185. package/src/breakouts/breakout.ts +3 -1
  186. package/src/breakouts/events.ts +33 -11
  187. package/src/breakouts/index.ts +143 -3
  188. package/src/common/errors/webex-errors.ts +50 -3
  189. package/src/config.ts +6 -2
  190. package/src/constants.ts +49 -3
  191. package/src/controls-options-manager/constants.ts +14 -1
  192. package/src/controls-options-manager/index.ts +87 -28
  193. package/src/controls-options-manager/util.ts +81 -1
  194. package/src/hashTree/constants.ts +17 -0
  195. package/src/hashTree/hashTree.ts +17 -0
  196. package/src/hashTree/hashTreeParser.ts +1482 -361
  197. package/src/hashTree/types.ts +4 -0
  198. package/src/hashTree/utils.ts +45 -0
  199. package/src/index.ts +14 -1
  200. package/src/interceptors/constant.ts +6 -0
  201. package/src/interceptors/dataChannelAuthToken.ts +217 -0
  202. package/src/interceptors/index.ts +2 -1
  203. package/src/interceptors/locusRetry.ts +25 -4
  204. package/src/interceptors/utils.ts +16 -0
  205. package/src/interpretation/index.ts +29 -11
  206. package/src/interpretation/interpretation.types.ts +11 -0
  207. package/src/locus-info/controlsUtils.ts +14 -1
  208. package/src/locus-info/index.ts +976 -203
  209. package/src/locus-info/infoUtils.ts +41 -6
  210. package/src/locus-info/selfUtils.ts +1 -0
  211. package/src/locus-info/types.ts +33 -1
  212. package/src/media/MediaConnectionAwaiter.ts +62 -5
  213. package/src/media/index.ts +10 -1
  214. package/src/media/properties.ts +11 -4
  215. package/src/meeting/in-meeting-actions.ts +20 -0
  216. package/src/meeting/index.ts +1258 -222
  217. package/src/meeting/locusMediaRequest.ts +106 -6
  218. package/src/meeting/muteState.ts +10 -1
  219. package/src/meeting/request.ts +53 -0
  220. package/src/meeting/request.type.ts +6 -0
  221. package/src/meeting/util.ts +207 -7
  222. package/src/meeting-info/meeting-info-v2.ts +4 -2
  223. package/src/meetings/index.ts +319 -117
  224. package/src/meetings/meetings.types.ts +19 -0
  225. package/src/meetings/request.ts +43 -0
  226. package/src/meetings/util.ts +117 -4
  227. package/src/member/index.ts +20 -0
  228. package/src/member/types.ts +1 -0
  229. package/src/member/util.ts +41 -0
  230. package/src/members/index.ts +70 -7
  231. package/src/members/util.ts +12 -4
  232. package/src/metrics/constants.ts +12 -0
  233. package/src/multistream/codec/constants.ts +58 -0
  234. package/src/multistream/mediaRequestManager.ts +117 -76
  235. package/src/multistream/receiveSlot.ts +18 -0
  236. package/src/multistream/remoteMediaManager.ts +13 -0
  237. package/src/multistream/sendSlotManager.ts +97 -3
  238. package/src/reachability/clusterReachability.ts +3 -2
  239. package/src/reachability/index.ts +56 -16
  240. package/src/reachability/reachability.types.ts +11 -0
  241. package/src/reachability/util.ts +36 -0
  242. package/src/reactions/reactions.type.ts +4 -0
  243. package/src/reconnection-manager/index.ts +0 -1
  244. package/src/recording-controller/index.ts +1 -2
  245. package/src/roap/turnDiscovery.ts +9 -1
  246. package/src/webinar/index.ts +415 -11
  247. package/src/webinar/utils.ts +16 -0
  248. package/test/unit/spec/aiEnableRequest/index.ts +1067 -0
  249. package/test/unit/spec/aiEnableRequest/utils.ts +130 -0
  250. package/test/unit/spec/annotation/index.ts +228 -134
  251. package/test/unit/spec/breakouts/breakout.ts +9 -3
  252. package/test/unit/spec/breakouts/events.ts +120 -2
  253. package/test/unit/spec/breakouts/index.ts +305 -18
  254. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  255. package/test/unit/spec/controls-options-manager/index.js +244 -29
  256. package/test/unit/spec/controls-options-manager/util.js +165 -0
  257. package/test/unit/spec/hashTree/hashTree.ts +66 -0
  258. package/test/unit/spec/hashTree/hashTreeParser.ts +4528 -171
  259. package/test/unit/spec/hashTree/utils.ts +125 -1
  260. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +388 -0
  261. package/test/unit/spec/interceptors/locusRetry.ts +205 -4
  262. package/test/unit/spec/interceptors/utils.ts +75 -0
  263. package/test/unit/spec/interpretation/index.ts +26 -4
  264. package/test/unit/spec/locus-info/controlsUtils.js +200 -56
  265. package/test/unit/spec/locus-info/index.js +1861 -149
  266. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  267. package/test/unit/spec/media/MediaConnectionAwaiter.ts +96 -1
  268. package/test/unit/spec/media/index.ts +92 -0
  269. package/test/unit/spec/media/properties.ts +35 -26
  270. package/test/unit/spec/meeting/in-meeting-actions.ts +12 -2
  271. package/test/unit/spec/meeting/index.js +3694 -450
  272. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  273. package/test/unit/spec/meeting/muteState.js +81 -0
  274. package/test/unit/spec/meeting/request.js +82 -0
  275. package/test/unit/spec/meeting/utils.js +595 -27
  276. package/test/unit/spec/meeting-info/meetinginfov2.js +19 -10
  277. package/test/unit/spec/meetings/index.js +1138 -86
  278. package/test/unit/spec/meetings/request.js +141 -0
  279. package/test/unit/spec/meetings/utils.js +402 -51
  280. package/test/unit/spec/member/index.js +35 -4
  281. package/test/unit/spec/member/util.js +154 -27
  282. package/test/unit/spec/members/index.js +216 -0
  283. package/test/unit/spec/members/request.js +37 -1
  284. package/test/unit/spec/members/utils.js +63 -0
  285. package/test/unit/spec/multistream/mediaRequestManager.ts +503 -122
  286. package/test/unit/spec/multistream/remoteMediaManager.ts +30 -0
  287. package/test/unit/spec/multistream/sendSlotManager.ts +135 -36
  288. package/test/unit/spec/reachability/index.ts +151 -46
  289. package/test/unit/spec/reachability/util.ts +31 -0
  290. package/test/unit/spec/reconnection-manager/index.js +4 -8
  291. package/test/unit/spec/recording-controller/index.js +9 -8
  292. package/test/unit/spec/roap/turnDiscovery.ts +20 -0
  293. package/test/unit/spec/webinar/index.ts +1087 -167
  294. package/test/unit/spec/webinar/utils.ts +39 -0
@@ -13,7 +13,7 @@ import {
13
13
  CALL_DIAGNOSTIC_CONFIG,
14
14
  RtcMetrics,
15
15
  } from '@webex/internal-plugin-metrics';
16
- import {ClientEvent as RawClientEvent} from '@webex/event-dictionary-ts';
16
+ import type {ClientEvent as RawClientEvent} from '@webex/event-dictionary-ts';
17
17
 
18
18
  import {
19
19
  ConnectionState,
@@ -30,9 +30,12 @@ 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, type RegisterAndConnectTiming} from '@webex/internal-plugin-llm';
37
+ import type LLMChannel from '@webex/internal-plugin-llm';
38
+
36
39
  import {
37
40
  LocalStream,
38
41
  LocalCameraStream,
@@ -48,6 +51,7 @@ import {
48
51
  EVENT_TRIGGERS as VOICEAEVENTS,
49
52
  TURN_ON_CAPTION_STATUS,
50
53
  type MeetingTranscriptPayload,
54
+ type VoiceaChannel,
51
55
  } from '@webex/internal-plugin-voicea';
52
56
 
53
57
  import {
@@ -55,6 +59,7 @@ import {
55
59
  isBrowserMediaError,
56
60
  isBrowserMediaErrorName,
57
61
  } from '@webex/internal-plugin-metrics/src/call-diagnostic/call-diagnostic-metrics.util';
62
+ import {CapabilityState, WebCapabilities} from '@webex/web-capabilities';
58
63
  import {processNewCaptions} from './voicea-meeting';
59
64
 
60
65
  import {
@@ -63,6 +68,7 @@ import {
63
68
  NoMediaEstablishedYetError,
64
69
  UserNotJoinedError,
65
70
  AddMediaFailed,
71
+ MediaConnectionTimedOutError,
66
72
  SdpResponseTimeoutError,
67
73
  } from '../common/errors/webex-errors';
68
74
 
@@ -73,6 +79,7 @@ import Roap, {type TurnDiscoveryResult, type TurnDiscoverySkipReason} from '../r
73
79
  import {type TurnServerInfo} from '../roap/types';
74
80
  import Media, {type BundlePolicy} from '../media';
75
81
  import MediaProperties from '../media/properties';
82
+ import {type FailureResult as MediaConnectionAwaiterFailureResult} from '../media/MediaConnectionAwaiter';
76
83
  import MeetingStateMachine from './state';
77
84
  import {createMuteState} from './muteState';
78
85
  import LocusInfo, {LocusLLMEvent} from '../locus-info';
@@ -178,13 +185,15 @@ import JoinForbiddenError from '../common/errors/join-forbidden-error';
178
185
  import {ReachabilityMetrics} from '../reachability/reachability.types';
179
186
  import {SetStageOptions, SetStageVideoLayout, UnsetStageVideoLayout} from './request.type';
180
187
  import {Invitee} from './type';
181
- import {DataSet} from '../hashTree/hashTreeParser';
188
+ import {DataSet, HashTreeMessage, Metadata} from '../hashTree/hashTreeParser';
182
189
  import {LocusDTO} from '../locus-info/types';
190
+ import AIEnableRequest from '../aiEnableRequest';
183
191
 
184
192
  // default callback so we don't call an undefined function, but in practice it should never be used
185
193
  const DEFAULT_ICE_PHASE_CALLBACK = () => 'JOIN_MEETING_FINAL';
186
194
 
187
195
  const LLM_HEALTHCHECK_TIMER_MS = 3 * 60 * 1000;
196
+ const JOIN_WITH_MEDIA_RETRY_MAX_COUNT = 2;
188
197
 
189
198
  const logRequest = (request: any, {logText = ''}) => {
190
199
  LoggerProxy.logger.info(`${logText} - sending request`);
@@ -249,6 +258,7 @@ export type AddMediaOptions = {
249
258
  remoteMediaManagerConfig?: RemoteMediaManagerConfiguration; // applies only to multistream meetings
250
259
  bundlePolicy?: BundlePolicy; // applies only to multistream meetings
251
260
  allowMediaInLobby?: boolean; // allows adding media when in the lobby
261
+ allowPublishMediaInLobby?: boolean; // allows publishing media when in the lobby, if not specified, default value false is used
252
262
  additionalMediaOptions?: AdditionalMediaOptions; // allows adding additional options like send/receive audio/video
253
263
  };
254
264
 
@@ -563,6 +573,34 @@ type MediaReachabilityMetrics = ReachabilityMetrics & {
563
573
  * @memberof Meeting
564
574
  */
565
575
 
576
+ /**
577
+ * Stores an event so all events can be later retrieved via a console command for debugging.
578
+ * @param {string} type
579
+ * @param {Object} data
580
+ * @returns {void}
581
+ */
582
+ export function storeEventForDebugging(
583
+ type: string,
584
+ data: {
585
+ eventType: any;
586
+ stateElementsMessage?: HashTreeMessage;
587
+ }
588
+ ) {
589
+ if ((window as any)?.locusEvents) {
590
+ // only store non-heartbeat hash tree messages
591
+ if (
592
+ data.eventType === LOCUSEVENT.HASH_TREE_DATA_UPDATED &&
593
+ data.stateElementsMessage?.locusStateElements
594
+ ) {
595
+ (window as any).locusEvents.push({
596
+ ...data,
597
+ timestamp: new Date().toLocaleString(),
598
+ type,
599
+ });
600
+ }
601
+ }
602
+ }
603
+
566
604
  /**
567
605
  * @description Meeting is the crux of the plugin
568
606
  * @export
@@ -574,10 +612,11 @@ export default class Meeting extends StatelessWebexPlugin {
574
612
  breakouts: any;
575
613
  simultaneousInterpretation: any;
576
614
  annotation: any;
615
+ aiEnableRequest: any;
577
616
  webinar: any;
578
617
  conversationUrl: string;
579
618
  callStateForMetrics: CallStateForMetrics;
580
- destination: string;
619
+ destination: string | LocusDTO;
581
620
  destinationType: DESTINATION_TYPE;
582
621
  deviceUrl: string;
583
622
  hostId: string;
@@ -616,12 +655,22 @@ export default class Meeting extends StatelessWebexPlugin {
616
655
  floorGrantPending: boolean;
617
656
  hasJoinedOnce: boolean;
618
657
  hasWebsocketConnected: boolean;
658
+ private mercuryOnlineHandler?: () => void;
659
+ private mercuryOfflineHandler?: () => void;
619
660
  inMeetingActions: InMeetingActions;
620
661
  isLocalShareLive: boolean;
621
662
  isRoapInProgress: boolean;
622
663
  keepAliveTimerId: NodeJS.Timeout;
623
664
  lastVideoLayoutInfo: any;
624
665
  locusInfo: any;
666
+ // this group of properties is populated via updateMeetingObject() that's registered as a callback with LocusInfo
667
+ isUserUnadmitted?: boolean;
668
+ joinedWith?: any;
669
+ selfId?: string;
670
+ roles: any[];
671
+ canNotViewTheParticipantList?: boolean;
672
+ // ... there is more ... see SelfUtils.parse()
673
+ // end of the group
625
674
  locusMediaRequest?: LocusMediaRequest;
626
675
  mediaProperties: MediaProperties;
627
676
  mediaRequestManagers: {
@@ -656,7 +705,6 @@ export default class Meeting extends StatelessWebexPlugin {
656
705
  endCallInitJoinReq: any;
657
706
  endJoinReqResp: any;
658
707
  endLocalSDPGenRemoteSDPRecvDelay: any;
659
- joinedWith: any;
660
708
  locusId: any;
661
709
  startCallInitJoinReq: any;
662
710
  startJoinReqResp: any;
@@ -671,12 +719,11 @@ export default class Meeting extends StatelessWebexPlugin {
671
719
  permissionTokenReceivedLocalTime: number;
672
720
  resourceId: any;
673
721
  resourceUrl: string;
674
- selfId: string;
675
722
  state: any;
676
723
  localAudioStreamMuteStateHandler: () => void;
677
724
  localVideoStreamMuteStateHandler: () => void;
678
725
  localOutputTrackChangeHandler: () => void;
679
- roles: any[];
726
+ localConstraintsChangeHandler: () => void;
680
727
  environment: string;
681
728
  namespace = MEETINGS;
682
729
  allowMediaInLobby: boolean;
@@ -695,6 +742,8 @@ export default class Meeting extends StatelessWebexPlugin {
695
742
  isMoveToInProgress = false;
696
743
  registrationIdStatus: string;
697
744
  brbState: BrbState;
745
+ private emittedBreakoutJoinResponseMoveIds: Set<string> = new Set();
746
+ private promisesWaitingForPropUpdate: Record<string, Defer> = {};
698
747
 
699
748
  voiceaListenerCallbacks: object = {
700
749
  [VOICEAEVENTS.VOICEA_ANNOUNCEMENT]: (payload: Transcription['languageOptions']) => {
@@ -744,13 +793,20 @@ export default class Meeting extends StatelessWebexPlugin {
744
793
  private addMediaData: {
745
794
  retriedWithTurnServer: boolean;
746
795
  icePhaseCallback: () => string;
796
+ iceTransportPolicy?: RTCIceTransportPolicy;
747
797
  };
748
798
 
749
799
  private sendSlotManager: SendSlotManager = new SendSlotManager(LoggerProxy);
750
800
  private deferSDPAnswer?: Defer; // used for waiting for a response
751
801
  private sdpResponseTimer?: ReturnType<typeof setTimeout>;
752
802
  private hasMediaConnectionConnectedAtLeastOnce: boolean;
753
- private joinWithMediaRetryInfo?: {isRetry: boolean; prevJoinResponse?: any};
803
+ private joinWithMediaRetryInfo: {
804
+ retryCount: number;
805
+ prevJoinResponse?: any;
806
+ firstError?: Error;
807
+ prevError?: Error;
808
+ };
809
+
754
810
  private connectionStateHandler?: ConnectionStateHandler;
755
811
  private iceCandidateErrors: Map<string, number>;
756
812
  private iceCandidatesCount: number;
@@ -760,6 +816,22 @@ export default class Meeting extends StatelessWebexPlugin {
760
816
  private mediaServerIp: string;
761
817
  private llmHealthCheckTimer?: ReturnType<typeof setTimeout>;
762
818
 
819
+ /**
820
+ * The LLM channel owned by this meeting for datachannel communication.
821
+ * Created in updateLLMConnection, cleaned up in cleanupLLMConneciton.
822
+ */
823
+ private llmChannel?: LLMChannel;
824
+
825
+ /**
826
+ * The Voicea channel for transcription/captions, bound to this meeting's LLM channel.
827
+ */
828
+ voiceaChannel?: VoiceaChannel;
829
+
830
+ /**
831
+ * Pending datachannel token saved from join response, used when creating the LLM channel.
832
+ */
833
+ private _pendingDatachannelToken?: string;
834
+
763
835
  /**
764
836
  * @param {Object} attrs
765
837
  * @param {Object} options
@@ -893,6 +965,10 @@ export default class Meeting extends StatelessWebexPlugin {
893
965
  */
894
966
  // @ts-ignore
895
967
  this.simultaneousInterpretation = new SimultaneousInterpretation({}, {parent: this.webex});
968
+
969
+ // @ts-ignore
970
+ this.aiEnableRequest = new AIEnableRequest({locusUrl: this.locusUrl}, {parent: this.webex});
971
+
896
972
  /**
897
973
  * @instance
898
974
  * @type {Annotation}
@@ -922,6 +998,7 @@ export default class Meeting extends StatelessWebexPlugin {
922
998
  },
923
999
  (csi: CSI) => (this.members.findMemberByCsi(csi) as any)?.id
924
1000
  );
1001
+
925
1002
  /**
926
1003
  * Object containing helper classes for managing media requests for audio/video/screenshare (for multistream media connections)
927
1004
  * All multistream media requests sent out for this meeting have to go through them.
@@ -941,6 +1018,7 @@ export default class Meeting extends StatelessWebexPlugin {
941
1018
  mediaRequests
942
1019
  );
943
1020
  },
1021
+ this.getIngressPayloadTypeCallback.bind(this),
944
1022
  {
945
1023
  // @ts-ignore - config coming from registerPlugin
946
1024
  degradationPreferences: this.config.degradationPreferences,
@@ -962,6 +1040,7 @@ export default class Meeting extends StatelessWebexPlugin {
962
1040
  mediaRequests
963
1041
  );
964
1042
  },
1043
+ this.getIngressPayloadTypeCallback.bind(this),
965
1044
  {
966
1045
  // @ts-ignore - config coming from registerPlugin
967
1046
  degradationPreferences: this.config.degradationPreferences,
@@ -983,6 +1062,7 @@ export default class Meeting extends StatelessWebexPlugin {
983
1062
  mediaRequests
984
1063
  );
985
1064
  },
1065
+ this.getIngressPayloadTypeCallback.bind(this),
986
1066
  {
987
1067
  // @ts-ignore - config coming from registerPlugin
988
1068
  degradationPreferences: this.config.degradationPreferences,
@@ -1004,11 +1084,14 @@ export default class Meeting extends StatelessWebexPlugin {
1004
1084
  mediaRequests
1005
1085
  );
1006
1086
  },
1087
+ this.getIngressPayloadTypeCallback.bind(this),
1007
1088
  {
1008
1089
  // @ts-ignore - config coming from registerPlugin
1009
1090
  degradationPreferences: this.config.degradationPreferences,
1010
1091
  kind: 'video',
1011
1092
  trimRequestsToNumOfSources: false,
1093
+ // @ts-ignore - config coming from registerPlugin
1094
+ enableAv1: this.config.enableAv1SlidesSupport,
1012
1095
  }
1013
1096
  ),
1014
1097
  };
@@ -1328,7 +1411,48 @@ export default class Meeting extends StatelessWebexPlugin {
1328
1411
  * @memberof Meeting
1329
1412
  */
1330
1413
  // @ts-ignore - Fix type
1331
- this.locusInfo = new LocusInfo(this.updateMeetingObject.bind(this), this.webex, this.id);
1414
+ this.locusInfo = new LocusInfo(
1415
+ {
1416
+ updateMeeting: this.updateMeetingObject.bind(this),
1417
+ syncLatencyTracker: {
1418
+ // Compute/store latency timestamps live on CallDiagnosticLatencies, while
1419
+ // submitting the client.locus.sync.complete CA event is owned by the metrics
1420
+ // facade. Wire each method to the layer that owns that responsibility.
1421
+ saveLatency: (...args) =>
1422
+ // @ts-ignore
1423
+ this.webex.internal.newMetrics.callDiagnosticLatencies.saveLatency(...args),
1424
+ saveTimestamp: (saveTimestampOptions: {
1425
+ key: string;
1426
+ value?: number;
1427
+ options: {meetingId: string; dataSetName: string; trackingId?: string};
1428
+ }) => {
1429
+ // @ts-ignore
1430
+ this.webex.internal.newMetrics.callDiagnosticLatencies.saveTimestamp(
1431
+ saveTimestampOptions
1432
+ );
1433
+
1434
+ // The /sync response is one of the two milestones (the other is the LLM message) that
1435
+ // complete client.locus.sync.complete. Try to complete now: the metric is emitted only
1436
+ // once both the LLM message and the /sync response have arrived (either can come first).
1437
+ if (
1438
+ saveTimestampOptions.key === 'internal.client.locus.sync.response' &&
1439
+ saveTimestampOptions.options?.trackingId
1440
+ ) {
1441
+ this.tryCompleteLocusSyncLatency(
1442
+ saveTimestampOptions.options.meetingId,
1443
+ saveTimestampOptions.options.trackingId
1444
+ );
1445
+ }
1446
+ },
1447
+ clearLocusSyncLatency: (...args) =>
1448
+ // @ts-ignore
1449
+ this.webex.internal.newMetrics.callDiagnosticLatencies.clearLocusSyncLatency(...args),
1450
+ },
1451
+ },
1452
+ // @ts-ignore
1453
+ this.webex,
1454
+ this.id
1455
+ );
1332
1456
 
1333
1457
  // We had to add listeners first before setting up the locus instance
1334
1458
  /**
@@ -1513,6 +1637,8 @@ export default class Meeting extends StatelessWebexPlugin {
1513
1637
  this.controlsOptionsManager = new ControlsOptionsManager(this.meetingRequest, {
1514
1638
  locusUrl: this.locusInfo?.url,
1515
1639
  displayHints: [],
1640
+ getControls: () => this.locusInfo?.controls,
1641
+ isWebinar: () => this.locusInfo?.info?.isWebinar,
1516
1642
  });
1517
1643
 
1518
1644
  this.setUpLocusInfoListeners();
@@ -1542,6 +1668,12 @@ export default class Meeting extends StatelessWebexPlugin {
1542
1668
  }
1543
1669
  };
1544
1670
 
1671
+ this.localConstraintsChangeHandler = () => {
1672
+ if (!this.isMultistream) {
1673
+ this.mediaProperties.webrtcMediaConnection?.updatePreferredBitrateKbps();
1674
+ }
1675
+ };
1676
+
1545
1677
  /**
1546
1678
  * Promise that exists if SDP offer has been generated, and resolves once sdp answer is received.
1547
1679
  * @instance
@@ -1605,11 +1737,11 @@ export default class Meeting extends StatelessWebexPlugin {
1605
1737
  /**
1606
1738
  * Information needed for a retry of a call to joinWithMedia
1607
1739
  * @instance
1608
- * @type {{isRetry: boolean; prevJoinResponse?: any}}
1740
+ * @type {{retryCount: number; prevJoinResponse?: any}}
1609
1741
  * @private
1610
1742
  * @memberof Meeting
1611
1743
  */
1612
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
1744
+ this.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
1613
1745
 
1614
1746
  /**
1615
1747
  * Connection state handler
@@ -1663,6 +1795,37 @@ export default class Meeting extends StatelessWebexPlugin {
1663
1795
  this.mediaServerIp = undefined;
1664
1796
  }
1665
1797
 
1798
+ /**
1799
+ * Get the ingress payload type for a given media type and codec mime type
1800
+ * @param {MediaType} mediaType - The media type
1801
+ * @param {MediaCodecMimeType} codecMimeType - The codec mime type
1802
+ * @returns {number | undefined} - The ingress payload type
1803
+ * @private
1804
+ * @memberof Meeting
1805
+ */
1806
+ private getIngressPayloadTypeCallback(
1807
+ mediaType: MediaType,
1808
+ codecMimeType: MediaCodecMimeType
1809
+ ): number | undefined {
1810
+ if (this.isMultistream) {
1811
+ try {
1812
+ return this.mediaProperties.webrtcMediaConnection.getIngressPayloadType(
1813
+ mediaType,
1814
+ codecMimeType
1815
+ );
1816
+ } catch (error) {
1817
+ LoggerProxy.logger.info(
1818
+ `Meeting:index#mediaRequestManager --> failed to get ingress payload type for mediaType=${mediaType}, codecMimeType=${codecMimeType}`,
1819
+ error
1820
+ );
1821
+
1822
+ return undefined;
1823
+ }
1824
+ }
1825
+
1826
+ return undefined;
1827
+ }
1828
+
1666
1829
  /**
1667
1830
  * Temporary func to return webex object,
1668
1831
  * in order to access internal plugin metrics
@@ -2275,6 +2438,89 @@ export default class Meeting extends StatelessWebexPlugin {
2275
2438
  });
2276
2439
  }
2277
2440
 
2441
+ /**
2442
+ * Handles the LLM state-update message that resulted from a Locus /sync. Records the LLM arrival
2443
+ * time (the milestone that gates client.locus.sync.complete - the metric is emitted only for LLM
2444
+ * flows) and then tries to complete the metric.
2445
+ * @param {string} meetingId meeting id
2446
+ * @param {string} trackingId sync tracking id echoed back on the LLM message
2447
+ * @returns {void}
2448
+ * @private
2449
+ * @memberof Meeting
2450
+ */
2451
+ private onLocusSyncLlmMessage(meetingId: string, trackingId: string) {
2452
+ // @ts-ignore
2453
+ this.webex.internal.newMetrics.callDiagnosticLatencies.recordLocusSyncMessageReceived(
2454
+ meetingId,
2455
+ trackingId
2456
+ );
2457
+
2458
+ this.tryCompleteLocusSyncLatency(meetingId, trackingId);
2459
+ }
2460
+
2461
+ /**
2462
+ * Attempts to complete the Locus sync latency metric and emit client.locus.sync.complete. The
2463
+ * metric is emitted only once BOTH the /sync response and the resulting LLM message have arrived
2464
+ * (in either order); until then the record is kept so the missing milestone can still land. Both
2465
+ * trigger points (the LLM message handler and the /sync response timestamp) call this, so the
2466
+ * metric fires as soon as the second milestone is in.
2467
+ * @param {string} meetingId meeting id
2468
+ * @param {string} trackingId sync tracking id used to match the pending record
2469
+ * @returns {void}
2470
+ * @private
2471
+ * @memberof Meeting
2472
+ */
2473
+ private tryCompleteLocusSyncLatency(meetingId: string, trackingId: string) {
2474
+ const completed =
2475
+ // @ts-ignore
2476
+ this.webex.internal.newMetrics.callDiagnosticLatencies.completeLocusSyncLatency(
2477
+ meetingId,
2478
+ trackingId
2479
+ );
2480
+
2481
+ if (completed) {
2482
+ this.emitLocusSyncCompleteMetric(meetingId, completed);
2483
+ }
2484
+ }
2485
+
2486
+ /**
2487
+ * Submits the client.locus.sync.complete Call Analyzer event for a completed Locus sync latency
2488
+ * measurement.
2489
+ * @param {string} meetingId meeting id
2490
+ * @param {object} completed completed sync latency payload from the metrics plugin
2491
+ * @returns {void}
2492
+ * @private
2493
+ * @memberof Meeting
2494
+ */
2495
+ private emitLocusSyncCompleteMetric(
2496
+ meetingId: string,
2497
+ completed: {dataSet: string; syncLatency: object}
2498
+ ) {
2499
+ // @ts-ignore
2500
+ const llmWebsocketUrl = this.webex.internal.llm?.getWebSocketUrl?.() || undefined;
2501
+
2502
+ // Per the LLM sync-latency spec, the event carries the LLM websocket url identifier,
2503
+ // the llmInfo.dataSet (main, atd-active or atd-unmuted) and the syncLatency block.
2504
+ const clientEvent = {
2505
+ name: 'client.locus.sync.complete',
2506
+ payload: {
2507
+ identifiers: {
2508
+ llmWebsocketUrl,
2509
+ },
2510
+ llmInfo: {
2511
+ dataSet: completed.dataSet,
2512
+ },
2513
+ syncLatency: completed.syncLatency,
2514
+ },
2515
+ options: {
2516
+ meetingId,
2517
+ },
2518
+ };
2519
+
2520
+ // @ts-ignore
2521
+ this.webex.internal.newMetrics.submitClientEvent(clientEvent);
2522
+ }
2523
+
2278
2524
  /**
2279
2525
  * Proxy function for all the listener set ups
2280
2526
  * @returns {undefined}
@@ -2434,29 +2680,28 @@ export default class Meeting extends StatelessWebexPlugin {
2434
2680
  * @memberof Meeting
2435
2681
  */
2436
2682
  private setUpVoiceaListeners() {
2437
- // @ts-ignore
2438
- this.webex.internal.voicea.listenToEvents();
2683
+ if (!this.voiceaChannel) {
2684
+ LoggerProxy.logger.warn('Meeting:index#setUpVoiceaListeners --> voiceaChannel not available');
2439
2685
 
2440
- // @ts-ignore
2441
- this.webex.internal.voicea.on(
2686
+ return;
2687
+ }
2688
+
2689
+ this.voiceaChannel.on(
2442
2690
  VOICEAEVENTS.VOICEA_ANNOUNCEMENT,
2443
2691
  this.voiceaListenerCallbacks[VOICEAEVENTS.VOICEA_ANNOUNCEMENT]
2444
2692
  );
2445
2693
 
2446
- // @ts-ignore
2447
- this.webex.internal.voicea.on(
2694
+ this.voiceaChannel.on(
2448
2695
  VOICEAEVENTS.CAPTIONS_TURNED_ON,
2449
2696
  this.voiceaListenerCallbacks[VOICEAEVENTS.CAPTIONS_TURNED_ON]
2450
2697
  );
2451
2698
 
2452
- // @ts-ignore
2453
- this.webex.internal.voicea.on(
2699
+ this.voiceaChannel.on(
2454
2700
  VOICEAEVENTS.EVA_COMMAND,
2455
2701
  this.voiceaListenerCallbacks[VOICEAEVENTS.EVA_COMMAND]
2456
2702
  );
2457
2703
 
2458
- // @ts-ignore
2459
- this.webex.internal.voicea.on(
2704
+ this.voiceaChannel.on(
2460
2705
  VOICEAEVENTS.NEW_CAPTION,
2461
2706
  this.voiceaListenerCallbacks[VOICEAEVENTS.NEW_CAPTION]
2462
2707
  );
@@ -2739,7 +2984,7 @@ export default class Meeting extends StatelessWebexPlugin {
2739
2984
  private setupLocusControlsListener() {
2740
2985
  this.locusInfo.on(
2741
2986
  LOCUSINFO.EVENTS.CONTROLS_RECORDING_UPDATED,
2742
- ({state, modifiedBy, lastModified}) => {
2987
+ ({state, modifiedBy, lastModified, modifiedByServiceAppName, modifiedByServiceAppId}) => {
2743
2988
  let event;
2744
2989
 
2745
2990
  switch (state) {
@@ -2765,6 +3010,8 @@ export default class Meeting extends StatelessWebexPlugin {
2765
3010
  state: state === RECORDING_STATE.RESUMED ? RECORDING_STATE.RECORDING : state,
2766
3011
  modifiedBy,
2767
3012
  lastModified,
3013
+ modifiedByServiceAppName,
3014
+ modifiedByServiceAppId,
2768
3015
  };
2769
3016
  Trigger.trigger(
2770
3017
  this,
@@ -2823,8 +3070,7 @@ export default class Meeting extends StatelessWebexPlugin {
2823
3070
  if (this.transcription?.languageOptions) {
2824
3071
  this.transcription.languageOptions.currentSpokenLanguage = spokenLanguage;
2825
3072
  }
2826
- // @ts-ignore
2827
- this.webex.internal.voicea.onSpokenLanguageUpdate(spokenLanguage, this.id);
3073
+ this.voiceaChannel?.onSpokenLanguageUpdate(spokenLanguage, this.id);
2828
3074
 
2829
3075
  Trigger.trigger(
2830
3076
  this,
@@ -2853,8 +3099,7 @@ export default class Meeting extends StatelessWebexPlugin {
2853
3099
 
2854
3100
  this.locusInfo.on(LOCUSINFO.EVENTS.CONTROLS_MEETING_HESIOD_LLM_ID_UPDATED, ({hesiodLlmId}) => {
2855
3101
  if (hesiodLlmId) {
2856
- // @ts-ignore
2857
- this.webex.internal.voicea.onCaptionServiceIdUpdate(hesiodLlmId);
3102
+ this.voiceaChannel?.onCaptionServiceIdUpdate(hesiodLlmId);
2858
3103
  }
2859
3104
  });
2860
3105
 
@@ -2951,6 +3196,18 @@ export default class Meeting extends StatelessWebexPlugin {
2951
3196
  );
2952
3197
  });
2953
3198
 
3199
+ this.locusInfo.on(
3200
+ LOCUSINFO.EVENTS.CONTROLS_AI_SUMMARY_NOTIFICATION_UPDATED,
3201
+ ({aiSummaryNotification}) => {
3202
+ Trigger.trigger(
3203
+ this,
3204
+ {file: 'meeting/index', function: 'setupLocusControlsListener'},
3205
+ EVENT_TRIGGERS.MEETING_CONTROLS_AI_SUMMARY_NOTIFICATION_UPDATED,
3206
+ {aiSummaryNotification}
3207
+ );
3208
+ }
3209
+ );
3210
+
2954
3211
  this.locusInfo.on(LOCUSINFO.EVENTS.CONTROLS_WEBCAST_CHANGED, ({state}) => {
2955
3212
  Trigger.trigger(
2956
3213
  this,
@@ -3151,7 +3408,7 @@ export default class Meeting extends StatelessWebexPlugin {
3151
3408
  }
3152
3409
 
3153
3410
  LoggerProxy.logger.info(
3154
- `Meeting:index#setUpLocusInfoMediaInactiveListener --> this.shareStatus=${this.shareStatus} newShareStatus=${newShareStatus}`
3411
+ `Meeting:index#setUpLocusMediaSharesListener --> this.shareStatus=${this.shareStatus} newShareStatus=${newShareStatus}`
3155
3412
  );
3156
3413
 
3157
3414
  if (newShareStatus !== this.shareStatus) {
@@ -3397,6 +3654,7 @@ export default class Meeting extends StatelessWebexPlugin {
3397
3654
  this.breakouts.locusUrlUpdate(url);
3398
3655
  this.simultaneousInterpretation.locusUrlUpdate(url);
3399
3656
  this.annotation.locusUrlUpdate(url);
3657
+ this.aiEnableRequest.locusUrlUpdate(url);
3400
3658
  this.locusUrl = url;
3401
3659
  this.locusId = this.locusUrl?.split('/').pop();
3402
3660
  this.recordingController.setLocusUrl(this.locusUrl);
@@ -3432,6 +3690,7 @@ export default class Meeting extends StatelessWebexPlugin {
3432
3690
  this.breakouts.breakoutServiceUrlUpdate(payload?.services?.breakout?.url);
3433
3691
  this.annotation.approvalUrlUpdate(payload?.services?.approval?.url);
3434
3692
  this.simultaneousInterpretation.approvalUrlUpdate(payload?.services?.approval?.url);
3693
+ this.aiEnableRequest.approvalUrlUpdate(payload?.services?.approval?.url);
3435
3694
  });
3436
3695
  }
3437
3696
 
@@ -3529,6 +3788,9 @@ export default class Meeting extends StatelessWebexPlugin {
3529
3788
  // @ts-ignore - config coming from registerPlugin
3530
3789
  if (datachannelUrl && this.config.enableAutomaticLLM) {
3531
3790
  this.updateLLMConnection();
3791
+ if (this.webinar.isJoinPracticeSessionDataChannel()) {
3792
+ this.webinar.updatePSDataChannel();
3793
+ }
3532
3794
  }
3533
3795
  }
3534
3796
 
@@ -3692,6 +3954,16 @@ export default class Meeting extends StatelessWebexPlugin {
3692
3954
  });
3693
3955
  }
3694
3956
  this.rtcMetrics?.sendNextMetrics();
3957
+
3958
+ try {
3959
+ await this.ensureDefaultDatachannelTokenAfterAdmit();
3960
+ } catch (error) {
3961
+ LoggerProxy.logger.warn(
3962
+ `Meeting:index#setUpLocusInfoSelfListener --> failed post-admit token prefetch flow: ${
3963
+ error?.message || String(error)
3964
+ }`
3965
+ );
3966
+ }
3695
3967
  this.updateLLMConnection();
3696
3968
  });
3697
3969
 
@@ -3736,6 +4008,9 @@ export default class Meeting extends StatelessWebexPlugin {
3736
4008
  });
3737
4009
 
3738
4010
  this.locusInfo.on(LOCUSINFO.EVENTS.SELF_CANNOT_VIEW_PARTICIPANT_LIST_CHANGE, (payload) => {
4011
+ // canViewTheParticipantList meeting action depends on this value, so we need to update meeting actions
4012
+ this.updateMeetingActions();
4013
+
3739
4014
  Trigger.trigger(
3740
4015
  this,
3741
4016
  {
@@ -3761,6 +4036,10 @@ export default class Meeting extends StatelessWebexPlugin {
3761
4036
  );
3762
4037
  });
3763
4038
 
4039
+ this.locusInfo.on(LOCUSINFO.EVENTS.SELF_ID_CHANGED, (payload) => {
4040
+ this.aiEnableRequest.selfParticipantIdUpdate(payload.selfId);
4041
+ });
4042
+
3764
4043
  this.locusInfo.on(LOCUSINFO.EVENTS.SELF_MEETING_INTERPRETATION_CHANGED, (payload) => {
3765
4044
  const targetChanged = this.simultaneousInterpretation.updateSelfInterpretation(payload);
3766
4045
  Trigger.trigger(
@@ -3926,7 +4205,14 @@ export default class Meeting extends StatelessWebexPlugin {
3926
4205
  // is not changed by any delta event
3927
4206
  if (object && Object.keys(object).length) {
3928
4207
  Object.keys(object).forEach((key) => {
4208
+ const previousValue = this[key];
4209
+
3929
4210
  this[key] = object[key];
4211
+
4212
+ if (this.promisesWaitingForPropUpdate[key] && previousValue !== object[key]) {
4213
+ this.promisesWaitingForPropUpdate[key].resolve();
4214
+ delete this.promisesWaitingForPropUpdate[key];
4215
+ }
3930
4216
  });
3931
4217
  }
3932
4218
  }
@@ -4064,7 +4350,12 @@ export default class Meeting extends StatelessWebexPlugin {
4064
4350
  }
4065
4351
 
4066
4352
  /**
4067
- * Transfer the moderator role to another eligible member
4353
+ * Transfer the moderator role to another eligible member.
4354
+ *
4355
+ * If the target member is currently joined in the current session, the request is
4356
+ * sent against the current locus. Otherwise, we search the breakout sessions and,
4357
+ * when the member is found in one, we send the request against that breakout
4358
+ * session's locus url instead.
4068
4359
  * @param {String} memberId
4069
4360
  * @param {Boolean} moderator
4070
4361
  * @returns {Promise} see #members.transferHostToMember
@@ -4072,7 +4363,21 @@ export default class Meeting extends StatelessWebexPlugin {
4072
4363
  * @memberof Meeting
4073
4364
  */
4074
4365
  public transfer(memberId: string, moderator = true) {
4075
- return this.members.transferHostToMember(memberId, moderator);
4366
+ const targetMember = this.members.membersCollection.get(memberId);
4367
+
4368
+ if (targetMember?.isInMeeting) {
4369
+ return this.members.transferHostToMember(memberId, moderator);
4370
+ }
4371
+
4372
+ const breakout = this.breakouts?.breakouts?.models?.find((bo: any) => {
4373
+ const breakoutMember = bo.members?.membersCollection?.get(memberId);
4374
+
4375
+ return breakoutMember?.isInMeeting;
4376
+ });
4377
+
4378
+ const breakoutLocusUrl = breakout?.breakoutRosterLocus?.url;
4379
+
4380
+ return this.members.transferHostToMember(memberId, moderator, breakoutLocusUrl);
4076
4381
  }
4077
4382
 
4078
4383
  /**
@@ -4263,6 +4568,9 @@ export default class Meeting extends StatelessWebexPlugin {
4263
4568
  bothLeaveAndEndMeetingAvailable: MeetingUtil.bothLeaveAndEndMeetingAvailable(
4264
4569
  this.userDisplayHints
4265
4570
  ),
4571
+ requireHostEndMeetingBeforeLeave: MeetingUtil.requireHostEndMeetingBeforeLeave(
4572
+ this.userDisplayHints
4573
+ ),
4266
4574
  canEnableClosedCaption: MeetingUtil.canEnableClosedCaption(this.userDisplayHints),
4267
4575
  canStartTranscribing: MeetingUtil.canStartTranscribing(this.userDisplayHints),
4268
4576
  canStopTranscribing: MeetingUtil.canStopTranscribing(this.userDisplayHints),
@@ -4521,6 +4829,19 @@ export default class Meeting extends StatelessWebexPlugin {
4521
4829
  requiredHints: [DISPLAY_HINTS.DISABLE_ATTENDEE_START_POLLING_QA],
4522
4830
  displayHints: this.userDisplayHints,
4523
4831
  }),
4832
+ canAttendeeRequestAiAssistantEnabled: MeetingUtil.canAttendeeRequestAiAssistantEnabled(
4833
+ this.userDisplayHints,
4834
+ this.roles
4835
+ ),
4836
+ isAttendeeRequestAiAssistantDeclinedAll:
4837
+ MeetingUtil.attendeeRequestAiAssistantDeclinedAll(this.userDisplayHints),
4838
+ isAnonymizeDisplayNamesEnabled: MeetingUtil.isAnonymizeDisplayNamesEnabled(
4839
+ this.userDisplayHints
4840
+ ),
4841
+ canViewTheParticipantList: MeetingUtil.canViewTheParticipantList(
4842
+ this.userDisplayHints,
4843
+ this.canNotViewTheParticipantList ?? false
4844
+ ),
4524
4845
  }) || changed;
4525
4846
  }
4526
4847
  if (changed) {
@@ -4569,6 +4890,34 @@ export default class Meeting extends StatelessWebexPlugin {
4569
4890
  this.sipUri = sipUri;
4570
4891
  }
4571
4892
 
4893
+ /**
4894
+ * After initial locus setup, refreshes destination with synced locus data and optionally
4895
+ * performs deferred meeting info fetch when initial locus was incomplete.
4896
+ * @param {LocusDTO} locus
4897
+ * @returns {void}
4898
+ */
4899
+ public async finalizeMeetingAfterInitialLocusSetup(locus: LocusDTO): Promise<void> {
4900
+ if (locus && this?.destinationType === DESTINATION_TYPE.LOCUS_ID) {
4901
+ // destination is initialized from the initial locus snapshot in constructor,
4902
+ // so refresh it after locus sync to avoid stale partial hash-tree data.
4903
+ this.destination = locus;
4904
+ }
4905
+ if (
4906
+ (!this.meetingInfo || isEmpty(this.meetingInfo)) &&
4907
+ (this.destination as LocusDTO)?.info &&
4908
+ !this.fetchMeetingInfoTimeoutId &&
4909
+ !MeetingsUtil.isOneOnOneCall(locus)
4910
+ ) {
4911
+ try {
4912
+ await this.fetchMeetingInfo({});
4913
+ } catch (error: any) {
4914
+ LoggerProxy.logger.info(
4915
+ `Meeting:index#finalizeMeetingAfterInitialLocusSetup --> deferred fetchMeetingInfo failed: ${error.message}`
4916
+ );
4917
+ }
4918
+ }
4919
+ }
4920
+
4572
4921
  /**
4573
4922
  * Set the locus info the class instance. Should be called with the parsed locus
4574
4923
  * we got in the join response.
@@ -4592,7 +4941,8 @@ export default class Meeting extends StatelessWebexPlugin {
4592
4941
  mediaId: string;
4593
4942
  host: object;
4594
4943
  selfId: string;
4595
- dataSets: DataSet[];
4944
+ dataSets: DataSet[]; // only sent by Locus when hash trees are used
4945
+ metadata: Metadata; // only sent by Locus when hash trees are used
4596
4946
  }) {
4597
4947
  const mtgLocus: any = data.locus;
4598
4948
 
@@ -4608,6 +4958,7 @@ export default class Meeting extends StatelessWebexPlugin {
4608
4958
  trigger: 'join-response',
4609
4959
  locus: mtgLocus,
4610
4960
  dataSets: data.dataSets,
4961
+ metadata: data.metadata,
4611
4962
  });
4612
4963
  }
4613
4964
 
@@ -4817,6 +5168,7 @@ export default class Meeting extends StatelessWebexPlugin {
4817
5168
  this.localVideoStreamMuteStateHandler
4818
5169
  );
4819
5170
  oldStream?.off(LocalStreamEventNames.OutputTrackChange, this.localOutputTrackChangeHandler);
5171
+ oldStream?.off(LocalStreamEventNames.ConstraintsChange, this.localConstraintsChangeHandler);
4820
5172
 
4821
5173
  // we don't update this.mediaProperties.mediaDirection.sendVideo, because we always keep it as true to avoid extra SDP exchanges
4822
5174
  this.mediaProperties.setLocalVideoStream(localStream);
@@ -4832,6 +5184,7 @@ export default class Meeting extends StatelessWebexPlugin {
4832
5184
  this.localVideoStreamMuteStateHandler
4833
5185
  );
4834
5186
  localStream?.on(LocalStreamEventNames.OutputTrackChange, this.localOutputTrackChangeHandler);
5187
+ localStream?.on(LocalStreamEventNames.ConstraintsChange, this.localConstraintsChangeHandler);
4835
5188
 
4836
5189
  if (!this.isMultistream || !localStream) {
4837
5190
  // for multistream WCME automatically un-publishes the old stream when we publish a new one
@@ -4966,6 +5319,7 @@ export default class Meeting extends StatelessWebexPlugin {
4966
5319
  this.localVideoStreamMuteStateHandler
4967
5320
  );
4968
5321
  videoStream?.off(LocalStreamEventNames.OutputTrackChange, this.localOutputTrackChangeHandler);
5322
+ videoStream?.off(LocalStreamEventNames.ConstraintsChange, this.localConstraintsChangeHandler);
4969
5323
 
4970
5324
  shareAudioStream?.off(StreamEventNames.Ended, this.handleShareAudioStreamEnded);
4971
5325
  shareAudioStream?.off(
@@ -5035,8 +5389,7 @@ export default class Meeting extends StatelessWebexPlugin {
5035
5389
  public setMercuryListener() {
5036
5390
  // Client will have a socket manager and handle reconnecting to mercury, when we reconnect to mercury
5037
5391
  // if the meeting has active peer connections, it should try to reconnect.
5038
- // @ts-ignore
5039
- this.webex.internal.mercury.on(ONLINE, () => {
5392
+ this.mercuryOnlineHandler = () => {
5040
5393
  LoggerProxy.logger.info('Meeting:index#setMercuryListener --> Web socket online');
5041
5394
 
5042
5395
  // Only send restore event when it was disconnected before and for connected later
@@ -5046,15 +5399,47 @@ export default class Meeting extends StatelessWebexPlugin {
5046
5399
  });
5047
5400
  }
5048
5401
  this.hasWebsocketConnected = true;
5049
- });
5402
+ };
5050
5403
 
5051
- // @ts-ignore
5052
- this.webex.internal.mercury.on(OFFLINE, () => {
5404
+ this.mercuryOfflineHandler = () => {
5053
5405
  LoggerProxy.logger.error('Meeting:index#setMercuryListener --> Web socket offline');
5054
5406
  Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.MERCURY_CONNECTION_FAILURE, {
5055
5407
  correlation_id: this.correlationId,
5056
5408
  });
5057
- });
5409
+ };
5410
+
5411
+ // @ts-ignore
5412
+ this.webex.internal.mercury.on(ONLINE, this.mercuryOnlineHandler);
5413
+ // @ts-ignore
5414
+ this.webex.internal.mercury.on(OFFLINE, this.mercuryOfflineHandler);
5415
+ }
5416
+
5417
+ /**
5418
+ * Removes this meeting's Mercury ONLINE/OFFLINE event listeners registered
5419
+ * by setMercuryListener(). Must be called before Locus /leave to avoid
5420
+ * unnecessary syncs/metrics triggered by events received while leaving
5421
+ * (per Locus team recommendation).
5422
+ *
5423
+ * Mercury is a process-wide singleton shared with other plugins, so we
5424
+ * pass the bound handler refs to .off() to avoid clearing every listener
5425
+ * for ONLINE/OFFLINE on the shared emitter.
5426
+ *
5427
+ * Idempotent: subsequent calls are no-ops because the handler refs are
5428
+ * cleared after detaching.
5429
+ * @private
5430
+ * @returns {void}
5431
+ */
5432
+ private stopListeningForMercuryEvents() {
5433
+ if (this.mercuryOnlineHandler) {
5434
+ // @ts-ignore
5435
+ this.webex.internal.mercury.off(ONLINE, this.mercuryOnlineHandler);
5436
+ this.mercuryOnlineHandler = undefined;
5437
+ }
5438
+ if (this.mercuryOfflineHandler) {
5439
+ // @ts-ignore
5440
+ this.webex.internal.mercury.off(OFFLINE, this.mercuryOfflineHandler);
5441
+ this.mercuryOfflineHandler = undefined;
5442
+ }
5058
5443
  }
5059
5444
 
5060
5445
  /**
@@ -5078,6 +5463,7 @@ export default class Meeting extends StatelessWebexPlugin {
5078
5463
  );
5079
5464
 
5080
5465
  this.receiveSlotManager.reset();
5466
+
5081
5467
  this.mediaProperties.webrtcMediaConnection.close();
5082
5468
  this.mediaProperties.unsetPeerConnection();
5083
5469
  this.sendSlotManager.reset();
@@ -5365,7 +5751,7 @@ export default class Meeting extends StatelessWebexPlugin {
5365
5751
  } = {}
5366
5752
  ) {
5367
5753
  const {mediaOptions, joinOptions = {}} = options;
5368
- const {isRetry, prevJoinResponse} = this.joinWithMediaRetryInfo;
5754
+ const {retryCount, prevJoinResponse, prevError} = this.joinWithMediaRetryInfo;
5369
5755
 
5370
5756
  if (!mediaOptions?.allowMediaInLobby) {
5371
5757
  return Promise.reject(
@@ -5376,15 +5762,40 @@ export default class Meeting extends StatelessWebexPlugin {
5376
5762
 
5377
5763
  LoggerProxy.logger.info('Meeting:index#joinWithMedia called');
5378
5764
 
5765
+ /* Before we do anything, check if RTCPeerConnection is available. Normally this is checked
5766
+ by addMediaInternal() itself when creating the media connection, but since joinWithMedia()
5767
+ is a convenience method that does both join() and addMedia(), we want to fail fast here
5768
+ in case WebRTC is not available at all.
5769
+ */
5770
+ if (WebCapabilities.supportsRTCPeerConnection() === CapabilityState.NOT_CAPABLE) {
5771
+ // throw the same error that would be thrown by addMediaInternal()
5772
+ throw new Errors.WebrtcApiNotAvailableError(
5773
+ 'RTCPeerConnection API is not available in this environment'
5774
+ );
5775
+ }
5776
+
5777
+ /* While we're trying to join, we may fail and be doing a retry. In that case,
5778
+ we sometimes get dropped by Locus as a result of the 1st failed attempt.
5779
+ That notification from Locus needs to be ignored, otherwise it causes the meeting to be
5780
+ cleaned up and prevents the retry from running correctly.
5781
+ */
5782
+ this.locusInfo.suspendDestroyMeeting(true);
5783
+
5379
5784
  let joined = false;
5380
5785
  let joinResponse = prevJoinResponse;
5381
5786
 
5787
+ const shouldJoin =
5788
+ !joinResponse || // first try, when the join response is empty
5789
+ (prevError && prevError instanceof UserNotJoinedError) || // last try failed with UserNotJoinedError
5790
+ this.isErrorMeaningLocusDroppedUs(prevError) ||
5791
+ MeetingUtil.isUserInLeftState(this.locusInfo); // locus dropped the connection before we can re-try addMedia
5792
+
5382
5793
  try {
5383
5794
  let turnServerInfo;
5384
5795
  let turnDiscoverySkippedReason;
5385
5796
  let forceTurnDiscovery = false;
5386
5797
 
5387
- if (!joinResponse) {
5798
+ if (shouldJoin) {
5388
5799
  // This is the 1st attempt or a retry after join request failed -> we need to do a join with TURN discovery
5389
5800
 
5390
5801
  const turnDiscoveryRequest = await this.roap.generateTurnDiscoveryRequestMessage(
@@ -5423,16 +5834,24 @@ export default class Meeting extends StatelessWebexPlugin {
5423
5834
  joined = true;
5424
5835
  }
5425
5836
 
5837
+ const shouldRetryMediaWithOnlyTurnTLS = await this.shouldRetryMediaWithOnlyTurnTLS(prevError);
5838
+
5426
5839
  const mediaResponse = await this.addMediaInternal(
5427
5840
  () => {
5428
- return this.joinWithMediaRetryInfo.isRetry ? 'JOIN_MEETING_FINAL' : 'JOIN_MEETING_RETRY';
5841
+ // callback is not called when UserNotJoinedError is thrown
5842
+ return this.joinWithMediaRetryInfo.retryCount >= 1
5843
+ ? 'JOIN_MEETING_FINAL'
5844
+ : 'JOIN_MEETING_RETRY';
5429
5845
  },
5430
- turnServerInfo,
5431
5846
  forceTurnDiscovery,
5847
+ turnServerInfo,
5848
+ shouldRetryMediaWithOnlyTurnTLS ? 'relay' : undefined,
5432
5849
  mediaOptions
5433
5850
  );
5434
5851
 
5435
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
5852
+ this.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
5853
+
5854
+ this.locusInfo.suspendDestroyMeeting(false);
5436
5855
 
5437
5856
  return {
5438
5857
  join: joinResponse,
@@ -5446,10 +5865,17 @@ export default class Meeting extends StatelessWebexPlugin {
5446
5865
 
5447
5866
  this.roap.abortTurnDiscovery();
5448
5867
 
5449
- // if this was the first attempt, let's do a retry
5450
- let shouldRetry = !isRetry;
5868
+ // let's do a retry (but not on 1-1 calls, because the flow would get too complicated)
5869
+ let shouldRetry =
5870
+ !MeetingsUtil.isOneOnOneCall(this.locusInfo.parsedLocus) &&
5871
+ (retryCount < 1 ||
5872
+ ((error instanceof UserNotJoinedError || this.isErrorMeaningLocusDroppedUs(error)) &&
5873
+ retryCount < JOIN_WITH_MEDIA_RETRY_MAX_COUNT));
5451
5874
 
5452
- if (CallDiagnosticUtils.isSdpOfferCreationError(error)) {
5875
+ if (
5876
+ CallDiagnosticUtils.isSdpOfferCreationError(error) ||
5877
+ CallDiagnosticUtils.isWebrtcApiNotAvailableError(error)
5878
+ ) {
5453
5879
  // errors related to offer creation (for example missing H264 codec) will happen again no matter how many times we try,
5454
5880
  // so there is no point doing a retry
5455
5881
  shouldRetry = false;
@@ -5469,8 +5895,8 @@ export default class Meeting extends StatelessWebexPlugin {
5469
5895
  });
5470
5896
  }
5471
5897
 
5472
- // we only want to call leave if join was successful and this was a retry or we won't be doing any more retries
5473
- if (joined && (isRetry || !shouldRetry)) {
5898
+ // we only want to call leave if join was successful, and we won't be doing any more retries
5899
+ if (joined && !shouldRetry) {
5474
5900
  try {
5475
5901
  await this.leave({resourceId: joinOptions?.resourceId, reason: 'joinWithMedia failure'});
5476
5902
  } catch (e) {
@@ -5487,7 +5913,7 @@ export default class Meeting extends StatelessWebexPlugin {
5487
5913
  reason: error.message,
5488
5914
  stack: error.stack,
5489
5915
  leaveErrorReason: leaveError?.message,
5490
- isRetry,
5916
+ isRetry: retryCount > 0,
5491
5917
  },
5492
5918
  {
5493
5919
  type: error.name,
@@ -5496,15 +5922,28 @@ export default class Meeting extends StatelessWebexPlugin {
5496
5922
 
5497
5923
  if (shouldRetry) {
5498
5924
  LoggerProxy.logger.warn('Meeting:index#joinWithMedia --> retrying call to joinWithMedia');
5499
- this.joinWithMediaRetryInfo.isRetry = true;
5925
+ this.joinWithMediaRetryInfo.retryCount = retryCount + 1;
5500
5926
  this.joinWithMediaRetryInfo.prevJoinResponse = joinResponse;
5927
+ this.joinWithMediaRetryInfo.prevError = error;
5928
+ if (!this.joinWithMediaRetryInfo.firstError) {
5929
+ this.joinWithMediaRetryInfo.firstError = error;
5930
+ }
5501
5931
 
5502
5932
  return this.joinWithMedia(options);
5503
5933
  }
5504
5934
 
5505
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
5935
+ const {firstError} = this.joinWithMediaRetryInfo;
5506
5936
 
5507
- throw error;
5937
+ this.joinWithMediaRetryInfo = {
5938
+ retryCount: 0,
5939
+ prevJoinResponse: undefined,
5940
+ firstError: undefined,
5941
+ prevError: undefined,
5942
+ };
5943
+
5944
+ this.locusInfo.suspendDestroyMeeting(false);
5945
+
5946
+ throw firstError ?? error;
5508
5947
  }
5509
5948
  }
5510
5949
 
@@ -5609,8 +6048,7 @@ export default class Meeting extends StatelessWebexPlugin {
5609
6048
 
5610
6049
  try {
5611
6050
  const voiceaListenerCaptionUpdate = (payload) => {
5612
- // @ts-ignore
5613
- this.webex.internal.voicea.off(
6051
+ this.voiceaChannel?.off(
5614
6052
  VOICEAEVENTS.CAPTION_LANGUAGE_UPDATE,
5615
6053
  voiceaListenerCaptionUpdate
5616
6054
  );
@@ -5626,13 +6064,8 @@ export default class Meeting extends StatelessWebexPlugin {
5626
6064
  reject(payload);
5627
6065
  }
5628
6066
  };
5629
- // @ts-ignore
5630
- this.webex.internal.voicea.on(
5631
- VOICEAEVENTS.CAPTION_LANGUAGE_UPDATE,
5632
- voiceaListenerCaptionUpdate
5633
- );
5634
- // @ts-ignore
5635
- this.webex.internal.voicea.requestLanguage(language);
6067
+ this.voiceaChannel?.on(VOICEAEVENTS.CAPTION_LANGUAGE_UPDATE, voiceaListenerCaptionUpdate);
6068
+ this.voiceaChannel?.requestLanguage(language);
5636
6069
  } catch (error) {
5637
6070
  LoggerProxy.logger.error(`Meeting:index#setCaptionLanguage --> ${error}`);
5638
6071
 
@@ -5666,8 +6099,7 @@ export default class Meeting extends StatelessWebexPlugin {
5666
6099
 
5667
6100
  try {
5668
6101
  const voiceaListenerLanguageUpdate = (payload) => {
5669
- // @ts-ignore
5670
- this.webex.internal.voicea.off(
6102
+ this.voiceaChannel?.off(
5671
6103
  VOICEAEVENTS.SPOKEN_LANGUAGE_UPDATE,
5672
6104
  voiceaListenerLanguageUpdate
5673
6105
  );
@@ -5684,14 +6116,9 @@ export default class Meeting extends StatelessWebexPlugin {
5684
6116
  }
5685
6117
  };
5686
6118
 
5687
- // @ts-ignore
5688
- this.webex.internal.voicea.on(
5689
- VOICEAEVENTS.SPOKEN_LANGUAGE_UPDATE,
5690
- voiceaListenerLanguageUpdate
5691
- );
6119
+ this.voiceaChannel?.on(VOICEAEVENTS.SPOKEN_LANGUAGE_UPDATE, voiceaListenerLanguageUpdate);
5692
6120
 
5693
- // @ts-ignore
5694
- this.webex.internal.voicea.setSpokenLanguage(language);
6121
+ this.voiceaChannel?.setSpokenLanguage(language);
5695
6122
  } catch (error) {
5696
6123
  LoggerProxy.logger.error(`Meeting:index#setSpokenLanguage --> ${error}`);
5697
6124
 
@@ -5713,12 +6140,18 @@ export default class Meeting extends StatelessWebexPlugin {
5713
6140
  );
5714
6141
 
5715
6142
  try {
6143
+ if (!this.voiceaChannel) {
6144
+ LoggerProxy.logger.warn(
6145
+ 'Meeting:index#startTranscription --> voiceaChannel not available'
6146
+ );
6147
+
6148
+ return;
6149
+ }
6150
+
5716
6151
  if (!this.areVoiceaEventsSetup) {
5717
6152
  this.setUpVoiceaListeners();
5718
6153
  }
5719
-
5720
- // @ts-ignore
5721
- await this.webex.internal.voicea.turnOnCaptions(options?.spokenLanguage);
6154
+ await this.voiceaChannel.turnOnCaptions(options?.spokenLanguage);
5722
6155
  } catch (error) {
5723
6156
  LoggerProxy.logger.error(`Meeting:index#startTranscription --> ${error}`);
5724
6157
  Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.RECEIVE_TRANSCRIPTION_FAILURE, {
@@ -5742,7 +6175,23 @@ export default class Meeting extends StatelessWebexPlugin {
5742
6175
  */
5743
6176
  private processLocusLLMEvent = (event: LocusLLMEvent): void => {
5744
6177
  if (event.data.eventType === LOCUSEVENT.HASH_TREE_DATA_UPDATED) {
6178
+ // @ts-ignore
6179
+ if (this.config.experimental.storeLocusHashTreeEventsForDebugging) {
6180
+ storeEventForDebugging('llm', event.data);
6181
+ }
6182
+
6183
+ const {trackingId} = event;
6184
+
5745
6185
  this.locusInfo.parse(this, event.data);
6186
+
6187
+ // Only the client whose /sync request tracking id matches the tracking id echoed back on this
6188
+ // LLM message should emit client.locus.sync.complete. The tracking id lives at the top level
6189
+ // of the received LLM event envelope. When it is absent there is nothing to correlate, so
6190
+ // skip. onLocusSyncLlmMessage records the LLM arrival time and is a no-op unless a stored
6191
+ // record for this meeting matches the tracking id.
6192
+ if (trackingId) {
6193
+ this.onLocusSyncLlmMessage(this.id, trackingId);
6194
+ }
5746
6195
  } else {
5747
6196
  LoggerProxy.logger.warn(
5748
6197
  `Meeting:index#processLocusLLMEvent --> Unknown event type: ${event.data.eventType}`
@@ -5750,6 +6199,35 @@ export default class Meeting extends StatelessWebexPlugin {
5750
6199
  }
5751
6200
  };
5752
6201
 
6202
+ /**
6203
+ * Verifies the relay event was delivered for the active LLM session binding.
6204
+ * With the factory pattern, each meeting owns its channel, so we just verify
6205
+ * the route matches our channel's binding or the practice session binding.
6206
+ * @param {RelayEvent} event Event object coming from LLM Connection
6207
+ * @returns {boolean}
6208
+ */
6209
+ private isRelayEventRouteValid(event: RelayEvent): boolean {
6210
+ const route = event?.headers?.route;
6211
+
6212
+ if (!route) {
6213
+ return true;
6214
+ }
6215
+
6216
+ // With the factory pattern, both channels may be connected simultaneously.
6217
+ // Determine which session is "active" based on whether PS channel is connected.
6218
+ const isPracticeSession = this.webinar?.isPracticeSessionLLMChannelConnected() ?? false;
6219
+
6220
+ const expectedBinding = isPracticeSession
6221
+ ? this.webinar?.getPracticeSessionBinding()
6222
+ : this.llmChannel?.getBinding();
6223
+
6224
+ if (!expectedBinding || route === expectedBinding) {
6225
+ return true;
6226
+ }
6227
+
6228
+ return false;
6229
+ }
6230
+
5753
6231
  /**
5754
6232
  * Callback called when a relay event is received from meeting LLM Connection
5755
6233
  * @param {RelayEvent} e Event object coming from LLM Connection
@@ -5757,15 +6235,19 @@ export default class Meeting extends StatelessWebexPlugin {
5757
6235
  * @returns {void}
5758
6236
  */
5759
6237
  private processRelayEvent = (e: RelayEvent): void => {
6238
+ if (!this.isRelayEventRouteValid(e)) {
6239
+ return;
6240
+ }
5760
6241
  switch (e.data.relayType) {
5761
6242
  case REACTION_RELAY_TYPES.REACTION:
6243
+ // @ts-ignore - config coming from registerPlugin
5762
6244
  if (
5763
6245
  // @ts-ignore - config coming from registerPlugin
5764
- (this.config.receiveReactions || options.receiveReactions) &&
6246
+ this.config.receiveReactions &&
5765
6247
  this.isReactionsSupported()
5766
6248
  ) {
5767
6249
  const member = this.members.membersCollection.get(e.data.sender.participantId);
5768
- if (!member) {
6250
+ if (!member && !this.locusInfo?.info?.isWebinar) {
5769
6251
  // @ts-ignore -- fix type
5770
6252
  LoggerProxy.logger.warn(
5771
6253
  `Meeting:index#processRelayEvent --> Skipping handling of ${REACTION_RELAY_TYPES.REACTION} for ${this.id}. participantId ${e.data.sender.participantId} does not exist in membersCollection.`
@@ -5773,7 +6255,7 @@ export default class Meeting extends StatelessWebexPlugin {
5773
6255
  break;
5774
6256
  }
5775
6257
 
5776
- const {name} = member;
6258
+ const name = (member && member.name) || e.data.sender.displayName;
5777
6259
  const processedReaction: ProcessedReaction = {
5778
6260
  reaction: e.data.reaction,
5779
6261
  sender: {
@@ -5802,37 +6284,30 @@ export default class Meeting extends StatelessWebexPlugin {
5802
6284
  * @returns {void}
5803
6285
  */
5804
6286
  stopTranscription() {
5805
- if (this.transcription) {
5806
- // @ts-ignore
5807
- this.webex.internal.voicea.off(
5808
- VOICEAEVENTS.VOICEA_ANNOUNCEMENT,
5809
- this.voiceaListenerCallbacks[VOICEAEVENTS.VOICEA_ANNOUNCEMENT]
5810
- );
6287
+ this.voiceaChannel?.off(
6288
+ VOICEAEVENTS.VOICEA_ANNOUNCEMENT,
6289
+ this.voiceaListenerCallbacks[VOICEAEVENTS.VOICEA_ANNOUNCEMENT]
6290
+ );
5811
6291
 
5812
- // @ts-ignore
5813
- this.webex.internal.voicea.off(
5814
- VOICEAEVENTS.CAPTIONS_TURNED_ON,
5815
- this.voiceaListenerCallbacks[VOICEAEVENTS.CAPTIONS_TURNED_ON]
5816
- );
6292
+ this.voiceaChannel?.off(
6293
+ VOICEAEVENTS.CAPTIONS_TURNED_ON,
6294
+ this.voiceaListenerCallbacks[VOICEAEVENTS.CAPTIONS_TURNED_ON]
6295
+ );
5817
6296
 
5818
- // @ts-ignore
5819
- this.webex.internal.voicea.off(
5820
- VOICEAEVENTS.EVA_COMMAND,
5821
- this.voiceaListenerCallbacks[VOICEAEVENTS.EVA_COMMAND]
5822
- );
6297
+ this.voiceaChannel?.off(
6298
+ VOICEAEVENTS.EVA_COMMAND,
6299
+ this.voiceaListenerCallbacks[VOICEAEVENTS.EVA_COMMAND]
6300
+ );
5823
6301
 
5824
- // @ts-ignore
5825
- this.webex.internal.voicea.off(
5826
- VOICEAEVENTS.NEW_CAPTION,
5827
- this.voiceaListenerCallbacks[VOICEAEVENTS.NEW_CAPTION]
5828
- );
6302
+ this.voiceaChannel?.off(
6303
+ VOICEAEVENTS.NEW_CAPTION,
6304
+ this.voiceaListenerCallbacks[VOICEAEVENTS.NEW_CAPTION]
6305
+ );
5829
6306
 
5830
- // @ts-ignore
5831
- this.webex.internal.voicea.deregisterEvents();
6307
+ this.voiceaChannel?.deregisterEvents();
5832
6308
 
5833
- this.areVoiceaEventsSetup = false;
5834
- this.triggerStopReceivingTranscriptionEvent();
5835
- }
6309
+ this.areVoiceaEventsSetup = false;
6310
+ this.triggerStopReceivingTranscriptionEvent();
5836
6311
  }
5837
6312
 
5838
6313
  /**
@@ -5856,6 +6331,28 @@ export default class Meeting extends StatelessWebexPlugin {
5856
6331
  );
5857
6332
  }
5858
6333
 
6334
+ /**
6335
+ * Restores LLM subchannel subscriptions after reconnect when captions are active.
6336
+ * @returns {void}
6337
+ */
6338
+ private restoreLLMSubscriptionsIfNeeded(): void {
6339
+ try {
6340
+ const keepTranscriptionSubscribed = this.voiceaChannel?.getKeepTranscriptionSubscribed();
6341
+
6342
+ if (!keepTranscriptionSubscribed) {
6343
+ return;
6344
+ }
6345
+
6346
+ this.voiceaChannel?.updateSubchannelSubscriptions({subscribe: ['transcription']});
6347
+ } catch (error) {
6348
+ const msg = error?.message || String(error);
6349
+
6350
+ LoggerProxy.logger.warn(
6351
+ `Meeting:index#restoreLLMSubscriptionsIfNeeded --> failed to restore subscriptions after LLM online: ${msg}`
6352
+ );
6353
+ }
6354
+ }
6355
+
5859
6356
  /**
5860
6357
  * This is a callback for the LLM event that is triggered when it comes online
5861
6358
  * This method in turn will trigger an event to the developers that the LLM is connected
@@ -5864,8 +6361,9 @@ export default class Meeting extends StatelessWebexPlugin {
5864
6361
  * @returns {null}
5865
6362
  */
5866
6363
  private handleLLMOnline = (): void => {
5867
- // @ts-ignore
5868
- this.webex.internal.llm.off('online', this.handleLLMOnline);
6364
+ this.restoreLLMSubscriptionsIfNeeded();
6365
+ this.locusInfo.syncAllHashTreeDatasets({onlyLLM: true});
6366
+
5869
6367
  Trigger.trigger(
5870
6368
  this,
5871
6369
  {
@@ -6093,11 +6591,10 @@ export default class Meeting extends StatelessWebexPlugin {
6093
6591
  return Promise.reject(error);
6094
6592
  })
6095
6593
  .then((join) => {
6594
+ this.saveDataChannelToken(join);
6096
6595
  // @ts-ignore - config coming from registerPlugin
6097
6596
  if (this.config.enableAutomaticLLM) {
6098
- // @ts-ignore
6099
- this.webex.internal.llm.on('online', this.handleLLMOnline);
6100
- this.updateLLMConnection()
6597
+ this.updateLLMConnection({isInitialJoinPhase: true})
6101
6598
  .catch((error) => {
6102
6599
  LoggerProxy.logger.error(
6103
6600
  'Meeting:index#join --> Transcription Socket Connection Failed',
@@ -6131,12 +6628,10 @@ export default class Meeting extends StatelessWebexPlugin {
6131
6628
  this.clearLLMHealthCheckTimer();
6132
6629
 
6133
6630
  this.llmHealthCheckTimer = setTimeout(() => {
6134
- // @ts-ignore
6135
- const isConnected = this.webex.internal.llm.isConnected();
6631
+ const isConnected = this.llmChannel?.isConnected() ?? false;
6136
6632
 
6137
6633
  if (!isConnected) {
6138
- // @ts-ignore
6139
- const {hasEverConnected} = this.webex.internal.llm;
6634
+ const hasEverConnected = this.llmChannel?.hasEverConnected ?? false;
6140
6635
 
6141
6636
  // only send metric if not connected - to avoid too many metrics
6142
6637
  Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.LLM_HEALTHCHECK_FAILURE, {
@@ -6161,78 +6656,370 @@ export default class Meeting extends StatelessWebexPlugin {
6161
6656
  }
6162
6657
  }
6163
6658
 
6659
+ /**
6660
+ * Removes LLM event listeners and clears the health check timer.
6661
+ * Must be called before Locus /leave to avoid unnecessary syncs triggered
6662
+ * by events received while leaving (per Locus team recommendation).
6663
+ * Idempotent: safe to call multiple times; .off() is a no-op when no
6664
+ * matching listener is registered.
6665
+ * @private
6666
+ * @returns {void}
6667
+ */
6668
+ private stopListeningForLLMEvents() {
6669
+ this.llmChannel?.off('event:relay.event', this.processRelayEvent);
6670
+ this.llmChannel?.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6671
+ this.llmChannel?.off('online', this.handleLLMOnline);
6672
+ this.breakouts?.unregisterLLMChannel();
6673
+ this.voiceaChannel?.deregisterEvents();
6674
+ this.voiceaChannel = undefined;
6675
+ this.clearLLMHealthCheckTimer();
6676
+ }
6677
+
6678
+ /**
6679
+ * Stops listening on every event bus (LLM, Mercury, voicea/transcription,
6680
+ * annotation) that could otherwise deliver events to this meeting while
6681
+ * Locus is processing /leave or /end. Per the Locus team recommendation,
6682
+ * this must run before the Locus request is dispatched to avoid
6683
+ * unnecessary syncs triggered by in-flight events.
6684
+ *
6685
+ * Voicea (transcription) subscribes to llm 'event:relay.event' internally,
6686
+ * and the annotation plugin subscribes to both mercury and llm, so both
6687
+ * must be torn down alongside the direct LLM/Mercury listeners.
6688
+ *
6689
+ * Idempotent: safe to call multiple times; .off() is a no-op when no
6690
+ * matching listener is registered, and stopTranscription is guarded.
6691
+ * @private
6692
+ * @returns {void}
6693
+ */
6694
+ private stopListeningForMeetingEvents() {
6695
+ this.stopListeningForLLMEvents();
6696
+ this.stopListeningForMercuryEvents();
6697
+ if (this.transcription) {
6698
+ this.stopTranscription();
6699
+ this.transcription = undefined;
6700
+ }
6701
+ this.annotation.deregisterEvents();
6702
+ }
6703
+
6704
+ /**
6705
+ * Disconnects and cleans up the LLM channel owned by this meeting.
6706
+ *
6707
+ * @param {Object} options
6708
+ * @param {boolean} [options.throwOnError=true] rethrows disconnect errors when true
6709
+ * @returns {Promise<void>}
6710
+ */
6711
+ private cleanupLLMConneciton = async ({
6712
+ throwOnError = true,
6713
+ }: {
6714
+ throwOnError?: boolean;
6715
+ } = {}): Promise<void> => {
6716
+ // Always clear the timer, even if there's no channel
6717
+ this.clearLLMHealthCheckTimer();
6718
+
6719
+ if (!this.llmChannel) {
6720
+ return;
6721
+ }
6722
+
6723
+ try {
6724
+ await this.llmChannel.disconnect({
6725
+ code: 3050,
6726
+ reason: 'done (permanent)',
6727
+ });
6728
+ } catch (error) {
6729
+ LoggerProxy.logger.error(
6730
+ 'Meeting:index#cleanupLLMConneciton --> Failed to disconnect LLM channel',
6731
+ error
6732
+ );
6733
+
6734
+ if (throwOnError) {
6735
+ throw error;
6736
+ }
6737
+ } finally {
6738
+ this.stopListeningForLLMEvents();
6739
+ this.llmChannel = undefined;
6740
+ }
6741
+ };
6742
+
6743
+ /**
6744
+ * Sets the datachannel token on the meeting's LLM channel.
6745
+ * Used by the DataChannelAuthTokenInterceptor after refreshing tokens.
6746
+ * @param {string} token - The new datachannel token
6747
+ * @returns {void}
6748
+ */
6749
+ setLLMChannelDataToken(token: string): void {
6750
+ this.llmChannel?.setDatachannelToken(token);
6751
+ }
6752
+
6753
+ /**
6754
+ * Saves the data channel tokens from the join response.
6755
+ * Default session token is stored on this.llmChannel when available.
6756
+ * Practice session token is stored on the webinar's practice LLM channel.
6757
+ * @param {Object} join - The parsed join response (from MeetingUtil.parseLocusJoin)
6758
+ * @returns {void}
6759
+ */
6760
+ saveDataChannelToken(join: any): void {
6761
+ const datachannelToken = join?.locus?.self?.datachannelToken;
6762
+ const practiceSessionDatachannelToken = join?.locus?.self?.practiceSessionDatachannelToken;
6763
+
6764
+ // Store default session token on our LLM channel if it exists
6765
+ if (datachannelToken && this.llmChannel) {
6766
+ this.llmChannel.setDatachannelToken(datachannelToken);
6767
+ }
6768
+
6769
+ // Store the token temporarily for use when channel is created
6770
+ if (datachannelToken) {
6771
+ this._pendingDatachannelToken = datachannelToken;
6772
+ }
6773
+
6774
+ // Practice session token is handled by webinar
6775
+ if (practiceSessionDatachannelToken) {
6776
+ this.webinar.setPracticeSessionDatachannelToken(practiceSessionDatachannelToken);
6777
+ }
6778
+ }
6779
+
6780
+ /**
6781
+ * Ensures default-session data channel token exists after lobby admission.
6782
+ * Some lobby users do not receive a token until they are admitted.
6783
+ * @returns {Promise<boolean>} true when a new token is fetched and cached
6784
+ */
6785
+ private async ensureDefaultDatachannelTokenAfterAdmit(): Promise<boolean> {
6786
+ try {
6787
+ const datachannelToken =
6788
+ this.llmChannel?.getDatachannelToken() ?? this._pendingDatachannelToken;
6789
+ // @ts-ignore
6790
+ const isDataChannelTokenEnabled = await this.webex.internal.llm.isDataChannelTokenEnabled();
6791
+
6792
+ if (!isDataChannelTokenEnabled || datachannelToken) {
6793
+ return false;
6794
+ }
6795
+
6796
+ const response = await this.meetingRequest.fetchDatachannelToken({
6797
+ locusUrl: this.locusUrl,
6798
+ requestingParticipantId: this.members.selfId,
6799
+ isPracticeSession: false,
6800
+ });
6801
+ const fetchedDatachannelToken = response?.body?.datachannelToken;
6802
+
6803
+ if (!fetchedDatachannelToken) {
6804
+ return false;
6805
+ }
6806
+
6807
+ // Store on channel if exists, otherwise save as pending
6808
+ if (this.llmChannel) {
6809
+ this.llmChannel.setDatachannelToken(fetchedDatachannelToken);
6810
+ } else {
6811
+ this._pendingDatachannelToken = fetchedDatachannelToken;
6812
+ }
6813
+
6814
+ return true;
6815
+ } catch (error) {
6816
+ const msg = error?.message || String(error);
6817
+
6818
+ LoggerProxy.logger.warn(
6819
+ `Meeting:index#ensureDefaultDatachannelTokenAfterAdmit --> failed to proactively fetch default data channel token after admit: ${msg}`,
6820
+ {statusCode: error?.statusCode}
6821
+ );
6822
+
6823
+ return false;
6824
+ }
6825
+ }
6826
+
6164
6827
  /**
6165
6828
  * Connects to low latency mercury and reconnects if the address has changed
6166
6829
  * It will also disconnect if called when the meeting has ended
6167
- * @param {String} datachannelUrl
6830
+ * @param {Object} [options]
6831
+ * @param {boolean} [options.isInitialJoinPhase] true when called from initial join flow
6168
6832
  * @returns {Promise}
6169
6833
  */
6170
- async updateLLMConnection() {
6834
+ async updateLLMConnection({isInitialJoinPhase = false}: {isInitialJoinPhase?: boolean} = {}) {
6171
6835
  // @ts-ignore - Fix type
6172
- const {url, info: {datachannelUrl, practiceSessionDatachannelUrl} = {}} = this.locusInfo;
6836
+ const {url = undefined, info: {datachannelUrl = undefined} = {}} = this.locusInfo || {};
6173
6837
 
6174
6838
  const isJoined = this.isJoined();
6839
+ const dataChannelUrl = datachannelUrl;
6175
6840
 
6176
- // webinar panelist should use new data channel in practice session
6177
- const dataChannelUrl =
6178
- this.webinar.isJoinPracticeSessionDataChannel() && practiceSessionDatachannelUrl
6179
- ? practiceSessionDatachannelUrl
6180
- : datachannelUrl;
6841
+ // If we have an existing channel, check if we should reuse it or clean it up
6842
+ if (this.llmChannel) {
6843
+ const isSameUrls =
6844
+ url === this.llmChannel.getLocusUrl() &&
6845
+ dataChannelUrl === this.llmChannel.getDatachannelUrl();
6181
6846
 
6182
- // @ts-ignore - Fix type
6183
- if (this.webex.internal.llm.isConnected()) {
6184
- if (
6185
- // @ts-ignore - Fix type
6186
- url === this.webex.internal.llm.getLocusUrl() &&
6187
- // @ts-ignore - Fix type
6188
- dataChannelUrl === this.webex.internal.llm.getDatachannelUrl() &&
6189
- isJoined
6190
- ) {
6847
+ // If already connected to same URLs, skip reconnect
6848
+ if (this.llmChannel.isConnected() && isSameUrls && isJoined) {
6191
6849
  return undefined;
6192
6850
  }
6193
- // @ts-ignore - Fix type
6194
- await this.webex.internal.llm.disconnectLLM(
6195
- isJoined
6196
- ? {
6197
- code: 3050,
6198
- reason: 'done (permanent)',
6199
- }
6200
- : undefined
6201
- );
6202
- // @ts-ignore - Fix type
6203
- this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6204
- // @ts-ignore - Fix type
6205
- this.webex.internal.llm.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6206
6851
 
6207
- this.clearLLMHealthCheckTimer();
6852
+ // If currently connecting to same URLs, wait for that to complete
6853
+ if (this.llmChannel.isConnecting() && isSameUrls && isJoined) {
6854
+ return undefined;
6855
+ }
6856
+
6857
+ // URLs changed or not joined, disconnect existing channel
6858
+ await this.cleanupLLMConneciton();
6208
6859
  }
6209
6860
 
6210
6861
  if (!isJoined) {
6211
6862
  return undefined;
6212
6863
  }
6213
6864
 
6865
+ // Create a new LLM channel for this meeting
6214
6866
  // @ts-ignore - Fix type
6215
- return this.webex.internal.llm
6216
- .registerAndConnect(url, dataChannelUrl)
6867
+ this.llmChannel = this.webex.internal.llm.createChannel();
6868
+
6869
+ // Get token from pending (saved from join response) or channel
6870
+ const datachannelToken = this._pendingDatachannelToken ?? this.llmChannel.getDatachannelToken();
6871
+
6872
+ // Set up refresh handler before registration so interceptor-triggered token
6873
+ // refresh during register POST can resolve a valid handler.
6874
+ this.llmChannel.setRefreshHandler(() => this.refreshDataChannelToken());
6875
+
6876
+ // If we have a pending token, store it on the channel
6877
+ if (this._pendingDatachannelToken) {
6878
+ this.llmChannel.setDatachannelToken(this._pendingDatachannelToken);
6879
+ this._pendingDatachannelToken = undefined;
6880
+ }
6881
+
6882
+ return this.llmChannel
6883
+ .registerAndConnect(url, dataChannelUrl, datachannelToken)
6217
6884
  .then((registerAndConnectResult) => {
6885
+ this.locusInfo.syncAllHashTreeDatasets({onlyLLM: true});
6886
+
6887
+ // Register event listeners on the channel
6888
+ this.llmChannel.off('event:relay.event', this.processRelayEvent);
6889
+ this.llmChannel.on('event:relay.event', this.processRelayEvent);
6890
+ this.llmChannel.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6891
+ this.llmChannel.on(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6892
+ this.llmChannel.off('online', this.handleLLMOnline);
6893
+ this.llmChannel.on('online', this.handleLLMOnline);
6894
+
6895
+ // Register annotation channel only if not in practice session
6896
+ // (practice session manages its own annotation channel via updatePSDataChannel)
6897
+ if (!this.webinar?.isJoinPracticeSessionDataChannel()) {
6898
+ this.annotation.registerChannel(this.llmChannel);
6899
+ }
6900
+
6901
+ // Register breakouts channel
6902
+ this.breakouts.registerLLMChannel(this.llmChannel);
6903
+
6904
+ // Create VoiceaChannel for this meeting
6218
6905
  // @ts-ignore - Fix type
6219
- this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6220
- // @ts-ignore - Fix type
6221
- this.webex.internal.llm.on('event:relay.event', this.processRelayEvent);
6222
- // @ts-ignore - Fix type
6223
- this.webex.internal.llm.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6224
- // @ts-ignore - Fix type
6225
- this.webex.internal.llm.on(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6906
+ this.voiceaChannel = this.webex.internal.voicea.createChannel(this.llmChannel);
6226
6907
  LoggerProxy.logger.info(
6227
6908
  'Meeting:index#updateLLMConnection --> enabled to receive relay events!'
6228
6909
  );
6229
-
6230
6910
  this.startLLMHealthCheckTimer();
6231
6911
 
6912
+ if (registerAndConnectResult) {
6913
+ if (isInitialJoinPhase) {
6914
+ this.sendLLMConnectMetric(registerAndConnectResult);
6915
+ }
6916
+
6917
+ this.breakouts?.trigger(BREAKOUTS.EVENTS.LLM_CONNECT_RESPONSE, {
6918
+ meeting: this,
6919
+ llmLatency: registerAndConnectResult,
6920
+ });
6921
+ }
6922
+
6232
6923
  return Promise.resolve(registerAndConnectResult);
6924
+ })
6925
+ .catch((error) => {
6926
+ // Prefer the partial timing registerAndConnect attaches when register succeeded but the
6927
+ // websocket connect() failed, so a ws failure isn't misreported as register never completing.
6928
+ const llmLatency = {
6929
+ clientLLMDatachannelResponseTime: error?.timing?.clientLLMDatachannelResponseTime ?? 0,
6930
+ clientLLMWebSocketConnectTime: 0,
6931
+ };
6932
+
6933
+ if (isInitialJoinPhase) {
6934
+ this.sendLLMConnectMetric(llmLatency, error);
6935
+ }
6936
+
6937
+ this.breakouts?.trigger(BREAKOUTS.EVENTS.LLM_CONNECT_RESPONSE, {
6938
+ meeting: this,
6939
+ llmLatency,
6940
+ error,
6941
+ });
6942
+
6943
+ // Clean up the channel on failure
6944
+ this.llmChannel = undefined;
6945
+
6946
+ return Promise.reject(error);
6233
6947
  });
6234
6948
  }
6235
6949
 
6950
+ /**
6951
+ * Ensures breakout join response metric with LLM latency is emitted only once per breakout move id.
6952
+ * @param {string | undefined} breakoutMoveId
6953
+ * @param {boolean} [hasLLMLatency=false]
6954
+ * @returns {boolean}
6955
+ */
6956
+ private shouldEmitBreakoutJoinResponseMetric(
6957
+ breakoutMoveId?: string,
6958
+ hasLLMLatency = false
6959
+ ): boolean {
6960
+ if (!breakoutMoveId) {
6961
+ return false;
6962
+ }
6963
+
6964
+ if (!hasLLMLatency) {
6965
+ // When automatic LLM is enabled, updateLLMConnection will emit this same breakout join
6966
+ // response after the LLM connection finishes, including llmLatency and llmWebsocketUrl.
6967
+ // Suppress the earlier non-LLM event to avoid sending two events for the same move id,
6968
+ // where the first one would be missing the LLM-specific fields we want to validate.
6969
+ // @ts-ignore - config coming from registerPlugin
6970
+ return !this.config.enableAutomaticLLM;
6971
+ }
6972
+
6973
+ if (this.emittedBreakoutJoinResponseMoveIds.has(breakoutMoveId)) {
6974
+ return false;
6975
+ }
6976
+
6977
+ this.emittedBreakoutJoinResponseMoveIds.add(breakoutMoveId);
6978
+
6979
+ return true;
6980
+ }
6981
+
6982
+ /**
6983
+ * Sends LLM connect latencies for initial join flow.
6984
+ * @param {RegisterAndConnectTiming} timings
6985
+ * @param {any} [error]
6986
+ * @returns {void}
6987
+ */
6988
+ private sendLLMConnectMetric(timings: RegisterAndConnectTiming, error?: any) {
6989
+ // @ts-ignore
6990
+ const llmWebsocketUrl = this.webex.internal.llm.getWebSocketUrl?.() || undefined;
6991
+ const {clientLLMDatachannelResponseTime = 0, clientLLMWebSocketConnectTime} = timings || {};
6992
+
6993
+ const llmLatency: any = {
6994
+ clientLLMDatachannelResponseTime,
6995
+ };
6996
+
6997
+ if (clientLLMWebSocketConnectTime !== undefined) {
6998
+ llmLatency.clientLLMWebSocketConnectTime = clientLLMWebSocketConnectTime;
6999
+ }
7000
+
7001
+ const payload: any = {
7002
+ identifiers: {
7003
+ llmWebsocketUrl,
7004
+ },
7005
+ llmLatency,
7006
+ };
7007
+
7008
+ const options: any = {
7009
+ meetingId: this.id,
7010
+ ...(error && {rawError: error}),
7011
+ };
7012
+
7013
+ const metricEvent = {
7014
+ name: 'client.llm.connect.response',
7015
+ payload,
7016
+ options,
7017
+ };
7018
+
7019
+ // @ts-ignore
7020
+ this.webex.internal.newMetrics.submitClientEvent(metricEvent);
7021
+ }
7022
+
6236
7023
  /**
6237
7024
  * Use phone for meeting audio
6238
7025
  * @param {String} phoneNumber If provided, it will dial-out using this number. If not provided, dial-in will be used
@@ -6660,16 +7447,32 @@ export default class Meeting extends StatelessWebexPlugin {
6660
7447
  // @ts-ignore
6661
7448
  const cdl = this.webex.internal.newMetrics.callDiagnosticLatencies;
6662
7449
 
7450
+ // Compute the offer->answer latency from when the local SDP offer was generated up to now,
7451
+ // rather than from the stored remote-sdp-received timestamp. That stored timestamp uses
7452
+ // saveFirstTimestampOnly, so if waitForRemoteSDPAnswer() already timed out and submitted a
7453
+ // remote-sdp-received event, the stored value would be pinned to the timeout time and would
7454
+ // under-report an answer that arrives late. This handler fires exactly when the answer is
7455
+ // processed, so Date.now() is the accurate "received" time.
7456
+ // (submitClientEvent below still records the remote-sdp-received timestamp used by the CA
7457
+ // join-time metric, so we don't need to save it here.)
7458
+ const localSdpGeneratedTimestamp = cdl.latencyTimestamps.get(
7459
+ 'client.media-engine.local-sdp-generated'
7460
+ );
7461
+ const localSDPGenRemoteSDPRecv =
7462
+ localSdpGeneratedTimestamp !== undefined
7463
+ ? Date.now() - localSdpGeneratedTimestamp
7464
+ : undefined;
7465
+
6663
7466
  // @ts-ignore
6664
7467
  this.webex.internal.newMetrics.submitClientEvent({
6665
7468
  name: 'client.media-engine.remote-sdp-received',
7469
+ payload: {
7470
+ eventData: {
7471
+ localSDPGenRemoteSDPRecv,
7472
+ },
7473
+ },
6666
7474
  options: {meetingId: this.id},
6667
7475
  });
6668
- Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.ROAP_OFFER_TO_ANSWER_LATENCY, {
6669
- correlation_id: this.correlationId,
6670
- latency: cdl.getLocalSDPGenRemoteSDPRecv(),
6671
- meetingId: this.id,
6672
- });
6673
7476
 
6674
7477
  if (this.deferSDPAnswer) {
6675
7478
  this.deferSDPAnswer.resolve();
@@ -7255,23 +8058,104 @@ export default class Meeting extends StatelessWebexPlugin {
7255
8058
  }
7256
8059
  }
7257
8060
  });
8061
+ this.statsAnalyzer.on(StatsAnalyzerEventNames.STATS_UPDATE, (data) => {
8062
+ // Extract srtpCipher from transport stats
8063
+ let srtpCipher: string | undefined;
8064
+ for (const stats of data.stats.values()) {
8065
+ if (stats.type === 'transport' && stats.srtpCipher) {
8066
+ srtpCipher = stats.srtpCipher as string;
8067
+ break;
8068
+ }
8069
+ }
8070
+
8071
+ // Only emit event if srtpCipher has changed
8072
+ if (srtpCipher && srtpCipher !== this.mediaProperties.srtpCipher) {
8073
+ LoggerProxy.logger.info(
8074
+ `Meeting:index#setupStatsAnalyzerEventHandlers --> SRTP cipher changed from ${this.mediaProperties.srtpCipher} to ${srtpCipher}`
8075
+ );
8076
+ this.mediaProperties.srtpCipher = srtpCipher;
8077
+ Trigger.trigger(
8078
+ this,
8079
+ {
8080
+ file: 'meeting/index',
8081
+ function: 'setupStatsAnalyzerEventHandlers',
8082
+ },
8083
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
8084
+ {srtpCipher}
8085
+ );
8086
+ }
8087
+ });
7258
8088
  };
7259
8089
 
7260
8090
  getMediaConnectionDebugId() {
7261
8091
  return `MC-${this.id.substring(0, 4)}`;
7262
8092
  }
7263
8093
 
8094
+ /**
8095
+ * Checks if the error indicates that Locus dropped us from the meeting,
8096
+ * either directly on the error or wrapped inside an AddMediaFailed cause.
8097
+ * This method is meant to be called only with errors thrown by Meeting.addMediaInternal()
8098
+ *
8099
+ * @param {Error} error
8100
+ * @returns {boolean}
8101
+ */
8102
+ private isErrorMeaningLocusDroppedUs(error: Error | undefined): boolean {
8103
+ const statusCode = (error as any)?.statusCode;
8104
+ const causeStatusCode = (error as any)?.cause?.statusCode;
8105
+
8106
+ return (
8107
+ statusCode === 409 || statusCode === 403 || causeStatusCode === 409 || causeStatusCode === 403
8108
+ );
8109
+ }
8110
+
8111
+ /**
8112
+ * Determines if the next media attempt should use only TURN-TLS (iceTransportPolicy='relay').
8113
+ * We do this in the hope that it will minimize the chance of Homer sending DTLS packets on a wrong
8114
+ * transport (as there will be only 1 transport) and dealing with firewalls that let STUN packets through, but block
8115
+ * other UDP traffic.
8116
+ *
8117
+ * For clients landing on video mesh nodes (VMN), reachability might still have successful TLS (to public nodes)
8118
+ * but TURN discovery will result in empty TURN urls array and iceTransportPolicy='relay' will still be overriden to undefined,
8119
+ * see the code in establishMediaConnection()
8120
+ *
8121
+ * @param {Error} prevError - The error from the previous addMedia attempt
8122
+ * @returns {Promise<boolean>}
8123
+ */
8124
+ private async shouldRetryMediaWithOnlyTurnTLS(prevError: Error | undefined): Promise<boolean> {
8125
+ if (
8126
+ this.isMultistream &&
8127
+ prevError instanceof AddMediaFailed &&
8128
+ prevError.isDtlsHandshakeFailure &&
8129
+ prevError.connectionType === 'UDP'
8130
+ ) {
8131
+ const hasTlsReachability =
8132
+ // @ts-ignore
8133
+ await this.webex.meetings.reachability.isAnyClusterReachableViaProtocol('xtls');
8134
+
8135
+ if (hasTlsReachability) {
8136
+ LoggerProxy.logger.info(
8137
+ 'Meeting:index#shouldRetryMediaWithOnlyTurnTLS --> previous attempt failed due to DTLS handshake failure over UDP and TLS reachability is available'
8138
+ );
8139
+
8140
+ return true;
8141
+ }
8142
+ }
8143
+
8144
+ return false;
8145
+ }
8146
+
7264
8147
  /**
7265
8148
  * Creates a webrtc media connection and publishes streams to it
7266
8149
  *
7267
8150
  * @param {Object} turnServerInfo TURN server information
7268
8151
  * @param {BundlePolicy} [bundlePolicy] Bundle policy settings
7269
- * @param {AddMediaOptions} [options] Options for enabling/disabling audio/video
8152
+ * @param {RTCIceTransportPolicy} [iceTransportPolicy] ICE transport policy override
7270
8153
  * @returns {RoapMediaConnection | MultistreamRoapMediaConnection}
7271
8154
  */
7272
8155
  private async createMediaConnection(
7273
8156
  turnServerInfo?: TurnServerInfo,
7274
- bundlePolicy?: BundlePolicy
8157
+ bundlePolicy?: BundlePolicy,
8158
+ iceTransportPolicy?: RTCIceTransportPolicy
7275
8159
  ) {
7276
8160
  this.rtcMetrics = this.isMultistream
7277
8161
  ? // @ts-ignore
@@ -7295,12 +8179,15 @@ export default class Meeting extends StatelessWebexPlugin {
7295
8179
  enableExtmap: this.config.enableExtmap,
7296
8180
  turnServerInfo,
7297
8181
  bundlePolicy,
8182
+ iceTransportPolicy,
7298
8183
  // @ts-ignore - config coming from registerPlugin
7299
8184
  iceCandidatesTimeout: this.config.iceCandidatesGatheringTimeout,
7300
8185
  // @ts-ignore - config coming from registerPlugin
7301
8186
  disableAudioMainDtx: this.config.experimental.disableAudioMainDtx,
7302
8187
  // @ts-ignore - config coming from registerPlugin
7303
8188
  enableAudioTwcc: this.config.enableAudioTwccForMultistream,
8189
+ // @ts-ignore - config coming from registerPlugin
8190
+ enableAv1SlidesSupport: this.config.enableAv1SlidesSupport,
7304
8191
  stopIceGatheringAfterFirstRelayCandidate:
7305
8192
  // @ts-ignore - config coming from registerPlugin
7306
8193
  this.config.stopIceGatheringAfterFirstRelayCandidate,
@@ -7320,6 +8207,7 @@ export default class Meeting extends StatelessWebexPlugin {
7320
8207
  this.mediaProperties.mediaDirection.receiveShare,
7321
8208
  ];
7322
8209
 
8210
+ this.sendSlotManager.reset();
7323
8211
  this.sendSlotManager.createSlot(mc, MediaType.VideoMain, videoEnabled);
7324
8212
  this.sendSlotManager.createSlot(mc, MediaType.AudioMain, audioEnabled);
7325
8213
  this.sendSlotManager.createSlot(mc, MediaType.VideoSlides, shareEnabled);
@@ -7417,9 +8305,9 @@ export default class Meeting extends StatelessWebexPlugin {
7417
8305
  */
7418
8306
  private async waitForMediaConnectionConnected(): Promise<void> {
7419
8307
  try {
7420
- await this.mediaProperties.waitForMediaConnectionConnected();
8308
+ await this.mediaProperties.waitForMediaConnectionConnected(this.correlationId);
7421
8309
  } catch (error) {
7422
- const {iceConnected} = error;
8310
+ const {iceConnected} = error as MediaConnectionAwaiterFailureResult;
7423
8311
 
7424
8312
  if (!this.hasMediaConnectionConnectedAtLeastOnce) {
7425
8313
  // Only send CA event for join flow if we haven't successfully connected media yet
@@ -7459,13 +8347,12 @@ export default class Meeting extends StatelessWebexPlugin {
7459
8347
  });
7460
8348
  }
7461
8349
 
7462
- const timedOutError = new Error(
7463
- `Timed out waiting for media connection to be connected, correlationId=${this.correlationId}`
8350
+ throw new MediaConnectionTimedOutError(
8351
+ `Timed out waiting for media connection to be connected, correlationId=${this.correlationId}`,
8352
+ iceConnected,
8353
+ // keep reference to the original rejected result (which is the object the SDK reports to CA as rawError above)
8354
+ error
7464
8355
  );
7465
-
7466
- timedOutError.cause = error;
7467
-
7468
- throw timedOutError;
7469
8356
  }
7470
8357
  }
7471
8358
 
@@ -7511,12 +8398,12 @@ export default class Meeting extends StatelessWebexPlugin {
7511
8398
  return !member.isSelf && !member.isPairedWithSelf && !member.isAudioMuted;
7512
8399
  });
7513
8400
 
7514
- if (atLeastOneUnmutedOtherMember) {
7515
- this.mediaProperties.sendMediaIssueMetric(
7516
- 'inbound_audio',
7517
- data.issueSubType,
7518
- this.correlationId
7519
- );
8401
+ // we also ignore any issues while we're waiting in the lobby, as we're not receiving any audio yet
8402
+ if (atLeastOneUnmutedOtherMember && !this.isUserUnadmitted) {
8403
+ this.mediaProperties.sendMediaIssueMetric('inbound_audio', data.issueSubType, {
8404
+ correlationId: this.correlationId,
8405
+ isMultistream: this.isMultistream,
8406
+ });
7520
8407
 
7521
8408
  Trigger.trigger(
7522
8409
  this,
@@ -7678,7 +8565,18 @@ export default class Meeting extends StatelessWebexPlugin {
7678
8565
  error
7679
8566
  );
7680
8567
 
7681
- throw new AddMediaFailed(error);
8568
+ const {connectionType, selectedCandidatePairChanges, numTransports} =
8569
+ await this.mediaProperties.getCurrentConnectionInfo();
8570
+
8571
+ const iceConnected = error instanceof MediaConnectionTimedOutError && error.iceConnected;
8572
+
8573
+ throw new AddMediaFailed({
8574
+ cause: error,
8575
+ connectionType,
8576
+ selectedCandidatePairChanges,
8577
+ numTransports,
8578
+ iceConnected,
8579
+ });
7682
8580
  }
7683
8581
  }
7684
8582
 
@@ -7753,7 +8651,21 @@ export default class Meeting extends StatelessWebexPlugin {
7753
8651
  ({turnServerInfo} = await this.doTurnDiscovery(isReconnecting, isForced));
7754
8652
  }
7755
8653
 
7756
- const mc = await this.createMediaConnection(turnServerInfo, bundlePolicy);
8654
+ if (
8655
+ (!turnServerInfo || !turnServerInfo.urls?.length) &&
8656
+ this.addMediaData.iceTransportPolicy === 'relay'
8657
+ ) {
8658
+ LoggerProxy.logger.info(
8659
+ `${LOG_HEADER} cannot do iceTransportPolicy=relay, because there is no turn server info available`
8660
+ );
8661
+ // drop the forced relay policy and use the default, because we don't have a TURN server
8662
+ this.addMediaData.iceTransportPolicy = undefined;
8663
+ }
8664
+ const mediaConnection = await this.createMediaConnection(
8665
+ turnServerInfo,
8666
+ bundlePolicy,
8667
+ this.addMediaData.iceTransportPolicy
8668
+ );
7757
8669
 
7758
8670
  LoggerProxy.logger.info(
7759
8671
  `${LOG_HEADER} media connection created this.isMultistream=${this.isMultistream}`
@@ -7790,7 +8702,7 @@ export default class Meeting extends StatelessWebexPlugin {
7790
8702
  await this.remoteMediaManager.start();
7791
8703
  }
7792
8704
 
7793
- await mc.initiateOffer();
8705
+ await mediaConnection.initiateOffer();
7794
8706
 
7795
8707
  await this.waitForRemoteSDPAnswer();
7796
8708
 
@@ -7858,6 +8770,9 @@ export default class Meeting extends StatelessWebexPlugin {
7858
8770
 
7859
8771
  this.isMultistream = false;
7860
8772
 
8773
+ // reset iceTransportPolicy, because it's only applied for multistream media connections
8774
+ this.addMediaData.iceTransportPolicy = undefined;
8775
+
7861
8776
  if (this.mediaProperties.webrtcMediaConnection) {
7862
8777
  // close peer connection, but don't reset mute state information, because we will want to use it on the retry
7863
8778
  this.closePeerConnections(false);
@@ -7938,6 +8853,8 @@ export default class Meeting extends StatelessWebexPlugin {
7938
8853
  regionCode: this.webex.meetings.geoHintInfo?.regionCode,
7939
8854
  },
7940
8855
  preferTranscoding: !this.isMultistream,
8856
+ getCurrentSelfUrl: () => this.selfUrl,
8857
+ waitForSelfUrlChange: () => this.waitForSelfUrlChange(),
7941
8858
  },
7942
8859
  {
7943
8860
  // @ts-ignore
@@ -7946,6 +8863,41 @@ export default class Meeting extends StatelessWebexPlugin {
7946
8863
  );
7947
8864
  }
7948
8865
 
8866
+ /**
8867
+ * Waits for LocusInfo to update meeting.selfUrl, with a timeout fallback.
8868
+ * @returns {Promise<void>}
8869
+ * @private
8870
+ * @memberof Meeting
8871
+ */
8872
+ private waitForSelfUrlChange(): Promise<void> {
8873
+ if (this.joinWithMediaRetryInfo.retryCount > 0) {
8874
+ /* During joinWithMedia() retries we can get 403/409 from Locus and it doesn't mean
8875
+ * that the selfUrl will change, it is usually caused by Locus dropping us as a result of
8876
+ * media connection failure during joinWithMedia's earlier media connection attempt,
8877
+ * so we don't want to wait for selfUrl change as this would only slow down the join process. */
8878
+ LoggerProxy.logger.info(
8879
+ 'Meeting:index#waitForSelfUrlChange --> joinWithMedia retry in progress, will not wait for selfUrl change'
8880
+ );
8881
+
8882
+ return Promise.resolve();
8883
+ }
8884
+
8885
+ if (!this.promisesWaitingForPropUpdate.selfUrl) {
8886
+ const pendingSelfUrlUpdate = new Defer();
8887
+
8888
+ this.promisesWaitingForPropUpdate.selfUrl = pendingSelfUrlUpdate;
8889
+
8890
+ setTimeout(() => {
8891
+ if (this.promisesWaitingForPropUpdate.selfUrl === pendingSelfUrlUpdate) {
8892
+ delete this.promisesWaitingForPropUpdate.selfUrl;
8893
+ pendingSelfUrlUpdate.resolve();
8894
+ }
8895
+ }, 5000);
8896
+ }
8897
+
8898
+ return this.promisesWaitingForPropUpdate.selfUrl.promise;
8899
+ }
8900
+
7949
8901
  /**
7950
8902
  * Creates a media connection to the server. Media connection is required for sending or receiving any audio/video.
7951
8903
  *
@@ -7957,8 +8909,9 @@ export default class Meeting extends StatelessWebexPlugin {
7957
8909
  addMedia(options: AddMediaOptions = {}): Promise<void> {
7958
8910
  return this.addMediaInternal(
7959
8911
  () => (this.turnServerUsed ? 'JOIN_MEETING_FINAL' : 'JOIN_MEETING_RETRY'),
7960
- undefined,
7961
8912
  false,
8913
+ undefined /* turnServerInfo - it will be fetched via doTurnDiscovery() */,
8914
+ undefined /* iceTransportPolicy - we're relying on the default value */,
7962
8915
  options
7963
8916
  );
7964
8917
  }
@@ -7967,8 +8920,9 @@ export default class Meeting extends StatelessWebexPlugin {
7967
8920
  * Internal version of addMedia() with some more arguments for finer control of its behavior
7968
8921
  *
7969
8922
  * @param {Function} icePhaseCallback - callback to determine the icePhase for CA "client.ice.end" failure events
7970
- * @param {TurnServerInfo} turnServerInfo - TURN server information
7971
8923
  * @param {boolean} forceTurnDiscovery - if true, TURN discovery will be done
8924
+ * @param {TurnServerInfo} turnServerInfo - TURN server information
8925
+ * @param {RTCIceTransportPolicy} [iceTransportPolicy] - ICE transport policy override
7972
8926
  * @param {AddMediaOptions} options - same as options of the public addMedia() method
7973
8927
  * @returns {Promise<void>}
7974
8928
  * @protected
@@ -7976,12 +8930,14 @@ export default class Meeting extends StatelessWebexPlugin {
7976
8930
  */
7977
8931
  protected async addMediaInternal(
7978
8932
  icePhaseCallback: () => string,
7979
- turnServerInfo: TurnServerInfo,
7980
- forceTurnDiscovery,
8933
+ forceTurnDiscovery: boolean,
8934
+ turnServerInfo?: TurnServerInfo,
8935
+ iceTransportPolicy?: RTCIceTransportPolicy,
7981
8936
  options: AddMediaOptions = {}
7982
8937
  ): Promise<void> {
7983
8938
  this.addMediaData.retriedWithTurnServer = false;
7984
8939
  this.addMediaData.icePhaseCallback = icePhaseCallback;
8940
+ this.addMediaData.iceTransportPolicy = iceTransportPolicy;
7985
8941
 
7986
8942
  this.hasMediaConnectionConnectedAtLeastOnce = false;
7987
8943
  const LOG_HEADER = 'Meeting:index#addMedia -->';
@@ -7990,7 +8946,7 @@ export default class Meeting extends StatelessWebexPlugin {
7990
8946
  options
7991
8947
  )}, turnServerInfo=${JSON.stringify(
7992
8948
  turnServerInfo
7993
- )}, forceTurnDiscovery=${forceTurnDiscovery}`
8949
+ )}, forceTurnDiscovery=${forceTurnDiscovery}, iceTransportPolicy=${iceTransportPolicy}`
7994
8950
  );
7995
8951
 
7996
8952
  if (options.allowMediaInLobby !== true && this.meetingState !== FULL_STATE.ACTIVE) {
@@ -8010,6 +8966,7 @@ export default class Meeting extends StatelessWebexPlugin {
8010
8966
  remoteMediaManagerConfig,
8011
8967
  bundlePolicy = 'max-bundle',
8012
8968
  additionalMediaOptions = {},
8969
+ allowPublishMediaInLobby = false,
8013
8970
  } = options;
8014
8971
 
8015
8972
  const {
@@ -8030,7 +8987,6 @@ export default class Meeting extends StatelessWebexPlugin {
8030
8987
  const ipver = MeetingUtil.getIpVersion(this.webex); // used just for metrics
8031
8988
 
8032
8989
  // If the user is unjoined or guest waiting in lobby dont allow the user to addMedia
8033
- // @ts-ignore - isUserUnadmitted coming from SelfUtil
8034
8990
  if (this.isUserUnadmitted && !this.wirelessShare && !this.allowMediaInLobby) {
8035
8991
  throw new UserInLobbyError();
8036
8992
  }
@@ -8075,7 +9031,13 @@ export default class Meeting extends StatelessWebexPlugin {
8075
9031
  this.brbState = createBrbState(this, false);
8076
9032
 
8077
9033
  try {
8078
- await this.setUpLocalStreamReferences(localStreams);
9034
+ // if we're in a lobby and allowPublishMediaInLobby==false, we don't want to
9035
+ // setup local streams for publishing, because if we ever end up admitted to the meeting
9036
+ // but Locus event about it for us is delayed or missed, others could see/hear our user's video/audio
9037
+ // while the user would still think they're in the lobby
9038
+ if (allowPublishMediaInLobby || !this.isUserUnadmitted) {
9039
+ await this.setUpLocalStreamReferences(localStreams);
9040
+ }
8079
9041
 
8080
9042
  this.setMercuryListener();
8081
9043
 
@@ -8098,12 +9060,7 @@ export default class Meeting extends StatelessWebexPlugin {
8098
9060
 
8099
9061
  // Establish new media connection with forced TURN discovery
8100
9062
  // 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
8101
- await this.establishMediaConnection(
8102
- remoteMediaManagerConfig,
8103
- bundlePolicy,
8104
- true,
8105
- undefined
8106
- );
9063
+ await this.establishMediaConnection(remoteMediaManagerConfig, bundlePolicy, true);
8107
9064
  } else {
8108
9065
  throw error;
8109
9066
  }
@@ -8132,7 +9089,8 @@ export default class Meeting extends StatelessWebexPlugin {
8132
9089
  numTransports,
8133
9090
  isMultistream: this.isMultistream,
8134
9091
  retriedWithTurnServer: this.addMediaData.retriedWithTurnServer,
8135
- isJoinWithMediaRetry: this.joinWithMediaRetryInfo.isRetry,
9092
+ isJoinWithMediaRetry: this.joinWithMediaRetryInfo.retryCount > 0,
9093
+ iceTransportPolicy: this.addMediaData.iceTransportPolicy || 'all',
8136
9094
  ...reachabilityMetrics,
8137
9095
  ...iceCandidateErrors,
8138
9096
  iceCandidatesCount: this.iceCandidatesCount,
@@ -8154,14 +9112,16 @@ export default class Meeting extends StatelessWebexPlugin {
8154
9112
  // We can log ReceiveSlot SSRCs only after the SDP exchange, so doing it here:
8155
9113
  this.remoteMediaManager?.logAllReceiveSlots();
8156
9114
  this.startPeriodicLogUpload();
8157
- } catch (error) {
9115
+ } catch (error: any) {
8158
9116
  LoggerProxy.logger.error(`${LOG_HEADER} failed to establish media connection: `, error);
8159
9117
 
8160
9118
  // @ts-ignore
8161
9119
  const reachabilityMetrics = await this.getMediaReachabilityMetricFields();
8162
9120
 
8163
- const {selectedCandidatePairChanges, numTransports} =
8164
- await this.mediaProperties.getCurrentConnectionInfo();
9121
+ const {connectionType, selectedCandidatePairChanges, numTransports} =
9122
+ error instanceof AddMediaFailed
9123
+ ? error
9124
+ : await this.mediaProperties.getCurrentConnectionInfo();
8165
9125
 
8166
9126
  const iceCandidateErrors = Object.fromEntries(this.iceCandidateErrors);
8167
9127
 
@@ -8177,7 +9137,8 @@ export default class Meeting extends StatelessWebexPlugin {
8177
9137
  turnServerUsed: this.turnServerUsed,
8178
9138
  retriedWithTurnServer: this.addMediaData.retriedWithTurnServer,
8179
9139
  isMultistream: this.isMultistream,
8180
- isJoinWithMediaRetry: this.joinWithMediaRetryInfo.isRetry,
9140
+ isJoinWithMediaRetry: this.joinWithMediaRetryInfo.retryCount > 0,
9141
+ iceTransportPolicy: this.addMediaData.iceTransportPolicy || 'all',
8181
9142
  signalingState:
8182
9143
  this.mediaProperties.webrtcMediaConnection?.multistreamConnection?.pc?.pc
8183
9144
  ?.signalingState ||
@@ -8193,6 +9154,7 @@ export default class Meeting extends StatelessWebexPlugin {
8193
9154
  ?.iceConnectionState ||
8194
9155
  this.mediaProperties.webrtcMediaConnection?.mediaConnection?.pc?.iceConnectionState ||
8195
9156
  'unknown',
9157
+ connectionType,
8196
9158
  ...reachabilityMetrics,
8197
9159
  ...iceCandidateErrors,
8198
9160
  iceCandidatesCount: this.iceCandidatesCount,
@@ -8541,14 +9503,15 @@ export default class Meeting extends StatelessWebexPlugin {
8541
9503
  options: {meetingId: this.id},
8542
9504
  });
8543
9505
  LoggerProxy.logger.log('Meeting:index#leave --> Leaving a meeting');
9506
+ this.stopListeningForMeetingEvents();
8544
9507
 
8545
9508
  return MeetingUtil.leaveMeeting(this, options)
8546
- .then((leave) => {
9509
+ .then(async (leave) => {
8547
9510
  // CA team recommends submitting this *after* locus /leave
8548
9511
  submitLeaveMetric();
8549
9512
 
8550
9513
  this.meetingFiniteStateMachine.leave();
8551
- this.clearMeetingData();
9514
+ await this.clearMeetingData();
8552
9515
 
8553
9516
  // upload logs on leave irrespective of meeting delete
8554
9517
  Trigger.trigger(
@@ -9406,11 +10369,13 @@ export default class Meeting extends StatelessWebexPlugin {
9406
10369
  locus_id: this.locusId,
9407
10370
  });
9408
10371
 
10372
+ this.stopListeningForMeetingEvents();
10373
+
9409
10374
  return MeetingUtil.endMeetingForAll(this)
9410
- .then((end) => {
10375
+ .then(async (end) => {
9411
10376
  this.meetingFiniteStateMachine.end();
9412
10377
 
9413
- this.clearMeetingData();
10378
+ await this.clearMeetingData();
9414
10379
  // upload logs on leave irrespective of meeting delete
9415
10380
  Trigger.trigger(
9416
10381
  this,
@@ -9458,7 +10423,7 @@ export default class Meeting extends StatelessWebexPlugin {
9458
10423
  * @public
9459
10424
  * @memberof Meeting
9460
10425
  */
9461
- clearMeetingData = () => {
10426
+ clearMeetingData = async () => {
9462
10427
  this.audio = null;
9463
10428
  this.video = null;
9464
10429
  this.screenShareFloorState = ScreenShareFloorStatus.RELEASED;
@@ -9467,19 +10432,12 @@ export default class Meeting extends StatelessWebexPlugin {
9467
10432
  }
9468
10433
  this.queuedMediaUpdates = [];
9469
10434
 
9470
- if (this.transcription) {
9471
- this.stopTranscription();
9472
- this.transcription = undefined;
9473
- }
9474
-
9475
- this.annotation.deregisterEvents();
9476
-
9477
- // @ts-ignore - fix types
9478
- this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
9479
- // @ts-ignore - Fix type
9480
- this.webex.internal.llm.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
10435
+ // Listener teardown (transcription, annotation, llm/mercury) runs in
10436
+ // stopListeningForMeetingEvents() before /leave and /end so events
10437
+ // received mid-teardown do not trigger Locus syncs.
10438
+ // Token cleanup happens automatically when cleanupLLMConneciton destroys the channel.
9481
10439
 
9482
- this.clearLLMHealthCheckTimer();
10440
+ await this.cleanupLLMConneciton({throwOnError: false});
9483
10441
  };
9484
10442
 
9485
10443
  /**
@@ -9555,15 +10513,12 @@ export default class Meeting extends StatelessWebexPlugin {
9555
10513
  * @public
9556
10514
  * @memberof Meeting
9557
10515
  */
9558
- public sendReaction(reactionType: ReactionServerType, skinToneType?: SkinToneType) {
10516
+ public sendReaction(reactionType: string, skinToneType?: SkinToneType) {
9559
10517
  const reactionChannelUrl = this.locusInfo?.controls?.reactions?.reactionChannelUrl as string;
9560
10518
  const participantId = this.members.selfId;
9561
10519
 
9562
- const reactionData = Reactions[reactionType];
10520
+ const reactionData = Reactions[reactionType] || {type: reactionType};
9563
10521
 
9564
- if (!reactionData) {
9565
- return Promise.reject(new Error(`${reactionType} is not a valid reaction.`));
9566
- }
9567
10522
  const skinToneData = SkinTones[skinToneType] || SkinTones.normal;
9568
10523
  const reaction: Reaction = {
9569
10524
  ...reactionData,
@@ -9672,15 +10627,20 @@ export default class Meeting extends StatelessWebexPlugin {
9672
10627
  }
9673
10628
 
9674
10629
  if (shouldEnableMusicMode) {
9675
- await this.sendSlotManager.setCodecParameters(MediaType.AudioMain, {
9676
- maxaveragebitrate: '64000',
9677
- maxplaybackrate: '48000',
9678
- });
10630
+ await this.sendSlotManager.setCustomCodecParameters(
10631
+ MediaType.AudioMain,
10632
+ MediaCodecMimeType.OPUS,
10633
+ {
10634
+ maxaveragebitrate: '64000',
10635
+ maxplaybackrate: '48000',
10636
+ }
10637
+ );
9679
10638
  } else {
9680
- await this.sendSlotManager.deleteCodecParameters(MediaType.AudioMain, [
9681
- 'maxaveragebitrate',
9682
- 'maxplaybackrate',
9683
- ]);
10639
+ await this.sendSlotManager.markCustomCodecParametersForDeletion(
10640
+ MediaType.AudioMain,
10641
+ MediaCodecMimeType.OPUS,
10642
+ ['maxaveragebitrate', 'maxplaybackrate']
10643
+ );
9684
10644
  }
9685
10645
  }
9686
10646
 
@@ -10179,4 +11139,80 @@ export default class Meeting extends StatelessWebexPlugin {
10179
11139
  cancelSipCallOut(participantId: string) {
10180
11140
  return this.meetingRequest.cancelSipCallOut(participantId);
10181
11141
  }
11142
+
11143
+ /**
11144
+ * Method to get new data
11145
+ * @returns {Promise}
11146
+ */
11147
+ public async refreshDataChannelToken() {
11148
+ const isPracticeSession = this.webinar.isJoinPracticeSessionDataChannel();
11149
+ const dataChannelTokenType = this.getDataChannelTokenType();
11150
+
11151
+ try {
11152
+ const res = await this.meetingRequest.fetchDatachannelToken({
11153
+ locusUrl: this.locusUrl,
11154
+ requestingParticipantId: this.members.selfId,
11155
+ isPracticeSession,
11156
+ });
11157
+
11158
+ return {
11159
+ body: {
11160
+ datachannelToken: res.body.datachannelToken,
11161
+ dataChannelTokenType,
11162
+ },
11163
+ };
11164
+ } catch (e) {
11165
+ const msg = e?.message || String(e);
11166
+
11167
+ LoggerProxy.logger.warn(
11168
+ `Meeting:index#refreshDataChannelToken --> DataChannel token refresh failed (likely locus changed or participant left): ${msg}`,
11169
+ {statusCode: e?.statusCode}
11170
+ );
11171
+
11172
+ return null;
11173
+ }
11174
+ }
11175
+
11176
+ /**
11177
+ * Checks if the LLM channel is connected.
11178
+ * Handles practice session context automatically - returns practice session
11179
+ * LLM channel status when in practice session, main LLM channel status otherwise.
11180
+ * @returns {boolean} True if the appropriate LLM channel is connected
11181
+ */
11182
+ public isLLMConnected(): boolean {
11183
+ if (this.webinar?.isJoinPracticeSessionDataChannel()) {
11184
+ return this.webinar.isPracticeSessionLLMChannelConnected();
11185
+ }
11186
+
11187
+ return this.llmChannel?.isConnected() ?? false;
11188
+ }
11189
+
11190
+ /**
11191
+ * Gets the locus URL from the LLM channel.
11192
+ * Handles practice session context automatically - returns practice session
11193
+ * LLM channel's locus URL when in practice session, main LLM channel's locus URL otherwise.
11194
+ * @returns {string | undefined} The locus URL or undefined
11195
+ */
11196
+ public getLLMLocusUrl(): string | undefined {
11197
+ if (this.webinar?.isJoinPracticeSessionDataChannel()) {
11198
+ return this.webinar.getPracticeSessionLocusUrl();
11199
+ }
11200
+
11201
+ return this.llmChannel?.getLocusUrl();
11202
+ }
11203
+
11204
+ /**
11205
+ * Determines the current data channel token type based on the meeting state.
11206
+ *
11207
+ * variant should be used when connecting to the LLM data channel.
11208
+ *
11209
+ * @returns {DataChannelTokenType} The token type representing the current session mode.
11210
+ */
11211
+ public getDataChannelTokenType(): DataChannelTokenType {
11212
+ if (this.webinar.isJoinPracticeSessionDataChannel()) {
11213
+ return DataChannelTokenType.PracticeSession;
11214
+ }
11215
+
11216
+ return DataChannelTokenType.Default;
11217
+ }
10182
11218
  }