@webex/plugin-meetings 3.12.0-next.15 → 3.12.0-next.151

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