@webex/plugin-meetings 3.12.0-task-refactor.1 → 3.12.0-webex-services-ready.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. package/AGENTS.md +9 -0
  2. package/dist/aiEnableRequest/index.js +197 -0
  3. package/dist/aiEnableRequest/index.js.map +1 -0
  4. package/dist/aiEnableRequest/utils.js +36 -0
  5. package/dist/aiEnableRequest/utils.js.map +1 -0
  6. package/dist/annotation/index.js +14 -5
  7. package/dist/annotation/index.js.map +1 -1
  8. package/dist/breakouts/breakout.js +8 -3
  9. package/dist/breakouts/breakout.js.map +1 -1
  10. package/dist/breakouts/index.js +26 -2
  11. package/dist/breakouts/index.js.map +1 -1
  12. package/dist/common/errors/webex-errors.js +49 -5
  13. package/dist/common/errors/webex-errors.js.map +1 -1
  14. package/dist/config.js +9 -3
  15. package/dist/config.js.map +1 -1
  16. package/dist/constants.js +59 -10
  17. package/dist/constants.js.map +1 -1
  18. package/dist/controls-options-manager/constants.js +11 -1
  19. package/dist/controls-options-manager/constants.js.map +1 -1
  20. package/dist/controls-options-manager/index.js +67 -29
  21. package/dist/controls-options-manager/index.js.map +1 -1
  22. package/dist/controls-options-manager/util.js +91 -0
  23. package/dist/controls-options-manager/util.js.map +1 -1
  24. package/dist/hashTree/constants.js +34 -0
  25. package/dist/hashTree/constants.js.map +1 -0
  26. package/dist/hashTree/hashTree.js +533 -0
  27. package/dist/hashTree/hashTree.js.map +1 -0
  28. package/dist/hashTree/hashTreeParser.js +2068 -36
  29. package/dist/hashTree/hashTreeParser.js.map +1 -1
  30. package/dist/hashTree/types.js +13 -3
  31. package/dist/hashTree/types.js.map +1 -1
  32. package/dist/hashTree/utils.js +111 -0
  33. package/dist/hashTree/utils.js.map +1 -0
  34. package/dist/index.js +18 -2
  35. package/dist/index.js.map +1 -1
  36. package/dist/interceptors/constant.js +12 -0
  37. package/dist/interceptors/constant.js.map +1 -0
  38. package/dist/interceptors/dataChannelAuthToken.js +350 -0
  39. package/dist/interceptors/dataChannelAuthToken.js.map +1 -0
  40. package/dist/interceptors/index.js +7 -0
  41. package/dist/interceptors/index.js.map +1 -1
  42. package/dist/interceptors/locusRetry.js +23 -8
  43. package/dist/interceptors/locusRetry.js.map +1 -1
  44. package/dist/interceptors/locusRouteToken.js +27 -5
  45. package/dist/interceptors/locusRouteToken.js.map +1 -1
  46. package/dist/interceptors/utils.js +27 -0
  47. package/dist/interceptors/utils.js.map +1 -0
  48. package/dist/interpretation/index.js +11 -2
  49. package/dist/interpretation/index.js.map +1 -1
  50. package/dist/interpretation/interpretation.types.js +7 -0
  51. package/dist/interpretation/interpretation.types.js.map +1 -0
  52. package/dist/interpretation/siLanguage.js +1 -1
  53. package/dist/locus-info/controlsUtils.js +11 -4
  54. package/dist/locus-info/controlsUtils.js.map +1 -1
  55. package/dist/locus-info/index.js +896 -277
  56. package/dist/locus-info/index.js.map +1 -1
  57. package/dist/locus-info/infoUtils.js +36 -5
  58. package/dist/locus-info/infoUtils.js.map +1 -1
  59. package/dist/locus-info/selfUtils.js +1 -0
  60. package/dist/locus-info/selfUtils.js.map +1 -1
  61. package/dist/locus-info/types.js +19 -0
  62. package/dist/locus-info/types.js.map +1 -1
  63. package/dist/media/MediaConnectionAwaiter.js +72 -3
  64. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  65. package/dist/media/index.js +8 -2
  66. package/dist/media/index.js.map +1 -1
  67. package/dist/media/properties.js +5 -2
  68. package/dist/media/properties.js.map +1 -1
  69. package/dist/meeting/in-meeting-actions.js +11 -1
  70. package/dist/meeting/in-meeting-actions.js.map +1 -1
  71. package/dist/meeting/index.js +2075 -1096
  72. package/dist/meeting/index.js.map +1 -1
  73. package/dist/meeting/locusMediaRequest.js +229 -82
  74. package/dist/meeting/locusMediaRequest.js.map +1 -1
  75. package/dist/meeting/muteState.js +10 -1
  76. package/dist/meeting/muteState.js.map +1 -1
  77. package/dist/meeting/request.js +55 -2
  78. package/dist/meeting/request.js.map +1 -1
  79. package/dist/meeting/request.type.js.map +1 -1
  80. package/dist/meeting/util.js +168 -5
  81. package/dist/meeting/util.js.map +1 -1
  82. package/dist/meeting-info/meeting-info-v2.js +2 -2
  83. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  84. package/dist/meetings/index.js +369 -173
  85. package/dist/meetings/index.js.map +1 -1
  86. package/dist/meetings/meetings.types.js +6 -1
  87. package/dist/meetings/meetings.types.js.map +1 -1
  88. package/dist/meetings/request.js +39 -0
  89. package/dist/meetings/request.js.map +1 -1
  90. package/dist/meetings/util.js +127 -25
  91. package/dist/meetings/util.js.map +1 -1
  92. package/dist/member/index.js +20 -0
  93. package/dist/member/index.js.map +1 -1
  94. package/dist/member/types.js.map +1 -1
  95. package/dist/member/util.js +40 -0
  96. package/dist/member/util.js.map +1 -1
  97. package/dist/members/index.js +101 -43
  98. package/dist/members/index.js.map +1 -1
  99. package/dist/members/util.js +8 -1
  100. package/dist/members/util.js.map +1 -1
  101. package/dist/metrics/constants.js +11 -1
  102. package/dist/metrics/constants.js.map +1 -1
  103. package/dist/multistream/codec/constants.js +63 -0
  104. package/dist/multistream/codec/constants.js.map +1 -0
  105. package/dist/multistream/mediaRequestManager.js +64 -68
  106. package/dist/multistream/mediaRequestManager.js.map +1 -1
  107. package/dist/multistream/receiveSlot.js +9 -0
  108. package/dist/multistream/receiveSlot.js.map +1 -1
  109. package/dist/multistream/remoteMediaManager.js +11 -0
  110. package/dist/multistream/remoteMediaManager.js.map +1 -1
  111. package/dist/multistream/sendSlotManager.js +116 -2
  112. package/dist/multistream/sendSlotManager.js.map +1 -1
  113. package/dist/reachability/clusterReachability.js +171 -18
  114. package/dist/reachability/clusterReachability.js.map +1 -1
  115. package/dist/reachability/index.js +142 -94
  116. package/dist/reachability/index.js.map +1 -1
  117. package/dist/reachability/reachability.types.js +2 -0
  118. package/dist/reachability/reachability.types.js.map +1 -1
  119. package/dist/reachability/reachabilityPeerConnection.js +1 -1
  120. package/dist/reachability/reachabilityPeerConnection.js.map +1 -1
  121. package/dist/reachability/util.js +45 -0
  122. package/dist/reachability/util.js.map +1 -1
  123. package/dist/reactions/reactions.type.js.map +1 -1
  124. package/dist/reconnection-manager/index.js +0 -1
  125. package/dist/reconnection-manager/index.js.map +1 -1
  126. package/dist/recording-controller/index.js +1 -3
  127. package/dist/recording-controller/index.js.map +1 -1
  128. package/dist/types/aiEnableRequest/index.d.ts +5 -0
  129. package/dist/types/aiEnableRequest/utils.d.ts +2 -0
  130. package/dist/types/common/browser-detection.d.ts +1 -0
  131. package/dist/types/common/errors/webex-errors.d.ts +32 -2
  132. package/dist/types/common/events/events-scope.d.ts +1 -0
  133. package/dist/types/common/events/events.d.ts +1 -0
  134. package/dist/types/config.d.ts +7 -2
  135. package/dist/types/constants.d.ts +35 -1
  136. package/dist/types/controls-options-manager/constants.d.ts +6 -1
  137. package/dist/types/controls-options-manager/index.d.ts +16 -0
  138. package/dist/types/hashTree/constants.d.ts +11 -0
  139. package/dist/types/hashTree/hashTree.d.ts +136 -0
  140. package/dist/types/hashTree/hashTreeParser.d.ts +392 -14
  141. package/dist/types/hashTree/types.d.ts +20 -0
  142. package/dist/types/hashTree/utils.d.ts +40 -0
  143. package/dist/types/index.d.ts +4 -0
  144. package/dist/types/interceptors/constant.d.ts +5 -0
  145. package/dist/types/interceptors/dataChannelAuthToken.d.ts +43 -0
  146. package/dist/types/interceptors/index.d.ts +2 -1
  147. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  148. package/dist/types/interceptors/locusRouteToken.d.ts +2 -0
  149. package/dist/types/interceptors/utils.d.ts +1 -0
  150. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  151. package/dist/types/locus-info/index.d.ts +116 -51
  152. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  153. package/dist/types/locus-info/types.d.ts +48 -12
  154. package/dist/types/media/MediaConnectionAwaiter.d.ts +20 -2
  155. package/dist/types/media/properties.d.ts +3 -1
  156. package/dist/types/meeting/in-meeting-actions.d.ts +10 -0
  157. package/dist/types/meeting/index.d.ts +196 -15
  158. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  159. package/dist/types/meeting/request.d.ts +17 -1
  160. package/dist/types/meeting/request.type.d.ts +5 -0
  161. package/dist/types/meeting/util.d.ts +40 -0
  162. package/dist/types/meeting-info/util.d.ts +1 -0
  163. package/dist/types/meeting-info/utilv2.d.ts +1 -0
  164. package/dist/types/meetings/index.d.ts +34 -20
  165. package/dist/types/meetings/meetings.types.d.ts +15 -0
  166. package/dist/types/meetings/request.d.ts +14 -0
  167. package/dist/types/member/index.d.ts +2 -0
  168. package/dist/types/member/types.d.ts +5 -4
  169. package/dist/types/member/util.d.ts +14 -0
  170. package/dist/types/members/index.d.ts +15 -2
  171. package/dist/types/members/util.d.ts +1 -5
  172. package/dist/types/metrics/constants.d.ts +10 -0
  173. package/dist/types/multistream/codec/constants.d.ts +7 -0
  174. package/dist/types/multistream/mediaRequestManager.d.ts +20 -26
  175. package/dist/types/multistream/sendSlotManager.d.ts +23 -1
  176. package/dist/types/reachability/clusterReachability.d.ts +33 -6
  177. package/dist/types/reachability/index.d.ts +10 -3
  178. package/dist/types/reachability/reachability.types.d.ts +7 -0
  179. package/dist/types/reachability/util.d.ts +17 -0
  180. package/dist/types/reactions/reactions.type.d.ts +4 -0
  181. package/dist/types/recording-controller/util.d.ts +5 -5
  182. package/dist/types/roap/index.d.ts +1 -1
  183. package/dist/types/webinar/utils.d.ts +6 -0
  184. package/dist/webinar/index.js +585 -164
  185. package/dist/webinar/index.js.map +1 -1
  186. package/dist/webinar/utils.js +25 -0
  187. package/dist/webinar/utils.js.map +1 -0
  188. package/package.json +26 -24
  189. package/src/aiEnableRequest/README.md +84 -0
  190. package/src/aiEnableRequest/index.ts +186 -0
  191. package/src/aiEnableRequest/utils.ts +25 -0
  192. package/src/annotation/index.ts +27 -7
  193. package/src/breakouts/breakout.ts +3 -1
  194. package/src/breakouts/index.ts +31 -0
  195. package/src/common/errors/webex-errors.ts +50 -3
  196. package/src/config.ts +7 -2
  197. package/src/constants.ts +49 -3
  198. package/src/controls-options-manager/constants.ts +14 -1
  199. package/src/controls-options-manager/index.ts +87 -28
  200. package/src/controls-options-manager/util.ts +81 -1
  201. package/src/hashTree/constants.ts +26 -0
  202. package/src/hashTree/hashTree.ts +480 -0
  203. package/src/hashTree/hashTreeParser.ts +1911 -29
  204. package/src/hashTree/types.ts +24 -1
  205. package/src/hashTree/utils.ts +98 -0
  206. package/src/index.ts +14 -1
  207. package/src/interceptors/constant.ts +6 -0
  208. package/src/interceptors/dataChannelAuthToken.ts +246 -0
  209. package/src/interceptors/index.ts +2 -1
  210. package/src/interceptors/locusRetry.ts +25 -4
  211. package/src/interceptors/locusRouteToken.ts +22 -5
  212. package/src/interceptors/utils.ts +16 -0
  213. package/src/interpretation/index.ts +29 -11
  214. package/src/interpretation/interpretation.types.ts +11 -0
  215. package/src/locus-info/controlsUtils.ts +20 -1
  216. package/src/locus-info/index.ts +958 -250
  217. package/src/locus-info/infoUtils.ts +41 -6
  218. package/src/locus-info/selfUtils.ts +1 -0
  219. package/src/locus-info/types.ts +51 -12
  220. package/src/media/MediaConnectionAwaiter.ts +62 -5
  221. package/src/media/index.ts +10 -1
  222. package/src/media/properties.ts +4 -1
  223. package/src/meeting/in-meeting-actions.ts +20 -0
  224. package/src/meeting/index.ts +1025 -146
  225. package/src/meeting/locusMediaRequest.ts +106 -6
  226. package/src/meeting/muteState.ts +10 -1
  227. package/src/meeting/request.ts +53 -0
  228. package/src/meeting/request.type.ts +6 -0
  229. package/src/meeting/util.ts +207 -7
  230. package/src/meeting-info/meeting-info-v2.ts +4 -2
  231. package/src/meetings/index.ts +307 -132
  232. package/src/meetings/meetings.types.ts +19 -0
  233. package/src/meetings/request.ts +43 -0
  234. package/src/meetings/util.ts +127 -13
  235. package/src/member/index.ts +20 -0
  236. package/src/member/types.ts +1 -0
  237. package/src/member/util.ts +41 -0
  238. package/src/members/index.ts +70 -7
  239. package/src/members/util.ts +12 -4
  240. package/src/metrics/constants.ts +11 -0
  241. package/src/multistream/codec/constants.ts +58 -0
  242. package/src/multistream/mediaRequestManager.ts +117 -76
  243. package/src/multistream/receiveSlot.ts +18 -0
  244. package/src/multistream/remoteMediaManager.ts +13 -0
  245. package/src/multistream/sendSlotManager.ts +97 -3
  246. package/src/reachability/clusterReachability.ts +156 -29
  247. package/src/reachability/index.ts +62 -17
  248. package/src/reachability/reachability.types.ts +11 -0
  249. package/src/reachability/reachabilityPeerConnection.ts +3 -1
  250. package/src/reachability/util.ts +36 -0
  251. package/src/reactions/reactions.type.ts +4 -0
  252. package/src/reconnection-manager/index.ts +0 -1
  253. package/src/recording-controller/index.ts +1 -2
  254. package/src/webinar/index.ts +448 -11
  255. package/src/webinar/utils.ts +16 -0
  256. package/test/unit/spec/aiEnableRequest/index.ts +1067 -0
  257. package/test/unit/spec/aiEnableRequest/utils.ts +130 -0
  258. package/test/unit/spec/annotation/index.ts +69 -7
  259. package/test/unit/spec/breakouts/breakout.ts +9 -3
  260. package/test/unit/spec/breakouts/index.ts +49 -0
  261. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  262. package/test/unit/spec/controls-options-manager/index.js +244 -29
  263. package/test/unit/spec/controls-options-manager/util.js +165 -0
  264. package/test/unit/spec/hashTree/hashTree.ts +721 -0
  265. package/test/unit/spec/hashTree/hashTreeParser.ts +5328 -0
  266. package/test/unit/spec/hashTree/utils.ts +264 -0
  267. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +406 -0
  268. package/test/unit/spec/interceptors/locusRetry.ts +205 -4
  269. package/test/unit/spec/interceptors/locusRouteToken.ts +44 -0
  270. package/test/unit/spec/interceptors/utils.ts +75 -0
  271. package/test/unit/spec/interpretation/index.ts +26 -4
  272. package/test/unit/spec/locus-info/controlsUtils.js +222 -52
  273. package/test/unit/spec/locus-info/index.js +2000 -171
  274. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  275. package/test/unit/spec/media/MediaConnectionAwaiter.ts +96 -1
  276. package/test/unit/spec/media/index.ts +92 -0
  277. package/test/unit/spec/media/properties.ts +12 -3
  278. package/test/unit/spec/meeting/in-meeting-actions.ts +12 -2
  279. package/test/unit/spec/meeting/index.js +2925 -209
  280. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  281. package/test/unit/spec/meeting/muteState.js +81 -0
  282. package/test/unit/spec/meeting/request.js +82 -0
  283. package/test/unit/spec/meeting/utils.js +595 -27
  284. package/test/unit/spec/meeting-info/meetinginfov2.js +19 -10
  285. package/test/unit/spec/meetings/index.js +1214 -75
  286. package/test/unit/spec/meetings/request.js +141 -0
  287. package/test/unit/spec/meetings/utils.js +453 -52
  288. package/test/unit/spec/member/index.js +35 -4
  289. package/test/unit/spec/member/util.js +154 -27
  290. package/test/unit/spec/members/index.js +216 -0
  291. package/test/unit/spec/members/request.js +37 -1
  292. package/test/unit/spec/members/utils.js +63 -0
  293. package/test/unit/spec/multistream/mediaRequestManager.ts +503 -122
  294. package/test/unit/spec/multistream/remoteMediaManager.ts +30 -0
  295. package/test/unit/spec/multistream/sendSlotManager.ts +135 -36
  296. package/test/unit/spec/reachability/clusterReachability.ts +125 -1
  297. package/test/unit/spec/reachability/index.ts +154 -49
  298. package/test/unit/spec/reachability/util.ts +31 -0
  299. package/test/unit/spec/reconnection-manager/index.js +4 -8
  300. package/test/unit/spec/recording-controller/index.js +9 -8
  301. package/test/unit/spec/webinar/index.ts +837 -39
  302. package/test/unit/spec/webinar/utils.ts +39 -0
@@ -1,5 +1,5 @@
1
1
  import uuid from 'uuid';
2
- import {cloneDeep, isEqual, isEmpty} from 'lodash';
2
+ import {cloneDeep, isEqual, isEmpty, merge} from 'lodash';
3
3
  import jwtDecode from 'jwt-decode';
4
4
  // @ts-ignore - Fix this
5
5
  import {StatelessWebexPlugin} from '@webex/webex-core';
@@ -13,7 +13,7 @@ import {
13
13
  CALL_DIAGNOSTIC_CONFIG,
14
14
  RtcMetrics,
15
15
  } from '@webex/internal-plugin-metrics';
16
- import {ClientEvent as RawClientEvent} from '@webex/event-dictionary-ts';
16
+ import type {ClientEvent as RawClientEvent} from '@webex/event-dictionary-ts';
17
17
 
18
18
  import {
19
19
  ConnectionState,
@@ -30,9 +30,11 @@ import {
30
30
  NetworkQualityMonitor,
31
31
  StatsMonitor,
32
32
  StatsMonitorEventNames,
33
- InboundAudioIssueSubTypes,
33
+ MediaCodecMimeType,
34
34
  } from '@webex/internal-media-core';
35
35
 
36
+ import {DataChannelTokenType} from '@webex/internal-plugin-llm';
37
+
36
38
  import {
37
39
  LocalStream,
38
40
  LocalCameraStream,
@@ -50,6 +52,12 @@ import {
50
52
  type MeetingTranscriptPayload,
51
53
  } from '@webex/internal-plugin-voicea';
52
54
 
55
+ import {
56
+ getBrowserMediaErrorCode,
57
+ isBrowserMediaError,
58
+ isBrowserMediaErrorName,
59
+ } from '@webex/internal-plugin-metrics/src/call-diagnostic/call-diagnostic-metrics.util';
60
+ import {CapabilityState, WebCapabilities} from '@webex/web-capabilities';
53
61
  import {processNewCaptions} from './voicea-meeting';
54
62
 
55
63
  import {
@@ -58,6 +66,7 @@ import {
58
66
  NoMediaEstablishedYetError,
59
67
  UserNotJoinedError,
60
68
  AddMediaFailed,
69
+ MediaConnectionTimedOutError,
61
70
  SdpResponseTimeoutError,
62
71
  } from '../common/errors/webex-errors';
63
72
 
@@ -68,6 +77,7 @@ import Roap, {type TurnDiscoveryResult, type TurnDiscoverySkipReason} from '../r
68
77
  import {type TurnServerInfo} from '../roap/types';
69
78
  import Media, {type BundlePolicy} from '../media';
70
79
  import MediaProperties from '../media/properties';
80
+ import {type FailureResult as MediaConnectionAwaiterFailureResult} from '../media/MediaConnectionAwaiter';
71
81
  import MeetingStateMachine from './state';
72
82
  import {createMuteState} from './muteState';
73
83
  import LocusInfo, {LocusLLMEvent} from '../locus-info';
@@ -128,6 +138,8 @@ import {
128
138
  STAGE_MANAGER_TYPE,
129
139
  LOCUSEVENT,
130
140
  LOCUS_LLM_EVENT,
141
+ LLM_DEFAULT_SESSION,
142
+ LLM_PRACTICE_SESSION,
131
143
  } from '../constants';
132
144
  import BEHAVIORAL_METRICS from '../metrics/constants';
133
145
  import ParameterError from '../common/errors/parameter';
@@ -173,12 +185,16 @@ import JoinForbiddenError from '../common/errors/join-forbidden-error';
173
185
  import {ReachabilityMetrics} from '../reachability/reachability.types';
174
186
  import {SetStageOptions, SetStageVideoLayout, UnsetStageVideoLayout} from './request.type';
175
187
  import {Invitee} from './type';
176
- import {DataSet} from '../hashTree/hashTreeParser';
188
+ import {DataSet, HashTreeMessage, Metadata} from '../hashTree/hashTreeParser';
177
189
  import {LocusDTO} from '../locus-info/types';
190
+ import AIEnableRequest from '../aiEnableRequest';
178
191
 
179
192
  // default callback so we don't call an undefined function, but in practice it should never be used
180
193
  const DEFAULT_ICE_PHASE_CALLBACK = () => 'JOIN_MEETING_FINAL';
181
194
 
195
+ const LLM_HEALTHCHECK_TIMER_MS = 3 * 60 * 1000;
196
+ const JOIN_WITH_MEDIA_RETRY_MAX_COUNT = 2;
197
+
182
198
  const logRequest = (request: any, {logText = ''}) => {
183
199
  LoggerProxy.logger.info(`${logText} - sending request`);
184
200
 
@@ -242,6 +258,7 @@ export type AddMediaOptions = {
242
258
  remoteMediaManagerConfig?: RemoteMediaManagerConfiguration; // applies only to multistream meetings
243
259
  bundlePolicy?: BundlePolicy; // applies only to multistream meetings
244
260
  allowMediaInLobby?: boolean; // allows adding media when in the lobby
261
+ allowPublishMediaInLobby?: boolean; // allows publishing media when in the lobby, if not specified, default value false is used
245
262
  additionalMediaOptions?: AdditionalMediaOptions; // allows adding additional options like send/receive audio/video
246
263
  };
247
264
 
@@ -556,6 +573,34 @@ type MediaReachabilityMetrics = ReachabilityMetrics & {
556
573
  * @memberof Meeting
557
574
  */
558
575
 
576
+ /**
577
+ * Stores an event so all events can be later retrieved via a console command for debugging.
578
+ * @param {string} type
579
+ * @param {Object} data
580
+ * @returns {void}
581
+ */
582
+ export function storeEventForDebugging(
583
+ type: string,
584
+ data: {
585
+ eventType: any;
586
+ stateElementsMessage?: HashTreeMessage;
587
+ }
588
+ ) {
589
+ if ((window as any)?.locusEvents) {
590
+ // only store non-heartbeat hash tree messages
591
+ if (
592
+ data.eventType === LOCUSEVENT.HASH_TREE_DATA_UPDATED &&
593
+ data.stateElementsMessage?.locusStateElements
594
+ ) {
595
+ (window as any).locusEvents.push({
596
+ ...data,
597
+ timestamp: new Date().toLocaleString(),
598
+ type,
599
+ });
600
+ }
601
+ }
602
+ }
603
+
559
604
  /**
560
605
  * @description Meeting is the crux of the plugin
561
606
  * @export
@@ -567,10 +612,11 @@ export default class Meeting extends StatelessWebexPlugin {
567
612
  breakouts: any;
568
613
  simultaneousInterpretation: any;
569
614
  annotation: any;
615
+ aiEnableRequest: any;
570
616
  webinar: any;
571
617
  conversationUrl: string;
572
618
  callStateForMetrics: CallStateForMetrics;
573
- destination: string;
619
+ destination: string | LocusDTO;
574
620
  destinationType: DESTINATION_TYPE;
575
621
  deviceUrl: string;
576
622
  hostId: string;
@@ -609,12 +655,22 @@ export default class Meeting extends StatelessWebexPlugin {
609
655
  floorGrantPending: boolean;
610
656
  hasJoinedOnce: boolean;
611
657
  hasWebsocketConnected: boolean;
658
+ private mercuryOnlineHandler?: () => void;
659
+ private mercuryOfflineHandler?: () => void;
612
660
  inMeetingActions: InMeetingActions;
613
661
  isLocalShareLive: boolean;
614
662
  isRoapInProgress: boolean;
615
663
  keepAliveTimerId: NodeJS.Timeout;
616
664
  lastVideoLayoutInfo: any;
617
665
  locusInfo: any;
666
+ // this group of properties is populated via updateMeetingObject() that's registered as a callback with LocusInfo
667
+ isUserUnadmitted?: boolean;
668
+ joinedWith?: any;
669
+ selfId?: string;
670
+ roles: any[];
671
+ canNotViewTheParticipantList?: boolean;
672
+ // ... there is more ... see SelfUtils.parse()
673
+ // end of the group
618
674
  locusMediaRequest?: LocusMediaRequest;
619
675
  mediaProperties: MediaProperties;
620
676
  mediaRequestManagers: {
@@ -649,7 +705,6 @@ export default class Meeting extends StatelessWebexPlugin {
649
705
  endCallInitJoinReq: any;
650
706
  endJoinReqResp: any;
651
707
  endLocalSDPGenRemoteSDPRecvDelay: any;
652
- joinedWith: any;
653
708
  locusId: any;
654
709
  startCallInitJoinReq: any;
655
710
  startJoinReqResp: any;
@@ -664,12 +719,11 @@ export default class Meeting extends StatelessWebexPlugin {
664
719
  permissionTokenReceivedLocalTime: number;
665
720
  resourceId: any;
666
721
  resourceUrl: string;
667
- selfId: string;
668
722
  state: any;
669
723
  localAudioStreamMuteStateHandler: () => void;
670
724
  localVideoStreamMuteStateHandler: () => void;
671
725
  localOutputTrackChangeHandler: () => void;
672
- roles: any[];
726
+ localConstraintsChangeHandler: () => void;
673
727
  environment: string;
674
728
  namespace = MEETINGS;
675
729
  allowMediaInLobby: boolean;
@@ -688,6 +742,7 @@ export default class Meeting extends StatelessWebexPlugin {
688
742
  isMoveToInProgress = false;
689
743
  registrationIdStatus: string;
690
744
  brbState: BrbState;
745
+ private promisesWaitingForPropUpdate: Record<string, Defer> = {};
691
746
 
692
747
  voiceaListenerCallbacks: object = {
693
748
  [VOICEAEVENTS.VOICEA_ANNOUNCEMENT]: (payload: Transcription['languageOptions']) => {
@@ -737,13 +792,20 @@ export default class Meeting extends StatelessWebexPlugin {
737
792
  private addMediaData: {
738
793
  retriedWithTurnServer: boolean;
739
794
  icePhaseCallback: () => string;
795
+ iceTransportPolicy?: RTCIceTransportPolicy;
740
796
  };
741
797
 
742
798
  private sendSlotManager: SendSlotManager = new SendSlotManager(LoggerProxy);
743
799
  private deferSDPAnswer?: Defer; // used for waiting for a response
744
800
  private sdpResponseTimer?: ReturnType<typeof setTimeout>;
745
801
  private hasMediaConnectionConnectedAtLeastOnce: boolean;
746
- private joinWithMediaRetryInfo?: {isRetry: boolean; prevJoinResponse?: any};
802
+ private joinWithMediaRetryInfo: {
803
+ retryCount: number;
804
+ prevJoinResponse?: any;
805
+ firstError?: Error;
806
+ prevError?: Error;
807
+ };
808
+
747
809
  private connectionStateHandler?: ConnectionStateHandler;
748
810
  private iceCandidateErrors: Map<string, number>;
749
811
  private iceCandidatesCount: number;
@@ -751,6 +813,7 @@ export default class Meeting extends StatelessWebexPlugin {
751
813
  private uploadLogsTimer?: ReturnType<typeof setTimeout>;
752
814
  private logUploadIntervalIndex: number;
753
815
  private mediaServerIp: string;
816
+ private llmHealthCheckTimer?: ReturnType<typeof setTimeout>;
754
817
 
755
818
  /**
756
819
  * @param {Object} attrs
@@ -885,6 +948,10 @@ export default class Meeting extends StatelessWebexPlugin {
885
948
  */
886
949
  // @ts-ignore
887
950
  this.simultaneousInterpretation = new SimultaneousInterpretation({}, {parent: this.webex});
951
+
952
+ // @ts-ignore
953
+ this.aiEnableRequest = new AIEnableRequest({locusUrl: this.locusUrl}, {parent: this.webex});
954
+
888
955
  /**
889
956
  * @instance
890
957
  * @type {Annotation}
@@ -914,6 +981,7 @@ export default class Meeting extends StatelessWebexPlugin {
914
981
  },
915
982
  (csi: CSI) => (this.members.findMemberByCsi(csi) as any)?.id
916
983
  );
984
+
917
985
  /**
918
986
  * Object containing helper classes for managing media requests for audio/video/screenshare (for multistream media connections)
919
987
  * All multistream media requests sent out for this meeting have to go through them.
@@ -933,6 +1001,7 @@ export default class Meeting extends StatelessWebexPlugin {
933
1001
  mediaRequests
934
1002
  );
935
1003
  },
1004
+ this.getIngressPayloadTypeCallback.bind(this),
936
1005
  {
937
1006
  // @ts-ignore - config coming from registerPlugin
938
1007
  degradationPreferences: this.config.degradationPreferences,
@@ -954,6 +1023,7 @@ export default class Meeting extends StatelessWebexPlugin {
954
1023
  mediaRequests
955
1024
  );
956
1025
  },
1026
+ this.getIngressPayloadTypeCallback.bind(this),
957
1027
  {
958
1028
  // @ts-ignore - config coming from registerPlugin
959
1029
  degradationPreferences: this.config.degradationPreferences,
@@ -975,6 +1045,7 @@ export default class Meeting extends StatelessWebexPlugin {
975
1045
  mediaRequests
976
1046
  );
977
1047
  },
1048
+ this.getIngressPayloadTypeCallback.bind(this),
978
1049
  {
979
1050
  // @ts-ignore - config coming from registerPlugin
980
1051
  degradationPreferences: this.config.degradationPreferences,
@@ -996,11 +1067,14 @@ export default class Meeting extends StatelessWebexPlugin {
996
1067
  mediaRequests
997
1068
  );
998
1069
  },
1070
+ this.getIngressPayloadTypeCallback.bind(this),
999
1071
  {
1000
1072
  // @ts-ignore - config coming from registerPlugin
1001
1073
  degradationPreferences: this.config.degradationPreferences,
1002
1074
  kind: 'video',
1003
1075
  trimRequestsToNumOfSources: false,
1076
+ // @ts-ignore - config coming from registerPlugin
1077
+ enableAv1: this.config.enableAv1SlidesSupport,
1004
1078
  }
1005
1079
  ),
1006
1080
  };
@@ -1505,6 +1579,8 @@ export default class Meeting extends StatelessWebexPlugin {
1505
1579
  this.controlsOptionsManager = new ControlsOptionsManager(this.meetingRequest, {
1506
1580
  locusUrl: this.locusInfo?.url,
1507
1581
  displayHints: [],
1582
+ getControls: () => this.locusInfo?.controls,
1583
+ isWebinar: () => this.locusInfo?.info?.isWebinar,
1508
1584
  });
1509
1585
 
1510
1586
  this.setUpLocusInfoListeners();
@@ -1534,6 +1610,12 @@ export default class Meeting extends StatelessWebexPlugin {
1534
1610
  }
1535
1611
  };
1536
1612
 
1613
+ this.localConstraintsChangeHandler = () => {
1614
+ if (!this.isMultistream) {
1615
+ this.mediaProperties.webrtcMediaConnection?.updatePreferredBitrateKbps();
1616
+ }
1617
+ };
1618
+
1537
1619
  /**
1538
1620
  * Promise that exists if SDP offer has been generated, and resolves once sdp answer is received.
1539
1621
  * @instance
@@ -1597,11 +1679,11 @@ export default class Meeting extends StatelessWebexPlugin {
1597
1679
  /**
1598
1680
  * Information needed for a retry of a call to joinWithMedia
1599
1681
  * @instance
1600
- * @type {{isRetry: boolean; prevJoinResponse?: any}}
1682
+ * @type {{retryCount: number; prevJoinResponse?: any}}
1601
1683
  * @private
1602
1684
  * @memberof Meeting
1603
1685
  */
1604
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
1686
+ this.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
1605
1687
 
1606
1688
  /**
1607
1689
  * Connection state handler
@@ -1655,6 +1737,37 @@ export default class Meeting extends StatelessWebexPlugin {
1655
1737
  this.mediaServerIp = undefined;
1656
1738
  }
1657
1739
 
1740
+ /**
1741
+ * Get the ingress payload type for a given media type and codec mime type
1742
+ * @param {MediaType} mediaType - The media type
1743
+ * @param {MediaCodecMimeType} codecMimeType - The codec mime type
1744
+ * @returns {number | undefined} - The ingress payload type
1745
+ * @private
1746
+ * @memberof Meeting
1747
+ */
1748
+ private getIngressPayloadTypeCallback(
1749
+ mediaType: MediaType,
1750
+ codecMimeType: MediaCodecMimeType
1751
+ ): number | undefined {
1752
+ if (this.isMultistream) {
1753
+ try {
1754
+ return this.mediaProperties.webrtcMediaConnection.getIngressPayloadType(
1755
+ mediaType,
1756
+ codecMimeType
1757
+ );
1758
+ } catch (error) {
1759
+ LoggerProxy.logger.info(
1760
+ `Meeting:index#mediaRequestManager --> failed to get ingress payload type for mediaType=${mediaType}, codecMimeType=${codecMimeType}`,
1761
+ error
1762
+ );
1763
+
1764
+ return undefined;
1765
+ }
1766
+ }
1767
+
1768
+ return undefined;
1769
+ }
1770
+
1658
1771
  /**
1659
1772
  * Temporary func to return webex object,
1660
1773
  * in order to access internal plugin metrics
@@ -2731,7 +2844,7 @@ export default class Meeting extends StatelessWebexPlugin {
2731
2844
  private setupLocusControlsListener() {
2732
2845
  this.locusInfo.on(
2733
2846
  LOCUSINFO.EVENTS.CONTROLS_RECORDING_UPDATED,
2734
- ({state, modifiedBy, lastModified}) => {
2847
+ ({state, modifiedBy, lastModified, modifiedByServiceAppName, modifiedByServiceAppId}) => {
2735
2848
  let event;
2736
2849
 
2737
2850
  switch (state) {
@@ -2757,6 +2870,8 @@ export default class Meeting extends StatelessWebexPlugin {
2757
2870
  state: state === RECORDING_STATE.RESUMED ? RECORDING_STATE.RECORDING : state,
2758
2871
  modifiedBy,
2759
2872
  lastModified,
2873
+ modifiedByServiceAppName,
2874
+ modifiedByServiceAppId,
2760
2875
  };
2761
2876
  Trigger.trigger(
2762
2877
  this,
@@ -2843,6 +2958,13 @@ export default class Meeting extends StatelessWebexPlugin {
2843
2958
  );
2844
2959
  });
2845
2960
 
2961
+ this.locusInfo.on(LOCUSINFO.EVENTS.CONTROLS_MEETING_HESIOD_LLM_ID_UPDATED, ({hesiodLlmId}) => {
2962
+ if (hesiodLlmId) {
2963
+ // @ts-ignore
2964
+ this.webex.internal.voicea.onCaptionServiceIdUpdate(hesiodLlmId);
2965
+ }
2966
+ });
2967
+
2846
2968
  this.locusInfo.on(LOCUSINFO.EVENTS.CONTROLS_MEETING_BREAKOUT_UPDATED, ({breakout}) => {
2847
2969
  this.breakouts.updateBreakout(breakout);
2848
2970
  Trigger.trigger(
@@ -2936,6 +3058,18 @@ export default class Meeting extends StatelessWebexPlugin {
2936
3058
  );
2937
3059
  });
2938
3060
 
3061
+ this.locusInfo.on(
3062
+ LOCUSINFO.EVENTS.CONTROLS_AI_SUMMARY_NOTIFICATION_UPDATED,
3063
+ ({aiSummaryNotification}) => {
3064
+ Trigger.trigger(
3065
+ this,
3066
+ {file: 'meeting/index', function: 'setupLocusControlsListener'},
3067
+ EVENT_TRIGGERS.MEETING_CONTROLS_AI_SUMMARY_NOTIFICATION_UPDATED,
3068
+ {aiSummaryNotification}
3069
+ );
3070
+ }
3071
+ );
3072
+
2939
3073
  this.locusInfo.on(LOCUSINFO.EVENTS.CONTROLS_WEBCAST_CHANGED, ({state}) => {
2940
3074
  Trigger.trigger(
2941
3075
  this,
@@ -3382,6 +3516,7 @@ export default class Meeting extends StatelessWebexPlugin {
3382
3516
  this.breakouts.locusUrlUpdate(url);
3383
3517
  this.simultaneousInterpretation.locusUrlUpdate(url);
3384
3518
  this.annotation.locusUrlUpdate(url);
3519
+ this.aiEnableRequest.locusUrlUpdate(url);
3385
3520
  this.locusUrl = url;
3386
3521
  this.locusId = this.locusUrl?.split('/').pop();
3387
3522
  this.recordingController.setLocusUrl(this.locusUrl);
@@ -3417,6 +3552,7 @@ export default class Meeting extends StatelessWebexPlugin {
3417
3552
  this.breakouts.breakoutServiceUrlUpdate(payload?.services?.breakout?.url);
3418
3553
  this.annotation.approvalUrlUpdate(payload?.services?.approval?.url);
3419
3554
  this.simultaneousInterpretation.approvalUrlUpdate(payload?.services?.approval?.url);
3555
+ this.aiEnableRequest.approvalUrlUpdate(payload?.services?.approval?.url);
3420
3556
  });
3421
3557
  }
3422
3558
 
@@ -3514,6 +3650,9 @@ export default class Meeting extends StatelessWebexPlugin {
3514
3650
  // @ts-ignore - config coming from registerPlugin
3515
3651
  if (datachannelUrl && this.config.enableAutomaticLLM) {
3516
3652
  this.updateLLMConnection();
3653
+ if (this.webinar.isJoinPracticeSessionDataChannel()) {
3654
+ this.webinar.updatePSDataChannel();
3655
+ }
3517
3656
  }
3518
3657
  }
3519
3658
 
@@ -3677,6 +3816,17 @@ export default class Meeting extends StatelessWebexPlugin {
3677
3816
  });
3678
3817
  }
3679
3818
  this.rtcMetrics?.sendNextMetrics();
3819
+
3820
+ try {
3821
+ await this.ensureDefaultDatachannelTokenAfterAdmit();
3822
+ } catch (error) {
3823
+ LoggerProxy.logger.warn(
3824
+ `Meeting:index#setUpLocusInfoSelfListener --> failed post-admit token prefetch flow: ${
3825
+ error?.message || String(error)
3826
+ }`
3827
+ );
3828
+ }
3829
+
3680
3830
  this.updateLLMConnection();
3681
3831
  });
3682
3832
 
@@ -3721,6 +3871,9 @@ export default class Meeting extends StatelessWebexPlugin {
3721
3871
  });
3722
3872
 
3723
3873
  this.locusInfo.on(LOCUSINFO.EVENTS.SELF_CANNOT_VIEW_PARTICIPANT_LIST_CHANGE, (payload) => {
3874
+ // canViewTheParticipantList meeting action depends on this value, so we need to update meeting actions
3875
+ this.updateMeetingActions();
3876
+
3724
3877
  Trigger.trigger(
3725
3878
  this,
3726
3879
  {
@@ -3746,6 +3899,10 @@ export default class Meeting extends StatelessWebexPlugin {
3746
3899
  );
3747
3900
  });
3748
3901
 
3902
+ this.locusInfo.on(LOCUSINFO.EVENTS.SELF_ID_CHANGED, (payload) => {
3903
+ this.aiEnableRequest.selfParticipantIdUpdate(payload.selfId);
3904
+ });
3905
+
3749
3906
  this.locusInfo.on(LOCUSINFO.EVENTS.SELF_MEETING_INTERPRETATION_CHANGED, (payload) => {
3750
3907
  const targetChanged = this.simultaneousInterpretation.updateSelfInterpretation(payload);
3751
3908
  Trigger.trigger(
@@ -3911,7 +4068,14 @@ export default class Meeting extends StatelessWebexPlugin {
3911
4068
  // is not changed by any delta event
3912
4069
  if (object && Object.keys(object).length) {
3913
4070
  Object.keys(object).forEach((key) => {
4071
+ const previousValue = this[key];
4072
+
3914
4073
  this[key] = object[key];
4074
+
4075
+ if (this.promisesWaitingForPropUpdate[key] && previousValue !== object[key]) {
4076
+ this.promisesWaitingForPropUpdate[key].resolve();
4077
+ delete this.promisesWaitingForPropUpdate[key];
4078
+ }
3915
4079
  });
3916
4080
  }
3917
4081
  }
@@ -4049,7 +4213,12 @@ export default class Meeting extends StatelessWebexPlugin {
4049
4213
  }
4050
4214
 
4051
4215
  /**
4052
- * Transfer the moderator role to another eligible member
4216
+ * Transfer the moderator role to another eligible member.
4217
+ *
4218
+ * If the target member is currently joined in the current session, the request is
4219
+ * sent against the current locus. Otherwise, we search the breakout sessions and,
4220
+ * when the member is found in one, we send the request against that breakout
4221
+ * session's locus url instead.
4053
4222
  * @param {String} memberId
4054
4223
  * @param {Boolean} moderator
4055
4224
  * @returns {Promise} see #members.transferHostToMember
@@ -4057,7 +4226,21 @@ export default class Meeting extends StatelessWebexPlugin {
4057
4226
  * @memberof Meeting
4058
4227
  */
4059
4228
  public transfer(memberId: string, moderator = true) {
4060
- return this.members.transferHostToMember(memberId, moderator);
4229
+ const targetMember = this.members.membersCollection.get(memberId);
4230
+
4231
+ if (targetMember?.isInMeeting) {
4232
+ return this.members.transferHostToMember(memberId, moderator);
4233
+ }
4234
+
4235
+ const breakout = this.breakouts?.breakouts?.models?.find((bo: any) => {
4236
+ const breakoutMember = bo.members?.membersCollection?.get(memberId);
4237
+
4238
+ return breakoutMember?.isInMeeting;
4239
+ });
4240
+
4241
+ const breakoutLocusUrl = breakout?.breakoutRosterLocus?.url;
4242
+
4243
+ return this.members.transferHostToMember(memberId, moderator, breakoutLocusUrl);
4061
4244
  }
4062
4245
 
4063
4246
  /**
@@ -4248,6 +4431,9 @@ export default class Meeting extends StatelessWebexPlugin {
4248
4431
  bothLeaveAndEndMeetingAvailable: MeetingUtil.bothLeaveAndEndMeetingAvailable(
4249
4432
  this.userDisplayHints
4250
4433
  ),
4434
+ requireHostEndMeetingBeforeLeave: MeetingUtil.requireHostEndMeetingBeforeLeave(
4435
+ this.userDisplayHints
4436
+ ),
4251
4437
  canEnableClosedCaption: MeetingUtil.canEnableClosedCaption(this.userDisplayHints),
4252
4438
  canStartTranscribing: MeetingUtil.canStartTranscribing(this.userDisplayHints),
4253
4439
  canStopTranscribing: MeetingUtil.canStopTranscribing(this.userDisplayHints),
@@ -4506,6 +4692,19 @@ export default class Meeting extends StatelessWebexPlugin {
4506
4692
  requiredHints: [DISPLAY_HINTS.DISABLE_ATTENDEE_START_POLLING_QA],
4507
4693
  displayHints: this.userDisplayHints,
4508
4694
  }),
4695
+ canAttendeeRequestAiAssistantEnabled: MeetingUtil.canAttendeeRequestAiAssistantEnabled(
4696
+ this.userDisplayHints,
4697
+ this.roles
4698
+ ),
4699
+ isAttendeeRequestAiAssistantDeclinedAll:
4700
+ MeetingUtil.attendeeRequestAiAssistantDeclinedAll(this.userDisplayHints),
4701
+ isAnonymizeDisplayNamesEnabled: MeetingUtil.isAnonymizeDisplayNamesEnabled(
4702
+ this.userDisplayHints
4703
+ ),
4704
+ canViewTheParticipantList: MeetingUtil.canViewTheParticipantList(
4705
+ this.userDisplayHints,
4706
+ this.canNotViewTheParticipantList ?? false
4707
+ ),
4509
4708
  }) || changed;
4510
4709
  }
4511
4710
  if (changed) {
@@ -4554,6 +4753,34 @@ export default class Meeting extends StatelessWebexPlugin {
4554
4753
  this.sipUri = sipUri;
4555
4754
  }
4556
4755
 
4756
+ /**
4757
+ * After initial locus setup, refreshes destination with synced locus data and optionally
4758
+ * performs deferred meeting info fetch when initial locus was incomplete.
4759
+ * @param {LocusDTO} locus
4760
+ * @returns {void}
4761
+ */
4762
+ public async finalizeMeetingAfterInitialLocusSetup(locus: LocusDTO): Promise<void> {
4763
+ if (locus && this?.destinationType === DESTINATION_TYPE.LOCUS_ID) {
4764
+ // destination is initialized from the initial locus snapshot in constructor,
4765
+ // so refresh it after locus sync to avoid stale partial hash-tree data.
4766
+ this.destination = locus;
4767
+ }
4768
+ if (
4769
+ (!this.meetingInfo || isEmpty(this.meetingInfo)) &&
4770
+ (this.destination as LocusDTO)?.info &&
4771
+ !this.fetchMeetingInfoTimeoutId &&
4772
+ !MeetingsUtil.isOneOnOneCall(locus)
4773
+ ) {
4774
+ try {
4775
+ await this.fetchMeetingInfo({});
4776
+ } catch (error: any) {
4777
+ LoggerProxy.logger.info(
4778
+ `Meeting:index#finalizeMeetingAfterInitialLocusSetup --> deferred fetchMeetingInfo failed: ${error.message}`
4779
+ );
4780
+ }
4781
+ }
4782
+ }
4783
+
4557
4784
  /**
4558
4785
  * Set the locus info the class instance. Should be called with the parsed locus
4559
4786
  * we got in the join response.
@@ -4577,7 +4804,8 @@ export default class Meeting extends StatelessWebexPlugin {
4577
4804
  mediaId: string;
4578
4805
  host: object;
4579
4806
  selfId: string;
4580
- dataSets: DataSet[];
4807
+ dataSets: DataSet[]; // only sent by Locus when hash trees are used
4808
+ metadata: Metadata; // only sent by Locus when hash trees are used
4581
4809
  }) {
4582
4810
  const mtgLocus: any = data.locus;
4583
4811
 
@@ -4593,6 +4821,7 @@ export default class Meeting extends StatelessWebexPlugin {
4593
4821
  trigger: 'join-response',
4594
4822
  locus: mtgLocus,
4595
4823
  dataSets: data.dataSets,
4824
+ metadata: data.metadata,
4596
4825
  });
4597
4826
  }
4598
4827
 
@@ -4802,6 +5031,7 @@ export default class Meeting extends StatelessWebexPlugin {
4802
5031
  this.localVideoStreamMuteStateHandler
4803
5032
  );
4804
5033
  oldStream?.off(LocalStreamEventNames.OutputTrackChange, this.localOutputTrackChangeHandler);
5034
+ oldStream?.off(LocalStreamEventNames.ConstraintsChange, this.localConstraintsChangeHandler);
4805
5035
 
4806
5036
  // we don't update this.mediaProperties.mediaDirection.sendVideo, because we always keep it as true to avoid extra SDP exchanges
4807
5037
  this.mediaProperties.setLocalVideoStream(localStream);
@@ -4817,6 +5047,7 @@ export default class Meeting extends StatelessWebexPlugin {
4817
5047
  this.localVideoStreamMuteStateHandler
4818
5048
  );
4819
5049
  localStream?.on(LocalStreamEventNames.OutputTrackChange, this.localOutputTrackChangeHandler);
5050
+ localStream?.on(LocalStreamEventNames.ConstraintsChange, this.localConstraintsChangeHandler);
4820
5051
 
4821
5052
  if (!this.isMultistream || !localStream) {
4822
5053
  // for multistream WCME automatically un-publishes the old stream when we publish a new one
@@ -4951,6 +5182,7 @@ export default class Meeting extends StatelessWebexPlugin {
4951
5182
  this.localVideoStreamMuteStateHandler
4952
5183
  );
4953
5184
  videoStream?.off(LocalStreamEventNames.OutputTrackChange, this.localOutputTrackChangeHandler);
5185
+ videoStream?.off(LocalStreamEventNames.ConstraintsChange, this.localConstraintsChangeHandler);
4954
5186
 
4955
5187
  shareAudioStream?.off(StreamEventNames.Ended, this.handleShareAudioStreamEnded);
4956
5188
  shareAudioStream?.off(
@@ -5020,8 +5252,7 @@ export default class Meeting extends StatelessWebexPlugin {
5020
5252
  public setMercuryListener() {
5021
5253
  // Client will have a socket manager and handle reconnecting to mercury, when we reconnect to mercury
5022
5254
  // if the meeting has active peer connections, it should try to reconnect.
5023
- // @ts-ignore
5024
- this.webex.internal.mercury.on(ONLINE, () => {
5255
+ this.mercuryOnlineHandler = () => {
5025
5256
  LoggerProxy.logger.info('Meeting:index#setMercuryListener --> Web socket online');
5026
5257
 
5027
5258
  // Only send restore event when it was disconnected before and for connected later
@@ -5031,15 +5262,47 @@ export default class Meeting extends StatelessWebexPlugin {
5031
5262
  });
5032
5263
  }
5033
5264
  this.hasWebsocketConnected = true;
5034
- });
5265
+ };
5035
5266
 
5036
- // @ts-ignore
5037
- this.webex.internal.mercury.on(OFFLINE, () => {
5267
+ this.mercuryOfflineHandler = () => {
5038
5268
  LoggerProxy.logger.error('Meeting:index#setMercuryListener --> Web socket offline');
5039
5269
  Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.MERCURY_CONNECTION_FAILURE, {
5040
5270
  correlation_id: this.correlationId,
5041
5271
  });
5042
- });
5272
+ };
5273
+
5274
+ // @ts-ignore
5275
+ this.webex.internal.mercury.on(ONLINE, this.mercuryOnlineHandler);
5276
+ // @ts-ignore
5277
+ this.webex.internal.mercury.on(OFFLINE, this.mercuryOfflineHandler);
5278
+ }
5279
+
5280
+ /**
5281
+ * Removes this meeting's Mercury ONLINE/OFFLINE event listeners registered
5282
+ * by setMercuryListener(). Must be called before Locus /leave to avoid
5283
+ * unnecessary syncs/metrics triggered by events received while leaving
5284
+ * (per Locus team recommendation).
5285
+ *
5286
+ * Mercury is a process-wide singleton shared with other plugins, so we
5287
+ * pass the bound handler refs to .off() to avoid clearing every listener
5288
+ * for ONLINE/OFFLINE on the shared emitter.
5289
+ *
5290
+ * Idempotent: subsequent calls are no-ops because the handler refs are
5291
+ * cleared after detaching.
5292
+ * @private
5293
+ * @returns {void}
5294
+ */
5295
+ private stopListeningForMercuryEvents() {
5296
+ if (this.mercuryOnlineHandler) {
5297
+ // @ts-ignore
5298
+ this.webex.internal.mercury.off(ONLINE, this.mercuryOnlineHandler);
5299
+ this.mercuryOnlineHandler = undefined;
5300
+ }
5301
+ if (this.mercuryOfflineHandler) {
5302
+ // @ts-ignore
5303
+ this.webex.internal.mercury.off(OFFLINE, this.mercuryOfflineHandler);
5304
+ this.mercuryOfflineHandler = undefined;
5305
+ }
5043
5306
  }
5044
5307
 
5045
5308
  /**
@@ -5350,7 +5613,7 @@ export default class Meeting extends StatelessWebexPlugin {
5350
5613
  } = {}
5351
5614
  ) {
5352
5615
  const {mediaOptions, joinOptions = {}} = options;
5353
- const {isRetry, prevJoinResponse} = this.joinWithMediaRetryInfo;
5616
+ const {retryCount, prevJoinResponse, prevError} = this.joinWithMediaRetryInfo;
5354
5617
 
5355
5618
  if (!mediaOptions?.allowMediaInLobby) {
5356
5619
  return Promise.reject(
@@ -5364,12 +5627,29 @@ export default class Meeting extends StatelessWebexPlugin {
5364
5627
  let joined = false;
5365
5628
  let joinResponse = prevJoinResponse;
5366
5629
 
5630
+ /* Before we do anything, check if RTCPeerConnection is available. Normally this is checked
5631
+ by addMediaInternal() itself when creating the media connection, but since joinWithMedia()
5632
+ is a convenience method that does both join() and addMedia(), we want to fail fast here
5633
+ in case WebRTC is not available at all.
5634
+ */
5635
+ if (WebCapabilities.supportsRTCPeerConnection() === CapabilityState.NOT_CAPABLE) {
5636
+ // throw the same error that would be thrown by addMediaInternal()
5637
+ throw new Errors.WebrtcApiNotAvailableError(
5638
+ 'RTCPeerConnection API is not available in this environment'
5639
+ );
5640
+ }
5641
+
5642
+ const shouldJoin =
5643
+ !joinResponse || // first try, when the join response is empty
5644
+ (prevError && prevError instanceof UserNotJoinedError) || // last try failed with UserNotJoinedError
5645
+ MeetingUtil.isUserInLeftState(this.locusInfo); // locus dropped the connection before we can re-try addMedia
5646
+
5367
5647
  try {
5368
5648
  let turnServerInfo;
5369
5649
  let turnDiscoverySkippedReason;
5370
5650
  let forceTurnDiscovery = false;
5371
5651
 
5372
- if (!joinResponse) {
5652
+ if (shouldJoin) {
5373
5653
  // This is the 1st attempt or a retry after join request failed -> we need to do a join with TURN discovery
5374
5654
 
5375
5655
  const turnDiscoveryRequest = await this.roap.generateTurnDiscoveryRequestMessage(
@@ -5408,16 +5688,22 @@ export default class Meeting extends StatelessWebexPlugin {
5408
5688
  joined = true;
5409
5689
  }
5410
5690
 
5691
+ const shouldRetryMediaWithOnlyTurnTLS = await this.shouldRetryMediaWithOnlyTurnTLS(prevError);
5692
+
5411
5693
  const mediaResponse = await this.addMediaInternal(
5412
5694
  () => {
5413
- return this.joinWithMediaRetryInfo.isRetry ? 'JOIN_MEETING_FINAL' : 'JOIN_MEETING_RETRY';
5695
+ // callback is not called when UserNotJoinedError is thrown
5696
+ return this.joinWithMediaRetryInfo.retryCount >= 1
5697
+ ? 'JOIN_MEETING_FINAL'
5698
+ : 'JOIN_MEETING_RETRY';
5414
5699
  },
5415
- turnServerInfo,
5416
5700
  forceTurnDiscovery,
5701
+ turnServerInfo,
5702
+ shouldRetryMediaWithOnlyTurnTLS ? 'relay' : undefined,
5417
5703
  mediaOptions
5418
5704
  );
5419
5705
 
5420
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
5706
+ this.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
5421
5707
 
5422
5708
  return {
5423
5709
  join: joinResponse,
@@ -5431,17 +5717,36 @@ export default class Meeting extends StatelessWebexPlugin {
5431
5717
 
5432
5718
  this.roap.abortTurnDiscovery();
5433
5719
 
5434
- // if this was the first attempt, let's do a retry
5435
- let shouldRetry = !isRetry;
5720
+ // let's do a retry
5721
+ let shouldRetry =
5722
+ retryCount < 1 ||
5723
+ (error instanceof UserNotJoinedError && retryCount < JOIN_WITH_MEDIA_RETRY_MAX_COUNT);
5436
5724
 
5437
- if (CallDiagnosticUtils.isSdpOfferCreationError(error)) {
5725
+ if (
5726
+ CallDiagnosticUtils.isSdpOfferCreationError(error) ||
5727
+ CallDiagnosticUtils.isWebrtcApiNotAvailableError(error)
5728
+ ) {
5438
5729
  // errors related to offer creation (for example missing H264 codec) will happen again no matter how many times we try,
5439
5730
  // so there is no point doing a retry
5440
5731
  shouldRetry = false;
5441
5732
  }
5442
5733
 
5443
- // we only want to call leave if join was successful and this was a retry or we won't be doing any more retries
5444
- if (joined && (isRetry || !shouldRetry)) {
5734
+ if (CallDiagnosticUtils.isBrowserMediaError(error)) {
5735
+ shouldRetry = false;
5736
+ // eslint-disable-next-line no-ex-assign
5737
+ error = merge({
5738
+ error: {
5739
+ body: {
5740
+ errorCode: CallDiagnosticUtils.getBrowserMediaErrorCode(error),
5741
+ message: error?.message,
5742
+ name: error?.name,
5743
+ },
5744
+ },
5745
+ });
5746
+ }
5747
+
5748
+ // we only want to call leave if join was successful, and we won't be doing any more retries
5749
+ if (joined && !shouldRetry) {
5445
5750
  try {
5446
5751
  await this.leave({resourceId: joinOptions?.resourceId, reason: 'joinWithMedia failure'});
5447
5752
  } catch (e) {
@@ -5458,7 +5763,7 @@ export default class Meeting extends StatelessWebexPlugin {
5458
5763
  reason: error.message,
5459
5764
  stack: error.stack,
5460
5765
  leaveErrorReason: leaveError?.message,
5461
- isRetry,
5766
+ isRetry: retryCount > 0,
5462
5767
  },
5463
5768
  {
5464
5769
  type: error.name,
@@ -5467,15 +5772,26 @@ export default class Meeting extends StatelessWebexPlugin {
5467
5772
 
5468
5773
  if (shouldRetry) {
5469
5774
  LoggerProxy.logger.warn('Meeting:index#joinWithMedia --> retrying call to joinWithMedia');
5470
- this.joinWithMediaRetryInfo.isRetry = true;
5775
+ this.joinWithMediaRetryInfo.retryCount = retryCount + 1;
5471
5776
  this.joinWithMediaRetryInfo.prevJoinResponse = joinResponse;
5777
+ this.joinWithMediaRetryInfo.prevError = error;
5778
+ if (!this.joinWithMediaRetryInfo.firstError) {
5779
+ this.joinWithMediaRetryInfo.firstError = error;
5780
+ }
5472
5781
 
5473
5782
  return this.joinWithMedia(options);
5474
5783
  }
5475
5784
 
5476
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
5785
+ const {firstError} = this.joinWithMediaRetryInfo;
5477
5786
 
5478
- throw error;
5787
+ this.joinWithMediaRetryInfo = {
5788
+ retryCount: 0,
5789
+ prevJoinResponse: undefined,
5790
+ firstError: undefined,
5791
+ prevError: undefined,
5792
+ };
5793
+
5794
+ throw firstError ?? error;
5479
5795
  }
5480
5796
  }
5481
5797
 
@@ -5713,6 +6029,11 @@ export default class Meeting extends StatelessWebexPlugin {
5713
6029
  */
5714
6030
  private processLocusLLMEvent = (event: LocusLLMEvent): void => {
5715
6031
  if (event.data.eventType === LOCUSEVENT.HASH_TREE_DATA_UPDATED) {
6032
+ // @ts-ignore
6033
+ if (this.config.experimental.storeLocusHashTreeEventsForDebugging) {
6034
+ storeEventForDebugging('llm', event.data);
6035
+ }
6036
+
5716
6037
  this.locusInfo.parse(this, event.data);
5717
6038
  } else {
5718
6039
  LoggerProxy.logger.warn(
@@ -5721,6 +6042,31 @@ export default class Meeting extends StatelessWebexPlugin {
5721
6042
  }
5722
6043
  };
5723
6044
 
6045
+ /**
6046
+ * Verifies the relay event was delivered for the active LLM session binding.
6047
+ * @param {RelayEvent} event Event object coming from LLM Connection
6048
+ * @returns {boolean}
6049
+ */
6050
+ private isRelayEventRouteValid(event: RelayEvent): boolean {
6051
+ const route = event?.headers?.route;
6052
+
6053
+ if (!route) {
6054
+ return true;
6055
+ }
6056
+
6057
+ const {llm} = (this as any).webex.internal;
6058
+ const isPracticeSession = llm.isConnected(LLM_PRACTICE_SESSION);
6059
+ const expectedBinding = isPracticeSession
6060
+ ? llm.getBinding(LLM_PRACTICE_SESSION)
6061
+ : llm.getBinding();
6062
+
6063
+ if (!expectedBinding || route === expectedBinding) {
6064
+ return true;
6065
+ }
6066
+
6067
+ return false;
6068
+ }
6069
+
5724
6070
  /**
5725
6071
  * Callback called when a relay event is received from meeting LLM Connection
5726
6072
  * @param {RelayEvent} e Event object coming from LLM Connection
@@ -5728,6 +6074,9 @@ export default class Meeting extends StatelessWebexPlugin {
5728
6074
  * @returns {void}
5729
6075
  */
5730
6076
  private processRelayEvent = (e: RelayEvent): void => {
6077
+ if (!this.isRelayEventRouteValid(e)) {
6078
+ return;
6079
+ }
5731
6080
  switch (e.data.relayType) {
5732
6081
  case REACTION_RELAY_TYPES.REACTION:
5733
6082
  if (
@@ -5736,7 +6085,7 @@ export default class Meeting extends StatelessWebexPlugin {
5736
6085
  this.isReactionsSupported()
5737
6086
  ) {
5738
6087
  const member = this.members.membersCollection.get(e.data.sender.participantId);
5739
- if (!member) {
6088
+ if (!member && !this.locusInfo?.info?.isWebinar) {
5740
6089
  // @ts-ignore -- fix type
5741
6090
  LoggerProxy.logger.warn(
5742
6091
  `Meeting:index#processRelayEvent --> Skipping handling of ${REACTION_RELAY_TYPES.REACTION} for ${this.id}. participantId ${e.data.sender.participantId} does not exist in membersCollection.`
@@ -5744,7 +6093,7 @@ export default class Meeting extends StatelessWebexPlugin {
5744
6093
  break;
5745
6094
  }
5746
6095
 
5747
- const {name} = member;
6096
+ const name = (member && member.name) || e.data.sender.displayName;
5748
6097
  const processedReaction: ProcessedReaction = {
5749
6098
  reaction: e.data.reaction,
5750
6099
  sender: {
@@ -5773,37 +6122,35 @@ export default class Meeting extends StatelessWebexPlugin {
5773
6122
  * @returns {void}
5774
6123
  */
5775
6124
  stopTranscription() {
5776
- if (this.transcription) {
5777
- // @ts-ignore
5778
- this.webex.internal.voicea.off(
5779
- VOICEAEVENTS.VOICEA_ANNOUNCEMENT,
5780
- this.voiceaListenerCallbacks[VOICEAEVENTS.VOICEA_ANNOUNCEMENT]
5781
- );
6125
+ // @ts-ignore
6126
+ this.webex.internal.voicea.off(
6127
+ VOICEAEVENTS.VOICEA_ANNOUNCEMENT,
6128
+ this.voiceaListenerCallbacks[VOICEAEVENTS.VOICEA_ANNOUNCEMENT]
6129
+ );
5782
6130
 
5783
- // @ts-ignore
5784
- this.webex.internal.voicea.off(
5785
- VOICEAEVENTS.CAPTIONS_TURNED_ON,
5786
- this.voiceaListenerCallbacks[VOICEAEVENTS.CAPTIONS_TURNED_ON]
5787
- );
6131
+ // @ts-ignore
6132
+ this.webex.internal.voicea.off(
6133
+ VOICEAEVENTS.CAPTIONS_TURNED_ON,
6134
+ this.voiceaListenerCallbacks[VOICEAEVENTS.CAPTIONS_TURNED_ON]
6135
+ );
5788
6136
 
5789
- // @ts-ignore
5790
- this.webex.internal.voicea.off(
5791
- VOICEAEVENTS.EVA_COMMAND,
5792
- this.voiceaListenerCallbacks[VOICEAEVENTS.EVA_COMMAND]
5793
- );
6137
+ // @ts-ignore
6138
+ this.webex.internal.voicea.off(
6139
+ VOICEAEVENTS.EVA_COMMAND,
6140
+ this.voiceaListenerCallbacks[VOICEAEVENTS.EVA_COMMAND]
6141
+ );
5794
6142
 
5795
- // @ts-ignore
5796
- this.webex.internal.voicea.off(
5797
- VOICEAEVENTS.NEW_CAPTION,
5798
- this.voiceaListenerCallbacks[VOICEAEVENTS.NEW_CAPTION]
5799
- );
6143
+ // @ts-ignore
6144
+ this.webex.internal.voicea.off(
6145
+ VOICEAEVENTS.NEW_CAPTION,
6146
+ this.voiceaListenerCallbacks[VOICEAEVENTS.NEW_CAPTION]
6147
+ );
5800
6148
 
5801
- // @ts-ignore
5802
- this.webex.internal.voicea.deregisterEvents();
6149
+ // @ts-ignore
6150
+ this.webex.internal.voicea.deregisterEvents();
5803
6151
 
5804
- this.areVoiceaEventsSetup = false;
5805
- this.triggerStopReceivingTranscriptionEvent();
5806
- }
6152
+ this.areVoiceaEventsSetup = false;
6153
+ this.triggerStopReceivingTranscriptionEvent();
5807
6154
  }
5808
6155
 
5809
6156
  /**
@@ -5827,6 +6174,30 @@ export default class Meeting extends StatelessWebexPlugin {
5827
6174
  );
5828
6175
  }
5829
6176
 
6177
+ /**
6178
+ * Restores LLM subchannel subscriptions after reconnect when captions are active.
6179
+ * @returns {void}
6180
+ */
6181
+ private restoreLLMSubscriptionsIfNeeded(): void {
6182
+ try {
6183
+ // @ts-ignore
6184
+ const isCaptionBoxOn = this.webex.internal.voicea?.getIsCaptionBoxOn?.();
6185
+
6186
+ if (!isCaptionBoxOn) {
6187
+ return;
6188
+ }
6189
+
6190
+ // @ts-ignore
6191
+ this.webex.internal.voicea.updateSubchannelSubscriptions({subscribe: ['transcription']});
6192
+ } catch (error) {
6193
+ const msg = error?.message || String(error);
6194
+
6195
+ LoggerProxy.logger.warn(
6196
+ `Meeting:index#restoreLLMSubscriptionsIfNeeded --> failed to restore subscriptions after LLM online: ${msg}`
6197
+ );
6198
+ }
6199
+ }
6200
+
5830
6201
  /**
5831
6202
  * This is a callback for the LLM event that is triggered when it comes online
5832
6203
  * This method in turn will trigger an event to the developers that the LLM is connected
@@ -5835,8 +6206,9 @@ export default class Meeting extends StatelessWebexPlugin {
5835
6206
  * @returns {null}
5836
6207
  */
5837
6208
  private handleLLMOnline = (): void => {
5838
- // @ts-ignore
5839
- this.webex.internal.llm.off('online', this.handleLLMOnline);
6209
+ this.restoreLLMSubscriptionsIfNeeded();
6210
+ this.locusInfo.syncAllHashTreeDatasets({onlyLLM: true});
6211
+
5840
6212
  Trigger.trigger(
5841
6213
  this,
5842
6214
  {
@@ -6064,8 +6436,11 @@ export default class Meeting extends StatelessWebexPlugin {
6064
6436
  return Promise.reject(error);
6065
6437
  })
6066
6438
  .then((join) => {
6439
+ this.saveDataChannelToken(join);
6067
6440
  // @ts-ignore - config coming from registerPlugin
6068
6441
  if (this.config.enableAutomaticLLM) {
6442
+ // @ts-ignore
6443
+ this.webex.internal.llm.off('online', this.handleLLMOnline);
6069
6444
  // @ts-ignore
6070
6445
  this.webex.internal.llm.on('online', this.handleLLMOnline);
6071
6446
  this.updateLLMConnection()
@@ -6092,26 +6467,313 @@ export default class Meeting extends StatelessWebexPlugin {
6092
6467
  });
6093
6468
  }
6094
6469
 
6470
+ /** starts a timer that after a few minutes checks if
6471
+ * the LLM connection is connected, if not it sends a metric
6472
+ * @private
6473
+ * @returns {void}
6474
+ */
6475
+ private startLLMHealthCheckTimer() {
6476
+ // first cancel any existing timer
6477
+ this.clearLLMHealthCheckTimer();
6478
+
6479
+ this.llmHealthCheckTimer = setTimeout(() => {
6480
+ // @ts-ignore
6481
+ const isConnected = this.webex.internal.llm.isConnected();
6482
+
6483
+ if (!isConnected) {
6484
+ // @ts-ignore
6485
+ const {hasEverConnected} = this.webex.internal.llm;
6486
+
6487
+ // only send metric if not connected - to avoid too many metrics
6488
+ Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.LLM_HEALTHCHECK_FAILURE, {
6489
+ correlation_id: this.correlationId,
6490
+ hasEverConnected,
6491
+ });
6492
+ }
6493
+
6494
+ this.llmHealthCheckTimer = undefined;
6495
+ }, LLM_HEALTHCHECK_TIMER_MS);
6496
+ }
6497
+
6498
+ /**
6499
+ * Clears the LLM health check timer
6500
+ * @private
6501
+ * @returns {void}
6502
+ */
6503
+ private clearLLMHealthCheckTimer() {
6504
+ if (this.llmHealthCheckTimer) {
6505
+ clearTimeout(this.llmHealthCheckTimer);
6506
+ this.llmHealthCheckTimer = undefined;
6507
+ }
6508
+ }
6509
+
6510
+ /**
6511
+ * Removes LLM event listeners and clears the health check timer.
6512
+ * Must be called before Locus /leave to avoid unnecessary syncs triggered
6513
+ * by events received while leaving (per Locus team recommendation).
6514
+ * Idempotent: safe to call multiple times; .off() is a no-op when no
6515
+ * matching listener is registered.
6516
+ * @private
6517
+ * @returns {void}
6518
+ */
6519
+ private stopListeningForLLMEvents() {
6520
+ // @ts-ignore - fix types
6521
+ this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6522
+ // @ts-ignore - fix types
6523
+ this.webex.internal.llm.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6524
+ this.clearLLMHealthCheckTimer();
6525
+ }
6526
+
6527
+ /**
6528
+ * Stops listening on every event bus (LLM, Mercury, voicea/transcription,
6529
+ * annotation) that could otherwise deliver events to this meeting while
6530
+ * Locus is processing /leave or /end. Per the Locus team recommendation,
6531
+ * this must run before the Locus request is dispatched to avoid
6532
+ * unnecessary syncs triggered by in-flight events.
6533
+ *
6534
+ * Voicea (transcription) subscribes to llm 'event:relay.event' internally,
6535
+ * and the annotation plugin subscribes to both mercury and llm, so both
6536
+ * must be torn down alongside the direct LLM/Mercury listeners.
6537
+ *
6538
+ * Idempotent: safe to call multiple times; .off() is a no-op when no
6539
+ * matching listener is registered, and stopTranscription is guarded.
6540
+ * @private
6541
+ * @returns {void}
6542
+ */
6543
+ private stopListeningForMeetingEvents() {
6544
+ this.stopListeningForLLMEvents();
6545
+ this.stopListeningForMercuryEvents();
6546
+ if (this.transcription) {
6547
+ this.stopTranscription();
6548
+ this.transcription = undefined;
6549
+ }
6550
+ this.annotation.deregisterEvents();
6551
+ }
6552
+
6553
+ /**
6554
+ * Disconnects and cleans up the default LLM session listeners/timers.
6555
+ *
6556
+ * Ownership-aware: only calls `disconnectLLM` when this meeting is the
6557
+ * current owner of the default LLM session (or when no owner is recorded).
6558
+ * Event listeners belonging to this meeting instance are always detached
6559
+ * so they do not receive another meeting's relay events.
6560
+ *
6561
+ * @param {Object} options
6562
+ * @param {boolean} [options.removeOnlineListener=true] removes the one-time online listener
6563
+ * @param {boolean} [options.throwOnError=true] rethrows disconnect errors when true
6564
+ * @returns {Promise<void>}
6565
+ */
6566
+ private cleanupLLMConneciton = async ({
6567
+ removeOnlineListener = true,
6568
+ throwOnError = true,
6569
+ }: {
6570
+ removeOnlineListener?: boolean;
6571
+ throwOnError?: boolean;
6572
+ } = {}): Promise<void> => {
6573
+ // @ts-ignore - Fix type
6574
+ // @ts-ignore - Fix type
6575
+ const {currentOwner, isOwner} = this.webex.internal.llm.resolveSessionOwnership(
6576
+ this.id,
6577
+ LLM_DEFAULT_SESSION
6578
+ );
6579
+
6580
+ try {
6581
+ if (isOwner) {
6582
+ // @ts-ignore - Fix type
6583
+ await this.webex.internal.llm.disconnectLLM(
6584
+ {
6585
+ code: 3050,
6586
+ reason: 'done (permanent)',
6587
+ },
6588
+ LLM_DEFAULT_SESSION,
6589
+ this.id
6590
+ );
6591
+ } else {
6592
+ LoggerProxy.logger.info(
6593
+ `Meeting:index#cleanupLLMConneciton --> skipping disconnect; LLM owned by meeting ${currentOwner}, not ${this.id}`
6594
+ );
6595
+ }
6596
+ } catch (error) {
6597
+ LoggerProxy.logger.error(
6598
+ 'Meeting:index#cleanupLLMConneciton --> Failed to disconnect default LLM session',
6599
+ error
6600
+ );
6601
+
6602
+ if (throwOnError) {
6603
+ throw error;
6604
+ }
6605
+ } finally {
6606
+ if (removeOnlineListener) {
6607
+ // @ts-ignore - Fix type
6608
+ this.webex.internal.llm.off('online', this.handleLLMOnline);
6609
+ }
6610
+ this.stopListeningForLLMEvents();
6611
+
6612
+ // Re-check ownership after awaiting disconnectLLM. If ownership changed
6613
+ // while cleanup was in flight, do not clear another meeting's owner tag.
6614
+ if (isOwner) {
6615
+ const {currentOwner: currentOwnerAfterCleanup} =
6616
+ // @ts-ignore - Fix type
6617
+ this.webex.internal.llm.resolveSessionOwnership(this.id, LLM_DEFAULT_SESSION);
6618
+
6619
+ if (currentOwnerAfterCleanup === this.id) {
6620
+ // @ts-ignore - Fix type
6621
+ this.webex.internal.llm.setOwnerMeetingId?.(undefined);
6622
+ }
6623
+ }
6624
+ }
6625
+ };
6626
+
6627
+ /**
6628
+ * Clears data channel tokens associated with this meeting ownership.
6629
+ * Ownership checks are enforced in internal-plugin-llm.
6630
+ * @returns {void}
6631
+ */
6632
+ clearDataChannelToken(): void {
6633
+ // @ts-ignore
6634
+ this.webex.internal.llm.clearDatachannelToken(LLM_DEFAULT_SESSION, this.id);
6635
+ // @ts-ignore
6636
+ this.webex.internal.llm.clearDatachannelToken(LLM_PRACTICE_SESSION, this.id);
6637
+ }
6638
+
6639
+ /**
6640
+ * Saves the data channel tokens from the join response into LLM so that
6641
+ * updateLLMConnection / updatePSDataChannel don't need to fetch them from locusInfo.
6642
+ * @param {Object} join - The parsed join response (from MeetingUtil.parseLocusJoin)
6643
+ * @returns {void}
6644
+ */
6645
+ saveDataChannelToken(join: any): void {
6646
+ const datachannelToken = join?.locus?.self?.datachannelToken;
6647
+ const practiceSessionDatachannelToken = join?.locus?.self?.practiceSessionDatachannelToken;
6648
+
6649
+ if (datachannelToken) {
6650
+ // @ts-ignore
6651
+ this.webex.internal.llm.setDatachannelToken(datachannelToken, LLM_DEFAULT_SESSION, this.id);
6652
+ }
6653
+
6654
+ if (practiceSessionDatachannelToken) {
6655
+ // @ts-ignore
6656
+ this.webex.internal.llm.setDatachannelToken(
6657
+ practiceSessionDatachannelToken,
6658
+ LLM_PRACTICE_SESSION,
6659
+ this.id
6660
+ );
6661
+ }
6662
+ }
6663
+
6664
+ /**
6665
+ * Ensures default-session data channel token exists after lobby admission.
6666
+ * Some lobby users do not receive a token until they are admitted.
6667
+ * @returns {Promise<boolean>} true when a new token is fetched and cached
6668
+ */
6669
+ private async ensureDefaultDatachannelTokenAfterAdmit(): Promise<boolean> {
6670
+ try {
6671
+ // @ts-ignore
6672
+ const datachannelToken = this.webex.internal.llm.getDatachannelToken(
6673
+ LLM_DEFAULT_SESSION,
6674
+ this.id
6675
+ );
6676
+ // @ts-ignore
6677
+ const isDataChannelTokenEnabled = await this.webex.internal.llm.isDataChannelTokenEnabled();
6678
+
6679
+ if (!isDataChannelTokenEnabled || datachannelToken) {
6680
+ return false;
6681
+ }
6682
+
6683
+ const response = await this.meetingRequest.fetchDatachannelToken({
6684
+ locusUrl: this.locusUrl,
6685
+ requestingParticipantId: this.members.selfId,
6686
+ isPracticeSession: false,
6687
+ });
6688
+ const fetchedDatachannelToken = response?.body?.datachannelToken;
6689
+
6690
+ if (!fetchedDatachannelToken) {
6691
+ return false;
6692
+ }
6693
+
6694
+ // @ts-ignore
6695
+ this.webex.internal.llm.setDatachannelToken(
6696
+ fetchedDatachannelToken,
6697
+ LLM_DEFAULT_SESSION,
6698
+ this.id
6699
+ );
6700
+
6701
+ return true;
6702
+ } catch (error) {
6703
+ const msg = error?.message || String(error);
6704
+
6705
+ LoggerProxy.logger.warn(
6706
+ `Meeting:index#ensureDefaultDatachannelTokenAfterAdmit --> failed to proactively fetch default data channel token after admit: ${msg}`,
6707
+ {statusCode: error?.statusCode}
6708
+ );
6709
+
6710
+ return false;
6711
+ }
6712
+ }
6713
+
6095
6714
  /**
6096
6715
  * Connects to low latency mercury and reconnects if the address has changed
6097
6716
  * It will also disconnect if called when the meeting has ended
6098
- * @param {String} datachannelUrl
6099
6717
  * @returns {Promise}
6100
6718
  */
6101
6719
  async updateLLMConnection() {
6102
6720
  // @ts-ignore - Fix type
6103
- const {url, info: {datachannelUrl, practiceSessionDatachannelUrl} = {}} = this.locusInfo;
6721
+ const {url = undefined, info: {datachannelUrl = undefined} = {}} = this.locusInfo || {};
6104
6722
 
6105
6723
  const isJoined = this.isJoined();
6106
6724
 
6107
- // webinar panelist should use new data channel in practice session
6108
- const dataChannelUrl =
6109
- this.webinar.isJoinPracticeSessionDataChannel() && practiceSessionDatachannelUrl
6110
- ? practiceSessionDatachannelUrl
6111
- : datachannelUrl;
6725
+ const dataChannelUrl = datachannelUrl;
6112
6726
 
6727
+ // Ownership guard: when the default LLM session is already connected and
6728
+ // owned by a *different* Meeting instance, do not disconnect or reconfigure
6729
+ // it. Another meeting's `updateLLMConnection` must be ignored here to
6730
+ // avoid killing the socket it relies on. We only proceed to manage the
6731
+ // connection when this meeting is the current owner, or when no owner is
6732
+ // set yet (first claim).
6113
6733
  // @ts-ignore - Fix type
6114
- if (this.webex.internal.llm.isConnected()) {
6734
+ const {currentOwner} = this.webex.internal.llm.resolveSessionOwnership(
6735
+ this.id,
6736
+ LLM_DEFAULT_SESSION
6737
+ );
6738
+
6739
+ // Capture connectivity before any reconnect attempt. If LLM was already
6740
+ // connected, we must respect current ownership. If it was disconnected,
6741
+ // this flow may reclaim stale owner tags after a fresh connect.
6742
+ // @ts-ignore - Fix type
6743
+ const wasConnected = this.webex.internal.llm.isConnected();
6744
+
6745
+ // Prefer ownership-scoped token read. For disconnected stale-owner reclaim
6746
+ // flows, fallback to ownerless read so initial register can still carry a
6747
+ // token and recover from stale ownership without 401/403 dead-end.
6748
+ // @ts-ignore - Fix type
6749
+ let datachannelToken = this.webex.internal.llm.getDatachannelToken(
6750
+ LLM_DEFAULT_SESSION,
6751
+ this.id
6752
+ );
6753
+
6754
+ if (!datachannelToken && !wasConnected && currentOwner && currentOwner !== this.id) {
6755
+ // @ts-ignore - Fix type
6756
+ datachannelToken = this.webex.internal.llm.getDatachannelToken(LLM_DEFAULT_SESSION);
6757
+ }
6758
+
6759
+ // @ts-ignore - Fix type
6760
+ if (wasConnected) {
6761
+ if (currentOwner && currentOwner !== this.id) {
6762
+ // Another meeting owns the live LLM socket. We must not disconnect
6763
+ // or reconfigure it -- doing so would tear down a session the
6764
+ // owning meeting still relies on. Locus/datachannel URL mismatch is
6765
+ // expected here (each meeting has its own locus URL) and is NOT a
6766
+ // valid signal of staleness, so we never reclaim from this path.
6767
+ // The only safe reclaim mechanism is the `finally`-block owner-tag
6768
+ // release in `cleanupLLMConneciton`, which fires when this meeting
6769
+ // itself is being torn down.
6770
+ LoggerProxy.logger.info(
6771
+ `Meeting:index#updateLLMConnection --> skipping; LLM owned by meeting ${currentOwner}, not ${this.id}`
6772
+ );
6773
+
6774
+ return undefined;
6775
+ }
6776
+
6115
6777
  if (
6116
6778
  // @ts-ignore - Fix type
6117
6779
  url === this.webex.internal.llm.getLocusUrl() &&
@@ -6121,29 +6783,63 @@ export default class Meeting extends StatelessWebexPlugin {
6121
6783
  ) {
6122
6784
  return undefined;
6123
6785
  }
6124
- // @ts-ignore - Fix type
6125
- await this.webex.internal.llm.disconnectLLM(
6126
- isJoined
6127
- ? {
6128
- code: 3050,
6129
- reason: 'done (permanent)',
6130
- }
6131
- : undefined
6132
- );
6133
- // @ts-ignore - Fix type
6134
- this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6135
- // @ts-ignore - Fix type
6136
- this.webex.internal.llm.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6786
+ await this.cleanupLLMConneciton({removeOnlineListener: false});
6137
6787
  }
6138
6788
 
6139
6789
  if (!isJoined) {
6140
6790
  return undefined;
6141
6791
  }
6142
6792
 
6793
+ // Bind refresh handler before registration so interceptor-triggered token
6794
+ // refresh during register POST can resolve a valid handler.
6795
+ // Prefer this meeting as owner, but allow owner-less fallback when a stale
6796
+ // foreign owner tag is present on a disconnected session.
6797
+ const refreshHandlerOwnerMeetingId =
6798
+ currentOwner && currentOwner !== this.id ? undefined : this.id;
6799
+ const shouldAlignRefreshHandlerAfterOwnershipClaim = refreshHandlerOwnerMeetingId !== this.id;
6800
+ // @ts-ignore - Fix type
6801
+ this.webex.internal.llm.setRefreshHandler(
6802
+ () => this.refreshDataChannelToken(),
6803
+ LLM_DEFAULT_SESSION,
6804
+ refreshHandlerOwnerMeetingId
6805
+ );
6806
+
6143
6807
  // @ts-ignore - Fix type
6144
6808
  return this.webex.internal.llm
6145
- .registerAndConnect(url, dataChannelUrl)
6809
+ .registerAndConnect(url, dataChannelUrl, datachannelToken)
6146
6810
  .then((registerAndConnectResult) => {
6811
+ this.locusInfo.syncAllHashTreeDatasets({onlyLLM: true});
6812
+ // Record ownership of the default LLM session for this meeting so
6813
+ // subsequent cross-meeting `updateLLMConnection` / `cleanupLLMConneciton`
6814
+ // calls can detect and skip work that doesn't belong to them.
6815
+ // @ts-ignore - Fix type
6816
+ const {isOwner} = this.webex.internal.llm.resolveSessionOwnership(
6817
+ this.id,
6818
+ LLM_DEFAULT_SESSION
6819
+ );
6820
+ const canReclaimAfterDisconnectedStart = !wasConnected;
6821
+
6822
+ // Refresh handler is pre-bound before registerAndConnect so token
6823
+ // refresh can work even during the registration request itself.
6824
+ if (isOwner || canReclaimAfterDisconnectedStart) {
6825
+ // Record ownership of the default LLM session for this meeting so
6826
+ // subsequent cross-meeting `updateLLMConnection` / `cleanupLLMConneciton`
6827
+ // calls can detect and skip work that doesn't belong to them.
6828
+ // @ts-ignore - Fix type
6829
+ this.webex.internal.llm.setOwnerMeetingId?.(this.id);
6830
+
6831
+ // If we pre-bound refresh ownerlessly (stale-owner reclaim path),
6832
+ // align the handler with the newly claimed owner immediately after
6833
+ // ownership is updated.
6834
+ if (shouldAlignRefreshHandlerAfterOwnershipClaim) {
6835
+ // @ts-ignore - Fix type
6836
+ this.webex.internal.llm.setRefreshHandler(
6837
+ () => this.refreshDataChannelToken(),
6838
+ LLM_DEFAULT_SESSION,
6839
+ this.id
6840
+ );
6841
+ }
6842
+ }
6147
6843
  // @ts-ignore - Fix type
6148
6844
  this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6149
6845
  // @ts-ignore - Fix type
@@ -6156,6 +6852,8 @@ export default class Meeting extends StatelessWebexPlugin {
6156
6852
  'Meeting:index#updateLLMConnection --> enabled to receive relay events!'
6157
6853
  );
6158
6854
 
6855
+ this.startLLMHealthCheckTimer();
6856
+
6159
6857
  return Promise.resolve(registerAndConnectResult);
6160
6858
  });
6161
6859
  }
@@ -7182,23 +7880,87 @@ export default class Meeting extends StatelessWebexPlugin {
7182
7880
  }
7183
7881
  }
7184
7882
  });
7883
+ this.statsAnalyzer.on(StatsAnalyzerEventNames.STATS_UPDATE, (data) => {
7884
+ // Extract srtpCipher from transport stats
7885
+ let srtpCipher: string | undefined;
7886
+ for (const stats of data.stats.values()) {
7887
+ if (stats.type === 'transport' && stats.srtpCipher) {
7888
+ srtpCipher = stats.srtpCipher as string;
7889
+ break;
7890
+ }
7891
+ }
7892
+
7893
+ // Only emit event if srtpCipher has changed
7894
+ if (srtpCipher && srtpCipher !== this.mediaProperties.srtpCipher) {
7895
+ LoggerProxy.logger.info(
7896
+ `Meeting:index#setupStatsAnalyzerEventHandlers --> SRTP cipher changed from ${this.mediaProperties.srtpCipher} to ${srtpCipher}`
7897
+ );
7898
+ this.mediaProperties.srtpCipher = srtpCipher;
7899
+ Trigger.trigger(
7900
+ this,
7901
+ {
7902
+ file: 'meeting/index',
7903
+ function: 'setupStatsAnalyzerEventHandlers',
7904
+ },
7905
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
7906
+ {srtpCipher}
7907
+ );
7908
+ }
7909
+ });
7185
7910
  };
7186
7911
 
7187
7912
  getMediaConnectionDebugId() {
7188
7913
  return `MC-${this.id.substring(0, 4)}`;
7189
7914
  }
7190
7915
 
7916
+ /**
7917
+ * Determines if the next media attempt should use only TURN-TLS (iceTransportPolicy='relay').
7918
+ * We do this in the hope that it will minimize the chance of Homer sending DTLS packets on a wrong
7919
+ * transport (as there will be only 1 transport) and dealing with firewalls that let STUN packets through, but block
7920
+ * other UDP traffic.
7921
+ *
7922
+ * For clients landing on video mesh nodes (VMN), reachability might still have successful TLS (to public nodes)
7923
+ * but TURN discovery will result in empty TURN urls array and iceTransportPolicy='relay' will still be overriden to undefined,
7924
+ * see the code in establishMediaConnection()
7925
+ *
7926
+ * @param {Error} prevError - The error from the previous addMedia attempt
7927
+ * @returns {Promise<boolean>}
7928
+ */
7929
+ private async shouldRetryMediaWithOnlyTurnTLS(prevError: Error | undefined): Promise<boolean> {
7930
+ if (
7931
+ this.isMultistream &&
7932
+ prevError instanceof AddMediaFailed &&
7933
+ prevError.isDtlsHandshakeFailure &&
7934
+ prevError.connectionType === 'UDP'
7935
+ ) {
7936
+ const hasTlsReachability =
7937
+ // @ts-ignore
7938
+ await this.webex.meetings.reachability.isAnyClusterReachableViaProtocol('xtls');
7939
+
7940
+ if (hasTlsReachability) {
7941
+ LoggerProxy.logger.info(
7942
+ 'Meeting:index#shouldRetryMediaWithOnlyTurnTLS --> previous attempt failed due to DTLS handshake failure over UDP and TLS reachability is available'
7943
+ );
7944
+
7945
+ return true;
7946
+ }
7947
+ }
7948
+
7949
+ return false;
7950
+ }
7951
+
7191
7952
  /**
7192
7953
  * Creates a webrtc media connection and publishes streams to it
7193
7954
  *
7194
7955
  * @param {Object} turnServerInfo TURN server information
7195
7956
  * @param {BundlePolicy} [bundlePolicy] Bundle policy settings
7196
- * @param {AddMediaOptions} [options] Options for enabling/disabling audio/video
7957
+ * @param {RTCIceTransportPolicy} [iceTransportPolicy] ICE transport policy override
7197
7958
  * @returns {RoapMediaConnection | MultistreamRoapMediaConnection}
7198
7959
  */
7199
7960
  private async createMediaConnection(
7200
7961
  turnServerInfo?: TurnServerInfo,
7201
- bundlePolicy?: BundlePolicy
7962
+ bundlePolicy?: BundlePolicy,
7963
+ iceTransportPolicy?: RTCIceTransportPolicy
7202
7964
  ) {
7203
7965
  this.rtcMetrics = this.isMultistream
7204
7966
  ? // @ts-ignore
@@ -7222,12 +7984,15 @@ export default class Meeting extends StatelessWebexPlugin {
7222
7984
  enableExtmap: this.config.enableExtmap,
7223
7985
  turnServerInfo,
7224
7986
  bundlePolicy,
7987
+ iceTransportPolicy,
7225
7988
  // @ts-ignore - config coming from registerPlugin
7226
7989
  iceCandidatesTimeout: this.config.iceCandidatesGatheringTimeout,
7227
7990
  // @ts-ignore - config coming from registerPlugin
7228
7991
  disableAudioMainDtx: this.config.experimental.disableAudioMainDtx,
7229
7992
  // @ts-ignore - config coming from registerPlugin
7230
7993
  enableAudioTwcc: this.config.enableAudioTwccForMultistream,
7994
+ // @ts-ignore - config coming from registerPlugin
7995
+ enableAv1SlidesSupport: this.config.enableAv1SlidesSupport,
7231
7996
  stopIceGatheringAfterFirstRelayCandidate:
7232
7997
  // @ts-ignore - config coming from registerPlugin
7233
7998
  this.config.stopIceGatheringAfterFirstRelayCandidate,
@@ -7344,9 +8109,9 @@ export default class Meeting extends StatelessWebexPlugin {
7344
8109
  */
7345
8110
  private async waitForMediaConnectionConnected(): Promise<void> {
7346
8111
  try {
7347
- await this.mediaProperties.waitForMediaConnectionConnected();
8112
+ await this.mediaProperties.waitForMediaConnectionConnected(this.correlationId);
7348
8113
  } catch (error) {
7349
- const {iceConnected} = error;
8114
+ const {iceConnected} = error as MediaConnectionAwaiterFailureResult;
7350
8115
 
7351
8116
  if (!this.hasMediaConnectionConnectedAtLeastOnce) {
7352
8117
  // Only send CA event for join flow if we haven't successfully connected media yet
@@ -7386,13 +8151,12 @@ export default class Meeting extends StatelessWebexPlugin {
7386
8151
  });
7387
8152
  }
7388
8153
 
7389
- const timedOutError = new Error(
7390
- `Timed out waiting for media connection to be connected, correlationId=${this.correlationId}`
8154
+ throw new MediaConnectionTimedOutError(
8155
+ `Timed out waiting for media connection to be connected, correlationId=${this.correlationId}`,
8156
+ iceConnected,
8157
+ // keep reference to the original rejected result (which is the object the SDK reports to CA as rawError above)
8158
+ error
7391
8159
  );
7392
-
7393
- timedOutError.cause = error;
7394
-
7395
- throw timedOutError;
7396
8160
  }
7397
8161
  }
7398
8162
 
@@ -7605,7 +8369,18 @@ export default class Meeting extends StatelessWebexPlugin {
7605
8369
  error
7606
8370
  );
7607
8371
 
7608
- throw new AddMediaFailed(error);
8372
+ const {connectionType, selectedCandidatePairChanges, numTransports} =
8373
+ await this.mediaProperties.getCurrentConnectionInfo();
8374
+
8375
+ const iceConnected = error instanceof MediaConnectionTimedOutError && error.iceConnected;
8376
+
8377
+ throw new AddMediaFailed({
8378
+ cause: error,
8379
+ connectionType,
8380
+ selectedCandidatePairChanges,
8381
+ numTransports,
8382
+ iceConnected,
8383
+ });
7609
8384
  }
7610
8385
  }
7611
8386
 
@@ -7680,7 +8455,21 @@ export default class Meeting extends StatelessWebexPlugin {
7680
8455
  ({turnServerInfo} = await this.doTurnDiscovery(isReconnecting, isForced));
7681
8456
  }
7682
8457
 
7683
- const mc = await this.createMediaConnection(turnServerInfo, bundlePolicy);
8458
+ if (
8459
+ (!turnServerInfo || !turnServerInfo.urls?.length) &&
8460
+ this.addMediaData.iceTransportPolicy === 'relay'
8461
+ ) {
8462
+ LoggerProxy.logger.info(
8463
+ `${LOG_HEADER} cannot do iceTransportPolicy=relay, because there is no turn server info available`
8464
+ );
8465
+ // drop the forced relay policy and use the default, because we don't have a TURN server
8466
+ this.addMediaData.iceTransportPolicy = undefined;
8467
+ }
8468
+ const mediaConnection = await this.createMediaConnection(
8469
+ turnServerInfo,
8470
+ bundlePolicy,
8471
+ this.addMediaData.iceTransportPolicy
8472
+ );
7684
8473
 
7685
8474
  LoggerProxy.logger.info(
7686
8475
  `${LOG_HEADER} media connection created this.isMultistream=${this.isMultistream}`
@@ -7717,7 +8506,7 @@ export default class Meeting extends StatelessWebexPlugin {
7717
8506
  await this.remoteMediaManager.start();
7718
8507
  }
7719
8508
 
7720
- await mc.initiateOffer();
8509
+ await mediaConnection.initiateOffer();
7721
8510
 
7722
8511
  await this.waitForRemoteSDPAnswer();
7723
8512
 
@@ -7785,6 +8574,9 @@ export default class Meeting extends StatelessWebexPlugin {
7785
8574
 
7786
8575
  this.isMultistream = false;
7787
8576
 
8577
+ // reset iceTransportPolicy, because it's only applied for multistream media connections
8578
+ this.addMediaData.iceTransportPolicy = undefined;
8579
+
7788
8580
  if (this.mediaProperties.webrtcMediaConnection) {
7789
8581
  // close peer connection, but don't reset mute state information, because we will want to use it on the retry
7790
8582
  this.closePeerConnections(false);
@@ -7865,6 +8657,8 @@ export default class Meeting extends StatelessWebexPlugin {
7865
8657
  regionCode: this.webex.meetings.geoHintInfo?.regionCode,
7866
8658
  },
7867
8659
  preferTranscoding: !this.isMultistream,
8660
+ getCurrentSelfUrl: () => this.selfUrl,
8661
+ waitForSelfUrlChange: () => this.waitForSelfUrlChange(),
7868
8662
  },
7869
8663
  {
7870
8664
  // @ts-ignore
@@ -7873,6 +8667,29 @@ export default class Meeting extends StatelessWebexPlugin {
7873
8667
  );
7874
8668
  }
7875
8669
 
8670
+ /**
8671
+ * Waits for LocusInfo to update meeting.selfUrl, with a timeout fallback.
8672
+ * @returns {Promise<void>}
8673
+ * @private
8674
+ * @memberof Meeting
8675
+ */
8676
+ private waitForSelfUrlChange(): Promise<void> {
8677
+ if (!this.promisesWaitingForPropUpdate.selfUrl) {
8678
+ const pendingSelfUrlUpdate = new Defer();
8679
+
8680
+ this.promisesWaitingForPropUpdate.selfUrl = pendingSelfUrlUpdate;
8681
+
8682
+ setTimeout(() => {
8683
+ if (this.promisesWaitingForPropUpdate.selfUrl === pendingSelfUrlUpdate) {
8684
+ delete this.promisesWaitingForPropUpdate.selfUrl;
8685
+ pendingSelfUrlUpdate.resolve();
8686
+ }
8687
+ }, 5000);
8688
+ }
8689
+
8690
+ return this.promisesWaitingForPropUpdate.selfUrl.promise;
8691
+ }
8692
+
7876
8693
  /**
7877
8694
  * Creates a media connection to the server. Media connection is required for sending or receiving any audio/video.
7878
8695
  *
@@ -7884,8 +8701,9 @@ export default class Meeting extends StatelessWebexPlugin {
7884
8701
  addMedia(options: AddMediaOptions = {}): Promise<void> {
7885
8702
  return this.addMediaInternal(
7886
8703
  () => (this.turnServerUsed ? 'JOIN_MEETING_FINAL' : 'JOIN_MEETING_RETRY'),
7887
- undefined,
7888
8704
  false,
8705
+ undefined /* turnServerInfo - it will be fetched via doTurnDiscovery() */,
8706
+ undefined /* iceTransportPolicy - we're relying on the default value */,
7889
8707
  options
7890
8708
  );
7891
8709
  }
@@ -7894,8 +8712,9 @@ export default class Meeting extends StatelessWebexPlugin {
7894
8712
  * Internal version of addMedia() with some more arguments for finer control of its behavior
7895
8713
  *
7896
8714
  * @param {Function} icePhaseCallback - callback to determine the icePhase for CA "client.ice.end" failure events
7897
- * @param {TurnServerInfo} turnServerInfo - TURN server information
7898
8715
  * @param {boolean} forceTurnDiscovery - if true, TURN discovery will be done
8716
+ * @param {TurnServerInfo} turnServerInfo - TURN server information
8717
+ * @param {RTCIceTransportPolicy} [iceTransportPolicy] - ICE transport policy override
7899
8718
  * @param {AddMediaOptions} options - same as options of the public addMedia() method
7900
8719
  * @returns {Promise<void>}
7901
8720
  * @protected
@@ -7903,12 +8722,14 @@ export default class Meeting extends StatelessWebexPlugin {
7903
8722
  */
7904
8723
  protected async addMediaInternal(
7905
8724
  icePhaseCallback: () => string,
7906
- turnServerInfo: TurnServerInfo,
7907
- forceTurnDiscovery,
8725
+ forceTurnDiscovery: boolean,
8726
+ turnServerInfo?: TurnServerInfo,
8727
+ iceTransportPolicy?: RTCIceTransportPolicy,
7908
8728
  options: AddMediaOptions = {}
7909
8729
  ): Promise<void> {
7910
8730
  this.addMediaData.retriedWithTurnServer = false;
7911
8731
  this.addMediaData.icePhaseCallback = icePhaseCallback;
8732
+ this.addMediaData.iceTransportPolicy = iceTransportPolicy;
7912
8733
 
7913
8734
  this.hasMediaConnectionConnectedAtLeastOnce = false;
7914
8735
  const LOG_HEADER = 'Meeting:index#addMedia -->';
@@ -7917,7 +8738,7 @@ export default class Meeting extends StatelessWebexPlugin {
7917
8738
  options
7918
8739
  )}, turnServerInfo=${JSON.stringify(
7919
8740
  turnServerInfo
7920
- )}, forceTurnDiscovery=${forceTurnDiscovery}`
8741
+ )}, forceTurnDiscovery=${forceTurnDiscovery}, iceTransportPolicy=${iceTransportPolicy}`
7921
8742
  );
7922
8743
 
7923
8744
  if (options.allowMediaInLobby !== true && this.meetingState !== FULL_STATE.ACTIVE) {
@@ -7937,6 +8758,7 @@ export default class Meeting extends StatelessWebexPlugin {
7937
8758
  remoteMediaManagerConfig,
7938
8759
  bundlePolicy = 'max-bundle',
7939
8760
  additionalMediaOptions = {},
8761
+ allowPublishMediaInLobby = false,
7940
8762
  } = options;
7941
8763
 
7942
8764
  const {
@@ -7957,7 +8779,6 @@ export default class Meeting extends StatelessWebexPlugin {
7957
8779
  const ipver = MeetingUtil.getIpVersion(this.webex); // used just for metrics
7958
8780
 
7959
8781
  // If the user is unjoined or guest waiting in lobby dont allow the user to addMedia
7960
- // @ts-ignore - isUserUnadmitted coming from SelfUtil
7961
8782
  if (this.isUserUnadmitted && !this.wirelessShare && !this.allowMediaInLobby) {
7962
8783
  throw new UserInLobbyError();
7963
8784
  }
@@ -8002,7 +8823,13 @@ export default class Meeting extends StatelessWebexPlugin {
8002
8823
  this.brbState = createBrbState(this, false);
8003
8824
 
8004
8825
  try {
8005
- await this.setUpLocalStreamReferences(localStreams);
8826
+ // if we're in a lobby and allowPublishMediaInLobby==false, we don't want to
8827
+ // setup local streams for publishing, because if we ever end up admitted to the meeting
8828
+ // but Locus event about it for us is delayed or missed, others could see/hear our user's video/audio
8829
+ // while the user would still think they're in the lobby
8830
+ if (allowPublishMediaInLobby || !this.isUserUnadmitted) {
8831
+ await this.setUpLocalStreamReferences(localStreams);
8832
+ }
8006
8833
 
8007
8834
  this.setMercuryListener();
8008
8835
 
@@ -8025,12 +8852,7 @@ export default class Meeting extends StatelessWebexPlugin {
8025
8852
 
8026
8853
  // Establish new media connection with forced TURN discovery
8027
8854
  // 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
8028
- await this.establishMediaConnection(
8029
- remoteMediaManagerConfig,
8030
- bundlePolicy,
8031
- true,
8032
- undefined
8033
- );
8855
+ await this.establishMediaConnection(remoteMediaManagerConfig, bundlePolicy, true);
8034
8856
  } else {
8035
8857
  throw error;
8036
8858
  }
@@ -8059,7 +8881,8 @@ export default class Meeting extends StatelessWebexPlugin {
8059
8881
  numTransports,
8060
8882
  isMultistream: this.isMultistream,
8061
8883
  retriedWithTurnServer: this.addMediaData.retriedWithTurnServer,
8062
- isJoinWithMediaRetry: this.joinWithMediaRetryInfo.isRetry,
8884
+ isJoinWithMediaRetry: this.joinWithMediaRetryInfo.retryCount > 0,
8885
+ iceTransportPolicy: this.addMediaData.iceTransportPolicy || 'all',
8063
8886
  ...reachabilityMetrics,
8064
8887
  ...iceCandidateErrors,
8065
8888
  iceCandidatesCount: this.iceCandidatesCount,
@@ -8081,14 +8904,16 @@ export default class Meeting extends StatelessWebexPlugin {
8081
8904
  // We can log ReceiveSlot SSRCs only after the SDP exchange, so doing it here:
8082
8905
  this.remoteMediaManager?.logAllReceiveSlots();
8083
8906
  this.startPeriodicLogUpload();
8084
- } catch (error) {
8907
+ } catch (error: any) {
8085
8908
  LoggerProxy.logger.error(`${LOG_HEADER} failed to establish media connection: `, error);
8086
8909
 
8087
8910
  // @ts-ignore
8088
8911
  const reachabilityMetrics = await this.getMediaReachabilityMetricFields();
8089
8912
 
8090
- const {selectedCandidatePairChanges, numTransports} =
8091
- await this.mediaProperties.getCurrentConnectionInfo();
8913
+ const {connectionType, selectedCandidatePairChanges, numTransports} =
8914
+ error instanceof AddMediaFailed
8915
+ ? error
8916
+ : await this.mediaProperties.getCurrentConnectionInfo();
8092
8917
 
8093
8918
  const iceCandidateErrors = Object.fromEntries(this.iceCandidateErrors);
8094
8919
 
@@ -8104,7 +8929,8 @@ export default class Meeting extends StatelessWebexPlugin {
8104
8929
  turnServerUsed: this.turnServerUsed,
8105
8930
  retriedWithTurnServer: this.addMediaData.retriedWithTurnServer,
8106
8931
  isMultistream: this.isMultistream,
8107
- isJoinWithMediaRetry: this.joinWithMediaRetryInfo.isRetry,
8932
+ isJoinWithMediaRetry: this.joinWithMediaRetryInfo.retryCount > 0,
8933
+ iceTransportPolicy: this.addMediaData.iceTransportPolicy || 'all',
8108
8934
  signalingState:
8109
8935
  this.mediaProperties.webrtcMediaConnection?.multistreamConnection?.pc?.pc
8110
8936
  ?.signalingState ||
@@ -8120,6 +8946,7 @@ export default class Meeting extends StatelessWebexPlugin {
8120
8946
  ?.iceConnectionState ||
8121
8947
  this.mediaProperties.webrtcMediaConnection?.mediaConnection?.pc?.iceConnectionState ||
8122
8948
  'unknown',
8949
+ connectionType,
8123
8950
  ...reachabilityMetrics,
8124
8951
  ...iceCandidateErrors,
8125
8952
  iceCandidatesCount: this.iceCandidatesCount,
@@ -8468,14 +9295,15 @@ export default class Meeting extends StatelessWebexPlugin {
8468
9295
  options: {meetingId: this.id},
8469
9296
  });
8470
9297
  LoggerProxy.logger.log('Meeting:index#leave --> Leaving a meeting');
9298
+ this.stopListeningForMeetingEvents();
8471
9299
 
8472
9300
  return MeetingUtil.leaveMeeting(this, options)
8473
- .then((leave) => {
9301
+ .then(async (leave) => {
8474
9302
  // CA team recommends submitting this *after* locus /leave
8475
9303
  submitLeaveMetric();
8476
9304
 
8477
9305
  this.meetingFiniteStateMachine.leave();
8478
- this.clearMeetingData();
9306
+ await this.clearMeetingData();
8479
9307
 
8480
9308
  // upload logs on leave irrespective of meeting delete
8481
9309
  Trigger.trigger(
@@ -9333,11 +10161,13 @@ export default class Meeting extends StatelessWebexPlugin {
9333
10161
  locus_id: this.locusId,
9334
10162
  });
9335
10163
 
10164
+ this.stopListeningForMeetingEvents();
10165
+
9336
10166
  return MeetingUtil.endMeetingForAll(this)
9337
- .then((end) => {
10167
+ .then(async (end) => {
9338
10168
  this.meetingFiniteStateMachine.end();
9339
10169
 
9340
- this.clearMeetingData();
10170
+ await this.clearMeetingData();
9341
10171
  // upload logs on leave irrespective of meeting delete
9342
10172
  Trigger.trigger(
9343
10173
  this,
@@ -9385,7 +10215,7 @@ export default class Meeting extends StatelessWebexPlugin {
9385
10215
  * @public
9386
10216
  * @memberof Meeting
9387
10217
  */
9388
- clearMeetingData = () => {
10218
+ clearMeetingData = async () => {
9389
10219
  this.audio = null;
9390
10220
  this.video = null;
9391
10221
  this.screenShareFloorState = ScreenShareFloorStatus.RELEASED;
@@ -9394,17 +10224,16 @@ export default class Meeting extends StatelessWebexPlugin {
9394
10224
  }
9395
10225
  this.queuedMediaUpdates = [];
9396
10226
 
9397
- if (this.transcription) {
9398
- this.stopTranscription();
9399
- this.transcription = undefined;
9400
- }
10227
+ // Listener teardown (transcription, annotation, llm/mercury) runs in
10228
+ // stopListeningForMeetingEvents() before /leave and /end so events
10229
+ // received mid-teardown do not trigger Locus syncs. Calling it here
10230
+ // again would double-emit MEETING_STOPPED_RECEIVING_TRANSCRIPTION
10231
+ // because stopTranscription() always fires its trigger.
10232
+ //
10233
+ // Ownership-aware token clear is encapsulated inside clearDataChannelToken().
10234
+ this.clearDataChannelToken();
9401
10235
 
9402
- this.annotation.deregisterEvents();
9403
-
9404
- // @ts-ignore - fix types
9405
- this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
9406
- // @ts-ignore - Fix type
9407
- this.webex.internal.llm.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
10236
+ await this.cleanupLLMConneciton({throwOnError: false});
9408
10237
  };
9409
10238
 
9410
10239
  /**
@@ -9480,15 +10309,12 @@ export default class Meeting extends StatelessWebexPlugin {
9480
10309
  * @public
9481
10310
  * @memberof Meeting
9482
10311
  */
9483
- public sendReaction(reactionType: ReactionServerType, skinToneType?: SkinToneType) {
10312
+ public sendReaction(reactionType: string, skinToneType?: SkinToneType) {
9484
10313
  const reactionChannelUrl = this.locusInfo?.controls?.reactions?.reactionChannelUrl as string;
9485
10314
  const participantId = this.members.selfId;
9486
10315
 
9487
- const reactionData = Reactions[reactionType];
10316
+ const reactionData = Reactions[reactionType] || {type: reactionType};
9488
10317
 
9489
- if (!reactionData) {
9490
- return Promise.reject(new Error(`${reactionType} is not a valid reaction.`));
9491
- }
9492
10318
  const skinToneData = SkinTones[skinToneType] || SkinTones.normal;
9493
10319
  const reaction: Reaction = {
9494
10320
  ...reactionData,
@@ -9597,15 +10423,20 @@ export default class Meeting extends StatelessWebexPlugin {
9597
10423
  }
9598
10424
 
9599
10425
  if (shouldEnableMusicMode) {
9600
- await this.sendSlotManager.setCodecParameters(MediaType.AudioMain, {
9601
- maxaveragebitrate: '64000',
9602
- maxplaybackrate: '48000',
9603
- });
10426
+ await this.sendSlotManager.setCustomCodecParameters(
10427
+ MediaType.AudioMain,
10428
+ MediaCodecMimeType.OPUS,
10429
+ {
10430
+ maxaveragebitrate: '64000',
10431
+ maxplaybackrate: '48000',
10432
+ }
10433
+ );
9604
10434
  } else {
9605
- await this.sendSlotManager.deleteCodecParameters(MediaType.AudioMain, [
9606
- 'maxaveragebitrate',
9607
- 'maxplaybackrate',
9608
- ]);
10435
+ await this.sendSlotManager.markCustomCodecParametersForDeletion(
10436
+ MediaType.AudioMain,
10437
+ MediaCodecMimeType.OPUS,
10438
+ ['maxaveragebitrate', 'maxplaybackrate']
10439
+ );
9609
10440
  }
9610
10441
  }
9611
10442
 
@@ -10104,4 +10935,52 @@ export default class Meeting extends StatelessWebexPlugin {
10104
10935
  cancelSipCallOut(participantId: string) {
10105
10936
  return this.meetingRequest.cancelSipCallOut(participantId);
10106
10937
  }
10938
+
10939
+ /**
10940
+ * Method to get new data
10941
+ * @returns {Promise}
10942
+ */
10943
+ public async refreshDataChannelToken() {
10944
+ const isPracticeSession = this.webinar.isJoinPracticeSessionDataChannel();
10945
+ const dataChannelTokenType = this.getDataChannelTokenType();
10946
+
10947
+ try {
10948
+ const res = await this.meetingRequest.fetchDatachannelToken({
10949
+ locusUrl: this.locusUrl,
10950
+ requestingParticipantId: this.members.selfId,
10951
+ isPracticeSession,
10952
+ });
10953
+
10954
+ return {
10955
+ body: {
10956
+ datachannelToken: res.body.datachannelToken,
10957
+ dataChannelTokenType,
10958
+ },
10959
+ };
10960
+ } catch (e) {
10961
+ const msg = e?.message || String(e);
10962
+
10963
+ LoggerProxy.logger.warn(
10964
+ `Meeting:index#refreshDataChannelToken --> DataChannel token refresh failed (likely locus changed or participant left): ${msg}`,
10965
+ {statusCode: e?.statusCode}
10966
+ );
10967
+
10968
+ return null;
10969
+ }
10970
+ }
10971
+
10972
+ /**
10973
+ * Determines the current data channel token type based on the meeting state.
10974
+ *
10975
+ * variant should be used when connecting to the LLM data channel.
10976
+ *
10977
+ * @returns {DataChannelTokenType} The token type representing the current session mode.
10978
+ */
10979
+ public getDataChannelTokenType(): DataChannelTokenType {
10980
+ if (this.webinar.isJoinPracticeSessionDataChannel()) {
10981
+ return DataChannelTokenType.PracticeSession;
10982
+ }
10983
+
10984
+ return DataChannelTokenType.Default;
10985
+ }
10107
10986
  }