@webex/plugin-meetings 3.12.0-next.1 → 3.12.0-next.100

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 (235) 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 +13 -1
  21. package/dist/hashTree/constants.js.map +1 -1
  22. package/dist/hashTree/hashTreeParser.js +898 -391
  23. package/dist/hashTree/hashTreeParser.js.map +1 -1
  24. package/dist/hashTree/utils.js +42 -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 +1444 -772
  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 +10 -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/multistream/sendSlotManager.js +116 -2
  91. package/dist/multistream/sendSlotManager.js.map +1 -1
  92. package/dist/reachability/clusterReachability.js.map +1 -1
  93. package/dist/reachability/index.js +121 -83
  94. package/dist/reachability/index.js.map +1 -1
  95. package/dist/reachability/reachability.types.js +2 -0
  96. package/dist/reachability/reachability.types.js.map +1 -1
  97. package/dist/reachability/util.js +45 -0
  98. package/dist/reachability/util.js.map +1 -1
  99. package/dist/reactions/reactions.type.js.map +1 -1
  100. package/dist/recording-controller/index.js +1 -3
  101. package/dist/recording-controller/index.js.map +1 -1
  102. package/dist/roap/turnDiscovery.js +8 -1
  103. package/dist/roap/turnDiscovery.js.map +1 -1
  104. package/dist/types/common/errors/webex-errors.d.ts +32 -2
  105. package/dist/types/config.d.ts +2 -2
  106. package/dist/types/constants.d.ts +12 -1
  107. package/dist/types/controls-options-manager/constants.d.ts +6 -1
  108. package/dist/types/controls-options-manager/index.d.ts +16 -0
  109. package/dist/types/hashTree/constants.d.ts +2 -0
  110. package/dist/types/hashTree/hashTreeParser.d.ts +146 -17
  111. package/dist/types/hashTree/utils.d.ts +18 -0
  112. package/dist/types/index.d.ts +3 -0
  113. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  114. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  115. package/dist/types/locus-info/index.d.ts +59 -6
  116. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  117. package/dist/types/locus-info/types.d.ts +21 -1
  118. package/dist/types/media/MediaConnectionAwaiter.d.ts +10 -1
  119. package/dist/types/media/properties.d.ts +1 -0
  120. package/dist/types/meeting/in-meeting-actions.d.ts +4 -0
  121. package/dist/types/meeting/index.d.ts +143 -9
  122. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  123. package/dist/types/meeting/request.d.ts +1 -0
  124. package/dist/types/meeting/util.d.ts +9 -0
  125. package/dist/types/meetings/index.d.ts +30 -18
  126. package/dist/types/meetings/meetings.types.d.ts +15 -0
  127. package/dist/types/meetings/request.d.ts +14 -0
  128. package/dist/types/member/index.d.ts +1 -0
  129. package/dist/types/member/types.d.ts +1 -0
  130. package/dist/types/member/util.d.ts +9 -0
  131. package/dist/types/members/index.d.ts +15 -2
  132. package/dist/types/members/util.d.ts +1 -5
  133. package/dist/types/metrics/constants.d.ts +9 -0
  134. package/dist/types/multistream/codec/constants.d.ts +7 -0
  135. package/dist/types/multistream/mediaRequestManager.d.ts +22 -5
  136. package/dist/types/multistream/sendSlotManager.d.ts +23 -1
  137. package/dist/types/reachability/clusterReachability.d.ts +3 -3
  138. package/dist/types/reachability/index.d.ts +10 -3
  139. package/dist/types/reachability/reachability.types.d.ts +7 -0
  140. package/dist/types/reachability/util.d.ts +17 -0
  141. package/dist/types/reactions/reactions.type.d.ts +3 -0
  142. package/dist/webinar/index.js +485 -234
  143. package/dist/webinar/index.js.map +1 -1
  144. package/package.json +22 -22
  145. package/src/aiEnableRequest/index.ts +16 -0
  146. package/src/breakouts/breakout.ts +3 -1
  147. package/src/breakouts/index.ts +31 -0
  148. package/src/common/errors/webex-errors.ts +50 -3
  149. package/src/config.ts +2 -2
  150. package/src/constants.ts +20 -3
  151. package/src/controls-options-manager/constants.ts +14 -1
  152. package/src/controls-options-manager/index.ts +87 -28
  153. package/src/controls-options-manager/util.ts +81 -1
  154. package/src/hashTree/constants.ts +16 -0
  155. package/src/hashTree/hashTreeParser.ts +596 -204
  156. package/src/hashTree/utils.ts +36 -0
  157. package/src/index.ts +6 -0
  158. package/src/interceptors/dataChannelAuthToken.ts +88 -12
  159. package/src/interceptors/locusRetry.ts +25 -4
  160. package/src/interpretation/index.ts +27 -9
  161. package/src/interpretation/interpretation.types.ts +11 -0
  162. package/src/locus-info/controlsUtils.ts +3 -1
  163. package/src/locus-info/index.ts +415 -136
  164. package/src/locus-info/infoUtils.ts +41 -6
  165. package/src/locus-info/types.ts +25 -1
  166. package/src/media/MediaConnectionAwaiter.ts +21 -4
  167. package/src/media/index.ts +10 -1
  168. package/src/media/properties.ts +1 -0
  169. package/src/meeting/in-meeting-actions.ts +8 -0
  170. package/src/meeting/index.ts +790 -136
  171. package/src/meeting/locusMediaRequest.ts +106 -6
  172. package/src/meeting/muteState.ts +10 -1
  173. package/src/meeting/request.ts +11 -0
  174. package/src/meeting/util.ts +47 -5
  175. package/src/meeting-info/meeting-info-v2.ts +4 -2
  176. package/src/meetings/index.ts +133 -78
  177. package/src/meetings/meetings.types.ts +19 -0
  178. package/src/meetings/request.ts +43 -0
  179. package/src/meetings/util.ts +117 -4
  180. package/src/member/index.ts +10 -0
  181. package/src/member/types.ts +1 -0
  182. package/src/member/util.ts +29 -0
  183. package/src/members/index.ts +70 -7
  184. package/src/members/util.ts +12 -4
  185. package/src/metrics/constants.ts +10 -0
  186. package/src/multistream/codec/constants.ts +58 -0
  187. package/src/multistream/mediaRequestManager.ts +119 -28
  188. package/src/multistream/receiveSlot.ts +18 -0
  189. package/src/multistream/sendSlotManager.ts +97 -3
  190. package/src/reachability/clusterReachability.ts +3 -2
  191. package/src/reachability/index.ts +47 -16
  192. package/src/reachability/reachability.types.ts +11 -0
  193. package/src/reachability/util.ts +36 -0
  194. package/src/reactions/reactions.type.ts +3 -0
  195. package/src/recording-controller/index.ts +1 -2
  196. package/src/roap/turnDiscovery.ts +9 -1
  197. package/src/webinar/index.ts +330 -50
  198. package/test/unit/spec/aiEnableRequest/index.ts +86 -0
  199. package/test/unit/spec/breakouts/breakout.ts +9 -3
  200. package/test/unit/spec/breakouts/index.ts +49 -0
  201. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  202. package/test/unit/spec/controls-options-manager/index.js +244 -29
  203. package/test/unit/spec/controls-options-manager/util.js +165 -0
  204. package/test/unit/spec/hashTree/hashTreeParser.ts +1911 -143
  205. package/test/unit/spec/hashTree/utils.ts +125 -1
  206. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +196 -0
  207. package/test/unit/spec/interceptors/locusRetry.ts +205 -4
  208. package/test/unit/spec/interpretation/index.ts +26 -4
  209. package/test/unit/spec/locus-info/controlsUtils.js +172 -57
  210. package/test/unit/spec/locus-info/index.js +645 -80
  211. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  212. package/test/unit/spec/media/MediaConnectionAwaiter.ts +55 -0
  213. package/test/unit/spec/media/index.ts +92 -0
  214. package/test/unit/spec/meeting/in-meeting-actions.ts +4 -0
  215. package/test/unit/spec/meeting/index.js +2261 -109
  216. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  217. package/test/unit/spec/meeting/muteState.js +81 -0
  218. package/test/unit/spec/meeting/request.js +12 -0
  219. package/test/unit/spec/meeting/utils.js +157 -1
  220. package/test/unit/spec/meeting-info/meetinginfov2.js +19 -10
  221. package/test/unit/spec/meetings/index.js +366 -39
  222. package/test/unit/spec/meetings/request.js +141 -0
  223. package/test/unit/spec/meetings/utils.js +402 -51
  224. package/test/unit/spec/member/index.js +7 -0
  225. package/test/unit/spec/member/util.js +89 -0
  226. package/test/unit/spec/members/index.js +216 -0
  227. package/test/unit/spec/members/request.js +37 -1
  228. package/test/unit/spec/members/utils.js +63 -0
  229. package/test/unit/spec/multistream/mediaRequestManager.ts +501 -37
  230. package/test/unit/spec/multistream/sendSlotManager.ts +135 -36
  231. package/test/unit/spec/reachability/index.ts +128 -46
  232. package/test/unit/spec/reachability/util.ts +31 -0
  233. package/test/unit/spec/recording-controller/index.js +9 -8
  234. package/test/unit/spec/roap/turnDiscovery.ts +20 -0
  235. package/test/unit/spec/webinar/index.ts +516 -30
@@ -30,7 +30,7 @@ import {
30
30
  NetworkQualityMonitor,
31
31
  StatsMonitor,
32
32
  StatsMonitorEventNames,
33
- InboundAudioIssueSubTypes,
33
+ MediaCodecMimeType,
34
34
  } from '@webex/internal-media-core';
35
35
 
36
36
  import {DataChannelTokenType} from '@webex/internal-plugin-llm';
@@ -66,6 +66,7 @@ import {
66
66
  NoMediaEstablishedYetError,
67
67
  UserNotJoinedError,
68
68
  AddMediaFailed,
69
+ MediaConnectionTimedOutError,
69
70
  SdpResponseTimeoutError,
70
71
  } from '../common/errors/webex-errors';
71
72
 
@@ -76,6 +77,7 @@ import Roap, {type TurnDiscoveryResult, type TurnDiscoverySkipReason} from '../r
76
77
  import {type TurnServerInfo} from '../roap/types';
77
78
  import Media, {type BundlePolicy} from '../media';
78
79
  import MediaProperties from '../media/properties';
80
+ import {type FailureResult as MediaConnectionAwaiterFailureResult} from '../media/MediaConnectionAwaiter';
79
81
  import MeetingStateMachine from './state';
80
82
  import {createMuteState} from './muteState';
81
83
  import LocusInfo, {LocusLLMEvent} from '../locus-info';
@@ -136,6 +138,8 @@ import {
136
138
  STAGE_MANAGER_TYPE,
137
139
  LOCUSEVENT,
138
140
  LOCUS_LLM_EVENT,
141
+ LLM_DEFAULT_SESSION,
142
+ LLM_PRACTICE_SESSION,
139
143
  } from '../constants';
140
144
  import BEHAVIORAL_METRICS from '../metrics/constants';
141
145
  import ParameterError from '../common/errors/parameter';
@@ -189,6 +193,7 @@ import AIEnableRequest from '../aiEnableRequest';
189
193
  const DEFAULT_ICE_PHASE_CALLBACK = () => 'JOIN_MEETING_FINAL';
190
194
 
191
195
  const LLM_HEALTHCHECK_TIMER_MS = 3 * 60 * 1000;
196
+ const JOIN_WITH_MEDIA_RETRY_MAX_COUNT = 2;
192
197
 
193
198
  const logRequest = (request: any, {logText = ''}) => {
194
199
  LoggerProxy.logger.info(`${logText} - sending request`);
@@ -611,7 +616,7 @@ export default class Meeting extends StatelessWebexPlugin {
611
616
  webinar: any;
612
617
  conversationUrl: string;
613
618
  callStateForMetrics: CallStateForMetrics;
614
- destination: string;
619
+ destination: string | LocusDTO;
615
620
  destinationType: DESTINATION_TYPE;
616
621
  deviceUrl: string;
617
622
  hostId: string;
@@ -650,6 +655,8 @@ export default class Meeting extends StatelessWebexPlugin {
650
655
  floorGrantPending: boolean;
651
656
  hasJoinedOnce: boolean;
652
657
  hasWebsocketConnected: boolean;
658
+ private mercuryOnlineHandler?: () => void;
659
+ private mercuryOfflineHandler?: () => void;
653
660
  inMeetingActions: InMeetingActions;
654
661
  isLocalShareLive: boolean;
655
662
  isRoapInProgress: boolean;
@@ -661,6 +668,7 @@ export default class Meeting extends StatelessWebexPlugin {
661
668
  joinedWith?: any;
662
669
  selfId?: string;
663
670
  roles: any[];
671
+ canNotViewTheParticipantList?: boolean;
664
672
  // ... there is more ... see SelfUtils.parse()
665
673
  // end of the group
666
674
  locusMediaRequest?: LocusMediaRequest;
@@ -734,6 +742,7 @@ export default class Meeting extends StatelessWebexPlugin {
734
742
  isMoveToInProgress = false;
735
743
  registrationIdStatus: string;
736
744
  brbState: BrbState;
745
+ private promisesWaitingForPropUpdate: Record<string, Defer> = {};
737
746
 
738
747
  voiceaListenerCallbacks: object = {
739
748
  [VOICEAEVENTS.VOICEA_ANNOUNCEMENT]: (payload: Transcription['languageOptions']) => {
@@ -783,13 +792,20 @@ export default class Meeting extends StatelessWebexPlugin {
783
792
  private addMediaData: {
784
793
  retriedWithTurnServer: boolean;
785
794
  icePhaseCallback: () => string;
795
+ iceTransportPolicy?: RTCIceTransportPolicy;
786
796
  };
787
797
 
788
798
  private sendSlotManager: SendSlotManager = new SendSlotManager(LoggerProxy);
789
799
  private deferSDPAnswer?: Defer; // used for waiting for a response
790
800
  private sdpResponseTimer?: ReturnType<typeof setTimeout>;
791
801
  private hasMediaConnectionConnectedAtLeastOnce: boolean;
792
- private joinWithMediaRetryInfo?: {isRetry: boolean; prevJoinResponse?: any};
802
+ private joinWithMediaRetryInfo: {
803
+ retryCount: number;
804
+ prevJoinResponse?: any;
805
+ firstError?: Error;
806
+ prevError?: Error;
807
+ };
808
+
793
809
  private connectionStateHandler?: ConnectionStateHandler;
794
810
  private iceCandidateErrors: Map<string, number>;
795
811
  private iceCandidatesCount: number;
@@ -934,7 +950,7 @@ export default class Meeting extends StatelessWebexPlugin {
934
950
  this.simultaneousInterpretation = new SimultaneousInterpretation({}, {parent: this.webex});
935
951
 
936
952
  // @ts-ignore
937
- this.aiEnableRequest = new AIEnableRequest({}, {parent: this.webex});
953
+ this.aiEnableRequest = new AIEnableRequest({locusUrl: this.locusUrl}, {parent: this.webex});
938
954
 
939
955
  /**
940
956
  * @instance
@@ -965,6 +981,7 @@ export default class Meeting extends StatelessWebexPlugin {
965
981
  },
966
982
  (csi: CSI) => (this.members.findMemberByCsi(csi) as any)?.id
967
983
  );
984
+
968
985
  /**
969
986
  * Object containing helper classes for managing media requests for audio/video/screenshare (for multistream media connections)
970
987
  * All multistream media requests sent out for this meeting have to go through them.
@@ -984,6 +1001,7 @@ export default class Meeting extends StatelessWebexPlugin {
984
1001
  mediaRequests
985
1002
  );
986
1003
  },
1004
+ this.getIngressPayloadTypeCallback.bind(this),
987
1005
  {
988
1006
  // @ts-ignore - config coming from registerPlugin
989
1007
  degradationPreferences: this.config.degradationPreferences,
@@ -1005,6 +1023,7 @@ export default class Meeting extends StatelessWebexPlugin {
1005
1023
  mediaRequests
1006
1024
  );
1007
1025
  },
1026
+ this.getIngressPayloadTypeCallback.bind(this),
1008
1027
  {
1009
1028
  // @ts-ignore - config coming from registerPlugin
1010
1029
  degradationPreferences: this.config.degradationPreferences,
@@ -1026,6 +1045,7 @@ export default class Meeting extends StatelessWebexPlugin {
1026
1045
  mediaRequests
1027
1046
  );
1028
1047
  },
1048
+ this.getIngressPayloadTypeCallback.bind(this),
1029
1049
  {
1030
1050
  // @ts-ignore - config coming from registerPlugin
1031
1051
  degradationPreferences: this.config.degradationPreferences,
@@ -1047,11 +1067,14 @@ export default class Meeting extends StatelessWebexPlugin {
1047
1067
  mediaRequests
1048
1068
  );
1049
1069
  },
1070
+ this.getIngressPayloadTypeCallback.bind(this),
1050
1071
  {
1051
1072
  // @ts-ignore - config coming from registerPlugin
1052
1073
  degradationPreferences: this.config.degradationPreferences,
1053
1074
  kind: 'video',
1054
1075
  trimRequestsToNumOfSources: false,
1076
+ // @ts-ignore - config coming from registerPlugin
1077
+ enableAv1: this.config.enableAv1SlidesSupport,
1055
1078
  }
1056
1079
  ),
1057
1080
  };
@@ -1556,6 +1579,8 @@ export default class Meeting extends StatelessWebexPlugin {
1556
1579
  this.controlsOptionsManager = new ControlsOptionsManager(this.meetingRequest, {
1557
1580
  locusUrl: this.locusInfo?.url,
1558
1581
  displayHints: [],
1582
+ getControls: () => this.locusInfo?.controls,
1583
+ isWebinar: () => this.locusInfo?.info?.isWebinar,
1559
1584
  });
1560
1585
 
1561
1586
  this.setUpLocusInfoListeners();
@@ -1654,11 +1679,11 @@ export default class Meeting extends StatelessWebexPlugin {
1654
1679
  /**
1655
1680
  * Information needed for a retry of a call to joinWithMedia
1656
1681
  * @instance
1657
- * @type {{isRetry: boolean; prevJoinResponse?: any}}
1682
+ * @type {{retryCount: number; prevJoinResponse?: any}}
1658
1683
  * @private
1659
1684
  * @memberof Meeting
1660
1685
  */
1661
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
1686
+ this.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
1662
1687
 
1663
1688
  /**
1664
1689
  * Connection state handler
@@ -1712,6 +1737,37 @@ export default class Meeting extends StatelessWebexPlugin {
1712
1737
  this.mediaServerIp = undefined;
1713
1738
  }
1714
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
+
1715
1771
  /**
1716
1772
  * Temporary func to return webex object,
1717
1773
  * in order to access internal plugin metrics
@@ -2788,7 +2844,7 @@ export default class Meeting extends StatelessWebexPlugin {
2788
2844
  private setupLocusControlsListener() {
2789
2845
  this.locusInfo.on(
2790
2846
  LOCUSINFO.EVENTS.CONTROLS_RECORDING_UPDATED,
2791
- ({state, modifiedBy, lastModified}) => {
2847
+ ({state, modifiedBy, lastModified, modifiedByServiceAppName, modifiedByServiceAppId}) => {
2792
2848
  let event;
2793
2849
 
2794
2850
  switch (state) {
@@ -2814,6 +2870,8 @@ export default class Meeting extends StatelessWebexPlugin {
2814
2870
  state: state === RECORDING_STATE.RESUMED ? RECORDING_STATE.RECORDING : state,
2815
2871
  modifiedBy,
2816
2872
  lastModified,
2873
+ modifiedByServiceAppName,
2874
+ modifiedByServiceAppId,
2817
2875
  };
2818
2876
  Trigger.trigger(
2819
2877
  this,
@@ -3212,7 +3270,7 @@ export default class Meeting extends StatelessWebexPlugin {
3212
3270
  }
3213
3271
 
3214
3272
  LoggerProxy.logger.info(
3215
- `Meeting:index#setUpLocusInfoMediaInactiveListener --> this.shareStatus=${this.shareStatus} newShareStatus=${newShareStatus}`
3273
+ `Meeting:index#setUpLocusMediaSharesListener --> this.shareStatus=${this.shareStatus} newShareStatus=${newShareStatus}`
3216
3274
  );
3217
3275
 
3218
3276
  if (newShareStatus !== this.shareStatus) {
@@ -3458,13 +3516,12 @@ export default class Meeting extends StatelessWebexPlugin {
3458
3516
  this.breakouts.locusUrlUpdate(url);
3459
3517
  this.simultaneousInterpretation.locusUrlUpdate(url);
3460
3518
  this.annotation.locusUrlUpdate(url);
3519
+ this.aiEnableRequest.locusUrlUpdate(url);
3461
3520
  this.locusUrl = url;
3462
3521
  this.locusId = this.locusUrl?.split('/').pop();
3463
3522
  this.recordingController.setLocusUrl(this.locusUrl);
3464
3523
  this.controlsOptionsManager.setLocusUrl(this.locusUrl, !!isMainLocus);
3465
3524
  this.webinar.locusUrlUpdate(url);
3466
- // @ts-ignore
3467
- this.webex.internal.llm.setRefreshHandler(() => this.refreshDataChannelToken());
3468
3525
 
3469
3526
  Trigger.trigger(
3470
3527
  this,
@@ -3759,6 +3816,17 @@ export default class Meeting extends StatelessWebexPlugin {
3759
3816
  });
3760
3817
  }
3761
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
+
3762
3830
  this.updateLLMConnection();
3763
3831
  });
3764
3832
 
@@ -3803,6 +3871,9 @@ export default class Meeting extends StatelessWebexPlugin {
3803
3871
  });
3804
3872
 
3805
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
+
3806
3877
  Trigger.trigger(
3807
3878
  this,
3808
3879
  {
@@ -3997,7 +4068,14 @@ export default class Meeting extends StatelessWebexPlugin {
3997
4068
  // is not changed by any delta event
3998
4069
  if (object && Object.keys(object).length) {
3999
4070
  Object.keys(object).forEach((key) => {
4071
+ const previousValue = this[key];
4072
+
4000
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
+ }
4001
4079
  });
4002
4080
  }
4003
4081
  }
@@ -4135,7 +4213,12 @@ export default class Meeting extends StatelessWebexPlugin {
4135
4213
  }
4136
4214
 
4137
4215
  /**
4138
- * 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.
4139
4222
  * @param {String} memberId
4140
4223
  * @param {Boolean} moderator
4141
4224
  * @returns {Promise} see #members.transferHostToMember
@@ -4143,7 +4226,21 @@ export default class Meeting extends StatelessWebexPlugin {
4143
4226
  * @memberof Meeting
4144
4227
  */
4145
4228
  public transfer(memberId: string, moderator = true) {
4146
- 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);
4147
4244
  }
4148
4245
 
4149
4246
  /**
@@ -4601,6 +4698,13 @@ export default class Meeting extends StatelessWebexPlugin {
4601
4698
  ),
4602
4699
  isAttendeeRequestAiAssistantDeclinedAll:
4603
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
+ ),
4604
4708
  }) || changed;
4605
4709
  }
4606
4710
  if (changed) {
@@ -4649,6 +4753,34 @@ export default class Meeting extends StatelessWebexPlugin {
4649
4753
  this.sipUri = sipUri;
4650
4754
  }
4651
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
+
4652
4784
  /**
4653
4785
  * Set the locus info the class instance. Should be called with the parsed locus
4654
4786
  * we got in the join response.
@@ -5120,8 +5252,7 @@ export default class Meeting extends StatelessWebexPlugin {
5120
5252
  public setMercuryListener() {
5121
5253
  // Client will have a socket manager and handle reconnecting to mercury, when we reconnect to mercury
5122
5254
  // if the meeting has active peer connections, it should try to reconnect.
5123
- // @ts-ignore
5124
- this.webex.internal.mercury.on(ONLINE, () => {
5255
+ this.mercuryOnlineHandler = () => {
5125
5256
  LoggerProxy.logger.info('Meeting:index#setMercuryListener --> Web socket online');
5126
5257
 
5127
5258
  // Only send restore event when it was disconnected before and for connected later
@@ -5131,15 +5262,47 @@ export default class Meeting extends StatelessWebexPlugin {
5131
5262
  });
5132
5263
  }
5133
5264
  this.hasWebsocketConnected = true;
5134
- });
5265
+ };
5135
5266
 
5136
- // @ts-ignore
5137
- this.webex.internal.mercury.on(OFFLINE, () => {
5267
+ this.mercuryOfflineHandler = () => {
5138
5268
  LoggerProxy.logger.error('Meeting:index#setMercuryListener --> Web socket offline');
5139
5269
  Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.MERCURY_CONNECTION_FAILURE, {
5140
5270
  correlation_id: this.correlationId,
5141
5271
  });
5142
- });
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
+ }
5143
5306
  }
5144
5307
 
5145
5308
  /**
@@ -5163,6 +5326,7 @@ export default class Meeting extends StatelessWebexPlugin {
5163
5326
  );
5164
5327
 
5165
5328
  this.receiveSlotManager.reset();
5329
+
5166
5330
  this.mediaProperties.webrtcMediaConnection.close();
5167
5331
  this.mediaProperties.unsetPeerConnection();
5168
5332
  this.sendSlotManager.reset();
@@ -5450,7 +5614,7 @@ export default class Meeting extends StatelessWebexPlugin {
5450
5614
  } = {}
5451
5615
  ) {
5452
5616
  const {mediaOptions, joinOptions = {}} = options;
5453
- const {isRetry, prevJoinResponse} = this.joinWithMediaRetryInfo;
5617
+ const {retryCount, prevJoinResponse, prevError} = this.joinWithMediaRetryInfo;
5454
5618
 
5455
5619
  if (!mediaOptions?.allowMediaInLobby) {
5456
5620
  return Promise.reject(
@@ -5461,9 +5625,6 @@ export default class Meeting extends StatelessWebexPlugin {
5461
5625
 
5462
5626
  LoggerProxy.logger.info('Meeting:index#joinWithMedia called');
5463
5627
 
5464
- let joined = false;
5465
- let joinResponse = prevJoinResponse;
5466
-
5467
5628
  /* Before we do anything, check if RTCPeerConnection is available. Normally this is checked
5468
5629
  by addMediaInternal() itself when creating the media connection, but since joinWithMedia()
5469
5630
  is a convenience method that does both join() and addMedia(), we want to fail fast here
@@ -5476,12 +5637,28 @@ export default class Meeting extends StatelessWebexPlugin {
5476
5637
  );
5477
5638
  }
5478
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
+
5479
5656
  try {
5480
5657
  let turnServerInfo;
5481
5658
  let turnDiscoverySkippedReason;
5482
5659
  let forceTurnDiscovery = false;
5483
5660
 
5484
- if (!joinResponse) {
5661
+ if (shouldJoin) {
5485
5662
  // This is the 1st attempt or a retry after join request failed -> we need to do a join with TURN discovery
5486
5663
 
5487
5664
  const turnDiscoveryRequest = await this.roap.generateTurnDiscoveryRequestMessage(
@@ -5520,16 +5697,24 @@ export default class Meeting extends StatelessWebexPlugin {
5520
5697
  joined = true;
5521
5698
  }
5522
5699
 
5700
+ const shouldRetryMediaWithOnlyTurnTLS = await this.shouldRetryMediaWithOnlyTurnTLS(prevError);
5701
+
5523
5702
  const mediaResponse = await this.addMediaInternal(
5524
5703
  () => {
5525
- 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';
5526
5708
  },
5527
- turnServerInfo,
5528
5709
  forceTurnDiscovery,
5710
+ turnServerInfo,
5711
+ shouldRetryMediaWithOnlyTurnTLS ? 'relay' : undefined,
5529
5712
  mediaOptions
5530
5713
  );
5531
5714
 
5532
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
5715
+ this.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
5716
+
5717
+ this.locusInfo.suspendDestroyMeeting(false);
5533
5718
 
5534
5719
  return {
5535
5720
  join: joinResponse,
@@ -5543,8 +5728,12 @@ export default class Meeting extends StatelessWebexPlugin {
5543
5728
 
5544
5729
  this.roap.abortTurnDiscovery();
5545
5730
 
5546
- // if this was the first attempt, let's do a retry
5547
- 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));
5548
5737
 
5549
5738
  if (
5550
5739
  CallDiagnosticUtils.isSdpOfferCreationError(error) ||
@@ -5569,8 +5758,8 @@ export default class Meeting extends StatelessWebexPlugin {
5569
5758
  });
5570
5759
  }
5571
5760
 
5572
- // we only want to call leave if join was successful and this was a retry or we won't be doing any more retries
5573
- 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) {
5574
5763
  try {
5575
5764
  await this.leave({resourceId: joinOptions?.resourceId, reason: 'joinWithMedia failure'});
5576
5765
  } catch (e) {
@@ -5587,7 +5776,7 @@ export default class Meeting extends StatelessWebexPlugin {
5587
5776
  reason: error.message,
5588
5777
  stack: error.stack,
5589
5778
  leaveErrorReason: leaveError?.message,
5590
- isRetry,
5779
+ isRetry: retryCount > 0,
5591
5780
  },
5592
5781
  {
5593
5782
  type: error.name,
@@ -5596,15 +5785,28 @@ export default class Meeting extends StatelessWebexPlugin {
5596
5785
 
5597
5786
  if (shouldRetry) {
5598
5787
  LoggerProxy.logger.warn('Meeting:index#joinWithMedia --> retrying call to joinWithMedia');
5599
- this.joinWithMediaRetryInfo.isRetry = true;
5788
+ this.joinWithMediaRetryInfo.retryCount = retryCount + 1;
5600
5789
  this.joinWithMediaRetryInfo.prevJoinResponse = joinResponse;
5790
+ this.joinWithMediaRetryInfo.prevError = error;
5791
+ if (!this.joinWithMediaRetryInfo.firstError) {
5792
+ this.joinWithMediaRetryInfo.firstError = error;
5793
+ }
5601
5794
 
5602
5795
  return this.joinWithMedia(options);
5603
5796
  }
5604
5797
 
5605
- this.joinWithMediaRetryInfo = {isRetry: false, prevJoinResponse: undefined};
5798
+ const {firstError} = this.joinWithMediaRetryInfo;
5606
5799
 
5607
- 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;
5608
5810
  }
5609
5811
  }
5610
5812
 
@@ -5855,6 +6057,31 @@ export default class Meeting extends StatelessWebexPlugin {
5855
6057
  }
5856
6058
  };
5857
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
+
5858
6085
  /**
5859
6086
  * Callback called when a relay event is received from meeting LLM Connection
5860
6087
  * @param {RelayEvent} e Event object coming from LLM Connection
@@ -5862,6 +6089,9 @@ export default class Meeting extends StatelessWebexPlugin {
5862
6089
  * @returns {void}
5863
6090
  */
5864
6091
  private processRelayEvent = (e: RelayEvent): void => {
6092
+ if (!this.isRelayEventRouteValid(e)) {
6093
+ return;
6094
+ }
5865
6095
  switch (e.data.relayType) {
5866
6096
  case REACTION_RELAY_TYPES.REACTION:
5867
6097
  if (
@@ -5907,37 +6137,35 @@ export default class Meeting extends StatelessWebexPlugin {
5907
6137
  * @returns {void}
5908
6138
  */
5909
6139
  stopTranscription() {
5910
- if (this.transcription) {
5911
- // @ts-ignore
5912
- this.webex.internal.voicea.off(
5913
- VOICEAEVENTS.VOICEA_ANNOUNCEMENT,
5914
- this.voiceaListenerCallbacks[VOICEAEVENTS.VOICEA_ANNOUNCEMENT]
5915
- );
6140
+ // @ts-ignore
6141
+ this.webex.internal.voicea.off(
6142
+ VOICEAEVENTS.VOICEA_ANNOUNCEMENT,
6143
+ this.voiceaListenerCallbacks[VOICEAEVENTS.VOICEA_ANNOUNCEMENT]
6144
+ );
5916
6145
 
5917
- // @ts-ignore
5918
- this.webex.internal.voicea.off(
5919
- VOICEAEVENTS.CAPTIONS_TURNED_ON,
5920
- this.voiceaListenerCallbacks[VOICEAEVENTS.CAPTIONS_TURNED_ON]
5921
- );
6146
+ // @ts-ignore
6147
+ this.webex.internal.voicea.off(
6148
+ VOICEAEVENTS.CAPTIONS_TURNED_ON,
6149
+ this.voiceaListenerCallbacks[VOICEAEVENTS.CAPTIONS_TURNED_ON]
6150
+ );
5922
6151
 
5923
- // @ts-ignore
5924
- this.webex.internal.voicea.off(
5925
- VOICEAEVENTS.EVA_COMMAND,
5926
- this.voiceaListenerCallbacks[VOICEAEVENTS.EVA_COMMAND]
5927
- );
6152
+ // @ts-ignore
6153
+ this.webex.internal.voicea.off(
6154
+ VOICEAEVENTS.EVA_COMMAND,
6155
+ this.voiceaListenerCallbacks[VOICEAEVENTS.EVA_COMMAND]
6156
+ );
5928
6157
 
5929
- // @ts-ignore
5930
- this.webex.internal.voicea.off(
5931
- VOICEAEVENTS.NEW_CAPTION,
5932
- this.voiceaListenerCallbacks[VOICEAEVENTS.NEW_CAPTION]
5933
- );
6158
+ // @ts-ignore
6159
+ this.webex.internal.voicea.off(
6160
+ VOICEAEVENTS.NEW_CAPTION,
6161
+ this.voiceaListenerCallbacks[VOICEAEVENTS.NEW_CAPTION]
6162
+ );
5934
6163
 
5935
- // @ts-ignore
5936
- this.webex.internal.voicea.deregisterEvents();
6164
+ // @ts-ignore
6165
+ this.webex.internal.voicea.deregisterEvents();
5937
6166
 
5938
- this.areVoiceaEventsSetup = false;
5939
- this.triggerStopReceivingTranscriptionEvent();
5940
- }
6167
+ this.areVoiceaEventsSetup = false;
6168
+ this.triggerStopReceivingTranscriptionEvent();
5941
6169
  }
5942
6170
 
5943
6171
  /**
@@ -5961,6 +6189,30 @@ export default class Meeting extends StatelessWebexPlugin {
5961
6189
  );
5962
6190
  }
5963
6191
 
6192
+ /**
6193
+ * Restores LLM subchannel subscriptions after reconnect when captions are active.
6194
+ * @returns {void}
6195
+ */
6196
+ private restoreLLMSubscriptionsIfNeeded(): void {
6197
+ try {
6198
+ // @ts-ignore
6199
+ const isCaptionBoxOn = this.webex.internal.voicea?.getIsCaptionBoxOn?.();
6200
+
6201
+ if (!isCaptionBoxOn) {
6202
+ return;
6203
+ }
6204
+
6205
+ // @ts-ignore
6206
+ this.webex.internal.voicea.updateSubchannelSubscriptions({subscribe: ['transcription']});
6207
+ } catch (error) {
6208
+ const msg = error?.message || String(error);
6209
+
6210
+ LoggerProxy.logger.warn(
6211
+ `Meeting:index#restoreLLMSubscriptionsIfNeeded --> failed to restore subscriptions after LLM online: ${msg}`
6212
+ );
6213
+ }
6214
+ }
6215
+
5964
6216
  /**
5965
6217
  * This is a callback for the LLM event that is triggered when it comes online
5966
6218
  * This method in turn will trigger an event to the developers that the LLM is connected
@@ -5969,8 +6221,9 @@ export default class Meeting extends StatelessWebexPlugin {
5969
6221
  * @returns {null}
5970
6222
  */
5971
6223
  private handleLLMOnline = (): void => {
5972
- // @ts-ignore
5973
- this.webex.internal.llm.off('online', this.handleLLMOnline);
6224
+ this.restoreLLMSubscriptionsIfNeeded();
6225
+ this.locusInfo.syncAllHashTreeDatasets({onlyLLM: true});
6226
+
5974
6227
  Trigger.trigger(
5975
6228
  this,
5976
6229
  {
@@ -6198,8 +6451,11 @@ export default class Meeting extends StatelessWebexPlugin {
6198
6451
  return Promise.reject(error);
6199
6452
  })
6200
6453
  .then((join) => {
6454
+ this.saveDataChannelToken(join);
6201
6455
  // @ts-ignore - config coming from registerPlugin
6202
6456
  if (this.config.enableAutomaticLLM) {
6457
+ // @ts-ignore
6458
+ this.webex.internal.llm.off('online', this.handleLLMOnline);
6203
6459
  // @ts-ignore
6204
6460
  this.webex.internal.llm.on('online', this.handleLLMOnline);
6205
6461
  this.updateLLMConnection()
@@ -6266,8 +6522,57 @@ export default class Meeting extends StatelessWebexPlugin {
6266
6522
  }
6267
6523
  }
6268
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
+
6269
6568
  /**
6270
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
+ *
6271
6576
  * @param {Object} options
6272
6577
  * @param {boolean} [options.removeOnlineListener=true] removes the one-time online listener
6273
6578
  * @param {boolean} [options.throwOnError=true] rethrows disconnect errors when true
@@ -6280,12 +6585,29 @@ export default class Meeting extends StatelessWebexPlugin {
6280
6585
  removeOnlineListener?: boolean;
6281
6586
  throwOnError?: boolean;
6282
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
+
6283
6595
  try {
6284
- // @ts-ignore - Fix type
6285
- await this.webex.internal.llm.disconnectLLM({
6286
- code: 3050,
6287
- reason: 'done (permanent)',
6288
- });
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
+ }
6289
6611
  } catch (error) {
6290
6612
  LoggerProxy.logger.error(
6291
6613
  'Meeting:index#cleanupLLMConneciton --> Failed to disconnect default LLM session',
@@ -6300,46 +6622,173 @@ export default class Meeting extends StatelessWebexPlugin {
6300
6622
  // @ts-ignore - Fix type
6301
6623
  this.webex.internal.llm.off('online', this.handleLLMOnline);
6302
6624
  }
6303
- // @ts-ignore - fix types
6304
- this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6305
- // @ts-ignore - Fix type
6306
- 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);
6307
6633
 
6308
- this.clearLLMHealthCheckTimer();
6634
+ if (currentOwnerAfterCleanup === this.id) {
6635
+ // @ts-ignore - Fix type
6636
+ this.webex.internal.llm.setOwnerMeetingId?.(undefined);
6637
+ }
6638
+ }
6309
6639
  }
6310
6640
  };
6311
6641
 
6642
+ /**
6643
+ * Clears data channel tokens associated with this meeting ownership.
6644
+ * Ownership checks are enforced in internal-plugin-llm.
6645
+ * @returns {void}
6646
+ */
6647
+ clearDataChannelToken(): void {
6648
+ // @ts-ignore
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);
6652
+ }
6653
+
6654
+ /**
6655
+ * Saves the data channel tokens from the join response into LLM so that
6656
+ * updateLLMConnection / updatePSDataChannel don't need to fetch them from locusInfo.
6657
+ * @param {Object} join - The parsed join response (from MeetingUtil.parseLocusJoin)
6658
+ * @returns {void}
6659
+ */
6660
+ saveDataChannelToken(join: any): void {
6661
+ const datachannelToken = join?.locus?.self?.datachannelToken;
6662
+ const practiceSessionDatachannelToken = join?.locus?.self?.practiceSessionDatachannelToken;
6663
+
6664
+ if (datachannelToken) {
6665
+ // @ts-ignore
6666
+ this.webex.internal.llm.setDatachannelToken(datachannelToken, LLM_DEFAULT_SESSION, this.id);
6667
+ }
6668
+
6669
+ if (practiceSessionDatachannelToken) {
6670
+ // @ts-ignore
6671
+ this.webex.internal.llm.setDatachannelToken(
6672
+ practiceSessionDatachannelToken,
6673
+ LLM_PRACTICE_SESSION,
6674
+ this.id
6675
+ );
6676
+ }
6677
+ }
6678
+
6679
+ /**
6680
+ * Ensures default-session data channel token exists after lobby admission.
6681
+ * Some lobby users do not receive a token until they are admitted.
6682
+ * @returns {Promise<boolean>} true when a new token is fetched and cached
6683
+ */
6684
+ private async ensureDefaultDatachannelTokenAfterAdmit(): Promise<boolean> {
6685
+ try {
6686
+ // @ts-ignore
6687
+ const datachannelToken = this.webex.internal.llm.getDatachannelToken(
6688
+ LLM_DEFAULT_SESSION,
6689
+ this.id
6690
+ );
6691
+ // @ts-ignore
6692
+ const isDataChannelTokenEnabled = await this.webex.internal.llm.isDataChannelTokenEnabled();
6693
+
6694
+ if (!isDataChannelTokenEnabled || datachannelToken) {
6695
+ return false;
6696
+ }
6697
+
6698
+ const response = await this.meetingRequest.fetchDatachannelToken({
6699
+ locusUrl: this.locusUrl,
6700
+ requestingParticipantId: this.members.selfId,
6701
+ isPracticeSession: false,
6702
+ });
6703
+ const fetchedDatachannelToken = response?.body?.datachannelToken;
6704
+
6705
+ if (!fetchedDatachannelToken) {
6706
+ return false;
6707
+ }
6708
+
6709
+ // @ts-ignore
6710
+ this.webex.internal.llm.setDatachannelToken(
6711
+ fetchedDatachannelToken,
6712
+ LLM_DEFAULT_SESSION,
6713
+ this.id
6714
+ );
6715
+
6716
+ return true;
6717
+ } catch (error) {
6718
+ const msg = error?.message || String(error);
6719
+
6720
+ LoggerProxy.logger.warn(
6721
+ `Meeting:index#ensureDefaultDatachannelTokenAfterAdmit --> failed to proactively fetch default data channel token after admit: ${msg}`,
6722
+ {statusCode: error?.statusCode}
6723
+ );
6724
+
6725
+ return false;
6726
+ }
6727
+ }
6728
+
6312
6729
  /**
6313
6730
  * Connects to low latency mercury and reconnects if the address has changed
6314
6731
  * It will also disconnect if called when the meeting has ended
6315
- * @param {String} datachannelUrl
6316
6732
  * @returns {Promise}
6317
6733
  */
6318
6734
  async updateLLMConnection() {
6319
6735
  // @ts-ignore - Fix type
6320
- const {
6321
- url = undefined,
6322
- info: {datachannelUrl = undefined} = {},
6323
- self: {datachannelToken = undefined} = {},
6324
- } = this.locusInfo || {};
6736
+ const {url = undefined, info: {datachannelUrl = undefined} = {}} = this.locusInfo || {};
6325
6737
 
6326
6738
  const isJoined = this.isJoined();
6327
6739
 
6328
- // @ts-ignore
6329
- const currentToken = this.webex.internal.llm.getDatachannelToken(DataChannelTokenType.Default);
6740
+ const dataChannelUrl = datachannelUrl;
6330
6741
 
6331
- const finalToken = currentToken ?? datachannelToken;
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
6752
+ );
6332
6753
 
6333
- if (!currentToken && datachannelToken) {
6334
- // @ts-ignore
6335
- this.webex.internal.llm.setDatachannelToken(datachannelToken, DataChannelTokenType.Default);
6336
- }
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();
6337
6759
 
6338
- // webinar panelist should use new data channel in practice session
6339
- const dataChannelUrl = datachannelUrl;
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.
6763
+ // @ts-ignore - Fix type
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
+ }
6340
6773
 
6341
6774
  // @ts-ignore - Fix type
6342
- if (this.webex.internal.llm.isConnected()) {
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
+
6343
6792
  if (
6344
6793
  // @ts-ignore - Fix type
6345
6794
  url === this.webex.internal.llm.getLocusUrl() &&
@@ -6356,10 +6805,56 @@ export default class Meeting extends StatelessWebexPlugin {
6356
6805
  return undefined;
6357
6806
  }
6358
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
+
6359
6822
  // @ts-ignore - Fix type
6360
6823
  return this.webex.internal.llm
6361
- .registerAndConnect(url, dataChannelUrl, finalToken)
6824
+ .registerAndConnect(url, dataChannelUrl, datachannelToken)
6362
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
+ }
6363
6858
  // @ts-ignore - Fix type
6364
6859
  this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6365
6860
  // @ts-ignore - Fix type
@@ -7400,23 +7895,104 @@ export default class Meeting extends StatelessWebexPlugin {
7400
7895
  }
7401
7896
  }
7402
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
+ });
7403
7925
  };
7404
7926
 
7405
7927
  getMediaConnectionDebugId() {
7406
7928
  return `MC-${this.id.substring(0, 4)}`;
7407
7929
  }
7408
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
+
7409
7984
  /**
7410
7985
  * Creates a webrtc media connection and publishes streams to it
7411
7986
  *
7412
7987
  * @param {Object} turnServerInfo TURN server information
7413
7988
  * @param {BundlePolicy} [bundlePolicy] Bundle policy settings
7414
- * @param {AddMediaOptions} [options] Options for enabling/disabling audio/video
7989
+ * @param {RTCIceTransportPolicy} [iceTransportPolicy] ICE transport policy override
7415
7990
  * @returns {RoapMediaConnection | MultistreamRoapMediaConnection}
7416
7991
  */
7417
7992
  private async createMediaConnection(
7418
7993
  turnServerInfo?: TurnServerInfo,
7419
- bundlePolicy?: BundlePolicy
7994
+ bundlePolicy?: BundlePolicy,
7995
+ iceTransportPolicy?: RTCIceTransportPolicy
7420
7996
  ) {
7421
7997
  this.rtcMetrics = this.isMultistream
7422
7998
  ? // @ts-ignore
@@ -7440,12 +8016,15 @@ export default class Meeting extends StatelessWebexPlugin {
7440
8016
  enableExtmap: this.config.enableExtmap,
7441
8017
  turnServerInfo,
7442
8018
  bundlePolicy,
8019
+ iceTransportPolicy,
7443
8020
  // @ts-ignore - config coming from registerPlugin
7444
8021
  iceCandidatesTimeout: this.config.iceCandidatesGatheringTimeout,
7445
8022
  // @ts-ignore - config coming from registerPlugin
7446
8023
  disableAudioMainDtx: this.config.experimental.disableAudioMainDtx,
7447
8024
  // @ts-ignore - config coming from registerPlugin
7448
8025
  enableAudioTwcc: this.config.enableAudioTwccForMultistream,
8026
+ // @ts-ignore - config coming from registerPlugin
8027
+ enableAv1SlidesSupport: this.config.enableAv1SlidesSupport,
7449
8028
  stopIceGatheringAfterFirstRelayCandidate:
7450
8029
  // @ts-ignore - config coming from registerPlugin
7451
8030
  this.config.stopIceGatheringAfterFirstRelayCandidate,
@@ -7564,7 +8143,7 @@ export default class Meeting extends StatelessWebexPlugin {
7564
8143
  try {
7565
8144
  await this.mediaProperties.waitForMediaConnectionConnected(this.correlationId);
7566
8145
  } catch (error) {
7567
- const {iceConnected} = error;
8146
+ const {iceConnected} = error as MediaConnectionAwaiterFailureResult;
7568
8147
 
7569
8148
  if (!this.hasMediaConnectionConnectedAtLeastOnce) {
7570
8149
  // Only send CA event for join flow if we haven't successfully connected media yet
@@ -7604,13 +8183,12 @@ export default class Meeting extends StatelessWebexPlugin {
7604
8183
  });
7605
8184
  }
7606
8185
 
7607
- const timedOutError = new Error(
7608
- `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
7609
8191
  );
7610
-
7611
- timedOutError.cause = error;
7612
-
7613
- throw timedOutError;
7614
8192
  }
7615
8193
  }
7616
8194
 
@@ -7823,7 +8401,18 @@ export default class Meeting extends StatelessWebexPlugin {
7823
8401
  error
7824
8402
  );
7825
8403
 
7826
- 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
+ });
7827
8416
  }
7828
8417
  }
7829
8418
 
@@ -7898,7 +8487,21 @@ export default class Meeting extends StatelessWebexPlugin {
7898
8487
  ({turnServerInfo} = await this.doTurnDiscovery(isReconnecting, isForced));
7899
8488
  }
7900
8489
 
7901
- 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
+ );
7902
8505
 
7903
8506
  LoggerProxy.logger.info(
7904
8507
  `${LOG_HEADER} media connection created this.isMultistream=${this.isMultistream}`
@@ -7935,7 +8538,7 @@ export default class Meeting extends StatelessWebexPlugin {
7935
8538
  await this.remoteMediaManager.start();
7936
8539
  }
7937
8540
 
7938
- await mc.initiateOffer();
8541
+ await mediaConnection.initiateOffer();
7939
8542
 
7940
8543
  await this.waitForRemoteSDPAnswer();
7941
8544
 
@@ -8003,6 +8606,9 @@ export default class Meeting extends StatelessWebexPlugin {
8003
8606
 
8004
8607
  this.isMultistream = false;
8005
8608
 
8609
+ // reset iceTransportPolicy, because it's only applied for multistream media connections
8610
+ this.addMediaData.iceTransportPolicy = undefined;
8611
+
8006
8612
  if (this.mediaProperties.webrtcMediaConnection) {
8007
8613
  // close peer connection, but don't reset mute state information, because we will want to use it on the retry
8008
8614
  this.closePeerConnections(false);
@@ -8083,6 +8689,8 @@ export default class Meeting extends StatelessWebexPlugin {
8083
8689
  regionCode: this.webex.meetings.geoHintInfo?.regionCode,
8084
8690
  },
8085
8691
  preferTranscoding: !this.isMultistream,
8692
+ getCurrentSelfUrl: () => this.selfUrl,
8693
+ waitForSelfUrlChange: () => this.waitForSelfUrlChange(),
8086
8694
  },
8087
8695
  {
8088
8696
  // @ts-ignore
@@ -8091,6 +8699,41 @@ export default class Meeting extends StatelessWebexPlugin {
8091
8699
  );
8092
8700
  }
8093
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
+
8094
8737
  /**
8095
8738
  * Creates a media connection to the server. Media connection is required for sending or receiving any audio/video.
8096
8739
  *
@@ -8102,8 +8745,9 @@ export default class Meeting extends StatelessWebexPlugin {
8102
8745
  addMedia(options: AddMediaOptions = {}): Promise<void> {
8103
8746
  return this.addMediaInternal(
8104
8747
  () => (this.turnServerUsed ? 'JOIN_MEETING_FINAL' : 'JOIN_MEETING_RETRY'),
8105
- undefined,
8106
8748
  false,
8749
+ undefined /* turnServerInfo - it will be fetched via doTurnDiscovery() */,
8750
+ undefined /* iceTransportPolicy - we're relying on the default value */,
8107
8751
  options
8108
8752
  );
8109
8753
  }
@@ -8112,8 +8756,9 @@ export default class Meeting extends StatelessWebexPlugin {
8112
8756
  * Internal version of addMedia() with some more arguments for finer control of its behavior
8113
8757
  *
8114
8758
  * @param {Function} icePhaseCallback - callback to determine the icePhase for CA "client.ice.end" failure events
8115
- * @param {TurnServerInfo} turnServerInfo - TURN server information
8116
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
8117
8762
  * @param {AddMediaOptions} options - same as options of the public addMedia() method
8118
8763
  * @returns {Promise<void>}
8119
8764
  * @protected
@@ -8121,12 +8766,14 @@ export default class Meeting extends StatelessWebexPlugin {
8121
8766
  */
8122
8767
  protected async addMediaInternal(
8123
8768
  icePhaseCallback: () => string,
8124
- turnServerInfo: TurnServerInfo,
8125
- forceTurnDiscovery,
8769
+ forceTurnDiscovery: boolean,
8770
+ turnServerInfo?: TurnServerInfo,
8771
+ iceTransportPolicy?: RTCIceTransportPolicy,
8126
8772
  options: AddMediaOptions = {}
8127
8773
  ): Promise<void> {
8128
8774
  this.addMediaData.retriedWithTurnServer = false;
8129
8775
  this.addMediaData.icePhaseCallback = icePhaseCallback;
8776
+ this.addMediaData.iceTransportPolicy = iceTransportPolicy;
8130
8777
 
8131
8778
  this.hasMediaConnectionConnectedAtLeastOnce = false;
8132
8779
  const LOG_HEADER = 'Meeting:index#addMedia -->';
@@ -8135,7 +8782,7 @@ export default class Meeting extends StatelessWebexPlugin {
8135
8782
  options
8136
8783
  )}, turnServerInfo=${JSON.stringify(
8137
8784
  turnServerInfo
8138
- )}, forceTurnDiscovery=${forceTurnDiscovery}`
8785
+ )}, forceTurnDiscovery=${forceTurnDiscovery}, iceTransportPolicy=${iceTransportPolicy}`
8139
8786
  );
8140
8787
 
8141
8788
  if (options.allowMediaInLobby !== true && this.meetingState !== FULL_STATE.ACTIVE) {
@@ -8249,12 +8896,7 @@ export default class Meeting extends StatelessWebexPlugin {
8249
8896
 
8250
8897
  // Establish new media connection with forced TURN discovery
8251
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
8252
- await this.establishMediaConnection(
8253
- remoteMediaManagerConfig,
8254
- bundlePolicy,
8255
- true,
8256
- undefined
8257
- );
8899
+ await this.establishMediaConnection(remoteMediaManagerConfig, bundlePolicy, true);
8258
8900
  } else {
8259
8901
  throw error;
8260
8902
  }
@@ -8283,7 +8925,8 @@ export default class Meeting extends StatelessWebexPlugin {
8283
8925
  numTransports,
8284
8926
  isMultistream: this.isMultistream,
8285
8927
  retriedWithTurnServer: this.addMediaData.retriedWithTurnServer,
8286
- isJoinWithMediaRetry: this.joinWithMediaRetryInfo.isRetry,
8928
+ isJoinWithMediaRetry: this.joinWithMediaRetryInfo.retryCount > 0,
8929
+ iceTransportPolicy: this.addMediaData.iceTransportPolicy || 'all',
8287
8930
  ...reachabilityMetrics,
8288
8931
  ...iceCandidateErrors,
8289
8932
  iceCandidatesCount: this.iceCandidatesCount,
@@ -8305,14 +8948,16 @@ export default class Meeting extends StatelessWebexPlugin {
8305
8948
  // We can log ReceiveSlot SSRCs only after the SDP exchange, so doing it here:
8306
8949
  this.remoteMediaManager?.logAllReceiveSlots();
8307
8950
  this.startPeriodicLogUpload();
8308
- } catch (error) {
8951
+ } catch (error: any) {
8309
8952
  LoggerProxy.logger.error(`${LOG_HEADER} failed to establish media connection: `, error);
8310
8953
 
8311
8954
  // @ts-ignore
8312
8955
  const reachabilityMetrics = await this.getMediaReachabilityMetricFields();
8313
8956
 
8314
- const {selectedCandidatePairChanges, numTransports} =
8315
- await this.mediaProperties.getCurrentConnectionInfo();
8957
+ const {connectionType, selectedCandidatePairChanges, numTransports} =
8958
+ error instanceof AddMediaFailed
8959
+ ? error
8960
+ : await this.mediaProperties.getCurrentConnectionInfo();
8316
8961
 
8317
8962
  const iceCandidateErrors = Object.fromEntries(this.iceCandidateErrors);
8318
8963
 
@@ -8328,7 +8973,8 @@ export default class Meeting extends StatelessWebexPlugin {
8328
8973
  turnServerUsed: this.turnServerUsed,
8329
8974
  retriedWithTurnServer: this.addMediaData.retriedWithTurnServer,
8330
8975
  isMultistream: this.isMultistream,
8331
- isJoinWithMediaRetry: this.joinWithMediaRetryInfo.isRetry,
8976
+ isJoinWithMediaRetry: this.joinWithMediaRetryInfo.retryCount > 0,
8977
+ iceTransportPolicy: this.addMediaData.iceTransportPolicy || 'all',
8332
8978
  signalingState:
8333
8979
  this.mediaProperties.webrtcMediaConnection?.multistreamConnection?.pc?.pc
8334
8980
  ?.signalingState ||
@@ -8344,6 +8990,7 @@ export default class Meeting extends StatelessWebexPlugin {
8344
8990
  ?.iceConnectionState ||
8345
8991
  this.mediaProperties.webrtcMediaConnection?.mediaConnection?.pc?.iceConnectionState ||
8346
8992
  'unknown',
8993
+ connectionType,
8347
8994
  ...reachabilityMetrics,
8348
8995
  ...iceCandidateErrors,
8349
8996
  iceCandidatesCount: this.iceCandidatesCount,
@@ -8692,6 +9339,7 @@ export default class Meeting extends StatelessWebexPlugin {
8692
9339
  options: {meetingId: this.id},
8693
9340
  });
8694
9341
  LoggerProxy.logger.log('Meeting:index#leave --> Leaving a meeting');
9342
+ this.stopListeningForMeetingEvents();
8695
9343
 
8696
9344
  return MeetingUtil.leaveMeeting(this, options)
8697
9345
  .then(async (leave) => {
@@ -9557,6 +10205,8 @@ export default class Meeting extends StatelessWebexPlugin {
9557
10205
  locus_id: this.locusId,
9558
10206
  });
9559
10207
 
10208
+ this.stopListeningForMeetingEvents();
10209
+
9560
10210
  return MeetingUtil.endMeetingForAll(this)
9561
10211
  .then(async (end) => {
9562
10212
  this.meetingFiniteStateMachine.end();
@@ -9618,12 +10268,14 @@ export default class Meeting extends StatelessWebexPlugin {
9618
10268
  }
9619
10269
  this.queuedMediaUpdates = [];
9620
10270
 
9621
- if (this.transcription) {
9622
- this.stopTranscription();
9623
- this.transcription = undefined;
9624
- }
9625
-
9626
- this.annotation.deregisterEvents();
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().
10278
+ this.clearDataChannelToken();
9627
10279
 
9628
10280
  await this.cleanupLLMConneciton({throwOnError: false});
9629
10281
  };
@@ -9701,15 +10353,12 @@ export default class Meeting extends StatelessWebexPlugin {
9701
10353
  * @public
9702
10354
  * @memberof Meeting
9703
10355
  */
9704
- public sendReaction(reactionType: ReactionServerType, skinToneType?: SkinToneType) {
10356
+ public sendReaction(reactionType: string, skinToneType?: SkinToneType) {
9705
10357
  const reactionChannelUrl = this.locusInfo?.controls?.reactions?.reactionChannelUrl as string;
9706
10358
  const participantId = this.members.selfId;
9707
10359
 
9708
- const reactionData = Reactions[reactionType];
10360
+ const reactionData = Reactions[reactionType] || {type: reactionType};
9709
10361
 
9710
- if (!reactionData) {
9711
- return Promise.reject(new Error(`${reactionType} is not a valid reaction.`));
9712
- }
9713
10362
  const skinToneData = SkinTones[skinToneType] || SkinTones.normal;
9714
10363
  const reaction: Reaction = {
9715
10364
  ...reactionData,
@@ -9818,15 +10467,20 @@ export default class Meeting extends StatelessWebexPlugin {
9818
10467
  }
9819
10468
 
9820
10469
  if (shouldEnableMusicMode) {
9821
- await this.sendSlotManager.setCodecParameters(MediaType.AudioMain, {
9822
- maxaveragebitrate: '64000',
9823
- maxplaybackrate: '48000',
9824
- });
10470
+ await this.sendSlotManager.setCustomCodecParameters(
10471
+ MediaType.AudioMain,
10472
+ MediaCodecMimeType.OPUS,
10473
+ {
10474
+ maxaveragebitrate: '64000',
10475
+ maxplaybackrate: '48000',
10476
+ }
10477
+ );
9825
10478
  } else {
9826
- await this.sendSlotManager.deleteCodecParameters(MediaType.AudioMain, [
9827
- 'maxaveragebitrate',
9828
- 'maxplaybackrate',
9829
- ]);
10479
+ await this.sendSlotManager.markCustomCodecParametersForDeletion(
10480
+ MediaType.AudioMain,
10481
+ MediaCodecMimeType.OPUS,
10482
+ ['maxaveragebitrate', 'maxplaybackrate']
10483
+ );
9830
10484
  }
9831
10485
  }
9832
10486