@webex/plugin-meetings 3.12.0-next.17 → 3.12.0-next.171

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 (301) hide show
  1. package/.sdd/manifest.json +1312 -0
  2. package/.sdd/templates/.source.json +30 -0
  3. package/.sdd/templates/component-repo/module-docs/module-spec-quality.md +111 -0
  4. package/.sdd/templates/component-repo/module-docs/module-spec.template.md +321 -0
  5. package/.sdd/templates/component-repo/reference-docs/adr/_adr-example.md +59 -0
  6. package/.sdd/templates/component-repo/reference-docs/patterns/_pattern-example.md +49 -0
  7. package/.sdd/templates/component-repo/reference-docs/rules/_rule-example.md +42 -0
  8. package/.sdd/templates/component-repo/standing-docs/AGENTS.template.md +120 -0
  9. package/.sdd/templates/component-repo/standing-docs/ARCHITECTURE.template.md +206 -0
  10. package/.sdd/templates/component-repo/standing-docs/CONTRACTS.template.md +90 -0
  11. package/.sdd/templates/component-repo/standing-docs/DATA_MODEL.template.md +68 -0
  12. package/.sdd/templates/component-repo/standing-docs/GETTING_STARTED.template.md +111 -0
  13. package/.sdd/templates/component-repo/standing-docs/GLOSSARY.template.md +57 -0
  14. package/.sdd/templates/component-repo/standing-docs/REVIEW_CHECKLIST.template.md +69 -0
  15. package/.sdd/templates/component-repo/standing-docs/RULES.template.md +96 -0
  16. package/.sdd/templates/component-repo/standing-docs/SECURITY.template.md +84 -0
  17. package/.sdd/templates/component-repo/standing-docs/SERVICE_STATE.template.md +82 -0
  18. package/.sdd/templates/component-repo/standing-docs/SPEC_INDEX.template.md +94 -0
  19. package/.sdd/templates/component-repo/standing-docs/TEST_INDEX.template.md +64 -0
  20. package/.sdd/templates/component-repo/template-map.json +112 -0
  21. package/AGENTS.md +135 -0
  22. package/ai-docs/ARCHITECTURE.md +207 -0
  23. package/ai-docs/CONTRACTS.md +267 -0
  24. package/ai-docs/DATA_MODEL.md +64 -0
  25. package/ai-docs/GETTING_STARTED.md +73 -0
  26. package/ai-docs/GLOSSARY.md +56 -0
  27. package/ai-docs/REVIEW_CHECKLIST.md +45 -0
  28. package/ai-docs/RULES.md +79 -0
  29. package/ai-docs/SECURITY.md +74 -0
  30. package/ai-docs/SERVICE_STATE.md +59 -0
  31. package/ai-docs/SPEC_INDEX.md +85 -0
  32. package/ai-docs/TEST_INDEX.md +45 -0
  33. package/ai-docs/adr/0001-migrate-existing-docs-into-sdd.md +61 -0
  34. package/ai-docs/patterns/defensive-error-propagation.md +55 -0
  35. package/ai-docs/patterns/event-scope-emission.md +46 -0
  36. package/ai-docs/patterns/source-to-test-path-mirroring.md +45 -0
  37. package/ai-docs/patterns/stateless-plugin-request-classes.md +53 -0
  38. package/ai-docs/patterns/typed-constants-and-enum-values.md +47 -0
  39. package/dist/aiEnableRequest/index.js +15 -2
  40. package/dist/aiEnableRequest/index.js.map +1 -1
  41. package/dist/annotation/index.js +2 -2
  42. package/dist/annotation/index.js.map +1 -1
  43. package/dist/breakouts/breakout.js +8 -3
  44. package/dist/breakouts/breakout.js.map +1 -1
  45. package/dist/breakouts/events.js +29 -14
  46. package/dist/breakouts/events.js.map +1 -1
  47. package/dist/breakouts/index.js +99 -4
  48. package/dist/breakouts/index.js.map +1 -1
  49. package/dist/common/errors/webex-errors.js +49 -5
  50. package/dist/common/errors/webex-errors.js.map +1 -1
  51. package/dist/config.js +2 -2
  52. package/dist/config.js.map +1 -1
  53. package/dist/constants.js +37 -10
  54. package/dist/constants.js.map +1 -1
  55. package/dist/controls-options-manager/index.js +46 -10
  56. package/dist/controls-options-manager/index.js.map +1 -1
  57. package/dist/hashTree/constants.js +4 -1
  58. package/dist/hashTree/constants.js.map +1 -1
  59. package/dist/hashTree/hashTreeParser.js +1096 -391
  60. package/dist/hashTree/hashTreeParser.js.map +1 -1
  61. package/dist/hashTree/utils.js +20 -0
  62. package/dist/hashTree/utils.js.map +1 -1
  63. package/dist/index.js +7 -0
  64. package/dist/index.js.map +1 -1
  65. package/dist/interceptors/dataChannelAuthToken.js +75 -15
  66. package/dist/interceptors/dataChannelAuthToken.js.map +1 -1
  67. package/dist/interceptors/locusRetry.js +24 -9
  68. package/dist/interceptors/locusRetry.js.map +1 -1
  69. package/dist/interpretation/index.js +55 -12
  70. package/dist/interpretation/index.js.map +1 -1
  71. package/dist/interpretation/interpretation.types.js +7 -0
  72. package/dist/interpretation/interpretation.types.js.map +1 -0
  73. package/dist/interpretation/siLanguage.js +1 -1
  74. package/dist/locus-info/controlsUtils.js +4 -1
  75. package/dist/locus-info/controlsUtils.js.map +1 -1
  76. package/dist/locus-info/index.js +615 -176
  77. package/dist/locus-info/index.js.map +1 -1
  78. package/dist/locus-info/infoUtils.js +36 -5
  79. package/dist/locus-info/infoUtils.js.map +1 -1
  80. package/dist/locus-info/types.js +20 -0
  81. package/dist/locus-info/types.js.map +1 -1
  82. package/dist/media/MediaConnectionAwaiter.js +15 -2
  83. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  84. package/dist/media/index.js +8 -2
  85. package/dist/media/index.js.map +1 -1
  86. package/dist/media/properties.js +4 -5
  87. package/dist/media/properties.js.map +1 -1
  88. package/dist/meeting/in-meeting-actions.js +5 -1
  89. package/dist/meeting/in-meeting-actions.js.map +1 -1
  90. package/dist/meeting/index.js +1684 -835
  91. package/dist/meeting/index.js.map +1 -1
  92. package/dist/meeting/locusMediaRequest.js +229 -82
  93. package/dist/meeting/locusMediaRequest.js.map +1 -1
  94. package/dist/meeting/muteState.js +10 -1
  95. package/dist/meeting/muteState.js.map +1 -1
  96. package/dist/meeting/request.js +5 -2
  97. package/dist/meeting/request.js.map +1 -1
  98. package/dist/meeting/util.js +37 -3
  99. package/dist/meeting/util.js.map +1 -1
  100. package/dist/meeting/voicea-meeting.js +2 -1
  101. package/dist/meeting/voicea-meeting.js.map +1 -1
  102. package/dist/meeting-info/meeting-info-v2.js +12 -5
  103. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  104. package/dist/meetings/index.js +300 -128
  105. package/dist/meetings/index.js.map +1 -1
  106. package/dist/meetings/meetings.types.js +6 -1
  107. package/dist/meetings/meetings.types.js.map +1 -1
  108. package/dist/meetings/request.js +39 -0
  109. package/dist/meetings/request.js.map +1 -1
  110. package/dist/meetings/util.js +116 -18
  111. package/dist/meetings/util.js.map +1 -1
  112. package/dist/member/index.js +10 -0
  113. package/dist/member/index.js.map +1 -1
  114. package/dist/member/types.js.map +1 -1
  115. package/dist/member/util.js +30 -0
  116. package/dist/member/util.js.map +1 -1
  117. package/dist/members/index.js +101 -43
  118. package/dist/members/index.js.map +1 -1
  119. package/dist/members/util.js +8 -1
  120. package/dist/members/util.js.map +1 -1
  121. package/dist/metrics/constants.js +7 -1
  122. package/dist/metrics/constants.js.map +1 -1
  123. package/dist/multistream/codec/constants.js +63 -0
  124. package/dist/multistream/codec/constants.js.map +1 -0
  125. package/dist/multistream/mediaRequestManager.js +62 -15
  126. package/dist/multistream/mediaRequestManager.js.map +1 -1
  127. package/dist/multistream/receiveSlot.js +9 -0
  128. package/dist/multistream/receiveSlot.js.map +1 -1
  129. package/dist/multistream/remoteMediaManager.js +32 -4
  130. package/dist/multistream/remoteMediaManager.js.map +1 -1
  131. package/dist/reachability/clusterReachability.js.map +1 -1
  132. package/dist/reachability/index.js +121 -83
  133. package/dist/reachability/index.js.map +1 -1
  134. package/dist/reachability/reachability.types.js +2 -0
  135. package/dist/reachability/reachability.types.js.map +1 -1
  136. package/dist/reachability/util.js +45 -0
  137. package/dist/reachability/util.js.map +1 -1
  138. package/dist/reactions/reactions.type.js.map +1 -1
  139. package/dist/recording-controller/index.js +1 -3
  140. package/dist/recording-controller/index.js.map +1 -1
  141. package/dist/roap/turnDiscovery.js +8 -1
  142. package/dist/roap/turnDiscovery.js.map +1 -1
  143. package/dist/types/common/errors/webex-errors.d.ts +32 -2
  144. package/dist/types/config.d.ts +2 -2
  145. package/dist/types/constants.d.ts +13 -1
  146. package/dist/types/controls-options-manager/index.d.ts +16 -0
  147. package/dist/types/hashTree/constants.d.ts +1 -0
  148. package/dist/types/hashTree/hashTreeParser.d.ts +201 -22
  149. package/dist/types/hashTree/utils.d.ts +7 -0
  150. package/dist/types/index.d.ts +3 -0
  151. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  152. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  153. package/dist/types/locus-info/index.d.ts +106 -8
  154. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  155. package/dist/types/locus-info/types.d.ts +22 -1
  156. package/dist/types/media/MediaConnectionAwaiter.d.ts +10 -1
  157. package/dist/types/media/properties.d.ts +6 -2
  158. package/dist/types/meeting/in-meeting-actions.d.ts +4 -0
  159. package/dist/types/meeting/index.d.ts +178 -11
  160. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  161. package/dist/types/meeting/request.d.ts +1 -0
  162. package/dist/types/meeting/util.d.ts +9 -0
  163. package/dist/types/meeting-info/meeting-info-v2.d.ts +1 -0
  164. package/dist/types/meetings/index.d.ts +40 -19
  165. package/dist/types/meetings/meetings.types.d.ts +15 -0
  166. package/dist/types/meetings/request.d.ts +14 -0
  167. package/dist/types/member/index.d.ts +1 -0
  168. package/dist/types/member/types.d.ts +1 -0
  169. package/dist/types/member/util.d.ts +9 -0
  170. package/dist/types/members/index.d.ts +15 -2
  171. package/dist/types/members/util.d.ts +1 -5
  172. package/dist/types/metrics/constants.d.ts +6 -0
  173. package/dist/types/multistream/codec/constants.d.ts +7 -0
  174. package/dist/types/multistream/mediaRequestManager.d.ts +22 -5
  175. package/dist/types/multistream/remoteMediaManager.d.ts +18 -0
  176. package/dist/types/reachability/clusterReachability.d.ts +3 -3
  177. package/dist/types/reachability/index.d.ts +10 -3
  178. package/dist/types/reachability/reachability.types.d.ts +7 -0
  179. package/dist/types/reachability/util.d.ts +17 -0
  180. package/dist/types/reactions/reactions.type.d.ts +3 -0
  181. package/dist/webinar/index.js +307 -161
  182. package/dist/webinar/index.js.map +1 -1
  183. package/package.json +23 -23
  184. package/src/aiEnableRequest/ai-docs/ai-enable-request-spec.md +223 -0
  185. package/src/aiEnableRequest/index.ts +16 -0
  186. package/src/annotation/ai-docs/annotation-spec.md +236 -0
  187. package/src/annotation/index.ts +6 -4
  188. package/src/breakouts/ai-docs/breakouts-spec.md +324 -0
  189. package/src/breakouts/breakout.ts +3 -1
  190. package/src/breakouts/events.ts +33 -11
  191. package/src/breakouts/index.ts +122 -2
  192. package/src/common/errors/webex-errors.ts +50 -3
  193. package/src/config.ts +2 -2
  194. package/src/constants.ts +21 -3
  195. package/src/controls-options-manager/ai-docs/controls-options-manager-spec.md +243 -0
  196. package/src/controls-options-manager/index.ts +62 -10
  197. package/src/hashTree/ai-docs/hash-tree-spec.md +267 -0
  198. package/src/hashTree/constants.ts +7 -0
  199. package/src/hashTree/hashTreeParser.ts +861 -193
  200. package/src/hashTree/utils.ts +19 -0
  201. package/src/index.ts +6 -0
  202. package/src/interceptors/ai-docs/interceptors-spec.md +247 -0
  203. package/src/interceptors/dataChannelAuthToken.ts +88 -12
  204. package/src/interceptors/locusRetry.ts +26 -5
  205. package/src/interpretation/ai-docs/interpretation-spec.md +256 -0
  206. package/src/interpretation/index.ts +65 -10
  207. package/src/interpretation/interpretation.types.ts +11 -0
  208. package/src/locus-info/ai-docs/locus-info-spec.md +293 -0
  209. package/src/locus-info/controlsUtils.ts +3 -1
  210. package/src/locus-info/index.ts +566 -164
  211. package/src/locus-info/infoUtils.ts +41 -6
  212. package/src/locus-info/types.ts +26 -1
  213. package/src/media/MediaConnectionAwaiter.ts +21 -4
  214. package/src/media/ai-docs/media-spec.md +267 -0
  215. package/src/media/index.ts +10 -1
  216. package/src/media/properties.ts +8 -3
  217. package/src/meeting/ai-docs/meeting-spec.md +401 -0
  218. package/src/meeting/in-meeting-actions.ts +8 -0
  219. package/src/meeting/index.ts +944 -120
  220. package/src/meeting/locusMediaRequest.ts +106 -6
  221. package/src/meeting/muteState.ts +10 -1
  222. package/src/meeting/request.ts +11 -0
  223. package/src/meeting/util.ts +51 -7
  224. package/src/meeting/voicea-meeting.ts +1 -1
  225. package/src/meeting-info/ai-docs/meeting-info-spec.md +261 -0
  226. package/src/meeting-info/meeting-info-v2.ts +11 -4
  227. package/src/meetings/ai-docs/meetings-spec.md +296 -0
  228. package/src/meetings/index.ts +200 -80
  229. package/src/meetings/meetings.types.ts +19 -0
  230. package/src/meetings/request.ts +43 -0
  231. package/src/meetings/util.ts +117 -4
  232. package/src/member/ai-docs/member-spec.md +196 -0
  233. package/src/member/index.ts +10 -0
  234. package/src/member/types.ts +1 -0
  235. package/src/member/util.ts +29 -0
  236. package/src/members/ai-docs/members-spec.md +256 -0
  237. package/src/members/index.ts +70 -7
  238. package/src/members/util.ts +12 -4
  239. package/src/metrics/ai-docs/metrics-spec.md +185 -0
  240. package/src/metrics/constants.ts +6 -0
  241. package/src/multistream/ai-docs/multistream-spec.md +292 -0
  242. package/src/multistream/codec/constants.ts +58 -0
  243. package/src/multistream/mediaRequestManager.ts +119 -28
  244. package/src/multistream/receiveSlot.ts +18 -0
  245. package/src/multistream/remoteMediaManager.ts +23 -1
  246. package/src/personal-meeting-room/ai-docs/personal-meeting-room-spec.md +234 -0
  247. package/src/reachability/ai-docs/reachability-spec.md +261 -0
  248. package/src/reachability/clusterReachability.ts +3 -2
  249. package/src/reachability/index.ts +47 -16
  250. package/src/reachability/reachability.types.ts +11 -0
  251. package/src/reachability/util.ts +36 -0
  252. package/src/reactions/ai-docs/reactions-spec.md +198 -0
  253. package/src/reactions/reactions.type.ts +3 -0
  254. package/src/reconnection-manager/ai-docs/reconnection-manager-spec.md +272 -0
  255. package/src/recording-controller/ai-docs/recording-controller-spec.md +223 -0
  256. package/src/recording-controller/index.ts +1 -2
  257. package/src/roap/ai-docs/roap-spec.md +241 -0
  258. package/src/roap/turnDiscovery.ts +9 -1
  259. package/src/webinar/ai-docs/webinar-spec.md +243 -0
  260. package/src/webinar/index.ts +216 -38
  261. package/test/unit/spec/aiEnableRequest/index.ts +86 -0
  262. package/test/unit/spec/annotation/index.ts +3 -3
  263. package/test/unit/spec/breakouts/breakout.ts +9 -3
  264. package/test/unit/spec/breakouts/events.ts +120 -2
  265. package/test/unit/spec/breakouts/index.ts +223 -3
  266. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  267. package/test/unit/spec/controls-options-manager/index.js +139 -32
  268. package/test/unit/spec/hashTree/hashTreeParser.ts +2451 -184
  269. package/test/unit/spec/hashTree/utils.ts +37 -0
  270. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +196 -0
  271. package/test/unit/spec/interceptors/locusRetry.ts +234 -5
  272. package/test/unit/spec/interpretation/index.ts +119 -4
  273. package/test/unit/spec/locus-info/controlsUtils.js +172 -57
  274. package/test/unit/spec/locus-info/index.js +1014 -58
  275. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  276. package/test/unit/spec/media/MediaConnectionAwaiter.ts +55 -0
  277. package/test/unit/spec/media/index.ts +92 -0
  278. package/test/unit/spec/media/properties.ts +23 -23
  279. package/test/unit/spec/meeting/in-meeting-actions.ts +4 -0
  280. package/test/unit/spec/meeting/index.js +2834 -110
  281. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  282. package/test/unit/spec/meeting/muteState.js +81 -0
  283. package/test/unit/spec/meeting/request.js +12 -0
  284. package/test/unit/spec/meeting/utils.js +189 -17
  285. package/test/unit/spec/meeting/voicea-meeting.ts +85 -1
  286. package/test/unit/spec/meeting-info/meetinginfov2.js +88 -11
  287. package/test/unit/spec/meetings/index.js +544 -49
  288. package/test/unit/spec/meetings/request.js +141 -0
  289. package/test/unit/spec/meetings/utils.js +402 -51
  290. package/test/unit/spec/member/index.js +7 -0
  291. package/test/unit/spec/member/util.js +89 -0
  292. package/test/unit/spec/members/index.js +216 -0
  293. package/test/unit/spec/members/request.js +37 -1
  294. package/test/unit/spec/members/utils.js +63 -0
  295. package/test/unit/spec/multistream/mediaRequestManager.ts +501 -37
  296. package/test/unit/spec/multistream/remoteMediaManager.ts +46 -0
  297. package/test/unit/spec/reachability/index.ts +128 -46
  298. package/test/unit/spec/reachability/util.ts +31 -0
  299. package/test/unit/spec/recording-controller/index.js +9 -8
  300. package/test/unit/spec/roap/turnDiscovery.ts +20 -0
  301. package/test/unit/spec/webinar/index.ts +332 -31
@@ -22,7 +22,6 @@ import {
22
22
  MediaConnectionEventNames,
23
23
  MediaContent,
24
24
  MediaType,
25
- MediaCodecMimeType,
26
25
  RemoteTrackType,
27
26
  RoapMessage,
28
27
  StatsAnalyzer,
@@ -31,10 +30,10 @@ import {
31
30
  NetworkQualityMonitor,
32
31
  StatsMonitor,
33
32
  StatsMonitorEventNames,
34
- InboundAudioIssueSubTypes,
33
+ MediaCodecMimeType,
35
34
  } from '@webex/internal-media-core';
36
35
 
37
- import {DataChannelTokenType} from '@webex/internal-plugin-llm';
36
+ import {DataChannelTokenType, type RegisterAndConnectTiming} from '@webex/internal-plugin-llm';
38
37
 
39
38
  import {
40
39
  LocalStream,
@@ -58,6 +57,7 @@ import {
58
57
  isBrowserMediaError,
59
58
  isBrowserMediaErrorName,
60
59
  } from '@webex/internal-plugin-metrics/src/call-diagnostic/call-diagnostic-metrics.util';
60
+ import type {MetricEventMeetingJoinPhase} from '@webex/internal-plugin-metrics/src/metrics.types';
61
61
  import {CapabilityState, WebCapabilities} from '@webex/web-capabilities';
62
62
  import {processNewCaptions} from './voicea-meeting';
63
63
 
@@ -67,6 +67,7 @@ import {
67
67
  NoMediaEstablishedYetError,
68
68
  UserNotJoinedError,
69
69
  AddMediaFailed,
70
+ MediaConnectionTimedOutError,
70
71
  SdpResponseTimeoutError,
71
72
  } from '../common/errors/webex-errors';
72
73
 
@@ -77,6 +78,7 @@ import Roap, {type TurnDiscoveryResult, type TurnDiscoverySkipReason} from '../r
77
78
  import {type TurnServerInfo} from '../roap/types';
78
79
  import Media, {type BundlePolicy} from '../media';
79
80
  import MediaProperties from '../media/properties';
81
+ import {type FailureResult as MediaConnectionAwaiterFailureResult} from '../media/MediaConnectionAwaiter';
80
82
  import MeetingStateMachine from './state';
81
83
  import {createMuteState} from './muteState';
82
84
  import LocusInfo, {LocusLLMEvent} from '../locus-info';
@@ -137,6 +139,8 @@ import {
137
139
  STAGE_MANAGER_TYPE,
138
140
  LOCUSEVENT,
139
141
  LOCUS_LLM_EVENT,
142
+ LLM_DEFAULT_SESSION,
143
+ LLM_PRACTICE_SESSION,
140
144
  } from '../constants';
141
145
  import BEHAVIORAL_METRICS from '../metrics/constants';
142
146
  import ParameterError from '../common/errors/parameter';
@@ -154,6 +158,7 @@ import {
154
158
  Configuration as RemoteMediaManagerConfiguration,
155
159
  RemoteMediaManager,
156
160
  Event as RemoteMediaManagerEvent,
161
+ getRemoteMediaManagerConfigForLogging,
157
162
  } from '../multistream/remoteMediaManager';
158
163
  import {
159
164
  Reaction,
@@ -183,13 +188,14 @@ import {ReachabilityMetrics} from '../reachability/reachability.types';
183
188
  import {SetStageOptions, SetStageVideoLayout, UnsetStageVideoLayout} from './request.type';
184
189
  import {Invitee} from './type';
185
190
  import {DataSet, HashTreeMessage, Metadata} from '../hashTree/hashTreeParser';
186
- import {LocusDTO} from '../locus-info/types';
191
+ import {LocusDTO, LocusErrorCodes} from '../locus-info/types';
187
192
  import AIEnableRequest from '../aiEnableRequest';
188
193
 
189
194
  // default callback so we don't call an undefined function, but in practice it should never be used
190
195
  const DEFAULT_ICE_PHASE_CALLBACK = () => 'JOIN_MEETING_FINAL';
191
196
 
192
197
  const LLM_HEALTHCHECK_TIMER_MS = 3 * 60 * 1000;
198
+ const JOIN_WITH_MEDIA_RETRY_MAX_COUNT = 2;
193
199
 
194
200
  const logRequest = (request: any, {logText = ''}) => {
195
201
  LoggerProxy.logger.info(`${logText} - sending request`);
@@ -273,6 +279,7 @@ export type CallStateForMetrics = {
273
279
  userNameInput?: string;
274
280
  emailInput?: string;
275
281
  pstnCorrelationId?: string;
282
+ meetingJoinPhase?: MetricEventMeetingJoinPhase;
276
283
  };
277
284
 
278
285
  export const MEDIA_UPDATE_TYPE = {
@@ -612,7 +619,7 @@ export default class Meeting extends StatelessWebexPlugin {
612
619
  webinar: any;
613
620
  conversationUrl: string;
614
621
  callStateForMetrics: CallStateForMetrics;
615
- destination: string;
622
+ destination: string | LocusDTO;
616
623
  destinationType: DESTINATION_TYPE;
617
624
  deviceUrl: string;
618
625
  hostId: string;
@@ -651,6 +658,8 @@ export default class Meeting extends StatelessWebexPlugin {
651
658
  floorGrantPending: boolean;
652
659
  hasJoinedOnce: boolean;
653
660
  hasWebsocketConnected: boolean;
661
+ private mercuryOnlineHandler?: () => void;
662
+ private mercuryOfflineHandler?: () => void;
654
663
  inMeetingActions: InMeetingActions;
655
664
  isLocalShareLive: boolean;
656
665
  isRoapInProgress: boolean;
@@ -662,6 +671,7 @@ export default class Meeting extends StatelessWebexPlugin {
662
671
  joinedWith?: any;
663
672
  selfId?: string;
664
673
  roles: any[];
674
+ canNotViewTheParticipantList?: boolean;
665
675
  // ... there is more ... see SelfUtils.parse()
666
676
  // end of the group
667
677
  locusMediaRequest?: LocusMediaRequest;
@@ -735,6 +745,8 @@ export default class Meeting extends StatelessWebexPlugin {
735
745
  isMoveToInProgress = false;
736
746
  registrationIdStatus: string;
737
747
  brbState: BrbState;
748
+ private emittedBreakoutJoinResponseMoveIds: Set<string> = new Set();
749
+ private promisesWaitingForPropUpdate: Record<string, Defer> = {};
738
750
 
739
751
  voiceaListenerCallbacks: object = {
740
752
  [VOICEAEVENTS.VOICEA_ANNOUNCEMENT]: (payload: Transcription['languageOptions']) => {
@@ -784,13 +796,20 @@ export default class Meeting extends StatelessWebexPlugin {
784
796
  private addMediaData: {
785
797
  retriedWithTurnServer: boolean;
786
798
  icePhaseCallback: () => string;
799
+ iceTransportPolicy?: RTCIceTransportPolicy;
787
800
  };
788
801
 
789
802
  private sendSlotManager: SendSlotManager = new SendSlotManager(LoggerProxy);
790
803
  private deferSDPAnswer?: Defer; // used for waiting for a response
791
804
  private sdpResponseTimer?: ReturnType<typeof setTimeout>;
792
805
  private hasMediaConnectionConnectedAtLeastOnce: boolean;
793
- private joinWithMediaRetryInfo?: {isRetry: boolean; prevJoinResponse?: any};
806
+ private joinWithMediaRetryInfo: {
807
+ retryCount: number;
808
+ prevJoinResponse?: any;
809
+ firstError?: Error;
810
+ prevError?: Error;
811
+ };
812
+
794
813
  private connectionStateHandler?: ConnectionStateHandler;
795
814
  private iceCandidateErrors: Map<string, number>;
796
815
  private iceCandidatesCount: number;
@@ -935,7 +954,7 @@ export default class Meeting extends StatelessWebexPlugin {
935
954
  this.simultaneousInterpretation = new SimultaneousInterpretation({}, {parent: this.webex});
936
955
 
937
956
  // @ts-ignore
938
- this.aiEnableRequest = new AIEnableRequest({}, {parent: this.webex});
957
+ this.aiEnableRequest = new AIEnableRequest({locusUrl: this.locusUrl}, {parent: this.webex});
939
958
 
940
959
  /**
941
960
  * @instance
@@ -966,6 +985,7 @@ export default class Meeting extends StatelessWebexPlugin {
966
985
  },
967
986
  (csi: CSI) => (this.members.findMemberByCsi(csi) as any)?.id
968
987
  );
988
+
969
989
  /**
970
990
  * Object containing helper classes for managing media requests for audio/video/screenshare (for multistream media connections)
971
991
  * All multistream media requests sent out for this meeting have to go through them.
@@ -985,6 +1005,7 @@ export default class Meeting extends StatelessWebexPlugin {
985
1005
  mediaRequests
986
1006
  );
987
1007
  },
1008
+ this.getIngressPayloadTypeCallback.bind(this),
988
1009
  {
989
1010
  // @ts-ignore - config coming from registerPlugin
990
1011
  degradationPreferences: this.config.degradationPreferences,
@@ -1006,6 +1027,7 @@ export default class Meeting extends StatelessWebexPlugin {
1006
1027
  mediaRequests
1007
1028
  );
1008
1029
  },
1030
+ this.getIngressPayloadTypeCallback.bind(this),
1009
1031
  {
1010
1032
  // @ts-ignore - config coming from registerPlugin
1011
1033
  degradationPreferences: this.config.degradationPreferences,
@@ -1027,6 +1049,7 @@ export default class Meeting extends StatelessWebexPlugin {
1027
1049
  mediaRequests
1028
1050
  );
1029
1051
  },
1052
+ this.getIngressPayloadTypeCallback.bind(this),
1030
1053
  {
1031
1054
  // @ts-ignore - config coming from registerPlugin
1032
1055
  degradationPreferences: this.config.degradationPreferences,
@@ -1048,11 +1071,14 @@ export default class Meeting extends StatelessWebexPlugin {
1048
1071
  mediaRequests
1049
1072
  );
1050
1073
  },
1074
+ this.getIngressPayloadTypeCallback.bind(this),
1051
1075
  {
1052
1076
  // @ts-ignore - config coming from registerPlugin
1053
1077
  degradationPreferences: this.config.degradationPreferences,
1054
1078
  kind: 'video',
1055
1079
  trimRequestsToNumOfSources: false,
1080
+ // @ts-ignore - config coming from registerPlugin
1081
+ enableAv1: this.config.enableAv1SlidesSupport,
1056
1082
  }
1057
1083
  ),
1058
1084
  };
@@ -1372,7 +1398,48 @@ export default class Meeting extends StatelessWebexPlugin {
1372
1398
  * @memberof Meeting
1373
1399
  */
1374
1400
  // @ts-ignore - Fix type
1375
- this.locusInfo = new LocusInfo(this.updateMeetingObject.bind(this), this.webex, this.id);
1401
+ this.locusInfo = new LocusInfo(
1402
+ {
1403
+ updateMeeting: this.updateMeetingObject.bind(this),
1404
+ syncLatencyTracker: {
1405
+ // Compute/store latency timestamps live on CallDiagnosticLatencies, while
1406
+ // submitting the client.locus.sync.complete CA event is owned by the metrics
1407
+ // facade. Wire each method to the layer that owns that responsibility.
1408
+ saveLatency: (...args) =>
1409
+ // @ts-ignore
1410
+ this.webex.internal.newMetrics.callDiagnosticLatencies.saveLatency(...args),
1411
+ saveTimestamp: (saveTimestampOptions: {
1412
+ key: string;
1413
+ value?: number;
1414
+ options: {meetingId: string; dataSetName: string; trackingId?: string};
1415
+ }) => {
1416
+ // @ts-ignore
1417
+ this.webex.internal.newMetrics.callDiagnosticLatencies.saveTimestamp(
1418
+ saveTimestampOptions
1419
+ );
1420
+
1421
+ // The /sync response is one of the two milestones (the other is the LLM message) that
1422
+ // complete client.locus.sync.complete. Try to complete now: the metric is emitted only
1423
+ // once both the LLM message and the /sync response have arrived (either can come first).
1424
+ if (
1425
+ saveTimestampOptions.key === 'internal.client.locus.sync.response' &&
1426
+ saveTimestampOptions.options?.trackingId
1427
+ ) {
1428
+ this.tryCompleteLocusSyncLatency(
1429
+ saveTimestampOptions.options.meetingId,
1430
+ saveTimestampOptions.options.trackingId
1431
+ );
1432
+ }
1433
+ },
1434
+ clearLocusSyncLatency: (...args) =>
1435
+ // @ts-ignore
1436
+ this.webex.internal.newMetrics.callDiagnosticLatencies.clearLocusSyncLatency(...args),
1437
+ },
1438
+ },
1439
+ // @ts-ignore
1440
+ this.webex,
1441
+ this.id
1442
+ );
1376
1443
 
1377
1444
  // We had to add listeners first before setting up the locus instance
1378
1445
  /**
@@ -1557,6 +1624,8 @@ export default class Meeting extends StatelessWebexPlugin {
1557
1624
  this.controlsOptionsManager = new ControlsOptionsManager(this.meetingRequest, {
1558
1625
  locusUrl: this.locusInfo?.url,
1559
1626
  displayHints: [],
1627
+ getControls: () => this.locusInfo?.controls,
1628
+ isWebinar: () => this.locusInfo?.info?.isWebinar,
1560
1629
  });
1561
1630
 
1562
1631
  this.setUpLocusInfoListeners();
@@ -1655,11 +1724,11 @@ export default class Meeting extends StatelessWebexPlugin {
1655
1724
  /**
1656
1725
  * Information needed for a retry of a call to joinWithMedia
1657
1726
  * @instance
1658
- * @type {{isRetry: boolean; prevJoinResponse?: any}}
1727
+ * @type {{retryCount: number; prevJoinResponse?: any}}
1659
1728
  * @private
1660
1729
  * @memberof Meeting
1661
1730
  */
1662
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
1731
+ this.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
1663
1732
 
1664
1733
  /**
1665
1734
  * Connection state handler
@@ -1713,6 +1782,37 @@ export default class Meeting extends StatelessWebexPlugin {
1713
1782
  this.mediaServerIp = undefined;
1714
1783
  }
1715
1784
 
1785
+ /**
1786
+ * Get the ingress payload type for a given media type and codec mime type
1787
+ * @param {MediaType} mediaType - The media type
1788
+ * @param {MediaCodecMimeType} codecMimeType - The codec mime type
1789
+ * @returns {number | undefined} - The ingress payload type
1790
+ * @private
1791
+ * @memberof Meeting
1792
+ */
1793
+ private getIngressPayloadTypeCallback(
1794
+ mediaType: MediaType,
1795
+ codecMimeType: MediaCodecMimeType
1796
+ ): number | undefined {
1797
+ if (this.isMultistream) {
1798
+ try {
1799
+ return this.mediaProperties.webrtcMediaConnection.getIngressPayloadType(
1800
+ mediaType,
1801
+ codecMimeType
1802
+ );
1803
+ } catch (error) {
1804
+ LoggerProxy.logger.info(
1805
+ `Meeting:index#mediaRequestManager --> failed to get ingress payload type for mediaType=${mediaType}, codecMimeType=${codecMimeType}`,
1806
+ error
1807
+ );
1808
+
1809
+ return undefined;
1810
+ }
1811
+ }
1812
+
1813
+ return undefined;
1814
+ }
1815
+
1716
1816
  /**
1717
1817
  * Temporary func to return webex object,
1718
1818
  * in order to access internal plugin metrics
@@ -1993,7 +2093,7 @@ export default class Meeting extends StatelessWebexPlugin {
1993
2093
  this.config.installedOrgID,
1994
2094
  this.locusId,
1995
2095
  extraParams,
1996
- {meetingId: this.id, sendCAevents},
2096
+ {meetingId: this.id, sendCAevents, correlationId: this.correlationId},
1997
2097
  registrationId,
1998
2098
  null,
1999
2099
  classificationId
@@ -2325,6 +2425,89 @@ export default class Meeting extends StatelessWebexPlugin {
2325
2425
  });
2326
2426
  }
2327
2427
 
2428
+ /**
2429
+ * Handles the LLM state-update message that resulted from a Locus /sync. Records the LLM arrival
2430
+ * time (the milestone that gates client.locus.sync.complete - the metric is emitted only for LLM
2431
+ * flows) and then tries to complete the metric.
2432
+ * @param {string} meetingId meeting id
2433
+ * @param {string} trackingId sync tracking id echoed back on the LLM message
2434
+ * @returns {void}
2435
+ * @private
2436
+ * @memberof Meeting
2437
+ */
2438
+ private onLocusSyncLlmMessage(meetingId: string, trackingId: string) {
2439
+ // @ts-ignore
2440
+ this.webex.internal.newMetrics.callDiagnosticLatencies.recordLocusSyncMessageReceived(
2441
+ meetingId,
2442
+ trackingId
2443
+ );
2444
+
2445
+ this.tryCompleteLocusSyncLatency(meetingId, trackingId);
2446
+ }
2447
+
2448
+ /**
2449
+ * Attempts to complete the Locus sync latency metric and emit client.locus.sync.complete. The
2450
+ * metric is emitted only once BOTH the /sync response and the resulting LLM message have arrived
2451
+ * (in either order); until then the record is kept so the missing milestone can still land. Both
2452
+ * trigger points (the LLM message handler and the /sync response timestamp) call this, so the
2453
+ * metric fires as soon as the second milestone is in.
2454
+ * @param {string} meetingId meeting id
2455
+ * @param {string} trackingId sync tracking id used to match the pending record
2456
+ * @returns {void}
2457
+ * @private
2458
+ * @memberof Meeting
2459
+ */
2460
+ private tryCompleteLocusSyncLatency(meetingId: string, trackingId: string) {
2461
+ const completed =
2462
+ // @ts-ignore
2463
+ this.webex.internal.newMetrics.callDiagnosticLatencies.completeLocusSyncLatency(
2464
+ meetingId,
2465
+ trackingId
2466
+ );
2467
+
2468
+ if (completed) {
2469
+ this.emitLocusSyncCompleteMetric(meetingId, completed);
2470
+ }
2471
+ }
2472
+
2473
+ /**
2474
+ * Submits the client.locus.sync.complete Call Analyzer event for a completed Locus sync latency
2475
+ * measurement.
2476
+ * @param {string} meetingId meeting id
2477
+ * @param {object} completed completed sync latency payload from the metrics plugin
2478
+ * @returns {void}
2479
+ * @private
2480
+ * @memberof Meeting
2481
+ */
2482
+ private emitLocusSyncCompleteMetric(
2483
+ meetingId: string,
2484
+ completed: {dataSet: string; syncLatency: object}
2485
+ ) {
2486
+ // @ts-ignore
2487
+ const llmWebsocketUrl = this.webex.internal.llm?.getWebSocketUrl?.() || undefined;
2488
+
2489
+ // Per the LLM sync-latency spec, the event carries the LLM websocket url identifier,
2490
+ // the llmInfo.dataSet (main, atd-active or atd-unmuted) and the syncLatency block.
2491
+ const clientEvent = {
2492
+ name: 'client.locus.sync.complete',
2493
+ payload: {
2494
+ identifiers: {
2495
+ llmWebsocketUrl,
2496
+ },
2497
+ llmInfo: {
2498
+ dataSet: completed.dataSet,
2499
+ },
2500
+ syncLatency: completed.syncLatency,
2501
+ },
2502
+ options: {
2503
+ meetingId,
2504
+ },
2505
+ };
2506
+
2507
+ // @ts-ignore
2508
+ this.webex.internal.newMetrics.submitClientEvent(clientEvent);
2509
+ }
2510
+
2328
2511
  /**
2329
2512
  * Proxy function for all the listener set ups
2330
2513
  * @returns {undefined}
@@ -2789,7 +2972,7 @@ export default class Meeting extends StatelessWebexPlugin {
2789
2972
  private setupLocusControlsListener() {
2790
2973
  this.locusInfo.on(
2791
2974
  LOCUSINFO.EVENTS.CONTROLS_RECORDING_UPDATED,
2792
- ({state, modifiedBy, lastModified}) => {
2975
+ ({state, modifiedBy, lastModified, modifiedByServiceAppName, modifiedByServiceAppId}) => {
2793
2976
  let event;
2794
2977
 
2795
2978
  switch (state) {
@@ -2815,6 +2998,8 @@ export default class Meeting extends StatelessWebexPlugin {
2815
2998
  state: state === RECORDING_STATE.RESUMED ? RECORDING_STATE.RECORDING : state,
2816
2999
  modifiedBy,
2817
3000
  lastModified,
3001
+ modifiedByServiceAppName,
3002
+ modifiedByServiceAppId,
2818
3003
  };
2819
3004
  Trigger.trigger(
2820
3005
  this,
@@ -3213,7 +3398,7 @@ export default class Meeting extends StatelessWebexPlugin {
3213
3398
  }
3214
3399
 
3215
3400
  LoggerProxy.logger.info(
3216
- `Meeting:index#setUpLocusInfoMediaInactiveListener --> this.shareStatus=${this.shareStatus} newShareStatus=${newShareStatus}`
3401
+ `Meeting:index#setUpLocusMediaSharesListener --> this.shareStatus=${this.shareStatus} newShareStatus=${newShareStatus}`
3217
3402
  );
3218
3403
 
3219
3404
  if (newShareStatus !== this.shareStatus) {
@@ -3459,13 +3644,12 @@ export default class Meeting extends StatelessWebexPlugin {
3459
3644
  this.breakouts.locusUrlUpdate(url);
3460
3645
  this.simultaneousInterpretation.locusUrlUpdate(url);
3461
3646
  this.annotation.locusUrlUpdate(url);
3647
+ this.aiEnableRequest.locusUrlUpdate(url);
3462
3648
  this.locusUrl = url;
3463
3649
  this.locusId = this.locusUrl?.split('/').pop();
3464
3650
  this.recordingController.setLocusUrl(this.locusUrl);
3465
3651
  this.controlsOptionsManager.setLocusUrl(this.locusUrl, !!isMainLocus);
3466
3652
  this.webinar.locusUrlUpdate(url);
3467
- // @ts-ignore
3468
- this.webex.internal.llm.setRefreshHandler(() => this.refreshDataChannelToken());
3469
3653
 
3470
3654
  Trigger.trigger(
3471
3655
  this,
@@ -3734,7 +3918,7 @@ export default class Meeting extends StatelessWebexPlugin {
3734
3918
  });
3735
3919
  this.updateLLMConnection();
3736
3920
  });
3737
- this.locusInfo.on(LOCUSINFO.EVENTS.SELF_ADMITTED_GUEST, (payload) => {
3921
+ this.locusInfo.on(LOCUSINFO.EVENTS.SELF_ADMITTED_GUEST, async (payload) => {
3738
3922
  this.stopKeepAlive();
3739
3923
 
3740
3924
  if (payload) {
@@ -3761,13 +3945,15 @@ export default class Meeting extends StatelessWebexPlugin {
3761
3945
  }
3762
3946
  this.rtcMetrics?.sendNextMetrics();
3763
3947
 
3764
- this.ensureDefaultDatachannelTokenAfterAdmit().catch((error) => {
3948
+ try {
3949
+ await this.ensureDefaultDatachannelTokenAfterAdmit();
3950
+ } catch (error) {
3765
3951
  LoggerProxy.logger.warn(
3766
3952
  `Meeting:index#setUpLocusInfoSelfListener --> failed post-admit token prefetch flow: ${
3767
3953
  error?.message || String(error)
3768
3954
  }`
3769
3955
  );
3770
- });
3956
+ }
3771
3957
 
3772
3958
  this.updateLLMConnection();
3773
3959
  });
@@ -3813,6 +3999,9 @@ export default class Meeting extends StatelessWebexPlugin {
3813
3999
  });
3814
4000
 
3815
4001
  this.locusInfo.on(LOCUSINFO.EVENTS.SELF_CANNOT_VIEW_PARTICIPANT_LIST_CHANGE, (payload) => {
4002
+ // canViewTheParticipantList meeting action depends on this value, so we need to update meeting actions
4003
+ this.updateMeetingActions();
4004
+
3816
4005
  Trigger.trigger(
3817
4006
  this,
3818
4007
  {
@@ -4007,7 +4196,14 @@ export default class Meeting extends StatelessWebexPlugin {
4007
4196
  // is not changed by any delta event
4008
4197
  if (object && Object.keys(object).length) {
4009
4198
  Object.keys(object).forEach((key) => {
4199
+ const previousValue = this[key];
4200
+
4010
4201
  this[key] = object[key];
4202
+
4203
+ if (this.promisesWaitingForPropUpdate[key] && previousValue !== object[key]) {
4204
+ this.promisesWaitingForPropUpdate[key].resolve();
4205
+ delete this.promisesWaitingForPropUpdate[key];
4206
+ }
4011
4207
  });
4012
4208
  }
4013
4209
  }
@@ -4145,7 +4341,12 @@ export default class Meeting extends StatelessWebexPlugin {
4145
4341
  }
4146
4342
 
4147
4343
  /**
4148
- * Transfer the moderator role to another eligible member
4344
+ * Transfer the moderator role to another eligible member.
4345
+ *
4346
+ * If the target member is currently joined in the current session, the request is
4347
+ * sent against the current locus. Otherwise, we search the breakout sessions and,
4348
+ * when the member is found in one, we send the request against that breakout
4349
+ * session's locus url instead.
4149
4350
  * @param {String} memberId
4150
4351
  * @param {Boolean} moderator
4151
4352
  * @returns {Promise} see #members.transferHostToMember
@@ -4153,7 +4354,21 @@ export default class Meeting extends StatelessWebexPlugin {
4153
4354
  * @memberof Meeting
4154
4355
  */
4155
4356
  public transfer(memberId: string, moderator = true) {
4156
- return this.members.transferHostToMember(memberId, moderator);
4357
+ const targetMember = this.members.membersCollection.get(memberId);
4358
+
4359
+ if (targetMember?.isInMeeting) {
4360
+ return this.members.transferHostToMember(memberId, moderator);
4361
+ }
4362
+
4363
+ const breakout = this.breakouts?.breakouts?.models?.find((bo: any) => {
4364
+ const breakoutMember = bo.members?.membersCollection?.get(memberId);
4365
+
4366
+ return breakoutMember?.isInMeeting;
4367
+ });
4368
+
4369
+ const breakoutLocusUrl = breakout?.breakoutRosterLocus?.url;
4370
+
4371
+ return this.members.transferHostToMember(memberId, moderator, breakoutLocusUrl);
4157
4372
  }
4158
4373
 
4159
4374
  /**
@@ -4611,6 +4826,13 @@ export default class Meeting extends StatelessWebexPlugin {
4611
4826
  ),
4612
4827
  isAttendeeRequestAiAssistantDeclinedAll:
4613
4828
  MeetingUtil.attendeeRequestAiAssistantDeclinedAll(this.userDisplayHints),
4829
+ isAnonymizeDisplayNamesEnabled: MeetingUtil.isAnonymizeDisplayNamesEnabled(
4830
+ this.userDisplayHints
4831
+ ),
4832
+ canViewTheParticipantList: MeetingUtil.canViewTheParticipantList(
4833
+ this.userDisplayHints,
4834
+ this.canNotViewTheParticipantList ?? false
4835
+ ),
4614
4836
  }) || changed;
4615
4837
  }
4616
4838
  if (changed) {
@@ -4659,6 +4881,34 @@ export default class Meeting extends StatelessWebexPlugin {
4659
4881
  this.sipUri = sipUri;
4660
4882
  }
4661
4883
 
4884
+ /**
4885
+ * After initial locus setup, refreshes destination with synced locus data and optionally
4886
+ * performs deferred meeting info fetch when initial locus was incomplete.
4887
+ * @param {LocusDTO} locus
4888
+ * @returns {void}
4889
+ */
4890
+ public async finalizeMeetingAfterInitialLocusSetup(locus: LocusDTO): Promise<void> {
4891
+ if (locus && this?.destinationType === DESTINATION_TYPE.LOCUS_ID) {
4892
+ // destination is initialized from the initial locus snapshot in constructor,
4893
+ // so refresh it after locus sync to avoid stale partial hash-tree data.
4894
+ this.destination = locus;
4895
+ }
4896
+ if (
4897
+ (!this.meetingInfo || isEmpty(this.meetingInfo)) &&
4898
+ (this.destination as LocusDTO)?.info &&
4899
+ !this.fetchMeetingInfoTimeoutId &&
4900
+ !MeetingsUtil.isOneOnOneCall(locus)
4901
+ ) {
4902
+ try {
4903
+ await this.fetchMeetingInfo({});
4904
+ } catch (error: any) {
4905
+ LoggerProxy.logger.info(
4906
+ `Meeting:index#finalizeMeetingAfterInitialLocusSetup --> deferred fetchMeetingInfo failed: ${error.message}`
4907
+ );
4908
+ }
4909
+ }
4910
+ }
4911
+
4662
4912
  /**
4663
4913
  * Set the locus info the class instance. Should be called with the parsed locus
4664
4914
  * we got in the join response.
@@ -5130,8 +5380,7 @@ export default class Meeting extends StatelessWebexPlugin {
5130
5380
  public setMercuryListener() {
5131
5381
  // Client will have a socket manager and handle reconnecting to mercury, when we reconnect to mercury
5132
5382
  // if the meeting has active peer connections, it should try to reconnect.
5133
- // @ts-ignore
5134
- this.webex.internal.mercury.on(ONLINE, () => {
5383
+ this.mercuryOnlineHandler = () => {
5135
5384
  LoggerProxy.logger.info('Meeting:index#setMercuryListener --> Web socket online');
5136
5385
 
5137
5386
  // Only send restore event when it was disconnected before and for connected later
@@ -5141,15 +5390,47 @@ export default class Meeting extends StatelessWebexPlugin {
5141
5390
  });
5142
5391
  }
5143
5392
  this.hasWebsocketConnected = true;
5144
- });
5393
+ };
5145
5394
 
5146
- // @ts-ignore
5147
- this.webex.internal.mercury.on(OFFLINE, () => {
5395
+ this.mercuryOfflineHandler = () => {
5148
5396
  LoggerProxy.logger.error('Meeting:index#setMercuryListener --> Web socket offline');
5149
5397
  Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.MERCURY_CONNECTION_FAILURE, {
5150
5398
  correlation_id: this.correlationId,
5151
5399
  });
5152
- });
5400
+ };
5401
+
5402
+ // @ts-ignore
5403
+ this.webex.internal.mercury.on(ONLINE, this.mercuryOnlineHandler);
5404
+ // @ts-ignore
5405
+ this.webex.internal.mercury.on(OFFLINE, this.mercuryOfflineHandler);
5406
+ }
5407
+
5408
+ /**
5409
+ * Removes this meeting's Mercury ONLINE/OFFLINE event listeners registered
5410
+ * by setMercuryListener(). Must be called before Locus /leave to avoid
5411
+ * unnecessary syncs/metrics triggered by events received while leaving
5412
+ * (per Locus team recommendation).
5413
+ *
5414
+ * Mercury is a process-wide singleton shared with other plugins, so we
5415
+ * pass the bound handler refs to .off() to avoid clearing every listener
5416
+ * for ONLINE/OFFLINE on the shared emitter.
5417
+ *
5418
+ * Idempotent: subsequent calls are no-ops because the handler refs are
5419
+ * cleared after detaching.
5420
+ * @private
5421
+ * @returns {void}
5422
+ */
5423
+ private stopListeningForMercuryEvents() {
5424
+ if (this.mercuryOnlineHandler) {
5425
+ // @ts-ignore
5426
+ this.webex.internal.mercury.off(ONLINE, this.mercuryOnlineHandler);
5427
+ this.mercuryOnlineHandler = undefined;
5428
+ }
5429
+ if (this.mercuryOfflineHandler) {
5430
+ // @ts-ignore
5431
+ this.webex.internal.mercury.off(OFFLINE, this.mercuryOfflineHandler);
5432
+ this.mercuryOfflineHandler = undefined;
5433
+ }
5153
5434
  }
5154
5435
 
5155
5436
  /**
@@ -5173,6 +5454,7 @@ export default class Meeting extends StatelessWebexPlugin {
5173
5454
  );
5174
5455
 
5175
5456
  this.receiveSlotManager.reset();
5457
+
5176
5458
  this.mediaProperties.webrtcMediaConnection.close();
5177
5459
  this.mediaProperties.unsetPeerConnection();
5178
5460
  this.sendSlotManager.reset();
@@ -5460,7 +5742,7 @@ export default class Meeting extends StatelessWebexPlugin {
5460
5742
  } = {}
5461
5743
  ) {
5462
5744
  const {mediaOptions, joinOptions = {}} = options;
5463
- const {isRetry, prevJoinResponse} = this.joinWithMediaRetryInfo;
5745
+ const {retryCount, prevJoinResponse, prevError} = this.joinWithMediaRetryInfo;
5464
5746
 
5465
5747
  if (!mediaOptions?.allowMediaInLobby) {
5466
5748
  return Promise.reject(
@@ -5471,9 +5753,6 @@ export default class Meeting extends StatelessWebexPlugin {
5471
5753
 
5472
5754
  LoggerProxy.logger.info('Meeting:index#joinWithMedia called');
5473
5755
 
5474
- let joined = false;
5475
- let joinResponse = prevJoinResponse;
5476
-
5477
5756
  /* Before we do anything, check if RTCPeerConnection is available. Normally this is checked
5478
5757
  by addMediaInternal() itself when creating the media connection, but since joinWithMedia()
5479
5758
  is a convenience method that does both join() and addMedia(), we want to fail fast here
@@ -5486,12 +5765,28 @@ export default class Meeting extends StatelessWebexPlugin {
5486
5765
  );
5487
5766
  }
5488
5767
 
5768
+ /* While we're trying to join, we may fail and be doing a retry. In that case,
5769
+ we sometimes get dropped by Locus as a result of the 1st failed attempt.
5770
+ That notification from Locus needs to be ignored, otherwise it causes the meeting to be
5771
+ cleaned up and prevents the retry from running correctly.
5772
+ */
5773
+ this.locusInfo.suspendDestroyMeeting(true);
5774
+
5775
+ let joined = false;
5776
+ let joinResponse = prevJoinResponse;
5777
+
5778
+ const shouldJoin =
5779
+ !joinResponse || // first try, when the join response is empty
5780
+ (prevError && prevError instanceof UserNotJoinedError) || // last try failed with UserNotJoinedError
5781
+ this.isErrorMeaningLocusDroppedUs(prevError) ||
5782
+ MeetingUtil.isUserInLeftState(this.locusInfo); // locus dropped the connection before we can re-try addMedia
5783
+
5489
5784
  try {
5490
5785
  let turnServerInfo;
5491
5786
  let turnDiscoverySkippedReason;
5492
5787
  let forceTurnDiscovery = false;
5493
5788
 
5494
- if (!joinResponse) {
5789
+ if (shouldJoin) {
5495
5790
  // This is the 1st attempt or a retry after join request failed -> we need to do a join with TURN discovery
5496
5791
 
5497
5792
  const turnDiscoveryRequest = await this.roap.generateTurnDiscoveryRequestMessage(
@@ -5530,16 +5825,24 @@ export default class Meeting extends StatelessWebexPlugin {
5530
5825
  joined = true;
5531
5826
  }
5532
5827
 
5828
+ const shouldRetryMediaWithOnlyTurnTLS = await this.shouldRetryMediaWithOnlyTurnTLS(prevError);
5829
+
5533
5830
  const mediaResponse = await this.addMediaInternal(
5534
5831
  () => {
5535
- return this.joinWithMediaRetryInfo.isRetry ? 'JOIN_MEETING_FINAL' : 'JOIN_MEETING_RETRY';
5832
+ // callback is not called when UserNotJoinedError is thrown
5833
+ return this.joinWithMediaRetryInfo.retryCount >= 1
5834
+ ? 'JOIN_MEETING_FINAL'
5835
+ : 'JOIN_MEETING_RETRY';
5536
5836
  },
5537
- turnServerInfo,
5538
5837
  forceTurnDiscovery,
5838
+ turnServerInfo,
5839
+ shouldRetryMediaWithOnlyTurnTLS ? 'relay' : undefined,
5539
5840
  mediaOptions
5540
5841
  );
5541
5842
 
5542
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
5843
+ this.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
5844
+
5845
+ this.locusInfo.suspendDestroyMeeting(false);
5543
5846
 
5544
5847
  return {
5545
5848
  join: joinResponse,
@@ -5553,15 +5856,21 @@ export default class Meeting extends StatelessWebexPlugin {
5553
5856
 
5554
5857
  this.roap.abortTurnDiscovery();
5555
5858
 
5556
- // if this was the first attempt, let's do a retry
5557
- let shouldRetry = !isRetry;
5859
+ // let's do a retry (but not on 1-1 calls, because the flow would get too complicated)
5860
+ let shouldRetry =
5861
+ !MeetingsUtil.isOneOnOneCall(this.locusInfo.parsedLocus) &&
5862
+ (retryCount < 1 ||
5863
+ ((error instanceof UserNotJoinedError || this.isErrorMeaningLocusDroppedUs(error)) &&
5864
+ retryCount < JOIN_WITH_MEDIA_RETRY_MAX_COUNT));
5558
5865
 
5559
5866
  if (
5560
5867
  CallDiagnosticUtils.isSdpOfferCreationError(error) ||
5561
- CallDiagnosticUtils.isWebrtcApiNotAvailableError(error)
5868
+ CallDiagnosticUtils.isWebrtcApiNotAvailableError(error) ||
5869
+ this.isLocusUserFullError(error)
5562
5870
  ) {
5563
5871
  // errors related to offer creation (for example missing H264 codec) will happen again no matter how many times we try,
5564
5872
  // so there is no point doing a retry
5873
+ // when the locus is full, we also don't want to retry, because it will just fail again
5565
5874
  shouldRetry = false;
5566
5875
  }
5567
5876
 
@@ -5579,8 +5888,8 @@ export default class Meeting extends StatelessWebexPlugin {
5579
5888
  });
5580
5889
  }
5581
5890
 
5582
- // we only want to call leave if join was successful and this was a retry or we won't be doing any more retries
5583
- if (joined && (isRetry || !shouldRetry)) {
5891
+ // we only want to call leave if join was successful, and we won't be doing any more retries
5892
+ if (joined && !shouldRetry) {
5584
5893
  try {
5585
5894
  await this.leave({resourceId: joinOptions?.resourceId, reason: 'joinWithMedia failure'});
5586
5895
  } catch (e) {
@@ -5597,7 +5906,7 @@ export default class Meeting extends StatelessWebexPlugin {
5597
5906
  reason: error.message,
5598
5907
  stack: error.stack,
5599
5908
  leaveErrorReason: leaveError?.message,
5600
- isRetry,
5909
+ isRetry: retryCount > 0,
5601
5910
  },
5602
5911
  {
5603
5912
  type: error.name,
@@ -5606,15 +5915,30 @@ export default class Meeting extends StatelessWebexPlugin {
5606
5915
 
5607
5916
  if (shouldRetry) {
5608
5917
  LoggerProxy.logger.warn('Meeting:index#joinWithMedia --> retrying call to joinWithMedia');
5609
- this.joinWithMediaRetryInfo.isRetry = true;
5918
+ this.joinWithMediaRetryInfo.retryCount = retryCount + 1;
5610
5919
  this.joinWithMediaRetryInfo.prevJoinResponse = joinResponse;
5920
+ this.joinWithMediaRetryInfo.prevError = error;
5921
+ if (!this.joinWithMediaRetryInfo.firstError) {
5922
+ this.joinWithMediaRetryInfo.firstError = error;
5923
+ }
5611
5924
 
5612
5925
  return this.joinWithMedia(options);
5613
5926
  }
5614
5927
 
5615
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
5928
+ const {firstError} = this.joinWithMediaRetryInfo;
5616
5929
 
5617
- throw error;
5930
+ this.joinWithMediaRetryInfo = {
5931
+ retryCount: 0,
5932
+ prevJoinResponse: undefined,
5933
+ firstError: undefined,
5934
+ prevError: undefined,
5935
+ };
5936
+
5937
+ this.locusInfo.suspendDestroyMeeting(false);
5938
+
5939
+ // LOCUS_USER_FULL is a definitive capacity error the client must surface, so it takes
5940
+ // precedence over any earlier retryable error stored in firstError.
5941
+ throw this.isLocusUserFullError(error) ? error : firstError ?? error;
5618
5942
  }
5619
5943
  }
5620
5944
 
@@ -5857,7 +6181,18 @@ export default class Meeting extends StatelessWebexPlugin {
5857
6181
  storeEventForDebugging('llm', event.data);
5858
6182
  }
5859
6183
 
6184
+ const {trackingId} = event;
6185
+
5860
6186
  this.locusInfo.parse(this, event.data);
6187
+
6188
+ // Only the client whose /sync request tracking id matches the tracking id echoed back on this
6189
+ // LLM message should emit client.locus.sync.complete. The tracking id lives at the top level
6190
+ // of the received LLM event envelope. When it is absent there is nothing to correlate, so
6191
+ // skip. onLocusSyncLlmMessage records the LLM arrival time and is a no-op unless a stored
6192
+ // record for this meeting matches the tracking id.
6193
+ if (trackingId) {
6194
+ this.onLocusSyncLlmMessage(this.id, trackingId);
6195
+ }
5861
6196
  } else {
5862
6197
  LoggerProxy.logger.warn(
5863
6198
  `Meeting:index#processLocusLLMEvent --> Unknown event type: ${event.data.eventType}`
@@ -5865,6 +6200,31 @@ export default class Meeting extends StatelessWebexPlugin {
5865
6200
  }
5866
6201
  };
5867
6202
 
6203
+ /**
6204
+ * Verifies the relay event was delivered for the active LLM session binding.
6205
+ * @param {RelayEvent} event Event object coming from LLM Connection
6206
+ * @returns {boolean}
6207
+ */
6208
+ private isRelayEventRouteValid(event: RelayEvent): boolean {
6209
+ const route = event?.headers?.route;
6210
+
6211
+ if (!route) {
6212
+ return true;
6213
+ }
6214
+
6215
+ const {llm} = (this as any).webex.internal;
6216
+ const isPracticeSession = llm.isConnected(LLM_PRACTICE_SESSION);
6217
+ const expectedBinding = isPracticeSession
6218
+ ? llm.getBinding(LLM_PRACTICE_SESSION)
6219
+ : llm.getBinding();
6220
+
6221
+ if (!expectedBinding || route === expectedBinding) {
6222
+ return true;
6223
+ }
6224
+
6225
+ return false;
6226
+ }
6227
+
5868
6228
  /**
5869
6229
  * Callback called when a relay event is received from meeting LLM Connection
5870
6230
  * @param {RelayEvent} e Event object coming from LLM Connection
@@ -5872,6 +6232,9 @@ export default class Meeting extends StatelessWebexPlugin {
5872
6232
  * @returns {void}
5873
6233
  */
5874
6234
  private processRelayEvent = (e: RelayEvent): void => {
6235
+ if (!this.isRelayEventRouteValid(e)) {
6236
+ return;
6237
+ }
5875
6238
  switch (e.data.relayType) {
5876
6239
  case REACTION_RELAY_TYPES.REACTION:
5877
6240
  if (
@@ -5975,10 +6338,11 @@ export default class Meeting extends StatelessWebexPlugin {
5975
6338
  */
5976
6339
  private restoreLLMSubscriptionsIfNeeded(): void {
5977
6340
  try {
5978
- // @ts-ignore
5979
- const isCaptionBoxOn = this.webex.internal.voicea?.getIsCaptionBoxOn?.();
6341
+ const keepTranscriptionSubscribed =
6342
+ // @ts-ignore
6343
+ this.webex.internal.voicea?.getKeepTranscriptionSubscribed?.();
5980
6344
 
5981
- if (!isCaptionBoxOn) {
6345
+ if (!keepTranscriptionSubscribed) {
5982
6346
  return;
5983
6347
  }
5984
6348
 
@@ -6002,6 +6366,7 @@ export default class Meeting extends StatelessWebexPlugin {
6002
6366
  */
6003
6367
  private handleLLMOnline = (): void => {
6004
6368
  this.restoreLLMSubscriptionsIfNeeded();
6369
+ this.locusInfo.syncAllHashTreeDatasets({onlyLLM: true});
6005
6370
 
6006
6371
  Trigger.trigger(
6007
6372
  this,
@@ -6237,7 +6602,7 @@ export default class Meeting extends StatelessWebexPlugin {
6237
6602
  this.webex.internal.llm.off('online', this.handleLLMOnline);
6238
6603
  // @ts-ignore
6239
6604
  this.webex.internal.llm.on('online', this.handleLLMOnline);
6240
- this.updateLLMConnection()
6605
+ this.updateLLMConnection({isInitialJoinPhase: true})
6241
6606
  .catch((error) => {
6242
6607
  LoggerProxy.logger.error(
6243
6608
  'Meeting:index#join --> Transcription Socket Connection Failed',
@@ -6301,8 +6666,57 @@ export default class Meeting extends StatelessWebexPlugin {
6301
6666
  }
6302
6667
  }
6303
6668
 
6669
+ /**
6670
+ * Removes LLM event listeners and clears the health check timer.
6671
+ * Must be called before Locus /leave to avoid unnecessary syncs triggered
6672
+ * by events received while leaving (per Locus team recommendation).
6673
+ * Idempotent: safe to call multiple times; .off() is a no-op when no
6674
+ * matching listener is registered.
6675
+ * @private
6676
+ * @returns {void}
6677
+ */
6678
+ private stopListeningForLLMEvents() {
6679
+ // @ts-ignore - fix types
6680
+ this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6681
+ // @ts-ignore - fix types
6682
+ this.webex.internal.llm.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6683
+ this.clearLLMHealthCheckTimer();
6684
+ }
6685
+
6686
+ /**
6687
+ * Stops listening on every event bus (LLM, Mercury, voicea/transcription,
6688
+ * annotation) that could otherwise deliver events to this meeting while
6689
+ * Locus is processing /leave or /end. Per the Locus team recommendation,
6690
+ * this must run before the Locus request is dispatched to avoid
6691
+ * unnecessary syncs triggered by in-flight events.
6692
+ *
6693
+ * Voicea (transcription) subscribes to llm 'event:relay.event' internally,
6694
+ * and the annotation plugin subscribes to both mercury and llm, so both
6695
+ * must be torn down alongside the direct LLM/Mercury listeners.
6696
+ *
6697
+ * Idempotent: safe to call multiple times; .off() is a no-op when no
6698
+ * matching listener is registered, and stopTranscription is guarded.
6699
+ * @private
6700
+ * @returns {void}
6701
+ */
6702
+ private stopListeningForMeetingEvents() {
6703
+ this.stopListeningForLLMEvents();
6704
+ this.stopListeningForMercuryEvents();
6705
+ if (this.transcription) {
6706
+ this.stopTranscription();
6707
+ this.transcription = undefined;
6708
+ }
6709
+ this.annotation.deregisterEvents();
6710
+ }
6711
+
6304
6712
  /**
6305
6713
  * Disconnects and cleans up the default LLM session listeners/timers.
6714
+ *
6715
+ * Ownership-aware: only calls `disconnectLLM` when this meeting is the
6716
+ * current owner of the default LLM session (or when no owner is recorded).
6717
+ * Event listeners belonging to this meeting instance are always detached
6718
+ * so they do not receive another meeting's relay events.
6719
+ *
6306
6720
  * @param {Object} options
6307
6721
  * @param {boolean} [options.removeOnlineListener=true] removes the one-time online listener
6308
6722
  * @param {boolean} [options.throwOnError=true] rethrows disconnect errors when true
@@ -6315,12 +6729,29 @@ export default class Meeting extends StatelessWebexPlugin {
6315
6729
  removeOnlineListener?: boolean;
6316
6730
  throwOnError?: boolean;
6317
6731
  } = {}): Promise<void> => {
6732
+ // @ts-ignore - Fix type
6733
+ // @ts-ignore - Fix type
6734
+ const {currentOwner, isOwner} = this.webex.internal.llm.resolveSessionOwnership(
6735
+ this.id,
6736
+ LLM_DEFAULT_SESSION
6737
+ );
6738
+
6318
6739
  try {
6319
- // @ts-ignore - Fix type
6320
- await this.webex.internal.llm.disconnectLLM({
6321
- code: 3050,
6322
- reason: 'done (permanent)',
6323
- });
6740
+ if (isOwner) {
6741
+ // @ts-ignore - Fix type
6742
+ await this.webex.internal.llm.disconnectLLM(
6743
+ {
6744
+ code: 3050,
6745
+ reason: 'done (permanent)',
6746
+ },
6747
+ LLM_DEFAULT_SESSION,
6748
+ this.id
6749
+ );
6750
+ } else {
6751
+ LoggerProxy.logger.info(
6752
+ `Meeting:index#cleanupLLMConneciton --> skipping disconnect; LLM owned by meeting ${currentOwner}, not ${this.id}`
6753
+ );
6754
+ }
6324
6755
  } catch (error) {
6325
6756
  LoggerProxy.logger.error(
6326
6757
  'Meeting:index#cleanupLLMConneciton --> Failed to disconnect default LLM session',
@@ -6335,23 +6766,33 @@ export default class Meeting extends StatelessWebexPlugin {
6335
6766
  // @ts-ignore - Fix type
6336
6767
  this.webex.internal.llm.off('online', this.handleLLMOnline);
6337
6768
  }
6338
- // @ts-ignore - fix types
6339
- this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6340
- // @ts-ignore - Fix type
6341
- this.webex.internal.llm.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6769
+ this.stopListeningForLLMEvents();
6770
+
6771
+ // Re-check ownership after awaiting disconnectLLM. If ownership changed
6772
+ // while cleanup was in flight, do not clear another meeting's owner tag.
6773
+ if (isOwner) {
6774
+ const {currentOwner: currentOwnerAfterCleanup} =
6775
+ // @ts-ignore - Fix type
6776
+ this.webex.internal.llm.resolveSessionOwnership(this.id, LLM_DEFAULT_SESSION);
6342
6777
 
6343
- this.clearLLMHealthCheckTimer();
6778
+ if (currentOwnerAfterCleanup === this.id) {
6779
+ // @ts-ignore - Fix type
6780
+ this.webex.internal.llm.setOwnerMeetingId?.(undefined);
6781
+ }
6782
+ }
6344
6783
  }
6345
6784
  };
6346
6785
 
6347
6786
  /**
6348
- * Clears all data channel tokens stored in LLM.
6349
- * Called during meeting cleanup to ensure stale tokens are not reused.
6787
+ * Clears data channel tokens associated with this meeting ownership.
6788
+ * Ownership checks are enforced in internal-plugin-llm.
6350
6789
  * @returns {void}
6351
6790
  */
6352
6791
  clearDataChannelToken(): void {
6353
6792
  // @ts-ignore
6354
- this.webex.internal.llm.resetDatachannelTokens();
6793
+ this.webex.internal.llm.clearDatachannelToken(LLM_DEFAULT_SESSION, this.id);
6794
+ // @ts-ignore
6795
+ this.webex.internal.llm.clearDatachannelToken(LLM_PRACTICE_SESSION, this.id);
6355
6796
  }
6356
6797
 
6357
6798
  /**
@@ -6366,14 +6807,15 @@ export default class Meeting extends StatelessWebexPlugin {
6366
6807
 
6367
6808
  if (datachannelToken) {
6368
6809
  // @ts-ignore
6369
- this.webex.internal.llm.setDatachannelToken(datachannelToken, DataChannelTokenType.Default);
6810
+ this.webex.internal.llm.setDatachannelToken(datachannelToken, LLM_DEFAULT_SESSION, this.id);
6370
6811
  }
6371
6812
 
6372
6813
  if (practiceSessionDatachannelToken) {
6373
6814
  // @ts-ignore
6374
6815
  this.webex.internal.llm.setDatachannelToken(
6375
6816
  practiceSessionDatachannelToken,
6376
- DataChannelTokenType.PracticeSession
6817
+ LLM_PRACTICE_SESSION,
6818
+ this.id
6377
6819
  );
6378
6820
  }
6379
6821
  }
@@ -6386,7 +6828,10 @@ export default class Meeting extends StatelessWebexPlugin {
6386
6828
  private async ensureDefaultDatachannelTokenAfterAdmit(): Promise<boolean> {
6387
6829
  try {
6388
6830
  // @ts-ignore
6389
- const datachannelToken = this.webex.internal.llm.getDatachannelToken();
6831
+ const datachannelToken = this.webex.internal.llm.getDatachannelToken(
6832
+ LLM_DEFAULT_SESSION,
6833
+ this.id
6834
+ );
6390
6835
  // @ts-ignore
6391
6836
  const isDataChannelTokenEnabled = await this.webex.internal.llm.isDataChannelTokenEnabled();
6392
6837
 
@@ -6408,7 +6853,8 @@ export default class Meeting extends StatelessWebexPlugin {
6408
6853
  // @ts-ignore
6409
6854
  this.webex.internal.llm.setDatachannelToken(
6410
6855
  fetchedDatachannelToken,
6411
- DataChannelTokenType.Default
6856
+ LLM_DEFAULT_SESSION,
6857
+ this.id
6412
6858
  );
6413
6859
 
6414
6860
  return true;
@@ -6427,23 +6873,68 @@ export default class Meeting extends StatelessWebexPlugin {
6427
6873
  /**
6428
6874
  * Connects to low latency mercury and reconnects if the address has changed
6429
6875
  * It will also disconnect if called when the meeting has ended
6876
+ * @param {Object} [options]
6877
+ * @param {boolean} [options.isInitialJoinPhase] true when called from initial join flow
6430
6878
  * @returns {Promise}
6431
6879
  */
6432
- async updateLLMConnection() {
6880
+ async updateLLMConnection({isInitialJoinPhase = false}: {isInitialJoinPhase?: boolean} = {}) {
6433
6881
  // @ts-ignore - Fix type
6434
6882
  const {url = undefined, info: {datachannelUrl = undefined} = {}} = this.locusInfo || {};
6435
6883
 
6436
6884
  const isJoined = this.isJoined();
6437
6885
 
6438
- // @ts-ignore
6439
- const datachannelToken = this.webex.internal.llm.getDatachannelToken(
6440
- DataChannelTokenType.Default
6886
+ const dataChannelUrl = datachannelUrl;
6887
+
6888
+ // Ownership guard: when the default LLM session is already connected and
6889
+ // owned by a *different* Meeting instance, do not disconnect or reconfigure
6890
+ // it. Another meeting's `updateLLMConnection` must be ignored here to
6891
+ // avoid killing the socket it relies on. We only proceed to manage the
6892
+ // connection when this meeting is the current owner, or when no owner is
6893
+ // set yet (first claim).
6894
+ // @ts-ignore - Fix type
6895
+ const {currentOwner} = this.webex.internal.llm.resolveSessionOwnership(
6896
+ this.id,
6897
+ LLM_DEFAULT_SESSION
6441
6898
  );
6442
6899
 
6443
- const dataChannelUrl = datachannelUrl;
6900
+ // Capture connectivity before any reconnect attempt. If LLM was already
6901
+ // connected, we must respect current ownership. If it was disconnected,
6902
+ // this flow may reclaim stale owner tags after a fresh connect.
6903
+ // @ts-ignore - Fix type
6904
+ const wasConnected = this.webex.internal.llm.isConnected();
6905
+
6906
+ // Prefer ownership-scoped token read. For disconnected stale-owner reclaim
6907
+ // flows, fallback to ownerless read so initial register can still carry a
6908
+ // token and recover from stale ownership without 401/403 dead-end.
6909
+ // @ts-ignore - Fix type
6910
+ let datachannelToken = this.webex.internal.llm.getDatachannelToken(
6911
+ LLM_DEFAULT_SESSION,
6912
+ this.id
6913
+ );
6914
+
6915
+ if (!datachannelToken && !wasConnected && currentOwner && currentOwner !== this.id) {
6916
+ // @ts-ignore - Fix type
6917
+ datachannelToken = this.webex.internal.llm.getDatachannelToken(LLM_DEFAULT_SESSION);
6918
+ }
6444
6919
 
6445
6920
  // @ts-ignore - Fix type
6446
- if (this.webex.internal.llm.isConnected()) {
6921
+ if (wasConnected) {
6922
+ if (currentOwner && currentOwner !== this.id) {
6923
+ // Another meeting owns the live LLM socket. We must not disconnect
6924
+ // or reconfigure it -- doing so would tear down a session the
6925
+ // owning meeting still relies on. Locus/datachannel URL mismatch is
6926
+ // expected here (each meeting has its own locus URL) and is NOT a
6927
+ // valid signal of staleness, so we never reclaim from this path.
6928
+ // The only safe reclaim mechanism is the `finally`-block owner-tag
6929
+ // release in `cleanupLLMConneciton`, which fires when this meeting
6930
+ // itself is being torn down.
6931
+ LoggerProxy.logger.info(
6932
+ `Meeting:index#updateLLMConnection --> skipping; LLM owned by meeting ${currentOwner}, not ${this.id}`
6933
+ );
6934
+
6935
+ return undefined;
6936
+ }
6937
+
6447
6938
  if (
6448
6939
  // @ts-ignore - Fix type
6449
6940
  url === this.webex.internal.llm.getLocusUrl() &&
@@ -6460,10 +6951,56 @@ export default class Meeting extends StatelessWebexPlugin {
6460
6951
  return undefined;
6461
6952
  }
6462
6953
 
6954
+ // Bind refresh handler before registration so interceptor-triggered token
6955
+ // refresh during register POST can resolve a valid handler.
6956
+ // Prefer this meeting as owner, but allow owner-less fallback when a stale
6957
+ // foreign owner tag is present on a disconnected session.
6958
+ const refreshHandlerOwnerMeetingId =
6959
+ currentOwner && currentOwner !== this.id ? undefined : this.id;
6960
+ const shouldAlignRefreshHandlerAfterOwnershipClaim = refreshHandlerOwnerMeetingId !== this.id;
6961
+ // @ts-ignore - Fix type
6962
+ this.webex.internal.llm.setRefreshHandler(
6963
+ () => this.refreshDataChannelToken(),
6964
+ LLM_DEFAULT_SESSION,
6965
+ refreshHandlerOwnerMeetingId
6966
+ );
6967
+
6463
6968
  // @ts-ignore - Fix type
6464
6969
  return this.webex.internal.llm
6465
6970
  .registerAndConnect(url, dataChannelUrl, datachannelToken)
6466
6971
  .then((registerAndConnectResult) => {
6972
+ this.locusInfo.syncAllHashTreeDatasets({onlyLLM: true});
6973
+ // Record ownership of the default LLM session for this meeting so
6974
+ // subsequent cross-meeting `updateLLMConnection` / `cleanupLLMConneciton`
6975
+ // calls can detect and skip work that doesn't belong to them.
6976
+ // @ts-ignore - Fix type
6977
+ const {isOwner} = this.webex.internal.llm.resolveSessionOwnership(
6978
+ this.id,
6979
+ LLM_DEFAULT_SESSION
6980
+ );
6981
+ const canReclaimAfterDisconnectedStart = !wasConnected;
6982
+
6983
+ // Refresh handler is pre-bound before registerAndConnect so token
6984
+ // refresh can work even during the registration request itself.
6985
+ if (isOwner || canReclaimAfterDisconnectedStart) {
6986
+ // Record ownership of the default LLM session for this meeting so
6987
+ // subsequent cross-meeting `updateLLMConnection` / `cleanupLLMConneciton`
6988
+ // calls can detect and skip work that doesn't belong to them.
6989
+ // @ts-ignore - Fix type
6990
+ this.webex.internal.llm.setOwnerMeetingId?.(this.id);
6991
+
6992
+ // If we pre-bound refresh ownerlessly (stale-owner reclaim path),
6993
+ // align the handler with the newly claimed owner immediately after
6994
+ // ownership is updated.
6995
+ if (shouldAlignRefreshHandlerAfterOwnershipClaim) {
6996
+ // @ts-ignore - Fix type
6997
+ this.webex.internal.llm.setRefreshHandler(
6998
+ () => this.refreshDataChannelToken(),
6999
+ LLM_DEFAULT_SESSION,
7000
+ this.id
7001
+ );
7002
+ }
7003
+ }
6467
7004
  // @ts-ignore - Fix type
6468
7005
  this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6469
7006
  // @ts-ignore - Fix type
@@ -6478,10 +7015,114 @@ export default class Meeting extends StatelessWebexPlugin {
6478
7015
 
6479
7016
  this.startLLMHealthCheckTimer();
6480
7017
 
7018
+ if (registerAndConnectResult) {
7019
+ if (isInitialJoinPhase) {
7020
+ this.sendLLMConnectMetric(registerAndConnectResult);
7021
+ }
7022
+
7023
+ this.breakouts?.trigger(BREAKOUTS.EVENTS.LLM_CONNECT_RESPONSE, {
7024
+ meeting: this,
7025
+ llmLatency: registerAndConnectResult,
7026
+ });
7027
+ }
7028
+
6481
7029
  return Promise.resolve(registerAndConnectResult);
7030
+ })
7031
+ .catch((error) => {
7032
+ // Prefer the partial timing registerAndConnect attaches when register succeeded but the
7033
+ // websocket connect() failed, so a ws failure isn't misreported as register never completing.
7034
+ const llmLatency = {
7035
+ clientLLMDatachannelResponseTime: error?.timing?.clientLLMDatachannelResponseTime ?? 0,
7036
+ clientLLMWebSocketConnectTime: 0,
7037
+ };
7038
+
7039
+ if (isInitialJoinPhase) {
7040
+ this.sendLLMConnectMetric(llmLatency, error);
7041
+ }
7042
+
7043
+ this.breakouts?.trigger(BREAKOUTS.EVENTS.LLM_CONNECT_RESPONSE, {
7044
+ meeting: this,
7045
+ llmLatency,
7046
+ error,
7047
+ });
7048
+
7049
+ return Promise.reject(error);
6482
7050
  });
6483
7051
  }
6484
7052
 
7053
+ /**
7054
+ * Ensures breakout join response metric with LLM latency is emitted only once per breakout move id.
7055
+ * @param {string | undefined} breakoutMoveId
7056
+ * @param {boolean} [hasLLMLatency=false]
7057
+ * @returns {boolean}
7058
+ */
7059
+ private shouldEmitBreakoutJoinResponseMetric(
7060
+ breakoutMoveId?: string,
7061
+ hasLLMLatency = false
7062
+ ): boolean {
7063
+ if (!breakoutMoveId) {
7064
+ return false;
7065
+ }
7066
+
7067
+ if (!hasLLMLatency) {
7068
+ // When automatic LLM is enabled, updateLLMConnection will emit this same breakout join
7069
+ // response after the LLM connection finishes, including llmLatency and llmWebsocketUrl.
7070
+ // Suppress the earlier non-LLM event to avoid sending two events for the same move id,
7071
+ // where the first one would be missing the LLM-specific fields we want to validate.
7072
+ // @ts-ignore - config coming from registerPlugin
7073
+ return !this.config.enableAutomaticLLM;
7074
+ }
7075
+
7076
+ if (this.emittedBreakoutJoinResponseMoveIds.has(breakoutMoveId)) {
7077
+ return false;
7078
+ }
7079
+
7080
+ this.emittedBreakoutJoinResponseMoveIds.add(breakoutMoveId);
7081
+
7082
+ return true;
7083
+ }
7084
+
7085
+ /**
7086
+ * Sends LLM connect latencies for initial join flow.
7087
+ * @param {RegisterAndConnectTiming} timings
7088
+ * @param {any} [error]
7089
+ * @returns {void}
7090
+ */
7091
+ private sendLLMConnectMetric(timings: RegisterAndConnectTiming, error?: any) {
7092
+ // @ts-ignore
7093
+ const llmWebsocketUrl = this.webex.internal.llm.getWebSocketUrl?.() || undefined;
7094
+ const {clientLLMDatachannelResponseTime = 0, clientLLMWebSocketConnectTime} = timings || {};
7095
+
7096
+ const llmLatency: any = {
7097
+ clientLLMDatachannelResponseTime,
7098
+ };
7099
+
7100
+ if (clientLLMWebSocketConnectTime !== undefined) {
7101
+ llmLatency.clientLLMWebSocketConnectTime = clientLLMWebSocketConnectTime;
7102
+ }
7103
+
7104
+ const payload: any = {
7105
+ identifiers: {
7106
+ llmWebsocketUrl,
7107
+ },
7108
+ llmLatency,
7109
+ };
7110
+
7111
+ const options: any = {
7112
+ meetingId: this.id,
7113
+ ...(error && {rawError: error}),
7114
+ };
7115
+
7116
+ const metricEvent = {
7117
+ name: 'client.llm.connect.response',
7118
+ payload,
7119
+ options,
7120
+ };
7121
+
7122
+ // @ts-ignore
7123
+ this.webex.internal.newMetrics.submitClientEvent(metricEvent);
7124
+ }
7125
+
6485
7126
  /**
6486
7127
  * Use phone for meeting audio
6487
7128
  * @param {String} phoneNumber If provided, it will dial-out using this number. If not provided, dial-in will be used
@@ -6909,16 +7550,32 @@ export default class Meeting extends StatelessWebexPlugin {
6909
7550
  // @ts-ignore
6910
7551
  const cdl = this.webex.internal.newMetrics.callDiagnosticLatencies;
6911
7552
 
7553
+ // Compute the offer->answer latency from when the local SDP offer was generated up to now,
7554
+ // rather than from the stored remote-sdp-received timestamp. That stored timestamp uses
7555
+ // saveFirstTimestampOnly, so if waitForRemoteSDPAnswer() already timed out and submitted a
7556
+ // remote-sdp-received event, the stored value would be pinned to the timeout time and would
7557
+ // under-report an answer that arrives late. This handler fires exactly when the answer is
7558
+ // processed, so Date.now() is the accurate "received" time.
7559
+ // (submitClientEvent below still records the remote-sdp-received timestamp used by the CA
7560
+ // join-time metric, so we don't need to save it here.)
7561
+ const localSdpGeneratedTimestamp = cdl.latencyTimestamps.get(
7562
+ 'client.media-engine.local-sdp-generated'
7563
+ );
7564
+ const localSDPGenRemoteSDPRecv =
7565
+ localSdpGeneratedTimestamp !== undefined
7566
+ ? Date.now() - localSdpGeneratedTimestamp
7567
+ : undefined;
7568
+
6912
7569
  // @ts-ignore
6913
7570
  this.webex.internal.newMetrics.submitClientEvent({
6914
7571
  name: 'client.media-engine.remote-sdp-received',
7572
+ payload: {
7573
+ eventData: {
7574
+ localSDPGenRemoteSDPRecv,
7575
+ },
7576
+ },
6915
7577
  options: {meetingId: this.id},
6916
7578
  });
6917
- Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.ROAP_OFFER_TO_ANSWER_LATENCY, {
6918
- correlation_id: this.correlationId,
6919
- latency: cdl.getLocalSDPGenRemoteSDPRecv(),
6920
- meetingId: this.id,
6921
- });
6922
7579
 
6923
7580
  if (this.deferSDPAnswer) {
6924
7581
  this.deferSDPAnswer.resolve();
@@ -7504,23 +8161,108 @@ export default class Meeting extends StatelessWebexPlugin {
7504
8161
  }
7505
8162
  }
7506
8163
  });
8164
+ this.statsAnalyzer.on(StatsAnalyzerEventNames.STATS_UPDATE, (data) => {
8165
+ // Extract srtpCipher from transport stats
8166
+ let srtpCipher: string | undefined;
8167
+ for (const stats of data.stats.values()) {
8168
+ if (stats.type === 'transport' && stats.srtpCipher) {
8169
+ srtpCipher = stats.srtpCipher as string;
8170
+ break;
8171
+ }
8172
+ }
8173
+
8174
+ // Only emit event if srtpCipher has changed
8175
+ if (srtpCipher && srtpCipher !== this.mediaProperties.srtpCipher) {
8176
+ LoggerProxy.logger.info(
8177
+ `Meeting:index#setupStatsAnalyzerEventHandlers --> SRTP cipher changed from ${this.mediaProperties.srtpCipher} to ${srtpCipher}`
8178
+ );
8179
+ this.mediaProperties.srtpCipher = srtpCipher;
8180
+ Trigger.trigger(
8181
+ this,
8182
+ {
8183
+ file: 'meeting/index',
8184
+ function: 'setupStatsAnalyzerEventHandlers',
8185
+ },
8186
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
8187
+ {srtpCipher}
8188
+ );
8189
+ }
8190
+ });
7507
8191
  };
7508
8192
 
7509
8193
  getMediaConnectionDebugId() {
7510
8194
  return `MC-${this.id.substring(0, 4)}`;
7511
8195
  }
7512
8196
 
8197
+ /**
8198
+ * Checks if the error indicates that Locus dropped us from the meeting,
8199
+ * either directly on the error or wrapped inside an AddMediaFailed cause.
8200
+ * This method is meant to be called only with errors thrown by Meeting.addMediaInternal()
8201
+ *
8202
+ * @param {Error} error
8203
+ * @returns {boolean}
8204
+ */
8205
+ private isErrorMeaningLocusDroppedUs(error: Error | undefined): boolean {
8206
+ const statusCode = (error as any)?.statusCode;
8207
+ const causeStatusCode = (error as any)?.cause?.statusCode;
8208
+
8209
+ return (
8210
+ statusCode === 409 || statusCode === 403 || causeStatusCode === 409 || causeStatusCode === 403
8211
+ );
8212
+ }
8213
+
8214
+ private isLocusUserFullError(error: Error | undefined): boolean {
8215
+ return (error as any)?.error?.body?.errorCode === LocusErrorCodes.LOCUS_USER_FULL;
8216
+ }
8217
+
8218
+ /**
8219
+ * Determines if the next media attempt should use only TURN-TLS (iceTransportPolicy='relay').
8220
+ * We do this in the hope that it will minimize the chance of Homer sending DTLS packets on a wrong
8221
+ * transport (as there will be only 1 transport) and dealing with firewalls that let STUN packets through, but block
8222
+ * other UDP traffic.
8223
+ *
8224
+ * For clients landing on video mesh nodes (VMN), reachability might still have successful TLS (to public nodes)
8225
+ * but TURN discovery will result in empty TURN urls array and iceTransportPolicy='relay' will still be overriden to undefined,
8226
+ * see the code in establishMediaConnection()
8227
+ *
8228
+ * @param {Error} prevError - The error from the previous addMedia attempt
8229
+ * @returns {Promise<boolean>}
8230
+ */
8231
+ private async shouldRetryMediaWithOnlyTurnTLS(prevError: Error | undefined): Promise<boolean> {
8232
+ if (
8233
+ this.isMultistream &&
8234
+ prevError instanceof AddMediaFailed &&
8235
+ prevError.isDtlsHandshakeFailure &&
8236
+ prevError.connectionType === 'UDP'
8237
+ ) {
8238
+ const hasTlsReachability =
8239
+ // @ts-ignore
8240
+ await this.webex.meetings.reachability.isAnyClusterReachableViaProtocol('xtls');
8241
+
8242
+ if (hasTlsReachability) {
8243
+ LoggerProxy.logger.info(
8244
+ 'Meeting:index#shouldRetryMediaWithOnlyTurnTLS --> previous attempt failed due to DTLS handshake failure over UDP and TLS reachability is available'
8245
+ );
8246
+
8247
+ return true;
8248
+ }
8249
+ }
8250
+
8251
+ return false;
8252
+ }
8253
+
7513
8254
  /**
7514
8255
  * Creates a webrtc media connection and publishes streams to it
7515
8256
  *
7516
8257
  * @param {Object} turnServerInfo TURN server information
7517
8258
  * @param {BundlePolicy} [bundlePolicy] Bundle policy settings
7518
- * @param {AddMediaOptions} [options] Options for enabling/disabling audio/video
8259
+ * @param {RTCIceTransportPolicy} [iceTransportPolicy] ICE transport policy override
7519
8260
  * @returns {RoapMediaConnection | MultistreamRoapMediaConnection}
7520
8261
  */
7521
8262
  private async createMediaConnection(
7522
8263
  turnServerInfo?: TurnServerInfo,
7523
- bundlePolicy?: BundlePolicy
8264
+ bundlePolicy?: BundlePolicy,
8265
+ iceTransportPolicy?: RTCIceTransportPolicy
7524
8266
  ) {
7525
8267
  this.rtcMetrics = this.isMultistream
7526
8268
  ? // @ts-ignore
@@ -7544,12 +8286,15 @@ export default class Meeting extends StatelessWebexPlugin {
7544
8286
  enableExtmap: this.config.enableExtmap,
7545
8287
  turnServerInfo,
7546
8288
  bundlePolicy,
8289
+ iceTransportPolicy,
7547
8290
  // @ts-ignore - config coming from registerPlugin
7548
8291
  iceCandidatesTimeout: this.config.iceCandidatesGatheringTimeout,
7549
8292
  // @ts-ignore - config coming from registerPlugin
7550
8293
  disableAudioMainDtx: this.config.experimental.disableAudioMainDtx,
7551
8294
  // @ts-ignore - config coming from registerPlugin
7552
8295
  enableAudioTwcc: this.config.enableAudioTwccForMultistream,
8296
+ // @ts-ignore - config coming from registerPlugin
8297
+ enableAv1SlidesSupport: this.config.enableAv1SlidesSupport,
7553
8298
  stopIceGatheringAfterFirstRelayCandidate:
7554
8299
  // @ts-ignore - config coming from registerPlugin
7555
8300
  this.config.stopIceGatheringAfterFirstRelayCandidate,
@@ -7569,6 +8314,7 @@ export default class Meeting extends StatelessWebexPlugin {
7569
8314
  this.mediaProperties.mediaDirection.receiveShare,
7570
8315
  ];
7571
8316
 
8317
+ this.sendSlotManager.reset();
7572
8318
  this.sendSlotManager.createSlot(mc, MediaType.VideoMain, videoEnabled);
7573
8319
  this.sendSlotManager.createSlot(mc, MediaType.AudioMain, audioEnabled);
7574
8320
  this.sendSlotManager.createSlot(mc, MediaType.VideoSlides, shareEnabled);
@@ -7668,7 +8414,7 @@ export default class Meeting extends StatelessWebexPlugin {
7668
8414
  try {
7669
8415
  await this.mediaProperties.waitForMediaConnectionConnected(this.correlationId);
7670
8416
  } catch (error) {
7671
- const {iceConnected} = error;
8417
+ const {iceConnected} = error as MediaConnectionAwaiterFailureResult;
7672
8418
 
7673
8419
  if (!this.hasMediaConnectionConnectedAtLeastOnce) {
7674
8420
  // Only send CA event for join flow if we haven't successfully connected media yet
@@ -7708,13 +8454,12 @@ export default class Meeting extends StatelessWebexPlugin {
7708
8454
  });
7709
8455
  }
7710
8456
 
7711
- const timedOutError = new Error(
7712
- `Timed out waiting for media connection to be connected, correlationId=${this.correlationId}`
8457
+ throw new MediaConnectionTimedOutError(
8458
+ `Timed out waiting for media connection to be connected, correlationId=${this.correlationId}`,
8459
+ iceConnected,
8460
+ // keep reference to the original rejected result (which is the object the SDK reports to CA as rawError above)
8461
+ error
7713
8462
  );
7714
-
7715
- timedOutError.cause = error;
7716
-
7717
- throw timedOutError;
7718
8463
  }
7719
8464
  }
7720
8465
 
@@ -7760,12 +8505,12 @@ export default class Meeting extends StatelessWebexPlugin {
7760
8505
  return !member.isSelf && !member.isPairedWithSelf && !member.isAudioMuted;
7761
8506
  });
7762
8507
 
7763
- if (atLeastOneUnmutedOtherMember) {
7764
- this.mediaProperties.sendMediaIssueMetric(
7765
- 'inbound_audio',
7766
- data.issueSubType,
7767
- this.correlationId
7768
- );
8508
+ // we also ignore any issues while we're waiting in the lobby, as we're not receiving any audio yet
8509
+ if (atLeastOneUnmutedOtherMember && !this.isUserUnadmitted) {
8510
+ this.mediaProperties.sendMediaIssueMetric('inbound_audio', data.issueSubType, {
8511
+ correlationId: this.correlationId,
8512
+ isMultistream: this.isMultistream,
8513
+ });
7769
8514
 
7770
8515
  Trigger.trigger(
7771
8516
  this,
@@ -7927,7 +8672,18 @@ export default class Meeting extends StatelessWebexPlugin {
7927
8672
  error
7928
8673
  );
7929
8674
 
7930
- throw new AddMediaFailed(error);
8675
+ const {connectionType, selectedCandidatePairChanges, numTransports} =
8676
+ await this.mediaProperties.getCurrentConnectionInfo();
8677
+
8678
+ const iceConnected = error instanceof MediaConnectionTimedOutError && error.iceConnected;
8679
+
8680
+ throw new AddMediaFailed({
8681
+ cause: error,
8682
+ connectionType,
8683
+ selectedCandidatePairChanges,
8684
+ numTransports,
8685
+ iceConnected,
8686
+ });
7931
8687
  }
7932
8688
  }
7933
8689
 
@@ -8002,7 +8758,21 @@ export default class Meeting extends StatelessWebexPlugin {
8002
8758
  ({turnServerInfo} = await this.doTurnDiscovery(isReconnecting, isForced));
8003
8759
  }
8004
8760
 
8005
- const mc = await this.createMediaConnection(turnServerInfo, bundlePolicy);
8761
+ if (
8762
+ (!turnServerInfo || !turnServerInfo.urls?.length) &&
8763
+ this.addMediaData.iceTransportPolicy === 'relay'
8764
+ ) {
8765
+ LoggerProxy.logger.info(
8766
+ `${LOG_HEADER} cannot do iceTransportPolicy=relay, because there is no turn server info available`
8767
+ );
8768
+ // drop the forced relay policy and use the default, because we don't have a TURN server
8769
+ this.addMediaData.iceTransportPolicy = undefined;
8770
+ }
8771
+ const mediaConnection = await this.createMediaConnection(
8772
+ turnServerInfo,
8773
+ bundlePolicy,
8774
+ this.addMediaData.iceTransportPolicy
8775
+ );
8006
8776
 
8007
8777
  LoggerProxy.logger.info(
8008
8778
  `${LOG_HEADER} media connection created this.isMultistream=${this.isMultistream}`
@@ -8039,7 +8809,7 @@ export default class Meeting extends StatelessWebexPlugin {
8039
8809
  await this.remoteMediaManager.start();
8040
8810
  }
8041
8811
 
8042
- await mc.initiateOffer();
8812
+ await mediaConnection.initiateOffer();
8043
8813
 
8044
8814
  await this.waitForRemoteSDPAnswer();
8045
8815
 
@@ -8107,6 +8877,9 @@ export default class Meeting extends StatelessWebexPlugin {
8107
8877
 
8108
8878
  this.isMultistream = false;
8109
8879
 
8880
+ // reset iceTransportPolicy, because it's only applied for multistream media connections
8881
+ this.addMediaData.iceTransportPolicy = undefined;
8882
+
8110
8883
  if (this.mediaProperties.webrtcMediaConnection) {
8111
8884
  // close peer connection, but don't reset mute state information, because we will want to use it on the retry
8112
8885
  this.closePeerConnections(false);
@@ -8187,6 +8960,8 @@ export default class Meeting extends StatelessWebexPlugin {
8187
8960
  regionCode: this.webex.meetings.geoHintInfo?.regionCode,
8188
8961
  },
8189
8962
  preferTranscoding: !this.isMultistream,
8963
+ getCurrentSelfUrl: () => this.selfUrl,
8964
+ waitForSelfUrlChange: () => this.waitForSelfUrlChange(),
8190
8965
  },
8191
8966
  {
8192
8967
  // @ts-ignore
@@ -8195,6 +8970,41 @@ export default class Meeting extends StatelessWebexPlugin {
8195
8970
  );
8196
8971
  }
8197
8972
 
8973
+ /**
8974
+ * Waits for LocusInfo to update meeting.selfUrl, with a timeout fallback.
8975
+ * @returns {Promise<void>}
8976
+ * @private
8977
+ * @memberof Meeting
8978
+ */
8979
+ private waitForSelfUrlChange(): Promise<void> {
8980
+ if (this.joinWithMediaRetryInfo.retryCount > 0) {
8981
+ /* During joinWithMedia() retries we can get 403/409 from Locus and it doesn't mean
8982
+ * that the selfUrl will change, it is usually caused by Locus dropping us as a result of
8983
+ * media connection failure during joinWithMedia's earlier media connection attempt,
8984
+ * so we don't want to wait for selfUrl change as this would only slow down the join process. */
8985
+ LoggerProxy.logger.info(
8986
+ 'Meeting:index#waitForSelfUrlChange --> joinWithMedia retry in progress, will not wait for selfUrl change'
8987
+ );
8988
+
8989
+ return Promise.resolve();
8990
+ }
8991
+
8992
+ if (!this.promisesWaitingForPropUpdate.selfUrl) {
8993
+ const pendingSelfUrlUpdate = new Defer();
8994
+
8995
+ this.promisesWaitingForPropUpdate.selfUrl = pendingSelfUrlUpdate;
8996
+
8997
+ setTimeout(() => {
8998
+ if (this.promisesWaitingForPropUpdate.selfUrl === pendingSelfUrlUpdate) {
8999
+ delete this.promisesWaitingForPropUpdate.selfUrl;
9000
+ pendingSelfUrlUpdate.resolve();
9001
+ }
9002
+ }, 5000);
9003
+ }
9004
+
9005
+ return this.promisesWaitingForPropUpdate.selfUrl.promise;
9006
+ }
9007
+
8198
9008
  /**
8199
9009
  * Creates a media connection to the server. Media connection is required for sending or receiving any audio/video.
8200
9010
  *
@@ -8206,8 +9016,9 @@ export default class Meeting extends StatelessWebexPlugin {
8206
9016
  addMedia(options: AddMediaOptions = {}): Promise<void> {
8207
9017
  return this.addMediaInternal(
8208
9018
  () => (this.turnServerUsed ? 'JOIN_MEETING_FINAL' : 'JOIN_MEETING_RETRY'),
8209
- undefined,
8210
9019
  false,
9020
+ undefined /* turnServerInfo - it will be fetched via doTurnDiscovery() */,
9021
+ undefined /* iceTransportPolicy - we're relying on the default value */,
8211
9022
  options
8212
9023
  );
8213
9024
  }
@@ -8216,8 +9027,9 @@ export default class Meeting extends StatelessWebexPlugin {
8216
9027
  * Internal version of addMedia() with some more arguments for finer control of its behavior
8217
9028
  *
8218
9029
  * @param {Function} icePhaseCallback - callback to determine the icePhase for CA "client.ice.end" failure events
8219
- * @param {TurnServerInfo} turnServerInfo - TURN server information
8220
9030
  * @param {boolean} forceTurnDiscovery - if true, TURN discovery will be done
9031
+ * @param {TurnServerInfo} turnServerInfo - TURN server information
9032
+ * @param {RTCIceTransportPolicy} [iceTransportPolicy] - ICE transport policy override
8221
9033
  * @param {AddMediaOptions} options - same as options of the public addMedia() method
8222
9034
  * @returns {Promise<void>}
8223
9035
  * @protected
@@ -8225,21 +9037,30 @@ export default class Meeting extends StatelessWebexPlugin {
8225
9037
  */
8226
9038
  protected async addMediaInternal(
8227
9039
  icePhaseCallback: () => string,
8228
- turnServerInfo: TurnServerInfo,
8229
- forceTurnDiscovery,
9040
+ forceTurnDiscovery: boolean,
9041
+ turnServerInfo?: TurnServerInfo,
9042
+ iceTransportPolicy?: RTCIceTransportPolicy,
8230
9043
  options: AddMediaOptions = {}
8231
9044
  ): Promise<void> {
8232
9045
  this.addMediaData.retriedWithTurnServer = false;
8233
9046
  this.addMediaData.icePhaseCallback = icePhaseCallback;
9047
+ this.addMediaData.iceTransportPolicy = iceTransportPolicy;
8234
9048
 
8235
9049
  this.hasMediaConnectionConnectedAtLeastOnce = false;
8236
9050
  const LOG_HEADER = 'Meeting:index#addMedia -->';
9051
+ const optionsForLogging = {
9052
+ ...options,
9053
+ remoteMediaManagerConfig: getRemoteMediaManagerConfigForLogging(
9054
+ options.remoteMediaManagerConfig
9055
+ ),
9056
+ };
9057
+
8237
9058
  LoggerProxy.logger.info(
8238
9059
  `${LOG_HEADER} called with: options=${JSON.stringify(
8239
- options
9060
+ optionsForLogging
8240
9061
  )}, turnServerInfo=${JSON.stringify(
8241
9062
  turnServerInfo
8242
- )}, forceTurnDiscovery=${forceTurnDiscovery}`
9063
+ )}, forceTurnDiscovery=${forceTurnDiscovery}, iceTransportPolicy=${iceTransportPolicy}`
8243
9064
  );
8244
9065
 
8245
9066
  if (options.allowMediaInLobby !== true && this.meetingState !== FULL_STATE.ACTIVE) {
@@ -8353,12 +9174,7 @@ export default class Meeting extends StatelessWebexPlugin {
8353
9174
 
8354
9175
  // Establish new media connection with forced TURN discovery
8355
9176
  // 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
8356
- await this.establishMediaConnection(
8357
- remoteMediaManagerConfig,
8358
- bundlePolicy,
8359
- true,
8360
- undefined
8361
- );
9177
+ await this.establishMediaConnection(remoteMediaManagerConfig, bundlePolicy, true);
8362
9178
  } else {
8363
9179
  throw error;
8364
9180
  }
@@ -8387,7 +9203,8 @@ export default class Meeting extends StatelessWebexPlugin {
8387
9203
  numTransports,
8388
9204
  isMultistream: this.isMultistream,
8389
9205
  retriedWithTurnServer: this.addMediaData.retriedWithTurnServer,
8390
- isJoinWithMediaRetry: this.joinWithMediaRetryInfo.isRetry,
9206
+ isJoinWithMediaRetry: this.joinWithMediaRetryInfo.retryCount > 0,
9207
+ iceTransportPolicy: this.addMediaData.iceTransportPolicy || 'all',
8391
9208
  ...reachabilityMetrics,
8392
9209
  ...iceCandidateErrors,
8393
9210
  iceCandidatesCount: this.iceCandidatesCount,
@@ -8409,14 +9226,16 @@ export default class Meeting extends StatelessWebexPlugin {
8409
9226
  // We can log ReceiveSlot SSRCs only after the SDP exchange, so doing it here:
8410
9227
  this.remoteMediaManager?.logAllReceiveSlots();
8411
9228
  this.startPeriodicLogUpload();
8412
- } catch (error) {
9229
+ } catch (error: any) {
8413
9230
  LoggerProxy.logger.error(`${LOG_HEADER} failed to establish media connection: `, error);
8414
9231
 
8415
9232
  // @ts-ignore
8416
9233
  const reachabilityMetrics = await this.getMediaReachabilityMetricFields();
8417
9234
 
8418
- const {selectedCandidatePairChanges, numTransports} =
8419
- await this.mediaProperties.getCurrentConnectionInfo();
9235
+ const {connectionType, selectedCandidatePairChanges, numTransports} =
9236
+ error instanceof AddMediaFailed
9237
+ ? error
9238
+ : await this.mediaProperties.getCurrentConnectionInfo();
8420
9239
 
8421
9240
  const iceCandidateErrors = Object.fromEntries(this.iceCandidateErrors);
8422
9241
 
@@ -8432,7 +9251,8 @@ export default class Meeting extends StatelessWebexPlugin {
8432
9251
  turnServerUsed: this.turnServerUsed,
8433
9252
  retriedWithTurnServer: this.addMediaData.retriedWithTurnServer,
8434
9253
  isMultistream: this.isMultistream,
8435
- isJoinWithMediaRetry: this.joinWithMediaRetryInfo.isRetry,
9254
+ isJoinWithMediaRetry: this.joinWithMediaRetryInfo.retryCount > 0,
9255
+ iceTransportPolicy: this.addMediaData.iceTransportPolicy || 'all',
8436
9256
  signalingState:
8437
9257
  this.mediaProperties.webrtcMediaConnection?.multistreamConnection?.pc?.pc
8438
9258
  ?.signalingState ||
@@ -8448,6 +9268,7 @@ export default class Meeting extends StatelessWebexPlugin {
8448
9268
  ?.iceConnectionState ||
8449
9269
  this.mediaProperties.webrtcMediaConnection?.mediaConnection?.pc?.iceConnectionState ||
8450
9270
  'unknown',
9271
+ connectionType,
8451
9272
  ...reachabilityMetrics,
8452
9273
  ...iceCandidateErrors,
8453
9274
  iceCandidatesCount: this.iceCandidatesCount,
@@ -8796,6 +9617,7 @@ export default class Meeting extends StatelessWebexPlugin {
8796
9617
  options: {meetingId: this.id},
8797
9618
  });
8798
9619
  LoggerProxy.logger.log('Meeting:index#leave --> Leaving a meeting');
9620
+ this.stopListeningForMeetingEvents();
8799
9621
 
8800
9622
  return MeetingUtil.leaveMeeting(this, options)
8801
9623
  .then(async (leave) => {
@@ -9661,6 +10483,8 @@ export default class Meeting extends StatelessWebexPlugin {
9661
10483
  locus_id: this.locusId,
9662
10484
  });
9663
10485
 
10486
+ this.stopListeningForMeetingEvents();
10487
+
9664
10488
  return MeetingUtil.endMeetingForAll(this)
9665
10489
  .then(async (end) => {
9666
10490
  this.meetingFiniteStateMachine.end();
@@ -9722,12 +10546,15 @@ export default class Meeting extends StatelessWebexPlugin {
9722
10546
  }
9723
10547
  this.queuedMediaUpdates = [];
9724
10548
 
9725
- this.stopTranscription();
9726
- this.transcription = undefined;
9727
-
9728
- this.annotation.deregisterEvents();
9729
-
10549
+ // Listener teardown (transcription, annotation, llm/mercury) runs in
10550
+ // stopListeningForMeetingEvents() before /leave and /end so events
10551
+ // received mid-teardown do not trigger Locus syncs. Calling it here
10552
+ // again would double-emit MEETING_STOPPED_RECEIVING_TRANSCRIPTION
10553
+ // because stopTranscription() always fires its trigger.
10554
+ //
10555
+ // Ownership-aware token clear is encapsulated inside clearDataChannelToken().
9730
10556
  this.clearDataChannelToken();
10557
+
9731
10558
  await this.cleanupLLMConneciton({throwOnError: false});
9732
10559
  };
9733
10560
 
@@ -9804,15 +10631,12 @@ export default class Meeting extends StatelessWebexPlugin {
9804
10631
  * @public
9805
10632
  * @memberof Meeting
9806
10633
  */
9807
- public sendReaction(reactionType: ReactionServerType, skinToneType?: SkinToneType) {
10634
+ public sendReaction(reactionType: string, skinToneType?: SkinToneType) {
9808
10635
  const reactionChannelUrl = this.locusInfo?.controls?.reactions?.reactionChannelUrl as string;
9809
10636
  const participantId = this.members.selfId;
9810
10637
 
9811
- const reactionData = Reactions[reactionType];
10638
+ const reactionData = Reactions[reactionType] || {type: reactionType};
9812
10639
 
9813
- if (!reactionData) {
9814
- return Promise.reject(new Error(`${reactionType} is not a valid reaction.`));
9815
- }
9816
10640
  const skinToneData = SkinTones[skinToneType] || SkinTones.normal;
9817
10641
  const reaction: Reaction = {
9818
10642
  ...reactionData,