@webex/plugin-meetings 3.11.0 → 3.12.0-auth-prejoin-fetch.1

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