@webex/web-client-media-engine 1.33.2 → 1.34.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -1150,7 +1150,12 @@ class LocalTrack extends EventEmitter$2 {
1150
1150
  * Cleanup local microphone track.
1151
1151
  */
1152
1152
  disposeEffects() {
1153
- this.effects.forEach((effect) => effect.dispose());
1153
+ if (this.effects.size > 0) {
1154
+ this.effects.forEach((effect) => effect.dispose());
1155
+ this.effects.clear();
1156
+ this.underlyingStream = this.originalStream;
1157
+ this.emit(LocalTrackEvents.UnderlyingTrackChange);
1158
+ }
1154
1159
  }
1155
1160
  }
1156
1161
  LocalTrack.Events = LocalTrackEvents;
@@ -9434,41 +9439,42 @@ class MultistreamConnection extends EventEmitter {
9434
9439
  this.overuseUpdateCallback = () => { };
9435
9440
  this.options = Object.assign(Object.assign({}, defaultMultistreamConnectionOptions), userOptions);
9436
9441
  logger.info(`Creating multistream connection with options ${JSON.stringify(this.options)}`);
9437
- this.pc = new PeerConnection();
9438
- this.pc.on(PeerConnection.Events.ConnectionStateChange, (state) => this.emit(MultistreamConnectionEventNames.ConnectionStateUpdate, state));
9442
+ this.initializePeerConnection();
9439
9443
  this.streamSignalerManager = new StreamSignalerManager(this.options.streamSignalingMode);
9440
9444
  this.overuseStateManager = new OveruseStateManager((overuseState) => this.overuseUpdateCallback(overuseState));
9441
9445
  this.overuseStateManager.start();
9442
9446
  this.statsManager = new StatsManager(() => this.pc.getStats(), (stats) => this.preProcessStats(stats));
9443
- this.attachMetricsObserver();
9444
9447
  const mainSceneId = generateSceneId();
9445
- const videoMainEncodingOptions = !this.options.disableSimulcast
9446
- ? [
9447
- { scaleResolutionDownBy: 4, active: false },
9448
- { scaleResolutionDownBy: 2, active: false },
9449
- { active: false },
9450
- ]
9451
- : [{ active: false }];
9448
+ const videoMainEncodingOptions = this.getVideoEncodingOptions();
9452
9449
  this.createSendTransceiver(MediaType.VideoMain, mainSceneId, videoMainEncodingOptions);
9453
9450
  this.createSendTransceiver(MediaType.AudioMain, mainSceneId);
9454
9451
  if (this.options.floorControlledPresentation) {
9455
- const videoPresentationEncodingOptions = !this.options
9456
- .disableSimulcast
9457
- ? [
9458
- { scaleResolutionDownBy: 4, active: false },
9459
- { scaleResolutionDownBy: 2, active: false },
9460
- { active: false },
9461
- ]
9462
- : [{ active: false }];
9452
+ const videoPresentationEncodingOptions = this.getVideoEncodingOptions();
9463
9453
  const contentSceneId = generateSceneId();
9464
9454
  this.createSendTransceiver(MediaType.VideoSlides, contentSceneId, videoPresentationEncodingOptions);
9465
9455
  this.createSendTransceiver(MediaType.AudioSlides, contentSceneId);
9466
9456
  }
9457
+ }
9458
+ initializePeerConnection() {
9459
+ var _a;
9460
+ (_a = this.pc) === null || _a === void 0 ? void 0 : _a.close();
9461
+ this.pc = new PeerConnection();
9462
+ this.pc.on(PeerConnection.Events.ConnectionStateChange, (state) => this.emit(MultistreamConnectionEventNames.ConnectionStateUpdate, state));
9463
+ this.attachMetricsObserver();
9467
9464
  this.createDataChannel();
9468
9465
  }
9469
9466
  getConnectionState() {
9470
9467
  return this.pc.getConnectionState();
9471
9468
  }
9469
+ getVideoEncodingOptions() {
9470
+ return !this.options.disableSimulcast
9471
+ ? [
9472
+ { scaleResolutionDownBy: 4, active: false },
9473
+ { scaleResolutionDownBy: 2, active: false },
9474
+ { active: false },
9475
+ ]
9476
+ : [{ active: false }];
9477
+ }
9472
9478
  createSendTransceiver(mediaType, sceneId, sendEncodingsOptions) {
9473
9479
  const rtcTransceiver = this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {
9474
9480
  direction: 'sendrecv',
@@ -9476,6 +9482,9 @@ class MultistreamConnection extends EventEmitter {
9476
9482
  });
9477
9483
  const csi = generateCsi(getMediaFamily(mediaType), sceneId);
9478
9484
  this.sendTransceivers.set(mediaType, new SendOnlyTransceiver(rtcTransceiver, csi));
9485
+ this.createJmpSession(mediaType);
9486
+ }
9487
+ createJmpSession(mediaType) {
9479
9488
  const jmpSession = new JmpSession(getMediaFamily(mediaType), getMediaContent(mediaType));
9480
9489
  jmpSession.setTxCallback((msg) => {
9481
9490
  var _a;
@@ -9920,13 +9929,26 @@ class MultistreamConnection extends EventEmitter {
9920
9929
  this.pendingJmpTasks.push(task);
9921
9930
  }
9922
9931
  }
9923
- renewPeerConnection() {
9924
- var _a;
9925
- (_a = this.pc) === null || _a === void 0 ? void 0 : _a.close();
9926
- this.pc = new PeerConnection();
9927
- this.attachMetricsObserver();
9928
- this.createDataChannel();
9929
- this.sendTransceivers.forEach((transceiver, mediaType) => transceiver.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType))));
9932
+ renewPeerConnection(userOptions) {
9933
+ if (userOptions) {
9934
+ this.options = Object.assign(Object.assign({}, defaultMultistreamConnectionOptions), userOptions);
9935
+ }
9936
+ logger.info(`Renewing multistream connection with options ${JSON.stringify(this.options)}`);
9937
+ this.initializePeerConnection();
9938
+ this.streamSignalerManager = new StreamSignalerManager(this.options.streamSignalingMode);
9939
+ const mainSceneId = generateSceneId();
9940
+ this.sendTransceivers.forEach((transceiver, mediaType) => {
9941
+ var _a;
9942
+ transceiver.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {
9943
+ direction: 'sendrecv',
9944
+ sendEncodings: getMediaFamily(mediaType) === MediaFamily.Video
9945
+ ? this.getVideoEncodingOptions()
9946
+ : undefined,
9947
+ }));
9948
+ transceiver.csi = generateCsi(getMediaFamily(mediaType), mainSceneId);
9949
+ (_a = this.jmpSessions.get(mediaType)) === null || _a === void 0 ? void 0 : _a.close();
9950
+ this.createJmpSession(mediaType);
9951
+ });
9930
9952
  this.recvTransceivers.forEach((transceivers, mediaType) => {
9931
9953
  transceivers.forEach((t) => {
9932
9954
  t.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {