@webex/plugin-meetings 3.11.0-webex-services-ready.1 → 3.12.0-auth-prejoin-fetch.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 +16 -7
  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 +99 -4
  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 +350 -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 +2347 -1096
  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 +100 -38
  83. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  84. package/dist/meetings/index.js +466 -174
  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 +121 -83
  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/common/errors/webex-errors.d.ts +32 -2
  130. package/dist/types/config.d.ts +6 -2
  131. package/dist/types/constants.d.ts +35 -1
  132. package/dist/types/controls-options-manager/constants.d.ts +6 -1
  133. package/dist/types/controls-options-manager/index.d.ts +16 -0
  134. package/dist/types/hashTree/constants.d.ts +3 -0
  135. package/dist/types/hashTree/hashTree.d.ts +7 -0
  136. package/dist/types/hashTree/hashTreeParser.d.ts +315 -30
  137. package/dist/types/hashTree/types.d.ts +3 -0
  138. package/dist/types/hashTree/utils.d.ts +24 -0
  139. package/dist/types/index.d.ts +4 -0
  140. package/dist/types/interceptors/constant.d.ts +5 -0
  141. package/dist/types/interceptors/dataChannelAuthToken.d.ts +43 -0
  142. package/dist/types/interceptors/index.d.ts +2 -1
  143. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  144. package/dist/types/interceptors/utils.d.ts +1 -0
  145. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  146. package/dist/types/locus-info/index.d.ts +126 -15
  147. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  148. package/dist/types/locus-info/types.d.ts +28 -1
  149. package/dist/types/media/MediaConnectionAwaiter.d.ts +20 -2
  150. package/dist/types/media/properties.d.ts +8 -3
  151. package/dist/types/meeting/in-meeting-actions.d.ts +10 -0
  152. package/dist/types/meeting/index.d.ts +253 -16
  153. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  154. package/dist/types/meeting/request.d.ts +17 -1
  155. package/dist/types/meeting/request.type.d.ts +5 -0
  156. package/dist/types/meeting/util.d.ts +40 -0
  157. package/dist/types/meeting-info/meeting-info-v2.d.ts +25 -1
  158. package/dist/types/meetings/index.d.ts +54 -21
  159. package/dist/types/meetings/meetings.types.d.ts +30 -1
  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 +585 -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 +32 -10
  185. package/src/breakouts/breakout.ts +3 -1
  186. package/src/breakouts/events.ts +33 -11
  187. package/src/breakouts/index.ts +122 -2
  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 +246 -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 +1300 -180
  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 +83 -21
  223. package/src/meetings/index.ts +402 -121
  224. package/src/meetings/meetings.types.ts +36 -1
  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 +47 -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 +448 -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 +70 -8
  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 +223 -3
  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 +406 -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 +3691 -366
  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 +286 -10
  277. package/test/unit/spec/meetings/index.js +1400 -78
  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 +128 -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 +837 -39
  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,11 @@ import {
30
30
  NetworkQualityMonitor,
31
31
  StatsMonitor,
32
32
  StatsMonitorEventNames,
33
- InboundAudioIssueSubTypes,
33
+ MediaCodecMimeType,
34
34
  } from '@webex/internal-media-core';
35
35
 
36
+ import {DataChannelTokenType, type RegisterAndConnectTiming} from '@webex/internal-plugin-llm';
37
+
36
38
  import {
37
39
  LocalStream,
38
40
  LocalCameraStream,
@@ -64,6 +66,7 @@ import {
64
66
  NoMediaEstablishedYetError,
65
67
  UserNotJoinedError,
66
68
  AddMediaFailed,
69
+ MediaConnectionTimedOutError,
67
70
  SdpResponseTimeoutError,
68
71
  } from '../common/errors/webex-errors';
69
72
 
@@ -74,6 +77,7 @@ import Roap, {type TurnDiscoveryResult, type TurnDiscoverySkipReason} from '../r
74
77
  import {type TurnServerInfo} from '../roap/types';
75
78
  import Media, {type BundlePolicy} from '../media';
76
79
  import MediaProperties from '../media/properties';
80
+ import {type FailureResult as MediaConnectionAwaiterFailureResult} from '../media/MediaConnectionAwaiter';
77
81
  import MeetingStateMachine from './state';
78
82
  import {createMuteState} from './muteState';
79
83
  import LocusInfo, {LocusLLMEvent} from '../locus-info';
@@ -134,6 +138,8 @@ import {
134
138
  STAGE_MANAGER_TYPE,
135
139
  LOCUSEVENT,
136
140
  LOCUS_LLM_EVENT,
141
+ LLM_DEFAULT_SESSION,
142
+ LLM_PRACTICE_SESSION,
137
143
  } from '../constants';
138
144
  import BEHAVIORAL_METRICS from '../metrics/constants';
139
145
  import ParameterError from '../common/errors/parameter';
@@ -144,6 +150,7 @@ import {
144
150
  MeetingInfoV2JoinWebinarError,
145
151
  MeetingInfoV2JoinForbiddenError,
146
152
  } from '../meeting-info/meeting-info-v2';
153
+ import type {PrefetchedMeetingInfo} from '../meetings/meetings.types';
147
154
  import {CSI, ReceiveSlotManager} from '../multistream/receiveSlotManager';
148
155
  import SendSlotManager from '../multistream/sendSlotManager';
149
156
  import {MediaRequestManager} from '../multistream/mediaRequestManager';
@@ -179,13 +186,15 @@ import JoinForbiddenError from '../common/errors/join-forbidden-error';
179
186
  import {ReachabilityMetrics} from '../reachability/reachability.types';
180
187
  import {SetStageOptions, SetStageVideoLayout, UnsetStageVideoLayout} from './request.type';
181
188
  import {Invitee} from './type';
182
- import {DataSet} from '../hashTree/hashTreeParser';
189
+ import {DataSet, HashTreeMessage, Metadata} from '../hashTree/hashTreeParser';
183
190
  import {LocusDTO} from '../locus-info/types';
191
+ import AIEnableRequest from '../aiEnableRequest';
184
192
 
185
193
  // default callback so we don't call an undefined function, but in practice it should never be used
186
194
  const DEFAULT_ICE_PHASE_CALLBACK = () => 'JOIN_MEETING_FINAL';
187
195
 
188
196
  const LLM_HEALTHCHECK_TIMER_MS = 3 * 60 * 1000;
197
+ const JOIN_WITH_MEDIA_RETRY_MAX_COUNT = 2;
189
198
 
190
199
  const logRequest = (request: any, {logText = ''}) => {
191
200
  LoggerProxy.logger.info(`${logText} - sending request`);
@@ -250,6 +259,7 @@ export type AddMediaOptions = {
250
259
  remoteMediaManagerConfig?: RemoteMediaManagerConfiguration; // applies only to multistream meetings
251
260
  bundlePolicy?: BundlePolicy; // applies only to multistream meetings
252
261
  allowMediaInLobby?: boolean; // allows adding media when in the lobby
262
+ allowPublishMediaInLobby?: boolean; // allows publishing media when in the lobby, if not specified, default value false is used
253
263
  additionalMediaOptions?: AdditionalMediaOptions; // allows adding additional options like send/receive audio/video
254
264
  };
255
265
 
@@ -564,6 +574,34 @@ type MediaReachabilityMetrics = ReachabilityMetrics & {
564
574
  * @memberof Meeting
565
575
  */
566
576
 
577
+ /**
578
+ * Stores an event so all events can be later retrieved via a console command for debugging.
579
+ * @param {string} type
580
+ * @param {Object} data
581
+ * @returns {void}
582
+ */
583
+ export function storeEventForDebugging(
584
+ type: string,
585
+ data: {
586
+ eventType: any;
587
+ stateElementsMessage?: HashTreeMessage;
588
+ }
589
+ ) {
590
+ if ((window as any)?.locusEvents) {
591
+ // only store non-heartbeat hash tree messages
592
+ if (
593
+ data.eventType === LOCUSEVENT.HASH_TREE_DATA_UPDATED &&
594
+ data.stateElementsMessage?.locusStateElements
595
+ ) {
596
+ (window as any).locusEvents.push({
597
+ ...data,
598
+ timestamp: new Date().toLocaleString(),
599
+ type,
600
+ });
601
+ }
602
+ }
603
+ }
604
+
567
605
  /**
568
606
  * @description Meeting is the crux of the plugin
569
607
  * @export
@@ -575,10 +613,11 @@ export default class Meeting extends StatelessWebexPlugin {
575
613
  breakouts: any;
576
614
  simultaneousInterpretation: any;
577
615
  annotation: any;
616
+ aiEnableRequest: any;
578
617
  webinar: any;
579
618
  conversationUrl: string;
580
619
  callStateForMetrics: CallStateForMetrics;
581
- destination: string;
620
+ destination: string | LocusDTO;
582
621
  destinationType: DESTINATION_TYPE;
583
622
  deviceUrl: string;
584
623
  hostId: string;
@@ -617,12 +656,22 @@ export default class Meeting extends StatelessWebexPlugin {
617
656
  floorGrantPending: boolean;
618
657
  hasJoinedOnce: boolean;
619
658
  hasWebsocketConnected: boolean;
659
+ private mercuryOnlineHandler?: () => void;
660
+ private mercuryOfflineHandler?: () => void;
620
661
  inMeetingActions: InMeetingActions;
621
662
  isLocalShareLive: boolean;
622
663
  isRoapInProgress: boolean;
623
664
  keepAliveTimerId: NodeJS.Timeout;
624
665
  lastVideoLayoutInfo: any;
625
666
  locusInfo: any;
667
+ // this group of properties is populated via updateMeetingObject() that's registered as a callback with LocusInfo
668
+ isUserUnadmitted?: boolean;
669
+ joinedWith?: any;
670
+ selfId?: string;
671
+ roles: any[];
672
+ canNotViewTheParticipantList?: boolean;
673
+ // ... there is more ... see SelfUtils.parse()
674
+ // end of the group
626
675
  locusMediaRequest?: LocusMediaRequest;
627
676
  mediaProperties: MediaProperties;
628
677
  mediaRequestManagers: {
@@ -657,7 +706,6 @@ export default class Meeting extends StatelessWebexPlugin {
657
706
  endCallInitJoinReq: any;
658
707
  endJoinReqResp: any;
659
708
  endLocalSDPGenRemoteSDPRecvDelay: any;
660
- joinedWith: any;
661
709
  locusId: any;
662
710
  startCallInitJoinReq: any;
663
711
  startJoinReqResp: any;
@@ -672,12 +720,11 @@ export default class Meeting extends StatelessWebexPlugin {
672
720
  permissionTokenReceivedLocalTime: number;
673
721
  resourceId: any;
674
722
  resourceUrl: string;
675
- selfId: string;
676
723
  state: any;
677
724
  localAudioStreamMuteStateHandler: () => void;
678
725
  localVideoStreamMuteStateHandler: () => void;
679
726
  localOutputTrackChangeHandler: () => void;
680
- roles: any[];
727
+ localConstraintsChangeHandler: () => void;
681
728
  environment: string;
682
729
  namespace = MEETINGS;
683
730
  allowMediaInLobby: boolean;
@@ -696,6 +743,8 @@ export default class Meeting extends StatelessWebexPlugin {
696
743
  isMoveToInProgress = false;
697
744
  registrationIdStatus: string;
698
745
  brbState: BrbState;
746
+ private emittedBreakoutJoinResponseMoveIds: Set<string> = new Set();
747
+ private promisesWaitingForPropUpdate: Record<string, Defer> = {};
699
748
 
700
749
  voiceaListenerCallbacks: object = {
701
750
  [VOICEAEVENTS.VOICEA_ANNOUNCEMENT]: (payload: Transcription['languageOptions']) => {
@@ -745,13 +794,20 @@ export default class Meeting extends StatelessWebexPlugin {
745
794
  private addMediaData: {
746
795
  retriedWithTurnServer: boolean;
747
796
  icePhaseCallback: () => string;
797
+ iceTransportPolicy?: RTCIceTransportPolicy;
748
798
  };
749
799
 
750
800
  private sendSlotManager: SendSlotManager = new SendSlotManager(LoggerProxy);
751
801
  private deferSDPAnswer?: Defer; // used for waiting for a response
752
802
  private sdpResponseTimer?: ReturnType<typeof setTimeout>;
753
803
  private hasMediaConnectionConnectedAtLeastOnce: boolean;
754
- private joinWithMediaRetryInfo?: {isRetry: boolean; prevJoinResponse?: any};
804
+ private joinWithMediaRetryInfo: {
805
+ retryCount: number;
806
+ prevJoinResponse?: any;
807
+ firstError?: Error;
808
+ prevError?: Error;
809
+ };
810
+
755
811
  private connectionStateHandler?: ConnectionStateHandler;
756
812
  private iceCandidateErrors: Map<string, number>;
757
813
  private iceCandidatesCount: number;
@@ -894,6 +950,10 @@ export default class Meeting extends StatelessWebexPlugin {
894
950
  */
895
951
  // @ts-ignore
896
952
  this.simultaneousInterpretation = new SimultaneousInterpretation({}, {parent: this.webex});
953
+
954
+ // @ts-ignore
955
+ this.aiEnableRequest = new AIEnableRequest({locusUrl: this.locusUrl}, {parent: this.webex});
956
+
897
957
  /**
898
958
  * @instance
899
959
  * @type {Annotation}
@@ -923,6 +983,7 @@ export default class Meeting extends StatelessWebexPlugin {
923
983
  },
924
984
  (csi: CSI) => (this.members.findMemberByCsi(csi) as any)?.id
925
985
  );
986
+
926
987
  /**
927
988
  * Object containing helper classes for managing media requests for audio/video/screenshare (for multistream media connections)
928
989
  * All multistream media requests sent out for this meeting have to go through them.
@@ -942,6 +1003,7 @@ export default class Meeting extends StatelessWebexPlugin {
942
1003
  mediaRequests
943
1004
  );
944
1005
  },
1006
+ this.getIngressPayloadTypeCallback.bind(this),
945
1007
  {
946
1008
  // @ts-ignore - config coming from registerPlugin
947
1009
  degradationPreferences: this.config.degradationPreferences,
@@ -963,6 +1025,7 @@ export default class Meeting extends StatelessWebexPlugin {
963
1025
  mediaRequests
964
1026
  );
965
1027
  },
1028
+ this.getIngressPayloadTypeCallback.bind(this),
966
1029
  {
967
1030
  // @ts-ignore - config coming from registerPlugin
968
1031
  degradationPreferences: this.config.degradationPreferences,
@@ -984,6 +1047,7 @@ export default class Meeting extends StatelessWebexPlugin {
984
1047
  mediaRequests
985
1048
  );
986
1049
  },
1050
+ this.getIngressPayloadTypeCallback.bind(this),
987
1051
  {
988
1052
  // @ts-ignore - config coming from registerPlugin
989
1053
  degradationPreferences: this.config.degradationPreferences,
@@ -1005,11 +1069,14 @@ export default class Meeting extends StatelessWebexPlugin {
1005
1069
  mediaRequests
1006
1070
  );
1007
1071
  },
1072
+ this.getIngressPayloadTypeCallback.bind(this),
1008
1073
  {
1009
1074
  // @ts-ignore - config coming from registerPlugin
1010
1075
  degradationPreferences: this.config.degradationPreferences,
1011
1076
  kind: 'video',
1012
1077
  trimRequestsToNumOfSources: false,
1078
+ // @ts-ignore - config coming from registerPlugin
1079
+ enableAv1: this.config.enableAv1SlidesSupport,
1013
1080
  }
1014
1081
  ),
1015
1082
  };
@@ -1329,7 +1396,48 @@ export default class Meeting extends StatelessWebexPlugin {
1329
1396
  * @memberof Meeting
1330
1397
  */
1331
1398
  // @ts-ignore - Fix type
1332
- this.locusInfo = new LocusInfo(this.updateMeetingObject.bind(this), this.webex, this.id);
1399
+ this.locusInfo = new LocusInfo(
1400
+ {
1401
+ updateMeeting: this.updateMeetingObject.bind(this),
1402
+ syncLatencyTracker: {
1403
+ // Compute/store latency timestamps live on CallDiagnosticLatencies, while
1404
+ // submitting the client.locus.sync.complete CA event is owned by the metrics
1405
+ // facade. Wire each method to the layer that owns that responsibility.
1406
+ saveLatency: (...args) =>
1407
+ // @ts-ignore
1408
+ this.webex.internal.newMetrics.callDiagnosticLatencies.saveLatency(...args),
1409
+ saveTimestamp: (saveTimestampOptions: {
1410
+ key: string;
1411
+ value?: number;
1412
+ options: {meetingId: string; dataSetName: string; trackingId?: string};
1413
+ }) => {
1414
+ // @ts-ignore
1415
+ this.webex.internal.newMetrics.callDiagnosticLatencies.saveTimestamp(
1416
+ saveTimestampOptions
1417
+ );
1418
+
1419
+ // The /sync response is one of the two milestones (the other is the LLM message) that
1420
+ // complete client.locus.sync.complete. Try to complete now: the metric is emitted only
1421
+ // once both the LLM message and the /sync response have arrived (either can come first).
1422
+ if (
1423
+ saveTimestampOptions.key === 'internal.client.locus.sync.response' &&
1424
+ saveTimestampOptions.options?.trackingId
1425
+ ) {
1426
+ this.tryCompleteLocusSyncLatency(
1427
+ saveTimestampOptions.options.meetingId,
1428
+ saveTimestampOptions.options.trackingId
1429
+ );
1430
+ }
1431
+ },
1432
+ clearLocusSyncLatency: (...args) =>
1433
+ // @ts-ignore
1434
+ this.webex.internal.newMetrics.callDiagnosticLatencies.clearLocusSyncLatency(...args),
1435
+ },
1436
+ },
1437
+ // @ts-ignore
1438
+ this.webex,
1439
+ this.id
1440
+ );
1333
1441
 
1334
1442
  // We had to add listeners first before setting up the locus instance
1335
1443
  /**
@@ -1514,6 +1622,8 @@ export default class Meeting extends StatelessWebexPlugin {
1514
1622
  this.controlsOptionsManager = new ControlsOptionsManager(this.meetingRequest, {
1515
1623
  locusUrl: this.locusInfo?.url,
1516
1624
  displayHints: [],
1625
+ getControls: () => this.locusInfo?.controls,
1626
+ isWebinar: () => this.locusInfo?.info?.isWebinar,
1517
1627
  });
1518
1628
 
1519
1629
  this.setUpLocusInfoListeners();
@@ -1543,6 +1653,12 @@ export default class Meeting extends StatelessWebexPlugin {
1543
1653
  }
1544
1654
  };
1545
1655
 
1656
+ this.localConstraintsChangeHandler = () => {
1657
+ if (!this.isMultistream) {
1658
+ this.mediaProperties.webrtcMediaConnection?.updatePreferredBitrateKbps();
1659
+ }
1660
+ };
1661
+
1546
1662
  /**
1547
1663
  * Promise that exists if SDP offer has been generated, and resolves once sdp answer is received.
1548
1664
  * @instance
@@ -1606,11 +1722,11 @@ export default class Meeting extends StatelessWebexPlugin {
1606
1722
  /**
1607
1723
  * Information needed for a retry of a call to joinWithMedia
1608
1724
  * @instance
1609
- * @type {{isRetry: boolean; prevJoinResponse?: any}}
1725
+ * @type {{retryCount: number; prevJoinResponse?: any}}
1610
1726
  * @private
1611
1727
  * @memberof Meeting
1612
1728
  */
1613
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
1729
+ this.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
1614
1730
 
1615
1731
  /**
1616
1732
  * Connection state handler
@@ -1664,6 +1780,37 @@ export default class Meeting extends StatelessWebexPlugin {
1664
1780
  this.mediaServerIp = undefined;
1665
1781
  }
1666
1782
 
1783
+ /**
1784
+ * Get the ingress payload type for a given media type and codec mime type
1785
+ * @param {MediaType} mediaType - The media type
1786
+ * @param {MediaCodecMimeType} codecMimeType - The codec mime type
1787
+ * @returns {number | undefined} - The ingress payload type
1788
+ * @private
1789
+ * @memberof Meeting
1790
+ */
1791
+ private getIngressPayloadTypeCallback(
1792
+ mediaType: MediaType,
1793
+ codecMimeType: MediaCodecMimeType
1794
+ ): number | undefined {
1795
+ if (this.isMultistream) {
1796
+ try {
1797
+ return this.mediaProperties.webrtcMediaConnection.getIngressPayloadType(
1798
+ mediaType,
1799
+ codecMimeType
1800
+ );
1801
+ } catch (error) {
1802
+ LoggerProxy.logger.info(
1803
+ `Meeting:index#mediaRequestManager --> failed to get ingress payload type for mediaType=${mediaType}, codecMimeType=${codecMimeType}`,
1804
+ error
1805
+ );
1806
+
1807
+ return undefined;
1808
+ }
1809
+ }
1810
+
1811
+ return undefined;
1812
+ }
1813
+
1667
1814
  /**
1668
1815
  * Temporary func to return webex object,
1669
1816
  * in order to access internal plugin metrics
@@ -1929,26 +2076,33 @@ export default class Meeting extends StatelessWebexPlugin {
1929
2076
  sendCAevents = false,
1930
2077
  registrationId = null,
1931
2078
  classificationId = null,
2079
+ prefetchedMeetingInfo = null,
1932
2080
  }): Promise<void> {
1933
2081
  try {
1934
2082
  const captchaInfo = captchaCode
1935
2083
  ? {code: captchaCode, id: this.requiredCaptcha.captchaId}
1936
2084
  : null;
1937
2085
 
1938
- const info = await this.attrs.meetingInfoProvider.fetchMeetingInfo(
1939
- destination,
1940
- destinationType,
1941
- password,
1942
- captchaInfo,
1943
- // @ts-ignore - config coming from registerPlugin
1944
- this.config.installedOrgID,
1945
- this.locusId,
1946
- extraParams,
1947
- {meetingId: this.id, sendCAevents},
1948
- registrationId,
1949
- null,
1950
- classificationId
1951
- );
2086
+ let info;
2087
+
2088
+ if (prefetchedMeetingInfo) {
2089
+ info = await prefetchedMeetingInfo.request;
2090
+ } else {
2091
+ info = await this.attrs.meetingInfoProvider.fetchMeetingInfo(
2092
+ destination,
2093
+ destinationType,
2094
+ password,
2095
+ captchaInfo,
2096
+ // @ts-ignore - config coming from registerPlugin
2097
+ this.config.installedOrgID,
2098
+ this.locusId,
2099
+ extraParams,
2100
+ {meetingId: this.id, sendCAevents, correlationId: this.correlationId},
2101
+ registrationId,
2102
+ null,
2103
+ classificationId
2104
+ );
2105
+ }
1952
2106
 
1953
2107
  this.parseMeetingInfo(info?.body, this.destination, info?.errors);
1954
2108
  this.setMeetingInfo(info?.body, info?.url);
@@ -2143,6 +2297,26 @@ export default class Meeting extends StatelessWebexPlugin {
2143
2297
  });
2144
2298
  }
2145
2299
 
2300
+ /**
2301
+ * Consumes meeting information requested before this Meeting was created.
2302
+ *
2303
+ * @param {PrefetchedMeetingInfo} prefetchedMeetingInfo opaque early request handle
2304
+ * @returns {Promise<void>} resolves after the response is applied to this Meeting
2305
+ */
2306
+ public async consumePrefetchedMeetingInfo(prefetchedMeetingInfo: PrefetchedMeetingInfo) {
2307
+ const {provider, request, extraParams} = prefetchedMeetingInfo;
2308
+
2309
+ await this.prepForFetchMeetingInfo({extraParams}, 'consumePrefetchedMeetingInfo');
2310
+ this.attrs.meetingInfoProvider = provider;
2311
+
2312
+ return this.fetchMeetingInfoInternal({
2313
+ destination: this.destination,
2314
+ destinationType: this.destinationType,
2315
+ extraParams,
2316
+ prefetchedMeetingInfo: {request},
2317
+ });
2318
+ }
2319
+
2146
2320
  /**
2147
2321
  * Checks if the supplied password/host key is correct. It returns a promise with information whether the
2148
2322
  * password and captcha code were correct or not.
@@ -2276,6 +2450,89 @@ export default class Meeting extends StatelessWebexPlugin {
2276
2450
  });
2277
2451
  }
2278
2452
 
2453
+ /**
2454
+ * Handles the LLM state-update message that resulted from a Locus /sync. Records the LLM arrival
2455
+ * time (the milestone that gates client.locus.sync.complete - the metric is emitted only for LLM
2456
+ * flows) and then tries to complete the metric.
2457
+ * @param {string} meetingId meeting id
2458
+ * @param {string} trackingId sync tracking id echoed back on the LLM message
2459
+ * @returns {void}
2460
+ * @private
2461
+ * @memberof Meeting
2462
+ */
2463
+ private onLocusSyncLlmMessage(meetingId: string, trackingId: string) {
2464
+ // @ts-ignore
2465
+ this.webex.internal.newMetrics.callDiagnosticLatencies.recordLocusSyncMessageReceived(
2466
+ meetingId,
2467
+ trackingId
2468
+ );
2469
+
2470
+ this.tryCompleteLocusSyncLatency(meetingId, trackingId);
2471
+ }
2472
+
2473
+ /**
2474
+ * Attempts to complete the Locus sync latency metric and emit client.locus.sync.complete. The
2475
+ * metric is emitted only once BOTH the /sync response and the resulting LLM message have arrived
2476
+ * (in either order); until then the record is kept so the missing milestone can still land. Both
2477
+ * trigger points (the LLM message handler and the /sync response timestamp) call this, so the
2478
+ * metric fires as soon as the second milestone is in.
2479
+ * @param {string} meetingId meeting id
2480
+ * @param {string} trackingId sync tracking id used to match the pending record
2481
+ * @returns {void}
2482
+ * @private
2483
+ * @memberof Meeting
2484
+ */
2485
+ private tryCompleteLocusSyncLatency(meetingId: string, trackingId: string) {
2486
+ const completed =
2487
+ // @ts-ignore
2488
+ this.webex.internal.newMetrics.callDiagnosticLatencies.completeLocusSyncLatency(
2489
+ meetingId,
2490
+ trackingId
2491
+ );
2492
+
2493
+ if (completed) {
2494
+ this.emitLocusSyncCompleteMetric(meetingId, completed);
2495
+ }
2496
+ }
2497
+
2498
+ /**
2499
+ * Submits the client.locus.sync.complete Call Analyzer event for a completed Locus sync latency
2500
+ * measurement.
2501
+ * @param {string} meetingId meeting id
2502
+ * @param {object} completed completed sync latency payload from the metrics plugin
2503
+ * @returns {void}
2504
+ * @private
2505
+ * @memberof Meeting
2506
+ */
2507
+ private emitLocusSyncCompleteMetric(
2508
+ meetingId: string,
2509
+ completed: {dataSet: string; syncLatency: object}
2510
+ ) {
2511
+ // @ts-ignore
2512
+ const llmWebsocketUrl = this.webex.internal.llm?.getWebSocketUrl?.() || undefined;
2513
+
2514
+ // Per the LLM sync-latency spec, the event carries the LLM websocket url identifier,
2515
+ // the llmInfo.dataSet (main, atd-active or atd-unmuted) and the syncLatency block.
2516
+ const clientEvent = {
2517
+ name: 'client.locus.sync.complete',
2518
+ payload: {
2519
+ identifiers: {
2520
+ llmWebsocketUrl,
2521
+ },
2522
+ llmInfo: {
2523
+ dataSet: completed.dataSet,
2524
+ },
2525
+ syncLatency: completed.syncLatency,
2526
+ },
2527
+ options: {
2528
+ meetingId,
2529
+ },
2530
+ };
2531
+
2532
+ // @ts-ignore
2533
+ this.webex.internal.newMetrics.submitClientEvent(clientEvent);
2534
+ }
2535
+
2279
2536
  /**
2280
2537
  * Proxy function for all the listener set ups
2281
2538
  * @returns {undefined}
@@ -2740,7 +2997,7 @@ export default class Meeting extends StatelessWebexPlugin {
2740
2997
  private setupLocusControlsListener() {
2741
2998
  this.locusInfo.on(
2742
2999
  LOCUSINFO.EVENTS.CONTROLS_RECORDING_UPDATED,
2743
- ({state, modifiedBy, lastModified}) => {
3000
+ ({state, modifiedBy, lastModified, modifiedByServiceAppName, modifiedByServiceAppId}) => {
2744
3001
  let event;
2745
3002
 
2746
3003
  switch (state) {
@@ -2766,6 +3023,8 @@ export default class Meeting extends StatelessWebexPlugin {
2766
3023
  state: state === RECORDING_STATE.RESUMED ? RECORDING_STATE.RECORDING : state,
2767
3024
  modifiedBy,
2768
3025
  lastModified,
3026
+ modifiedByServiceAppName,
3027
+ modifiedByServiceAppId,
2769
3028
  };
2770
3029
  Trigger.trigger(
2771
3030
  this,
@@ -2952,6 +3211,18 @@ export default class Meeting extends StatelessWebexPlugin {
2952
3211
  );
2953
3212
  });
2954
3213
 
3214
+ this.locusInfo.on(
3215
+ LOCUSINFO.EVENTS.CONTROLS_AI_SUMMARY_NOTIFICATION_UPDATED,
3216
+ ({aiSummaryNotification}) => {
3217
+ Trigger.trigger(
3218
+ this,
3219
+ {file: 'meeting/index', function: 'setupLocusControlsListener'},
3220
+ EVENT_TRIGGERS.MEETING_CONTROLS_AI_SUMMARY_NOTIFICATION_UPDATED,
3221
+ {aiSummaryNotification}
3222
+ );
3223
+ }
3224
+ );
3225
+
2955
3226
  this.locusInfo.on(LOCUSINFO.EVENTS.CONTROLS_WEBCAST_CHANGED, ({state}) => {
2956
3227
  Trigger.trigger(
2957
3228
  this,
@@ -3152,7 +3423,7 @@ export default class Meeting extends StatelessWebexPlugin {
3152
3423
  }
3153
3424
 
3154
3425
  LoggerProxy.logger.info(
3155
- `Meeting:index#setUpLocusInfoMediaInactiveListener --> this.shareStatus=${this.shareStatus} newShareStatus=${newShareStatus}`
3426
+ `Meeting:index#setUpLocusMediaSharesListener --> this.shareStatus=${this.shareStatus} newShareStatus=${newShareStatus}`
3156
3427
  );
3157
3428
 
3158
3429
  if (newShareStatus !== this.shareStatus) {
@@ -3398,6 +3669,7 @@ export default class Meeting extends StatelessWebexPlugin {
3398
3669
  this.breakouts.locusUrlUpdate(url);
3399
3670
  this.simultaneousInterpretation.locusUrlUpdate(url);
3400
3671
  this.annotation.locusUrlUpdate(url);
3672
+ this.aiEnableRequest.locusUrlUpdate(url);
3401
3673
  this.locusUrl = url;
3402
3674
  this.locusId = this.locusUrl?.split('/').pop();
3403
3675
  this.recordingController.setLocusUrl(this.locusUrl);
@@ -3433,6 +3705,7 @@ export default class Meeting extends StatelessWebexPlugin {
3433
3705
  this.breakouts.breakoutServiceUrlUpdate(payload?.services?.breakout?.url);
3434
3706
  this.annotation.approvalUrlUpdate(payload?.services?.approval?.url);
3435
3707
  this.simultaneousInterpretation.approvalUrlUpdate(payload?.services?.approval?.url);
3708
+ this.aiEnableRequest.approvalUrlUpdate(payload?.services?.approval?.url);
3436
3709
  });
3437
3710
  }
3438
3711
 
@@ -3530,6 +3803,9 @@ export default class Meeting extends StatelessWebexPlugin {
3530
3803
  // @ts-ignore - config coming from registerPlugin
3531
3804
  if (datachannelUrl && this.config.enableAutomaticLLM) {
3532
3805
  this.updateLLMConnection();
3806
+ if (this.webinar.isJoinPracticeSessionDataChannel()) {
3807
+ this.webinar.updatePSDataChannel();
3808
+ }
3533
3809
  }
3534
3810
  }
3535
3811
 
@@ -3693,6 +3969,17 @@ export default class Meeting extends StatelessWebexPlugin {
3693
3969
  });
3694
3970
  }
3695
3971
  this.rtcMetrics?.sendNextMetrics();
3972
+
3973
+ try {
3974
+ await this.ensureDefaultDatachannelTokenAfterAdmit();
3975
+ } catch (error) {
3976
+ LoggerProxy.logger.warn(
3977
+ `Meeting:index#setUpLocusInfoSelfListener --> failed post-admit token prefetch flow: ${
3978
+ error?.message || String(error)
3979
+ }`
3980
+ );
3981
+ }
3982
+
3696
3983
  this.updateLLMConnection();
3697
3984
  });
3698
3985
 
@@ -3737,6 +4024,9 @@ export default class Meeting extends StatelessWebexPlugin {
3737
4024
  });
3738
4025
 
3739
4026
  this.locusInfo.on(LOCUSINFO.EVENTS.SELF_CANNOT_VIEW_PARTICIPANT_LIST_CHANGE, (payload) => {
4027
+ // canViewTheParticipantList meeting action depends on this value, so we need to update meeting actions
4028
+ this.updateMeetingActions();
4029
+
3740
4030
  Trigger.trigger(
3741
4031
  this,
3742
4032
  {
@@ -3762,6 +4052,10 @@ export default class Meeting extends StatelessWebexPlugin {
3762
4052
  );
3763
4053
  });
3764
4054
 
4055
+ this.locusInfo.on(LOCUSINFO.EVENTS.SELF_ID_CHANGED, (payload) => {
4056
+ this.aiEnableRequest.selfParticipantIdUpdate(payload.selfId);
4057
+ });
4058
+
3765
4059
  this.locusInfo.on(LOCUSINFO.EVENTS.SELF_MEETING_INTERPRETATION_CHANGED, (payload) => {
3766
4060
  const targetChanged = this.simultaneousInterpretation.updateSelfInterpretation(payload);
3767
4061
  Trigger.trigger(
@@ -3927,7 +4221,14 @@ export default class Meeting extends StatelessWebexPlugin {
3927
4221
  // is not changed by any delta event
3928
4222
  if (object && Object.keys(object).length) {
3929
4223
  Object.keys(object).forEach((key) => {
4224
+ const previousValue = this[key];
4225
+
3930
4226
  this[key] = object[key];
4227
+
4228
+ if (this.promisesWaitingForPropUpdate[key] && previousValue !== object[key]) {
4229
+ this.promisesWaitingForPropUpdate[key].resolve();
4230
+ delete this.promisesWaitingForPropUpdate[key];
4231
+ }
3931
4232
  });
3932
4233
  }
3933
4234
  }
@@ -4065,7 +4366,12 @@ export default class Meeting extends StatelessWebexPlugin {
4065
4366
  }
4066
4367
 
4067
4368
  /**
4068
- * Transfer the moderator role to another eligible member
4369
+ * Transfer the moderator role to another eligible member.
4370
+ *
4371
+ * If the target member is currently joined in the current session, the request is
4372
+ * sent against the current locus. Otherwise, we search the breakout sessions and,
4373
+ * when the member is found in one, we send the request against that breakout
4374
+ * session's locus url instead.
4069
4375
  * @param {String} memberId
4070
4376
  * @param {Boolean} moderator
4071
4377
  * @returns {Promise} see #members.transferHostToMember
@@ -4073,7 +4379,21 @@ export default class Meeting extends StatelessWebexPlugin {
4073
4379
  * @memberof Meeting
4074
4380
  */
4075
4381
  public transfer(memberId: string, moderator = true) {
4076
- return this.members.transferHostToMember(memberId, moderator);
4382
+ const targetMember = this.members.membersCollection.get(memberId);
4383
+
4384
+ if (targetMember?.isInMeeting) {
4385
+ return this.members.transferHostToMember(memberId, moderator);
4386
+ }
4387
+
4388
+ const breakout = this.breakouts?.breakouts?.models?.find((bo: any) => {
4389
+ const breakoutMember = bo.members?.membersCollection?.get(memberId);
4390
+
4391
+ return breakoutMember?.isInMeeting;
4392
+ });
4393
+
4394
+ const breakoutLocusUrl = breakout?.breakoutRosterLocus?.url;
4395
+
4396
+ return this.members.transferHostToMember(memberId, moderator, breakoutLocusUrl);
4077
4397
  }
4078
4398
 
4079
4399
  /**
@@ -4264,6 +4584,9 @@ export default class Meeting extends StatelessWebexPlugin {
4264
4584
  bothLeaveAndEndMeetingAvailable: MeetingUtil.bothLeaveAndEndMeetingAvailable(
4265
4585
  this.userDisplayHints
4266
4586
  ),
4587
+ requireHostEndMeetingBeforeLeave: MeetingUtil.requireHostEndMeetingBeforeLeave(
4588
+ this.userDisplayHints
4589
+ ),
4267
4590
  canEnableClosedCaption: MeetingUtil.canEnableClosedCaption(this.userDisplayHints),
4268
4591
  canStartTranscribing: MeetingUtil.canStartTranscribing(this.userDisplayHints),
4269
4592
  canStopTranscribing: MeetingUtil.canStopTranscribing(this.userDisplayHints),
@@ -4522,6 +4845,19 @@ export default class Meeting extends StatelessWebexPlugin {
4522
4845
  requiredHints: [DISPLAY_HINTS.DISABLE_ATTENDEE_START_POLLING_QA],
4523
4846
  displayHints: this.userDisplayHints,
4524
4847
  }),
4848
+ canAttendeeRequestAiAssistantEnabled: MeetingUtil.canAttendeeRequestAiAssistantEnabled(
4849
+ this.userDisplayHints,
4850
+ this.roles
4851
+ ),
4852
+ isAttendeeRequestAiAssistantDeclinedAll:
4853
+ MeetingUtil.attendeeRequestAiAssistantDeclinedAll(this.userDisplayHints),
4854
+ isAnonymizeDisplayNamesEnabled: MeetingUtil.isAnonymizeDisplayNamesEnabled(
4855
+ this.userDisplayHints
4856
+ ),
4857
+ canViewTheParticipantList: MeetingUtil.canViewTheParticipantList(
4858
+ this.userDisplayHints,
4859
+ this.canNotViewTheParticipantList ?? false
4860
+ ),
4525
4861
  }) || changed;
4526
4862
  }
4527
4863
  if (changed) {
@@ -4570,6 +4906,34 @@ export default class Meeting extends StatelessWebexPlugin {
4570
4906
  this.sipUri = sipUri;
4571
4907
  }
4572
4908
 
4909
+ /**
4910
+ * After initial locus setup, refreshes destination with synced locus data and optionally
4911
+ * performs deferred meeting info fetch when initial locus was incomplete.
4912
+ * @param {LocusDTO} locus
4913
+ * @returns {void}
4914
+ */
4915
+ public async finalizeMeetingAfterInitialLocusSetup(locus: LocusDTO): Promise<void> {
4916
+ if (locus && this?.destinationType === DESTINATION_TYPE.LOCUS_ID) {
4917
+ // destination is initialized from the initial locus snapshot in constructor,
4918
+ // so refresh it after locus sync to avoid stale partial hash-tree data.
4919
+ this.destination = locus;
4920
+ }
4921
+ if (
4922
+ (!this.meetingInfo || isEmpty(this.meetingInfo)) &&
4923
+ (this.destination as LocusDTO)?.info &&
4924
+ !this.fetchMeetingInfoTimeoutId &&
4925
+ !MeetingsUtil.isOneOnOneCall(locus)
4926
+ ) {
4927
+ try {
4928
+ await this.fetchMeetingInfo({});
4929
+ } catch (error: any) {
4930
+ LoggerProxy.logger.info(
4931
+ `Meeting:index#finalizeMeetingAfterInitialLocusSetup --> deferred fetchMeetingInfo failed: ${error.message}`
4932
+ );
4933
+ }
4934
+ }
4935
+ }
4936
+
4573
4937
  /**
4574
4938
  * Set the locus info the class instance. Should be called with the parsed locus
4575
4939
  * we got in the join response.
@@ -4593,7 +4957,8 @@ export default class Meeting extends StatelessWebexPlugin {
4593
4957
  mediaId: string;
4594
4958
  host: object;
4595
4959
  selfId: string;
4596
- dataSets: DataSet[];
4960
+ dataSets: DataSet[]; // only sent by Locus when hash trees are used
4961
+ metadata: Metadata; // only sent by Locus when hash trees are used
4597
4962
  }) {
4598
4963
  const mtgLocus: any = data.locus;
4599
4964
 
@@ -4609,6 +4974,7 @@ export default class Meeting extends StatelessWebexPlugin {
4609
4974
  trigger: 'join-response',
4610
4975
  locus: mtgLocus,
4611
4976
  dataSets: data.dataSets,
4977
+ metadata: data.metadata,
4612
4978
  });
4613
4979
  }
4614
4980
 
@@ -4818,6 +5184,7 @@ export default class Meeting extends StatelessWebexPlugin {
4818
5184
  this.localVideoStreamMuteStateHandler
4819
5185
  );
4820
5186
  oldStream?.off(LocalStreamEventNames.OutputTrackChange, this.localOutputTrackChangeHandler);
5187
+ oldStream?.off(LocalStreamEventNames.ConstraintsChange, this.localConstraintsChangeHandler);
4821
5188
 
4822
5189
  // we don't update this.mediaProperties.mediaDirection.sendVideo, because we always keep it as true to avoid extra SDP exchanges
4823
5190
  this.mediaProperties.setLocalVideoStream(localStream);
@@ -4833,6 +5200,7 @@ export default class Meeting extends StatelessWebexPlugin {
4833
5200
  this.localVideoStreamMuteStateHandler
4834
5201
  );
4835
5202
  localStream?.on(LocalStreamEventNames.OutputTrackChange, this.localOutputTrackChangeHandler);
5203
+ localStream?.on(LocalStreamEventNames.ConstraintsChange, this.localConstraintsChangeHandler);
4836
5204
 
4837
5205
  if (!this.isMultistream || !localStream) {
4838
5206
  // for multistream WCME automatically un-publishes the old stream when we publish a new one
@@ -4967,6 +5335,7 @@ export default class Meeting extends StatelessWebexPlugin {
4967
5335
  this.localVideoStreamMuteStateHandler
4968
5336
  );
4969
5337
  videoStream?.off(LocalStreamEventNames.OutputTrackChange, this.localOutputTrackChangeHandler);
5338
+ videoStream?.off(LocalStreamEventNames.ConstraintsChange, this.localConstraintsChangeHandler);
4970
5339
 
4971
5340
  shareAudioStream?.off(StreamEventNames.Ended, this.handleShareAudioStreamEnded);
4972
5341
  shareAudioStream?.off(
@@ -5036,8 +5405,7 @@ export default class Meeting extends StatelessWebexPlugin {
5036
5405
  public setMercuryListener() {
5037
5406
  // Client will have a socket manager and handle reconnecting to mercury, when we reconnect to mercury
5038
5407
  // if the meeting has active peer connections, it should try to reconnect.
5039
- // @ts-ignore
5040
- this.webex.internal.mercury.on(ONLINE, () => {
5408
+ this.mercuryOnlineHandler = () => {
5041
5409
  LoggerProxy.logger.info('Meeting:index#setMercuryListener --> Web socket online');
5042
5410
 
5043
5411
  // Only send restore event when it was disconnected before and for connected later
@@ -5047,15 +5415,47 @@ export default class Meeting extends StatelessWebexPlugin {
5047
5415
  });
5048
5416
  }
5049
5417
  this.hasWebsocketConnected = true;
5050
- });
5418
+ };
5051
5419
 
5052
- // @ts-ignore
5053
- this.webex.internal.mercury.on(OFFLINE, () => {
5420
+ this.mercuryOfflineHandler = () => {
5054
5421
  LoggerProxy.logger.error('Meeting:index#setMercuryListener --> Web socket offline');
5055
5422
  Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.MERCURY_CONNECTION_FAILURE, {
5056
5423
  correlation_id: this.correlationId,
5057
5424
  });
5058
- });
5425
+ };
5426
+
5427
+ // @ts-ignore
5428
+ this.webex.internal.mercury.on(ONLINE, this.mercuryOnlineHandler);
5429
+ // @ts-ignore
5430
+ this.webex.internal.mercury.on(OFFLINE, this.mercuryOfflineHandler);
5431
+ }
5432
+
5433
+ /**
5434
+ * Removes this meeting's Mercury ONLINE/OFFLINE event listeners registered
5435
+ * by setMercuryListener(). Must be called before Locus /leave to avoid
5436
+ * unnecessary syncs/metrics triggered by events received while leaving
5437
+ * (per Locus team recommendation).
5438
+ *
5439
+ * Mercury is a process-wide singleton shared with other plugins, so we
5440
+ * pass the bound handler refs to .off() to avoid clearing every listener
5441
+ * for ONLINE/OFFLINE on the shared emitter.
5442
+ *
5443
+ * Idempotent: subsequent calls are no-ops because the handler refs are
5444
+ * cleared after detaching.
5445
+ * @private
5446
+ * @returns {void}
5447
+ */
5448
+ private stopListeningForMercuryEvents() {
5449
+ if (this.mercuryOnlineHandler) {
5450
+ // @ts-ignore
5451
+ this.webex.internal.mercury.off(ONLINE, this.mercuryOnlineHandler);
5452
+ this.mercuryOnlineHandler = undefined;
5453
+ }
5454
+ if (this.mercuryOfflineHandler) {
5455
+ // @ts-ignore
5456
+ this.webex.internal.mercury.off(OFFLINE, this.mercuryOfflineHandler);
5457
+ this.mercuryOfflineHandler = undefined;
5458
+ }
5059
5459
  }
5060
5460
 
5061
5461
  /**
@@ -5079,6 +5479,7 @@ export default class Meeting extends StatelessWebexPlugin {
5079
5479
  );
5080
5480
 
5081
5481
  this.receiveSlotManager.reset();
5482
+
5082
5483
  this.mediaProperties.webrtcMediaConnection.close();
5083
5484
  this.mediaProperties.unsetPeerConnection();
5084
5485
  this.sendSlotManager.reset();
@@ -5366,7 +5767,7 @@ export default class Meeting extends StatelessWebexPlugin {
5366
5767
  } = {}
5367
5768
  ) {
5368
5769
  const {mediaOptions, joinOptions = {}} = options;
5369
- const {isRetry, prevJoinResponse} = this.joinWithMediaRetryInfo;
5770
+ const {retryCount, prevJoinResponse, prevError} = this.joinWithMediaRetryInfo;
5370
5771
 
5371
5772
  if (!mediaOptions?.allowMediaInLobby) {
5372
5773
  return Promise.reject(
@@ -5377,9 +5778,6 @@ export default class Meeting extends StatelessWebexPlugin {
5377
5778
 
5378
5779
  LoggerProxy.logger.info('Meeting:index#joinWithMedia called');
5379
5780
 
5380
- let joined = false;
5381
- let joinResponse = prevJoinResponse;
5382
-
5383
5781
  /* Before we do anything, check if RTCPeerConnection is available. Normally this is checked
5384
5782
  by addMediaInternal() itself when creating the media connection, but since joinWithMedia()
5385
5783
  is a convenience method that does both join() and addMedia(), we want to fail fast here
@@ -5392,12 +5790,28 @@ export default class Meeting extends StatelessWebexPlugin {
5392
5790
  );
5393
5791
  }
5394
5792
 
5793
+ /* While we're trying to join, we may fail and be doing a retry. In that case,
5794
+ we sometimes get dropped by Locus as a result of the 1st failed attempt.
5795
+ That notification from Locus needs to be ignored, otherwise it causes the meeting to be
5796
+ cleaned up and prevents the retry from running correctly.
5797
+ */
5798
+ this.locusInfo.suspendDestroyMeeting(true);
5799
+
5800
+ let joined = false;
5801
+ let joinResponse = prevJoinResponse;
5802
+
5803
+ const shouldJoin =
5804
+ !joinResponse || // first try, when the join response is empty
5805
+ (prevError && prevError instanceof UserNotJoinedError) || // last try failed with UserNotJoinedError
5806
+ this.isErrorMeaningLocusDroppedUs(prevError) ||
5807
+ MeetingUtil.isUserInLeftState(this.locusInfo); // locus dropped the connection before we can re-try addMedia
5808
+
5395
5809
  try {
5396
5810
  let turnServerInfo;
5397
5811
  let turnDiscoverySkippedReason;
5398
5812
  let forceTurnDiscovery = false;
5399
5813
 
5400
- if (!joinResponse) {
5814
+ if (shouldJoin) {
5401
5815
  // This is the 1st attempt or a retry after join request failed -> we need to do a join with TURN discovery
5402
5816
 
5403
5817
  const turnDiscoveryRequest = await this.roap.generateTurnDiscoveryRequestMessage(
@@ -5436,16 +5850,24 @@ export default class Meeting extends StatelessWebexPlugin {
5436
5850
  joined = true;
5437
5851
  }
5438
5852
 
5853
+ const shouldRetryMediaWithOnlyTurnTLS = await this.shouldRetryMediaWithOnlyTurnTLS(prevError);
5854
+
5439
5855
  const mediaResponse = await this.addMediaInternal(
5440
5856
  () => {
5441
- return this.joinWithMediaRetryInfo.isRetry ? 'JOIN_MEETING_FINAL' : 'JOIN_MEETING_RETRY';
5857
+ // callback is not called when UserNotJoinedError is thrown
5858
+ return this.joinWithMediaRetryInfo.retryCount >= 1
5859
+ ? 'JOIN_MEETING_FINAL'
5860
+ : 'JOIN_MEETING_RETRY';
5442
5861
  },
5443
- turnServerInfo,
5444
5862
  forceTurnDiscovery,
5863
+ turnServerInfo,
5864
+ shouldRetryMediaWithOnlyTurnTLS ? 'relay' : undefined,
5445
5865
  mediaOptions
5446
5866
  );
5447
5867
 
5448
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
5868
+ this.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
5869
+
5870
+ this.locusInfo.suspendDestroyMeeting(false);
5449
5871
 
5450
5872
  return {
5451
5873
  join: joinResponse,
@@ -5459,8 +5881,12 @@ export default class Meeting extends StatelessWebexPlugin {
5459
5881
 
5460
5882
  this.roap.abortTurnDiscovery();
5461
5883
 
5462
- // if this was the first attempt, let's do a retry
5463
- let shouldRetry = !isRetry;
5884
+ // let's do a retry (but not on 1-1 calls, because the flow would get too complicated)
5885
+ let shouldRetry =
5886
+ !MeetingsUtil.isOneOnOneCall(this.locusInfo.parsedLocus) &&
5887
+ (retryCount < 1 ||
5888
+ ((error instanceof UserNotJoinedError || this.isErrorMeaningLocusDroppedUs(error)) &&
5889
+ retryCount < JOIN_WITH_MEDIA_RETRY_MAX_COUNT));
5464
5890
 
5465
5891
  if (
5466
5892
  CallDiagnosticUtils.isSdpOfferCreationError(error) ||
@@ -5485,8 +5911,8 @@ export default class Meeting extends StatelessWebexPlugin {
5485
5911
  });
5486
5912
  }
5487
5913
 
5488
- // we only want to call leave if join was successful and this was a retry or we won't be doing any more retries
5489
- if (joined && (isRetry || !shouldRetry)) {
5914
+ // we only want to call leave if join was successful, and we won't be doing any more retries
5915
+ if (joined && !shouldRetry) {
5490
5916
  try {
5491
5917
  await this.leave({resourceId: joinOptions?.resourceId, reason: 'joinWithMedia failure'});
5492
5918
  } catch (e) {
@@ -5503,7 +5929,7 @@ export default class Meeting extends StatelessWebexPlugin {
5503
5929
  reason: error.message,
5504
5930
  stack: error.stack,
5505
5931
  leaveErrorReason: leaveError?.message,
5506
- isRetry,
5932
+ isRetry: retryCount > 0,
5507
5933
  },
5508
5934
  {
5509
5935
  type: error.name,
@@ -5512,15 +5938,28 @@ export default class Meeting extends StatelessWebexPlugin {
5512
5938
 
5513
5939
  if (shouldRetry) {
5514
5940
  LoggerProxy.logger.warn('Meeting:index#joinWithMedia --> retrying call to joinWithMedia');
5515
- this.joinWithMediaRetryInfo.isRetry = true;
5941
+ this.joinWithMediaRetryInfo.retryCount = retryCount + 1;
5516
5942
  this.joinWithMediaRetryInfo.prevJoinResponse = joinResponse;
5943
+ this.joinWithMediaRetryInfo.prevError = error;
5944
+ if (!this.joinWithMediaRetryInfo.firstError) {
5945
+ this.joinWithMediaRetryInfo.firstError = error;
5946
+ }
5517
5947
 
5518
5948
  return this.joinWithMedia(options);
5519
5949
  }
5520
5950
 
5521
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
5951
+ const {firstError} = this.joinWithMediaRetryInfo;
5522
5952
 
5523
- throw error;
5953
+ this.joinWithMediaRetryInfo = {
5954
+ retryCount: 0,
5955
+ prevJoinResponse: undefined,
5956
+ firstError: undefined,
5957
+ prevError: undefined,
5958
+ };
5959
+
5960
+ this.locusInfo.suspendDestroyMeeting(false);
5961
+
5962
+ throw firstError ?? error;
5524
5963
  }
5525
5964
  }
5526
5965
 
@@ -5758,7 +6197,23 @@ export default class Meeting extends StatelessWebexPlugin {
5758
6197
  */
5759
6198
  private processLocusLLMEvent = (event: LocusLLMEvent): void => {
5760
6199
  if (event.data.eventType === LOCUSEVENT.HASH_TREE_DATA_UPDATED) {
6200
+ // @ts-ignore
6201
+ if (this.config.experimental.storeLocusHashTreeEventsForDebugging) {
6202
+ storeEventForDebugging('llm', event.data);
6203
+ }
6204
+
6205
+ const {trackingId} = event;
6206
+
5761
6207
  this.locusInfo.parse(this, event.data);
6208
+
6209
+ // Only the client whose /sync request tracking id matches the tracking id echoed back on this
6210
+ // LLM message should emit client.locus.sync.complete. The tracking id lives at the top level
6211
+ // of the received LLM event envelope. When it is absent there is nothing to correlate, so
6212
+ // skip. onLocusSyncLlmMessage records the LLM arrival time and is a no-op unless a stored
6213
+ // record for this meeting matches the tracking id.
6214
+ if (trackingId) {
6215
+ this.onLocusSyncLlmMessage(this.id, trackingId);
6216
+ }
5762
6217
  } else {
5763
6218
  LoggerProxy.logger.warn(
5764
6219
  `Meeting:index#processLocusLLMEvent --> Unknown event type: ${event.data.eventType}`
@@ -5766,6 +6221,31 @@ export default class Meeting extends StatelessWebexPlugin {
5766
6221
  }
5767
6222
  };
5768
6223
 
6224
+ /**
6225
+ * Verifies the relay event was delivered for the active LLM session binding.
6226
+ * @param {RelayEvent} event Event object coming from LLM Connection
6227
+ * @returns {boolean}
6228
+ */
6229
+ private isRelayEventRouteValid(event: RelayEvent): boolean {
6230
+ const route = event?.headers?.route;
6231
+
6232
+ if (!route) {
6233
+ return true;
6234
+ }
6235
+
6236
+ const {llm} = (this as any).webex.internal;
6237
+ const isPracticeSession = llm.isConnected(LLM_PRACTICE_SESSION);
6238
+ const expectedBinding = isPracticeSession
6239
+ ? llm.getBinding(LLM_PRACTICE_SESSION)
6240
+ : llm.getBinding();
6241
+
6242
+ if (!expectedBinding || route === expectedBinding) {
6243
+ return true;
6244
+ }
6245
+
6246
+ return false;
6247
+ }
6248
+
5769
6249
  /**
5770
6250
  * Callback called when a relay event is received from meeting LLM Connection
5771
6251
  * @param {RelayEvent} e Event object coming from LLM Connection
@@ -5773,6 +6253,9 @@ export default class Meeting extends StatelessWebexPlugin {
5773
6253
  * @returns {void}
5774
6254
  */
5775
6255
  private processRelayEvent = (e: RelayEvent): void => {
6256
+ if (!this.isRelayEventRouteValid(e)) {
6257
+ return;
6258
+ }
5776
6259
  switch (e.data.relayType) {
5777
6260
  case REACTION_RELAY_TYPES.REACTION:
5778
6261
  if (
@@ -5781,7 +6264,7 @@ export default class Meeting extends StatelessWebexPlugin {
5781
6264
  this.isReactionsSupported()
5782
6265
  ) {
5783
6266
  const member = this.members.membersCollection.get(e.data.sender.participantId);
5784
- if (!member) {
6267
+ if (!member && !this.locusInfo?.info?.isWebinar) {
5785
6268
  // @ts-ignore -- fix type
5786
6269
  LoggerProxy.logger.warn(
5787
6270
  `Meeting:index#processRelayEvent --> Skipping handling of ${REACTION_RELAY_TYPES.REACTION} for ${this.id}. participantId ${e.data.sender.participantId} does not exist in membersCollection.`
@@ -5789,7 +6272,7 @@ export default class Meeting extends StatelessWebexPlugin {
5789
6272
  break;
5790
6273
  }
5791
6274
 
5792
- const {name} = member;
6275
+ const name = (member && member.name) || e.data.sender.displayName;
5793
6276
  const processedReaction: ProcessedReaction = {
5794
6277
  reaction: e.data.reaction,
5795
6278
  sender: {
@@ -5818,37 +6301,35 @@ export default class Meeting extends StatelessWebexPlugin {
5818
6301
  * @returns {void}
5819
6302
  */
5820
6303
  stopTranscription() {
5821
- if (this.transcription) {
5822
- // @ts-ignore
5823
- this.webex.internal.voicea.off(
5824
- VOICEAEVENTS.VOICEA_ANNOUNCEMENT,
5825
- this.voiceaListenerCallbacks[VOICEAEVENTS.VOICEA_ANNOUNCEMENT]
5826
- );
6304
+ // @ts-ignore
6305
+ this.webex.internal.voicea.off(
6306
+ VOICEAEVENTS.VOICEA_ANNOUNCEMENT,
6307
+ this.voiceaListenerCallbacks[VOICEAEVENTS.VOICEA_ANNOUNCEMENT]
6308
+ );
5827
6309
 
5828
- // @ts-ignore
5829
- this.webex.internal.voicea.off(
5830
- VOICEAEVENTS.CAPTIONS_TURNED_ON,
5831
- this.voiceaListenerCallbacks[VOICEAEVENTS.CAPTIONS_TURNED_ON]
5832
- );
6310
+ // @ts-ignore
6311
+ this.webex.internal.voicea.off(
6312
+ VOICEAEVENTS.CAPTIONS_TURNED_ON,
6313
+ this.voiceaListenerCallbacks[VOICEAEVENTS.CAPTIONS_TURNED_ON]
6314
+ );
5833
6315
 
5834
- // @ts-ignore
5835
- this.webex.internal.voicea.off(
5836
- VOICEAEVENTS.EVA_COMMAND,
5837
- this.voiceaListenerCallbacks[VOICEAEVENTS.EVA_COMMAND]
5838
- );
6316
+ // @ts-ignore
6317
+ this.webex.internal.voicea.off(
6318
+ VOICEAEVENTS.EVA_COMMAND,
6319
+ this.voiceaListenerCallbacks[VOICEAEVENTS.EVA_COMMAND]
6320
+ );
5839
6321
 
5840
- // @ts-ignore
5841
- this.webex.internal.voicea.off(
5842
- VOICEAEVENTS.NEW_CAPTION,
5843
- this.voiceaListenerCallbacks[VOICEAEVENTS.NEW_CAPTION]
5844
- );
6322
+ // @ts-ignore
6323
+ this.webex.internal.voicea.off(
6324
+ VOICEAEVENTS.NEW_CAPTION,
6325
+ this.voiceaListenerCallbacks[VOICEAEVENTS.NEW_CAPTION]
6326
+ );
5845
6327
 
5846
- // @ts-ignore
5847
- this.webex.internal.voicea.deregisterEvents();
6328
+ // @ts-ignore
6329
+ this.webex.internal.voicea.deregisterEvents();
5848
6330
 
5849
- this.areVoiceaEventsSetup = false;
5850
- this.triggerStopReceivingTranscriptionEvent();
5851
- }
6331
+ this.areVoiceaEventsSetup = false;
6332
+ this.triggerStopReceivingTranscriptionEvent();
5852
6333
  }
5853
6334
 
5854
6335
  /**
@@ -5872,6 +6353,31 @@ export default class Meeting extends StatelessWebexPlugin {
5872
6353
  );
5873
6354
  }
5874
6355
 
6356
+ /**
6357
+ * Restores LLM subchannel subscriptions after reconnect when captions are active.
6358
+ * @returns {void}
6359
+ */
6360
+ private restoreLLMSubscriptionsIfNeeded(): void {
6361
+ try {
6362
+ const keepTranscriptionSubscribed =
6363
+ // @ts-ignore
6364
+ this.webex.internal.voicea?.getKeepTranscriptionSubscribed?.();
6365
+
6366
+ if (!keepTranscriptionSubscribed) {
6367
+ return;
6368
+ }
6369
+
6370
+ // @ts-ignore
6371
+ this.webex.internal.voicea.updateSubchannelSubscriptions({subscribe: ['transcription']});
6372
+ } catch (error) {
6373
+ const msg = error?.message || String(error);
6374
+
6375
+ LoggerProxy.logger.warn(
6376
+ `Meeting:index#restoreLLMSubscriptionsIfNeeded --> failed to restore subscriptions after LLM online: ${msg}`
6377
+ );
6378
+ }
6379
+ }
6380
+
5875
6381
  /**
5876
6382
  * This is a callback for the LLM event that is triggered when it comes online
5877
6383
  * This method in turn will trigger an event to the developers that the LLM is connected
@@ -5880,8 +6386,9 @@ export default class Meeting extends StatelessWebexPlugin {
5880
6386
  * @returns {null}
5881
6387
  */
5882
6388
  private handleLLMOnline = (): void => {
5883
- // @ts-ignore
5884
- this.webex.internal.llm.off('online', this.handleLLMOnline);
6389
+ this.restoreLLMSubscriptionsIfNeeded();
6390
+ this.locusInfo.syncAllHashTreeDatasets({onlyLLM: true});
6391
+
5885
6392
  Trigger.trigger(
5886
6393
  this,
5887
6394
  {
@@ -6109,11 +6616,14 @@ export default class Meeting extends StatelessWebexPlugin {
6109
6616
  return Promise.reject(error);
6110
6617
  })
6111
6618
  .then((join) => {
6619
+ this.saveDataChannelToken(join);
6112
6620
  // @ts-ignore - config coming from registerPlugin
6113
6621
  if (this.config.enableAutomaticLLM) {
6622
+ // @ts-ignore
6623
+ this.webex.internal.llm.off('online', this.handleLLMOnline);
6114
6624
  // @ts-ignore
6115
6625
  this.webex.internal.llm.on('online', this.handleLLMOnline);
6116
- this.updateLLMConnection()
6626
+ this.updateLLMConnection({isInitialJoinPhase: true})
6117
6627
  .catch((error) => {
6118
6628
  LoggerProxy.logger.error(
6119
6629
  'Meeting:index#join --> Transcription Socket Connection Failed',
@@ -6177,26 +6687,275 @@ export default class Meeting extends StatelessWebexPlugin {
6177
6687
  }
6178
6688
  }
6179
6689
 
6690
+ /**
6691
+ * Removes LLM event listeners and clears the health check timer.
6692
+ * Must be called before Locus /leave to avoid unnecessary syncs triggered
6693
+ * by events received while leaving (per Locus team recommendation).
6694
+ * Idempotent: safe to call multiple times; .off() is a no-op when no
6695
+ * matching listener is registered.
6696
+ * @private
6697
+ * @returns {void}
6698
+ */
6699
+ private stopListeningForLLMEvents() {
6700
+ // @ts-ignore - fix types
6701
+ this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6702
+ // @ts-ignore - fix types
6703
+ this.webex.internal.llm.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6704
+ this.clearLLMHealthCheckTimer();
6705
+ }
6706
+
6707
+ /**
6708
+ * Stops listening on every event bus (LLM, Mercury, voicea/transcription,
6709
+ * annotation) that could otherwise deliver events to this meeting while
6710
+ * Locus is processing /leave or /end. Per the Locus team recommendation,
6711
+ * this must run before the Locus request is dispatched to avoid
6712
+ * unnecessary syncs triggered by in-flight events.
6713
+ *
6714
+ * Voicea (transcription) subscribes to llm 'event:relay.event' internally,
6715
+ * and the annotation plugin subscribes to both mercury and llm, so both
6716
+ * must be torn down alongside the direct LLM/Mercury listeners.
6717
+ *
6718
+ * Idempotent: safe to call multiple times; .off() is a no-op when no
6719
+ * matching listener is registered, and stopTranscription is guarded.
6720
+ * @private
6721
+ * @returns {void}
6722
+ */
6723
+ private stopListeningForMeetingEvents() {
6724
+ this.stopListeningForLLMEvents();
6725
+ this.stopListeningForMercuryEvents();
6726
+ if (this.transcription) {
6727
+ this.stopTranscription();
6728
+ this.transcription = undefined;
6729
+ }
6730
+ this.annotation.deregisterEvents();
6731
+ }
6732
+
6733
+ /**
6734
+ * Disconnects and cleans up the default LLM session listeners/timers.
6735
+ *
6736
+ * Ownership-aware: only calls `disconnectLLM` when this meeting is the
6737
+ * current owner of the default LLM session (or when no owner is recorded).
6738
+ * Event listeners belonging to this meeting instance are always detached
6739
+ * so they do not receive another meeting's relay events.
6740
+ *
6741
+ * @param {Object} options
6742
+ * @param {boolean} [options.removeOnlineListener=true] removes the one-time online listener
6743
+ * @param {boolean} [options.throwOnError=true] rethrows disconnect errors when true
6744
+ * @returns {Promise<void>}
6745
+ */
6746
+ private cleanupLLMConneciton = async ({
6747
+ removeOnlineListener = true,
6748
+ throwOnError = true,
6749
+ }: {
6750
+ removeOnlineListener?: boolean;
6751
+ throwOnError?: boolean;
6752
+ } = {}): Promise<void> => {
6753
+ // @ts-ignore - Fix type
6754
+ // @ts-ignore - Fix type
6755
+ const {currentOwner, isOwner} = this.webex.internal.llm.resolveSessionOwnership(
6756
+ this.id,
6757
+ LLM_DEFAULT_SESSION
6758
+ );
6759
+
6760
+ try {
6761
+ if (isOwner) {
6762
+ // @ts-ignore - Fix type
6763
+ await this.webex.internal.llm.disconnectLLM(
6764
+ {
6765
+ code: 3050,
6766
+ reason: 'done (permanent)',
6767
+ },
6768
+ LLM_DEFAULT_SESSION,
6769
+ this.id
6770
+ );
6771
+ } else {
6772
+ LoggerProxy.logger.info(
6773
+ `Meeting:index#cleanupLLMConneciton --> skipping disconnect; LLM owned by meeting ${currentOwner}, not ${this.id}`
6774
+ );
6775
+ }
6776
+ } catch (error) {
6777
+ LoggerProxy.logger.error(
6778
+ 'Meeting:index#cleanupLLMConneciton --> Failed to disconnect default LLM session',
6779
+ error
6780
+ );
6781
+
6782
+ if (throwOnError) {
6783
+ throw error;
6784
+ }
6785
+ } finally {
6786
+ if (removeOnlineListener) {
6787
+ // @ts-ignore - Fix type
6788
+ this.webex.internal.llm.off('online', this.handleLLMOnline);
6789
+ }
6790
+ this.stopListeningForLLMEvents();
6791
+
6792
+ // Re-check ownership after awaiting disconnectLLM. If ownership changed
6793
+ // while cleanup was in flight, do not clear another meeting's owner tag.
6794
+ if (isOwner) {
6795
+ const {currentOwner: currentOwnerAfterCleanup} =
6796
+ // @ts-ignore - Fix type
6797
+ this.webex.internal.llm.resolveSessionOwnership(this.id, LLM_DEFAULT_SESSION);
6798
+
6799
+ if (currentOwnerAfterCleanup === this.id) {
6800
+ // @ts-ignore - Fix type
6801
+ this.webex.internal.llm.setOwnerMeetingId?.(undefined);
6802
+ }
6803
+ }
6804
+ }
6805
+ };
6806
+
6807
+ /**
6808
+ * Clears data channel tokens associated with this meeting ownership.
6809
+ * Ownership checks are enforced in internal-plugin-llm.
6810
+ * @returns {void}
6811
+ */
6812
+ clearDataChannelToken(): void {
6813
+ // @ts-ignore
6814
+ this.webex.internal.llm.clearDatachannelToken(LLM_DEFAULT_SESSION, this.id);
6815
+ // @ts-ignore
6816
+ this.webex.internal.llm.clearDatachannelToken(LLM_PRACTICE_SESSION, this.id);
6817
+ }
6818
+
6819
+ /**
6820
+ * Saves the data channel tokens from the join response into LLM so that
6821
+ * updateLLMConnection / updatePSDataChannel don't need to fetch them from locusInfo.
6822
+ * @param {Object} join - The parsed join response (from MeetingUtil.parseLocusJoin)
6823
+ * @returns {void}
6824
+ */
6825
+ saveDataChannelToken(join: any): void {
6826
+ const datachannelToken = join?.locus?.self?.datachannelToken;
6827
+ const practiceSessionDatachannelToken = join?.locus?.self?.practiceSessionDatachannelToken;
6828
+
6829
+ if (datachannelToken) {
6830
+ // @ts-ignore
6831
+ this.webex.internal.llm.setDatachannelToken(datachannelToken, LLM_DEFAULT_SESSION, this.id);
6832
+ }
6833
+
6834
+ if (practiceSessionDatachannelToken) {
6835
+ // @ts-ignore
6836
+ this.webex.internal.llm.setDatachannelToken(
6837
+ practiceSessionDatachannelToken,
6838
+ LLM_PRACTICE_SESSION,
6839
+ this.id
6840
+ );
6841
+ }
6842
+ }
6843
+
6844
+ /**
6845
+ * Ensures default-session data channel token exists after lobby admission.
6846
+ * Some lobby users do not receive a token until they are admitted.
6847
+ * @returns {Promise<boolean>} true when a new token is fetched and cached
6848
+ */
6849
+ private async ensureDefaultDatachannelTokenAfterAdmit(): Promise<boolean> {
6850
+ try {
6851
+ // @ts-ignore
6852
+ const datachannelToken = this.webex.internal.llm.getDatachannelToken(
6853
+ LLM_DEFAULT_SESSION,
6854
+ this.id
6855
+ );
6856
+ // @ts-ignore
6857
+ const isDataChannelTokenEnabled = await this.webex.internal.llm.isDataChannelTokenEnabled();
6858
+
6859
+ if (!isDataChannelTokenEnabled || datachannelToken) {
6860
+ return false;
6861
+ }
6862
+
6863
+ const response = await this.meetingRequest.fetchDatachannelToken({
6864
+ locusUrl: this.locusUrl,
6865
+ requestingParticipantId: this.members.selfId,
6866
+ isPracticeSession: false,
6867
+ });
6868
+ const fetchedDatachannelToken = response?.body?.datachannelToken;
6869
+
6870
+ if (!fetchedDatachannelToken) {
6871
+ return false;
6872
+ }
6873
+
6874
+ // @ts-ignore
6875
+ this.webex.internal.llm.setDatachannelToken(
6876
+ fetchedDatachannelToken,
6877
+ LLM_DEFAULT_SESSION,
6878
+ this.id
6879
+ );
6880
+
6881
+ return true;
6882
+ } catch (error) {
6883
+ const msg = error?.message || String(error);
6884
+
6885
+ LoggerProxy.logger.warn(
6886
+ `Meeting:index#ensureDefaultDatachannelTokenAfterAdmit --> failed to proactively fetch default data channel token after admit: ${msg}`,
6887
+ {statusCode: error?.statusCode}
6888
+ );
6889
+
6890
+ return false;
6891
+ }
6892
+ }
6893
+
6180
6894
  /**
6181
6895
  * Connects to low latency mercury and reconnects if the address has changed
6182
6896
  * It will also disconnect if called when the meeting has ended
6183
- * @param {String} datachannelUrl
6897
+ * @param {Object} [options]
6898
+ * @param {boolean} [options.isInitialJoinPhase] true when called from initial join flow
6184
6899
  * @returns {Promise}
6185
6900
  */
6186
- async updateLLMConnection() {
6901
+ async updateLLMConnection({isInitialJoinPhase = false}: {isInitialJoinPhase?: boolean} = {}) {
6187
6902
  // @ts-ignore - Fix type
6188
- const {url, info: {datachannelUrl, practiceSessionDatachannelUrl} = {}} = this.locusInfo;
6903
+ const {url = undefined, info: {datachannelUrl = undefined} = {}} = this.locusInfo || {};
6189
6904
 
6190
6905
  const isJoined = this.isJoined();
6191
6906
 
6192
- // webinar panelist should use new data channel in practice session
6193
- const dataChannelUrl =
6194
- this.webinar.isJoinPracticeSessionDataChannel() && practiceSessionDatachannelUrl
6195
- ? practiceSessionDatachannelUrl
6196
- : datachannelUrl;
6907
+ const dataChannelUrl = datachannelUrl;
6908
+
6909
+ // Ownership guard: when the default LLM session is already connected and
6910
+ // owned by a *different* Meeting instance, do not disconnect or reconfigure
6911
+ // it. Another meeting's `updateLLMConnection` must be ignored here to
6912
+ // avoid killing the socket it relies on. We only proceed to manage the
6913
+ // connection when this meeting is the current owner, or when no owner is
6914
+ // set yet (first claim).
6915
+ // @ts-ignore - Fix type
6916
+ const {currentOwner} = this.webex.internal.llm.resolveSessionOwnership(
6917
+ this.id,
6918
+ LLM_DEFAULT_SESSION
6919
+ );
6920
+
6921
+ // Capture connectivity before any reconnect attempt. If LLM was already
6922
+ // connected, we must respect current ownership. If it was disconnected,
6923
+ // this flow may reclaim stale owner tags after a fresh connect.
6924
+ // @ts-ignore - Fix type
6925
+ const wasConnected = this.webex.internal.llm.isConnected();
6926
+
6927
+ // Prefer ownership-scoped token read. For disconnected stale-owner reclaim
6928
+ // flows, fallback to ownerless read so initial register can still carry a
6929
+ // token and recover from stale ownership without 401/403 dead-end.
6930
+ // @ts-ignore - Fix type
6931
+ let datachannelToken = this.webex.internal.llm.getDatachannelToken(
6932
+ LLM_DEFAULT_SESSION,
6933
+ this.id
6934
+ );
6935
+
6936
+ if (!datachannelToken && !wasConnected && currentOwner && currentOwner !== this.id) {
6937
+ // @ts-ignore - Fix type
6938
+ datachannelToken = this.webex.internal.llm.getDatachannelToken(LLM_DEFAULT_SESSION);
6939
+ }
6197
6940
 
6198
6941
  // @ts-ignore - Fix type
6199
- if (this.webex.internal.llm.isConnected()) {
6942
+ if (wasConnected) {
6943
+ if (currentOwner && currentOwner !== this.id) {
6944
+ // Another meeting owns the live LLM socket. We must not disconnect
6945
+ // or reconfigure it -- doing so would tear down a session the
6946
+ // owning meeting still relies on. Locus/datachannel URL mismatch is
6947
+ // expected here (each meeting has its own locus URL) and is NOT a
6948
+ // valid signal of staleness, so we never reclaim from this path.
6949
+ // The only safe reclaim mechanism is the `finally`-block owner-tag
6950
+ // release in `cleanupLLMConneciton`, which fires when this meeting
6951
+ // itself is being torn down.
6952
+ LoggerProxy.logger.info(
6953
+ `Meeting:index#updateLLMConnection --> skipping; LLM owned by meeting ${currentOwner}, not ${this.id}`
6954
+ );
6955
+
6956
+ return undefined;
6957
+ }
6958
+
6200
6959
  if (
6201
6960
  // @ts-ignore - Fix type
6202
6961
  url === this.webex.internal.llm.getLocusUrl() &&
@@ -6206,31 +6965,63 @@ export default class Meeting extends StatelessWebexPlugin {
6206
6965
  ) {
6207
6966
  return undefined;
6208
6967
  }
6209
- // @ts-ignore - Fix type
6210
- await this.webex.internal.llm.disconnectLLM(
6211
- isJoined
6212
- ? {
6213
- code: 3050,
6214
- reason: 'done (permanent)',
6215
- }
6216
- : undefined
6217
- );
6218
- // @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.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6222
-
6223
- this.clearLLMHealthCheckTimer();
6968
+ await this.cleanupLLMConneciton({removeOnlineListener: false});
6224
6969
  }
6225
6970
 
6226
6971
  if (!isJoined) {
6227
6972
  return undefined;
6228
6973
  }
6229
6974
 
6975
+ // Bind refresh handler before registration so interceptor-triggered token
6976
+ // refresh during register POST can resolve a valid handler.
6977
+ // Prefer this meeting as owner, but allow owner-less fallback when a stale
6978
+ // foreign owner tag is present on a disconnected session.
6979
+ const refreshHandlerOwnerMeetingId =
6980
+ currentOwner && currentOwner !== this.id ? undefined : this.id;
6981
+ const shouldAlignRefreshHandlerAfterOwnershipClaim = refreshHandlerOwnerMeetingId !== this.id;
6982
+ // @ts-ignore - Fix type
6983
+ this.webex.internal.llm.setRefreshHandler(
6984
+ () => this.refreshDataChannelToken(),
6985
+ LLM_DEFAULT_SESSION,
6986
+ refreshHandlerOwnerMeetingId
6987
+ );
6988
+
6230
6989
  // @ts-ignore - Fix type
6231
6990
  return this.webex.internal.llm
6232
- .registerAndConnect(url, dataChannelUrl)
6991
+ .registerAndConnect(url, dataChannelUrl, datachannelToken)
6233
6992
  .then((registerAndConnectResult) => {
6993
+ this.locusInfo.syncAllHashTreeDatasets({onlyLLM: true});
6994
+ // Record ownership of the default LLM session for this meeting so
6995
+ // subsequent cross-meeting `updateLLMConnection` / `cleanupLLMConneciton`
6996
+ // calls can detect and skip work that doesn't belong to them.
6997
+ // @ts-ignore - Fix type
6998
+ const {isOwner} = this.webex.internal.llm.resolveSessionOwnership(
6999
+ this.id,
7000
+ LLM_DEFAULT_SESSION
7001
+ );
7002
+ const canReclaimAfterDisconnectedStart = !wasConnected;
7003
+
7004
+ // Refresh handler is pre-bound before registerAndConnect so token
7005
+ // refresh can work even during the registration request itself.
7006
+ if (isOwner || canReclaimAfterDisconnectedStart) {
7007
+ // Record ownership of the default LLM session for this meeting so
7008
+ // subsequent cross-meeting `updateLLMConnection` / `cleanupLLMConneciton`
7009
+ // calls can detect and skip work that doesn't belong to them.
7010
+ // @ts-ignore - Fix type
7011
+ this.webex.internal.llm.setOwnerMeetingId?.(this.id);
7012
+
7013
+ // If we pre-bound refresh ownerlessly (stale-owner reclaim path),
7014
+ // align the handler with the newly claimed owner immediately after
7015
+ // ownership is updated.
7016
+ if (shouldAlignRefreshHandlerAfterOwnershipClaim) {
7017
+ // @ts-ignore - Fix type
7018
+ this.webex.internal.llm.setRefreshHandler(
7019
+ () => this.refreshDataChannelToken(),
7020
+ LLM_DEFAULT_SESSION,
7021
+ this.id
7022
+ );
7023
+ }
7024
+ }
6234
7025
  // @ts-ignore - Fix type
6235
7026
  this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6236
7027
  // @ts-ignore - Fix type
@@ -6245,10 +7036,114 @@ export default class Meeting extends StatelessWebexPlugin {
6245
7036
 
6246
7037
  this.startLLMHealthCheckTimer();
6247
7038
 
7039
+ if (registerAndConnectResult) {
7040
+ if (isInitialJoinPhase) {
7041
+ this.sendLLMConnectMetric(registerAndConnectResult);
7042
+ }
7043
+
7044
+ this.breakouts?.trigger(BREAKOUTS.EVENTS.LLM_CONNECT_RESPONSE, {
7045
+ meeting: this,
7046
+ llmLatency: registerAndConnectResult,
7047
+ });
7048
+ }
7049
+
6248
7050
  return Promise.resolve(registerAndConnectResult);
7051
+ })
7052
+ .catch((error) => {
7053
+ // Prefer the partial timing registerAndConnect attaches when register succeeded but the
7054
+ // websocket connect() failed, so a ws failure isn't misreported as register never completing.
7055
+ const llmLatency = {
7056
+ clientLLMDatachannelResponseTime: error?.timing?.clientLLMDatachannelResponseTime ?? 0,
7057
+ clientLLMWebSocketConnectTime: 0,
7058
+ };
7059
+
7060
+ if (isInitialJoinPhase) {
7061
+ this.sendLLMConnectMetric(llmLatency, error);
7062
+ }
7063
+
7064
+ this.breakouts?.trigger(BREAKOUTS.EVENTS.LLM_CONNECT_RESPONSE, {
7065
+ meeting: this,
7066
+ llmLatency,
7067
+ error,
7068
+ });
7069
+
7070
+ return Promise.reject(error);
6249
7071
  });
6250
7072
  }
6251
7073
 
7074
+ /**
7075
+ * Ensures breakout join response metric with LLM latency is emitted only once per breakout move id.
7076
+ * @param {string | undefined} breakoutMoveId
7077
+ * @param {boolean} [hasLLMLatency=false]
7078
+ * @returns {boolean}
7079
+ */
7080
+ private shouldEmitBreakoutJoinResponseMetric(
7081
+ breakoutMoveId?: string,
7082
+ hasLLMLatency = false
7083
+ ): boolean {
7084
+ if (!breakoutMoveId) {
7085
+ return false;
7086
+ }
7087
+
7088
+ if (!hasLLMLatency) {
7089
+ // When automatic LLM is enabled, updateLLMConnection will emit this same breakout join
7090
+ // response after the LLM connection finishes, including llmLatency and llmWebsocketUrl.
7091
+ // Suppress the earlier non-LLM event to avoid sending two events for the same move id,
7092
+ // where the first one would be missing the LLM-specific fields we want to validate.
7093
+ // @ts-ignore - config coming from registerPlugin
7094
+ return !this.config.enableAutomaticLLM;
7095
+ }
7096
+
7097
+ if (this.emittedBreakoutJoinResponseMoveIds.has(breakoutMoveId)) {
7098
+ return false;
7099
+ }
7100
+
7101
+ this.emittedBreakoutJoinResponseMoveIds.add(breakoutMoveId);
7102
+
7103
+ return true;
7104
+ }
7105
+
7106
+ /**
7107
+ * Sends LLM connect latencies for initial join flow.
7108
+ * @param {RegisterAndConnectTiming} timings
7109
+ * @param {any} [error]
7110
+ * @returns {void}
7111
+ */
7112
+ private sendLLMConnectMetric(timings: RegisterAndConnectTiming, error?: any) {
7113
+ // @ts-ignore
7114
+ const llmWebsocketUrl = this.webex.internal.llm.getWebSocketUrl?.() || undefined;
7115
+ const {clientLLMDatachannelResponseTime = 0, clientLLMWebSocketConnectTime} = timings || {};
7116
+
7117
+ const llmLatency: any = {
7118
+ clientLLMDatachannelResponseTime,
7119
+ };
7120
+
7121
+ if (clientLLMWebSocketConnectTime !== undefined) {
7122
+ llmLatency.clientLLMWebSocketConnectTime = clientLLMWebSocketConnectTime;
7123
+ }
7124
+
7125
+ const payload: any = {
7126
+ identifiers: {
7127
+ llmWebsocketUrl,
7128
+ },
7129
+ llmLatency,
7130
+ };
7131
+
7132
+ const options: any = {
7133
+ meetingId: this.id,
7134
+ ...(error && {rawError: error}),
7135
+ };
7136
+
7137
+ const metricEvent = {
7138
+ name: 'client.llm.connect.response',
7139
+ payload,
7140
+ options,
7141
+ };
7142
+
7143
+ // @ts-ignore
7144
+ this.webex.internal.newMetrics.submitClientEvent(metricEvent);
7145
+ }
7146
+
6252
7147
  /**
6253
7148
  * Use phone for meeting audio
6254
7149
  * @param {String} phoneNumber If provided, it will dial-out using this number. If not provided, dial-in will be used
@@ -6676,16 +7571,32 @@ export default class Meeting extends StatelessWebexPlugin {
6676
7571
  // @ts-ignore
6677
7572
  const cdl = this.webex.internal.newMetrics.callDiagnosticLatencies;
6678
7573
 
7574
+ // Compute the offer->answer latency from when the local SDP offer was generated up to now,
7575
+ // rather than from the stored remote-sdp-received timestamp. That stored timestamp uses
7576
+ // saveFirstTimestampOnly, so if waitForRemoteSDPAnswer() already timed out and submitted a
7577
+ // remote-sdp-received event, the stored value would be pinned to the timeout time and would
7578
+ // under-report an answer that arrives late. This handler fires exactly when the answer is
7579
+ // processed, so Date.now() is the accurate "received" time.
7580
+ // (submitClientEvent below still records the remote-sdp-received timestamp used by the CA
7581
+ // join-time metric, so we don't need to save it here.)
7582
+ const localSdpGeneratedTimestamp = cdl.latencyTimestamps.get(
7583
+ 'client.media-engine.local-sdp-generated'
7584
+ );
7585
+ const localSDPGenRemoteSDPRecv =
7586
+ localSdpGeneratedTimestamp !== undefined
7587
+ ? Date.now() - localSdpGeneratedTimestamp
7588
+ : undefined;
7589
+
6679
7590
  // @ts-ignore
6680
7591
  this.webex.internal.newMetrics.submitClientEvent({
6681
7592
  name: 'client.media-engine.remote-sdp-received',
7593
+ payload: {
7594
+ eventData: {
7595
+ localSDPGenRemoteSDPRecv,
7596
+ },
7597
+ },
6682
7598
  options: {meetingId: this.id},
6683
7599
  });
6684
- Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.ROAP_OFFER_TO_ANSWER_LATENCY, {
6685
- correlation_id: this.correlationId,
6686
- latency: cdl.getLocalSDPGenRemoteSDPRecv(),
6687
- meetingId: this.id,
6688
- });
6689
7600
 
6690
7601
  if (this.deferSDPAnswer) {
6691
7602
  this.deferSDPAnswer.resolve();
@@ -7271,23 +8182,104 @@ export default class Meeting extends StatelessWebexPlugin {
7271
8182
  }
7272
8183
  }
7273
8184
  });
8185
+ this.statsAnalyzer.on(StatsAnalyzerEventNames.STATS_UPDATE, (data) => {
8186
+ // Extract srtpCipher from transport stats
8187
+ let srtpCipher: string | undefined;
8188
+ for (const stats of data.stats.values()) {
8189
+ if (stats.type === 'transport' && stats.srtpCipher) {
8190
+ srtpCipher = stats.srtpCipher as string;
8191
+ break;
8192
+ }
8193
+ }
8194
+
8195
+ // Only emit event if srtpCipher has changed
8196
+ if (srtpCipher && srtpCipher !== this.mediaProperties.srtpCipher) {
8197
+ LoggerProxy.logger.info(
8198
+ `Meeting:index#setupStatsAnalyzerEventHandlers --> SRTP cipher changed from ${this.mediaProperties.srtpCipher} to ${srtpCipher}`
8199
+ );
8200
+ this.mediaProperties.srtpCipher = srtpCipher;
8201
+ Trigger.trigger(
8202
+ this,
8203
+ {
8204
+ file: 'meeting/index',
8205
+ function: 'setupStatsAnalyzerEventHandlers',
8206
+ },
8207
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
8208
+ {srtpCipher}
8209
+ );
8210
+ }
8211
+ });
7274
8212
  };
7275
8213
 
7276
8214
  getMediaConnectionDebugId() {
7277
8215
  return `MC-${this.id.substring(0, 4)}`;
7278
8216
  }
7279
8217
 
8218
+ /**
8219
+ * Checks if the error indicates that Locus dropped us from the meeting,
8220
+ * either directly on the error or wrapped inside an AddMediaFailed cause.
8221
+ * This method is meant to be called only with errors thrown by Meeting.addMediaInternal()
8222
+ *
8223
+ * @param {Error} error
8224
+ * @returns {boolean}
8225
+ */
8226
+ private isErrorMeaningLocusDroppedUs(error: Error | undefined): boolean {
8227
+ const statusCode = (error as any)?.statusCode;
8228
+ const causeStatusCode = (error as any)?.cause?.statusCode;
8229
+
8230
+ return (
8231
+ statusCode === 409 || statusCode === 403 || causeStatusCode === 409 || causeStatusCode === 403
8232
+ );
8233
+ }
8234
+
8235
+ /**
8236
+ * Determines if the next media attempt should use only TURN-TLS (iceTransportPolicy='relay').
8237
+ * We do this in the hope that it will minimize the chance of Homer sending DTLS packets on a wrong
8238
+ * transport (as there will be only 1 transport) and dealing with firewalls that let STUN packets through, but block
8239
+ * other UDP traffic.
8240
+ *
8241
+ * For clients landing on video mesh nodes (VMN), reachability might still have successful TLS (to public nodes)
8242
+ * but TURN discovery will result in empty TURN urls array and iceTransportPolicy='relay' will still be overriden to undefined,
8243
+ * see the code in establishMediaConnection()
8244
+ *
8245
+ * @param {Error} prevError - The error from the previous addMedia attempt
8246
+ * @returns {Promise<boolean>}
8247
+ */
8248
+ private async shouldRetryMediaWithOnlyTurnTLS(prevError: Error | undefined): Promise<boolean> {
8249
+ if (
8250
+ this.isMultistream &&
8251
+ prevError instanceof AddMediaFailed &&
8252
+ prevError.isDtlsHandshakeFailure &&
8253
+ prevError.connectionType === 'UDP'
8254
+ ) {
8255
+ const hasTlsReachability =
8256
+ // @ts-ignore
8257
+ await this.webex.meetings.reachability.isAnyClusterReachableViaProtocol('xtls');
8258
+
8259
+ if (hasTlsReachability) {
8260
+ LoggerProxy.logger.info(
8261
+ 'Meeting:index#shouldRetryMediaWithOnlyTurnTLS --> previous attempt failed due to DTLS handshake failure over UDP and TLS reachability is available'
8262
+ );
8263
+
8264
+ return true;
8265
+ }
8266
+ }
8267
+
8268
+ return false;
8269
+ }
8270
+
7280
8271
  /**
7281
8272
  * Creates a webrtc media connection and publishes streams to it
7282
8273
  *
7283
8274
  * @param {Object} turnServerInfo TURN server information
7284
8275
  * @param {BundlePolicy} [bundlePolicy] Bundle policy settings
7285
- * @param {AddMediaOptions} [options] Options for enabling/disabling audio/video
8276
+ * @param {RTCIceTransportPolicy} [iceTransportPolicy] ICE transport policy override
7286
8277
  * @returns {RoapMediaConnection | MultistreamRoapMediaConnection}
7287
8278
  */
7288
8279
  private async createMediaConnection(
7289
8280
  turnServerInfo?: TurnServerInfo,
7290
- bundlePolicy?: BundlePolicy
8281
+ bundlePolicy?: BundlePolicy,
8282
+ iceTransportPolicy?: RTCIceTransportPolicy
7291
8283
  ) {
7292
8284
  this.rtcMetrics = this.isMultistream
7293
8285
  ? // @ts-ignore
@@ -7311,12 +8303,15 @@ export default class Meeting extends StatelessWebexPlugin {
7311
8303
  enableExtmap: this.config.enableExtmap,
7312
8304
  turnServerInfo,
7313
8305
  bundlePolicy,
8306
+ iceTransportPolicy,
7314
8307
  // @ts-ignore - config coming from registerPlugin
7315
8308
  iceCandidatesTimeout: this.config.iceCandidatesGatheringTimeout,
7316
8309
  // @ts-ignore - config coming from registerPlugin
7317
8310
  disableAudioMainDtx: this.config.experimental.disableAudioMainDtx,
7318
8311
  // @ts-ignore - config coming from registerPlugin
7319
8312
  enableAudioTwcc: this.config.enableAudioTwccForMultistream,
8313
+ // @ts-ignore - config coming from registerPlugin
8314
+ enableAv1SlidesSupport: this.config.enableAv1SlidesSupport,
7320
8315
  stopIceGatheringAfterFirstRelayCandidate:
7321
8316
  // @ts-ignore - config coming from registerPlugin
7322
8317
  this.config.stopIceGatheringAfterFirstRelayCandidate,
@@ -7336,6 +8331,7 @@ export default class Meeting extends StatelessWebexPlugin {
7336
8331
  this.mediaProperties.mediaDirection.receiveShare,
7337
8332
  ];
7338
8333
 
8334
+ this.sendSlotManager.reset();
7339
8335
  this.sendSlotManager.createSlot(mc, MediaType.VideoMain, videoEnabled);
7340
8336
  this.sendSlotManager.createSlot(mc, MediaType.AudioMain, audioEnabled);
7341
8337
  this.sendSlotManager.createSlot(mc, MediaType.VideoSlides, shareEnabled);
@@ -7433,9 +8429,9 @@ export default class Meeting extends StatelessWebexPlugin {
7433
8429
  */
7434
8430
  private async waitForMediaConnectionConnected(): Promise<void> {
7435
8431
  try {
7436
- await this.mediaProperties.waitForMediaConnectionConnected();
8432
+ await this.mediaProperties.waitForMediaConnectionConnected(this.correlationId);
7437
8433
  } catch (error) {
7438
- const {iceConnected} = error;
8434
+ const {iceConnected} = error as MediaConnectionAwaiterFailureResult;
7439
8435
 
7440
8436
  if (!this.hasMediaConnectionConnectedAtLeastOnce) {
7441
8437
  // Only send CA event for join flow if we haven't successfully connected media yet
@@ -7475,13 +8471,12 @@ export default class Meeting extends StatelessWebexPlugin {
7475
8471
  });
7476
8472
  }
7477
8473
 
7478
- const timedOutError = new Error(
7479
- `Timed out waiting for media connection to be connected, correlationId=${this.correlationId}`
8474
+ throw new MediaConnectionTimedOutError(
8475
+ `Timed out waiting for media connection to be connected, correlationId=${this.correlationId}`,
8476
+ iceConnected,
8477
+ // keep reference to the original rejected result (which is the object the SDK reports to CA as rawError above)
8478
+ error
7480
8479
  );
7481
-
7482
- timedOutError.cause = error;
7483
-
7484
- throw timedOutError;
7485
8480
  }
7486
8481
  }
7487
8482
 
@@ -7527,12 +8522,12 @@ export default class Meeting extends StatelessWebexPlugin {
7527
8522
  return !member.isSelf && !member.isPairedWithSelf && !member.isAudioMuted;
7528
8523
  });
7529
8524
 
7530
- if (atLeastOneUnmutedOtherMember) {
7531
- this.mediaProperties.sendMediaIssueMetric(
7532
- 'inbound_audio',
7533
- data.issueSubType,
7534
- this.correlationId
7535
- );
8525
+ // we also ignore any issues while we're waiting in the lobby, as we're not receiving any audio yet
8526
+ if (atLeastOneUnmutedOtherMember && !this.isUserUnadmitted) {
8527
+ this.mediaProperties.sendMediaIssueMetric('inbound_audio', data.issueSubType, {
8528
+ correlationId: this.correlationId,
8529
+ isMultistream: this.isMultistream,
8530
+ });
7536
8531
 
7537
8532
  Trigger.trigger(
7538
8533
  this,
@@ -7694,7 +8689,18 @@ export default class Meeting extends StatelessWebexPlugin {
7694
8689
  error
7695
8690
  );
7696
8691
 
7697
- throw new AddMediaFailed(error);
8692
+ const {connectionType, selectedCandidatePairChanges, numTransports} =
8693
+ await this.mediaProperties.getCurrentConnectionInfo();
8694
+
8695
+ const iceConnected = error instanceof MediaConnectionTimedOutError && error.iceConnected;
8696
+
8697
+ throw new AddMediaFailed({
8698
+ cause: error,
8699
+ connectionType,
8700
+ selectedCandidatePairChanges,
8701
+ numTransports,
8702
+ iceConnected,
8703
+ });
7698
8704
  }
7699
8705
  }
7700
8706
 
@@ -7769,7 +8775,21 @@ export default class Meeting extends StatelessWebexPlugin {
7769
8775
  ({turnServerInfo} = await this.doTurnDiscovery(isReconnecting, isForced));
7770
8776
  }
7771
8777
 
7772
- const mc = await this.createMediaConnection(turnServerInfo, bundlePolicy);
8778
+ if (
8779
+ (!turnServerInfo || !turnServerInfo.urls?.length) &&
8780
+ this.addMediaData.iceTransportPolicy === 'relay'
8781
+ ) {
8782
+ LoggerProxy.logger.info(
8783
+ `${LOG_HEADER} cannot do iceTransportPolicy=relay, because there is no turn server info available`
8784
+ );
8785
+ // drop the forced relay policy and use the default, because we don't have a TURN server
8786
+ this.addMediaData.iceTransportPolicy = undefined;
8787
+ }
8788
+ const mediaConnection = await this.createMediaConnection(
8789
+ turnServerInfo,
8790
+ bundlePolicy,
8791
+ this.addMediaData.iceTransportPolicy
8792
+ );
7773
8793
 
7774
8794
  LoggerProxy.logger.info(
7775
8795
  `${LOG_HEADER} media connection created this.isMultistream=${this.isMultistream}`
@@ -7806,7 +8826,7 @@ export default class Meeting extends StatelessWebexPlugin {
7806
8826
  await this.remoteMediaManager.start();
7807
8827
  }
7808
8828
 
7809
- await mc.initiateOffer();
8829
+ await mediaConnection.initiateOffer();
7810
8830
 
7811
8831
  await this.waitForRemoteSDPAnswer();
7812
8832
 
@@ -7874,6 +8894,9 @@ export default class Meeting extends StatelessWebexPlugin {
7874
8894
 
7875
8895
  this.isMultistream = false;
7876
8896
 
8897
+ // reset iceTransportPolicy, because it's only applied for multistream media connections
8898
+ this.addMediaData.iceTransportPolicy = undefined;
8899
+
7877
8900
  if (this.mediaProperties.webrtcMediaConnection) {
7878
8901
  // close peer connection, but don't reset mute state information, because we will want to use it on the retry
7879
8902
  this.closePeerConnections(false);
@@ -7954,6 +8977,8 @@ export default class Meeting extends StatelessWebexPlugin {
7954
8977
  regionCode: this.webex.meetings.geoHintInfo?.regionCode,
7955
8978
  },
7956
8979
  preferTranscoding: !this.isMultistream,
8980
+ getCurrentSelfUrl: () => this.selfUrl,
8981
+ waitForSelfUrlChange: () => this.waitForSelfUrlChange(),
7957
8982
  },
7958
8983
  {
7959
8984
  // @ts-ignore
@@ -7962,6 +8987,41 @@ export default class Meeting extends StatelessWebexPlugin {
7962
8987
  );
7963
8988
  }
7964
8989
 
8990
+ /**
8991
+ * Waits for LocusInfo to update meeting.selfUrl, with a timeout fallback.
8992
+ * @returns {Promise<void>}
8993
+ * @private
8994
+ * @memberof Meeting
8995
+ */
8996
+ private waitForSelfUrlChange(): Promise<void> {
8997
+ if (this.joinWithMediaRetryInfo.retryCount > 0) {
8998
+ /* During joinWithMedia() retries we can get 403/409 from Locus and it doesn't mean
8999
+ * that the selfUrl will change, it is usually caused by Locus dropping us as a result of
9000
+ * media connection failure during joinWithMedia's earlier media connection attempt,
9001
+ * so we don't want to wait for selfUrl change as this would only slow down the join process. */
9002
+ LoggerProxy.logger.info(
9003
+ 'Meeting:index#waitForSelfUrlChange --> joinWithMedia retry in progress, will not wait for selfUrl change'
9004
+ );
9005
+
9006
+ return Promise.resolve();
9007
+ }
9008
+
9009
+ if (!this.promisesWaitingForPropUpdate.selfUrl) {
9010
+ const pendingSelfUrlUpdate = new Defer();
9011
+
9012
+ this.promisesWaitingForPropUpdate.selfUrl = pendingSelfUrlUpdate;
9013
+
9014
+ setTimeout(() => {
9015
+ if (this.promisesWaitingForPropUpdate.selfUrl === pendingSelfUrlUpdate) {
9016
+ delete this.promisesWaitingForPropUpdate.selfUrl;
9017
+ pendingSelfUrlUpdate.resolve();
9018
+ }
9019
+ }, 5000);
9020
+ }
9021
+
9022
+ return this.promisesWaitingForPropUpdate.selfUrl.promise;
9023
+ }
9024
+
7965
9025
  /**
7966
9026
  * Creates a media connection to the server. Media connection is required for sending or receiving any audio/video.
7967
9027
  *
@@ -7973,8 +9033,9 @@ export default class Meeting extends StatelessWebexPlugin {
7973
9033
  addMedia(options: AddMediaOptions = {}): Promise<void> {
7974
9034
  return this.addMediaInternal(
7975
9035
  () => (this.turnServerUsed ? 'JOIN_MEETING_FINAL' : 'JOIN_MEETING_RETRY'),
7976
- undefined,
7977
9036
  false,
9037
+ undefined /* turnServerInfo - it will be fetched via doTurnDiscovery() */,
9038
+ undefined /* iceTransportPolicy - we're relying on the default value */,
7978
9039
  options
7979
9040
  );
7980
9041
  }
@@ -7983,8 +9044,9 @@ export default class Meeting extends StatelessWebexPlugin {
7983
9044
  * Internal version of addMedia() with some more arguments for finer control of its behavior
7984
9045
  *
7985
9046
  * @param {Function} icePhaseCallback - callback to determine the icePhase for CA "client.ice.end" failure events
7986
- * @param {TurnServerInfo} turnServerInfo - TURN server information
7987
9047
  * @param {boolean} forceTurnDiscovery - if true, TURN discovery will be done
9048
+ * @param {TurnServerInfo} turnServerInfo - TURN server information
9049
+ * @param {RTCIceTransportPolicy} [iceTransportPolicy] - ICE transport policy override
7988
9050
  * @param {AddMediaOptions} options - same as options of the public addMedia() method
7989
9051
  * @returns {Promise<void>}
7990
9052
  * @protected
@@ -7992,12 +9054,14 @@ export default class Meeting extends StatelessWebexPlugin {
7992
9054
  */
7993
9055
  protected async addMediaInternal(
7994
9056
  icePhaseCallback: () => string,
7995
- turnServerInfo: TurnServerInfo,
7996
- forceTurnDiscovery,
9057
+ forceTurnDiscovery: boolean,
9058
+ turnServerInfo?: TurnServerInfo,
9059
+ iceTransportPolicy?: RTCIceTransportPolicy,
7997
9060
  options: AddMediaOptions = {}
7998
9061
  ): Promise<void> {
7999
9062
  this.addMediaData.retriedWithTurnServer = false;
8000
9063
  this.addMediaData.icePhaseCallback = icePhaseCallback;
9064
+ this.addMediaData.iceTransportPolicy = iceTransportPolicy;
8001
9065
 
8002
9066
  this.hasMediaConnectionConnectedAtLeastOnce = false;
8003
9067
  const LOG_HEADER = 'Meeting:index#addMedia -->';
@@ -8006,7 +9070,7 @@ export default class Meeting extends StatelessWebexPlugin {
8006
9070
  options
8007
9071
  )}, turnServerInfo=${JSON.stringify(
8008
9072
  turnServerInfo
8009
- )}, forceTurnDiscovery=${forceTurnDiscovery}`
9073
+ )}, forceTurnDiscovery=${forceTurnDiscovery}, iceTransportPolicy=${iceTransportPolicy}`
8010
9074
  );
8011
9075
 
8012
9076
  if (options.allowMediaInLobby !== true && this.meetingState !== FULL_STATE.ACTIVE) {
@@ -8026,6 +9090,7 @@ export default class Meeting extends StatelessWebexPlugin {
8026
9090
  remoteMediaManagerConfig,
8027
9091
  bundlePolicy = 'max-bundle',
8028
9092
  additionalMediaOptions = {},
9093
+ allowPublishMediaInLobby = false,
8029
9094
  } = options;
8030
9095
 
8031
9096
  const {
@@ -8046,7 +9111,6 @@ export default class Meeting extends StatelessWebexPlugin {
8046
9111
  const ipver = MeetingUtil.getIpVersion(this.webex); // used just for metrics
8047
9112
 
8048
9113
  // If the user is unjoined or guest waiting in lobby dont allow the user to addMedia
8049
- // @ts-ignore - isUserUnadmitted coming from SelfUtil
8050
9114
  if (this.isUserUnadmitted && !this.wirelessShare && !this.allowMediaInLobby) {
8051
9115
  throw new UserInLobbyError();
8052
9116
  }
@@ -8091,7 +9155,13 @@ export default class Meeting extends StatelessWebexPlugin {
8091
9155
  this.brbState = createBrbState(this, false);
8092
9156
 
8093
9157
  try {
8094
- await this.setUpLocalStreamReferences(localStreams);
9158
+ // if we're in a lobby and allowPublishMediaInLobby==false, we don't want to
9159
+ // setup local streams for publishing, because if we ever end up admitted to the meeting
9160
+ // but Locus event about it for us is delayed or missed, others could see/hear our user's video/audio
9161
+ // while the user would still think they're in the lobby
9162
+ if (allowPublishMediaInLobby || !this.isUserUnadmitted) {
9163
+ await this.setUpLocalStreamReferences(localStreams);
9164
+ }
8095
9165
 
8096
9166
  this.setMercuryListener();
8097
9167
 
@@ -8114,12 +9184,7 @@ export default class Meeting extends StatelessWebexPlugin {
8114
9184
 
8115
9185
  // Establish new media connection with forced TURN discovery
8116
9186
  // 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
8117
- await this.establishMediaConnection(
8118
- remoteMediaManagerConfig,
8119
- bundlePolicy,
8120
- true,
8121
- undefined
8122
- );
9187
+ await this.establishMediaConnection(remoteMediaManagerConfig, bundlePolicy, true);
8123
9188
  } else {
8124
9189
  throw error;
8125
9190
  }
@@ -8148,7 +9213,8 @@ export default class Meeting extends StatelessWebexPlugin {
8148
9213
  numTransports,
8149
9214
  isMultistream: this.isMultistream,
8150
9215
  retriedWithTurnServer: this.addMediaData.retriedWithTurnServer,
8151
- isJoinWithMediaRetry: this.joinWithMediaRetryInfo.isRetry,
9216
+ isJoinWithMediaRetry: this.joinWithMediaRetryInfo.retryCount > 0,
9217
+ iceTransportPolicy: this.addMediaData.iceTransportPolicy || 'all',
8152
9218
  ...reachabilityMetrics,
8153
9219
  ...iceCandidateErrors,
8154
9220
  iceCandidatesCount: this.iceCandidatesCount,
@@ -8170,14 +9236,16 @@ export default class Meeting extends StatelessWebexPlugin {
8170
9236
  // We can log ReceiveSlot SSRCs only after the SDP exchange, so doing it here:
8171
9237
  this.remoteMediaManager?.logAllReceiveSlots();
8172
9238
  this.startPeriodicLogUpload();
8173
- } catch (error) {
9239
+ } catch (error: any) {
8174
9240
  LoggerProxy.logger.error(`${LOG_HEADER} failed to establish media connection: `, error);
8175
9241
 
8176
9242
  // @ts-ignore
8177
9243
  const reachabilityMetrics = await this.getMediaReachabilityMetricFields();
8178
9244
 
8179
- const {selectedCandidatePairChanges, numTransports} =
8180
- await this.mediaProperties.getCurrentConnectionInfo();
9245
+ const {connectionType, selectedCandidatePairChanges, numTransports} =
9246
+ error instanceof AddMediaFailed
9247
+ ? error
9248
+ : await this.mediaProperties.getCurrentConnectionInfo();
8181
9249
 
8182
9250
  const iceCandidateErrors = Object.fromEntries(this.iceCandidateErrors);
8183
9251
 
@@ -8193,7 +9261,8 @@ export default class Meeting extends StatelessWebexPlugin {
8193
9261
  turnServerUsed: this.turnServerUsed,
8194
9262
  retriedWithTurnServer: this.addMediaData.retriedWithTurnServer,
8195
9263
  isMultistream: this.isMultistream,
8196
- isJoinWithMediaRetry: this.joinWithMediaRetryInfo.isRetry,
9264
+ isJoinWithMediaRetry: this.joinWithMediaRetryInfo.retryCount > 0,
9265
+ iceTransportPolicy: this.addMediaData.iceTransportPolicy || 'all',
8197
9266
  signalingState:
8198
9267
  this.mediaProperties.webrtcMediaConnection?.multistreamConnection?.pc?.pc
8199
9268
  ?.signalingState ||
@@ -8209,6 +9278,7 @@ export default class Meeting extends StatelessWebexPlugin {
8209
9278
  ?.iceConnectionState ||
8210
9279
  this.mediaProperties.webrtcMediaConnection?.mediaConnection?.pc?.iceConnectionState ||
8211
9280
  'unknown',
9281
+ connectionType,
8212
9282
  ...reachabilityMetrics,
8213
9283
  ...iceCandidateErrors,
8214
9284
  iceCandidatesCount: this.iceCandidatesCount,
@@ -8557,14 +9627,15 @@ export default class Meeting extends StatelessWebexPlugin {
8557
9627
  options: {meetingId: this.id},
8558
9628
  });
8559
9629
  LoggerProxy.logger.log('Meeting:index#leave --> Leaving a meeting');
9630
+ this.stopListeningForMeetingEvents();
8560
9631
 
8561
9632
  return MeetingUtil.leaveMeeting(this, options)
8562
- .then((leave) => {
9633
+ .then(async (leave) => {
8563
9634
  // CA team recommends submitting this *after* locus /leave
8564
9635
  submitLeaveMetric();
8565
9636
 
8566
9637
  this.meetingFiniteStateMachine.leave();
8567
- this.clearMeetingData();
9638
+ await this.clearMeetingData();
8568
9639
 
8569
9640
  // upload logs on leave irrespective of meeting delete
8570
9641
  Trigger.trigger(
@@ -9422,11 +10493,13 @@ export default class Meeting extends StatelessWebexPlugin {
9422
10493
  locus_id: this.locusId,
9423
10494
  });
9424
10495
 
10496
+ this.stopListeningForMeetingEvents();
10497
+
9425
10498
  return MeetingUtil.endMeetingForAll(this)
9426
- .then((end) => {
10499
+ .then(async (end) => {
9427
10500
  this.meetingFiniteStateMachine.end();
9428
10501
 
9429
- this.clearMeetingData();
10502
+ await this.clearMeetingData();
9430
10503
  // upload logs on leave irrespective of meeting delete
9431
10504
  Trigger.trigger(
9432
10505
  this,
@@ -9474,7 +10547,7 @@ export default class Meeting extends StatelessWebexPlugin {
9474
10547
  * @public
9475
10548
  * @memberof Meeting
9476
10549
  */
9477
- clearMeetingData = () => {
10550
+ clearMeetingData = async () => {
9478
10551
  this.audio = null;
9479
10552
  this.video = null;
9480
10553
  this.screenShareFloorState = ScreenShareFloorStatus.RELEASED;
@@ -9483,19 +10556,16 @@ export default class Meeting extends StatelessWebexPlugin {
9483
10556
  }
9484
10557
  this.queuedMediaUpdates = [];
9485
10558
 
9486
- if (this.transcription) {
9487
- this.stopTranscription();
9488
- this.transcription = undefined;
9489
- }
9490
-
9491
- this.annotation.deregisterEvents();
9492
-
9493
- // @ts-ignore - fix types
9494
- this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
9495
- // @ts-ignore - Fix type
9496
- this.webex.internal.llm.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
10559
+ // Listener teardown (transcription, annotation, llm/mercury) runs in
10560
+ // stopListeningForMeetingEvents() before /leave and /end so events
10561
+ // received mid-teardown do not trigger Locus syncs. Calling it here
10562
+ // again would double-emit MEETING_STOPPED_RECEIVING_TRANSCRIPTION
10563
+ // because stopTranscription() always fires its trigger.
10564
+ //
10565
+ // Ownership-aware token clear is encapsulated inside clearDataChannelToken().
10566
+ this.clearDataChannelToken();
9497
10567
 
9498
- this.clearLLMHealthCheckTimer();
10568
+ await this.cleanupLLMConneciton({throwOnError: false});
9499
10569
  };
9500
10570
 
9501
10571
  /**
@@ -9571,15 +10641,12 @@ export default class Meeting extends StatelessWebexPlugin {
9571
10641
  * @public
9572
10642
  * @memberof Meeting
9573
10643
  */
9574
- public sendReaction(reactionType: ReactionServerType, skinToneType?: SkinToneType) {
10644
+ public sendReaction(reactionType: string, skinToneType?: SkinToneType) {
9575
10645
  const reactionChannelUrl = this.locusInfo?.controls?.reactions?.reactionChannelUrl as string;
9576
10646
  const participantId = this.members.selfId;
9577
10647
 
9578
- const reactionData = Reactions[reactionType];
10648
+ const reactionData = Reactions[reactionType] || {type: reactionType};
9579
10649
 
9580
- if (!reactionData) {
9581
- return Promise.reject(new Error(`${reactionType} is not a valid reaction.`));
9582
- }
9583
10650
  const skinToneData = SkinTones[skinToneType] || SkinTones.normal;
9584
10651
  const reaction: Reaction = {
9585
10652
  ...reactionData,
@@ -9688,15 +10755,20 @@ export default class Meeting extends StatelessWebexPlugin {
9688
10755
  }
9689
10756
 
9690
10757
  if (shouldEnableMusicMode) {
9691
- await this.sendSlotManager.setCodecParameters(MediaType.AudioMain, {
9692
- maxaveragebitrate: '64000',
9693
- maxplaybackrate: '48000',
9694
- });
10758
+ await this.sendSlotManager.setCustomCodecParameters(
10759
+ MediaType.AudioMain,
10760
+ MediaCodecMimeType.OPUS,
10761
+ {
10762
+ maxaveragebitrate: '64000',
10763
+ maxplaybackrate: '48000',
10764
+ }
10765
+ );
9695
10766
  } else {
9696
- await this.sendSlotManager.deleteCodecParameters(MediaType.AudioMain, [
9697
- 'maxaveragebitrate',
9698
- 'maxplaybackrate',
9699
- ]);
10767
+ await this.sendSlotManager.markCustomCodecParametersForDeletion(
10768
+ MediaType.AudioMain,
10769
+ MediaCodecMimeType.OPUS,
10770
+ ['maxaveragebitrate', 'maxplaybackrate']
10771
+ );
9700
10772
  }
9701
10773
  }
9702
10774
 
@@ -10195,4 +11267,52 @@ export default class Meeting extends StatelessWebexPlugin {
10195
11267
  cancelSipCallOut(participantId: string) {
10196
11268
  return this.meetingRequest.cancelSipCallOut(participantId);
10197
11269
  }
11270
+
11271
+ /**
11272
+ * Method to get new data
11273
+ * @returns {Promise}
11274
+ */
11275
+ public async refreshDataChannelToken() {
11276
+ const isPracticeSession = this.webinar.isJoinPracticeSessionDataChannel();
11277
+ const dataChannelTokenType = this.getDataChannelTokenType();
11278
+
11279
+ try {
11280
+ const res = await this.meetingRequest.fetchDatachannelToken({
11281
+ locusUrl: this.locusUrl,
11282
+ requestingParticipantId: this.members.selfId,
11283
+ isPracticeSession,
11284
+ });
11285
+
11286
+ return {
11287
+ body: {
11288
+ datachannelToken: res.body.datachannelToken,
11289
+ dataChannelTokenType,
11290
+ },
11291
+ };
11292
+ } catch (e) {
11293
+ const msg = e?.message || String(e);
11294
+
11295
+ LoggerProxy.logger.warn(
11296
+ `Meeting:index#refreshDataChannelToken --> DataChannel token refresh failed (likely locus changed or participant left): ${msg}`,
11297
+ {statusCode: e?.statusCode}
11298
+ );
11299
+
11300
+ return null;
11301
+ }
11302
+ }
11303
+
11304
+ /**
11305
+ * Determines the current data channel token type based on the meeting state.
11306
+ *
11307
+ * variant should be used when connecting to the LLM data channel.
11308
+ *
11309
+ * @returns {DataChannelTokenType} The token type representing the current session mode.
11310
+ */
11311
+ public getDataChannelTokenType(): DataChannelTokenType {
11312
+ if (this.webinar.isJoinPracticeSessionDataChannel()) {
11313
+ return DataChannelTokenType.PracticeSession;
11314
+ }
11315
+
11316
+ return DataChannelTokenType.Default;
11317
+ }
10198
11318
  }