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

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