@webex/plugin-meetings 3.11.0-webex-services-ready.1 → 3.12.0-metrics-init-fix-2.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 (293) 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 +14 -5
  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 +90 -3
  13. package/dist/breakouts/index.js.map +1 -1
  14. package/dist/common/errors/webex-errors.js +49 -5
  15. package/dist/common/errors/webex-errors.js.map +1 -1
  16. package/dist/config.js +8 -3
  17. package/dist/config.js.map +1 -1
  18. package/dist/constants.js +60 -11
  19. package/dist/constants.js.map +1 -1
  20. package/dist/controls-options-manager/constants.js +11 -1
  21. package/dist/controls-options-manager/constants.js.map +1 -1
  22. package/dist/controls-options-manager/index.js +67 -29
  23. package/dist/controls-options-manager/index.js.map +1 -1
  24. package/dist/controls-options-manager/util.js +91 -0
  25. package/dist/controls-options-manager/util.js.map +1 -1
  26. package/dist/hashTree/constants.js +16 -2
  27. package/dist/hashTree/constants.js.map +1 -1
  28. package/dist/hashTree/hashTree.js +18 -0
  29. package/dist/hashTree/hashTree.js.map +1 -1
  30. package/dist/hashTree/hashTreeParser.js +1655 -538
  31. package/dist/hashTree/hashTreeParser.js.map +1 -1
  32. package/dist/hashTree/types.js +4 -2
  33. package/dist/hashTree/types.js.map +1 -1
  34. package/dist/hashTree/utils.js +52 -0
  35. package/dist/hashTree/utils.js.map +1 -1
  36. package/dist/index.js +18 -2
  37. package/dist/index.js.map +1 -1
  38. package/dist/interceptors/constant.js +12 -0
  39. package/dist/interceptors/constant.js.map +1 -0
  40. package/dist/interceptors/dataChannelAuthToken.js +350 -0
  41. package/dist/interceptors/dataChannelAuthToken.js.map +1 -0
  42. package/dist/interceptors/index.js +7 -0
  43. package/dist/interceptors/index.js.map +1 -1
  44. package/dist/interceptors/locusRetry.js +23 -8
  45. package/dist/interceptors/locusRetry.js.map +1 -1
  46. package/dist/interceptors/utils.js +27 -0
  47. package/dist/interceptors/utils.js.map +1 -0
  48. package/dist/interpretation/index.js +11 -2
  49. package/dist/interpretation/index.js.map +1 -1
  50. package/dist/interpretation/interpretation.types.js +7 -0
  51. package/dist/interpretation/interpretation.types.js.map +1 -0
  52. package/dist/interpretation/siLanguage.js +1 -1
  53. package/dist/locus-info/controlsUtils.js +9 -4
  54. package/dist/locus-info/controlsUtils.js.map +1 -1
  55. package/dist/locus-info/index.js +911 -211
  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 +2266 -1069
  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/common/errors/webex-errors.d.ts +32 -2
  130. package/dist/types/config.d.ts +6 -2
  131. package/dist/types/constants.d.ts +35 -1
  132. package/dist/types/controls-options-manager/constants.d.ts +6 -1
  133. package/dist/types/controls-options-manager/index.d.ts +16 -0
  134. package/dist/types/hashTree/constants.d.ts +3 -0
  135. package/dist/types/hashTree/hashTree.d.ts +7 -0
  136. package/dist/types/hashTree/hashTreeParser.d.ts +315 -30
  137. package/dist/types/hashTree/types.d.ts +3 -0
  138. package/dist/types/hashTree/utils.d.ts +24 -0
  139. package/dist/types/index.d.ts +4 -0
  140. package/dist/types/interceptors/constant.d.ts +5 -0
  141. package/dist/types/interceptors/dataChannelAuthToken.d.ts +43 -0
  142. package/dist/types/interceptors/index.d.ts +2 -1
  143. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  144. package/dist/types/interceptors/utils.d.ts +1 -0
  145. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  146. package/dist/types/locus-info/index.d.ts +126 -15
  147. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  148. package/dist/types/locus-info/types.d.ts +28 -1
  149. package/dist/types/media/MediaConnectionAwaiter.d.ts +20 -2
  150. package/dist/types/media/properties.d.ts +8 -3
  151. package/dist/types/meeting/in-meeting-actions.d.ts +10 -0
  152. package/dist/types/meeting/index.d.ts +245 -16
  153. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  154. package/dist/types/meeting/request.d.ts +17 -1
  155. package/dist/types/meeting/request.type.d.ts +5 -0
  156. package/dist/types/meeting/util.d.ts +40 -0
  157. package/dist/types/meetings/index.d.ts +42 -20
  158. package/dist/types/meetings/meetings.types.d.ts +15 -0
  159. package/dist/types/meetings/request.d.ts +14 -0
  160. package/dist/types/member/index.d.ts +2 -0
  161. package/dist/types/member/types.d.ts +1 -0
  162. package/dist/types/member/util.d.ts +14 -0
  163. package/dist/types/members/index.d.ts +15 -2
  164. package/dist/types/members/util.d.ts +1 -5
  165. package/dist/types/metrics/constants.d.ts +11 -0
  166. package/dist/types/multistream/codec/constants.d.ts +7 -0
  167. package/dist/types/multistream/mediaRequestManager.d.ts +20 -26
  168. package/dist/types/multistream/sendSlotManager.d.ts +23 -1
  169. package/dist/types/reachability/clusterReachability.d.ts +3 -3
  170. package/dist/types/reachability/index.d.ts +10 -3
  171. package/dist/types/reachability/reachability.types.d.ts +7 -0
  172. package/dist/types/reachability/util.d.ts +17 -0
  173. package/dist/types/reactions/reactions.type.d.ts +4 -0
  174. package/dist/types/webinar/utils.d.ts +6 -0
  175. package/dist/webinar/index.js +585 -164
  176. package/dist/webinar/index.js.map +1 -1
  177. package/dist/webinar/utils.js +25 -0
  178. package/dist/webinar/utils.js.map +1 -0
  179. package/package.json +24 -23
  180. package/src/aiEnableRequest/README.md +84 -0
  181. package/src/aiEnableRequest/index.ts +186 -0
  182. package/src/aiEnableRequest/utils.ts +25 -0
  183. package/src/annotation/index.ts +27 -7
  184. package/src/breakouts/breakout.ts +3 -1
  185. package/src/breakouts/events.ts +33 -11
  186. package/src/breakouts/index.ts +110 -1
  187. package/src/common/errors/webex-errors.ts +50 -3
  188. package/src/config.ts +6 -2
  189. package/src/constants.ts +49 -3
  190. package/src/controls-options-manager/constants.ts +14 -1
  191. package/src/controls-options-manager/index.ts +87 -28
  192. package/src/controls-options-manager/util.ts +81 -1
  193. package/src/hashTree/constants.ts +17 -0
  194. package/src/hashTree/hashTree.ts +17 -0
  195. package/src/hashTree/hashTreeParser.ts +1482 -361
  196. package/src/hashTree/types.ts +4 -0
  197. package/src/hashTree/utils.ts +45 -0
  198. package/src/index.ts +14 -1
  199. package/src/interceptors/constant.ts +6 -0
  200. package/src/interceptors/dataChannelAuthToken.ts +246 -0
  201. package/src/interceptors/index.ts +2 -1
  202. package/src/interceptors/locusRetry.ts +25 -4
  203. package/src/interceptors/utils.ts +16 -0
  204. package/src/interpretation/index.ts +29 -11
  205. package/src/interpretation/interpretation.types.ts +11 -0
  206. package/src/locus-info/controlsUtils.ts +14 -1
  207. package/src/locus-info/index.ts +975 -203
  208. package/src/locus-info/infoUtils.ts +41 -6
  209. package/src/locus-info/selfUtils.ts +1 -0
  210. package/src/locus-info/types.ts +33 -1
  211. package/src/media/MediaConnectionAwaiter.ts +62 -5
  212. package/src/media/index.ts +10 -1
  213. package/src/media/properties.ts +11 -4
  214. package/src/meeting/in-meeting-actions.ts +20 -0
  215. package/src/meeting/index.ts +1258 -166
  216. package/src/meeting/locusMediaRequest.ts +106 -6
  217. package/src/meeting/muteState.ts +10 -1
  218. package/src/meeting/request.ts +53 -0
  219. package/src/meeting/request.type.ts +6 -0
  220. package/src/meeting/util.ts +207 -7
  221. package/src/meeting-info/meeting-info-v2.ts +4 -2
  222. package/src/meetings/index.ts +319 -117
  223. package/src/meetings/meetings.types.ts +19 -0
  224. package/src/meetings/request.ts +43 -0
  225. package/src/meetings/util.ts +117 -4
  226. package/src/member/index.ts +20 -0
  227. package/src/member/types.ts +1 -0
  228. package/src/member/util.ts +41 -0
  229. package/src/members/index.ts +70 -7
  230. package/src/members/util.ts +12 -4
  231. package/src/metrics/constants.ts +12 -0
  232. package/src/multistream/codec/constants.ts +58 -0
  233. package/src/multistream/mediaRequestManager.ts +117 -76
  234. package/src/multistream/receiveSlot.ts +18 -0
  235. package/src/multistream/remoteMediaManager.ts +13 -0
  236. package/src/multistream/sendSlotManager.ts +97 -3
  237. package/src/reachability/clusterReachability.ts +3 -2
  238. package/src/reachability/index.ts +47 -16
  239. package/src/reachability/reachability.types.ts +11 -0
  240. package/src/reachability/util.ts +36 -0
  241. package/src/reactions/reactions.type.ts +4 -0
  242. package/src/reconnection-manager/index.ts +0 -1
  243. package/src/recording-controller/index.ts +1 -2
  244. package/src/roap/turnDiscovery.ts +9 -1
  245. package/src/webinar/index.ts +448 -11
  246. package/src/webinar/utils.ts +16 -0
  247. package/test/unit/spec/aiEnableRequest/index.ts +1067 -0
  248. package/test/unit/spec/aiEnableRequest/utils.ts +130 -0
  249. package/test/unit/spec/annotation/index.ts +69 -7
  250. package/test/unit/spec/breakouts/breakout.ts +9 -3
  251. package/test/unit/spec/breakouts/events.ts +120 -2
  252. package/test/unit/spec/breakouts/index.ts +191 -2
  253. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  254. package/test/unit/spec/controls-options-manager/index.js +244 -29
  255. package/test/unit/spec/controls-options-manager/util.js +165 -0
  256. package/test/unit/spec/hashTree/hashTree.ts +66 -0
  257. package/test/unit/spec/hashTree/hashTreeParser.ts +4528 -171
  258. package/test/unit/spec/hashTree/utils.ts +125 -1
  259. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +406 -0
  260. package/test/unit/spec/interceptors/locusRetry.ts +205 -4
  261. package/test/unit/spec/interceptors/utils.ts +75 -0
  262. package/test/unit/spec/interpretation/index.ts +26 -4
  263. package/test/unit/spec/locus-info/controlsUtils.js +200 -56
  264. package/test/unit/spec/locus-info/index.js +1848 -164
  265. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  266. package/test/unit/spec/media/MediaConnectionAwaiter.ts +96 -1
  267. package/test/unit/spec/media/index.ts +92 -0
  268. package/test/unit/spec/media/properties.ts +35 -26
  269. package/test/unit/spec/meeting/in-meeting-actions.ts +12 -2
  270. package/test/unit/spec/meeting/index.js +3611 -334
  271. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  272. package/test/unit/spec/meeting/muteState.js +81 -0
  273. package/test/unit/spec/meeting/request.js +82 -0
  274. package/test/unit/spec/meeting/utils.js +595 -27
  275. package/test/unit/spec/meeting-info/meetinginfov2.js +19 -10
  276. package/test/unit/spec/meetings/index.js +1138 -86
  277. package/test/unit/spec/meetings/request.js +141 -0
  278. package/test/unit/spec/meetings/utils.js +402 -51
  279. package/test/unit/spec/member/index.js +35 -4
  280. package/test/unit/spec/member/util.js +154 -27
  281. package/test/unit/spec/members/index.js +216 -0
  282. package/test/unit/spec/members/request.js +37 -1
  283. package/test/unit/spec/members/utils.js +63 -0
  284. package/test/unit/spec/multistream/mediaRequestManager.ts +503 -122
  285. package/test/unit/spec/multistream/remoteMediaManager.ts +30 -0
  286. package/test/unit/spec/multistream/sendSlotManager.ts +135 -36
  287. package/test/unit/spec/reachability/index.ts +128 -46
  288. package/test/unit/spec/reachability/util.ts +31 -0
  289. package/test/unit/spec/reconnection-manager/index.js +4 -8
  290. package/test/unit/spec/recording-controller/index.js +9 -8
  291. package/test/unit/spec/roap/turnDiscovery.ts +20 -0
  292. package/test/unit/spec/webinar/index.ts +837 -39
  293. package/test/unit/spec/webinar/utils.ts +39 -0
@@ -13,7 +13,7 @@ import {
13
13
  CALL_DIAGNOSTIC_CONFIG,
14
14
  RtcMetrics,
15
15
  } from '@webex/internal-plugin-metrics';
16
- import {ClientEvent as RawClientEvent} from '@webex/event-dictionary-ts';
16
+ import type {ClientEvent as RawClientEvent} from '@webex/event-dictionary-ts';
17
17
 
18
18
  import {
19
19
  ConnectionState,
@@ -30,9 +30,11 @@ import {
30
30
  NetworkQualityMonitor,
31
31
  StatsMonitor,
32
32
  StatsMonitorEventNames,
33
- InboundAudioIssueSubTypes,
33
+ MediaCodecMimeType,
34
34
  } from '@webex/internal-media-core';
35
35
 
36
+ import {DataChannelTokenType, type RegisterAndConnectTiming} from '@webex/internal-plugin-llm';
37
+
36
38
  import {
37
39
  LocalStream,
38
40
  LocalCameraStream,
@@ -64,6 +66,7 @@ import {
64
66
  NoMediaEstablishedYetError,
65
67
  UserNotJoinedError,
66
68
  AddMediaFailed,
69
+ MediaConnectionTimedOutError,
67
70
  SdpResponseTimeoutError,
68
71
  } from '../common/errors/webex-errors';
69
72
 
@@ -74,6 +77,7 @@ import Roap, {type TurnDiscoveryResult, type TurnDiscoverySkipReason} from '../r
74
77
  import {type TurnServerInfo} from '../roap/types';
75
78
  import Media, {type BundlePolicy} from '../media';
76
79
  import MediaProperties from '../media/properties';
80
+ import {type FailureResult as MediaConnectionAwaiterFailureResult} from '../media/MediaConnectionAwaiter';
77
81
  import MeetingStateMachine from './state';
78
82
  import {createMuteState} from './muteState';
79
83
  import LocusInfo, {LocusLLMEvent} from '../locus-info';
@@ -134,6 +138,8 @@ import {
134
138
  STAGE_MANAGER_TYPE,
135
139
  LOCUSEVENT,
136
140
  LOCUS_LLM_EVENT,
141
+ LLM_DEFAULT_SESSION,
142
+ LLM_PRACTICE_SESSION,
137
143
  } from '../constants';
138
144
  import BEHAVIORAL_METRICS from '../metrics/constants';
139
145
  import ParameterError from '../common/errors/parameter';
@@ -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;
@@ -894,6 +949,10 @@ export default class Meeting extends StatelessWebexPlugin {
894
949
  */
895
950
  // @ts-ignore
896
951
  this.simultaneousInterpretation = new SimultaneousInterpretation({}, {parent: this.webex});
952
+
953
+ // @ts-ignore
954
+ this.aiEnableRequest = new AIEnableRequest({locusUrl: this.locusUrl}, {parent: this.webex});
955
+
897
956
  /**
898
957
  * @instance
899
958
  * @type {Annotation}
@@ -923,6 +982,7 @@ export default class Meeting extends StatelessWebexPlugin {
923
982
  },
924
983
  (csi: CSI) => (this.members.findMemberByCsi(csi) as any)?.id
925
984
  );
985
+
926
986
  /**
927
987
  * Object containing helper classes for managing media requests for audio/video/screenshare (for multistream media connections)
928
988
  * All multistream media requests sent out for this meeting have to go through them.
@@ -942,6 +1002,7 @@ export default class Meeting extends StatelessWebexPlugin {
942
1002
  mediaRequests
943
1003
  );
944
1004
  },
1005
+ this.getIngressPayloadTypeCallback.bind(this),
945
1006
  {
946
1007
  // @ts-ignore - config coming from registerPlugin
947
1008
  degradationPreferences: this.config.degradationPreferences,
@@ -963,6 +1024,7 @@ export default class Meeting extends StatelessWebexPlugin {
963
1024
  mediaRequests
964
1025
  );
965
1026
  },
1027
+ this.getIngressPayloadTypeCallback.bind(this),
966
1028
  {
967
1029
  // @ts-ignore - config coming from registerPlugin
968
1030
  degradationPreferences: this.config.degradationPreferences,
@@ -984,6 +1046,7 @@ export default class Meeting extends StatelessWebexPlugin {
984
1046
  mediaRequests
985
1047
  );
986
1048
  },
1049
+ this.getIngressPayloadTypeCallback.bind(this),
987
1050
  {
988
1051
  // @ts-ignore - config coming from registerPlugin
989
1052
  degradationPreferences: this.config.degradationPreferences,
@@ -1005,11 +1068,14 @@ export default class Meeting extends StatelessWebexPlugin {
1005
1068
  mediaRequests
1006
1069
  );
1007
1070
  },
1071
+ this.getIngressPayloadTypeCallback.bind(this),
1008
1072
  {
1009
1073
  // @ts-ignore - config coming from registerPlugin
1010
1074
  degradationPreferences: this.config.degradationPreferences,
1011
1075
  kind: 'video',
1012
1076
  trimRequestsToNumOfSources: false,
1077
+ // @ts-ignore - config coming from registerPlugin
1078
+ enableAv1: this.config.enableAv1SlidesSupport,
1013
1079
  }
1014
1080
  ),
1015
1081
  };
@@ -1329,7 +1395,48 @@ export default class Meeting extends StatelessWebexPlugin {
1329
1395
  * @memberof Meeting
1330
1396
  */
1331
1397
  // @ts-ignore - Fix type
1332
- this.locusInfo = new LocusInfo(this.updateMeetingObject.bind(this), this.webex, this.id);
1398
+ this.locusInfo = new LocusInfo(
1399
+ {
1400
+ updateMeeting: this.updateMeetingObject.bind(this),
1401
+ syncLatencyTracker: {
1402
+ // Compute/store latency timestamps live on CallDiagnosticLatencies, while
1403
+ // submitting the client.locus.sync.complete CA event is owned by the metrics
1404
+ // facade. Wire each method to the layer that owns that responsibility.
1405
+ saveLatency: (...args) =>
1406
+ // @ts-ignore
1407
+ this.webex.internal.newMetrics.callDiagnosticLatencies.saveLatency(...args),
1408
+ saveTimestamp: (saveTimestampOptions: {
1409
+ key: string;
1410
+ value?: number;
1411
+ options: {meetingId: string; dataSetName: string; trackingId?: string};
1412
+ }) => {
1413
+ // @ts-ignore
1414
+ this.webex.internal.newMetrics.callDiagnosticLatencies.saveTimestamp(
1415
+ saveTimestampOptions
1416
+ );
1417
+
1418
+ // The /sync response is one of the two milestones (the other is the LLM message) that
1419
+ // complete client.locus.sync.complete. Try to complete now: the metric is emitted only
1420
+ // once both the LLM message and the /sync response have arrived (either can come first).
1421
+ if (
1422
+ saveTimestampOptions.key === 'internal.client.locus.sync.response' &&
1423
+ saveTimestampOptions.options?.trackingId
1424
+ ) {
1425
+ this.tryCompleteLocusSyncLatency(
1426
+ saveTimestampOptions.options.meetingId,
1427
+ saveTimestampOptions.options.trackingId
1428
+ );
1429
+ }
1430
+ },
1431
+ clearLocusSyncLatency: (...args) =>
1432
+ // @ts-ignore
1433
+ this.webex.internal.newMetrics.callDiagnosticLatencies.clearLocusSyncLatency(...args),
1434
+ },
1435
+ },
1436
+ // @ts-ignore
1437
+ this.webex,
1438
+ this.id
1439
+ );
1333
1440
 
1334
1441
  // We had to add listeners first before setting up the locus instance
1335
1442
  /**
@@ -1514,6 +1621,8 @@ export default class Meeting extends StatelessWebexPlugin {
1514
1621
  this.controlsOptionsManager = new ControlsOptionsManager(this.meetingRequest, {
1515
1622
  locusUrl: this.locusInfo?.url,
1516
1623
  displayHints: [],
1624
+ getControls: () => this.locusInfo?.controls,
1625
+ isWebinar: () => this.locusInfo?.info?.isWebinar,
1517
1626
  });
1518
1627
 
1519
1628
  this.setUpLocusInfoListeners();
@@ -1543,6 +1652,12 @@ export default class Meeting extends StatelessWebexPlugin {
1543
1652
  }
1544
1653
  };
1545
1654
 
1655
+ this.localConstraintsChangeHandler = () => {
1656
+ if (!this.isMultistream) {
1657
+ this.mediaProperties.webrtcMediaConnection?.updatePreferredBitrateKbps();
1658
+ }
1659
+ };
1660
+
1546
1661
  /**
1547
1662
  * Promise that exists if SDP offer has been generated, and resolves once sdp answer is received.
1548
1663
  * @instance
@@ -1606,11 +1721,11 @@ export default class Meeting extends StatelessWebexPlugin {
1606
1721
  /**
1607
1722
  * Information needed for a retry of a call to joinWithMedia
1608
1723
  * @instance
1609
- * @type {{isRetry: boolean; prevJoinResponse?: any}}
1724
+ * @type {{retryCount: number; prevJoinResponse?: any}}
1610
1725
  * @private
1611
1726
  * @memberof Meeting
1612
1727
  */
1613
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
1728
+ this.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
1614
1729
 
1615
1730
  /**
1616
1731
  * Connection state handler
@@ -1664,6 +1779,37 @@ export default class Meeting extends StatelessWebexPlugin {
1664
1779
  this.mediaServerIp = undefined;
1665
1780
  }
1666
1781
 
1782
+ /**
1783
+ * Get the ingress payload type for a given media type and codec mime type
1784
+ * @param {MediaType} mediaType - The media type
1785
+ * @param {MediaCodecMimeType} codecMimeType - The codec mime type
1786
+ * @returns {number | undefined} - The ingress payload type
1787
+ * @private
1788
+ * @memberof Meeting
1789
+ */
1790
+ private getIngressPayloadTypeCallback(
1791
+ mediaType: MediaType,
1792
+ codecMimeType: MediaCodecMimeType
1793
+ ): number | undefined {
1794
+ if (this.isMultistream) {
1795
+ try {
1796
+ return this.mediaProperties.webrtcMediaConnection.getIngressPayloadType(
1797
+ mediaType,
1798
+ codecMimeType
1799
+ );
1800
+ } catch (error) {
1801
+ LoggerProxy.logger.info(
1802
+ `Meeting:index#mediaRequestManager --> failed to get ingress payload type for mediaType=${mediaType}, codecMimeType=${codecMimeType}`,
1803
+ error
1804
+ );
1805
+
1806
+ return undefined;
1807
+ }
1808
+ }
1809
+
1810
+ return undefined;
1811
+ }
1812
+
1667
1813
  /**
1668
1814
  * Temporary func to return webex object,
1669
1815
  * in order to access internal plugin metrics
@@ -2276,6 +2422,89 @@ export default class Meeting extends StatelessWebexPlugin {
2276
2422
  });
2277
2423
  }
2278
2424
 
2425
+ /**
2426
+ * Handles the LLM state-update message that resulted from a Locus /sync. Records the LLM arrival
2427
+ * time (the milestone that gates client.locus.sync.complete - the metric is emitted only for LLM
2428
+ * flows) and then tries to complete the metric.
2429
+ * @param {string} meetingId meeting id
2430
+ * @param {string} trackingId sync tracking id echoed back on the LLM message
2431
+ * @returns {void}
2432
+ * @private
2433
+ * @memberof Meeting
2434
+ */
2435
+ private onLocusSyncLlmMessage(meetingId: string, trackingId: string) {
2436
+ // @ts-ignore
2437
+ this.webex.internal.newMetrics.callDiagnosticLatencies.recordLocusSyncMessageReceived(
2438
+ meetingId,
2439
+ trackingId
2440
+ );
2441
+
2442
+ this.tryCompleteLocusSyncLatency(meetingId, trackingId);
2443
+ }
2444
+
2445
+ /**
2446
+ * Attempts to complete the Locus sync latency metric and emit client.locus.sync.complete. The
2447
+ * metric is emitted only once BOTH the /sync response and the resulting LLM message have arrived
2448
+ * (in either order); until then the record is kept so the missing milestone can still land. Both
2449
+ * trigger points (the LLM message handler and the /sync response timestamp) call this, so the
2450
+ * metric fires as soon as the second milestone is in.
2451
+ * @param {string} meetingId meeting id
2452
+ * @param {string} trackingId sync tracking id used to match the pending record
2453
+ * @returns {void}
2454
+ * @private
2455
+ * @memberof Meeting
2456
+ */
2457
+ private tryCompleteLocusSyncLatency(meetingId: string, trackingId: string) {
2458
+ const completed =
2459
+ // @ts-ignore
2460
+ this.webex.internal.newMetrics.callDiagnosticLatencies.completeLocusSyncLatency(
2461
+ meetingId,
2462
+ trackingId
2463
+ );
2464
+
2465
+ if (completed) {
2466
+ this.emitLocusSyncCompleteMetric(meetingId, completed);
2467
+ }
2468
+ }
2469
+
2470
+ /**
2471
+ * Submits the client.locus.sync.complete Call Analyzer event for a completed Locus sync latency
2472
+ * measurement.
2473
+ * @param {string} meetingId meeting id
2474
+ * @param {object} completed completed sync latency payload from the metrics plugin
2475
+ * @returns {void}
2476
+ * @private
2477
+ * @memberof Meeting
2478
+ */
2479
+ private emitLocusSyncCompleteMetric(
2480
+ meetingId: string,
2481
+ completed: {dataSet: string; syncLatency: object}
2482
+ ) {
2483
+ // @ts-ignore
2484
+ const llmWebsocketUrl = this.webex.internal.llm?.getWebSocketUrl?.() || undefined;
2485
+
2486
+ // Per the LLM sync-latency spec, the event carries the LLM websocket url identifier,
2487
+ // the llmInfo.dataSet (main, atd-active or atd-unmuted) and the syncLatency block.
2488
+ const clientEvent = {
2489
+ name: 'client.locus.sync.complete',
2490
+ payload: {
2491
+ identifiers: {
2492
+ llmWebsocketUrl,
2493
+ },
2494
+ llmInfo: {
2495
+ dataSet: completed.dataSet,
2496
+ },
2497
+ syncLatency: completed.syncLatency,
2498
+ },
2499
+ options: {
2500
+ meetingId,
2501
+ },
2502
+ };
2503
+
2504
+ // @ts-ignore
2505
+ this.webex.internal.newMetrics.submitClientEvent(clientEvent);
2506
+ }
2507
+
2279
2508
  /**
2280
2509
  * Proxy function for all the listener set ups
2281
2510
  * @returns {undefined}
@@ -2740,7 +2969,7 @@ export default class Meeting extends StatelessWebexPlugin {
2740
2969
  private setupLocusControlsListener() {
2741
2970
  this.locusInfo.on(
2742
2971
  LOCUSINFO.EVENTS.CONTROLS_RECORDING_UPDATED,
2743
- ({state, modifiedBy, lastModified}) => {
2972
+ ({state, modifiedBy, lastModified, modifiedByServiceAppName, modifiedByServiceAppId}) => {
2744
2973
  let event;
2745
2974
 
2746
2975
  switch (state) {
@@ -2766,6 +2995,8 @@ export default class Meeting extends StatelessWebexPlugin {
2766
2995
  state: state === RECORDING_STATE.RESUMED ? RECORDING_STATE.RECORDING : state,
2767
2996
  modifiedBy,
2768
2997
  lastModified,
2998
+ modifiedByServiceAppName,
2999
+ modifiedByServiceAppId,
2769
3000
  };
2770
3001
  Trigger.trigger(
2771
3002
  this,
@@ -2952,6 +3183,18 @@ export default class Meeting extends StatelessWebexPlugin {
2952
3183
  );
2953
3184
  });
2954
3185
 
3186
+ this.locusInfo.on(
3187
+ LOCUSINFO.EVENTS.CONTROLS_AI_SUMMARY_NOTIFICATION_UPDATED,
3188
+ ({aiSummaryNotification}) => {
3189
+ Trigger.trigger(
3190
+ this,
3191
+ {file: 'meeting/index', function: 'setupLocusControlsListener'},
3192
+ EVENT_TRIGGERS.MEETING_CONTROLS_AI_SUMMARY_NOTIFICATION_UPDATED,
3193
+ {aiSummaryNotification}
3194
+ );
3195
+ }
3196
+ );
3197
+
2955
3198
  this.locusInfo.on(LOCUSINFO.EVENTS.CONTROLS_WEBCAST_CHANGED, ({state}) => {
2956
3199
  Trigger.trigger(
2957
3200
  this,
@@ -3152,7 +3395,7 @@ export default class Meeting extends StatelessWebexPlugin {
3152
3395
  }
3153
3396
 
3154
3397
  LoggerProxy.logger.info(
3155
- `Meeting:index#setUpLocusInfoMediaInactiveListener --> this.shareStatus=${this.shareStatus} newShareStatus=${newShareStatus}`
3398
+ `Meeting:index#setUpLocusMediaSharesListener --> this.shareStatus=${this.shareStatus} newShareStatus=${newShareStatus}`
3156
3399
  );
3157
3400
 
3158
3401
  if (newShareStatus !== this.shareStatus) {
@@ -3398,6 +3641,7 @@ export default class Meeting extends StatelessWebexPlugin {
3398
3641
  this.breakouts.locusUrlUpdate(url);
3399
3642
  this.simultaneousInterpretation.locusUrlUpdate(url);
3400
3643
  this.annotation.locusUrlUpdate(url);
3644
+ this.aiEnableRequest.locusUrlUpdate(url);
3401
3645
  this.locusUrl = url;
3402
3646
  this.locusId = this.locusUrl?.split('/').pop();
3403
3647
  this.recordingController.setLocusUrl(this.locusUrl);
@@ -3433,6 +3677,7 @@ export default class Meeting extends StatelessWebexPlugin {
3433
3677
  this.breakouts.breakoutServiceUrlUpdate(payload?.services?.breakout?.url);
3434
3678
  this.annotation.approvalUrlUpdate(payload?.services?.approval?.url);
3435
3679
  this.simultaneousInterpretation.approvalUrlUpdate(payload?.services?.approval?.url);
3680
+ this.aiEnableRequest.approvalUrlUpdate(payload?.services?.approval?.url);
3436
3681
  });
3437
3682
  }
3438
3683
 
@@ -3530,6 +3775,9 @@ export default class Meeting extends StatelessWebexPlugin {
3530
3775
  // @ts-ignore - config coming from registerPlugin
3531
3776
  if (datachannelUrl && this.config.enableAutomaticLLM) {
3532
3777
  this.updateLLMConnection();
3778
+ if (this.webinar.isJoinPracticeSessionDataChannel()) {
3779
+ this.webinar.updatePSDataChannel();
3780
+ }
3533
3781
  }
3534
3782
  }
3535
3783
 
@@ -3693,6 +3941,17 @@ export default class Meeting extends StatelessWebexPlugin {
3693
3941
  });
3694
3942
  }
3695
3943
  this.rtcMetrics?.sendNextMetrics();
3944
+
3945
+ try {
3946
+ await this.ensureDefaultDatachannelTokenAfterAdmit();
3947
+ } catch (error) {
3948
+ LoggerProxy.logger.warn(
3949
+ `Meeting:index#setUpLocusInfoSelfListener --> failed post-admit token prefetch flow: ${
3950
+ error?.message || String(error)
3951
+ }`
3952
+ );
3953
+ }
3954
+
3696
3955
  this.updateLLMConnection();
3697
3956
  });
3698
3957
 
@@ -3737,6 +3996,9 @@ export default class Meeting extends StatelessWebexPlugin {
3737
3996
  });
3738
3997
 
3739
3998
  this.locusInfo.on(LOCUSINFO.EVENTS.SELF_CANNOT_VIEW_PARTICIPANT_LIST_CHANGE, (payload) => {
3999
+ // canViewTheParticipantList meeting action depends on this value, so we need to update meeting actions
4000
+ this.updateMeetingActions();
4001
+
3740
4002
  Trigger.trigger(
3741
4003
  this,
3742
4004
  {
@@ -3762,6 +4024,10 @@ export default class Meeting extends StatelessWebexPlugin {
3762
4024
  );
3763
4025
  });
3764
4026
 
4027
+ this.locusInfo.on(LOCUSINFO.EVENTS.SELF_ID_CHANGED, (payload) => {
4028
+ this.aiEnableRequest.selfParticipantIdUpdate(payload.selfId);
4029
+ });
4030
+
3765
4031
  this.locusInfo.on(LOCUSINFO.EVENTS.SELF_MEETING_INTERPRETATION_CHANGED, (payload) => {
3766
4032
  const targetChanged = this.simultaneousInterpretation.updateSelfInterpretation(payload);
3767
4033
  Trigger.trigger(
@@ -3927,7 +4193,14 @@ export default class Meeting extends StatelessWebexPlugin {
3927
4193
  // is not changed by any delta event
3928
4194
  if (object && Object.keys(object).length) {
3929
4195
  Object.keys(object).forEach((key) => {
4196
+ const previousValue = this[key];
4197
+
3930
4198
  this[key] = object[key];
4199
+
4200
+ if (this.promisesWaitingForPropUpdate[key] && previousValue !== object[key]) {
4201
+ this.promisesWaitingForPropUpdate[key].resolve();
4202
+ delete this.promisesWaitingForPropUpdate[key];
4203
+ }
3931
4204
  });
3932
4205
  }
3933
4206
  }
@@ -4065,7 +4338,12 @@ export default class Meeting extends StatelessWebexPlugin {
4065
4338
  }
4066
4339
 
4067
4340
  /**
4068
- * Transfer the moderator role to another eligible member
4341
+ * Transfer the moderator role to another eligible member.
4342
+ *
4343
+ * If the target member is currently joined in the current session, the request is
4344
+ * sent against the current locus. Otherwise, we search the breakout sessions and,
4345
+ * when the member is found in one, we send the request against that breakout
4346
+ * session's locus url instead.
4069
4347
  * @param {String} memberId
4070
4348
  * @param {Boolean} moderator
4071
4349
  * @returns {Promise} see #members.transferHostToMember
@@ -4073,7 +4351,21 @@ export default class Meeting extends StatelessWebexPlugin {
4073
4351
  * @memberof Meeting
4074
4352
  */
4075
4353
  public transfer(memberId: string, moderator = true) {
4076
- return this.members.transferHostToMember(memberId, moderator);
4354
+ const targetMember = this.members.membersCollection.get(memberId);
4355
+
4356
+ if (targetMember?.isInMeeting) {
4357
+ return this.members.transferHostToMember(memberId, moderator);
4358
+ }
4359
+
4360
+ const breakout = this.breakouts?.breakouts?.models?.find((bo: any) => {
4361
+ const breakoutMember = bo.members?.membersCollection?.get(memberId);
4362
+
4363
+ return breakoutMember?.isInMeeting;
4364
+ });
4365
+
4366
+ const breakoutLocusUrl = breakout?.breakoutRosterLocus?.url;
4367
+
4368
+ return this.members.transferHostToMember(memberId, moderator, breakoutLocusUrl);
4077
4369
  }
4078
4370
 
4079
4371
  /**
@@ -4264,6 +4556,9 @@ export default class Meeting extends StatelessWebexPlugin {
4264
4556
  bothLeaveAndEndMeetingAvailable: MeetingUtil.bothLeaveAndEndMeetingAvailable(
4265
4557
  this.userDisplayHints
4266
4558
  ),
4559
+ requireHostEndMeetingBeforeLeave: MeetingUtil.requireHostEndMeetingBeforeLeave(
4560
+ this.userDisplayHints
4561
+ ),
4267
4562
  canEnableClosedCaption: MeetingUtil.canEnableClosedCaption(this.userDisplayHints),
4268
4563
  canStartTranscribing: MeetingUtil.canStartTranscribing(this.userDisplayHints),
4269
4564
  canStopTranscribing: MeetingUtil.canStopTranscribing(this.userDisplayHints),
@@ -4522,6 +4817,19 @@ export default class Meeting extends StatelessWebexPlugin {
4522
4817
  requiredHints: [DISPLAY_HINTS.DISABLE_ATTENDEE_START_POLLING_QA],
4523
4818
  displayHints: this.userDisplayHints,
4524
4819
  }),
4820
+ canAttendeeRequestAiAssistantEnabled: MeetingUtil.canAttendeeRequestAiAssistantEnabled(
4821
+ this.userDisplayHints,
4822
+ this.roles
4823
+ ),
4824
+ isAttendeeRequestAiAssistantDeclinedAll:
4825
+ MeetingUtil.attendeeRequestAiAssistantDeclinedAll(this.userDisplayHints),
4826
+ isAnonymizeDisplayNamesEnabled: MeetingUtil.isAnonymizeDisplayNamesEnabled(
4827
+ this.userDisplayHints
4828
+ ),
4829
+ canViewTheParticipantList: MeetingUtil.canViewTheParticipantList(
4830
+ this.userDisplayHints,
4831
+ this.canNotViewTheParticipantList ?? false
4832
+ ),
4525
4833
  }) || changed;
4526
4834
  }
4527
4835
  if (changed) {
@@ -4570,6 +4878,34 @@ export default class Meeting extends StatelessWebexPlugin {
4570
4878
  this.sipUri = sipUri;
4571
4879
  }
4572
4880
 
4881
+ /**
4882
+ * After initial locus setup, refreshes destination with synced locus data and optionally
4883
+ * performs deferred meeting info fetch when initial locus was incomplete.
4884
+ * @param {LocusDTO} locus
4885
+ * @returns {void}
4886
+ */
4887
+ public async finalizeMeetingAfterInitialLocusSetup(locus: LocusDTO): Promise<void> {
4888
+ if (locus && this?.destinationType === DESTINATION_TYPE.LOCUS_ID) {
4889
+ // destination is initialized from the initial locus snapshot in constructor,
4890
+ // so refresh it after locus sync to avoid stale partial hash-tree data.
4891
+ this.destination = locus;
4892
+ }
4893
+ if (
4894
+ (!this.meetingInfo || isEmpty(this.meetingInfo)) &&
4895
+ (this.destination as LocusDTO)?.info &&
4896
+ !this.fetchMeetingInfoTimeoutId &&
4897
+ !MeetingsUtil.isOneOnOneCall(locus)
4898
+ ) {
4899
+ try {
4900
+ await this.fetchMeetingInfo({});
4901
+ } catch (error: any) {
4902
+ LoggerProxy.logger.info(
4903
+ `Meeting:index#finalizeMeetingAfterInitialLocusSetup --> deferred fetchMeetingInfo failed: ${error.message}`
4904
+ );
4905
+ }
4906
+ }
4907
+ }
4908
+
4573
4909
  /**
4574
4910
  * Set the locus info the class instance. Should be called with the parsed locus
4575
4911
  * we got in the join response.
@@ -4593,7 +4929,8 @@ export default class Meeting extends StatelessWebexPlugin {
4593
4929
  mediaId: string;
4594
4930
  host: object;
4595
4931
  selfId: string;
4596
- dataSets: DataSet[];
4932
+ dataSets: DataSet[]; // only sent by Locus when hash trees are used
4933
+ metadata: Metadata; // only sent by Locus when hash trees are used
4597
4934
  }) {
4598
4935
  const mtgLocus: any = data.locus;
4599
4936
 
@@ -4609,6 +4946,7 @@ export default class Meeting extends StatelessWebexPlugin {
4609
4946
  trigger: 'join-response',
4610
4947
  locus: mtgLocus,
4611
4948
  dataSets: data.dataSets,
4949
+ metadata: data.metadata,
4612
4950
  });
4613
4951
  }
4614
4952
 
@@ -4818,6 +5156,7 @@ export default class Meeting extends StatelessWebexPlugin {
4818
5156
  this.localVideoStreamMuteStateHandler
4819
5157
  );
4820
5158
  oldStream?.off(LocalStreamEventNames.OutputTrackChange, this.localOutputTrackChangeHandler);
5159
+ oldStream?.off(LocalStreamEventNames.ConstraintsChange, this.localConstraintsChangeHandler);
4821
5160
 
4822
5161
  // we don't update this.mediaProperties.mediaDirection.sendVideo, because we always keep it as true to avoid extra SDP exchanges
4823
5162
  this.mediaProperties.setLocalVideoStream(localStream);
@@ -4833,6 +5172,7 @@ export default class Meeting extends StatelessWebexPlugin {
4833
5172
  this.localVideoStreamMuteStateHandler
4834
5173
  );
4835
5174
  localStream?.on(LocalStreamEventNames.OutputTrackChange, this.localOutputTrackChangeHandler);
5175
+ localStream?.on(LocalStreamEventNames.ConstraintsChange, this.localConstraintsChangeHandler);
4836
5176
 
4837
5177
  if (!this.isMultistream || !localStream) {
4838
5178
  // for multistream WCME automatically un-publishes the old stream when we publish a new one
@@ -4967,6 +5307,7 @@ export default class Meeting extends StatelessWebexPlugin {
4967
5307
  this.localVideoStreamMuteStateHandler
4968
5308
  );
4969
5309
  videoStream?.off(LocalStreamEventNames.OutputTrackChange, this.localOutputTrackChangeHandler);
5310
+ videoStream?.off(LocalStreamEventNames.ConstraintsChange, this.localConstraintsChangeHandler);
4970
5311
 
4971
5312
  shareAudioStream?.off(StreamEventNames.Ended, this.handleShareAudioStreamEnded);
4972
5313
  shareAudioStream?.off(
@@ -5036,8 +5377,7 @@ export default class Meeting extends StatelessWebexPlugin {
5036
5377
  public setMercuryListener() {
5037
5378
  // Client will have a socket manager and handle reconnecting to mercury, when we reconnect to mercury
5038
5379
  // if the meeting has active peer connections, it should try to reconnect.
5039
- // @ts-ignore
5040
- this.webex.internal.mercury.on(ONLINE, () => {
5380
+ this.mercuryOnlineHandler = () => {
5041
5381
  LoggerProxy.logger.info('Meeting:index#setMercuryListener --> Web socket online');
5042
5382
 
5043
5383
  // Only send restore event when it was disconnected before and for connected later
@@ -5047,15 +5387,47 @@ export default class Meeting extends StatelessWebexPlugin {
5047
5387
  });
5048
5388
  }
5049
5389
  this.hasWebsocketConnected = true;
5050
- });
5390
+ };
5051
5391
 
5052
- // @ts-ignore
5053
- this.webex.internal.mercury.on(OFFLINE, () => {
5392
+ this.mercuryOfflineHandler = () => {
5054
5393
  LoggerProxy.logger.error('Meeting:index#setMercuryListener --> Web socket offline');
5055
5394
  Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.MERCURY_CONNECTION_FAILURE, {
5056
5395
  correlation_id: this.correlationId,
5057
5396
  });
5058
- });
5397
+ };
5398
+
5399
+ // @ts-ignore
5400
+ this.webex.internal.mercury.on(ONLINE, this.mercuryOnlineHandler);
5401
+ // @ts-ignore
5402
+ this.webex.internal.mercury.on(OFFLINE, this.mercuryOfflineHandler);
5403
+ }
5404
+
5405
+ /**
5406
+ * Removes this meeting's Mercury ONLINE/OFFLINE event listeners registered
5407
+ * by setMercuryListener(). Must be called before Locus /leave to avoid
5408
+ * unnecessary syncs/metrics triggered by events received while leaving
5409
+ * (per Locus team recommendation).
5410
+ *
5411
+ * Mercury is a process-wide singleton shared with other plugins, so we
5412
+ * pass the bound handler refs to .off() to avoid clearing every listener
5413
+ * for ONLINE/OFFLINE on the shared emitter.
5414
+ *
5415
+ * Idempotent: subsequent calls are no-ops because the handler refs are
5416
+ * cleared after detaching.
5417
+ * @private
5418
+ * @returns {void}
5419
+ */
5420
+ private stopListeningForMercuryEvents() {
5421
+ if (this.mercuryOnlineHandler) {
5422
+ // @ts-ignore
5423
+ this.webex.internal.mercury.off(ONLINE, this.mercuryOnlineHandler);
5424
+ this.mercuryOnlineHandler = undefined;
5425
+ }
5426
+ if (this.mercuryOfflineHandler) {
5427
+ // @ts-ignore
5428
+ this.webex.internal.mercury.off(OFFLINE, this.mercuryOfflineHandler);
5429
+ this.mercuryOfflineHandler = undefined;
5430
+ }
5059
5431
  }
5060
5432
 
5061
5433
  /**
@@ -5079,6 +5451,7 @@ export default class Meeting extends StatelessWebexPlugin {
5079
5451
  );
5080
5452
 
5081
5453
  this.receiveSlotManager.reset();
5454
+
5082
5455
  this.mediaProperties.webrtcMediaConnection.close();
5083
5456
  this.mediaProperties.unsetPeerConnection();
5084
5457
  this.sendSlotManager.reset();
@@ -5366,7 +5739,7 @@ export default class Meeting extends StatelessWebexPlugin {
5366
5739
  } = {}
5367
5740
  ) {
5368
5741
  const {mediaOptions, joinOptions = {}} = options;
5369
- const {isRetry, prevJoinResponse} = this.joinWithMediaRetryInfo;
5742
+ const {retryCount, prevJoinResponse, prevError} = this.joinWithMediaRetryInfo;
5370
5743
 
5371
5744
  if (!mediaOptions?.allowMediaInLobby) {
5372
5745
  return Promise.reject(
@@ -5377,9 +5750,6 @@ export default class Meeting extends StatelessWebexPlugin {
5377
5750
 
5378
5751
  LoggerProxy.logger.info('Meeting:index#joinWithMedia called');
5379
5752
 
5380
- let joined = false;
5381
- let joinResponse = prevJoinResponse;
5382
-
5383
5753
  /* Before we do anything, check if RTCPeerConnection is available. Normally this is checked
5384
5754
  by addMediaInternal() itself when creating the media connection, but since joinWithMedia()
5385
5755
  is a convenience method that does both join() and addMedia(), we want to fail fast here
@@ -5392,12 +5762,28 @@ export default class Meeting extends StatelessWebexPlugin {
5392
5762
  );
5393
5763
  }
5394
5764
 
5765
+ /* While we're trying to join, we may fail and be doing a retry. In that case,
5766
+ we sometimes get dropped by Locus as a result of the 1st failed attempt.
5767
+ That notification from Locus needs to be ignored, otherwise it causes the meeting to be
5768
+ cleaned up and prevents the retry from running correctly.
5769
+ */
5770
+ this.locusInfo.suspendDestroyMeeting(true);
5771
+
5772
+ let joined = false;
5773
+ let joinResponse = prevJoinResponse;
5774
+
5775
+ const shouldJoin =
5776
+ !joinResponse || // first try, when the join response is empty
5777
+ (prevError && prevError instanceof UserNotJoinedError) || // last try failed with UserNotJoinedError
5778
+ this.isErrorMeaningLocusDroppedUs(prevError) ||
5779
+ MeetingUtil.isUserInLeftState(this.locusInfo); // locus dropped the connection before we can re-try addMedia
5780
+
5395
5781
  try {
5396
5782
  let turnServerInfo;
5397
5783
  let turnDiscoverySkippedReason;
5398
5784
  let forceTurnDiscovery = false;
5399
5785
 
5400
- if (!joinResponse) {
5786
+ if (shouldJoin) {
5401
5787
  // This is the 1st attempt or a retry after join request failed -> we need to do a join with TURN discovery
5402
5788
 
5403
5789
  const turnDiscoveryRequest = await this.roap.generateTurnDiscoveryRequestMessage(
@@ -5436,16 +5822,24 @@ export default class Meeting extends StatelessWebexPlugin {
5436
5822
  joined = true;
5437
5823
  }
5438
5824
 
5825
+ const shouldRetryMediaWithOnlyTurnTLS = await this.shouldRetryMediaWithOnlyTurnTLS(prevError);
5826
+
5439
5827
  const mediaResponse = await this.addMediaInternal(
5440
5828
  () => {
5441
- return this.joinWithMediaRetryInfo.isRetry ? 'JOIN_MEETING_FINAL' : 'JOIN_MEETING_RETRY';
5829
+ // callback is not called when UserNotJoinedError is thrown
5830
+ return this.joinWithMediaRetryInfo.retryCount >= 1
5831
+ ? 'JOIN_MEETING_FINAL'
5832
+ : 'JOIN_MEETING_RETRY';
5442
5833
  },
5443
- turnServerInfo,
5444
5834
  forceTurnDiscovery,
5835
+ turnServerInfo,
5836
+ shouldRetryMediaWithOnlyTurnTLS ? 'relay' : undefined,
5445
5837
  mediaOptions
5446
5838
  );
5447
5839
 
5448
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
5840
+ this.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
5841
+
5842
+ this.locusInfo.suspendDestroyMeeting(false);
5449
5843
 
5450
5844
  return {
5451
5845
  join: joinResponse,
@@ -5459,8 +5853,12 @@ export default class Meeting extends StatelessWebexPlugin {
5459
5853
 
5460
5854
  this.roap.abortTurnDiscovery();
5461
5855
 
5462
- // if this was the first attempt, let's do a retry
5463
- let shouldRetry = !isRetry;
5856
+ // let's do a retry (but not on 1-1 calls, because the flow would get too complicated)
5857
+ let shouldRetry =
5858
+ !MeetingsUtil.isOneOnOneCall(this.locusInfo.parsedLocus) &&
5859
+ (retryCount < 1 ||
5860
+ ((error instanceof UserNotJoinedError || this.isErrorMeaningLocusDroppedUs(error)) &&
5861
+ retryCount < JOIN_WITH_MEDIA_RETRY_MAX_COUNT));
5464
5862
 
5465
5863
  if (
5466
5864
  CallDiagnosticUtils.isSdpOfferCreationError(error) ||
@@ -5485,8 +5883,8 @@ export default class Meeting extends StatelessWebexPlugin {
5485
5883
  });
5486
5884
  }
5487
5885
 
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)) {
5886
+ // we only want to call leave if join was successful, and we won't be doing any more retries
5887
+ if (joined && !shouldRetry) {
5490
5888
  try {
5491
5889
  await this.leave({resourceId: joinOptions?.resourceId, reason: 'joinWithMedia failure'});
5492
5890
  } catch (e) {
@@ -5503,7 +5901,7 @@ export default class Meeting extends StatelessWebexPlugin {
5503
5901
  reason: error.message,
5504
5902
  stack: error.stack,
5505
5903
  leaveErrorReason: leaveError?.message,
5506
- isRetry,
5904
+ isRetry: retryCount > 0,
5507
5905
  },
5508
5906
  {
5509
5907
  type: error.name,
@@ -5512,15 +5910,28 @@ export default class Meeting extends StatelessWebexPlugin {
5512
5910
 
5513
5911
  if (shouldRetry) {
5514
5912
  LoggerProxy.logger.warn('Meeting:index#joinWithMedia --> retrying call to joinWithMedia');
5515
- this.joinWithMediaRetryInfo.isRetry = true;
5913
+ this.joinWithMediaRetryInfo.retryCount = retryCount + 1;
5516
5914
  this.joinWithMediaRetryInfo.prevJoinResponse = joinResponse;
5915
+ this.joinWithMediaRetryInfo.prevError = error;
5916
+ if (!this.joinWithMediaRetryInfo.firstError) {
5917
+ this.joinWithMediaRetryInfo.firstError = error;
5918
+ }
5517
5919
 
5518
5920
  return this.joinWithMedia(options);
5519
5921
  }
5520
5922
 
5521
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
5923
+ const {firstError} = this.joinWithMediaRetryInfo;
5522
5924
 
5523
- throw error;
5925
+ this.joinWithMediaRetryInfo = {
5926
+ retryCount: 0,
5927
+ prevJoinResponse: undefined,
5928
+ firstError: undefined,
5929
+ prevError: undefined,
5930
+ };
5931
+
5932
+ this.locusInfo.suspendDestroyMeeting(false);
5933
+
5934
+ throw firstError ?? error;
5524
5935
  }
5525
5936
  }
5526
5937
 
@@ -5758,7 +6169,23 @@ export default class Meeting extends StatelessWebexPlugin {
5758
6169
  */
5759
6170
  private processLocusLLMEvent = (event: LocusLLMEvent): void => {
5760
6171
  if (event.data.eventType === LOCUSEVENT.HASH_TREE_DATA_UPDATED) {
6172
+ // @ts-ignore
6173
+ if (this.config.experimental.storeLocusHashTreeEventsForDebugging) {
6174
+ storeEventForDebugging('llm', event.data);
6175
+ }
6176
+
6177
+ const {trackingId} = event;
6178
+
5761
6179
  this.locusInfo.parse(this, event.data);
6180
+
6181
+ // Only the client whose /sync request tracking id matches the tracking id echoed back on this
6182
+ // LLM message should emit client.locus.sync.complete. The tracking id lives at the top level
6183
+ // of the received LLM event envelope. When it is absent there is nothing to correlate, so
6184
+ // skip. onLocusSyncLlmMessage records the LLM arrival time and is a no-op unless a stored
6185
+ // record for this meeting matches the tracking id.
6186
+ if (trackingId) {
6187
+ this.onLocusSyncLlmMessage(this.id, trackingId);
6188
+ }
5762
6189
  } else {
5763
6190
  LoggerProxy.logger.warn(
5764
6191
  `Meeting:index#processLocusLLMEvent --> Unknown event type: ${event.data.eventType}`
@@ -5766,6 +6193,31 @@ export default class Meeting extends StatelessWebexPlugin {
5766
6193
  }
5767
6194
  };
5768
6195
 
6196
+ /**
6197
+ * Verifies the relay event was delivered for the active LLM session binding.
6198
+ * @param {RelayEvent} event Event object coming from LLM Connection
6199
+ * @returns {boolean}
6200
+ */
6201
+ private isRelayEventRouteValid(event: RelayEvent): boolean {
6202
+ const route = event?.headers?.route;
6203
+
6204
+ if (!route) {
6205
+ return true;
6206
+ }
6207
+
6208
+ const {llm} = (this as any).webex.internal;
6209
+ const isPracticeSession = llm.isConnected(LLM_PRACTICE_SESSION);
6210
+ const expectedBinding = isPracticeSession
6211
+ ? llm.getBinding(LLM_PRACTICE_SESSION)
6212
+ : llm.getBinding();
6213
+
6214
+ if (!expectedBinding || route === expectedBinding) {
6215
+ return true;
6216
+ }
6217
+
6218
+ return false;
6219
+ }
6220
+
5769
6221
  /**
5770
6222
  * Callback called when a relay event is received from meeting LLM Connection
5771
6223
  * @param {RelayEvent} e Event object coming from LLM Connection
@@ -5773,6 +6225,9 @@ export default class Meeting extends StatelessWebexPlugin {
5773
6225
  * @returns {void}
5774
6226
  */
5775
6227
  private processRelayEvent = (e: RelayEvent): void => {
6228
+ if (!this.isRelayEventRouteValid(e)) {
6229
+ return;
6230
+ }
5776
6231
  switch (e.data.relayType) {
5777
6232
  case REACTION_RELAY_TYPES.REACTION:
5778
6233
  if (
@@ -5781,7 +6236,7 @@ export default class Meeting extends StatelessWebexPlugin {
5781
6236
  this.isReactionsSupported()
5782
6237
  ) {
5783
6238
  const member = this.members.membersCollection.get(e.data.sender.participantId);
5784
- if (!member) {
6239
+ if (!member && !this.locusInfo?.info?.isWebinar) {
5785
6240
  // @ts-ignore -- fix type
5786
6241
  LoggerProxy.logger.warn(
5787
6242
  `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 +6244,7 @@ export default class Meeting extends StatelessWebexPlugin {
5789
6244
  break;
5790
6245
  }
5791
6246
 
5792
- const {name} = member;
6247
+ const name = (member && member.name) || e.data.sender.displayName;
5793
6248
  const processedReaction: ProcessedReaction = {
5794
6249
  reaction: e.data.reaction,
5795
6250
  sender: {
@@ -5818,37 +6273,35 @@ export default class Meeting extends StatelessWebexPlugin {
5818
6273
  * @returns {void}
5819
6274
  */
5820
6275
  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
- );
6276
+ // @ts-ignore
6277
+ this.webex.internal.voicea.off(
6278
+ VOICEAEVENTS.VOICEA_ANNOUNCEMENT,
6279
+ this.voiceaListenerCallbacks[VOICEAEVENTS.VOICEA_ANNOUNCEMENT]
6280
+ );
5827
6281
 
5828
- // @ts-ignore
5829
- this.webex.internal.voicea.off(
5830
- VOICEAEVENTS.CAPTIONS_TURNED_ON,
5831
- this.voiceaListenerCallbacks[VOICEAEVENTS.CAPTIONS_TURNED_ON]
5832
- );
6282
+ // @ts-ignore
6283
+ this.webex.internal.voicea.off(
6284
+ VOICEAEVENTS.CAPTIONS_TURNED_ON,
6285
+ this.voiceaListenerCallbacks[VOICEAEVENTS.CAPTIONS_TURNED_ON]
6286
+ );
5833
6287
 
5834
- // @ts-ignore
5835
- this.webex.internal.voicea.off(
5836
- VOICEAEVENTS.EVA_COMMAND,
5837
- this.voiceaListenerCallbacks[VOICEAEVENTS.EVA_COMMAND]
5838
- );
6288
+ // @ts-ignore
6289
+ this.webex.internal.voicea.off(
6290
+ VOICEAEVENTS.EVA_COMMAND,
6291
+ this.voiceaListenerCallbacks[VOICEAEVENTS.EVA_COMMAND]
6292
+ );
5839
6293
 
5840
- // @ts-ignore
5841
- this.webex.internal.voicea.off(
5842
- VOICEAEVENTS.NEW_CAPTION,
5843
- this.voiceaListenerCallbacks[VOICEAEVENTS.NEW_CAPTION]
5844
- );
6294
+ // @ts-ignore
6295
+ this.webex.internal.voicea.off(
6296
+ VOICEAEVENTS.NEW_CAPTION,
6297
+ this.voiceaListenerCallbacks[VOICEAEVENTS.NEW_CAPTION]
6298
+ );
5845
6299
 
5846
- // @ts-ignore
5847
- this.webex.internal.voicea.deregisterEvents();
6300
+ // @ts-ignore
6301
+ this.webex.internal.voicea.deregisterEvents();
5848
6302
 
5849
- this.areVoiceaEventsSetup = false;
5850
- this.triggerStopReceivingTranscriptionEvent();
5851
- }
6303
+ this.areVoiceaEventsSetup = false;
6304
+ this.triggerStopReceivingTranscriptionEvent();
5852
6305
  }
5853
6306
 
5854
6307
  /**
@@ -5872,6 +6325,31 @@ export default class Meeting extends StatelessWebexPlugin {
5872
6325
  );
5873
6326
  }
5874
6327
 
6328
+ /**
6329
+ * Restores LLM subchannel subscriptions after reconnect when captions are active.
6330
+ * @returns {void}
6331
+ */
6332
+ private restoreLLMSubscriptionsIfNeeded(): void {
6333
+ try {
6334
+ const keepTranscriptionSubscribed =
6335
+ // @ts-ignore
6336
+ this.webex.internal.voicea?.getKeepTranscriptionSubscribed?.();
6337
+
6338
+ if (!keepTranscriptionSubscribed) {
6339
+ return;
6340
+ }
6341
+
6342
+ // @ts-ignore
6343
+ this.webex.internal.voicea.updateSubchannelSubscriptions({subscribe: ['transcription']});
6344
+ } catch (error) {
6345
+ const msg = error?.message || String(error);
6346
+
6347
+ LoggerProxy.logger.warn(
6348
+ `Meeting:index#restoreLLMSubscriptionsIfNeeded --> failed to restore subscriptions after LLM online: ${msg}`
6349
+ );
6350
+ }
6351
+ }
6352
+
5875
6353
  /**
5876
6354
  * This is a callback for the LLM event that is triggered when it comes online
5877
6355
  * This method in turn will trigger an event to the developers that the LLM is connected
@@ -5880,8 +6358,9 @@ export default class Meeting extends StatelessWebexPlugin {
5880
6358
  * @returns {null}
5881
6359
  */
5882
6360
  private handleLLMOnline = (): void => {
5883
- // @ts-ignore
5884
- this.webex.internal.llm.off('online', this.handleLLMOnline);
6361
+ this.restoreLLMSubscriptionsIfNeeded();
6362
+ this.locusInfo.syncAllHashTreeDatasets({onlyLLM: true});
6363
+
5885
6364
  Trigger.trigger(
5886
6365
  this,
5887
6366
  {
@@ -6109,11 +6588,14 @@ export default class Meeting extends StatelessWebexPlugin {
6109
6588
  return Promise.reject(error);
6110
6589
  })
6111
6590
  .then((join) => {
6591
+ this.saveDataChannelToken(join);
6112
6592
  // @ts-ignore - config coming from registerPlugin
6113
6593
  if (this.config.enableAutomaticLLM) {
6594
+ // @ts-ignore
6595
+ this.webex.internal.llm.off('online', this.handleLLMOnline);
6114
6596
  // @ts-ignore
6115
6597
  this.webex.internal.llm.on('online', this.handleLLMOnline);
6116
- this.updateLLMConnection()
6598
+ this.updateLLMConnection({isInitialJoinPhase: true})
6117
6599
  .catch((error) => {
6118
6600
  LoggerProxy.logger.error(
6119
6601
  'Meeting:index#join --> Transcription Socket Connection Failed',
@@ -6177,26 +6659,275 @@ export default class Meeting extends StatelessWebexPlugin {
6177
6659
  }
6178
6660
  }
6179
6661
 
6662
+ /**
6663
+ * Removes LLM event listeners and clears the health check timer.
6664
+ * Must be called before Locus /leave to avoid unnecessary syncs triggered
6665
+ * by events received while leaving (per Locus team recommendation).
6666
+ * Idempotent: safe to call multiple times; .off() is a no-op when no
6667
+ * matching listener is registered.
6668
+ * @private
6669
+ * @returns {void}
6670
+ */
6671
+ private stopListeningForLLMEvents() {
6672
+ // @ts-ignore - fix types
6673
+ this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6674
+ // @ts-ignore - fix types
6675
+ this.webex.internal.llm.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6676
+ this.clearLLMHealthCheckTimer();
6677
+ }
6678
+
6679
+ /**
6680
+ * Stops listening on every event bus (LLM, Mercury, voicea/transcription,
6681
+ * annotation) that could otherwise deliver events to this meeting while
6682
+ * Locus is processing /leave or /end. Per the Locus team recommendation,
6683
+ * this must run before the Locus request is dispatched to avoid
6684
+ * unnecessary syncs triggered by in-flight events.
6685
+ *
6686
+ * Voicea (transcription) subscribes to llm 'event:relay.event' internally,
6687
+ * and the annotation plugin subscribes to both mercury and llm, so both
6688
+ * must be torn down alongside the direct LLM/Mercury listeners.
6689
+ *
6690
+ * Idempotent: safe to call multiple times; .off() is a no-op when no
6691
+ * matching listener is registered, and stopTranscription is guarded.
6692
+ * @private
6693
+ * @returns {void}
6694
+ */
6695
+ private stopListeningForMeetingEvents() {
6696
+ this.stopListeningForLLMEvents();
6697
+ this.stopListeningForMercuryEvents();
6698
+ if (this.transcription) {
6699
+ this.stopTranscription();
6700
+ this.transcription = undefined;
6701
+ }
6702
+ this.annotation.deregisterEvents();
6703
+ }
6704
+
6705
+ /**
6706
+ * Disconnects and cleans up the default LLM session listeners/timers.
6707
+ *
6708
+ * Ownership-aware: only calls `disconnectLLM` when this meeting is the
6709
+ * current owner of the default LLM session (or when no owner is recorded).
6710
+ * Event listeners belonging to this meeting instance are always detached
6711
+ * so they do not receive another meeting's relay events.
6712
+ *
6713
+ * @param {Object} options
6714
+ * @param {boolean} [options.removeOnlineListener=true] removes the one-time online listener
6715
+ * @param {boolean} [options.throwOnError=true] rethrows disconnect errors when true
6716
+ * @returns {Promise<void>}
6717
+ */
6718
+ private cleanupLLMConneciton = async ({
6719
+ removeOnlineListener = true,
6720
+ throwOnError = true,
6721
+ }: {
6722
+ removeOnlineListener?: boolean;
6723
+ throwOnError?: boolean;
6724
+ } = {}): Promise<void> => {
6725
+ // @ts-ignore - Fix type
6726
+ // @ts-ignore - Fix type
6727
+ const {currentOwner, isOwner} = this.webex.internal.llm.resolveSessionOwnership(
6728
+ this.id,
6729
+ LLM_DEFAULT_SESSION
6730
+ );
6731
+
6732
+ try {
6733
+ if (isOwner) {
6734
+ // @ts-ignore - Fix type
6735
+ await this.webex.internal.llm.disconnectLLM(
6736
+ {
6737
+ code: 3050,
6738
+ reason: 'done (permanent)',
6739
+ },
6740
+ LLM_DEFAULT_SESSION,
6741
+ this.id
6742
+ );
6743
+ } else {
6744
+ LoggerProxy.logger.info(
6745
+ `Meeting:index#cleanupLLMConneciton --> skipping disconnect; LLM owned by meeting ${currentOwner}, not ${this.id}`
6746
+ );
6747
+ }
6748
+ } catch (error) {
6749
+ LoggerProxy.logger.error(
6750
+ 'Meeting:index#cleanupLLMConneciton --> Failed to disconnect default LLM session',
6751
+ error
6752
+ );
6753
+
6754
+ if (throwOnError) {
6755
+ throw error;
6756
+ }
6757
+ } finally {
6758
+ if (removeOnlineListener) {
6759
+ // @ts-ignore - Fix type
6760
+ this.webex.internal.llm.off('online', this.handleLLMOnline);
6761
+ }
6762
+ this.stopListeningForLLMEvents();
6763
+
6764
+ // Re-check ownership after awaiting disconnectLLM. If ownership changed
6765
+ // while cleanup was in flight, do not clear another meeting's owner tag.
6766
+ if (isOwner) {
6767
+ const {currentOwner: currentOwnerAfterCleanup} =
6768
+ // @ts-ignore - Fix type
6769
+ this.webex.internal.llm.resolveSessionOwnership(this.id, LLM_DEFAULT_SESSION);
6770
+
6771
+ if (currentOwnerAfterCleanup === this.id) {
6772
+ // @ts-ignore - Fix type
6773
+ this.webex.internal.llm.setOwnerMeetingId?.(undefined);
6774
+ }
6775
+ }
6776
+ }
6777
+ };
6778
+
6779
+ /**
6780
+ * Clears data channel tokens associated with this meeting ownership.
6781
+ * Ownership checks are enforced in internal-plugin-llm.
6782
+ * @returns {void}
6783
+ */
6784
+ clearDataChannelToken(): void {
6785
+ // @ts-ignore
6786
+ this.webex.internal.llm.clearDatachannelToken(LLM_DEFAULT_SESSION, this.id);
6787
+ // @ts-ignore
6788
+ this.webex.internal.llm.clearDatachannelToken(LLM_PRACTICE_SESSION, this.id);
6789
+ }
6790
+
6791
+ /**
6792
+ * Saves the data channel tokens from the join response into LLM so that
6793
+ * updateLLMConnection / updatePSDataChannel don't need to fetch them from locusInfo.
6794
+ * @param {Object} join - The parsed join response (from MeetingUtil.parseLocusJoin)
6795
+ * @returns {void}
6796
+ */
6797
+ saveDataChannelToken(join: any): void {
6798
+ const datachannelToken = join?.locus?.self?.datachannelToken;
6799
+ const practiceSessionDatachannelToken = join?.locus?.self?.practiceSessionDatachannelToken;
6800
+
6801
+ if (datachannelToken) {
6802
+ // @ts-ignore
6803
+ this.webex.internal.llm.setDatachannelToken(datachannelToken, LLM_DEFAULT_SESSION, this.id);
6804
+ }
6805
+
6806
+ if (practiceSessionDatachannelToken) {
6807
+ // @ts-ignore
6808
+ this.webex.internal.llm.setDatachannelToken(
6809
+ practiceSessionDatachannelToken,
6810
+ LLM_PRACTICE_SESSION,
6811
+ this.id
6812
+ );
6813
+ }
6814
+ }
6815
+
6816
+ /**
6817
+ * Ensures default-session data channel token exists after lobby admission.
6818
+ * Some lobby users do not receive a token until they are admitted.
6819
+ * @returns {Promise<boolean>} true when a new token is fetched and cached
6820
+ */
6821
+ private async ensureDefaultDatachannelTokenAfterAdmit(): Promise<boolean> {
6822
+ try {
6823
+ // @ts-ignore
6824
+ const datachannelToken = this.webex.internal.llm.getDatachannelToken(
6825
+ LLM_DEFAULT_SESSION,
6826
+ this.id
6827
+ );
6828
+ // @ts-ignore
6829
+ const isDataChannelTokenEnabled = await this.webex.internal.llm.isDataChannelTokenEnabled();
6830
+
6831
+ if (!isDataChannelTokenEnabled || datachannelToken) {
6832
+ return false;
6833
+ }
6834
+
6835
+ const response = await this.meetingRequest.fetchDatachannelToken({
6836
+ locusUrl: this.locusUrl,
6837
+ requestingParticipantId: this.members.selfId,
6838
+ isPracticeSession: false,
6839
+ });
6840
+ const fetchedDatachannelToken = response?.body?.datachannelToken;
6841
+
6842
+ if (!fetchedDatachannelToken) {
6843
+ return false;
6844
+ }
6845
+
6846
+ // @ts-ignore
6847
+ this.webex.internal.llm.setDatachannelToken(
6848
+ fetchedDatachannelToken,
6849
+ LLM_DEFAULT_SESSION,
6850
+ this.id
6851
+ );
6852
+
6853
+ return true;
6854
+ } catch (error) {
6855
+ const msg = error?.message || String(error);
6856
+
6857
+ LoggerProxy.logger.warn(
6858
+ `Meeting:index#ensureDefaultDatachannelTokenAfterAdmit --> failed to proactively fetch default data channel token after admit: ${msg}`,
6859
+ {statusCode: error?.statusCode}
6860
+ );
6861
+
6862
+ return false;
6863
+ }
6864
+ }
6865
+
6180
6866
  /**
6181
6867
  * Connects to low latency mercury and reconnects if the address has changed
6182
6868
  * It will also disconnect if called when the meeting has ended
6183
- * @param {String} datachannelUrl
6869
+ * @param {Object} [options]
6870
+ * @param {boolean} [options.isInitialJoinPhase] true when called from initial join flow
6184
6871
  * @returns {Promise}
6185
6872
  */
6186
- async updateLLMConnection() {
6873
+ async updateLLMConnection({isInitialJoinPhase = false}: {isInitialJoinPhase?: boolean} = {}) {
6187
6874
  // @ts-ignore - Fix type
6188
- const {url, info: {datachannelUrl, practiceSessionDatachannelUrl} = {}} = this.locusInfo;
6875
+ const {url = undefined, info: {datachannelUrl = undefined} = {}} = this.locusInfo || {};
6189
6876
 
6190
6877
  const isJoined = this.isJoined();
6191
6878
 
6192
- // webinar panelist should use new data channel in practice session
6193
- const dataChannelUrl =
6194
- this.webinar.isJoinPracticeSessionDataChannel() && practiceSessionDatachannelUrl
6195
- ? practiceSessionDatachannelUrl
6196
- : datachannelUrl;
6879
+ const dataChannelUrl = datachannelUrl;
6880
+
6881
+ // Ownership guard: when the default LLM session is already connected and
6882
+ // owned by a *different* Meeting instance, do not disconnect or reconfigure
6883
+ // it. Another meeting's `updateLLMConnection` must be ignored here to
6884
+ // avoid killing the socket it relies on. We only proceed to manage the
6885
+ // connection when this meeting is the current owner, or when no owner is
6886
+ // set yet (first claim).
6887
+ // @ts-ignore - Fix type
6888
+ const {currentOwner} = this.webex.internal.llm.resolveSessionOwnership(
6889
+ this.id,
6890
+ LLM_DEFAULT_SESSION
6891
+ );
6197
6892
 
6893
+ // Capture connectivity before any reconnect attempt. If LLM was already
6894
+ // connected, we must respect current ownership. If it was disconnected,
6895
+ // this flow may reclaim stale owner tags after a fresh connect.
6198
6896
  // @ts-ignore - Fix type
6199
- if (this.webex.internal.llm.isConnected()) {
6897
+ const wasConnected = this.webex.internal.llm.isConnected();
6898
+
6899
+ // Prefer ownership-scoped token read. For disconnected stale-owner reclaim
6900
+ // flows, fallback to ownerless read so initial register can still carry a
6901
+ // token and recover from stale ownership without 401/403 dead-end.
6902
+ // @ts-ignore - Fix type
6903
+ let datachannelToken = this.webex.internal.llm.getDatachannelToken(
6904
+ LLM_DEFAULT_SESSION,
6905
+ this.id
6906
+ );
6907
+
6908
+ if (!datachannelToken && !wasConnected && currentOwner && currentOwner !== this.id) {
6909
+ // @ts-ignore - Fix type
6910
+ datachannelToken = this.webex.internal.llm.getDatachannelToken(LLM_DEFAULT_SESSION);
6911
+ }
6912
+
6913
+ // @ts-ignore - Fix type
6914
+ if (wasConnected) {
6915
+ if (currentOwner && currentOwner !== this.id) {
6916
+ // Another meeting owns the live LLM socket. We must not disconnect
6917
+ // or reconfigure it -- doing so would tear down a session the
6918
+ // owning meeting still relies on. Locus/datachannel URL mismatch is
6919
+ // expected here (each meeting has its own locus URL) and is NOT a
6920
+ // valid signal of staleness, so we never reclaim from this path.
6921
+ // The only safe reclaim mechanism is the `finally`-block owner-tag
6922
+ // release in `cleanupLLMConneciton`, which fires when this meeting
6923
+ // itself is being torn down.
6924
+ LoggerProxy.logger.info(
6925
+ `Meeting:index#updateLLMConnection --> skipping; LLM owned by meeting ${currentOwner}, not ${this.id}`
6926
+ );
6927
+
6928
+ return undefined;
6929
+ }
6930
+
6200
6931
  if (
6201
6932
  // @ts-ignore - Fix type
6202
6933
  url === this.webex.internal.llm.getLocusUrl() &&
@@ -6206,31 +6937,63 @@ export default class Meeting extends StatelessWebexPlugin {
6206
6937
  ) {
6207
6938
  return undefined;
6208
6939
  }
6209
- // @ts-ignore - Fix type
6210
- await this.webex.internal.llm.disconnectLLM(
6211
- isJoined
6212
- ? {
6213
- code: 3050,
6214
- reason: 'done (permanent)',
6215
- }
6216
- : undefined
6217
- );
6218
- // @ts-ignore - Fix type
6219
- this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6220
- // @ts-ignore - Fix type
6221
- this.webex.internal.llm.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6222
-
6223
- this.clearLLMHealthCheckTimer();
6940
+ await this.cleanupLLMConneciton({removeOnlineListener: false});
6224
6941
  }
6225
6942
 
6226
6943
  if (!isJoined) {
6227
6944
  return undefined;
6228
6945
  }
6229
6946
 
6947
+ // Bind refresh handler before registration so interceptor-triggered token
6948
+ // refresh during register POST can resolve a valid handler.
6949
+ // Prefer this meeting as owner, but allow owner-less fallback when a stale
6950
+ // foreign owner tag is present on a disconnected session.
6951
+ const refreshHandlerOwnerMeetingId =
6952
+ currentOwner && currentOwner !== this.id ? undefined : this.id;
6953
+ const shouldAlignRefreshHandlerAfterOwnershipClaim = refreshHandlerOwnerMeetingId !== this.id;
6954
+ // @ts-ignore - Fix type
6955
+ this.webex.internal.llm.setRefreshHandler(
6956
+ () => this.refreshDataChannelToken(),
6957
+ LLM_DEFAULT_SESSION,
6958
+ refreshHandlerOwnerMeetingId
6959
+ );
6960
+
6230
6961
  // @ts-ignore - Fix type
6231
6962
  return this.webex.internal.llm
6232
- .registerAndConnect(url, dataChannelUrl)
6963
+ .registerAndConnect(url, dataChannelUrl, datachannelToken)
6233
6964
  .then((registerAndConnectResult) => {
6965
+ this.locusInfo.syncAllHashTreeDatasets({onlyLLM: true});
6966
+ // Record ownership of the default LLM session for this meeting so
6967
+ // subsequent cross-meeting `updateLLMConnection` / `cleanupLLMConneciton`
6968
+ // calls can detect and skip work that doesn't belong to them.
6969
+ // @ts-ignore - Fix type
6970
+ const {isOwner} = this.webex.internal.llm.resolveSessionOwnership(
6971
+ this.id,
6972
+ LLM_DEFAULT_SESSION
6973
+ );
6974
+ const canReclaimAfterDisconnectedStart = !wasConnected;
6975
+
6976
+ // Refresh handler is pre-bound before registerAndConnect so token
6977
+ // refresh can work even during the registration request itself.
6978
+ if (isOwner || canReclaimAfterDisconnectedStart) {
6979
+ // Record ownership of the default LLM session for this meeting so
6980
+ // subsequent cross-meeting `updateLLMConnection` / `cleanupLLMConneciton`
6981
+ // calls can detect and skip work that doesn't belong to them.
6982
+ // @ts-ignore - Fix type
6983
+ this.webex.internal.llm.setOwnerMeetingId?.(this.id);
6984
+
6985
+ // If we pre-bound refresh ownerlessly (stale-owner reclaim path),
6986
+ // align the handler with the newly claimed owner immediately after
6987
+ // ownership is updated.
6988
+ if (shouldAlignRefreshHandlerAfterOwnershipClaim) {
6989
+ // @ts-ignore - Fix type
6990
+ this.webex.internal.llm.setRefreshHandler(
6991
+ () => this.refreshDataChannelToken(),
6992
+ LLM_DEFAULT_SESSION,
6993
+ this.id
6994
+ );
6995
+ }
6996
+ }
6234
6997
  // @ts-ignore - Fix type
6235
6998
  this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6236
6999
  // @ts-ignore - Fix type
@@ -6245,10 +7008,114 @@ export default class Meeting extends StatelessWebexPlugin {
6245
7008
 
6246
7009
  this.startLLMHealthCheckTimer();
6247
7010
 
7011
+ if (registerAndConnectResult) {
7012
+ if (isInitialJoinPhase) {
7013
+ this.sendLLMConnectMetric(registerAndConnectResult);
7014
+ }
7015
+
7016
+ this.breakouts?.trigger(BREAKOUTS.EVENTS.LLM_CONNECT_RESPONSE, {
7017
+ meeting: this,
7018
+ llmLatency: registerAndConnectResult,
7019
+ });
7020
+ }
7021
+
6248
7022
  return Promise.resolve(registerAndConnectResult);
7023
+ })
7024
+ .catch((error) => {
7025
+ // Prefer the partial timing registerAndConnect attaches when register succeeded but the
7026
+ // websocket connect() failed, so a ws failure isn't misreported as register never completing.
7027
+ const llmLatency = {
7028
+ clientLLMDatachannelResponseTime: error?.timing?.clientLLMDatachannelResponseTime ?? 0,
7029
+ clientLLMWebSocketConnectTime: 0,
7030
+ };
7031
+
7032
+ if (isInitialJoinPhase) {
7033
+ this.sendLLMConnectMetric(llmLatency, error);
7034
+ }
7035
+
7036
+ this.breakouts?.trigger(BREAKOUTS.EVENTS.LLM_CONNECT_RESPONSE, {
7037
+ meeting: this,
7038
+ llmLatency,
7039
+ error,
7040
+ });
7041
+
7042
+ return Promise.reject(error);
6249
7043
  });
6250
7044
  }
6251
7045
 
7046
+ /**
7047
+ * Ensures breakout join response metric with LLM latency is emitted only once per breakout move id.
7048
+ * @param {string | undefined} breakoutMoveId
7049
+ * @param {boolean} [hasLLMLatency=false]
7050
+ * @returns {boolean}
7051
+ */
7052
+ private shouldEmitBreakoutJoinResponseMetric(
7053
+ breakoutMoveId?: string,
7054
+ hasLLMLatency = false
7055
+ ): boolean {
7056
+ if (!breakoutMoveId) {
7057
+ return false;
7058
+ }
7059
+
7060
+ if (!hasLLMLatency) {
7061
+ // When automatic LLM is enabled, updateLLMConnection will emit this same breakout join
7062
+ // response after the LLM connection finishes, including llmLatency and llmWebsocketUrl.
7063
+ // Suppress the earlier non-LLM event to avoid sending two events for the same move id,
7064
+ // where the first one would be missing the LLM-specific fields we want to validate.
7065
+ // @ts-ignore - config coming from registerPlugin
7066
+ return !this.config.enableAutomaticLLM;
7067
+ }
7068
+
7069
+ if (this.emittedBreakoutJoinResponseMoveIds.has(breakoutMoveId)) {
7070
+ return false;
7071
+ }
7072
+
7073
+ this.emittedBreakoutJoinResponseMoveIds.add(breakoutMoveId);
7074
+
7075
+ return true;
7076
+ }
7077
+
7078
+ /**
7079
+ * Sends LLM connect latencies for initial join flow.
7080
+ * @param {RegisterAndConnectTiming} timings
7081
+ * @param {any} [error]
7082
+ * @returns {void}
7083
+ */
7084
+ private sendLLMConnectMetric(timings: RegisterAndConnectTiming, error?: any) {
7085
+ // @ts-ignore
7086
+ const llmWebsocketUrl = this.webex.internal.llm.getWebSocketUrl?.() || undefined;
7087
+ const {clientLLMDatachannelResponseTime = 0, clientLLMWebSocketConnectTime} = timings || {};
7088
+
7089
+ const llmLatency: any = {
7090
+ clientLLMDatachannelResponseTime,
7091
+ };
7092
+
7093
+ if (clientLLMWebSocketConnectTime !== undefined) {
7094
+ llmLatency.clientLLMWebSocketConnectTime = clientLLMWebSocketConnectTime;
7095
+ }
7096
+
7097
+ const payload: any = {
7098
+ identifiers: {
7099
+ llmWebsocketUrl,
7100
+ },
7101
+ llmLatency,
7102
+ };
7103
+
7104
+ const options: any = {
7105
+ meetingId: this.id,
7106
+ ...(error && {rawError: error}),
7107
+ };
7108
+
7109
+ const metricEvent = {
7110
+ name: 'client.llm.connect.response',
7111
+ payload,
7112
+ options,
7113
+ };
7114
+
7115
+ // @ts-ignore
7116
+ this.webex.internal.newMetrics.submitClientEvent(metricEvent);
7117
+ }
7118
+
6252
7119
  /**
6253
7120
  * Use phone for meeting audio
6254
7121
  * @param {String} phoneNumber If provided, it will dial-out using this number. If not provided, dial-in will be used
@@ -6676,16 +7543,32 @@ export default class Meeting extends StatelessWebexPlugin {
6676
7543
  // @ts-ignore
6677
7544
  const cdl = this.webex.internal.newMetrics.callDiagnosticLatencies;
6678
7545
 
7546
+ // Compute the offer->answer latency from when the local SDP offer was generated up to now,
7547
+ // rather than from the stored remote-sdp-received timestamp. That stored timestamp uses
7548
+ // saveFirstTimestampOnly, so if waitForRemoteSDPAnswer() already timed out and submitted a
7549
+ // remote-sdp-received event, the stored value would be pinned to the timeout time and would
7550
+ // under-report an answer that arrives late. This handler fires exactly when the answer is
7551
+ // processed, so Date.now() is the accurate "received" time.
7552
+ // (submitClientEvent below still records the remote-sdp-received timestamp used by the CA
7553
+ // join-time metric, so we don't need to save it here.)
7554
+ const localSdpGeneratedTimestamp = cdl.latencyTimestamps.get(
7555
+ 'client.media-engine.local-sdp-generated'
7556
+ );
7557
+ const localSDPGenRemoteSDPRecv =
7558
+ localSdpGeneratedTimestamp !== undefined
7559
+ ? Date.now() - localSdpGeneratedTimestamp
7560
+ : undefined;
7561
+
6679
7562
  // @ts-ignore
6680
7563
  this.webex.internal.newMetrics.submitClientEvent({
6681
7564
  name: 'client.media-engine.remote-sdp-received',
7565
+ payload: {
7566
+ eventData: {
7567
+ localSDPGenRemoteSDPRecv,
7568
+ },
7569
+ },
6682
7570
  options: {meetingId: this.id},
6683
7571
  });
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
7572
 
6690
7573
  if (this.deferSDPAnswer) {
6691
7574
  this.deferSDPAnswer.resolve();
@@ -7271,23 +8154,104 @@ export default class Meeting extends StatelessWebexPlugin {
7271
8154
  }
7272
8155
  }
7273
8156
  });
8157
+ this.statsAnalyzer.on(StatsAnalyzerEventNames.STATS_UPDATE, (data) => {
8158
+ // Extract srtpCipher from transport stats
8159
+ let srtpCipher: string | undefined;
8160
+ for (const stats of data.stats.values()) {
8161
+ if (stats.type === 'transport' && stats.srtpCipher) {
8162
+ srtpCipher = stats.srtpCipher as string;
8163
+ break;
8164
+ }
8165
+ }
8166
+
8167
+ // Only emit event if srtpCipher has changed
8168
+ if (srtpCipher && srtpCipher !== this.mediaProperties.srtpCipher) {
8169
+ LoggerProxy.logger.info(
8170
+ `Meeting:index#setupStatsAnalyzerEventHandlers --> SRTP cipher changed from ${this.mediaProperties.srtpCipher} to ${srtpCipher}`
8171
+ );
8172
+ this.mediaProperties.srtpCipher = srtpCipher;
8173
+ Trigger.trigger(
8174
+ this,
8175
+ {
8176
+ file: 'meeting/index',
8177
+ function: 'setupStatsAnalyzerEventHandlers',
8178
+ },
8179
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
8180
+ {srtpCipher}
8181
+ );
8182
+ }
8183
+ });
7274
8184
  };
7275
8185
 
7276
8186
  getMediaConnectionDebugId() {
7277
8187
  return `MC-${this.id.substring(0, 4)}`;
7278
8188
  }
7279
8189
 
8190
+ /**
8191
+ * Checks if the error indicates that Locus dropped us from the meeting,
8192
+ * either directly on the error or wrapped inside an AddMediaFailed cause.
8193
+ * This method is meant to be called only with errors thrown by Meeting.addMediaInternal()
8194
+ *
8195
+ * @param {Error} error
8196
+ * @returns {boolean}
8197
+ */
8198
+ private isErrorMeaningLocusDroppedUs(error: Error | undefined): boolean {
8199
+ const statusCode = (error as any)?.statusCode;
8200
+ const causeStatusCode = (error as any)?.cause?.statusCode;
8201
+
8202
+ return (
8203
+ statusCode === 409 || statusCode === 403 || causeStatusCode === 409 || causeStatusCode === 403
8204
+ );
8205
+ }
8206
+
8207
+ /**
8208
+ * Determines if the next media attempt should use only TURN-TLS (iceTransportPolicy='relay').
8209
+ * We do this in the hope that it will minimize the chance of Homer sending DTLS packets on a wrong
8210
+ * transport (as there will be only 1 transport) and dealing with firewalls that let STUN packets through, but block
8211
+ * other UDP traffic.
8212
+ *
8213
+ * For clients landing on video mesh nodes (VMN), reachability might still have successful TLS (to public nodes)
8214
+ * but TURN discovery will result in empty TURN urls array and iceTransportPolicy='relay' will still be overriden to undefined,
8215
+ * see the code in establishMediaConnection()
8216
+ *
8217
+ * @param {Error} prevError - The error from the previous addMedia attempt
8218
+ * @returns {Promise<boolean>}
8219
+ */
8220
+ private async shouldRetryMediaWithOnlyTurnTLS(prevError: Error | undefined): Promise<boolean> {
8221
+ if (
8222
+ this.isMultistream &&
8223
+ prevError instanceof AddMediaFailed &&
8224
+ prevError.isDtlsHandshakeFailure &&
8225
+ prevError.connectionType === 'UDP'
8226
+ ) {
8227
+ const hasTlsReachability =
8228
+ // @ts-ignore
8229
+ await this.webex.meetings.reachability.isAnyClusterReachableViaProtocol('xtls');
8230
+
8231
+ if (hasTlsReachability) {
8232
+ LoggerProxy.logger.info(
8233
+ 'Meeting:index#shouldRetryMediaWithOnlyTurnTLS --> previous attempt failed due to DTLS handshake failure over UDP and TLS reachability is available'
8234
+ );
8235
+
8236
+ return true;
8237
+ }
8238
+ }
8239
+
8240
+ return false;
8241
+ }
8242
+
7280
8243
  /**
7281
8244
  * Creates a webrtc media connection and publishes streams to it
7282
8245
  *
7283
8246
  * @param {Object} turnServerInfo TURN server information
7284
8247
  * @param {BundlePolicy} [bundlePolicy] Bundle policy settings
7285
- * @param {AddMediaOptions} [options] Options for enabling/disabling audio/video
8248
+ * @param {RTCIceTransportPolicy} [iceTransportPolicy] ICE transport policy override
7286
8249
  * @returns {RoapMediaConnection | MultistreamRoapMediaConnection}
7287
8250
  */
7288
8251
  private async createMediaConnection(
7289
8252
  turnServerInfo?: TurnServerInfo,
7290
- bundlePolicy?: BundlePolicy
8253
+ bundlePolicy?: BundlePolicy,
8254
+ iceTransportPolicy?: RTCIceTransportPolicy
7291
8255
  ) {
7292
8256
  this.rtcMetrics = this.isMultistream
7293
8257
  ? // @ts-ignore
@@ -7311,12 +8275,15 @@ export default class Meeting extends StatelessWebexPlugin {
7311
8275
  enableExtmap: this.config.enableExtmap,
7312
8276
  turnServerInfo,
7313
8277
  bundlePolicy,
8278
+ iceTransportPolicy,
7314
8279
  // @ts-ignore - config coming from registerPlugin
7315
8280
  iceCandidatesTimeout: this.config.iceCandidatesGatheringTimeout,
7316
8281
  // @ts-ignore - config coming from registerPlugin
7317
8282
  disableAudioMainDtx: this.config.experimental.disableAudioMainDtx,
7318
8283
  // @ts-ignore - config coming from registerPlugin
7319
8284
  enableAudioTwcc: this.config.enableAudioTwccForMultistream,
8285
+ // @ts-ignore - config coming from registerPlugin
8286
+ enableAv1SlidesSupport: this.config.enableAv1SlidesSupport,
7320
8287
  stopIceGatheringAfterFirstRelayCandidate:
7321
8288
  // @ts-ignore - config coming from registerPlugin
7322
8289
  this.config.stopIceGatheringAfterFirstRelayCandidate,
@@ -7336,6 +8303,7 @@ export default class Meeting extends StatelessWebexPlugin {
7336
8303
  this.mediaProperties.mediaDirection.receiveShare,
7337
8304
  ];
7338
8305
 
8306
+ this.sendSlotManager.reset();
7339
8307
  this.sendSlotManager.createSlot(mc, MediaType.VideoMain, videoEnabled);
7340
8308
  this.sendSlotManager.createSlot(mc, MediaType.AudioMain, audioEnabled);
7341
8309
  this.sendSlotManager.createSlot(mc, MediaType.VideoSlides, shareEnabled);
@@ -7433,9 +8401,9 @@ export default class Meeting extends StatelessWebexPlugin {
7433
8401
  */
7434
8402
  private async waitForMediaConnectionConnected(): Promise<void> {
7435
8403
  try {
7436
- await this.mediaProperties.waitForMediaConnectionConnected();
8404
+ await this.mediaProperties.waitForMediaConnectionConnected(this.correlationId);
7437
8405
  } catch (error) {
7438
- const {iceConnected} = error;
8406
+ const {iceConnected} = error as MediaConnectionAwaiterFailureResult;
7439
8407
 
7440
8408
  if (!this.hasMediaConnectionConnectedAtLeastOnce) {
7441
8409
  // Only send CA event for join flow if we haven't successfully connected media yet
@@ -7475,13 +8443,12 @@ export default class Meeting extends StatelessWebexPlugin {
7475
8443
  });
7476
8444
  }
7477
8445
 
7478
- const timedOutError = new Error(
7479
- `Timed out waiting for media connection to be connected, correlationId=${this.correlationId}`
8446
+ throw new MediaConnectionTimedOutError(
8447
+ `Timed out waiting for media connection to be connected, correlationId=${this.correlationId}`,
8448
+ iceConnected,
8449
+ // keep reference to the original rejected result (which is the object the SDK reports to CA as rawError above)
8450
+ error
7480
8451
  );
7481
-
7482
- timedOutError.cause = error;
7483
-
7484
- throw timedOutError;
7485
8452
  }
7486
8453
  }
7487
8454
 
@@ -7527,12 +8494,12 @@ export default class Meeting extends StatelessWebexPlugin {
7527
8494
  return !member.isSelf && !member.isPairedWithSelf && !member.isAudioMuted;
7528
8495
  });
7529
8496
 
7530
- if (atLeastOneUnmutedOtherMember) {
7531
- this.mediaProperties.sendMediaIssueMetric(
7532
- 'inbound_audio',
7533
- data.issueSubType,
7534
- this.correlationId
7535
- );
8497
+ // we also ignore any issues while we're waiting in the lobby, as we're not receiving any audio yet
8498
+ if (atLeastOneUnmutedOtherMember && !this.isUserUnadmitted) {
8499
+ this.mediaProperties.sendMediaIssueMetric('inbound_audio', data.issueSubType, {
8500
+ correlationId: this.correlationId,
8501
+ isMultistream: this.isMultistream,
8502
+ });
7536
8503
 
7537
8504
  Trigger.trigger(
7538
8505
  this,
@@ -7694,7 +8661,18 @@ export default class Meeting extends StatelessWebexPlugin {
7694
8661
  error
7695
8662
  );
7696
8663
 
7697
- throw new AddMediaFailed(error);
8664
+ const {connectionType, selectedCandidatePairChanges, numTransports} =
8665
+ await this.mediaProperties.getCurrentConnectionInfo();
8666
+
8667
+ const iceConnected = error instanceof MediaConnectionTimedOutError && error.iceConnected;
8668
+
8669
+ throw new AddMediaFailed({
8670
+ cause: error,
8671
+ connectionType,
8672
+ selectedCandidatePairChanges,
8673
+ numTransports,
8674
+ iceConnected,
8675
+ });
7698
8676
  }
7699
8677
  }
7700
8678
 
@@ -7769,7 +8747,21 @@ export default class Meeting extends StatelessWebexPlugin {
7769
8747
  ({turnServerInfo} = await this.doTurnDiscovery(isReconnecting, isForced));
7770
8748
  }
7771
8749
 
7772
- const mc = await this.createMediaConnection(turnServerInfo, bundlePolicy);
8750
+ if (
8751
+ (!turnServerInfo || !turnServerInfo.urls?.length) &&
8752
+ this.addMediaData.iceTransportPolicy === 'relay'
8753
+ ) {
8754
+ LoggerProxy.logger.info(
8755
+ `${LOG_HEADER} cannot do iceTransportPolicy=relay, because there is no turn server info available`
8756
+ );
8757
+ // drop the forced relay policy and use the default, because we don't have a TURN server
8758
+ this.addMediaData.iceTransportPolicy = undefined;
8759
+ }
8760
+ const mediaConnection = await this.createMediaConnection(
8761
+ turnServerInfo,
8762
+ bundlePolicy,
8763
+ this.addMediaData.iceTransportPolicy
8764
+ );
7773
8765
 
7774
8766
  LoggerProxy.logger.info(
7775
8767
  `${LOG_HEADER} media connection created this.isMultistream=${this.isMultistream}`
@@ -7806,7 +8798,7 @@ export default class Meeting extends StatelessWebexPlugin {
7806
8798
  await this.remoteMediaManager.start();
7807
8799
  }
7808
8800
 
7809
- await mc.initiateOffer();
8801
+ await mediaConnection.initiateOffer();
7810
8802
 
7811
8803
  await this.waitForRemoteSDPAnswer();
7812
8804
 
@@ -7874,6 +8866,9 @@ export default class Meeting extends StatelessWebexPlugin {
7874
8866
 
7875
8867
  this.isMultistream = false;
7876
8868
 
8869
+ // reset iceTransportPolicy, because it's only applied for multistream media connections
8870
+ this.addMediaData.iceTransportPolicy = undefined;
8871
+
7877
8872
  if (this.mediaProperties.webrtcMediaConnection) {
7878
8873
  // close peer connection, but don't reset mute state information, because we will want to use it on the retry
7879
8874
  this.closePeerConnections(false);
@@ -7954,6 +8949,8 @@ export default class Meeting extends StatelessWebexPlugin {
7954
8949
  regionCode: this.webex.meetings.geoHintInfo?.regionCode,
7955
8950
  },
7956
8951
  preferTranscoding: !this.isMultistream,
8952
+ getCurrentSelfUrl: () => this.selfUrl,
8953
+ waitForSelfUrlChange: () => this.waitForSelfUrlChange(),
7957
8954
  },
7958
8955
  {
7959
8956
  // @ts-ignore
@@ -7962,6 +8959,41 @@ export default class Meeting extends StatelessWebexPlugin {
7962
8959
  );
7963
8960
  }
7964
8961
 
8962
+ /**
8963
+ * Waits for LocusInfo to update meeting.selfUrl, with a timeout fallback.
8964
+ * @returns {Promise<void>}
8965
+ * @private
8966
+ * @memberof Meeting
8967
+ */
8968
+ private waitForSelfUrlChange(): Promise<void> {
8969
+ if (this.joinWithMediaRetryInfo.retryCount > 0) {
8970
+ /* During joinWithMedia() retries we can get 403/409 from Locus and it doesn't mean
8971
+ * that the selfUrl will change, it is usually caused by Locus dropping us as a result of
8972
+ * media connection failure during joinWithMedia's earlier media connection attempt,
8973
+ * so we don't want to wait for selfUrl change as this would only slow down the join process. */
8974
+ LoggerProxy.logger.info(
8975
+ 'Meeting:index#waitForSelfUrlChange --> joinWithMedia retry in progress, will not wait for selfUrl change'
8976
+ );
8977
+
8978
+ return Promise.resolve();
8979
+ }
8980
+
8981
+ if (!this.promisesWaitingForPropUpdate.selfUrl) {
8982
+ const pendingSelfUrlUpdate = new Defer();
8983
+
8984
+ this.promisesWaitingForPropUpdate.selfUrl = pendingSelfUrlUpdate;
8985
+
8986
+ setTimeout(() => {
8987
+ if (this.promisesWaitingForPropUpdate.selfUrl === pendingSelfUrlUpdate) {
8988
+ delete this.promisesWaitingForPropUpdate.selfUrl;
8989
+ pendingSelfUrlUpdate.resolve();
8990
+ }
8991
+ }, 5000);
8992
+ }
8993
+
8994
+ return this.promisesWaitingForPropUpdate.selfUrl.promise;
8995
+ }
8996
+
7965
8997
  /**
7966
8998
  * Creates a media connection to the server. Media connection is required for sending or receiving any audio/video.
7967
8999
  *
@@ -7973,8 +9005,9 @@ export default class Meeting extends StatelessWebexPlugin {
7973
9005
  addMedia(options: AddMediaOptions = {}): Promise<void> {
7974
9006
  return this.addMediaInternal(
7975
9007
  () => (this.turnServerUsed ? 'JOIN_MEETING_FINAL' : 'JOIN_MEETING_RETRY'),
7976
- undefined,
7977
9008
  false,
9009
+ undefined /* turnServerInfo - it will be fetched via doTurnDiscovery() */,
9010
+ undefined /* iceTransportPolicy - we're relying on the default value */,
7978
9011
  options
7979
9012
  );
7980
9013
  }
@@ -7983,8 +9016,9 @@ export default class Meeting extends StatelessWebexPlugin {
7983
9016
  * Internal version of addMedia() with some more arguments for finer control of its behavior
7984
9017
  *
7985
9018
  * @param {Function} icePhaseCallback - callback to determine the icePhase for CA "client.ice.end" failure events
7986
- * @param {TurnServerInfo} turnServerInfo - TURN server information
7987
9019
  * @param {boolean} forceTurnDiscovery - if true, TURN discovery will be done
9020
+ * @param {TurnServerInfo} turnServerInfo - TURN server information
9021
+ * @param {RTCIceTransportPolicy} [iceTransportPolicy] - ICE transport policy override
7988
9022
  * @param {AddMediaOptions} options - same as options of the public addMedia() method
7989
9023
  * @returns {Promise<void>}
7990
9024
  * @protected
@@ -7992,12 +9026,14 @@ export default class Meeting extends StatelessWebexPlugin {
7992
9026
  */
7993
9027
  protected async addMediaInternal(
7994
9028
  icePhaseCallback: () => string,
7995
- turnServerInfo: TurnServerInfo,
7996
- forceTurnDiscovery,
9029
+ forceTurnDiscovery: boolean,
9030
+ turnServerInfo?: TurnServerInfo,
9031
+ iceTransportPolicy?: RTCIceTransportPolicy,
7997
9032
  options: AddMediaOptions = {}
7998
9033
  ): Promise<void> {
7999
9034
  this.addMediaData.retriedWithTurnServer = false;
8000
9035
  this.addMediaData.icePhaseCallback = icePhaseCallback;
9036
+ this.addMediaData.iceTransportPolicy = iceTransportPolicy;
8001
9037
 
8002
9038
  this.hasMediaConnectionConnectedAtLeastOnce = false;
8003
9039
  const LOG_HEADER = 'Meeting:index#addMedia -->';
@@ -8006,7 +9042,7 @@ export default class Meeting extends StatelessWebexPlugin {
8006
9042
  options
8007
9043
  )}, turnServerInfo=${JSON.stringify(
8008
9044
  turnServerInfo
8009
- )}, forceTurnDiscovery=${forceTurnDiscovery}`
9045
+ )}, forceTurnDiscovery=${forceTurnDiscovery}, iceTransportPolicy=${iceTransportPolicy}`
8010
9046
  );
8011
9047
 
8012
9048
  if (options.allowMediaInLobby !== true && this.meetingState !== FULL_STATE.ACTIVE) {
@@ -8026,6 +9062,7 @@ export default class Meeting extends StatelessWebexPlugin {
8026
9062
  remoteMediaManagerConfig,
8027
9063
  bundlePolicy = 'max-bundle',
8028
9064
  additionalMediaOptions = {},
9065
+ allowPublishMediaInLobby = false,
8029
9066
  } = options;
8030
9067
 
8031
9068
  const {
@@ -8046,7 +9083,6 @@ export default class Meeting extends StatelessWebexPlugin {
8046
9083
  const ipver = MeetingUtil.getIpVersion(this.webex); // used just for metrics
8047
9084
 
8048
9085
  // If the user is unjoined or guest waiting in lobby dont allow the user to addMedia
8049
- // @ts-ignore - isUserUnadmitted coming from SelfUtil
8050
9086
  if (this.isUserUnadmitted && !this.wirelessShare && !this.allowMediaInLobby) {
8051
9087
  throw new UserInLobbyError();
8052
9088
  }
@@ -8091,7 +9127,13 @@ export default class Meeting extends StatelessWebexPlugin {
8091
9127
  this.brbState = createBrbState(this, false);
8092
9128
 
8093
9129
  try {
8094
- await this.setUpLocalStreamReferences(localStreams);
9130
+ // if we're in a lobby and allowPublishMediaInLobby==false, we don't want to
9131
+ // setup local streams for publishing, because if we ever end up admitted to the meeting
9132
+ // but Locus event about it for us is delayed or missed, others could see/hear our user's video/audio
9133
+ // while the user would still think they're in the lobby
9134
+ if (allowPublishMediaInLobby || !this.isUserUnadmitted) {
9135
+ await this.setUpLocalStreamReferences(localStreams);
9136
+ }
8095
9137
 
8096
9138
  this.setMercuryListener();
8097
9139
 
@@ -8114,12 +9156,7 @@ export default class Meeting extends StatelessWebexPlugin {
8114
9156
 
8115
9157
  // Establish new media connection with forced TURN discovery
8116
9158
  // 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
- );
9159
+ await this.establishMediaConnection(remoteMediaManagerConfig, bundlePolicy, true);
8123
9160
  } else {
8124
9161
  throw error;
8125
9162
  }
@@ -8148,7 +9185,8 @@ export default class Meeting extends StatelessWebexPlugin {
8148
9185
  numTransports,
8149
9186
  isMultistream: this.isMultistream,
8150
9187
  retriedWithTurnServer: this.addMediaData.retriedWithTurnServer,
8151
- isJoinWithMediaRetry: this.joinWithMediaRetryInfo.isRetry,
9188
+ isJoinWithMediaRetry: this.joinWithMediaRetryInfo.retryCount > 0,
9189
+ iceTransportPolicy: this.addMediaData.iceTransportPolicy || 'all',
8152
9190
  ...reachabilityMetrics,
8153
9191
  ...iceCandidateErrors,
8154
9192
  iceCandidatesCount: this.iceCandidatesCount,
@@ -8170,14 +9208,16 @@ export default class Meeting extends StatelessWebexPlugin {
8170
9208
  // We can log ReceiveSlot SSRCs only after the SDP exchange, so doing it here:
8171
9209
  this.remoteMediaManager?.logAllReceiveSlots();
8172
9210
  this.startPeriodicLogUpload();
8173
- } catch (error) {
9211
+ } catch (error: any) {
8174
9212
  LoggerProxy.logger.error(`${LOG_HEADER} failed to establish media connection: `, error);
8175
9213
 
8176
9214
  // @ts-ignore
8177
9215
  const reachabilityMetrics = await this.getMediaReachabilityMetricFields();
8178
9216
 
8179
- const {selectedCandidatePairChanges, numTransports} =
8180
- await this.mediaProperties.getCurrentConnectionInfo();
9217
+ const {connectionType, selectedCandidatePairChanges, numTransports} =
9218
+ error instanceof AddMediaFailed
9219
+ ? error
9220
+ : await this.mediaProperties.getCurrentConnectionInfo();
8181
9221
 
8182
9222
  const iceCandidateErrors = Object.fromEntries(this.iceCandidateErrors);
8183
9223
 
@@ -8193,7 +9233,8 @@ export default class Meeting extends StatelessWebexPlugin {
8193
9233
  turnServerUsed: this.turnServerUsed,
8194
9234
  retriedWithTurnServer: this.addMediaData.retriedWithTurnServer,
8195
9235
  isMultistream: this.isMultistream,
8196
- isJoinWithMediaRetry: this.joinWithMediaRetryInfo.isRetry,
9236
+ isJoinWithMediaRetry: this.joinWithMediaRetryInfo.retryCount > 0,
9237
+ iceTransportPolicy: this.addMediaData.iceTransportPolicy || 'all',
8197
9238
  signalingState:
8198
9239
  this.mediaProperties.webrtcMediaConnection?.multistreamConnection?.pc?.pc
8199
9240
  ?.signalingState ||
@@ -8209,6 +9250,7 @@ export default class Meeting extends StatelessWebexPlugin {
8209
9250
  ?.iceConnectionState ||
8210
9251
  this.mediaProperties.webrtcMediaConnection?.mediaConnection?.pc?.iceConnectionState ||
8211
9252
  'unknown',
9253
+ connectionType,
8212
9254
  ...reachabilityMetrics,
8213
9255
  ...iceCandidateErrors,
8214
9256
  iceCandidatesCount: this.iceCandidatesCount,
@@ -8557,14 +9599,15 @@ export default class Meeting extends StatelessWebexPlugin {
8557
9599
  options: {meetingId: this.id},
8558
9600
  });
8559
9601
  LoggerProxy.logger.log('Meeting:index#leave --> Leaving a meeting');
9602
+ this.stopListeningForMeetingEvents();
8560
9603
 
8561
9604
  return MeetingUtil.leaveMeeting(this, options)
8562
- .then((leave) => {
9605
+ .then(async (leave) => {
8563
9606
  // CA team recommends submitting this *after* locus /leave
8564
9607
  submitLeaveMetric();
8565
9608
 
8566
9609
  this.meetingFiniteStateMachine.leave();
8567
- this.clearMeetingData();
9610
+ await this.clearMeetingData();
8568
9611
 
8569
9612
  // upload logs on leave irrespective of meeting delete
8570
9613
  Trigger.trigger(
@@ -9422,11 +10465,13 @@ export default class Meeting extends StatelessWebexPlugin {
9422
10465
  locus_id: this.locusId,
9423
10466
  });
9424
10467
 
10468
+ this.stopListeningForMeetingEvents();
10469
+
9425
10470
  return MeetingUtil.endMeetingForAll(this)
9426
- .then((end) => {
10471
+ .then(async (end) => {
9427
10472
  this.meetingFiniteStateMachine.end();
9428
10473
 
9429
- this.clearMeetingData();
10474
+ await this.clearMeetingData();
9430
10475
  // upload logs on leave irrespective of meeting delete
9431
10476
  Trigger.trigger(
9432
10477
  this,
@@ -9474,7 +10519,7 @@ export default class Meeting extends StatelessWebexPlugin {
9474
10519
  * @public
9475
10520
  * @memberof Meeting
9476
10521
  */
9477
- clearMeetingData = () => {
10522
+ clearMeetingData = async () => {
9478
10523
  this.audio = null;
9479
10524
  this.video = null;
9480
10525
  this.screenShareFloorState = ScreenShareFloorStatus.RELEASED;
@@ -9483,19 +10528,16 @@ export default class Meeting extends StatelessWebexPlugin {
9483
10528
  }
9484
10529
  this.queuedMediaUpdates = [];
9485
10530
 
9486
- if (this.transcription) {
9487
- this.stopTranscription();
9488
- this.transcription = undefined;
9489
- }
9490
-
9491
- this.annotation.deregisterEvents();
10531
+ // Listener teardown (transcription, annotation, llm/mercury) runs in
10532
+ // stopListeningForMeetingEvents() before /leave and /end so events
10533
+ // received mid-teardown do not trigger Locus syncs. Calling it here
10534
+ // again would double-emit MEETING_STOPPED_RECEIVING_TRANSCRIPTION
10535
+ // because stopTranscription() always fires its trigger.
10536
+ //
10537
+ // Ownership-aware token clear is encapsulated inside clearDataChannelToken().
10538
+ this.clearDataChannelToken();
9492
10539
 
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);
9497
-
9498
- this.clearLLMHealthCheckTimer();
10540
+ await this.cleanupLLMConneciton({throwOnError: false});
9499
10541
  };
9500
10542
 
9501
10543
  /**
@@ -9571,15 +10613,12 @@ export default class Meeting extends StatelessWebexPlugin {
9571
10613
  * @public
9572
10614
  * @memberof Meeting
9573
10615
  */
9574
- public sendReaction(reactionType: ReactionServerType, skinToneType?: SkinToneType) {
10616
+ public sendReaction(reactionType: string, skinToneType?: SkinToneType) {
9575
10617
  const reactionChannelUrl = this.locusInfo?.controls?.reactions?.reactionChannelUrl as string;
9576
10618
  const participantId = this.members.selfId;
9577
10619
 
9578
- const reactionData = Reactions[reactionType];
10620
+ const reactionData = Reactions[reactionType] || {type: reactionType};
9579
10621
 
9580
- if (!reactionData) {
9581
- return Promise.reject(new Error(`${reactionType} is not a valid reaction.`));
9582
- }
9583
10622
  const skinToneData = SkinTones[skinToneType] || SkinTones.normal;
9584
10623
  const reaction: Reaction = {
9585
10624
  ...reactionData,
@@ -9688,15 +10727,20 @@ export default class Meeting extends StatelessWebexPlugin {
9688
10727
  }
9689
10728
 
9690
10729
  if (shouldEnableMusicMode) {
9691
- await this.sendSlotManager.setCodecParameters(MediaType.AudioMain, {
9692
- maxaveragebitrate: '64000',
9693
- maxplaybackrate: '48000',
9694
- });
10730
+ await this.sendSlotManager.setCustomCodecParameters(
10731
+ MediaType.AudioMain,
10732
+ MediaCodecMimeType.OPUS,
10733
+ {
10734
+ maxaveragebitrate: '64000',
10735
+ maxplaybackrate: '48000',
10736
+ }
10737
+ );
9695
10738
  } else {
9696
- await this.sendSlotManager.deleteCodecParameters(MediaType.AudioMain, [
9697
- 'maxaveragebitrate',
9698
- 'maxplaybackrate',
9699
- ]);
10739
+ await this.sendSlotManager.markCustomCodecParametersForDeletion(
10740
+ MediaType.AudioMain,
10741
+ MediaCodecMimeType.OPUS,
10742
+ ['maxaveragebitrate', 'maxplaybackrate']
10743
+ );
9700
10744
  }
9701
10745
  }
9702
10746
 
@@ -10195,4 +11239,52 @@ export default class Meeting extends StatelessWebexPlugin {
10195
11239
  cancelSipCallOut(participantId: string) {
10196
11240
  return this.meetingRequest.cancelSipCallOut(participantId);
10197
11241
  }
11242
+
11243
+ /**
11244
+ * Method to get new data
11245
+ * @returns {Promise}
11246
+ */
11247
+ public async refreshDataChannelToken() {
11248
+ const isPracticeSession = this.webinar.isJoinPracticeSessionDataChannel();
11249
+ const dataChannelTokenType = this.getDataChannelTokenType();
11250
+
11251
+ try {
11252
+ const res = await this.meetingRequest.fetchDatachannelToken({
11253
+ locusUrl: this.locusUrl,
11254
+ requestingParticipantId: this.members.selfId,
11255
+ isPracticeSession,
11256
+ });
11257
+
11258
+ return {
11259
+ body: {
11260
+ datachannelToken: res.body.datachannelToken,
11261
+ dataChannelTokenType,
11262
+ },
11263
+ };
11264
+ } catch (e) {
11265
+ const msg = e?.message || String(e);
11266
+
11267
+ LoggerProxy.logger.warn(
11268
+ `Meeting:index#refreshDataChannelToken --> DataChannel token refresh failed (likely locus changed or participant left): ${msg}`,
11269
+ {statusCode: e?.statusCode}
11270
+ );
11271
+
11272
+ return null;
11273
+ }
11274
+ }
11275
+
11276
+ /**
11277
+ * Determines the current data channel token type based on the meeting state.
11278
+ *
11279
+ * variant should be used when connecting to the LLM data channel.
11280
+ *
11281
+ * @returns {DataChannelTokenType} The token type representing the current session mode.
11282
+ */
11283
+ public getDataChannelTokenType(): DataChannelTokenType {
11284
+ if (this.webinar.isJoinPracticeSessionDataChannel()) {
11285
+ return DataChannelTokenType.PracticeSession;
11286
+ }
11287
+
11288
+ return DataChannelTokenType.Default;
11289
+ }
10198
11290
  }