@webex/plugin-meetings 3.12.0-next.16 → 3.12.0-next.160

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