@webex/plugin-meetings 3.12.0-next.10 → 3.12.0-next.101

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 (230) hide show
  1. package/AGENTS.md +9 -0
  2. package/dist/aiEnableRequest/index.js +15 -2
  3. package/dist/aiEnableRequest/index.js.map +1 -1
  4. package/dist/breakouts/breakout.js +8 -3
  5. package/dist/breakouts/breakout.js.map +1 -1
  6. package/dist/breakouts/index.js +26 -2
  7. package/dist/breakouts/index.js.map +1 -1
  8. package/dist/common/errors/webex-errors.js +49 -5
  9. package/dist/common/errors/webex-errors.js.map +1 -1
  10. package/dist/config.js +2 -2
  11. package/dist/config.js.map +1 -1
  12. package/dist/constants.js +35 -9
  13. package/dist/constants.js.map +1 -1
  14. package/dist/controls-options-manager/constants.js +11 -1
  15. package/dist/controls-options-manager/constants.js.map +1 -1
  16. package/dist/controls-options-manager/index.js +67 -29
  17. package/dist/controls-options-manager/index.js.map +1 -1
  18. package/dist/controls-options-manager/util.js +91 -0
  19. package/dist/controls-options-manager/util.js.map +1 -1
  20. package/dist/hashTree/constants.js +4 -1
  21. package/dist/hashTree/constants.js.map +1 -1
  22. package/dist/hashTree/hashTreeParser.js +880 -382
  23. package/dist/hashTree/hashTreeParser.js.map +1 -1
  24. package/dist/hashTree/utils.js +20 -0
  25. package/dist/hashTree/utils.js.map +1 -1
  26. package/dist/index.js +7 -0
  27. package/dist/index.js.map +1 -1
  28. package/dist/interceptors/dataChannelAuthToken.js +75 -15
  29. package/dist/interceptors/dataChannelAuthToken.js.map +1 -1
  30. package/dist/interceptors/locusRetry.js +23 -8
  31. package/dist/interceptors/locusRetry.js.map +1 -1
  32. package/dist/interpretation/index.js +10 -1
  33. package/dist/interpretation/index.js.map +1 -1
  34. package/dist/interpretation/interpretation.types.js +7 -0
  35. package/dist/interpretation/interpretation.types.js.map +1 -0
  36. package/dist/interpretation/siLanguage.js +1 -1
  37. package/dist/locus-info/controlsUtils.js +4 -1
  38. package/dist/locus-info/controlsUtils.js.map +1 -1
  39. package/dist/locus-info/index.js +401 -115
  40. package/dist/locus-info/index.js.map +1 -1
  41. package/dist/locus-info/infoUtils.js +36 -5
  42. package/dist/locus-info/infoUtils.js.map +1 -1
  43. package/dist/locus-info/types.js +19 -0
  44. package/dist/locus-info/types.js.map +1 -1
  45. package/dist/media/MediaConnectionAwaiter.js +15 -2
  46. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  47. package/dist/media/index.js +8 -2
  48. package/dist/media/index.js.map +1 -1
  49. package/dist/media/properties.js +1 -0
  50. package/dist/media/properties.js.map +1 -1
  51. package/dist/meeting/in-meeting-actions.js +5 -1
  52. package/dist/meeting/in-meeting-actions.js.map +1 -1
  53. package/dist/meeting/index.js +1389 -821
  54. package/dist/meeting/index.js.map +1 -1
  55. package/dist/meeting/locusMediaRequest.js +229 -82
  56. package/dist/meeting/locusMediaRequest.js.map +1 -1
  57. package/dist/meeting/muteState.js +10 -1
  58. package/dist/meeting/muteState.js.map +1 -1
  59. package/dist/meeting/request.js +5 -2
  60. package/dist/meeting/request.js.map +1 -1
  61. package/dist/meeting/util.js +35 -2
  62. package/dist/meeting/util.js.map +1 -1
  63. package/dist/meeting-info/meeting-info-v2.js +2 -2
  64. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  65. package/dist/meetings/index.js +231 -118
  66. package/dist/meetings/index.js.map +1 -1
  67. package/dist/meetings/meetings.types.js +6 -1
  68. package/dist/meetings/meetings.types.js.map +1 -1
  69. package/dist/meetings/request.js +39 -0
  70. package/dist/meetings/request.js.map +1 -1
  71. package/dist/meetings/util.js +116 -18
  72. package/dist/meetings/util.js.map +1 -1
  73. package/dist/member/index.js +10 -0
  74. package/dist/member/index.js.map +1 -1
  75. package/dist/member/types.js.map +1 -1
  76. package/dist/member/util.js +30 -0
  77. package/dist/member/util.js.map +1 -1
  78. package/dist/members/index.js +101 -43
  79. package/dist/members/index.js.map +1 -1
  80. package/dist/members/util.js +8 -1
  81. package/dist/members/util.js.map +1 -1
  82. package/dist/metrics/constants.js +6 -1
  83. package/dist/metrics/constants.js.map +1 -1
  84. package/dist/multistream/codec/constants.js +63 -0
  85. package/dist/multistream/codec/constants.js.map +1 -0
  86. package/dist/multistream/mediaRequestManager.js +62 -15
  87. package/dist/multistream/mediaRequestManager.js.map +1 -1
  88. package/dist/multistream/receiveSlot.js +9 -0
  89. package/dist/multistream/receiveSlot.js.map +1 -1
  90. package/dist/reachability/clusterReachability.js.map +1 -1
  91. package/dist/reachability/index.js +121 -83
  92. package/dist/reachability/index.js.map +1 -1
  93. package/dist/reachability/reachability.types.js +2 -0
  94. package/dist/reachability/reachability.types.js.map +1 -1
  95. package/dist/reachability/util.js +45 -0
  96. package/dist/reachability/util.js.map +1 -1
  97. package/dist/reactions/reactions.type.js.map +1 -1
  98. package/dist/recording-controller/index.js +1 -3
  99. package/dist/recording-controller/index.js.map +1 -1
  100. package/dist/roap/turnDiscovery.js +8 -1
  101. package/dist/roap/turnDiscovery.js.map +1 -1
  102. package/dist/types/common/errors/webex-errors.d.ts +32 -2
  103. package/dist/types/config.d.ts +2 -2
  104. package/dist/types/constants.d.ts +12 -1
  105. package/dist/types/controls-options-manager/constants.d.ts +6 -1
  106. package/dist/types/controls-options-manager/index.d.ts +16 -0
  107. package/dist/types/hashTree/constants.d.ts +1 -0
  108. package/dist/types/hashTree/hashTreeParser.d.ts +146 -17
  109. package/dist/types/hashTree/utils.d.ts +7 -0
  110. package/dist/types/index.d.ts +3 -0
  111. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  112. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  113. package/dist/types/locus-info/index.d.ts +59 -6
  114. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  115. package/dist/types/locus-info/types.d.ts +21 -1
  116. package/dist/types/media/MediaConnectionAwaiter.d.ts +10 -1
  117. package/dist/types/media/properties.d.ts +1 -0
  118. package/dist/types/meeting/in-meeting-actions.d.ts +4 -0
  119. package/dist/types/meeting/index.d.ts +121 -10
  120. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  121. package/dist/types/meeting/request.d.ts +1 -0
  122. package/dist/types/meeting/util.d.ts +9 -0
  123. package/dist/types/meetings/index.d.ts +30 -18
  124. package/dist/types/meetings/meetings.types.d.ts +15 -0
  125. package/dist/types/meetings/request.d.ts +14 -0
  126. package/dist/types/member/index.d.ts +1 -0
  127. package/dist/types/member/types.d.ts +1 -0
  128. package/dist/types/member/util.d.ts +9 -0
  129. package/dist/types/members/index.d.ts +15 -2
  130. package/dist/types/members/util.d.ts +1 -5
  131. package/dist/types/metrics/constants.d.ts +5 -0
  132. package/dist/types/multistream/codec/constants.d.ts +7 -0
  133. package/dist/types/multistream/mediaRequestManager.d.ts +22 -5
  134. package/dist/types/reachability/clusterReachability.d.ts +3 -3
  135. package/dist/types/reachability/index.d.ts +10 -3
  136. package/dist/types/reachability/reachability.types.d.ts +7 -0
  137. package/dist/types/reachability/util.d.ts +17 -0
  138. package/dist/types/reactions/reactions.type.d.ts +3 -0
  139. package/dist/webinar/index.js +305 -159
  140. package/dist/webinar/index.js.map +1 -1
  141. package/package.json +22 -22
  142. package/src/aiEnableRequest/index.ts +16 -0
  143. package/src/breakouts/breakout.ts +3 -1
  144. package/src/breakouts/index.ts +31 -0
  145. package/src/common/errors/webex-errors.ts +50 -3
  146. package/src/config.ts +2 -2
  147. package/src/constants.ts +20 -3
  148. package/src/controls-options-manager/constants.ts +14 -1
  149. package/src/controls-options-manager/index.ts +87 -28
  150. package/src/controls-options-manager/util.ts +81 -1
  151. package/src/hashTree/constants.ts +7 -0
  152. package/src/hashTree/hashTreeParser.ts +578 -193
  153. package/src/hashTree/utils.ts +19 -0
  154. package/src/index.ts +6 -0
  155. package/src/interceptors/dataChannelAuthToken.ts +88 -12
  156. package/src/interceptors/locusRetry.ts +25 -4
  157. package/src/interpretation/index.ts +27 -9
  158. package/src/interpretation/interpretation.types.ts +11 -0
  159. package/src/locus-info/controlsUtils.ts +3 -1
  160. package/src/locus-info/index.ts +415 -136
  161. package/src/locus-info/infoUtils.ts +41 -6
  162. package/src/locus-info/types.ts +25 -1
  163. package/src/media/MediaConnectionAwaiter.ts +21 -4
  164. package/src/media/index.ts +10 -1
  165. package/src/media/properties.ts +1 -0
  166. package/src/meeting/in-meeting-actions.ts +8 -0
  167. package/src/meeting/index.ts +644 -98
  168. package/src/meeting/locusMediaRequest.ts +106 -6
  169. package/src/meeting/muteState.ts +10 -1
  170. package/src/meeting/request.ts +11 -0
  171. package/src/meeting/util.ts +47 -5
  172. package/src/meeting-info/meeting-info-v2.ts +4 -2
  173. package/src/meetings/index.ts +133 -78
  174. package/src/meetings/meetings.types.ts +19 -0
  175. package/src/meetings/request.ts +43 -0
  176. package/src/meetings/util.ts +117 -4
  177. package/src/member/index.ts +10 -0
  178. package/src/member/types.ts +1 -0
  179. package/src/member/util.ts +29 -0
  180. package/src/members/index.ts +70 -7
  181. package/src/members/util.ts +12 -4
  182. package/src/metrics/constants.ts +5 -0
  183. package/src/multistream/codec/constants.ts +58 -0
  184. package/src/multistream/mediaRequestManager.ts +119 -28
  185. package/src/multistream/receiveSlot.ts +18 -0
  186. package/src/reachability/clusterReachability.ts +3 -2
  187. package/src/reachability/index.ts +47 -16
  188. package/src/reachability/reachability.types.ts +11 -0
  189. package/src/reachability/util.ts +36 -0
  190. package/src/reactions/reactions.type.ts +3 -0
  191. package/src/recording-controller/index.ts +1 -2
  192. package/src/roap/turnDiscovery.ts +9 -1
  193. package/src/webinar/index.ts +214 -36
  194. package/test/unit/spec/aiEnableRequest/index.ts +86 -0
  195. package/test/unit/spec/breakouts/breakout.ts +9 -3
  196. package/test/unit/spec/breakouts/index.ts +49 -0
  197. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  198. package/test/unit/spec/controls-options-manager/index.js +244 -29
  199. package/test/unit/spec/controls-options-manager/util.js +165 -0
  200. package/test/unit/spec/hashTree/hashTreeParser.ts +1848 -318
  201. package/test/unit/spec/hashTree/utils.ts +37 -0
  202. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +196 -0
  203. package/test/unit/spec/interceptors/locusRetry.ts +205 -4
  204. package/test/unit/spec/interpretation/index.ts +26 -4
  205. package/test/unit/spec/locus-info/controlsUtils.js +172 -57
  206. package/test/unit/spec/locus-info/index.js +645 -80
  207. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  208. package/test/unit/spec/media/MediaConnectionAwaiter.ts +55 -0
  209. package/test/unit/spec/media/index.ts +92 -0
  210. package/test/unit/spec/meeting/in-meeting-actions.ts +4 -0
  211. package/test/unit/spec/meeting/index.js +2119 -98
  212. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  213. package/test/unit/spec/meeting/muteState.js +81 -0
  214. package/test/unit/spec/meeting/request.js +12 -0
  215. package/test/unit/spec/meeting/utils.js +157 -1
  216. package/test/unit/spec/meeting-info/meetinginfov2.js +19 -10
  217. package/test/unit/spec/meetings/index.js +363 -36
  218. package/test/unit/spec/meetings/request.js +141 -0
  219. package/test/unit/spec/meetings/utils.js +402 -51
  220. package/test/unit/spec/member/index.js +7 -0
  221. package/test/unit/spec/member/util.js +89 -0
  222. package/test/unit/spec/members/index.js +216 -0
  223. package/test/unit/spec/members/request.js +37 -1
  224. package/test/unit/spec/members/utils.js +63 -0
  225. package/test/unit/spec/multistream/mediaRequestManager.ts +501 -37
  226. package/test/unit/spec/reachability/index.ts +128 -46
  227. package/test/unit/spec/reachability/util.ts +31 -0
  228. package/test/unit/spec/recording-controller/index.js +9 -8
  229. package/test/unit/spec/roap/turnDiscovery.ts +20 -0
  230. package/test/unit/spec/webinar/index.ts +329 -28
@@ -22,7 +22,6 @@ import {
22
22
  MediaConnectionEventNames,
23
23
  MediaContent,
24
24
  MediaType,
25
- MediaCodecMimeType,
26
25
  RemoteTrackType,
27
26
  RoapMessage,
28
27
  StatsAnalyzer,
@@ -31,7 +30,7 @@ import {
31
30
  NetworkQualityMonitor,
32
31
  StatsMonitor,
33
32
  StatsMonitorEventNames,
34
- InboundAudioIssueSubTypes,
33
+ MediaCodecMimeType,
35
34
  } from '@webex/internal-media-core';
36
35
 
37
36
  import {DataChannelTokenType} from '@webex/internal-plugin-llm';
@@ -67,6 +66,7 @@ import {
67
66
  NoMediaEstablishedYetError,
68
67
  UserNotJoinedError,
69
68
  AddMediaFailed,
69
+ MediaConnectionTimedOutError,
70
70
  SdpResponseTimeoutError,
71
71
  } from '../common/errors/webex-errors';
72
72
 
@@ -77,6 +77,7 @@ import Roap, {type TurnDiscoveryResult, type TurnDiscoverySkipReason} from '../r
77
77
  import {type TurnServerInfo} from '../roap/types';
78
78
  import Media, {type BundlePolicy} from '../media';
79
79
  import MediaProperties from '../media/properties';
80
+ import {type FailureResult as MediaConnectionAwaiterFailureResult} from '../media/MediaConnectionAwaiter';
80
81
  import MeetingStateMachine from './state';
81
82
  import {createMuteState} from './muteState';
82
83
  import LocusInfo, {LocusLLMEvent} from '../locus-info';
@@ -137,6 +138,8 @@ import {
137
138
  STAGE_MANAGER_TYPE,
138
139
  LOCUSEVENT,
139
140
  LOCUS_LLM_EVENT,
141
+ LLM_DEFAULT_SESSION,
142
+ LLM_PRACTICE_SESSION,
140
143
  } from '../constants';
141
144
  import BEHAVIORAL_METRICS from '../metrics/constants';
142
145
  import ParameterError from '../common/errors/parameter';
@@ -190,6 +193,7 @@ import AIEnableRequest from '../aiEnableRequest';
190
193
  const DEFAULT_ICE_PHASE_CALLBACK = () => 'JOIN_MEETING_FINAL';
191
194
 
192
195
  const LLM_HEALTHCHECK_TIMER_MS = 3 * 60 * 1000;
196
+ const JOIN_WITH_MEDIA_RETRY_MAX_COUNT = 2;
193
197
 
194
198
  const logRequest = (request: any, {logText = ''}) => {
195
199
  LoggerProxy.logger.info(`${logText} - sending request`);
@@ -612,7 +616,7 @@ export default class Meeting extends StatelessWebexPlugin {
612
616
  webinar: any;
613
617
  conversationUrl: string;
614
618
  callStateForMetrics: CallStateForMetrics;
615
- destination: string;
619
+ destination: string | LocusDTO;
616
620
  destinationType: DESTINATION_TYPE;
617
621
  deviceUrl: string;
618
622
  hostId: string;
@@ -651,6 +655,8 @@ export default class Meeting extends StatelessWebexPlugin {
651
655
  floorGrantPending: boolean;
652
656
  hasJoinedOnce: boolean;
653
657
  hasWebsocketConnected: boolean;
658
+ private mercuryOnlineHandler?: () => void;
659
+ private mercuryOfflineHandler?: () => void;
654
660
  inMeetingActions: InMeetingActions;
655
661
  isLocalShareLive: boolean;
656
662
  isRoapInProgress: boolean;
@@ -662,6 +668,7 @@ export default class Meeting extends StatelessWebexPlugin {
662
668
  joinedWith?: any;
663
669
  selfId?: string;
664
670
  roles: any[];
671
+ canNotViewTheParticipantList?: boolean;
665
672
  // ... there is more ... see SelfUtils.parse()
666
673
  // end of the group
667
674
  locusMediaRequest?: LocusMediaRequest;
@@ -735,6 +742,7 @@ export default class Meeting extends StatelessWebexPlugin {
735
742
  isMoveToInProgress = false;
736
743
  registrationIdStatus: string;
737
744
  brbState: BrbState;
745
+ private promisesWaitingForPropUpdate: Record<string, Defer> = {};
738
746
 
739
747
  voiceaListenerCallbacks: object = {
740
748
  [VOICEAEVENTS.VOICEA_ANNOUNCEMENT]: (payload: Transcription['languageOptions']) => {
@@ -784,13 +792,20 @@ export default class Meeting extends StatelessWebexPlugin {
784
792
  private addMediaData: {
785
793
  retriedWithTurnServer: boolean;
786
794
  icePhaseCallback: () => string;
795
+ iceTransportPolicy?: RTCIceTransportPolicy;
787
796
  };
788
797
 
789
798
  private sendSlotManager: SendSlotManager = new SendSlotManager(LoggerProxy);
790
799
  private deferSDPAnswer?: Defer; // used for waiting for a response
791
800
  private sdpResponseTimer?: ReturnType<typeof setTimeout>;
792
801
  private hasMediaConnectionConnectedAtLeastOnce: boolean;
793
- private joinWithMediaRetryInfo?: {isRetry: boolean; prevJoinResponse?: any};
802
+ private joinWithMediaRetryInfo: {
803
+ retryCount: number;
804
+ prevJoinResponse?: any;
805
+ firstError?: Error;
806
+ prevError?: Error;
807
+ };
808
+
794
809
  private connectionStateHandler?: ConnectionStateHandler;
795
810
  private iceCandidateErrors: Map<string, number>;
796
811
  private iceCandidatesCount: number;
@@ -935,7 +950,7 @@ export default class Meeting extends StatelessWebexPlugin {
935
950
  this.simultaneousInterpretation = new SimultaneousInterpretation({}, {parent: this.webex});
936
951
 
937
952
  // @ts-ignore
938
- this.aiEnableRequest = new AIEnableRequest({}, {parent: this.webex});
953
+ this.aiEnableRequest = new AIEnableRequest({locusUrl: this.locusUrl}, {parent: this.webex});
939
954
 
940
955
  /**
941
956
  * @instance
@@ -966,6 +981,7 @@ export default class Meeting extends StatelessWebexPlugin {
966
981
  },
967
982
  (csi: CSI) => (this.members.findMemberByCsi(csi) as any)?.id
968
983
  );
984
+
969
985
  /**
970
986
  * Object containing helper classes for managing media requests for audio/video/screenshare (for multistream media connections)
971
987
  * All multistream media requests sent out for this meeting have to go through them.
@@ -985,6 +1001,7 @@ export default class Meeting extends StatelessWebexPlugin {
985
1001
  mediaRequests
986
1002
  );
987
1003
  },
1004
+ this.getIngressPayloadTypeCallback.bind(this),
988
1005
  {
989
1006
  // @ts-ignore - config coming from registerPlugin
990
1007
  degradationPreferences: this.config.degradationPreferences,
@@ -1006,6 +1023,7 @@ export default class Meeting extends StatelessWebexPlugin {
1006
1023
  mediaRequests
1007
1024
  );
1008
1025
  },
1026
+ this.getIngressPayloadTypeCallback.bind(this),
1009
1027
  {
1010
1028
  // @ts-ignore - config coming from registerPlugin
1011
1029
  degradationPreferences: this.config.degradationPreferences,
@@ -1027,6 +1045,7 @@ export default class Meeting extends StatelessWebexPlugin {
1027
1045
  mediaRequests
1028
1046
  );
1029
1047
  },
1048
+ this.getIngressPayloadTypeCallback.bind(this),
1030
1049
  {
1031
1050
  // @ts-ignore - config coming from registerPlugin
1032
1051
  degradationPreferences: this.config.degradationPreferences,
@@ -1048,11 +1067,14 @@ export default class Meeting extends StatelessWebexPlugin {
1048
1067
  mediaRequests
1049
1068
  );
1050
1069
  },
1070
+ this.getIngressPayloadTypeCallback.bind(this),
1051
1071
  {
1052
1072
  // @ts-ignore - config coming from registerPlugin
1053
1073
  degradationPreferences: this.config.degradationPreferences,
1054
1074
  kind: 'video',
1055
1075
  trimRequestsToNumOfSources: false,
1076
+ // @ts-ignore - config coming from registerPlugin
1077
+ enableAv1: this.config.enableAv1SlidesSupport,
1056
1078
  }
1057
1079
  ),
1058
1080
  };
@@ -1557,6 +1579,8 @@ export default class Meeting extends StatelessWebexPlugin {
1557
1579
  this.controlsOptionsManager = new ControlsOptionsManager(this.meetingRequest, {
1558
1580
  locusUrl: this.locusInfo?.url,
1559
1581
  displayHints: [],
1582
+ getControls: () => this.locusInfo?.controls,
1583
+ isWebinar: () => this.locusInfo?.info?.isWebinar,
1560
1584
  });
1561
1585
 
1562
1586
  this.setUpLocusInfoListeners();
@@ -1655,11 +1679,11 @@ export default class Meeting extends StatelessWebexPlugin {
1655
1679
  /**
1656
1680
  * Information needed for a retry of a call to joinWithMedia
1657
1681
  * @instance
1658
- * @type {{isRetry: boolean; prevJoinResponse?: any}}
1682
+ * @type {{retryCount: number; prevJoinResponse?: any}}
1659
1683
  * @private
1660
1684
  * @memberof Meeting
1661
1685
  */
1662
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
1686
+ this.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
1663
1687
 
1664
1688
  /**
1665
1689
  * Connection state handler
@@ -1713,6 +1737,37 @@ export default class Meeting extends StatelessWebexPlugin {
1713
1737
  this.mediaServerIp = undefined;
1714
1738
  }
1715
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
+
1716
1771
  /**
1717
1772
  * Temporary func to return webex object,
1718
1773
  * in order to access internal plugin metrics
@@ -2789,7 +2844,7 @@ export default class Meeting extends StatelessWebexPlugin {
2789
2844
  private setupLocusControlsListener() {
2790
2845
  this.locusInfo.on(
2791
2846
  LOCUSINFO.EVENTS.CONTROLS_RECORDING_UPDATED,
2792
- ({state, modifiedBy, lastModified}) => {
2847
+ ({state, modifiedBy, lastModified, modifiedByServiceAppName, modifiedByServiceAppId}) => {
2793
2848
  let event;
2794
2849
 
2795
2850
  switch (state) {
@@ -2815,6 +2870,8 @@ export default class Meeting extends StatelessWebexPlugin {
2815
2870
  state: state === RECORDING_STATE.RESUMED ? RECORDING_STATE.RECORDING : state,
2816
2871
  modifiedBy,
2817
2872
  lastModified,
2873
+ modifiedByServiceAppName,
2874
+ modifiedByServiceAppId,
2818
2875
  };
2819
2876
  Trigger.trigger(
2820
2877
  this,
@@ -3213,7 +3270,7 @@ export default class Meeting extends StatelessWebexPlugin {
3213
3270
  }
3214
3271
 
3215
3272
  LoggerProxy.logger.info(
3216
- `Meeting:index#setUpLocusInfoMediaInactiveListener --> this.shareStatus=${this.shareStatus} newShareStatus=${newShareStatus}`
3273
+ `Meeting:index#setUpLocusMediaSharesListener --> this.shareStatus=${this.shareStatus} newShareStatus=${newShareStatus}`
3217
3274
  );
3218
3275
 
3219
3276
  if (newShareStatus !== this.shareStatus) {
@@ -3459,13 +3516,12 @@ export default class Meeting extends StatelessWebexPlugin {
3459
3516
  this.breakouts.locusUrlUpdate(url);
3460
3517
  this.simultaneousInterpretation.locusUrlUpdate(url);
3461
3518
  this.annotation.locusUrlUpdate(url);
3519
+ this.aiEnableRequest.locusUrlUpdate(url);
3462
3520
  this.locusUrl = url;
3463
3521
  this.locusId = this.locusUrl?.split('/').pop();
3464
3522
  this.recordingController.setLocusUrl(this.locusUrl);
3465
3523
  this.controlsOptionsManager.setLocusUrl(this.locusUrl, !!isMainLocus);
3466
3524
  this.webinar.locusUrlUpdate(url);
3467
- // @ts-ignore
3468
- this.webex.internal.llm.setRefreshHandler(() => this.refreshDataChannelToken());
3469
3525
 
3470
3526
  Trigger.trigger(
3471
3527
  this,
@@ -3734,7 +3790,7 @@ export default class Meeting extends StatelessWebexPlugin {
3734
3790
  });
3735
3791
  this.updateLLMConnection();
3736
3792
  });
3737
- this.locusInfo.on(LOCUSINFO.EVENTS.SELF_ADMITTED_GUEST, (payload) => {
3793
+ this.locusInfo.on(LOCUSINFO.EVENTS.SELF_ADMITTED_GUEST, async (payload) => {
3738
3794
  this.stopKeepAlive();
3739
3795
 
3740
3796
  if (payload) {
@@ -3761,13 +3817,15 @@ export default class Meeting extends StatelessWebexPlugin {
3761
3817
  }
3762
3818
  this.rtcMetrics?.sendNextMetrics();
3763
3819
 
3764
- this.ensureDefaultDatachannelTokenAfterAdmit().catch((error) => {
3820
+ try {
3821
+ await this.ensureDefaultDatachannelTokenAfterAdmit();
3822
+ } catch (error) {
3765
3823
  LoggerProxy.logger.warn(
3766
3824
  `Meeting:index#setUpLocusInfoSelfListener --> failed post-admit token prefetch flow: ${
3767
3825
  error?.message || String(error)
3768
3826
  }`
3769
3827
  );
3770
- });
3828
+ }
3771
3829
 
3772
3830
  this.updateLLMConnection();
3773
3831
  });
@@ -3813,6 +3871,9 @@ export default class Meeting extends StatelessWebexPlugin {
3813
3871
  });
3814
3872
 
3815
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
+
3816
3877
  Trigger.trigger(
3817
3878
  this,
3818
3879
  {
@@ -4007,7 +4068,14 @@ export default class Meeting extends StatelessWebexPlugin {
4007
4068
  // is not changed by any delta event
4008
4069
  if (object && Object.keys(object).length) {
4009
4070
  Object.keys(object).forEach((key) => {
4071
+ const previousValue = this[key];
4072
+
4010
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
+ }
4011
4079
  });
4012
4080
  }
4013
4081
  }
@@ -4145,7 +4213,12 @@ export default class Meeting extends StatelessWebexPlugin {
4145
4213
  }
4146
4214
 
4147
4215
  /**
4148
- * 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.
4149
4222
  * @param {String} memberId
4150
4223
  * @param {Boolean} moderator
4151
4224
  * @returns {Promise} see #members.transferHostToMember
@@ -4153,7 +4226,21 @@ export default class Meeting extends StatelessWebexPlugin {
4153
4226
  * @memberof Meeting
4154
4227
  */
4155
4228
  public transfer(memberId: string, moderator = true) {
4156
- 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);
4157
4244
  }
4158
4245
 
4159
4246
  /**
@@ -4611,6 +4698,13 @@ export default class Meeting extends StatelessWebexPlugin {
4611
4698
  ),
4612
4699
  isAttendeeRequestAiAssistantDeclinedAll:
4613
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
+ ),
4614
4708
  }) || changed;
4615
4709
  }
4616
4710
  if (changed) {
@@ -4659,6 +4753,34 @@ export default class Meeting extends StatelessWebexPlugin {
4659
4753
  this.sipUri = sipUri;
4660
4754
  }
4661
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
+
4662
4784
  /**
4663
4785
  * Set the locus info the class instance. Should be called with the parsed locus
4664
4786
  * we got in the join response.
@@ -5130,8 +5252,7 @@ export default class Meeting extends StatelessWebexPlugin {
5130
5252
  public setMercuryListener() {
5131
5253
  // Client will have a socket manager and handle reconnecting to mercury, when we reconnect to mercury
5132
5254
  // if the meeting has active peer connections, it should try to reconnect.
5133
- // @ts-ignore
5134
- this.webex.internal.mercury.on(ONLINE, () => {
5255
+ this.mercuryOnlineHandler = () => {
5135
5256
  LoggerProxy.logger.info('Meeting:index#setMercuryListener --> Web socket online');
5136
5257
 
5137
5258
  // Only send restore event when it was disconnected before and for connected later
@@ -5141,15 +5262,47 @@ export default class Meeting extends StatelessWebexPlugin {
5141
5262
  });
5142
5263
  }
5143
5264
  this.hasWebsocketConnected = true;
5144
- });
5265
+ };
5145
5266
 
5146
- // @ts-ignore
5147
- this.webex.internal.mercury.on(OFFLINE, () => {
5267
+ this.mercuryOfflineHandler = () => {
5148
5268
  LoggerProxy.logger.error('Meeting:index#setMercuryListener --> Web socket offline');
5149
5269
  Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.MERCURY_CONNECTION_FAILURE, {
5150
5270
  correlation_id: this.correlationId,
5151
5271
  });
5152
- });
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
+ }
5153
5306
  }
5154
5307
 
5155
5308
  /**
@@ -5173,6 +5326,7 @@ export default class Meeting extends StatelessWebexPlugin {
5173
5326
  );
5174
5327
 
5175
5328
  this.receiveSlotManager.reset();
5329
+
5176
5330
  this.mediaProperties.webrtcMediaConnection.close();
5177
5331
  this.mediaProperties.unsetPeerConnection();
5178
5332
  this.sendSlotManager.reset();
@@ -5460,7 +5614,7 @@ export default class Meeting extends StatelessWebexPlugin {
5460
5614
  } = {}
5461
5615
  ) {
5462
5616
  const {mediaOptions, joinOptions = {}} = options;
5463
- const {isRetry, prevJoinResponse} = this.joinWithMediaRetryInfo;
5617
+ const {retryCount, prevJoinResponse, prevError} = this.joinWithMediaRetryInfo;
5464
5618
 
5465
5619
  if (!mediaOptions?.allowMediaInLobby) {
5466
5620
  return Promise.reject(
@@ -5471,9 +5625,6 @@ export default class Meeting extends StatelessWebexPlugin {
5471
5625
 
5472
5626
  LoggerProxy.logger.info('Meeting:index#joinWithMedia called');
5473
5627
 
5474
- let joined = false;
5475
- let joinResponse = prevJoinResponse;
5476
-
5477
5628
  /* Before we do anything, check if RTCPeerConnection is available. Normally this is checked
5478
5629
  by addMediaInternal() itself when creating the media connection, but since joinWithMedia()
5479
5630
  is a convenience method that does both join() and addMedia(), we want to fail fast here
@@ -5486,12 +5637,28 @@ export default class Meeting extends StatelessWebexPlugin {
5486
5637
  );
5487
5638
  }
5488
5639
 
5640
+ /* While we're trying to join, we may fail and be doing a retry. In that case,
5641
+ we sometimes get dropped by Locus as a result of the 1st failed attempt.
5642
+ That notification from Locus needs to be ignored, otherwise it causes the meeting to be
5643
+ cleaned up and prevents the retry from running correctly.
5644
+ */
5645
+ this.locusInfo.suspendDestroyMeeting(true);
5646
+
5647
+ let joined = false;
5648
+ let joinResponse = prevJoinResponse;
5649
+
5650
+ const shouldJoin =
5651
+ !joinResponse || // first try, when the join response is empty
5652
+ (prevError && prevError instanceof UserNotJoinedError) || // last try failed with UserNotJoinedError
5653
+ this.isErrorMeaningLocusDroppedUs(prevError) ||
5654
+ MeetingUtil.isUserInLeftState(this.locusInfo); // locus dropped the connection before we can re-try addMedia
5655
+
5489
5656
  try {
5490
5657
  let turnServerInfo;
5491
5658
  let turnDiscoverySkippedReason;
5492
5659
  let forceTurnDiscovery = false;
5493
5660
 
5494
- if (!joinResponse) {
5661
+ if (shouldJoin) {
5495
5662
  // This is the 1st attempt or a retry after join request failed -> we need to do a join with TURN discovery
5496
5663
 
5497
5664
  const turnDiscoveryRequest = await this.roap.generateTurnDiscoveryRequestMessage(
@@ -5530,16 +5697,24 @@ export default class Meeting extends StatelessWebexPlugin {
5530
5697
  joined = true;
5531
5698
  }
5532
5699
 
5700
+ const shouldRetryMediaWithOnlyTurnTLS = await this.shouldRetryMediaWithOnlyTurnTLS(prevError);
5701
+
5533
5702
  const mediaResponse = await this.addMediaInternal(
5534
5703
  () => {
5535
- return this.joinWithMediaRetryInfo.isRetry ? 'JOIN_MEETING_FINAL' : 'JOIN_MEETING_RETRY';
5704
+ // callback is not called when UserNotJoinedError is thrown
5705
+ return this.joinWithMediaRetryInfo.retryCount >= 1
5706
+ ? 'JOIN_MEETING_FINAL'
5707
+ : 'JOIN_MEETING_RETRY';
5536
5708
  },
5537
- turnServerInfo,
5538
5709
  forceTurnDiscovery,
5710
+ turnServerInfo,
5711
+ shouldRetryMediaWithOnlyTurnTLS ? 'relay' : undefined,
5539
5712
  mediaOptions
5540
5713
  );
5541
5714
 
5542
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
5715
+ this.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
5716
+
5717
+ this.locusInfo.suspendDestroyMeeting(false);
5543
5718
 
5544
5719
  return {
5545
5720
  join: joinResponse,
@@ -5553,8 +5728,12 @@ export default class Meeting extends StatelessWebexPlugin {
5553
5728
 
5554
5729
  this.roap.abortTurnDiscovery();
5555
5730
 
5556
- // if this was the first attempt, let's do a retry
5557
- let shouldRetry = !isRetry;
5731
+ // let's do a retry (but not on 1-1 calls, because the flow would get too complicated)
5732
+ let shouldRetry =
5733
+ !MeetingsUtil.isOneOnOneCall(this.locusInfo.parsedLocus) &&
5734
+ (retryCount < 1 ||
5735
+ ((error instanceof UserNotJoinedError || this.isErrorMeaningLocusDroppedUs(error)) &&
5736
+ retryCount < JOIN_WITH_MEDIA_RETRY_MAX_COUNT));
5558
5737
 
5559
5738
  if (
5560
5739
  CallDiagnosticUtils.isSdpOfferCreationError(error) ||
@@ -5579,8 +5758,8 @@ export default class Meeting extends StatelessWebexPlugin {
5579
5758
  });
5580
5759
  }
5581
5760
 
5582
- // we only want to call leave if join was successful and this was a retry or we won't be doing any more retries
5583
- if (joined && (isRetry || !shouldRetry)) {
5761
+ // we only want to call leave if join was successful, and we won't be doing any more retries
5762
+ if (joined && !shouldRetry) {
5584
5763
  try {
5585
5764
  await this.leave({resourceId: joinOptions?.resourceId, reason: 'joinWithMedia failure'});
5586
5765
  } catch (e) {
@@ -5597,7 +5776,7 @@ export default class Meeting extends StatelessWebexPlugin {
5597
5776
  reason: error.message,
5598
5777
  stack: error.stack,
5599
5778
  leaveErrorReason: leaveError?.message,
5600
- isRetry,
5779
+ isRetry: retryCount > 0,
5601
5780
  },
5602
5781
  {
5603
5782
  type: error.name,
@@ -5606,15 +5785,28 @@ export default class Meeting extends StatelessWebexPlugin {
5606
5785
 
5607
5786
  if (shouldRetry) {
5608
5787
  LoggerProxy.logger.warn('Meeting:index#joinWithMedia --> retrying call to joinWithMedia');
5609
- this.joinWithMediaRetryInfo.isRetry = true;
5788
+ this.joinWithMediaRetryInfo.retryCount = retryCount + 1;
5610
5789
  this.joinWithMediaRetryInfo.prevJoinResponse = joinResponse;
5790
+ this.joinWithMediaRetryInfo.prevError = error;
5791
+ if (!this.joinWithMediaRetryInfo.firstError) {
5792
+ this.joinWithMediaRetryInfo.firstError = error;
5793
+ }
5611
5794
 
5612
5795
  return this.joinWithMedia(options);
5613
5796
  }
5614
5797
 
5615
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
5798
+ const {firstError} = this.joinWithMediaRetryInfo;
5616
5799
 
5617
- throw error;
5800
+ this.joinWithMediaRetryInfo = {
5801
+ retryCount: 0,
5802
+ prevJoinResponse: undefined,
5803
+ firstError: undefined,
5804
+ prevError: undefined,
5805
+ };
5806
+
5807
+ this.locusInfo.suspendDestroyMeeting(false);
5808
+
5809
+ throw firstError ?? error;
5618
5810
  }
5619
5811
  }
5620
5812
 
@@ -5865,6 +6057,31 @@ export default class Meeting extends StatelessWebexPlugin {
5865
6057
  }
5866
6058
  };
5867
6059
 
6060
+ /**
6061
+ * Verifies the relay event was delivered for the active LLM session binding.
6062
+ * @param {RelayEvent} event Event object coming from LLM Connection
6063
+ * @returns {boolean}
6064
+ */
6065
+ private isRelayEventRouteValid(event: RelayEvent): boolean {
6066
+ const route = event?.headers?.route;
6067
+
6068
+ if (!route) {
6069
+ return true;
6070
+ }
6071
+
6072
+ const {llm} = (this as any).webex.internal;
6073
+ const isPracticeSession = llm.isConnected(LLM_PRACTICE_SESSION);
6074
+ const expectedBinding = isPracticeSession
6075
+ ? llm.getBinding(LLM_PRACTICE_SESSION)
6076
+ : llm.getBinding();
6077
+
6078
+ if (!expectedBinding || route === expectedBinding) {
6079
+ return true;
6080
+ }
6081
+
6082
+ return false;
6083
+ }
6084
+
5868
6085
  /**
5869
6086
  * Callback called when a relay event is received from meeting LLM Connection
5870
6087
  * @param {RelayEvent} e Event object coming from LLM Connection
@@ -5872,6 +6089,9 @@ export default class Meeting extends StatelessWebexPlugin {
5872
6089
  * @returns {void}
5873
6090
  */
5874
6091
  private processRelayEvent = (e: RelayEvent): void => {
6092
+ if (!this.isRelayEventRouteValid(e)) {
6093
+ return;
6094
+ }
5875
6095
  switch (e.data.relayType) {
5876
6096
  case REACTION_RELAY_TYPES.REACTION:
5877
6097
  if (
@@ -6002,6 +6222,7 @@ export default class Meeting extends StatelessWebexPlugin {
6002
6222
  */
6003
6223
  private handleLLMOnline = (): void => {
6004
6224
  this.restoreLLMSubscriptionsIfNeeded();
6225
+ this.locusInfo.syncAllHashTreeDatasets({onlyLLM: true});
6005
6226
 
6006
6227
  Trigger.trigger(
6007
6228
  this,
@@ -6301,8 +6522,57 @@ export default class Meeting extends StatelessWebexPlugin {
6301
6522
  }
6302
6523
  }
6303
6524
 
6525
+ /**
6526
+ * Removes LLM event listeners and clears the health check timer.
6527
+ * Must be called before Locus /leave to avoid unnecessary syncs triggered
6528
+ * by events received while leaving (per Locus team recommendation).
6529
+ * Idempotent: safe to call multiple times; .off() is a no-op when no
6530
+ * matching listener is registered.
6531
+ * @private
6532
+ * @returns {void}
6533
+ */
6534
+ private stopListeningForLLMEvents() {
6535
+ // @ts-ignore - fix types
6536
+ this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6537
+ // @ts-ignore - fix types
6538
+ this.webex.internal.llm.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6539
+ this.clearLLMHealthCheckTimer();
6540
+ }
6541
+
6542
+ /**
6543
+ * Stops listening on every event bus (LLM, Mercury, voicea/transcription,
6544
+ * annotation) that could otherwise deliver events to this meeting while
6545
+ * Locus is processing /leave or /end. Per the Locus team recommendation,
6546
+ * this must run before the Locus request is dispatched to avoid
6547
+ * unnecessary syncs triggered by in-flight events.
6548
+ *
6549
+ * Voicea (transcription) subscribes to llm 'event:relay.event' internally,
6550
+ * and the annotation plugin subscribes to both mercury and llm, so both
6551
+ * must be torn down alongside the direct LLM/Mercury listeners.
6552
+ *
6553
+ * Idempotent: safe to call multiple times; .off() is a no-op when no
6554
+ * matching listener is registered, and stopTranscription is guarded.
6555
+ * @private
6556
+ * @returns {void}
6557
+ */
6558
+ private stopListeningForMeetingEvents() {
6559
+ this.stopListeningForLLMEvents();
6560
+ this.stopListeningForMercuryEvents();
6561
+ if (this.transcription) {
6562
+ this.stopTranscription();
6563
+ this.transcription = undefined;
6564
+ }
6565
+ this.annotation.deregisterEvents();
6566
+ }
6567
+
6304
6568
  /**
6305
6569
  * Disconnects and cleans up the default LLM session listeners/timers.
6570
+ *
6571
+ * Ownership-aware: only calls `disconnectLLM` when this meeting is the
6572
+ * current owner of the default LLM session (or when no owner is recorded).
6573
+ * Event listeners belonging to this meeting instance are always detached
6574
+ * so they do not receive another meeting's relay events.
6575
+ *
6306
6576
  * @param {Object} options
6307
6577
  * @param {boolean} [options.removeOnlineListener=true] removes the one-time online listener
6308
6578
  * @param {boolean} [options.throwOnError=true] rethrows disconnect errors when true
@@ -6315,12 +6585,29 @@ export default class Meeting extends StatelessWebexPlugin {
6315
6585
  removeOnlineListener?: boolean;
6316
6586
  throwOnError?: boolean;
6317
6587
  } = {}): Promise<void> => {
6588
+ // @ts-ignore - Fix type
6589
+ // @ts-ignore - Fix type
6590
+ const {currentOwner, isOwner} = this.webex.internal.llm.resolveSessionOwnership(
6591
+ this.id,
6592
+ LLM_DEFAULT_SESSION
6593
+ );
6594
+
6318
6595
  try {
6319
- // @ts-ignore - Fix type
6320
- await this.webex.internal.llm.disconnectLLM({
6321
- code: 3050,
6322
- reason: 'done (permanent)',
6323
- });
6596
+ if (isOwner) {
6597
+ // @ts-ignore - Fix type
6598
+ await this.webex.internal.llm.disconnectLLM(
6599
+ {
6600
+ code: 3050,
6601
+ reason: 'done (permanent)',
6602
+ },
6603
+ LLM_DEFAULT_SESSION,
6604
+ this.id
6605
+ );
6606
+ } else {
6607
+ LoggerProxy.logger.info(
6608
+ `Meeting:index#cleanupLLMConneciton --> skipping disconnect; LLM owned by meeting ${currentOwner}, not ${this.id}`
6609
+ );
6610
+ }
6324
6611
  } catch (error) {
6325
6612
  LoggerProxy.logger.error(
6326
6613
  'Meeting:index#cleanupLLMConneciton --> Failed to disconnect default LLM session',
@@ -6335,23 +6622,33 @@ export default class Meeting extends StatelessWebexPlugin {
6335
6622
  // @ts-ignore - Fix type
6336
6623
  this.webex.internal.llm.off('online', this.handleLLMOnline);
6337
6624
  }
6338
- // @ts-ignore - fix types
6339
- this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6340
- // @ts-ignore - Fix type
6341
- this.webex.internal.llm.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6625
+ this.stopListeningForLLMEvents();
6626
+
6627
+ // Re-check ownership after awaiting disconnectLLM. If ownership changed
6628
+ // while cleanup was in flight, do not clear another meeting's owner tag.
6629
+ if (isOwner) {
6630
+ const {currentOwner: currentOwnerAfterCleanup} =
6631
+ // @ts-ignore - Fix type
6632
+ this.webex.internal.llm.resolveSessionOwnership(this.id, LLM_DEFAULT_SESSION);
6342
6633
 
6343
- this.clearLLMHealthCheckTimer();
6634
+ if (currentOwnerAfterCleanup === this.id) {
6635
+ // @ts-ignore - Fix type
6636
+ this.webex.internal.llm.setOwnerMeetingId?.(undefined);
6637
+ }
6638
+ }
6344
6639
  }
6345
6640
  };
6346
6641
 
6347
6642
  /**
6348
- * Clears all data channel tokens stored in LLM.
6349
- * Called during meeting cleanup to ensure stale tokens are not reused.
6643
+ * Clears data channel tokens associated with this meeting ownership.
6644
+ * Ownership checks are enforced in internal-plugin-llm.
6350
6645
  * @returns {void}
6351
6646
  */
6352
6647
  clearDataChannelToken(): void {
6353
6648
  // @ts-ignore
6354
- this.webex.internal.llm.resetDatachannelTokens();
6649
+ this.webex.internal.llm.clearDatachannelToken(LLM_DEFAULT_SESSION, this.id);
6650
+ // @ts-ignore
6651
+ this.webex.internal.llm.clearDatachannelToken(LLM_PRACTICE_SESSION, this.id);
6355
6652
  }
6356
6653
 
6357
6654
  /**
@@ -6366,14 +6663,15 @@ export default class Meeting extends StatelessWebexPlugin {
6366
6663
 
6367
6664
  if (datachannelToken) {
6368
6665
  // @ts-ignore
6369
- this.webex.internal.llm.setDatachannelToken(datachannelToken, DataChannelTokenType.Default);
6666
+ this.webex.internal.llm.setDatachannelToken(datachannelToken, LLM_DEFAULT_SESSION, this.id);
6370
6667
  }
6371
6668
 
6372
6669
  if (practiceSessionDatachannelToken) {
6373
6670
  // @ts-ignore
6374
6671
  this.webex.internal.llm.setDatachannelToken(
6375
6672
  practiceSessionDatachannelToken,
6376
- DataChannelTokenType.PracticeSession
6673
+ LLM_PRACTICE_SESSION,
6674
+ this.id
6377
6675
  );
6378
6676
  }
6379
6677
  }
@@ -6386,7 +6684,10 @@ export default class Meeting extends StatelessWebexPlugin {
6386
6684
  private async ensureDefaultDatachannelTokenAfterAdmit(): Promise<boolean> {
6387
6685
  try {
6388
6686
  // @ts-ignore
6389
- const datachannelToken = this.webex.internal.llm.getDatachannelToken();
6687
+ const datachannelToken = this.webex.internal.llm.getDatachannelToken(
6688
+ LLM_DEFAULT_SESSION,
6689
+ this.id
6690
+ );
6390
6691
  // @ts-ignore
6391
6692
  const isDataChannelTokenEnabled = await this.webex.internal.llm.isDataChannelTokenEnabled();
6392
6693
 
@@ -6408,7 +6709,8 @@ export default class Meeting extends StatelessWebexPlugin {
6408
6709
  // @ts-ignore
6409
6710
  this.webex.internal.llm.setDatachannelToken(
6410
6711
  fetchedDatachannelToken,
6411
- DataChannelTokenType.Default
6712
+ LLM_DEFAULT_SESSION,
6713
+ this.id
6412
6714
  );
6413
6715
 
6414
6716
  return true;
@@ -6435,15 +6737,58 @@ export default class Meeting extends StatelessWebexPlugin {
6435
6737
 
6436
6738
  const isJoined = this.isJoined();
6437
6739
 
6438
- // @ts-ignore
6439
- const datachannelToken = this.webex.internal.llm.getDatachannelToken(
6440
- DataChannelTokenType.Default
6740
+ const dataChannelUrl = datachannelUrl;
6741
+
6742
+ // Ownership guard: when the default LLM session is already connected and
6743
+ // owned by a *different* Meeting instance, do not disconnect or reconfigure
6744
+ // it. Another meeting's `updateLLMConnection` must be ignored here to
6745
+ // avoid killing the socket it relies on. We only proceed to manage the
6746
+ // connection when this meeting is the current owner, or when no owner is
6747
+ // set yet (first claim).
6748
+ // @ts-ignore - Fix type
6749
+ const {currentOwner} = this.webex.internal.llm.resolveSessionOwnership(
6750
+ this.id,
6751
+ LLM_DEFAULT_SESSION
6441
6752
  );
6442
6753
 
6443
- const dataChannelUrl = datachannelUrl;
6754
+ // Capture connectivity before any reconnect attempt. If LLM was already
6755
+ // connected, we must respect current ownership. If it was disconnected,
6756
+ // this flow may reclaim stale owner tags after a fresh connect.
6757
+ // @ts-ignore - Fix type
6758
+ const wasConnected = this.webex.internal.llm.isConnected();
6444
6759
 
6760
+ // Prefer ownership-scoped token read. For disconnected stale-owner reclaim
6761
+ // flows, fallback to ownerless read so initial register can still carry a
6762
+ // token and recover from stale ownership without 401/403 dead-end.
6445
6763
  // @ts-ignore - Fix type
6446
- if (this.webex.internal.llm.isConnected()) {
6764
+ let datachannelToken = this.webex.internal.llm.getDatachannelToken(
6765
+ LLM_DEFAULT_SESSION,
6766
+ this.id
6767
+ );
6768
+
6769
+ if (!datachannelToken && !wasConnected && currentOwner && currentOwner !== this.id) {
6770
+ // @ts-ignore - Fix type
6771
+ datachannelToken = this.webex.internal.llm.getDatachannelToken(LLM_DEFAULT_SESSION);
6772
+ }
6773
+
6774
+ // @ts-ignore - Fix type
6775
+ if (wasConnected) {
6776
+ if (currentOwner && currentOwner !== this.id) {
6777
+ // Another meeting owns the live LLM socket. We must not disconnect
6778
+ // or reconfigure it -- doing so would tear down a session the
6779
+ // owning meeting still relies on. Locus/datachannel URL mismatch is
6780
+ // expected here (each meeting has its own locus URL) and is NOT a
6781
+ // valid signal of staleness, so we never reclaim from this path.
6782
+ // The only safe reclaim mechanism is the `finally`-block owner-tag
6783
+ // release in `cleanupLLMConneciton`, which fires when this meeting
6784
+ // itself is being torn down.
6785
+ LoggerProxy.logger.info(
6786
+ `Meeting:index#updateLLMConnection --> skipping; LLM owned by meeting ${currentOwner}, not ${this.id}`
6787
+ );
6788
+
6789
+ return undefined;
6790
+ }
6791
+
6447
6792
  if (
6448
6793
  // @ts-ignore - Fix type
6449
6794
  url === this.webex.internal.llm.getLocusUrl() &&
@@ -6460,10 +6805,56 @@ export default class Meeting extends StatelessWebexPlugin {
6460
6805
  return undefined;
6461
6806
  }
6462
6807
 
6808
+ // Bind refresh handler before registration so interceptor-triggered token
6809
+ // refresh during register POST can resolve a valid handler.
6810
+ // Prefer this meeting as owner, but allow owner-less fallback when a stale
6811
+ // foreign owner tag is present on a disconnected session.
6812
+ const refreshHandlerOwnerMeetingId =
6813
+ currentOwner && currentOwner !== this.id ? undefined : this.id;
6814
+ const shouldAlignRefreshHandlerAfterOwnershipClaim = refreshHandlerOwnerMeetingId !== this.id;
6815
+ // @ts-ignore - Fix type
6816
+ this.webex.internal.llm.setRefreshHandler(
6817
+ () => this.refreshDataChannelToken(),
6818
+ LLM_DEFAULT_SESSION,
6819
+ refreshHandlerOwnerMeetingId
6820
+ );
6821
+
6463
6822
  // @ts-ignore - Fix type
6464
6823
  return this.webex.internal.llm
6465
6824
  .registerAndConnect(url, dataChannelUrl, datachannelToken)
6466
6825
  .then((registerAndConnectResult) => {
6826
+ this.locusInfo.syncAllHashTreeDatasets({onlyLLM: true});
6827
+ // Record ownership of the default LLM session for this meeting so
6828
+ // subsequent cross-meeting `updateLLMConnection` / `cleanupLLMConneciton`
6829
+ // calls can detect and skip work that doesn't belong to them.
6830
+ // @ts-ignore - Fix type
6831
+ const {isOwner} = this.webex.internal.llm.resolveSessionOwnership(
6832
+ this.id,
6833
+ LLM_DEFAULT_SESSION
6834
+ );
6835
+ const canReclaimAfterDisconnectedStart = !wasConnected;
6836
+
6837
+ // Refresh handler is pre-bound before registerAndConnect so token
6838
+ // refresh can work even during the registration request itself.
6839
+ if (isOwner || canReclaimAfterDisconnectedStart) {
6840
+ // Record ownership of the default LLM session for this meeting so
6841
+ // subsequent cross-meeting `updateLLMConnection` / `cleanupLLMConneciton`
6842
+ // calls can detect and skip work that doesn't belong to them.
6843
+ // @ts-ignore - Fix type
6844
+ this.webex.internal.llm.setOwnerMeetingId?.(this.id);
6845
+
6846
+ // If we pre-bound refresh ownerlessly (stale-owner reclaim path),
6847
+ // align the handler with the newly claimed owner immediately after
6848
+ // ownership is updated.
6849
+ if (shouldAlignRefreshHandlerAfterOwnershipClaim) {
6850
+ // @ts-ignore - Fix type
6851
+ this.webex.internal.llm.setRefreshHandler(
6852
+ () => this.refreshDataChannelToken(),
6853
+ LLM_DEFAULT_SESSION,
6854
+ this.id
6855
+ );
6856
+ }
6857
+ }
6467
6858
  // @ts-ignore - Fix type
6468
6859
  this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6469
6860
  // @ts-ignore - Fix type
@@ -7504,23 +7895,104 @@ export default class Meeting extends StatelessWebexPlugin {
7504
7895
  }
7505
7896
  }
7506
7897
  });
7898
+ this.statsAnalyzer.on(StatsAnalyzerEventNames.STATS_UPDATE, (data) => {
7899
+ // Extract srtpCipher from transport stats
7900
+ let srtpCipher: string | undefined;
7901
+ for (const stats of data.stats.values()) {
7902
+ if (stats.type === 'transport' && stats.srtpCipher) {
7903
+ srtpCipher = stats.srtpCipher as string;
7904
+ break;
7905
+ }
7906
+ }
7907
+
7908
+ // Only emit event if srtpCipher has changed
7909
+ if (srtpCipher && srtpCipher !== this.mediaProperties.srtpCipher) {
7910
+ LoggerProxy.logger.info(
7911
+ `Meeting:index#setupStatsAnalyzerEventHandlers --> SRTP cipher changed from ${this.mediaProperties.srtpCipher} to ${srtpCipher}`
7912
+ );
7913
+ this.mediaProperties.srtpCipher = srtpCipher;
7914
+ Trigger.trigger(
7915
+ this,
7916
+ {
7917
+ file: 'meeting/index',
7918
+ function: 'setupStatsAnalyzerEventHandlers',
7919
+ },
7920
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
7921
+ {srtpCipher}
7922
+ );
7923
+ }
7924
+ });
7507
7925
  };
7508
7926
 
7509
7927
  getMediaConnectionDebugId() {
7510
7928
  return `MC-${this.id.substring(0, 4)}`;
7511
7929
  }
7512
7930
 
7931
+ /**
7932
+ * Checks if the error indicates that Locus dropped us from the meeting,
7933
+ * either directly on the error or wrapped inside an AddMediaFailed cause.
7934
+ * This method is meant to be called only with errors thrown by Meeting.addMediaInternal()
7935
+ *
7936
+ * @param {Error} error
7937
+ * @returns {boolean}
7938
+ */
7939
+ private isErrorMeaningLocusDroppedUs(error: Error | undefined): boolean {
7940
+ const statusCode = (error as any)?.statusCode;
7941
+ const causeStatusCode = (error as any)?.cause?.statusCode;
7942
+
7943
+ return (
7944
+ statusCode === 409 || statusCode === 403 || causeStatusCode === 409 || causeStatusCode === 403
7945
+ );
7946
+ }
7947
+
7948
+ /**
7949
+ * Determines if the next media attempt should use only TURN-TLS (iceTransportPolicy='relay').
7950
+ * We do this in the hope that it will minimize the chance of Homer sending DTLS packets on a wrong
7951
+ * transport (as there will be only 1 transport) and dealing with firewalls that let STUN packets through, but block
7952
+ * other UDP traffic.
7953
+ *
7954
+ * For clients landing on video mesh nodes (VMN), reachability might still have successful TLS (to public nodes)
7955
+ * but TURN discovery will result in empty TURN urls array and iceTransportPolicy='relay' will still be overriden to undefined,
7956
+ * see the code in establishMediaConnection()
7957
+ *
7958
+ * @param {Error} prevError - The error from the previous addMedia attempt
7959
+ * @returns {Promise<boolean>}
7960
+ */
7961
+ private async shouldRetryMediaWithOnlyTurnTLS(prevError: Error | undefined): Promise<boolean> {
7962
+ if (
7963
+ this.isMultistream &&
7964
+ prevError instanceof AddMediaFailed &&
7965
+ prevError.isDtlsHandshakeFailure &&
7966
+ prevError.connectionType === 'UDP'
7967
+ ) {
7968
+ const hasTlsReachability =
7969
+ // @ts-ignore
7970
+ await this.webex.meetings.reachability.isAnyClusterReachableViaProtocol('xtls');
7971
+
7972
+ if (hasTlsReachability) {
7973
+ LoggerProxy.logger.info(
7974
+ 'Meeting:index#shouldRetryMediaWithOnlyTurnTLS --> previous attempt failed due to DTLS handshake failure over UDP and TLS reachability is available'
7975
+ );
7976
+
7977
+ return true;
7978
+ }
7979
+ }
7980
+
7981
+ return false;
7982
+ }
7983
+
7513
7984
  /**
7514
7985
  * Creates a webrtc media connection and publishes streams to it
7515
7986
  *
7516
7987
  * @param {Object} turnServerInfo TURN server information
7517
7988
  * @param {BundlePolicy} [bundlePolicy] Bundle policy settings
7518
- * @param {AddMediaOptions} [options] Options for enabling/disabling audio/video
7989
+ * @param {RTCIceTransportPolicy} [iceTransportPolicy] ICE transport policy override
7519
7990
  * @returns {RoapMediaConnection | MultistreamRoapMediaConnection}
7520
7991
  */
7521
7992
  private async createMediaConnection(
7522
7993
  turnServerInfo?: TurnServerInfo,
7523
- bundlePolicy?: BundlePolicy
7994
+ bundlePolicy?: BundlePolicy,
7995
+ iceTransportPolicy?: RTCIceTransportPolicy
7524
7996
  ) {
7525
7997
  this.rtcMetrics = this.isMultistream
7526
7998
  ? // @ts-ignore
@@ -7544,12 +8016,15 @@ export default class Meeting extends StatelessWebexPlugin {
7544
8016
  enableExtmap: this.config.enableExtmap,
7545
8017
  turnServerInfo,
7546
8018
  bundlePolicy,
8019
+ iceTransportPolicy,
7547
8020
  // @ts-ignore - config coming from registerPlugin
7548
8021
  iceCandidatesTimeout: this.config.iceCandidatesGatheringTimeout,
7549
8022
  // @ts-ignore - config coming from registerPlugin
7550
8023
  disableAudioMainDtx: this.config.experimental.disableAudioMainDtx,
7551
8024
  // @ts-ignore - config coming from registerPlugin
7552
8025
  enableAudioTwcc: this.config.enableAudioTwccForMultistream,
8026
+ // @ts-ignore - config coming from registerPlugin
8027
+ enableAv1SlidesSupport: this.config.enableAv1SlidesSupport,
7553
8028
  stopIceGatheringAfterFirstRelayCandidate:
7554
8029
  // @ts-ignore - config coming from registerPlugin
7555
8030
  this.config.stopIceGatheringAfterFirstRelayCandidate,
@@ -7668,7 +8143,7 @@ export default class Meeting extends StatelessWebexPlugin {
7668
8143
  try {
7669
8144
  await this.mediaProperties.waitForMediaConnectionConnected(this.correlationId);
7670
8145
  } catch (error) {
7671
- const {iceConnected} = error;
8146
+ const {iceConnected} = error as MediaConnectionAwaiterFailureResult;
7672
8147
 
7673
8148
  if (!this.hasMediaConnectionConnectedAtLeastOnce) {
7674
8149
  // Only send CA event for join flow if we haven't successfully connected media yet
@@ -7708,13 +8183,12 @@ export default class Meeting extends StatelessWebexPlugin {
7708
8183
  });
7709
8184
  }
7710
8185
 
7711
- const timedOutError = new Error(
7712
- `Timed out waiting for media connection to be connected, correlationId=${this.correlationId}`
8186
+ throw new MediaConnectionTimedOutError(
8187
+ `Timed out waiting for media connection to be connected, correlationId=${this.correlationId}`,
8188
+ iceConnected,
8189
+ // keep reference to the original rejected result (which is the object the SDK reports to CA as rawError above)
8190
+ error
7713
8191
  );
7714
-
7715
- timedOutError.cause = error;
7716
-
7717
- throw timedOutError;
7718
8192
  }
7719
8193
  }
7720
8194
 
@@ -7927,7 +8401,18 @@ export default class Meeting extends StatelessWebexPlugin {
7927
8401
  error
7928
8402
  );
7929
8403
 
7930
- throw new AddMediaFailed(error);
8404
+ const {connectionType, selectedCandidatePairChanges, numTransports} =
8405
+ await this.mediaProperties.getCurrentConnectionInfo();
8406
+
8407
+ const iceConnected = error instanceof MediaConnectionTimedOutError && error.iceConnected;
8408
+
8409
+ throw new AddMediaFailed({
8410
+ cause: error,
8411
+ connectionType,
8412
+ selectedCandidatePairChanges,
8413
+ numTransports,
8414
+ iceConnected,
8415
+ });
7931
8416
  }
7932
8417
  }
7933
8418
 
@@ -8002,7 +8487,21 @@ export default class Meeting extends StatelessWebexPlugin {
8002
8487
  ({turnServerInfo} = await this.doTurnDiscovery(isReconnecting, isForced));
8003
8488
  }
8004
8489
 
8005
- const mc = await this.createMediaConnection(turnServerInfo, bundlePolicy);
8490
+ if (
8491
+ (!turnServerInfo || !turnServerInfo.urls?.length) &&
8492
+ this.addMediaData.iceTransportPolicy === 'relay'
8493
+ ) {
8494
+ LoggerProxy.logger.info(
8495
+ `${LOG_HEADER} cannot do iceTransportPolicy=relay, because there is no turn server info available`
8496
+ );
8497
+ // drop the forced relay policy and use the default, because we don't have a TURN server
8498
+ this.addMediaData.iceTransportPolicy = undefined;
8499
+ }
8500
+ const mediaConnection = await this.createMediaConnection(
8501
+ turnServerInfo,
8502
+ bundlePolicy,
8503
+ this.addMediaData.iceTransportPolicy
8504
+ );
8006
8505
 
8007
8506
  LoggerProxy.logger.info(
8008
8507
  `${LOG_HEADER} media connection created this.isMultistream=${this.isMultistream}`
@@ -8039,7 +8538,7 @@ export default class Meeting extends StatelessWebexPlugin {
8039
8538
  await this.remoteMediaManager.start();
8040
8539
  }
8041
8540
 
8042
- await mc.initiateOffer();
8541
+ await mediaConnection.initiateOffer();
8043
8542
 
8044
8543
  await this.waitForRemoteSDPAnswer();
8045
8544
 
@@ -8107,6 +8606,9 @@ export default class Meeting extends StatelessWebexPlugin {
8107
8606
 
8108
8607
  this.isMultistream = false;
8109
8608
 
8609
+ // reset iceTransportPolicy, because it's only applied for multistream media connections
8610
+ this.addMediaData.iceTransportPolicy = undefined;
8611
+
8110
8612
  if (this.mediaProperties.webrtcMediaConnection) {
8111
8613
  // close peer connection, but don't reset mute state information, because we will want to use it on the retry
8112
8614
  this.closePeerConnections(false);
@@ -8187,6 +8689,8 @@ export default class Meeting extends StatelessWebexPlugin {
8187
8689
  regionCode: this.webex.meetings.geoHintInfo?.regionCode,
8188
8690
  },
8189
8691
  preferTranscoding: !this.isMultistream,
8692
+ getCurrentSelfUrl: () => this.selfUrl,
8693
+ waitForSelfUrlChange: () => this.waitForSelfUrlChange(),
8190
8694
  },
8191
8695
  {
8192
8696
  // @ts-ignore
@@ -8195,6 +8699,41 @@ export default class Meeting extends StatelessWebexPlugin {
8195
8699
  );
8196
8700
  }
8197
8701
 
8702
+ /**
8703
+ * Waits for LocusInfo to update meeting.selfUrl, with a timeout fallback.
8704
+ * @returns {Promise<void>}
8705
+ * @private
8706
+ * @memberof Meeting
8707
+ */
8708
+ private waitForSelfUrlChange(): Promise<void> {
8709
+ if (this.joinWithMediaRetryInfo.retryCount > 0) {
8710
+ /* During joinWithMedia() retries we can get 403/409 from Locus and it doesn't mean
8711
+ * that the selfUrl will change, it is usually caused by Locus dropping us as a result of
8712
+ * media connection failure during joinWithMedia's earlier media connection attempt,
8713
+ * so we don't want to wait for selfUrl change as this would only slow down the join process. */
8714
+ LoggerProxy.logger.info(
8715
+ 'Meeting:index#waitForSelfUrlChange --> joinWithMedia retry in progress, will not wait for selfUrl change'
8716
+ );
8717
+
8718
+ return Promise.resolve();
8719
+ }
8720
+
8721
+ if (!this.promisesWaitingForPropUpdate.selfUrl) {
8722
+ const pendingSelfUrlUpdate = new Defer();
8723
+
8724
+ this.promisesWaitingForPropUpdate.selfUrl = pendingSelfUrlUpdate;
8725
+
8726
+ setTimeout(() => {
8727
+ if (this.promisesWaitingForPropUpdate.selfUrl === pendingSelfUrlUpdate) {
8728
+ delete this.promisesWaitingForPropUpdate.selfUrl;
8729
+ pendingSelfUrlUpdate.resolve();
8730
+ }
8731
+ }, 5000);
8732
+ }
8733
+
8734
+ return this.promisesWaitingForPropUpdate.selfUrl.promise;
8735
+ }
8736
+
8198
8737
  /**
8199
8738
  * Creates a media connection to the server. Media connection is required for sending or receiving any audio/video.
8200
8739
  *
@@ -8206,8 +8745,9 @@ export default class Meeting extends StatelessWebexPlugin {
8206
8745
  addMedia(options: AddMediaOptions = {}): Promise<void> {
8207
8746
  return this.addMediaInternal(
8208
8747
  () => (this.turnServerUsed ? 'JOIN_MEETING_FINAL' : 'JOIN_MEETING_RETRY'),
8209
- undefined,
8210
8748
  false,
8749
+ undefined /* turnServerInfo - it will be fetched via doTurnDiscovery() */,
8750
+ undefined /* iceTransportPolicy - we're relying on the default value */,
8211
8751
  options
8212
8752
  );
8213
8753
  }
@@ -8216,8 +8756,9 @@ export default class Meeting extends StatelessWebexPlugin {
8216
8756
  * Internal version of addMedia() with some more arguments for finer control of its behavior
8217
8757
  *
8218
8758
  * @param {Function} icePhaseCallback - callback to determine the icePhase for CA "client.ice.end" failure events
8219
- * @param {TurnServerInfo} turnServerInfo - TURN server information
8220
8759
  * @param {boolean} forceTurnDiscovery - if true, TURN discovery will be done
8760
+ * @param {TurnServerInfo} turnServerInfo - TURN server information
8761
+ * @param {RTCIceTransportPolicy} [iceTransportPolicy] - ICE transport policy override
8221
8762
  * @param {AddMediaOptions} options - same as options of the public addMedia() method
8222
8763
  * @returns {Promise<void>}
8223
8764
  * @protected
@@ -8225,12 +8766,14 @@ export default class Meeting extends StatelessWebexPlugin {
8225
8766
  */
8226
8767
  protected async addMediaInternal(
8227
8768
  icePhaseCallback: () => string,
8228
- turnServerInfo: TurnServerInfo,
8229
- forceTurnDiscovery,
8769
+ forceTurnDiscovery: boolean,
8770
+ turnServerInfo?: TurnServerInfo,
8771
+ iceTransportPolicy?: RTCIceTransportPolicy,
8230
8772
  options: AddMediaOptions = {}
8231
8773
  ): Promise<void> {
8232
8774
  this.addMediaData.retriedWithTurnServer = false;
8233
8775
  this.addMediaData.icePhaseCallback = icePhaseCallback;
8776
+ this.addMediaData.iceTransportPolicy = iceTransportPolicy;
8234
8777
 
8235
8778
  this.hasMediaConnectionConnectedAtLeastOnce = false;
8236
8779
  const LOG_HEADER = 'Meeting:index#addMedia -->';
@@ -8239,7 +8782,7 @@ export default class Meeting extends StatelessWebexPlugin {
8239
8782
  options
8240
8783
  )}, turnServerInfo=${JSON.stringify(
8241
8784
  turnServerInfo
8242
- )}, forceTurnDiscovery=${forceTurnDiscovery}`
8785
+ )}, forceTurnDiscovery=${forceTurnDiscovery}, iceTransportPolicy=${iceTransportPolicy}`
8243
8786
  );
8244
8787
 
8245
8788
  if (options.allowMediaInLobby !== true && this.meetingState !== FULL_STATE.ACTIVE) {
@@ -8353,12 +8896,7 @@ export default class Meeting extends StatelessWebexPlugin {
8353
8896
 
8354
8897
  // Establish new media connection with forced TURN discovery
8355
8898
  // We need to do TURN discovery again, because backend will be creating a new confluence, so it might land on a different node or cluster
8356
- await this.establishMediaConnection(
8357
- remoteMediaManagerConfig,
8358
- bundlePolicy,
8359
- true,
8360
- undefined
8361
- );
8899
+ await this.establishMediaConnection(remoteMediaManagerConfig, bundlePolicy, true);
8362
8900
  } else {
8363
8901
  throw error;
8364
8902
  }
@@ -8387,7 +8925,8 @@ export default class Meeting extends StatelessWebexPlugin {
8387
8925
  numTransports,
8388
8926
  isMultistream: this.isMultistream,
8389
8927
  retriedWithTurnServer: this.addMediaData.retriedWithTurnServer,
8390
- isJoinWithMediaRetry: this.joinWithMediaRetryInfo.isRetry,
8928
+ isJoinWithMediaRetry: this.joinWithMediaRetryInfo.retryCount > 0,
8929
+ iceTransportPolicy: this.addMediaData.iceTransportPolicy || 'all',
8391
8930
  ...reachabilityMetrics,
8392
8931
  ...iceCandidateErrors,
8393
8932
  iceCandidatesCount: this.iceCandidatesCount,
@@ -8409,14 +8948,16 @@ export default class Meeting extends StatelessWebexPlugin {
8409
8948
  // We can log ReceiveSlot SSRCs only after the SDP exchange, so doing it here:
8410
8949
  this.remoteMediaManager?.logAllReceiveSlots();
8411
8950
  this.startPeriodicLogUpload();
8412
- } catch (error) {
8951
+ } catch (error: any) {
8413
8952
  LoggerProxy.logger.error(`${LOG_HEADER} failed to establish media connection: `, error);
8414
8953
 
8415
8954
  // @ts-ignore
8416
8955
  const reachabilityMetrics = await this.getMediaReachabilityMetricFields();
8417
8956
 
8418
- const {selectedCandidatePairChanges, numTransports} =
8419
- await this.mediaProperties.getCurrentConnectionInfo();
8957
+ const {connectionType, selectedCandidatePairChanges, numTransports} =
8958
+ error instanceof AddMediaFailed
8959
+ ? error
8960
+ : await this.mediaProperties.getCurrentConnectionInfo();
8420
8961
 
8421
8962
  const iceCandidateErrors = Object.fromEntries(this.iceCandidateErrors);
8422
8963
 
@@ -8432,7 +8973,8 @@ export default class Meeting extends StatelessWebexPlugin {
8432
8973
  turnServerUsed: this.turnServerUsed,
8433
8974
  retriedWithTurnServer: this.addMediaData.retriedWithTurnServer,
8434
8975
  isMultistream: this.isMultistream,
8435
- isJoinWithMediaRetry: this.joinWithMediaRetryInfo.isRetry,
8976
+ isJoinWithMediaRetry: this.joinWithMediaRetryInfo.retryCount > 0,
8977
+ iceTransportPolicy: this.addMediaData.iceTransportPolicy || 'all',
8436
8978
  signalingState:
8437
8979
  this.mediaProperties.webrtcMediaConnection?.multistreamConnection?.pc?.pc
8438
8980
  ?.signalingState ||
@@ -8448,6 +8990,7 @@ export default class Meeting extends StatelessWebexPlugin {
8448
8990
  ?.iceConnectionState ||
8449
8991
  this.mediaProperties.webrtcMediaConnection?.mediaConnection?.pc?.iceConnectionState ||
8450
8992
  'unknown',
8993
+ connectionType,
8451
8994
  ...reachabilityMetrics,
8452
8995
  ...iceCandidateErrors,
8453
8996
  iceCandidatesCount: this.iceCandidatesCount,
@@ -8796,6 +9339,7 @@ export default class Meeting extends StatelessWebexPlugin {
8796
9339
  options: {meetingId: this.id},
8797
9340
  });
8798
9341
  LoggerProxy.logger.log('Meeting:index#leave --> Leaving a meeting');
9342
+ this.stopListeningForMeetingEvents();
8799
9343
 
8800
9344
  return MeetingUtil.leaveMeeting(this, options)
8801
9345
  .then(async (leave) => {
@@ -9661,6 +10205,8 @@ export default class Meeting extends StatelessWebexPlugin {
9661
10205
  locus_id: this.locusId,
9662
10206
  });
9663
10207
 
10208
+ this.stopListeningForMeetingEvents();
10209
+
9664
10210
  return MeetingUtil.endMeetingForAll(this)
9665
10211
  .then(async (end) => {
9666
10212
  this.meetingFiniteStateMachine.end();
@@ -9722,12 +10268,15 @@ export default class Meeting extends StatelessWebexPlugin {
9722
10268
  }
9723
10269
  this.queuedMediaUpdates = [];
9724
10270
 
9725
- this.stopTranscription();
9726
- this.transcription = undefined;
9727
-
9728
- this.annotation.deregisterEvents();
9729
-
10271
+ // Listener teardown (transcription, annotation, llm/mercury) runs in
10272
+ // stopListeningForMeetingEvents() before /leave and /end so events
10273
+ // received mid-teardown do not trigger Locus syncs. Calling it here
10274
+ // again would double-emit MEETING_STOPPED_RECEIVING_TRANSCRIPTION
10275
+ // because stopTranscription() always fires its trigger.
10276
+ //
10277
+ // Ownership-aware token clear is encapsulated inside clearDataChannelToken().
9730
10278
  this.clearDataChannelToken();
10279
+
9731
10280
  await this.cleanupLLMConneciton({throwOnError: false});
9732
10281
  };
9733
10282
 
@@ -9804,15 +10353,12 @@ export default class Meeting extends StatelessWebexPlugin {
9804
10353
  * @public
9805
10354
  * @memberof Meeting
9806
10355
  */
9807
- public sendReaction(reactionType: ReactionServerType, skinToneType?: SkinToneType) {
10356
+ public sendReaction(reactionType: string, skinToneType?: SkinToneType) {
9808
10357
  const reactionChannelUrl = this.locusInfo?.controls?.reactions?.reactionChannelUrl as string;
9809
10358
  const participantId = this.members.selfId;
9810
10359
 
9811
- const reactionData = Reactions[reactionType];
10360
+ const reactionData = Reactions[reactionType] || {type: reactionType};
9812
10361
 
9813
- if (!reactionData) {
9814
- return Promise.reject(new Error(`${reactionType} is not a valid reaction.`));
9815
- }
9816
10362
  const skinToneData = SkinTones[skinToneType] || SkinTones.normal;
9817
10363
  const reaction: Reaction = {
9818
10364
  ...reactionData,