@webex/plugin-meetings 3.11.0 → 3.12.0-metrics-init-fix-3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (293) hide show
  1. package/AGENTS.md +9 -0
  2. package/dist/aiEnableRequest/index.js +197 -0
  3. package/dist/aiEnableRequest/index.js.map +1 -0
  4. package/dist/aiEnableRequest/utils.js +36 -0
  5. package/dist/aiEnableRequest/utils.js.map +1 -0
  6. package/dist/annotation/index.js +14 -5
  7. package/dist/annotation/index.js.map +1 -1
  8. package/dist/breakouts/breakout.js +8 -3
  9. package/dist/breakouts/breakout.js.map +1 -1
  10. package/dist/breakouts/events.js +29 -14
  11. package/dist/breakouts/events.js.map +1 -1
  12. package/dist/breakouts/index.js +90 -3
  13. package/dist/breakouts/index.js.map +1 -1
  14. package/dist/common/errors/webex-errors.js +49 -5
  15. package/dist/common/errors/webex-errors.js.map +1 -1
  16. package/dist/config.js +8 -3
  17. package/dist/config.js.map +1 -1
  18. package/dist/constants.js +60 -11
  19. package/dist/constants.js.map +1 -1
  20. package/dist/controls-options-manager/constants.js +11 -1
  21. package/dist/controls-options-manager/constants.js.map +1 -1
  22. package/dist/controls-options-manager/index.js +67 -29
  23. package/dist/controls-options-manager/index.js.map +1 -1
  24. package/dist/controls-options-manager/util.js +91 -0
  25. package/dist/controls-options-manager/util.js.map +1 -1
  26. package/dist/hashTree/constants.js +16 -2
  27. package/dist/hashTree/constants.js.map +1 -1
  28. package/dist/hashTree/hashTree.js +18 -0
  29. package/dist/hashTree/hashTree.js.map +1 -1
  30. package/dist/hashTree/hashTreeParser.js +1655 -538
  31. package/dist/hashTree/hashTreeParser.js.map +1 -1
  32. package/dist/hashTree/types.js +4 -2
  33. package/dist/hashTree/types.js.map +1 -1
  34. package/dist/hashTree/utils.js +52 -0
  35. package/dist/hashTree/utils.js.map +1 -1
  36. package/dist/index.js +18 -2
  37. package/dist/index.js.map +1 -1
  38. package/dist/interceptors/constant.js +12 -0
  39. package/dist/interceptors/constant.js.map +1 -0
  40. package/dist/interceptors/dataChannelAuthToken.js +350 -0
  41. package/dist/interceptors/dataChannelAuthToken.js.map +1 -0
  42. package/dist/interceptors/index.js +7 -0
  43. package/dist/interceptors/index.js.map +1 -1
  44. package/dist/interceptors/locusRetry.js +23 -8
  45. package/dist/interceptors/locusRetry.js.map +1 -1
  46. package/dist/interceptors/utils.js +27 -0
  47. package/dist/interceptors/utils.js.map +1 -0
  48. package/dist/interpretation/index.js +11 -2
  49. package/dist/interpretation/index.js.map +1 -1
  50. package/dist/interpretation/interpretation.types.js +7 -0
  51. package/dist/interpretation/interpretation.types.js.map +1 -0
  52. package/dist/interpretation/siLanguage.js +1 -1
  53. package/dist/locus-info/controlsUtils.js +9 -4
  54. package/dist/locus-info/controlsUtils.js.map +1 -1
  55. package/dist/locus-info/index.js +911 -211
  56. package/dist/locus-info/index.js.map +1 -1
  57. package/dist/locus-info/infoUtils.js +36 -5
  58. package/dist/locus-info/infoUtils.js.map +1 -1
  59. package/dist/locus-info/selfUtils.js +1 -0
  60. package/dist/locus-info/selfUtils.js.map +1 -1
  61. package/dist/locus-info/types.js +19 -0
  62. package/dist/locus-info/types.js.map +1 -1
  63. package/dist/media/MediaConnectionAwaiter.js +72 -3
  64. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  65. package/dist/media/index.js +8 -2
  66. package/dist/media/index.js.map +1 -1
  67. package/dist/media/properties.js +8 -7
  68. package/dist/media/properties.js.map +1 -1
  69. package/dist/meeting/in-meeting-actions.js +11 -1
  70. package/dist/meeting/in-meeting-actions.js.map +1 -1
  71. package/dist/meeting/index.js +2276 -1067
  72. package/dist/meeting/index.js.map +1 -1
  73. package/dist/meeting/locusMediaRequest.js +229 -82
  74. package/dist/meeting/locusMediaRequest.js.map +1 -1
  75. package/dist/meeting/muteState.js +10 -1
  76. package/dist/meeting/muteState.js.map +1 -1
  77. package/dist/meeting/request.js +55 -2
  78. package/dist/meeting/request.js.map +1 -1
  79. package/dist/meeting/request.type.js.map +1 -1
  80. package/dist/meeting/util.js +168 -5
  81. package/dist/meeting/util.js.map +1 -1
  82. package/dist/meeting-info/meeting-info-v2.js +2 -2
  83. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  84. package/dist/meetings/index.js +369 -162
  85. package/dist/meetings/index.js.map +1 -1
  86. package/dist/meetings/meetings.types.js +6 -1
  87. package/dist/meetings/meetings.types.js.map +1 -1
  88. package/dist/meetings/request.js +39 -0
  89. package/dist/meetings/request.js.map +1 -1
  90. package/dist/meetings/util.js +116 -18
  91. package/dist/meetings/util.js.map +1 -1
  92. package/dist/member/index.js +20 -0
  93. package/dist/member/index.js.map +1 -1
  94. package/dist/member/types.js.map +1 -1
  95. package/dist/member/util.js +40 -0
  96. package/dist/member/util.js.map +1 -1
  97. package/dist/members/index.js +101 -43
  98. package/dist/members/index.js.map +1 -1
  99. package/dist/members/util.js +8 -1
  100. package/dist/members/util.js.map +1 -1
  101. package/dist/metrics/constants.js +12 -1
  102. package/dist/metrics/constants.js.map +1 -1
  103. package/dist/multistream/codec/constants.js +63 -0
  104. package/dist/multistream/codec/constants.js.map +1 -0
  105. package/dist/multistream/mediaRequestManager.js +64 -68
  106. package/dist/multistream/mediaRequestManager.js.map +1 -1
  107. package/dist/multistream/receiveSlot.js +9 -0
  108. package/dist/multistream/receiveSlot.js.map +1 -1
  109. package/dist/multistream/remoteMediaManager.js +11 -0
  110. package/dist/multistream/remoteMediaManager.js.map +1 -1
  111. package/dist/multistream/sendSlotManager.js +116 -2
  112. package/dist/multistream/sendSlotManager.js.map +1 -1
  113. package/dist/reachability/clusterReachability.js.map +1 -1
  114. package/dist/reachability/index.js +139 -93
  115. package/dist/reachability/index.js.map +1 -1
  116. package/dist/reachability/reachability.types.js +2 -0
  117. package/dist/reachability/reachability.types.js.map +1 -1
  118. package/dist/reachability/util.js +45 -0
  119. package/dist/reachability/util.js.map +1 -1
  120. package/dist/reactions/reactions.type.js.map +1 -1
  121. package/dist/reconnection-manager/index.js +0 -1
  122. package/dist/reconnection-manager/index.js.map +1 -1
  123. package/dist/recording-controller/index.js +1 -3
  124. package/dist/recording-controller/index.js.map +1 -1
  125. package/dist/roap/turnDiscovery.js +8 -1
  126. package/dist/roap/turnDiscovery.js.map +1 -1
  127. package/dist/types/aiEnableRequest/index.d.ts +5 -0
  128. package/dist/types/aiEnableRequest/utils.d.ts +2 -0
  129. package/dist/types/common/errors/webex-errors.d.ts +32 -2
  130. package/dist/types/config.d.ts +6 -2
  131. package/dist/types/constants.d.ts +35 -1
  132. package/dist/types/controls-options-manager/constants.d.ts +6 -1
  133. package/dist/types/controls-options-manager/index.d.ts +16 -0
  134. package/dist/types/hashTree/constants.d.ts +3 -0
  135. package/dist/types/hashTree/hashTree.d.ts +7 -0
  136. package/dist/types/hashTree/hashTreeParser.d.ts +315 -30
  137. package/dist/types/hashTree/types.d.ts +3 -0
  138. package/dist/types/hashTree/utils.d.ts +24 -0
  139. package/dist/types/index.d.ts +4 -0
  140. package/dist/types/interceptors/constant.d.ts +5 -0
  141. package/dist/types/interceptors/dataChannelAuthToken.d.ts +43 -0
  142. package/dist/types/interceptors/index.d.ts +2 -1
  143. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  144. package/dist/types/interceptors/utils.d.ts +1 -0
  145. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  146. package/dist/types/locus-info/index.d.ts +126 -15
  147. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  148. package/dist/types/locus-info/types.d.ts +28 -1
  149. package/dist/types/media/MediaConnectionAwaiter.d.ts +20 -2
  150. package/dist/types/media/properties.d.ts +8 -3
  151. package/dist/types/meeting/in-meeting-actions.d.ts +10 -0
  152. package/dist/types/meeting/index.d.ts +245 -16
  153. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  154. package/dist/types/meeting/request.d.ts +17 -1
  155. package/dist/types/meeting/request.type.d.ts +5 -0
  156. package/dist/types/meeting/util.d.ts +40 -0
  157. package/dist/types/meetings/index.d.ts +42 -20
  158. package/dist/types/meetings/meetings.types.d.ts +15 -0
  159. package/dist/types/meetings/request.d.ts +14 -0
  160. package/dist/types/member/index.d.ts +2 -0
  161. package/dist/types/member/types.d.ts +1 -0
  162. package/dist/types/member/util.d.ts +14 -0
  163. package/dist/types/members/index.d.ts +15 -2
  164. package/dist/types/members/util.d.ts +1 -5
  165. package/dist/types/metrics/constants.d.ts +11 -0
  166. package/dist/types/multistream/codec/constants.d.ts +7 -0
  167. package/dist/types/multistream/mediaRequestManager.d.ts +20 -26
  168. package/dist/types/multistream/sendSlotManager.d.ts +23 -1
  169. package/dist/types/reachability/clusterReachability.d.ts +3 -3
  170. package/dist/types/reachability/index.d.ts +10 -3
  171. package/dist/types/reachability/reachability.types.d.ts +7 -0
  172. package/dist/types/reachability/util.d.ts +17 -0
  173. package/dist/types/reactions/reactions.type.d.ts +4 -0
  174. package/dist/types/webinar/utils.d.ts +6 -0
  175. package/dist/webinar/index.js +585 -164
  176. package/dist/webinar/index.js.map +1 -1
  177. package/dist/webinar/utils.js +25 -0
  178. package/dist/webinar/utils.js.map +1 -0
  179. package/package.json +24 -23
  180. package/src/aiEnableRequest/README.md +84 -0
  181. package/src/aiEnableRequest/index.ts +186 -0
  182. package/src/aiEnableRequest/utils.ts +25 -0
  183. package/src/annotation/index.ts +27 -7
  184. package/src/breakouts/breakout.ts +3 -1
  185. package/src/breakouts/events.ts +33 -11
  186. package/src/breakouts/index.ts +110 -1
  187. package/src/common/errors/webex-errors.ts +50 -3
  188. package/src/config.ts +6 -2
  189. package/src/constants.ts +49 -3
  190. package/src/controls-options-manager/constants.ts +14 -1
  191. package/src/controls-options-manager/index.ts +87 -28
  192. package/src/controls-options-manager/util.ts +81 -1
  193. package/src/hashTree/constants.ts +17 -0
  194. package/src/hashTree/hashTree.ts +17 -0
  195. package/src/hashTree/hashTreeParser.ts +1482 -361
  196. package/src/hashTree/types.ts +4 -0
  197. package/src/hashTree/utils.ts +45 -0
  198. package/src/index.ts +14 -1
  199. package/src/interceptors/constant.ts +6 -0
  200. package/src/interceptors/dataChannelAuthToken.ts +246 -0
  201. package/src/interceptors/index.ts +2 -1
  202. package/src/interceptors/locusRetry.ts +25 -4
  203. package/src/interceptors/utils.ts +16 -0
  204. package/src/interpretation/index.ts +29 -11
  205. package/src/interpretation/interpretation.types.ts +11 -0
  206. package/src/locus-info/controlsUtils.ts +14 -1
  207. package/src/locus-info/index.ts +975 -203
  208. package/src/locus-info/infoUtils.ts +41 -6
  209. package/src/locus-info/selfUtils.ts +1 -0
  210. package/src/locus-info/types.ts +33 -1
  211. package/src/media/MediaConnectionAwaiter.ts +62 -5
  212. package/src/media/index.ts +10 -1
  213. package/src/media/properties.ts +11 -4
  214. package/src/meeting/in-meeting-actions.ts +20 -0
  215. package/src/meeting/index.ts +1272 -164
  216. package/src/meeting/locusMediaRequest.ts +106 -6
  217. package/src/meeting/muteState.ts +10 -1
  218. package/src/meeting/request.ts +53 -0
  219. package/src/meeting/request.type.ts +6 -0
  220. package/src/meeting/util.ts +207 -7
  221. package/src/meeting-info/meeting-info-v2.ts +4 -2
  222. package/src/meetings/index.ts +319 -117
  223. package/src/meetings/meetings.types.ts +19 -0
  224. package/src/meetings/request.ts +43 -0
  225. package/src/meetings/util.ts +117 -4
  226. package/src/member/index.ts +20 -0
  227. package/src/member/types.ts +1 -0
  228. package/src/member/util.ts +41 -0
  229. package/src/members/index.ts +70 -7
  230. package/src/members/util.ts +12 -4
  231. package/src/metrics/constants.ts +12 -0
  232. package/src/multistream/codec/constants.ts +58 -0
  233. package/src/multistream/mediaRequestManager.ts +117 -76
  234. package/src/multistream/receiveSlot.ts +18 -0
  235. package/src/multistream/remoteMediaManager.ts +13 -0
  236. package/src/multistream/sendSlotManager.ts +97 -3
  237. package/src/reachability/clusterReachability.ts +3 -2
  238. package/src/reachability/index.ts +56 -16
  239. package/src/reachability/reachability.types.ts +11 -0
  240. package/src/reachability/util.ts +36 -0
  241. package/src/reactions/reactions.type.ts +4 -0
  242. package/src/reconnection-manager/index.ts +0 -1
  243. package/src/recording-controller/index.ts +1 -2
  244. package/src/roap/turnDiscovery.ts +9 -1
  245. package/src/webinar/index.ts +448 -11
  246. package/src/webinar/utils.ts +16 -0
  247. package/test/unit/spec/aiEnableRequest/index.ts +1067 -0
  248. package/test/unit/spec/aiEnableRequest/utils.ts +130 -0
  249. package/test/unit/spec/annotation/index.ts +69 -7
  250. package/test/unit/spec/breakouts/breakout.ts +9 -3
  251. package/test/unit/spec/breakouts/events.ts +120 -2
  252. package/test/unit/spec/breakouts/index.ts +191 -2
  253. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  254. package/test/unit/spec/controls-options-manager/index.js +244 -29
  255. package/test/unit/spec/controls-options-manager/util.js +165 -0
  256. package/test/unit/spec/hashTree/hashTree.ts +66 -0
  257. package/test/unit/spec/hashTree/hashTreeParser.ts +4528 -171
  258. package/test/unit/spec/hashTree/utils.ts +125 -1
  259. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +406 -0
  260. package/test/unit/spec/interceptors/locusRetry.ts +205 -4
  261. package/test/unit/spec/interceptors/utils.ts +75 -0
  262. package/test/unit/spec/interpretation/index.ts +26 -4
  263. package/test/unit/spec/locus-info/controlsUtils.js +200 -56
  264. package/test/unit/spec/locus-info/index.js +1848 -164
  265. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  266. package/test/unit/spec/media/MediaConnectionAwaiter.ts +96 -1
  267. package/test/unit/spec/media/index.ts +92 -0
  268. package/test/unit/spec/media/properties.ts +35 -26
  269. package/test/unit/spec/meeting/in-meeting-actions.ts +12 -2
  270. package/test/unit/spec/meeting/index.js +3706 -405
  271. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  272. package/test/unit/spec/meeting/muteState.js +81 -0
  273. package/test/unit/spec/meeting/request.js +82 -0
  274. package/test/unit/spec/meeting/utils.js +595 -27
  275. package/test/unit/spec/meeting-info/meetinginfov2.js +19 -10
  276. package/test/unit/spec/meetings/index.js +1138 -86
  277. package/test/unit/spec/meetings/request.js +141 -0
  278. package/test/unit/spec/meetings/utils.js +402 -51
  279. package/test/unit/spec/member/index.js +35 -4
  280. package/test/unit/spec/member/util.js +154 -27
  281. package/test/unit/spec/members/index.js +216 -0
  282. package/test/unit/spec/members/request.js +37 -1
  283. package/test/unit/spec/members/utils.js +63 -0
  284. package/test/unit/spec/multistream/mediaRequestManager.ts +503 -122
  285. package/test/unit/spec/multistream/remoteMediaManager.ts +30 -0
  286. package/test/unit/spec/multistream/sendSlotManager.ts +135 -36
  287. package/test/unit/spec/reachability/index.ts +151 -46
  288. package/test/unit/spec/reachability/util.ts +31 -0
  289. package/test/unit/spec/reconnection-manager/index.js +4 -8
  290. package/test/unit/spec/recording-controller/index.js +9 -8
  291. package/test/unit/spec/roap/turnDiscovery.ts +20 -0
  292. package/test/unit/spec/webinar/index.ts +837 -39
  293. package/test/unit/spec/webinar/utils.ts +39 -0
@@ -13,7 +13,7 @@ import {
13
13
  CALL_DIAGNOSTIC_CONFIG,
14
14
  RtcMetrics,
15
15
  } from '@webex/internal-plugin-metrics';
16
- import {ClientEvent as RawClientEvent} from '@webex/event-dictionary-ts';
16
+ import type {ClientEvent as RawClientEvent} from '@webex/event-dictionary-ts';
17
17
 
18
18
  import {
19
19
  ConnectionState,
@@ -30,9 +30,11 @@ import {
30
30
  NetworkQualityMonitor,
31
31
  StatsMonitor,
32
32
  StatsMonitorEventNames,
33
- InboundAudioIssueSubTypes,
33
+ MediaCodecMimeType,
34
34
  } from '@webex/internal-media-core';
35
35
 
36
+ import {DataChannelTokenType, type RegisterAndConnectTiming} from '@webex/internal-plugin-llm';
37
+
36
38
  import {
37
39
  LocalStream,
38
40
  LocalCameraStream,
@@ -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';
@@ -178,13 +185,15 @@ import JoinForbiddenError from '../common/errors/join-forbidden-error';
178
185
  import {ReachabilityMetrics} from '../reachability/reachability.types';
179
186
  import {SetStageOptions, SetStageVideoLayout, UnsetStageVideoLayout} from './request.type';
180
187
  import {Invitee} from './type';
181
- import {DataSet} from '../hashTree/hashTreeParser';
188
+ import {DataSet, HashTreeMessage, Metadata} from '../hashTree/hashTreeParser';
182
189
  import {LocusDTO} from '../locus-info/types';
190
+ import AIEnableRequest from '../aiEnableRequest';
183
191
 
184
192
  // default callback so we don't call an undefined function, but in practice it should never be used
185
193
  const DEFAULT_ICE_PHASE_CALLBACK = () => 'JOIN_MEETING_FINAL';
186
194
 
187
195
  const LLM_HEALTHCHECK_TIMER_MS = 3 * 60 * 1000;
196
+ const JOIN_WITH_MEDIA_RETRY_MAX_COUNT = 2;
188
197
 
189
198
  const logRequest = (request: any, {logText = ''}) => {
190
199
  LoggerProxy.logger.info(`${logText} - sending request`);
@@ -249,6 +258,7 @@ export type AddMediaOptions = {
249
258
  remoteMediaManagerConfig?: RemoteMediaManagerConfiguration; // applies only to multistream meetings
250
259
  bundlePolicy?: BundlePolicy; // applies only to multistream meetings
251
260
  allowMediaInLobby?: boolean; // allows adding media when in the lobby
261
+ allowPublishMediaInLobby?: boolean; // allows publishing media when in the lobby, if not specified, default value false is used
252
262
  additionalMediaOptions?: AdditionalMediaOptions; // allows adding additional options like send/receive audio/video
253
263
  };
254
264
 
@@ -563,6 +573,34 @@ type MediaReachabilityMetrics = ReachabilityMetrics & {
563
573
  * @memberof Meeting
564
574
  */
565
575
 
576
+ /**
577
+ * Stores an event so all events can be later retrieved via a console command for debugging.
578
+ * @param {string} type
579
+ * @param {Object} data
580
+ * @returns {void}
581
+ */
582
+ export function storeEventForDebugging(
583
+ type: string,
584
+ data: {
585
+ eventType: any;
586
+ stateElementsMessage?: HashTreeMessage;
587
+ }
588
+ ) {
589
+ if ((window as any)?.locusEvents) {
590
+ // only store non-heartbeat hash tree messages
591
+ if (
592
+ data.eventType === LOCUSEVENT.HASH_TREE_DATA_UPDATED &&
593
+ data.stateElementsMessage?.locusStateElements
594
+ ) {
595
+ (window as any).locusEvents.push({
596
+ ...data,
597
+ timestamp: new Date().toLocaleString(),
598
+ type,
599
+ });
600
+ }
601
+ }
602
+ }
603
+
566
604
  /**
567
605
  * @description Meeting is the crux of the plugin
568
606
  * @export
@@ -574,10 +612,11 @@ export default class Meeting extends StatelessWebexPlugin {
574
612
  breakouts: any;
575
613
  simultaneousInterpretation: any;
576
614
  annotation: any;
615
+ aiEnableRequest: any;
577
616
  webinar: any;
578
617
  conversationUrl: string;
579
618
  callStateForMetrics: CallStateForMetrics;
580
- destination: string;
619
+ destination: string | LocusDTO;
581
620
  destinationType: DESTINATION_TYPE;
582
621
  deviceUrl: string;
583
622
  hostId: string;
@@ -616,12 +655,22 @@ export default class Meeting extends StatelessWebexPlugin {
616
655
  floorGrantPending: boolean;
617
656
  hasJoinedOnce: boolean;
618
657
  hasWebsocketConnected: boolean;
658
+ private mercuryOnlineHandler?: () => void;
659
+ private mercuryOfflineHandler?: () => void;
619
660
  inMeetingActions: InMeetingActions;
620
661
  isLocalShareLive: boolean;
621
662
  isRoapInProgress: boolean;
622
663
  keepAliveTimerId: NodeJS.Timeout;
623
664
  lastVideoLayoutInfo: any;
624
665
  locusInfo: any;
666
+ // this group of properties is populated via updateMeetingObject() that's registered as a callback with LocusInfo
667
+ isUserUnadmitted?: boolean;
668
+ joinedWith?: any;
669
+ selfId?: string;
670
+ roles: any[];
671
+ canNotViewTheParticipantList?: boolean;
672
+ // ... there is more ... see SelfUtils.parse()
673
+ // end of the group
625
674
  locusMediaRequest?: LocusMediaRequest;
626
675
  mediaProperties: MediaProperties;
627
676
  mediaRequestManagers: {
@@ -656,7 +705,6 @@ export default class Meeting extends StatelessWebexPlugin {
656
705
  endCallInitJoinReq: any;
657
706
  endJoinReqResp: any;
658
707
  endLocalSDPGenRemoteSDPRecvDelay: any;
659
- joinedWith: any;
660
708
  locusId: any;
661
709
  startCallInitJoinReq: any;
662
710
  startJoinReqResp: any;
@@ -671,12 +719,11 @@ export default class Meeting extends StatelessWebexPlugin {
671
719
  permissionTokenReceivedLocalTime: number;
672
720
  resourceId: any;
673
721
  resourceUrl: string;
674
- selfId: string;
675
722
  state: any;
676
723
  localAudioStreamMuteStateHandler: () => void;
677
724
  localVideoStreamMuteStateHandler: () => void;
678
725
  localOutputTrackChangeHandler: () => void;
679
- roles: any[];
726
+ localConstraintsChangeHandler: () => void;
680
727
  environment: string;
681
728
  namespace = MEETINGS;
682
729
  allowMediaInLobby: boolean;
@@ -695,6 +742,8 @@ export default class Meeting extends StatelessWebexPlugin {
695
742
  isMoveToInProgress = false;
696
743
  registrationIdStatus: string;
697
744
  brbState: BrbState;
745
+ private emittedBreakoutJoinResponseMoveIds: Set<string> = new Set();
746
+ private promisesWaitingForPropUpdate: Record<string, Defer> = {};
698
747
 
699
748
  voiceaListenerCallbacks: object = {
700
749
  [VOICEAEVENTS.VOICEA_ANNOUNCEMENT]: (payload: Transcription['languageOptions']) => {
@@ -744,13 +793,20 @@ export default class Meeting extends StatelessWebexPlugin {
744
793
  private addMediaData: {
745
794
  retriedWithTurnServer: boolean;
746
795
  icePhaseCallback: () => string;
796
+ iceTransportPolicy?: RTCIceTransportPolicy;
747
797
  };
748
798
 
749
799
  private sendSlotManager: SendSlotManager = new SendSlotManager(LoggerProxy);
750
800
  private deferSDPAnswer?: Defer; // used for waiting for a response
751
801
  private sdpResponseTimer?: ReturnType<typeof setTimeout>;
752
802
  private hasMediaConnectionConnectedAtLeastOnce: boolean;
753
- private joinWithMediaRetryInfo?: {isRetry: boolean; prevJoinResponse?: any};
803
+ private joinWithMediaRetryInfo: {
804
+ retryCount: number;
805
+ prevJoinResponse?: any;
806
+ firstError?: Error;
807
+ prevError?: Error;
808
+ };
809
+
754
810
  private connectionStateHandler?: ConnectionStateHandler;
755
811
  private iceCandidateErrors: Map<string, number>;
756
812
  private iceCandidatesCount: number;
@@ -893,6 +949,10 @@ export default class Meeting extends StatelessWebexPlugin {
893
949
  */
894
950
  // @ts-ignore
895
951
  this.simultaneousInterpretation = new SimultaneousInterpretation({}, {parent: this.webex});
952
+
953
+ // @ts-ignore
954
+ this.aiEnableRequest = new AIEnableRequest({locusUrl: this.locusUrl}, {parent: this.webex});
955
+
896
956
  /**
897
957
  * @instance
898
958
  * @type {Annotation}
@@ -922,6 +982,7 @@ export default class Meeting extends StatelessWebexPlugin {
922
982
  },
923
983
  (csi: CSI) => (this.members.findMemberByCsi(csi) as any)?.id
924
984
  );
985
+
925
986
  /**
926
987
  * Object containing helper classes for managing media requests for audio/video/screenshare (for multistream media connections)
927
988
  * All multistream media requests sent out for this meeting have to go through them.
@@ -941,6 +1002,7 @@ export default class Meeting extends StatelessWebexPlugin {
941
1002
  mediaRequests
942
1003
  );
943
1004
  },
1005
+ this.getIngressPayloadTypeCallback.bind(this),
944
1006
  {
945
1007
  // @ts-ignore - config coming from registerPlugin
946
1008
  degradationPreferences: this.config.degradationPreferences,
@@ -962,6 +1024,7 @@ export default class Meeting extends StatelessWebexPlugin {
962
1024
  mediaRequests
963
1025
  );
964
1026
  },
1027
+ this.getIngressPayloadTypeCallback.bind(this),
965
1028
  {
966
1029
  // @ts-ignore - config coming from registerPlugin
967
1030
  degradationPreferences: this.config.degradationPreferences,
@@ -983,6 +1046,7 @@ export default class Meeting extends StatelessWebexPlugin {
983
1046
  mediaRequests
984
1047
  );
985
1048
  },
1049
+ this.getIngressPayloadTypeCallback.bind(this),
986
1050
  {
987
1051
  // @ts-ignore - config coming from registerPlugin
988
1052
  degradationPreferences: this.config.degradationPreferences,
@@ -1004,11 +1068,14 @@ export default class Meeting extends StatelessWebexPlugin {
1004
1068
  mediaRequests
1005
1069
  );
1006
1070
  },
1071
+ this.getIngressPayloadTypeCallback.bind(this),
1007
1072
  {
1008
1073
  // @ts-ignore - config coming from registerPlugin
1009
1074
  degradationPreferences: this.config.degradationPreferences,
1010
1075
  kind: 'video',
1011
1076
  trimRequestsToNumOfSources: false,
1077
+ // @ts-ignore - config coming from registerPlugin
1078
+ enableAv1: this.config.enableAv1SlidesSupport,
1012
1079
  }
1013
1080
  ),
1014
1081
  };
@@ -1328,7 +1395,48 @@ export default class Meeting extends StatelessWebexPlugin {
1328
1395
  * @memberof Meeting
1329
1396
  */
1330
1397
  // @ts-ignore - Fix type
1331
- this.locusInfo = new LocusInfo(this.updateMeetingObject.bind(this), this.webex, this.id);
1398
+ this.locusInfo = new LocusInfo(
1399
+ {
1400
+ updateMeeting: this.updateMeetingObject.bind(this),
1401
+ syncLatencyTracker: {
1402
+ // Compute/store latency timestamps live on CallDiagnosticLatencies, while
1403
+ // submitting the client.locus.sync.complete CA event is owned by the metrics
1404
+ // facade. Wire each method to the layer that owns that responsibility.
1405
+ saveLatency: (...args) =>
1406
+ // @ts-ignore
1407
+ this.webex.internal.newMetrics.callDiagnosticLatencies.saveLatency(...args),
1408
+ saveTimestamp: (saveTimestampOptions: {
1409
+ key: string;
1410
+ value?: number;
1411
+ options: {meetingId: string; dataSetName: string; trackingId?: string};
1412
+ }) => {
1413
+ // @ts-ignore
1414
+ this.webex.internal.newMetrics.callDiagnosticLatencies.saveTimestamp(
1415
+ saveTimestampOptions
1416
+ );
1417
+
1418
+ // The /sync response is one of the two milestones (the other is the LLM message) that
1419
+ // complete client.locus.sync.complete. Try to complete now: the metric is emitted only
1420
+ // once both the LLM message and the /sync response have arrived (either can come first).
1421
+ if (
1422
+ saveTimestampOptions.key === 'internal.client.locus.sync.response' &&
1423
+ saveTimestampOptions.options?.trackingId
1424
+ ) {
1425
+ this.tryCompleteLocusSyncLatency(
1426
+ saveTimestampOptions.options.meetingId,
1427
+ saveTimestampOptions.options.trackingId
1428
+ );
1429
+ }
1430
+ },
1431
+ clearLocusSyncLatency: (...args) =>
1432
+ // @ts-ignore
1433
+ this.webex.internal.newMetrics.callDiagnosticLatencies.clearLocusSyncLatency(...args),
1434
+ },
1435
+ },
1436
+ // @ts-ignore
1437
+ this.webex,
1438
+ this.id
1439
+ );
1332
1440
 
1333
1441
  // We had to add listeners first before setting up the locus instance
1334
1442
  /**
@@ -1513,6 +1621,8 @@ export default class Meeting extends StatelessWebexPlugin {
1513
1621
  this.controlsOptionsManager = new ControlsOptionsManager(this.meetingRequest, {
1514
1622
  locusUrl: this.locusInfo?.url,
1515
1623
  displayHints: [],
1624
+ getControls: () => this.locusInfo?.controls,
1625
+ isWebinar: () => this.locusInfo?.info?.isWebinar,
1516
1626
  });
1517
1627
 
1518
1628
  this.setUpLocusInfoListeners();
@@ -1542,6 +1652,12 @@ export default class Meeting extends StatelessWebexPlugin {
1542
1652
  }
1543
1653
  };
1544
1654
 
1655
+ this.localConstraintsChangeHandler = () => {
1656
+ if (!this.isMultistream) {
1657
+ this.mediaProperties.webrtcMediaConnection?.updatePreferredBitrateKbps();
1658
+ }
1659
+ };
1660
+
1545
1661
  /**
1546
1662
  * Promise that exists if SDP offer has been generated, and resolves once sdp answer is received.
1547
1663
  * @instance
@@ -1605,11 +1721,11 @@ export default class Meeting extends StatelessWebexPlugin {
1605
1721
  /**
1606
1722
  * Information needed for a retry of a call to joinWithMedia
1607
1723
  * @instance
1608
- * @type {{isRetry: boolean; prevJoinResponse?: any}}
1724
+ * @type {{retryCount: number; prevJoinResponse?: any}}
1609
1725
  * @private
1610
1726
  * @memberof Meeting
1611
1727
  */
1612
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
1728
+ this.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
1613
1729
 
1614
1730
  /**
1615
1731
  * Connection state handler
@@ -1663,6 +1779,37 @@ export default class Meeting extends StatelessWebexPlugin {
1663
1779
  this.mediaServerIp = undefined;
1664
1780
  }
1665
1781
 
1782
+ /**
1783
+ * Get the ingress payload type for a given media type and codec mime type
1784
+ * @param {MediaType} mediaType - The media type
1785
+ * @param {MediaCodecMimeType} codecMimeType - The codec mime type
1786
+ * @returns {number | undefined} - The ingress payload type
1787
+ * @private
1788
+ * @memberof Meeting
1789
+ */
1790
+ private getIngressPayloadTypeCallback(
1791
+ mediaType: MediaType,
1792
+ codecMimeType: MediaCodecMimeType
1793
+ ): number | undefined {
1794
+ if (this.isMultistream) {
1795
+ try {
1796
+ return this.mediaProperties.webrtcMediaConnection.getIngressPayloadType(
1797
+ mediaType,
1798
+ codecMimeType
1799
+ );
1800
+ } catch (error) {
1801
+ LoggerProxy.logger.info(
1802
+ `Meeting:index#mediaRequestManager --> failed to get ingress payload type for mediaType=${mediaType}, codecMimeType=${codecMimeType}`,
1803
+ error
1804
+ );
1805
+
1806
+ return undefined;
1807
+ }
1808
+ }
1809
+
1810
+ return undefined;
1811
+ }
1812
+
1666
1813
  /**
1667
1814
  * Temporary func to return webex object,
1668
1815
  * in order to access internal plugin metrics
@@ -2275,6 +2422,89 @@ export default class Meeting extends StatelessWebexPlugin {
2275
2422
  });
2276
2423
  }
2277
2424
 
2425
+ /**
2426
+ * Handles the LLM state-update message that resulted from a Locus /sync. Records the LLM arrival
2427
+ * time (the milestone that gates client.locus.sync.complete - the metric is emitted only for LLM
2428
+ * flows) and then tries to complete the metric.
2429
+ * @param {string} meetingId meeting id
2430
+ * @param {string} trackingId sync tracking id echoed back on the LLM message
2431
+ * @returns {void}
2432
+ * @private
2433
+ * @memberof Meeting
2434
+ */
2435
+ private onLocusSyncLlmMessage(meetingId: string, trackingId: string) {
2436
+ // @ts-ignore
2437
+ this.webex.internal.newMetrics.callDiagnosticLatencies.recordLocusSyncMessageReceived(
2438
+ meetingId,
2439
+ trackingId
2440
+ );
2441
+
2442
+ this.tryCompleteLocusSyncLatency(meetingId, trackingId);
2443
+ }
2444
+
2445
+ /**
2446
+ * Attempts to complete the Locus sync latency metric and emit client.locus.sync.complete. The
2447
+ * metric is emitted only once BOTH the /sync response and the resulting LLM message have arrived
2448
+ * (in either order); until then the record is kept so the missing milestone can still land. Both
2449
+ * trigger points (the LLM message handler and the /sync response timestamp) call this, so the
2450
+ * metric fires as soon as the second milestone is in.
2451
+ * @param {string} meetingId meeting id
2452
+ * @param {string} trackingId sync tracking id used to match the pending record
2453
+ * @returns {void}
2454
+ * @private
2455
+ * @memberof Meeting
2456
+ */
2457
+ private tryCompleteLocusSyncLatency(meetingId: string, trackingId: string) {
2458
+ const completed =
2459
+ // @ts-ignore
2460
+ this.webex.internal.newMetrics.callDiagnosticLatencies.completeLocusSyncLatency(
2461
+ meetingId,
2462
+ trackingId
2463
+ );
2464
+
2465
+ if (completed) {
2466
+ this.emitLocusSyncCompleteMetric(meetingId, completed);
2467
+ }
2468
+ }
2469
+
2470
+ /**
2471
+ * Submits the client.locus.sync.complete Call Analyzer event for a completed Locus sync latency
2472
+ * measurement.
2473
+ * @param {string} meetingId meeting id
2474
+ * @param {object} completed completed sync latency payload from the metrics plugin
2475
+ * @returns {void}
2476
+ * @private
2477
+ * @memberof Meeting
2478
+ */
2479
+ private emitLocusSyncCompleteMetric(
2480
+ meetingId: string,
2481
+ completed: {dataSet: string; syncLatency: object}
2482
+ ) {
2483
+ // @ts-ignore
2484
+ const llmWebsocketUrl = this.webex.internal.llm?.getWebSocketUrl?.() || undefined;
2485
+
2486
+ // Per the LLM sync-latency spec, the event carries the LLM websocket url identifier,
2487
+ // the llmInfo.dataSet (main, atd-active or atd-unmuted) and the syncLatency block.
2488
+ const clientEvent = {
2489
+ name: 'client.locus.sync.complete',
2490
+ payload: {
2491
+ identifiers: {
2492
+ llmWebsocketUrl,
2493
+ },
2494
+ llmInfo: {
2495
+ dataSet: completed.dataSet,
2496
+ },
2497
+ syncLatency: completed.syncLatency,
2498
+ },
2499
+ options: {
2500
+ meetingId,
2501
+ },
2502
+ };
2503
+
2504
+ // @ts-ignore
2505
+ this.webex.internal.newMetrics.submitClientEvent(clientEvent);
2506
+ }
2507
+
2278
2508
  /**
2279
2509
  * Proxy function for all the listener set ups
2280
2510
  * @returns {undefined}
@@ -2739,7 +2969,7 @@ export default class Meeting extends StatelessWebexPlugin {
2739
2969
  private setupLocusControlsListener() {
2740
2970
  this.locusInfo.on(
2741
2971
  LOCUSINFO.EVENTS.CONTROLS_RECORDING_UPDATED,
2742
- ({state, modifiedBy, lastModified}) => {
2972
+ ({state, modifiedBy, lastModified, modifiedByServiceAppName, modifiedByServiceAppId}) => {
2743
2973
  let event;
2744
2974
 
2745
2975
  switch (state) {
@@ -2765,6 +2995,8 @@ export default class Meeting extends StatelessWebexPlugin {
2765
2995
  state: state === RECORDING_STATE.RESUMED ? RECORDING_STATE.RECORDING : state,
2766
2996
  modifiedBy,
2767
2997
  lastModified,
2998
+ modifiedByServiceAppName,
2999
+ modifiedByServiceAppId,
2768
3000
  };
2769
3001
  Trigger.trigger(
2770
3002
  this,
@@ -2951,6 +3183,18 @@ export default class Meeting extends StatelessWebexPlugin {
2951
3183
  );
2952
3184
  });
2953
3185
 
3186
+ this.locusInfo.on(
3187
+ LOCUSINFO.EVENTS.CONTROLS_AI_SUMMARY_NOTIFICATION_UPDATED,
3188
+ ({aiSummaryNotification}) => {
3189
+ Trigger.trigger(
3190
+ this,
3191
+ {file: 'meeting/index', function: 'setupLocusControlsListener'},
3192
+ EVENT_TRIGGERS.MEETING_CONTROLS_AI_SUMMARY_NOTIFICATION_UPDATED,
3193
+ {aiSummaryNotification}
3194
+ );
3195
+ }
3196
+ );
3197
+
2954
3198
  this.locusInfo.on(LOCUSINFO.EVENTS.CONTROLS_WEBCAST_CHANGED, ({state}) => {
2955
3199
  Trigger.trigger(
2956
3200
  this,
@@ -3151,7 +3395,7 @@ export default class Meeting extends StatelessWebexPlugin {
3151
3395
  }
3152
3396
 
3153
3397
  LoggerProxy.logger.info(
3154
- `Meeting:index#setUpLocusInfoMediaInactiveListener --> this.shareStatus=${this.shareStatus} newShareStatus=${newShareStatus}`
3398
+ `Meeting:index#setUpLocusMediaSharesListener --> this.shareStatus=${this.shareStatus} newShareStatus=${newShareStatus}`
3155
3399
  );
3156
3400
 
3157
3401
  if (newShareStatus !== this.shareStatus) {
@@ -3397,6 +3641,7 @@ export default class Meeting extends StatelessWebexPlugin {
3397
3641
  this.breakouts.locusUrlUpdate(url);
3398
3642
  this.simultaneousInterpretation.locusUrlUpdate(url);
3399
3643
  this.annotation.locusUrlUpdate(url);
3644
+ this.aiEnableRequest.locusUrlUpdate(url);
3400
3645
  this.locusUrl = url;
3401
3646
  this.locusId = this.locusUrl?.split('/').pop();
3402
3647
  this.recordingController.setLocusUrl(this.locusUrl);
@@ -3432,6 +3677,7 @@ export default class Meeting extends StatelessWebexPlugin {
3432
3677
  this.breakouts.breakoutServiceUrlUpdate(payload?.services?.breakout?.url);
3433
3678
  this.annotation.approvalUrlUpdate(payload?.services?.approval?.url);
3434
3679
  this.simultaneousInterpretation.approvalUrlUpdate(payload?.services?.approval?.url);
3680
+ this.aiEnableRequest.approvalUrlUpdate(payload?.services?.approval?.url);
3435
3681
  });
3436
3682
  }
3437
3683
 
@@ -3529,6 +3775,9 @@ export default class Meeting extends StatelessWebexPlugin {
3529
3775
  // @ts-ignore - config coming from registerPlugin
3530
3776
  if (datachannelUrl && this.config.enableAutomaticLLM) {
3531
3777
  this.updateLLMConnection();
3778
+ if (this.webinar.isJoinPracticeSessionDataChannel()) {
3779
+ this.webinar.updatePSDataChannel();
3780
+ }
3532
3781
  }
3533
3782
  }
3534
3783
 
@@ -3692,6 +3941,17 @@ export default class Meeting extends StatelessWebexPlugin {
3692
3941
  });
3693
3942
  }
3694
3943
  this.rtcMetrics?.sendNextMetrics();
3944
+
3945
+ try {
3946
+ await this.ensureDefaultDatachannelTokenAfterAdmit();
3947
+ } catch (error) {
3948
+ LoggerProxy.logger.warn(
3949
+ `Meeting:index#setUpLocusInfoSelfListener --> failed post-admit token prefetch flow: ${
3950
+ error?.message || String(error)
3951
+ }`
3952
+ );
3953
+ }
3954
+
3695
3955
  this.updateLLMConnection();
3696
3956
  });
3697
3957
 
@@ -3736,6 +3996,9 @@ export default class Meeting extends StatelessWebexPlugin {
3736
3996
  });
3737
3997
 
3738
3998
  this.locusInfo.on(LOCUSINFO.EVENTS.SELF_CANNOT_VIEW_PARTICIPANT_LIST_CHANGE, (payload) => {
3999
+ // canViewTheParticipantList meeting action depends on this value, so we need to update meeting actions
4000
+ this.updateMeetingActions();
4001
+
3739
4002
  Trigger.trigger(
3740
4003
  this,
3741
4004
  {
@@ -3761,6 +4024,10 @@ export default class Meeting extends StatelessWebexPlugin {
3761
4024
  );
3762
4025
  });
3763
4026
 
4027
+ this.locusInfo.on(LOCUSINFO.EVENTS.SELF_ID_CHANGED, (payload) => {
4028
+ this.aiEnableRequest.selfParticipantIdUpdate(payload.selfId);
4029
+ });
4030
+
3764
4031
  this.locusInfo.on(LOCUSINFO.EVENTS.SELF_MEETING_INTERPRETATION_CHANGED, (payload) => {
3765
4032
  const targetChanged = this.simultaneousInterpretation.updateSelfInterpretation(payload);
3766
4033
  Trigger.trigger(
@@ -3926,7 +4193,14 @@ export default class Meeting extends StatelessWebexPlugin {
3926
4193
  // is not changed by any delta event
3927
4194
  if (object && Object.keys(object).length) {
3928
4195
  Object.keys(object).forEach((key) => {
4196
+ const previousValue = this[key];
4197
+
3929
4198
  this[key] = object[key];
4199
+
4200
+ if (this.promisesWaitingForPropUpdate[key] && previousValue !== object[key]) {
4201
+ this.promisesWaitingForPropUpdate[key].resolve();
4202
+ delete this.promisesWaitingForPropUpdate[key];
4203
+ }
3930
4204
  });
3931
4205
  }
3932
4206
  }
@@ -4064,7 +4338,12 @@ export default class Meeting extends StatelessWebexPlugin {
4064
4338
  }
4065
4339
 
4066
4340
  /**
4067
- * Transfer the moderator role to another eligible member
4341
+ * Transfer the moderator role to another eligible member.
4342
+ *
4343
+ * If the target member is currently joined in the current session, the request is
4344
+ * sent against the current locus. Otherwise, we search the breakout sessions and,
4345
+ * when the member is found in one, we send the request against that breakout
4346
+ * session's locus url instead.
4068
4347
  * @param {String} memberId
4069
4348
  * @param {Boolean} moderator
4070
4349
  * @returns {Promise} see #members.transferHostToMember
@@ -4072,7 +4351,21 @@ export default class Meeting extends StatelessWebexPlugin {
4072
4351
  * @memberof Meeting
4073
4352
  */
4074
4353
  public transfer(memberId: string, moderator = true) {
4075
- return this.members.transferHostToMember(memberId, moderator);
4354
+ const targetMember = this.members.membersCollection.get(memberId);
4355
+
4356
+ if (targetMember?.isInMeeting) {
4357
+ return this.members.transferHostToMember(memberId, moderator);
4358
+ }
4359
+
4360
+ const breakout = this.breakouts?.breakouts?.models?.find((bo: any) => {
4361
+ const breakoutMember = bo.members?.membersCollection?.get(memberId);
4362
+
4363
+ return breakoutMember?.isInMeeting;
4364
+ });
4365
+
4366
+ const breakoutLocusUrl = breakout?.breakoutRosterLocus?.url;
4367
+
4368
+ return this.members.transferHostToMember(memberId, moderator, breakoutLocusUrl);
4076
4369
  }
4077
4370
 
4078
4371
  /**
@@ -4263,6 +4556,9 @@ export default class Meeting extends StatelessWebexPlugin {
4263
4556
  bothLeaveAndEndMeetingAvailable: MeetingUtil.bothLeaveAndEndMeetingAvailable(
4264
4557
  this.userDisplayHints
4265
4558
  ),
4559
+ requireHostEndMeetingBeforeLeave: MeetingUtil.requireHostEndMeetingBeforeLeave(
4560
+ this.userDisplayHints
4561
+ ),
4266
4562
  canEnableClosedCaption: MeetingUtil.canEnableClosedCaption(this.userDisplayHints),
4267
4563
  canStartTranscribing: MeetingUtil.canStartTranscribing(this.userDisplayHints),
4268
4564
  canStopTranscribing: MeetingUtil.canStopTranscribing(this.userDisplayHints),
@@ -4521,6 +4817,19 @@ export default class Meeting extends StatelessWebexPlugin {
4521
4817
  requiredHints: [DISPLAY_HINTS.DISABLE_ATTENDEE_START_POLLING_QA],
4522
4818
  displayHints: this.userDisplayHints,
4523
4819
  }),
4820
+ canAttendeeRequestAiAssistantEnabled: MeetingUtil.canAttendeeRequestAiAssistantEnabled(
4821
+ this.userDisplayHints,
4822
+ this.roles
4823
+ ),
4824
+ isAttendeeRequestAiAssistantDeclinedAll:
4825
+ MeetingUtil.attendeeRequestAiAssistantDeclinedAll(this.userDisplayHints),
4826
+ isAnonymizeDisplayNamesEnabled: MeetingUtil.isAnonymizeDisplayNamesEnabled(
4827
+ this.userDisplayHints
4828
+ ),
4829
+ canViewTheParticipantList: MeetingUtil.canViewTheParticipantList(
4830
+ this.userDisplayHints,
4831
+ this.canNotViewTheParticipantList ?? false
4832
+ ),
4524
4833
  }) || changed;
4525
4834
  }
4526
4835
  if (changed) {
@@ -4569,6 +4878,34 @@ export default class Meeting extends StatelessWebexPlugin {
4569
4878
  this.sipUri = sipUri;
4570
4879
  }
4571
4880
 
4881
+ /**
4882
+ * After initial locus setup, refreshes destination with synced locus data and optionally
4883
+ * performs deferred meeting info fetch when initial locus was incomplete.
4884
+ * @param {LocusDTO} locus
4885
+ * @returns {void}
4886
+ */
4887
+ public async finalizeMeetingAfterInitialLocusSetup(locus: LocusDTO): Promise<void> {
4888
+ if (locus && this?.destinationType === DESTINATION_TYPE.LOCUS_ID) {
4889
+ // destination is initialized from the initial locus snapshot in constructor,
4890
+ // so refresh it after locus sync to avoid stale partial hash-tree data.
4891
+ this.destination = locus;
4892
+ }
4893
+ if (
4894
+ (!this.meetingInfo || isEmpty(this.meetingInfo)) &&
4895
+ (this.destination as LocusDTO)?.info &&
4896
+ !this.fetchMeetingInfoTimeoutId &&
4897
+ !MeetingsUtil.isOneOnOneCall(locus)
4898
+ ) {
4899
+ try {
4900
+ await this.fetchMeetingInfo({});
4901
+ } catch (error: any) {
4902
+ LoggerProxy.logger.info(
4903
+ `Meeting:index#finalizeMeetingAfterInitialLocusSetup --> deferred fetchMeetingInfo failed: ${error.message}`
4904
+ );
4905
+ }
4906
+ }
4907
+ }
4908
+
4572
4909
  /**
4573
4910
  * Set the locus info the class instance. Should be called with the parsed locus
4574
4911
  * we got in the join response.
@@ -4592,7 +4929,8 @@ export default class Meeting extends StatelessWebexPlugin {
4592
4929
  mediaId: string;
4593
4930
  host: object;
4594
4931
  selfId: string;
4595
- dataSets: DataSet[];
4932
+ dataSets: DataSet[]; // only sent by Locus when hash trees are used
4933
+ metadata: Metadata; // only sent by Locus when hash trees are used
4596
4934
  }) {
4597
4935
  const mtgLocus: any = data.locus;
4598
4936
 
@@ -4608,6 +4946,7 @@ export default class Meeting extends StatelessWebexPlugin {
4608
4946
  trigger: 'join-response',
4609
4947
  locus: mtgLocus,
4610
4948
  dataSets: data.dataSets,
4949
+ metadata: data.metadata,
4611
4950
  });
4612
4951
  }
4613
4952
 
@@ -4817,6 +5156,7 @@ export default class Meeting extends StatelessWebexPlugin {
4817
5156
  this.localVideoStreamMuteStateHandler
4818
5157
  );
4819
5158
  oldStream?.off(LocalStreamEventNames.OutputTrackChange, this.localOutputTrackChangeHandler);
5159
+ oldStream?.off(LocalStreamEventNames.ConstraintsChange, this.localConstraintsChangeHandler);
4820
5160
 
4821
5161
  // we don't update this.mediaProperties.mediaDirection.sendVideo, because we always keep it as true to avoid extra SDP exchanges
4822
5162
  this.mediaProperties.setLocalVideoStream(localStream);
@@ -4832,6 +5172,7 @@ export default class Meeting extends StatelessWebexPlugin {
4832
5172
  this.localVideoStreamMuteStateHandler
4833
5173
  );
4834
5174
  localStream?.on(LocalStreamEventNames.OutputTrackChange, this.localOutputTrackChangeHandler);
5175
+ localStream?.on(LocalStreamEventNames.ConstraintsChange, this.localConstraintsChangeHandler);
4835
5176
 
4836
5177
  if (!this.isMultistream || !localStream) {
4837
5178
  // for multistream WCME automatically un-publishes the old stream when we publish a new one
@@ -4966,6 +5307,7 @@ export default class Meeting extends StatelessWebexPlugin {
4966
5307
  this.localVideoStreamMuteStateHandler
4967
5308
  );
4968
5309
  videoStream?.off(LocalStreamEventNames.OutputTrackChange, this.localOutputTrackChangeHandler);
5310
+ videoStream?.off(LocalStreamEventNames.ConstraintsChange, this.localConstraintsChangeHandler);
4969
5311
 
4970
5312
  shareAudioStream?.off(StreamEventNames.Ended, this.handleShareAudioStreamEnded);
4971
5313
  shareAudioStream?.off(
@@ -5035,8 +5377,7 @@ export default class Meeting extends StatelessWebexPlugin {
5035
5377
  public setMercuryListener() {
5036
5378
  // Client will have a socket manager and handle reconnecting to mercury, when we reconnect to mercury
5037
5379
  // if the meeting has active peer connections, it should try to reconnect.
5038
- // @ts-ignore
5039
- this.webex.internal.mercury.on(ONLINE, () => {
5380
+ this.mercuryOnlineHandler = () => {
5040
5381
  LoggerProxy.logger.info('Meeting:index#setMercuryListener --> Web socket online');
5041
5382
 
5042
5383
  // Only send restore event when it was disconnected before and for connected later
@@ -5046,15 +5387,47 @@ export default class Meeting extends StatelessWebexPlugin {
5046
5387
  });
5047
5388
  }
5048
5389
  this.hasWebsocketConnected = true;
5049
- });
5390
+ };
5050
5391
 
5051
- // @ts-ignore
5052
- this.webex.internal.mercury.on(OFFLINE, () => {
5392
+ this.mercuryOfflineHandler = () => {
5053
5393
  LoggerProxy.logger.error('Meeting:index#setMercuryListener --> Web socket offline');
5054
5394
  Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.MERCURY_CONNECTION_FAILURE, {
5055
5395
  correlation_id: this.correlationId,
5056
5396
  });
5057
- });
5397
+ };
5398
+
5399
+ // @ts-ignore
5400
+ this.webex.internal.mercury.on(ONLINE, this.mercuryOnlineHandler);
5401
+ // @ts-ignore
5402
+ this.webex.internal.mercury.on(OFFLINE, this.mercuryOfflineHandler);
5403
+ }
5404
+
5405
+ /**
5406
+ * Removes this meeting's Mercury ONLINE/OFFLINE event listeners registered
5407
+ * by setMercuryListener(). Must be called before Locus /leave to avoid
5408
+ * unnecessary syncs/metrics triggered by events received while leaving
5409
+ * (per Locus team recommendation).
5410
+ *
5411
+ * Mercury is a process-wide singleton shared with other plugins, so we
5412
+ * pass the bound handler refs to .off() to avoid clearing every listener
5413
+ * for ONLINE/OFFLINE on the shared emitter.
5414
+ *
5415
+ * Idempotent: subsequent calls are no-ops because the handler refs are
5416
+ * cleared after detaching.
5417
+ * @private
5418
+ * @returns {void}
5419
+ */
5420
+ private stopListeningForMercuryEvents() {
5421
+ if (this.mercuryOnlineHandler) {
5422
+ // @ts-ignore
5423
+ this.webex.internal.mercury.off(ONLINE, this.mercuryOnlineHandler);
5424
+ this.mercuryOnlineHandler = undefined;
5425
+ }
5426
+ if (this.mercuryOfflineHandler) {
5427
+ // @ts-ignore
5428
+ this.webex.internal.mercury.off(OFFLINE, this.mercuryOfflineHandler);
5429
+ this.mercuryOfflineHandler = undefined;
5430
+ }
5058
5431
  }
5059
5432
 
5060
5433
  /**
@@ -5078,6 +5451,7 @@ export default class Meeting extends StatelessWebexPlugin {
5078
5451
  );
5079
5452
 
5080
5453
  this.receiveSlotManager.reset();
5454
+
5081
5455
  this.mediaProperties.webrtcMediaConnection.close();
5082
5456
  this.mediaProperties.unsetPeerConnection();
5083
5457
  this.sendSlotManager.reset();
@@ -5365,7 +5739,7 @@ export default class Meeting extends StatelessWebexPlugin {
5365
5739
  } = {}
5366
5740
  ) {
5367
5741
  const {mediaOptions, joinOptions = {}} = options;
5368
- const {isRetry, prevJoinResponse} = this.joinWithMediaRetryInfo;
5742
+ const {retryCount, prevJoinResponse, prevError} = this.joinWithMediaRetryInfo;
5369
5743
 
5370
5744
  if (!mediaOptions?.allowMediaInLobby) {
5371
5745
  return Promise.reject(
@@ -5376,15 +5750,40 @@ export default class Meeting extends StatelessWebexPlugin {
5376
5750
 
5377
5751
  LoggerProxy.logger.info('Meeting:index#joinWithMedia called');
5378
5752
 
5753
+ /* Before we do anything, check if RTCPeerConnection is available. Normally this is checked
5754
+ by addMediaInternal() itself when creating the media connection, but since joinWithMedia()
5755
+ is a convenience method that does both join() and addMedia(), we want to fail fast here
5756
+ in case WebRTC is not available at all.
5757
+ */
5758
+ if (WebCapabilities.supportsRTCPeerConnection() === CapabilityState.NOT_CAPABLE) {
5759
+ // throw the same error that would be thrown by addMediaInternal()
5760
+ throw new Errors.WebrtcApiNotAvailableError(
5761
+ 'RTCPeerConnection API is not available in this environment'
5762
+ );
5763
+ }
5764
+
5765
+ /* While we're trying to join, we may fail and be doing a retry. In that case,
5766
+ we sometimes get dropped by Locus as a result of the 1st failed attempt.
5767
+ That notification from Locus needs to be ignored, otherwise it causes the meeting to be
5768
+ cleaned up and prevents the retry from running correctly.
5769
+ */
5770
+ this.locusInfo.suspendDestroyMeeting(true);
5771
+
5379
5772
  let joined = false;
5380
5773
  let joinResponse = prevJoinResponse;
5381
5774
 
5775
+ const shouldJoin =
5776
+ !joinResponse || // first try, when the join response is empty
5777
+ (prevError && prevError instanceof UserNotJoinedError) || // last try failed with UserNotJoinedError
5778
+ this.isErrorMeaningLocusDroppedUs(prevError) ||
5779
+ MeetingUtil.isUserInLeftState(this.locusInfo); // locus dropped the connection before we can re-try addMedia
5780
+
5382
5781
  try {
5383
5782
  let turnServerInfo;
5384
5783
  let turnDiscoverySkippedReason;
5385
5784
  let forceTurnDiscovery = false;
5386
5785
 
5387
- if (!joinResponse) {
5786
+ if (shouldJoin) {
5388
5787
  // This is the 1st attempt or a retry after join request failed -> we need to do a join with TURN discovery
5389
5788
 
5390
5789
  const turnDiscoveryRequest = await this.roap.generateTurnDiscoveryRequestMessage(
@@ -5423,16 +5822,24 @@ export default class Meeting extends StatelessWebexPlugin {
5423
5822
  joined = true;
5424
5823
  }
5425
5824
 
5825
+ const shouldRetryMediaWithOnlyTurnTLS = await this.shouldRetryMediaWithOnlyTurnTLS(prevError);
5826
+
5426
5827
  const mediaResponse = await this.addMediaInternal(
5427
5828
  () => {
5428
- return this.joinWithMediaRetryInfo.isRetry ? 'JOIN_MEETING_FINAL' : 'JOIN_MEETING_RETRY';
5829
+ // callback is not called when UserNotJoinedError is thrown
5830
+ return this.joinWithMediaRetryInfo.retryCount >= 1
5831
+ ? 'JOIN_MEETING_FINAL'
5832
+ : 'JOIN_MEETING_RETRY';
5429
5833
  },
5430
- turnServerInfo,
5431
5834
  forceTurnDiscovery,
5835
+ turnServerInfo,
5836
+ shouldRetryMediaWithOnlyTurnTLS ? 'relay' : undefined,
5432
5837
  mediaOptions
5433
5838
  );
5434
5839
 
5435
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
5840
+ this.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
5841
+
5842
+ this.locusInfo.suspendDestroyMeeting(false);
5436
5843
 
5437
5844
  return {
5438
5845
  join: joinResponse,
@@ -5446,10 +5853,17 @@ export default class Meeting extends StatelessWebexPlugin {
5446
5853
 
5447
5854
  this.roap.abortTurnDiscovery();
5448
5855
 
5449
- // if this was the first attempt, let's do a retry
5450
- let shouldRetry = !isRetry;
5856
+ // let's do a retry (but not on 1-1 calls, because the flow would get too complicated)
5857
+ let shouldRetry =
5858
+ !MeetingsUtil.isOneOnOneCall(this.locusInfo.parsedLocus) &&
5859
+ (retryCount < 1 ||
5860
+ ((error instanceof UserNotJoinedError || this.isErrorMeaningLocusDroppedUs(error)) &&
5861
+ retryCount < JOIN_WITH_MEDIA_RETRY_MAX_COUNT));
5451
5862
 
5452
- if (CallDiagnosticUtils.isSdpOfferCreationError(error)) {
5863
+ if (
5864
+ CallDiagnosticUtils.isSdpOfferCreationError(error) ||
5865
+ CallDiagnosticUtils.isWebrtcApiNotAvailableError(error)
5866
+ ) {
5453
5867
  // errors related to offer creation (for example missing H264 codec) will happen again no matter how many times we try,
5454
5868
  // so there is no point doing a retry
5455
5869
  shouldRetry = false;
@@ -5469,8 +5883,8 @@ export default class Meeting extends StatelessWebexPlugin {
5469
5883
  });
5470
5884
  }
5471
5885
 
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)) {
5886
+ // we only want to call leave if join was successful, and we won't be doing any more retries
5887
+ if (joined && !shouldRetry) {
5474
5888
  try {
5475
5889
  await this.leave({resourceId: joinOptions?.resourceId, reason: 'joinWithMedia failure'});
5476
5890
  } catch (e) {
@@ -5487,7 +5901,7 @@ export default class Meeting extends StatelessWebexPlugin {
5487
5901
  reason: error.message,
5488
5902
  stack: error.stack,
5489
5903
  leaveErrorReason: leaveError?.message,
5490
- isRetry,
5904
+ isRetry: retryCount > 0,
5491
5905
  },
5492
5906
  {
5493
5907
  type: error.name,
@@ -5496,15 +5910,28 @@ export default class Meeting extends StatelessWebexPlugin {
5496
5910
 
5497
5911
  if (shouldRetry) {
5498
5912
  LoggerProxy.logger.warn('Meeting:index#joinWithMedia --> retrying call to joinWithMedia');
5499
- this.joinWithMediaRetryInfo.isRetry = true;
5913
+ this.joinWithMediaRetryInfo.retryCount = retryCount + 1;
5500
5914
  this.joinWithMediaRetryInfo.prevJoinResponse = joinResponse;
5915
+ this.joinWithMediaRetryInfo.prevError = error;
5916
+ if (!this.joinWithMediaRetryInfo.firstError) {
5917
+ this.joinWithMediaRetryInfo.firstError = error;
5918
+ }
5501
5919
 
5502
5920
  return this.joinWithMedia(options);
5503
5921
  }
5504
5922
 
5505
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
5923
+ const {firstError} = this.joinWithMediaRetryInfo;
5506
5924
 
5507
- throw error;
5925
+ this.joinWithMediaRetryInfo = {
5926
+ retryCount: 0,
5927
+ prevJoinResponse: undefined,
5928
+ firstError: undefined,
5929
+ prevError: undefined,
5930
+ };
5931
+
5932
+ this.locusInfo.suspendDestroyMeeting(false);
5933
+
5934
+ throw firstError ?? error;
5508
5935
  }
5509
5936
  }
5510
5937
 
@@ -5742,7 +6169,23 @@ export default class Meeting extends StatelessWebexPlugin {
5742
6169
  */
5743
6170
  private processLocusLLMEvent = (event: LocusLLMEvent): void => {
5744
6171
  if (event.data.eventType === LOCUSEVENT.HASH_TREE_DATA_UPDATED) {
6172
+ // @ts-ignore
6173
+ if (this.config.experimental.storeLocusHashTreeEventsForDebugging) {
6174
+ storeEventForDebugging('llm', event.data);
6175
+ }
6176
+
6177
+ const {trackingId} = event;
6178
+
5745
6179
  this.locusInfo.parse(this, event.data);
6180
+
6181
+ // Only the client whose /sync request tracking id matches the tracking id echoed back on this
6182
+ // LLM message should emit client.locus.sync.complete. The tracking id lives at the top level
6183
+ // of the received LLM event envelope. When it is absent there is nothing to correlate, so
6184
+ // skip. onLocusSyncLlmMessage records the LLM arrival time and is a no-op unless a stored
6185
+ // record for this meeting matches the tracking id.
6186
+ if (trackingId) {
6187
+ this.onLocusSyncLlmMessage(this.id, trackingId);
6188
+ }
5746
6189
  } else {
5747
6190
  LoggerProxy.logger.warn(
5748
6191
  `Meeting:index#processLocusLLMEvent --> Unknown event type: ${event.data.eventType}`
@@ -5750,6 +6193,31 @@ export default class Meeting extends StatelessWebexPlugin {
5750
6193
  }
5751
6194
  };
5752
6195
 
6196
+ /**
6197
+ * Verifies the relay event was delivered for the active LLM session binding.
6198
+ * @param {RelayEvent} event Event object coming from LLM Connection
6199
+ * @returns {boolean}
6200
+ */
6201
+ private isRelayEventRouteValid(event: RelayEvent): boolean {
6202
+ const route = event?.headers?.route;
6203
+
6204
+ if (!route) {
6205
+ return true;
6206
+ }
6207
+
6208
+ const {llm} = (this as any).webex.internal;
6209
+ const isPracticeSession = llm.isConnected(LLM_PRACTICE_SESSION);
6210
+ const expectedBinding = isPracticeSession
6211
+ ? llm.getBinding(LLM_PRACTICE_SESSION)
6212
+ : llm.getBinding();
6213
+
6214
+ if (!expectedBinding || route === expectedBinding) {
6215
+ return true;
6216
+ }
6217
+
6218
+ return false;
6219
+ }
6220
+
5753
6221
  /**
5754
6222
  * Callback called when a relay event is received from meeting LLM Connection
5755
6223
  * @param {RelayEvent} e Event object coming from LLM Connection
@@ -5757,6 +6225,9 @@ export default class Meeting extends StatelessWebexPlugin {
5757
6225
  * @returns {void}
5758
6226
  */
5759
6227
  private processRelayEvent = (e: RelayEvent): void => {
6228
+ if (!this.isRelayEventRouteValid(e)) {
6229
+ return;
6230
+ }
5760
6231
  switch (e.data.relayType) {
5761
6232
  case REACTION_RELAY_TYPES.REACTION:
5762
6233
  if (
@@ -5765,7 +6236,7 @@ export default class Meeting extends StatelessWebexPlugin {
5765
6236
  this.isReactionsSupported()
5766
6237
  ) {
5767
6238
  const member = this.members.membersCollection.get(e.data.sender.participantId);
5768
- if (!member) {
6239
+ if (!member && !this.locusInfo?.info?.isWebinar) {
5769
6240
  // @ts-ignore -- fix type
5770
6241
  LoggerProxy.logger.warn(
5771
6242
  `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 +6244,7 @@ export default class Meeting extends StatelessWebexPlugin {
5773
6244
  break;
5774
6245
  }
5775
6246
 
5776
- const {name} = member;
6247
+ const name = (member && member.name) || e.data.sender.displayName;
5777
6248
  const processedReaction: ProcessedReaction = {
5778
6249
  reaction: e.data.reaction,
5779
6250
  sender: {
@@ -5802,37 +6273,35 @@ export default class Meeting extends StatelessWebexPlugin {
5802
6273
  * @returns {void}
5803
6274
  */
5804
6275
  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
- );
6276
+ // @ts-ignore
6277
+ this.webex.internal.voicea.off(
6278
+ VOICEAEVENTS.VOICEA_ANNOUNCEMENT,
6279
+ this.voiceaListenerCallbacks[VOICEAEVENTS.VOICEA_ANNOUNCEMENT]
6280
+ );
5811
6281
 
5812
- // @ts-ignore
5813
- this.webex.internal.voicea.off(
5814
- VOICEAEVENTS.CAPTIONS_TURNED_ON,
5815
- this.voiceaListenerCallbacks[VOICEAEVENTS.CAPTIONS_TURNED_ON]
5816
- );
6282
+ // @ts-ignore
6283
+ this.webex.internal.voicea.off(
6284
+ VOICEAEVENTS.CAPTIONS_TURNED_ON,
6285
+ this.voiceaListenerCallbacks[VOICEAEVENTS.CAPTIONS_TURNED_ON]
6286
+ );
5817
6287
 
5818
- // @ts-ignore
5819
- this.webex.internal.voicea.off(
5820
- VOICEAEVENTS.EVA_COMMAND,
5821
- this.voiceaListenerCallbacks[VOICEAEVENTS.EVA_COMMAND]
5822
- );
6288
+ // @ts-ignore
6289
+ this.webex.internal.voicea.off(
6290
+ VOICEAEVENTS.EVA_COMMAND,
6291
+ this.voiceaListenerCallbacks[VOICEAEVENTS.EVA_COMMAND]
6292
+ );
5823
6293
 
5824
- // @ts-ignore
5825
- this.webex.internal.voicea.off(
5826
- VOICEAEVENTS.NEW_CAPTION,
5827
- this.voiceaListenerCallbacks[VOICEAEVENTS.NEW_CAPTION]
5828
- );
6294
+ // @ts-ignore
6295
+ this.webex.internal.voicea.off(
6296
+ VOICEAEVENTS.NEW_CAPTION,
6297
+ this.voiceaListenerCallbacks[VOICEAEVENTS.NEW_CAPTION]
6298
+ );
5829
6299
 
5830
- // @ts-ignore
5831
- this.webex.internal.voicea.deregisterEvents();
6300
+ // @ts-ignore
6301
+ this.webex.internal.voicea.deregisterEvents();
5832
6302
 
5833
- this.areVoiceaEventsSetup = false;
5834
- this.triggerStopReceivingTranscriptionEvent();
5835
- }
6303
+ this.areVoiceaEventsSetup = false;
6304
+ this.triggerStopReceivingTranscriptionEvent();
5836
6305
  }
5837
6306
 
5838
6307
  /**
@@ -5856,6 +6325,31 @@ export default class Meeting extends StatelessWebexPlugin {
5856
6325
  );
5857
6326
  }
5858
6327
 
6328
+ /**
6329
+ * Restores LLM subchannel subscriptions after reconnect when captions are active.
6330
+ * @returns {void}
6331
+ */
6332
+ private restoreLLMSubscriptionsIfNeeded(): void {
6333
+ try {
6334
+ const keepTranscriptionSubscribed =
6335
+ // @ts-ignore
6336
+ this.webex.internal.voicea?.getKeepTranscriptionSubscribed?.();
6337
+
6338
+ if (!keepTranscriptionSubscribed) {
6339
+ return;
6340
+ }
6341
+
6342
+ // @ts-ignore
6343
+ this.webex.internal.voicea.updateSubchannelSubscriptions({subscribe: ['transcription']});
6344
+ } catch (error) {
6345
+ const msg = error?.message || String(error);
6346
+
6347
+ LoggerProxy.logger.warn(
6348
+ `Meeting:index#restoreLLMSubscriptionsIfNeeded --> failed to restore subscriptions after LLM online: ${msg}`
6349
+ );
6350
+ }
6351
+ }
6352
+
5859
6353
  /**
5860
6354
  * This is a callback for the LLM event that is triggered when it comes online
5861
6355
  * This method in turn will trigger an event to the developers that the LLM is connected
@@ -5864,8 +6358,9 @@ export default class Meeting extends StatelessWebexPlugin {
5864
6358
  * @returns {null}
5865
6359
  */
5866
6360
  private handleLLMOnline = (): void => {
5867
- // @ts-ignore
5868
- this.webex.internal.llm.off('online', this.handleLLMOnline);
6361
+ this.restoreLLMSubscriptionsIfNeeded();
6362
+ this.locusInfo.syncAllHashTreeDatasets({onlyLLM: true});
6363
+
5869
6364
  Trigger.trigger(
5870
6365
  this,
5871
6366
  {
@@ -6093,11 +6588,14 @@ export default class Meeting extends StatelessWebexPlugin {
6093
6588
  return Promise.reject(error);
6094
6589
  })
6095
6590
  .then((join) => {
6591
+ this.saveDataChannelToken(join);
6096
6592
  // @ts-ignore - config coming from registerPlugin
6097
6593
  if (this.config.enableAutomaticLLM) {
6594
+ // @ts-ignore
6595
+ this.webex.internal.llm.off('online', this.handleLLMOnline);
6098
6596
  // @ts-ignore
6099
6597
  this.webex.internal.llm.on('online', this.handleLLMOnline);
6100
- this.updateLLMConnection()
6598
+ this.updateLLMConnection({isInitialJoinPhase: true})
6101
6599
  .catch((error) => {
6102
6600
  LoggerProxy.logger.error(
6103
6601
  'Meeting:index#join --> Transcription Socket Connection Failed',
@@ -6161,26 +6659,275 @@ export default class Meeting extends StatelessWebexPlugin {
6161
6659
  }
6162
6660
  }
6163
6661
 
6662
+ /**
6663
+ * Removes LLM event listeners and clears the health check timer.
6664
+ * Must be called before Locus /leave to avoid unnecessary syncs triggered
6665
+ * by events received while leaving (per Locus team recommendation).
6666
+ * Idempotent: safe to call multiple times; .off() is a no-op when no
6667
+ * matching listener is registered.
6668
+ * @private
6669
+ * @returns {void}
6670
+ */
6671
+ private stopListeningForLLMEvents() {
6672
+ // @ts-ignore - fix types
6673
+ this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6674
+ // @ts-ignore - fix types
6675
+ this.webex.internal.llm.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6676
+ this.clearLLMHealthCheckTimer();
6677
+ }
6678
+
6679
+ /**
6680
+ * Stops listening on every event bus (LLM, Mercury, voicea/transcription,
6681
+ * annotation) that could otherwise deliver events to this meeting while
6682
+ * Locus is processing /leave or /end. Per the Locus team recommendation,
6683
+ * this must run before the Locus request is dispatched to avoid
6684
+ * unnecessary syncs triggered by in-flight events.
6685
+ *
6686
+ * Voicea (transcription) subscribes to llm 'event:relay.event' internally,
6687
+ * and the annotation plugin subscribes to both mercury and llm, so both
6688
+ * must be torn down alongside the direct LLM/Mercury listeners.
6689
+ *
6690
+ * Idempotent: safe to call multiple times; .off() is a no-op when no
6691
+ * matching listener is registered, and stopTranscription is guarded.
6692
+ * @private
6693
+ * @returns {void}
6694
+ */
6695
+ private stopListeningForMeetingEvents() {
6696
+ this.stopListeningForLLMEvents();
6697
+ this.stopListeningForMercuryEvents();
6698
+ if (this.transcription) {
6699
+ this.stopTranscription();
6700
+ this.transcription = undefined;
6701
+ }
6702
+ this.annotation.deregisterEvents();
6703
+ }
6704
+
6705
+ /**
6706
+ * Disconnects and cleans up the default LLM session listeners/timers.
6707
+ *
6708
+ * Ownership-aware: only calls `disconnectLLM` when this meeting is the
6709
+ * current owner of the default LLM session (or when no owner is recorded).
6710
+ * Event listeners belonging to this meeting instance are always detached
6711
+ * so they do not receive another meeting's relay events.
6712
+ *
6713
+ * @param {Object} options
6714
+ * @param {boolean} [options.removeOnlineListener=true] removes the one-time online listener
6715
+ * @param {boolean} [options.throwOnError=true] rethrows disconnect errors when true
6716
+ * @returns {Promise<void>}
6717
+ */
6718
+ private cleanupLLMConneciton = async ({
6719
+ removeOnlineListener = true,
6720
+ throwOnError = true,
6721
+ }: {
6722
+ removeOnlineListener?: boolean;
6723
+ throwOnError?: boolean;
6724
+ } = {}): Promise<void> => {
6725
+ // @ts-ignore - Fix type
6726
+ // @ts-ignore - Fix type
6727
+ const {currentOwner, isOwner} = this.webex.internal.llm.resolveSessionOwnership(
6728
+ this.id,
6729
+ LLM_DEFAULT_SESSION
6730
+ );
6731
+
6732
+ try {
6733
+ if (isOwner) {
6734
+ // @ts-ignore - Fix type
6735
+ await this.webex.internal.llm.disconnectLLM(
6736
+ {
6737
+ code: 3050,
6738
+ reason: 'done (permanent)',
6739
+ },
6740
+ LLM_DEFAULT_SESSION,
6741
+ this.id
6742
+ );
6743
+ } else {
6744
+ LoggerProxy.logger.info(
6745
+ `Meeting:index#cleanupLLMConneciton --> skipping disconnect; LLM owned by meeting ${currentOwner}, not ${this.id}`
6746
+ );
6747
+ }
6748
+ } catch (error) {
6749
+ LoggerProxy.logger.error(
6750
+ 'Meeting:index#cleanupLLMConneciton --> Failed to disconnect default LLM session',
6751
+ error
6752
+ );
6753
+
6754
+ if (throwOnError) {
6755
+ throw error;
6756
+ }
6757
+ } finally {
6758
+ if (removeOnlineListener) {
6759
+ // @ts-ignore - Fix type
6760
+ this.webex.internal.llm.off('online', this.handleLLMOnline);
6761
+ }
6762
+ this.stopListeningForLLMEvents();
6763
+
6764
+ // Re-check ownership after awaiting disconnectLLM. If ownership changed
6765
+ // while cleanup was in flight, do not clear another meeting's owner tag.
6766
+ if (isOwner) {
6767
+ const {currentOwner: currentOwnerAfterCleanup} =
6768
+ // @ts-ignore - Fix type
6769
+ this.webex.internal.llm.resolveSessionOwnership(this.id, LLM_DEFAULT_SESSION);
6770
+
6771
+ if (currentOwnerAfterCleanup === this.id) {
6772
+ // @ts-ignore - Fix type
6773
+ this.webex.internal.llm.setOwnerMeetingId?.(undefined);
6774
+ }
6775
+ }
6776
+ }
6777
+ };
6778
+
6779
+ /**
6780
+ * Clears data channel tokens associated with this meeting ownership.
6781
+ * Ownership checks are enforced in internal-plugin-llm.
6782
+ * @returns {void}
6783
+ */
6784
+ clearDataChannelToken(): void {
6785
+ // @ts-ignore
6786
+ this.webex.internal.llm.clearDatachannelToken(LLM_DEFAULT_SESSION, this.id);
6787
+ // @ts-ignore
6788
+ this.webex.internal.llm.clearDatachannelToken(LLM_PRACTICE_SESSION, this.id);
6789
+ }
6790
+
6791
+ /**
6792
+ * Saves the data channel tokens from the join response into LLM so that
6793
+ * updateLLMConnection / updatePSDataChannel don't need to fetch them from locusInfo.
6794
+ * @param {Object} join - The parsed join response (from MeetingUtil.parseLocusJoin)
6795
+ * @returns {void}
6796
+ */
6797
+ saveDataChannelToken(join: any): void {
6798
+ const datachannelToken = join?.locus?.self?.datachannelToken;
6799
+ const practiceSessionDatachannelToken = join?.locus?.self?.practiceSessionDatachannelToken;
6800
+
6801
+ if (datachannelToken) {
6802
+ // @ts-ignore
6803
+ this.webex.internal.llm.setDatachannelToken(datachannelToken, LLM_DEFAULT_SESSION, this.id);
6804
+ }
6805
+
6806
+ if (practiceSessionDatachannelToken) {
6807
+ // @ts-ignore
6808
+ this.webex.internal.llm.setDatachannelToken(
6809
+ practiceSessionDatachannelToken,
6810
+ LLM_PRACTICE_SESSION,
6811
+ this.id
6812
+ );
6813
+ }
6814
+ }
6815
+
6816
+ /**
6817
+ * Ensures default-session data channel token exists after lobby admission.
6818
+ * Some lobby users do not receive a token until they are admitted.
6819
+ * @returns {Promise<boolean>} true when a new token is fetched and cached
6820
+ */
6821
+ private async ensureDefaultDatachannelTokenAfterAdmit(): Promise<boolean> {
6822
+ try {
6823
+ // @ts-ignore
6824
+ const datachannelToken = this.webex.internal.llm.getDatachannelToken(
6825
+ LLM_DEFAULT_SESSION,
6826
+ this.id
6827
+ );
6828
+ // @ts-ignore
6829
+ const isDataChannelTokenEnabled = await this.webex.internal.llm.isDataChannelTokenEnabled();
6830
+
6831
+ if (!isDataChannelTokenEnabled || datachannelToken) {
6832
+ return false;
6833
+ }
6834
+
6835
+ const response = await this.meetingRequest.fetchDatachannelToken({
6836
+ locusUrl: this.locusUrl,
6837
+ requestingParticipantId: this.members.selfId,
6838
+ isPracticeSession: false,
6839
+ });
6840
+ const fetchedDatachannelToken = response?.body?.datachannelToken;
6841
+
6842
+ if (!fetchedDatachannelToken) {
6843
+ return false;
6844
+ }
6845
+
6846
+ // @ts-ignore
6847
+ this.webex.internal.llm.setDatachannelToken(
6848
+ fetchedDatachannelToken,
6849
+ LLM_DEFAULT_SESSION,
6850
+ this.id
6851
+ );
6852
+
6853
+ return true;
6854
+ } catch (error) {
6855
+ const msg = error?.message || String(error);
6856
+
6857
+ LoggerProxy.logger.warn(
6858
+ `Meeting:index#ensureDefaultDatachannelTokenAfterAdmit --> failed to proactively fetch default data channel token after admit: ${msg}`,
6859
+ {statusCode: error?.statusCode}
6860
+ );
6861
+
6862
+ return false;
6863
+ }
6864
+ }
6865
+
6164
6866
  /**
6165
6867
  * Connects to low latency mercury and reconnects if the address has changed
6166
6868
  * It will also disconnect if called when the meeting has ended
6167
- * @param {String} datachannelUrl
6869
+ * @param {Object} [options]
6870
+ * @param {boolean} [options.isInitialJoinPhase] true when called from initial join flow
6168
6871
  * @returns {Promise}
6169
6872
  */
6170
- async updateLLMConnection() {
6873
+ async updateLLMConnection({isInitialJoinPhase = false}: {isInitialJoinPhase?: boolean} = {}) {
6171
6874
  // @ts-ignore - Fix type
6172
- const {url, info: {datachannelUrl, practiceSessionDatachannelUrl} = {}} = this.locusInfo;
6875
+ const {url = undefined, info: {datachannelUrl = undefined} = {}} = this.locusInfo || {};
6173
6876
 
6174
6877
  const isJoined = this.isJoined();
6175
6878
 
6176
- // webinar panelist should use new data channel in practice session
6177
- const dataChannelUrl =
6178
- this.webinar.isJoinPracticeSessionDataChannel() && practiceSessionDatachannelUrl
6179
- ? practiceSessionDatachannelUrl
6180
- : datachannelUrl;
6879
+ const dataChannelUrl = datachannelUrl;
6880
+
6881
+ // Ownership guard: when the default LLM session is already connected and
6882
+ // owned by a *different* Meeting instance, do not disconnect or reconfigure
6883
+ // it. Another meeting's `updateLLMConnection` must be ignored here to
6884
+ // avoid killing the socket it relies on. We only proceed to manage the
6885
+ // connection when this meeting is the current owner, or when no owner is
6886
+ // set yet (first claim).
6887
+ // @ts-ignore - Fix type
6888
+ const {currentOwner} = this.webex.internal.llm.resolveSessionOwnership(
6889
+ this.id,
6890
+ LLM_DEFAULT_SESSION
6891
+ );
6181
6892
 
6893
+ // Capture connectivity before any reconnect attempt. If LLM was already
6894
+ // connected, we must respect current ownership. If it was disconnected,
6895
+ // this flow may reclaim stale owner tags after a fresh connect.
6182
6896
  // @ts-ignore - Fix type
6183
- if (this.webex.internal.llm.isConnected()) {
6897
+ const wasConnected = this.webex.internal.llm.isConnected();
6898
+
6899
+ // Prefer ownership-scoped token read. For disconnected stale-owner reclaim
6900
+ // flows, fallback to ownerless read so initial register can still carry a
6901
+ // token and recover from stale ownership without 401/403 dead-end.
6902
+ // @ts-ignore - Fix type
6903
+ let datachannelToken = this.webex.internal.llm.getDatachannelToken(
6904
+ LLM_DEFAULT_SESSION,
6905
+ this.id
6906
+ );
6907
+
6908
+ if (!datachannelToken && !wasConnected && currentOwner && currentOwner !== this.id) {
6909
+ // @ts-ignore - Fix type
6910
+ datachannelToken = this.webex.internal.llm.getDatachannelToken(LLM_DEFAULT_SESSION);
6911
+ }
6912
+
6913
+ // @ts-ignore - Fix type
6914
+ if (wasConnected) {
6915
+ if (currentOwner && currentOwner !== this.id) {
6916
+ // Another meeting owns the live LLM socket. We must not disconnect
6917
+ // or reconfigure it -- doing so would tear down a session the
6918
+ // owning meeting still relies on. Locus/datachannel URL mismatch is
6919
+ // expected here (each meeting has its own locus URL) and is NOT a
6920
+ // valid signal of staleness, so we never reclaim from this path.
6921
+ // The only safe reclaim mechanism is the `finally`-block owner-tag
6922
+ // release in `cleanupLLMConneciton`, which fires when this meeting
6923
+ // itself is being torn down.
6924
+ LoggerProxy.logger.info(
6925
+ `Meeting:index#updateLLMConnection --> skipping; LLM owned by meeting ${currentOwner}, not ${this.id}`
6926
+ );
6927
+
6928
+ return undefined;
6929
+ }
6930
+
6184
6931
  if (
6185
6932
  // @ts-ignore - Fix type
6186
6933
  url === this.webex.internal.llm.getLocusUrl() &&
@@ -6190,31 +6937,63 @@ export default class Meeting extends StatelessWebexPlugin {
6190
6937
  ) {
6191
6938
  return undefined;
6192
6939
  }
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();
6940
+ await this.cleanupLLMConneciton({removeOnlineListener: false});
6208
6941
  }
6209
6942
 
6210
6943
  if (!isJoined) {
6211
6944
  return undefined;
6212
6945
  }
6213
6946
 
6947
+ // Bind refresh handler before registration so interceptor-triggered token
6948
+ // refresh during register POST can resolve a valid handler.
6949
+ // Prefer this meeting as owner, but allow owner-less fallback when a stale
6950
+ // foreign owner tag is present on a disconnected session.
6951
+ const refreshHandlerOwnerMeetingId =
6952
+ currentOwner && currentOwner !== this.id ? undefined : this.id;
6953
+ const shouldAlignRefreshHandlerAfterOwnershipClaim = refreshHandlerOwnerMeetingId !== this.id;
6954
+ // @ts-ignore - Fix type
6955
+ this.webex.internal.llm.setRefreshHandler(
6956
+ () => this.refreshDataChannelToken(),
6957
+ LLM_DEFAULT_SESSION,
6958
+ refreshHandlerOwnerMeetingId
6959
+ );
6960
+
6214
6961
  // @ts-ignore - Fix type
6215
6962
  return this.webex.internal.llm
6216
- .registerAndConnect(url, dataChannelUrl)
6963
+ .registerAndConnect(url, dataChannelUrl, datachannelToken)
6217
6964
  .then((registerAndConnectResult) => {
6965
+ this.locusInfo.syncAllHashTreeDatasets({onlyLLM: true});
6966
+ // Record ownership of the default LLM session for this meeting so
6967
+ // subsequent cross-meeting `updateLLMConnection` / `cleanupLLMConneciton`
6968
+ // calls can detect and skip work that doesn't belong to them.
6969
+ // @ts-ignore - Fix type
6970
+ const {isOwner} = this.webex.internal.llm.resolveSessionOwnership(
6971
+ this.id,
6972
+ LLM_DEFAULT_SESSION
6973
+ );
6974
+ const canReclaimAfterDisconnectedStart = !wasConnected;
6975
+
6976
+ // Refresh handler is pre-bound before registerAndConnect so token
6977
+ // refresh can work even during the registration request itself.
6978
+ if (isOwner || canReclaimAfterDisconnectedStart) {
6979
+ // Record ownership of the default LLM session for this meeting so
6980
+ // subsequent cross-meeting `updateLLMConnection` / `cleanupLLMConneciton`
6981
+ // calls can detect and skip work that doesn't belong to them.
6982
+ // @ts-ignore - Fix type
6983
+ this.webex.internal.llm.setOwnerMeetingId?.(this.id);
6984
+
6985
+ // If we pre-bound refresh ownerlessly (stale-owner reclaim path),
6986
+ // align the handler with the newly claimed owner immediately after
6987
+ // ownership is updated.
6988
+ if (shouldAlignRefreshHandlerAfterOwnershipClaim) {
6989
+ // @ts-ignore - Fix type
6990
+ this.webex.internal.llm.setRefreshHandler(
6991
+ () => this.refreshDataChannelToken(),
6992
+ LLM_DEFAULT_SESSION,
6993
+ this.id
6994
+ );
6995
+ }
6996
+ }
6218
6997
  // @ts-ignore - Fix type
6219
6998
  this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6220
6999
  // @ts-ignore - Fix type
@@ -6229,10 +7008,114 @@ export default class Meeting extends StatelessWebexPlugin {
6229
7008
 
6230
7009
  this.startLLMHealthCheckTimer();
6231
7010
 
7011
+ if (registerAndConnectResult) {
7012
+ if (isInitialJoinPhase) {
7013
+ this.sendLLMConnectMetric(registerAndConnectResult);
7014
+ }
7015
+
7016
+ this.breakouts?.trigger(BREAKOUTS.EVENTS.LLM_CONNECT_RESPONSE, {
7017
+ meeting: this,
7018
+ llmLatency: registerAndConnectResult,
7019
+ });
7020
+ }
7021
+
6232
7022
  return Promise.resolve(registerAndConnectResult);
7023
+ })
7024
+ .catch((error) => {
7025
+ // Prefer the partial timing registerAndConnect attaches when register succeeded but the
7026
+ // websocket connect() failed, so a ws failure isn't misreported as register never completing.
7027
+ const llmLatency = {
7028
+ clientLLMDatachannelResponseTime: error?.timing?.clientLLMDatachannelResponseTime ?? 0,
7029
+ clientLLMWebSocketConnectTime: 0,
7030
+ };
7031
+
7032
+ if (isInitialJoinPhase) {
7033
+ this.sendLLMConnectMetric(llmLatency, error);
7034
+ }
7035
+
7036
+ this.breakouts?.trigger(BREAKOUTS.EVENTS.LLM_CONNECT_RESPONSE, {
7037
+ meeting: this,
7038
+ llmLatency,
7039
+ error,
7040
+ });
7041
+
7042
+ return Promise.reject(error);
6233
7043
  });
6234
7044
  }
6235
7045
 
7046
+ /**
7047
+ * Ensures breakout join response metric with LLM latency is emitted only once per breakout move id.
7048
+ * @param {string | undefined} breakoutMoveId
7049
+ * @param {boolean} [hasLLMLatency=false]
7050
+ * @returns {boolean}
7051
+ */
7052
+ private shouldEmitBreakoutJoinResponseMetric(
7053
+ breakoutMoveId?: string,
7054
+ hasLLMLatency = false
7055
+ ): boolean {
7056
+ if (!breakoutMoveId) {
7057
+ return false;
7058
+ }
7059
+
7060
+ if (!hasLLMLatency) {
7061
+ // When automatic LLM is enabled, updateLLMConnection will emit this same breakout join
7062
+ // response after the LLM connection finishes, including llmLatency and llmWebsocketUrl.
7063
+ // Suppress the earlier non-LLM event to avoid sending two events for the same move id,
7064
+ // where the first one would be missing the LLM-specific fields we want to validate.
7065
+ // @ts-ignore - config coming from registerPlugin
7066
+ return !this.config.enableAutomaticLLM;
7067
+ }
7068
+
7069
+ if (this.emittedBreakoutJoinResponseMoveIds.has(breakoutMoveId)) {
7070
+ return false;
7071
+ }
7072
+
7073
+ this.emittedBreakoutJoinResponseMoveIds.add(breakoutMoveId);
7074
+
7075
+ return true;
7076
+ }
7077
+
7078
+ /**
7079
+ * Sends LLM connect latencies for initial join flow.
7080
+ * @param {RegisterAndConnectTiming} timings
7081
+ * @param {any} [error]
7082
+ * @returns {void}
7083
+ */
7084
+ private sendLLMConnectMetric(timings: RegisterAndConnectTiming, error?: any) {
7085
+ // @ts-ignore
7086
+ const llmWebsocketUrl = this.webex.internal.llm.getWebSocketUrl?.() || undefined;
7087
+ const {clientLLMDatachannelResponseTime = 0, clientLLMWebSocketConnectTime} = timings || {};
7088
+
7089
+ const llmLatency: any = {
7090
+ clientLLMDatachannelResponseTime,
7091
+ };
7092
+
7093
+ if (clientLLMWebSocketConnectTime !== undefined) {
7094
+ llmLatency.clientLLMWebSocketConnectTime = clientLLMWebSocketConnectTime;
7095
+ }
7096
+
7097
+ const payload: any = {
7098
+ identifiers: {
7099
+ llmWebsocketUrl,
7100
+ },
7101
+ llmLatency,
7102
+ };
7103
+
7104
+ const options: any = {
7105
+ meetingId: this.id,
7106
+ ...(error && {rawError: error}),
7107
+ };
7108
+
7109
+ const metricEvent = {
7110
+ name: 'client.llm.connect.response',
7111
+ payload,
7112
+ options,
7113
+ };
7114
+
7115
+ // @ts-ignore
7116
+ this.webex.internal.newMetrics.submitClientEvent(metricEvent);
7117
+ }
7118
+
6236
7119
  /**
6237
7120
  * Use phone for meeting audio
6238
7121
  * @param {String} phoneNumber If provided, it will dial-out using this number. If not provided, dial-in will be used
@@ -6660,16 +7543,32 @@ export default class Meeting extends StatelessWebexPlugin {
6660
7543
  // @ts-ignore
6661
7544
  const cdl = this.webex.internal.newMetrics.callDiagnosticLatencies;
6662
7545
 
7546
+ // Compute the offer->answer latency from when the local SDP offer was generated up to now,
7547
+ // rather than from the stored remote-sdp-received timestamp. That stored timestamp uses
7548
+ // saveFirstTimestampOnly, so if waitForRemoteSDPAnswer() already timed out and submitted a
7549
+ // remote-sdp-received event, the stored value would be pinned to the timeout time and would
7550
+ // under-report an answer that arrives late. This handler fires exactly when the answer is
7551
+ // processed, so Date.now() is the accurate "received" time.
7552
+ // (submitClientEvent below still records the remote-sdp-received timestamp used by the CA
7553
+ // join-time metric, so we don't need to save it here.)
7554
+ const localSdpGeneratedTimestamp = cdl.latencyTimestamps.get(
7555
+ 'client.media-engine.local-sdp-generated'
7556
+ );
7557
+ const localSDPGenRemoteSDPRecv =
7558
+ localSdpGeneratedTimestamp !== undefined
7559
+ ? Date.now() - localSdpGeneratedTimestamp
7560
+ : undefined;
7561
+
6663
7562
  // @ts-ignore
6664
7563
  this.webex.internal.newMetrics.submitClientEvent({
6665
7564
  name: 'client.media-engine.remote-sdp-received',
7565
+ payload: {
7566
+ eventData: {
7567
+ localSDPGenRemoteSDPRecv,
7568
+ },
7569
+ },
6666
7570
  options: {meetingId: this.id},
6667
7571
  });
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
7572
 
6674
7573
  if (this.deferSDPAnswer) {
6675
7574
  this.deferSDPAnswer.resolve();
@@ -7255,23 +8154,104 @@ export default class Meeting extends StatelessWebexPlugin {
7255
8154
  }
7256
8155
  }
7257
8156
  });
8157
+ this.statsAnalyzer.on(StatsAnalyzerEventNames.STATS_UPDATE, (data) => {
8158
+ // Extract srtpCipher from transport stats
8159
+ let srtpCipher: string | undefined;
8160
+ for (const stats of data.stats.values()) {
8161
+ if (stats.type === 'transport' && stats.srtpCipher) {
8162
+ srtpCipher = stats.srtpCipher as string;
8163
+ break;
8164
+ }
8165
+ }
8166
+
8167
+ // Only emit event if srtpCipher has changed
8168
+ if (srtpCipher && srtpCipher !== this.mediaProperties.srtpCipher) {
8169
+ LoggerProxy.logger.info(
8170
+ `Meeting:index#setupStatsAnalyzerEventHandlers --> SRTP cipher changed from ${this.mediaProperties.srtpCipher} to ${srtpCipher}`
8171
+ );
8172
+ this.mediaProperties.srtpCipher = srtpCipher;
8173
+ Trigger.trigger(
8174
+ this,
8175
+ {
8176
+ file: 'meeting/index',
8177
+ function: 'setupStatsAnalyzerEventHandlers',
8178
+ },
8179
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
8180
+ {srtpCipher}
8181
+ );
8182
+ }
8183
+ });
7258
8184
  };
7259
8185
 
7260
8186
  getMediaConnectionDebugId() {
7261
8187
  return `MC-${this.id.substring(0, 4)}`;
7262
8188
  }
7263
8189
 
8190
+ /**
8191
+ * Checks if the error indicates that Locus dropped us from the meeting,
8192
+ * either directly on the error or wrapped inside an AddMediaFailed cause.
8193
+ * This method is meant to be called only with errors thrown by Meeting.addMediaInternal()
8194
+ *
8195
+ * @param {Error} error
8196
+ * @returns {boolean}
8197
+ */
8198
+ private isErrorMeaningLocusDroppedUs(error: Error | undefined): boolean {
8199
+ const statusCode = (error as any)?.statusCode;
8200
+ const causeStatusCode = (error as any)?.cause?.statusCode;
8201
+
8202
+ return (
8203
+ statusCode === 409 || statusCode === 403 || causeStatusCode === 409 || causeStatusCode === 403
8204
+ );
8205
+ }
8206
+
8207
+ /**
8208
+ * Determines if the next media attempt should use only TURN-TLS (iceTransportPolicy='relay').
8209
+ * We do this in the hope that it will minimize the chance of Homer sending DTLS packets on a wrong
8210
+ * transport (as there will be only 1 transport) and dealing with firewalls that let STUN packets through, but block
8211
+ * other UDP traffic.
8212
+ *
8213
+ * For clients landing on video mesh nodes (VMN), reachability might still have successful TLS (to public nodes)
8214
+ * but TURN discovery will result in empty TURN urls array and iceTransportPolicy='relay' will still be overriden to undefined,
8215
+ * see the code in establishMediaConnection()
8216
+ *
8217
+ * @param {Error} prevError - The error from the previous addMedia attempt
8218
+ * @returns {Promise<boolean>}
8219
+ */
8220
+ private async shouldRetryMediaWithOnlyTurnTLS(prevError: Error | undefined): Promise<boolean> {
8221
+ if (
8222
+ this.isMultistream &&
8223
+ prevError instanceof AddMediaFailed &&
8224
+ prevError.isDtlsHandshakeFailure &&
8225
+ prevError.connectionType === 'UDP'
8226
+ ) {
8227
+ const hasTlsReachability =
8228
+ // @ts-ignore
8229
+ await this.webex.meetings.reachability.isAnyClusterReachableViaProtocol('xtls');
8230
+
8231
+ if (hasTlsReachability) {
8232
+ LoggerProxy.logger.info(
8233
+ 'Meeting:index#shouldRetryMediaWithOnlyTurnTLS --> previous attempt failed due to DTLS handshake failure over UDP and TLS reachability is available'
8234
+ );
8235
+
8236
+ return true;
8237
+ }
8238
+ }
8239
+
8240
+ return false;
8241
+ }
8242
+
7264
8243
  /**
7265
8244
  * Creates a webrtc media connection and publishes streams to it
7266
8245
  *
7267
8246
  * @param {Object} turnServerInfo TURN server information
7268
8247
  * @param {BundlePolicy} [bundlePolicy] Bundle policy settings
7269
- * @param {AddMediaOptions} [options] Options for enabling/disabling audio/video
8248
+ * @param {RTCIceTransportPolicy} [iceTransportPolicy] ICE transport policy override
7270
8249
  * @returns {RoapMediaConnection | MultistreamRoapMediaConnection}
7271
8250
  */
7272
8251
  private async createMediaConnection(
7273
8252
  turnServerInfo?: TurnServerInfo,
7274
- bundlePolicy?: BundlePolicy
8253
+ bundlePolicy?: BundlePolicy,
8254
+ iceTransportPolicy?: RTCIceTransportPolicy
7275
8255
  ) {
7276
8256
  this.rtcMetrics = this.isMultistream
7277
8257
  ? // @ts-ignore
@@ -7295,12 +8275,15 @@ export default class Meeting extends StatelessWebexPlugin {
7295
8275
  enableExtmap: this.config.enableExtmap,
7296
8276
  turnServerInfo,
7297
8277
  bundlePolicy,
8278
+ iceTransportPolicy,
7298
8279
  // @ts-ignore - config coming from registerPlugin
7299
8280
  iceCandidatesTimeout: this.config.iceCandidatesGatheringTimeout,
7300
8281
  // @ts-ignore - config coming from registerPlugin
7301
8282
  disableAudioMainDtx: this.config.experimental.disableAudioMainDtx,
7302
8283
  // @ts-ignore - config coming from registerPlugin
7303
8284
  enableAudioTwcc: this.config.enableAudioTwccForMultistream,
8285
+ // @ts-ignore - config coming from registerPlugin
8286
+ enableAv1SlidesSupport: this.config.enableAv1SlidesSupport,
7304
8287
  stopIceGatheringAfterFirstRelayCandidate:
7305
8288
  // @ts-ignore - config coming from registerPlugin
7306
8289
  this.config.stopIceGatheringAfterFirstRelayCandidate,
@@ -7320,6 +8303,7 @@ export default class Meeting extends StatelessWebexPlugin {
7320
8303
  this.mediaProperties.mediaDirection.receiveShare,
7321
8304
  ];
7322
8305
 
8306
+ this.sendSlotManager.reset();
7323
8307
  this.sendSlotManager.createSlot(mc, MediaType.VideoMain, videoEnabled);
7324
8308
  this.sendSlotManager.createSlot(mc, MediaType.AudioMain, audioEnabled);
7325
8309
  this.sendSlotManager.createSlot(mc, MediaType.VideoSlides, shareEnabled);
@@ -7417,9 +8401,9 @@ export default class Meeting extends StatelessWebexPlugin {
7417
8401
  */
7418
8402
  private async waitForMediaConnectionConnected(): Promise<void> {
7419
8403
  try {
7420
- await this.mediaProperties.waitForMediaConnectionConnected();
8404
+ await this.mediaProperties.waitForMediaConnectionConnected(this.correlationId);
7421
8405
  } catch (error) {
7422
- const {iceConnected} = error;
8406
+ const {iceConnected} = error as MediaConnectionAwaiterFailureResult;
7423
8407
 
7424
8408
  if (!this.hasMediaConnectionConnectedAtLeastOnce) {
7425
8409
  // Only send CA event for join flow if we haven't successfully connected media yet
@@ -7459,13 +8443,12 @@ export default class Meeting extends StatelessWebexPlugin {
7459
8443
  });
7460
8444
  }
7461
8445
 
7462
- const timedOutError = new Error(
7463
- `Timed out waiting for media connection to be connected, correlationId=${this.correlationId}`
8446
+ throw new MediaConnectionTimedOutError(
8447
+ `Timed out waiting for media connection to be connected, correlationId=${this.correlationId}`,
8448
+ iceConnected,
8449
+ // keep reference to the original rejected result (which is the object the SDK reports to CA as rawError above)
8450
+ error
7464
8451
  );
7465
-
7466
- timedOutError.cause = error;
7467
-
7468
- throw timedOutError;
7469
8452
  }
7470
8453
  }
7471
8454
 
@@ -7511,12 +8494,12 @@ export default class Meeting extends StatelessWebexPlugin {
7511
8494
  return !member.isSelf && !member.isPairedWithSelf && !member.isAudioMuted;
7512
8495
  });
7513
8496
 
7514
- if (atLeastOneUnmutedOtherMember) {
7515
- this.mediaProperties.sendMediaIssueMetric(
7516
- 'inbound_audio',
7517
- data.issueSubType,
7518
- this.correlationId
7519
- );
8497
+ // we also ignore any issues while we're waiting in the lobby, as we're not receiving any audio yet
8498
+ if (atLeastOneUnmutedOtherMember && !this.isUserUnadmitted) {
8499
+ this.mediaProperties.sendMediaIssueMetric('inbound_audio', data.issueSubType, {
8500
+ correlationId: this.correlationId,
8501
+ isMultistream: this.isMultistream,
8502
+ });
7520
8503
 
7521
8504
  Trigger.trigger(
7522
8505
  this,
@@ -7678,7 +8661,18 @@ export default class Meeting extends StatelessWebexPlugin {
7678
8661
  error
7679
8662
  );
7680
8663
 
7681
- throw new AddMediaFailed(error);
8664
+ const {connectionType, selectedCandidatePairChanges, numTransports} =
8665
+ await this.mediaProperties.getCurrentConnectionInfo();
8666
+
8667
+ const iceConnected = error instanceof MediaConnectionTimedOutError && error.iceConnected;
8668
+
8669
+ throw new AddMediaFailed({
8670
+ cause: error,
8671
+ connectionType,
8672
+ selectedCandidatePairChanges,
8673
+ numTransports,
8674
+ iceConnected,
8675
+ });
7682
8676
  }
7683
8677
  }
7684
8678
 
@@ -7753,7 +8747,21 @@ export default class Meeting extends StatelessWebexPlugin {
7753
8747
  ({turnServerInfo} = await this.doTurnDiscovery(isReconnecting, isForced));
7754
8748
  }
7755
8749
 
7756
- const mc = await this.createMediaConnection(turnServerInfo, bundlePolicy);
8750
+ if (
8751
+ (!turnServerInfo || !turnServerInfo.urls?.length) &&
8752
+ this.addMediaData.iceTransportPolicy === 'relay'
8753
+ ) {
8754
+ LoggerProxy.logger.info(
8755
+ `${LOG_HEADER} cannot do iceTransportPolicy=relay, because there is no turn server info available`
8756
+ );
8757
+ // drop the forced relay policy and use the default, because we don't have a TURN server
8758
+ this.addMediaData.iceTransportPolicy = undefined;
8759
+ }
8760
+ const mediaConnection = await this.createMediaConnection(
8761
+ turnServerInfo,
8762
+ bundlePolicy,
8763
+ this.addMediaData.iceTransportPolicy
8764
+ );
7757
8765
 
7758
8766
  LoggerProxy.logger.info(
7759
8767
  `${LOG_HEADER} media connection created this.isMultistream=${this.isMultistream}`
@@ -7790,7 +8798,7 @@ export default class Meeting extends StatelessWebexPlugin {
7790
8798
  await this.remoteMediaManager.start();
7791
8799
  }
7792
8800
 
7793
- await mc.initiateOffer();
8801
+ await mediaConnection.initiateOffer();
7794
8802
 
7795
8803
  await this.waitForRemoteSDPAnswer();
7796
8804
 
@@ -7858,6 +8866,9 @@ export default class Meeting extends StatelessWebexPlugin {
7858
8866
 
7859
8867
  this.isMultistream = false;
7860
8868
 
8869
+ // reset iceTransportPolicy, because it's only applied for multistream media connections
8870
+ this.addMediaData.iceTransportPolicy = undefined;
8871
+
7861
8872
  if (this.mediaProperties.webrtcMediaConnection) {
7862
8873
  // close peer connection, but don't reset mute state information, because we will want to use it on the retry
7863
8874
  this.closePeerConnections(false);
@@ -7938,6 +8949,8 @@ export default class Meeting extends StatelessWebexPlugin {
7938
8949
  regionCode: this.webex.meetings.geoHintInfo?.regionCode,
7939
8950
  },
7940
8951
  preferTranscoding: !this.isMultistream,
8952
+ getCurrentSelfUrl: () => this.selfUrl,
8953
+ waitForSelfUrlChange: () => this.waitForSelfUrlChange(),
7941
8954
  },
7942
8955
  {
7943
8956
  // @ts-ignore
@@ -7946,6 +8959,41 @@ export default class Meeting extends StatelessWebexPlugin {
7946
8959
  );
7947
8960
  }
7948
8961
 
8962
+ /**
8963
+ * Waits for LocusInfo to update meeting.selfUrl, with a timeout fallback.
8964
+ * @returns {Promise<void>}
8965
+ * @private
8966
+ * @memberof Meeting
8967
+ */
8968
+ private waitForSelfUrlChange(): Promise<void> {
8969
+ if (this.joinWithMediaRetryInfo.retryCount > 0) {
8970
+ /* During joinWithMedia() retries we can get 403/409 from Locus and it doesn't mean
8971
+ * that the selfUrl will change, it is usually caused by Locus dropping us as a result of
8972
+ * media connection failure during joinWithMedia's earlier media connection attempt,
8973
+ * so we don't want to wait for selfUrl change as this would only slow down the join process. */
8974
+ LoggerProxy.logger.info(
8975
+ 'Meeting:index#waitForSelfUrlChange --> joinWithMedia retry in progress, will not wait for selfUrl change'
8976
+ );
8977
+
8978
+ return Promise.resolve();
8979
+ }
8980
+
8981
+ if (!this.promisesWaitingForPropUpdate.selfUrl) {
8982
+ const pendingSelfUrlUpdate = new Defer();
8983
+
8984
+ this.promisesWaitingForPropUpdate.selfUrl = pendingSelfUrlUpdate;
8985
+
8986
+ setTimeout(() => {
8987
+ if (this.promisesWaitingForPropUpdate.selfUrl === pendingSelfUrlUpdate) {
8988
+ delete this.promisesWaitingForPropUpdate.selfUrl;
8989
+ pendingSelfUrlUpdate.resolve();
8990
+ }
8991
+ }, 5000);
8992
+ }
8993
+
8994
+ return this.promisesWaitingForPropUpdate.selfUrl.promise;
8995
+ }
8996
+
7949
8997
  /**
7950
8998
  * Creates a media connection to the server. Media connection is required for sending or receiving any audio/video.
7951
8999
  *
@@ -7957,8 +9005,9 @@ export default class Meeting extends StatelessWebexPlugin {
7957
9005
  addMedia(options: AddMediaOptions = {}): Promise<void> {
7958
9006
  return this.addMediaInternal(
7959
9007
  () => (this.turnServerUsed ? 'JOIN_MEETING_FINAL' : 'JOIN_MEETING_RETRY'),
7960
- undefined,
7961
9008
  false,
9009
+ undefined /* turnServerInfo - it will be fetched via doTurnDiscovery() */,
9010
+ undefined /* iceTransportPolicy - we're relying on the default value */,
7962
9011
  options
7963
9012
  );
7964
9013
  }
@@ -7967,8 +9016,9 @@ export default class Meeting extends StatelessWebexPlugin {
7967
9016
  * Internal version of addMedia() with some more arguments for finer control of its behavior
7968
9017
  *
7969
9018
  * @param {Function} icePhaseCallback - callback to determine the icePhase for CA "client.ice.end" failure events
7970
- * @param {TurnServerInfo} turnServerInfo - TURN server information
7971
9019
  * @param {boolean} forceTurnDiscovery - if true, TURN discovery will be done
9020
+ * @param {TurnServerInfo} turnServerInfo - TURN server information
9021
+ * @param {RTCIceTransportPolicy} [iceTransportPolicy] - ICE transport policy override
7972
9022
  * @param {AddMediaOptions} options - same as options of the public addMedia() method
7973
9023
  * @returns {Promise<void>}
7974
9024
  * @protected
@@ -7976,12 +9026,14 @@ export default class Meeting extends StatelessWebexPlugin {
7976
9026
  */
7977
9027
  protected async addMediaInternal(
7978
9028
  icePhaseCallback: () => string,
7979
- turnServerInfo: TurnServerInfo,
7980
- forceTurnDiscovery,
9029
+ forceTurnDiscovery: boolean,
9030
+ turnServerInfo?: TurnServerInfo,
9031
+ iceTransportPolicy?: RTCIceTransportPolicy,
7981
9032
  options: AddMediaOptions = {}
7982
9033
  ): Promise<void> {
7983
9034
  this.addMediaData.retriedWithTurnServer = false;
7984
9035
  this.addMediaData.icePhaseCallback = icePhaseCallback;
9036
+ this.addMediaData.iceTransportPolicy = iceTransportPolicy;
7985
9037
 
7986
9038
  this.hasMediaConnectionConnectedAtLeastOnce = false;
7987
9039
  const LOG_HEADER = 'Meeting:index#addMedia -->';
@@ -7990,7 +9042,7 @@ export default class Meeting extends StatelessWebexPlugin {
7990
9042
  options
7991
9043
  )}, turnServerInfo=${JSON.stringify(
7992
9044
  turnServerInfo
7993
- )}, forceTurnDiscovery=${forceTurnDiscovery}`
9045
+ )}, forceTurnDiscovery=${forceTurnDiscovery}, iceTransportPolicy=${iceTransportPolicy}`
7994
9046
  );
7995
9047
 
7996
9048
  if (options.allowMediaInLobby !== true && this.meetingState !== FULL_STATE.ACTIVE) {
@@ -8010,6 +9062,7 @@ export default class Meeting extends StatelessWebexPlugin {
8010
9062
  remoteMediaManagerConfig,
8011
9063
  bundlePolicy = 'max-bundle',
8012
9064
  additionalMediaOptions = {},
9065
+ allowPublishMediaInLobby = false,
8013
9066
  } = options;
8014
9067
 
8015
9068
  const {
@@ -8030,7 +9083,6 @@ export default class Meeting extends StatelessWebexPlugin {
8030
9083
  const ipver = MeetingUtil.getIpVersion(this.webex); // used just for metrics
8031
9084
 
8032
9085
  // If the user is unjoined or guest waiting in lobby dont allow the user to addMedia
8033
- // @ts-ignore - isUserUnadmitted coming from SelfUtil
8034
9086
  if (this.isUserUnadmitted && !this.wirelessShare && !this.allowMediaInLobby) {
8035
9087
  throw new UserInLobbyError();
8036
9088
  }
@@ -8075,7 +9127,13 @@ export default class Meeting extends StatelessWebexPlugin {
8075
9127
  this.brbState = createBrbState(this, false);
8076
9128
 
8077
9129
  try {
8078
- await this.setUpLocalStreamReferences(localStreams);
9130
+ // if we're in a lobby and allowPublishMediaInLobby==false, we don't want to
9131
+ // setup local streams for publishing, because if we ever end up admitted to the meeting
9132
+ // but Locus event about it for us is delayed or missed, others could see/hear our user's video/audio
9133
+ // while the user would still think they're in the lobby
9134
+ if (allowPublishMediaInLobby || !this.isUserUnadmitted) {
9135
+ await this.setUpLocalStreamReferences(localStreams);
9136
+ }
8079
9137
 
8080
9138
  this.setMercuryListener();
8081
9139
 
@@ -8098,12 +9156,7 @@ export default class Meeting extends StatelessWebexPlugin {
8098
9156
 
8099
9157
  // Establish new media connection with forced TURN discovery
8100
9158
  // We need to do TURN discovery again, because backend will be creating a new confluence, so it might land on a different node or cluster
8101
- await this.establishMediaConnection(
8102
- remoteMediaManagerConfig,
8103
- bundlePolicy,
8104
- true,
8105
- undefined
8106
- );
9159
+ await this.establishMediaConnection(remoteMediaManagerConfig, bundlePolicy, true);
8107
9160
  } else {
8108
9161
  throw error;
8109
9162
  }
@@ -8132,7 +9185,8 @@ export default class Meeting extends StatelessWebexPlugin {
8132
9185
  numTransports,
8133
9186
  isMultistream: this.isMultistream,
8134
9187
  retriedWithTurnServer: this.addMediaData.retriedWithTurnServer,
8135
- isJoinWithMediaRetry: this.joinWithMediaRetryInfo.isRetry,
9188
+ isJoinWithMediaRetry: this.joinWithMediaRetryInfo.retryCount > 0,
9189
+ iceTransportPolicy: this.addMediaData.iceTransportPolicy || 'all',
8136
9190
  ...reachabilityMetrics,
8137
9191
  ...iceCandidateErrors,
8138
9192
  iceCandidatesCount: this.iceCandidatesCount,
@@ -8154,14 +9208,16 @@ export default class Meeting extends StatelessWebexPlugin {
8154
9208
  // We can log ReceiveSlot SSRCs only after the SDP exchange, so doing it here:
8155
9209
  this.remoteMediaManager?.logAllReceiveSlots();
8156
9210
  this.startPeriodicLogUpload();
8157
- } catch (error) {
9211
+ } catch (error: any) {
8158
9212
  LoggerProxy.logger.error(`${LOG_HEADER} failed to establish media connection: `, error);
8159
9213
 
8160
9214
  // @ts-ignore
8161
9215
  const reachabilityMetrics = await this.getMediaReachabilityMetricFields();
8162
9216
 
8163
- const {selectedCandidatePairChanges, numTransports} =
8164
- await this.mediaProperties.getCurrentConnectionInfo();
9217
+ const {connectionType, selectedCandidatePairChanges, numTransports} =
9218
+ error instanceof AddMediaFailed
9219
+ ? error
9220
+ : await this.mediaProperties.getCurrentConnectionInfo();
8165
9221
 
8166
9222
  const iceCandidateErrors = Object.fromEntries(this.iceCandidateErrors);
8167
9223
 
@@ -8177,7 +9233,8 @@ export default class Meeting extends StatelessWebexPlugin {
8177
9233
  turnServerUsed: this.turnServerUsed,
8178
9234
  retriedWithTurnServer: this.addMediaData.retriedWithTurnServer,
8179
9235
  isMultistream: this.isMultistream,
8180
- isJoinWithMediaRetry: this.joinWithMediaRetryInfo.isRetry,
9236
+ isJoinWithMediaRetry: this.joinWithMediaRetryInfo.retryCount > 0,
9237
+ iceTransportPolicy: this.addMediaData.iceTransportPolicy || 'all',
8181
9238
  signalingState:
8182
9239
  this.mediaProperties.webrtcMediaConnection?.multistreamConnection?.pc?.pc
8183
9240
  ?.signalingState ||
@@ -8193,6 +9250,7 @@ export default class Meeting extends StatelessWebexPlugin {
8193
9250
  ?.iceConnectionState ||
8194
9251
  this.mediaProperties.webrtcMediaConnection?.mediaConnection?.pc?.iceConnectionState ||
8195
9252
  'unknown',
9253
+ connectionType,
8196
9254
  ...reachabilityMetrics,
8197
9255
  ...iceCandidateErrors,
8198
9256
  iceCandidatesCount: this.iceCandidatesCount,
@@ -8541,14 +9599,15 @@ export default class Meeting extends StatelessWebexPlugin {
8541
9599
  options: {meetingId: this.id},
8542
9600
  });
8543
9601
  LoggerProxy.logger.log('Meeting:index#leave --> Leaving a meeting');
9602
+ this.stopListeningForMeetingEvents();
8544
9603
 
8545
9604
  return MeetingUtil.leaveMeeting(this, options)
8546
- .then((leave) => {
9605
+ .then(async (leave) => {
8547
9606
  // CA team recommends submitting this *after* locus /leave
8548
9607
  submitLeaveMetric();
8549
9608
 
8550
9609
  this.meetingFiniteStateMachine.leave();
8551
- this.clearMeetingData();
9610
+ await this.clearMeetingData();
8552
9611
 
8553
9612
  // upload logs on leave irrespective of meeting delete
8554
9613
  Trigger.trigger(
@@ -9406,11 +10465,13 @@ export default class Meeting extends StatelessWebexPlugin {
9406
10465
  locus_id: this.locusId,
9407
10466
  });
9408
10467
 
10468
+ this.stopListeningForMeetingEvents();
10469
+
9409
10470
  return MeetingUtil.endMeetingForAll(this)
9410
- .then((end) => {
10471
+ .then(async (end) => {
9411
10472
  this.meetingFiniteStateMachine.end();
9412
10473
 
9413
- this.clearMeetingData();
10474
+ await this.clearMeetingData();
9414
10475
  // upload logs on leave irrespective of meeting delete
9415
10476
  Trigger.trigger(
9416
10477
  this,
@@ -9458,7 +10519,7 @@ export default class Meeting extends StatelessWebexPlugin {
9458
10519
  * @public
9459
10520
  * @memberof Meeting
9460
10521
  */
9461
- clearMeetingData = () => {
10522
+ clearMeetingData = async () => {
9462
10523
  this.audio = null;
9463
10524
  this.video = null;
9464
10525
  this.screenShareFloorState = ScreenShareFloorStatus.RELEASED;
@@ -9467,19 +10528,16 @@ export default class Meeting extends StatelessWebexPlugin {
9467
10528
  }
9468
10529
  this.queuedMediaUpdates = [];
9469
10530
 
9470
- if (this.transcription) {
9471
- this.stopTranscription();
9472
- this.transcription = undefined;
9473
- }
9474
-
9475
- this.annotation.deregisterEvents();
10531
+ // Listener teardown (transcription, annotation, llm/mercury) runs in
10532
+ // stopListeningForMeetingEvents() before /leave and /end so events
10533
+ // received mid-teardown do not trigger Locus syncs. Calling it here
10534
+ // again would double-emit MEETING_STOPPED_RECEIVING_TRANSCRIPTION
10535
+ // because stopTranscription() always fires its trigger.
10536
+ //
10537
+ // Ownership-aware token clear is encapsulated inside clearDataChannelToken().
10538
+ this.clearDataChannelToken();
9476
10539
 
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);
9481
-
9482
- this.clearLLMHealthCheckTimer();
10540
+ await this.cleanupLLMConneciton({throwOnError: false});
9483
10541
  };
9484
10542
 
9485
10543
  /**
@@ -9555,15 +10613,12 @@ export default class Meeting extends StatelessWebexPlugin {
9555
10613
  * @public
9556
10614
  * @memberof Meeting
9557
10615
  */
9558
- public sendReaction(reactionType: ReactionServerType, skinToneType?: SkinToneType) {
10616
+ public sendReaction(reactionType: string, skinToneType?: SkinToneType) {
9559
10617
  const reactionChannelUrl = this.locusInfo?.controls?.reactions?.reactionChannelUrl as string;
9560
10618
  const participantId = this.members.selfId;
9561
10619
 
9562
- const reactionData = Reactions[reactionType];
10620
+ const reactionData = Reactions[reactionType] || {type: reactionType};
9563
10621
 
9564
- if (!reactionData) {
9565
- return Promise.reject(new Error(`${reactionType} is not a valid reaction.`));
9566
- }
9567
10622
  const skinToneData = SkinTones[skinToneType] || SkinTones.normal;
9568
10623
  const reaction: Reaction = {
9569
10624
  ...reactionData,
@@ -9672,15 +10727,20 @@ export default class Meeting extends StatelessWebexPlugin {
9672
10727
  }
9673
10728
 
9674
10729
  if (shouldEnableMusicMode) {
9675
- await this.sendSlotManager.setCodecParameters(MediaType.AudioMain, {
9676
- maxaveragebitrate: '64000',
9677
- maxplaybackrate: '48000',
9678
- });
10730
+ await this.sendSlotManager.setCustomCodecParameters(
10731
+ MediaType.AudioMain,
10732
+ MediaCodecMimeType.OPUS,
10733
+ {
10734
+ maxaveragebitrate: '64000',
10735
+ maxplaybackrate: '48000',
10736
+ }
10737
+ );
9679
10738
  } else {
9680
- await this.sendSlotManager.deleteCodecParameters(MediaType.AudioMain, [
9681
- 'maxaveragebitrate',
9682
- 'maxplaybackrate',
9683
- ]);
10739
+ await this.sendSlotManager.markCustomCodecParametersForDeletion(
10740
+ MediaType.AudioMain,
10741
+ MediaCodecMimeType.OPUS,
10742
+ ['maxaveragebitrate', 'maxplaybackrate']
10743
+ );
9684
10744
  }
9685
10745
  }
9686
10746
 
@@ -10179,4 +11239,52 @@ export default class Meeting extends StatelessWebexPlugin {
10179
11239
  cancelSipCallOut(participantId: string) {
10180
11240
  return this.meetingRequest.cancelSipCallOut(participantId);
10181
11241
  }
11242
+
11243
+ /**
11244
+ * Method to get new data
11245
+ * @returns {Promise}
11246
+ */
11247
+ public async refreshDataChannelToken() {
11248
+ const isPracticeSession = this.webinar.isJoinPracticeSessionDataChannel();
11249
+ const dataChannelTokenType = this.getDataChannelTokenType();
11250
+
11251
+ try {
11252
+ const res = await this.meetingRequest.fetchDatachannelToken({
11253
+ locusUrl: this.locusUrl,
11254
+ requestingParticipantId: this.members.selfId,
11255
+ isPracticeSession,
11256
+ });
11257
+
11258
+ return {
11259
+ body: {
11260
+ datachannelToken: res.body.datachannelToken,
11261
+ dataChannelTokenType,
11262
+ },
11263
+ };
11264
+ } catch (e) {
11265
+ const msg = e?.message || String(e);
11266
+
11267
+ LoggerProxy.logger.warn(
11268
+ `Meeting:index#refreshDataChannelToken --> DataChannel token refresh failed (likely locus changed or participant left): ${msg}`,
11269
+ {statusCode: e?.statusCode}
11270
+ );
11271
+
11272
+ return null;
11273
+ }
11274
+ }
11275
+
11276
+ /**
11277
+ * Determines the current data channel token type based on the meeting state.
11278
+ *
11279
+ * variant should be used when connecting to the LLM data channel.
11280
+ *
11281
+ * @returns {DataChannelTokenType} The token type representing the current session mode.
11282
+ */
11283
+ public getDataChannelTokenType(): DataChannelTokenType {
11284
+ if (this.webinar.isJoinPracticeSessionDataChannel()) {
11285
+ return DataChannelTokenType.PracticeSession;
11286
+ }
11287
+
11288
+ return DataChannelTokenType.Default;
11289
+ }
10182
11290
  }