@stream-io/video-client 1.16.3 → 1.16.4

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/index.cjs.js CHANGED
@@ -5205,15 +5205,6 @@ class BasePeerConnection {
5205
5205
  this.isIceRestarting = false;
5206
5206
  this.isDisposed = false;
5207
5207
  this.subscriptions = [];
5208
- /**
5209
- * Disposes the `RTCPeerConnection` instance.
5210
- */
5211
- this.dispose = () => {
5212
- this.onUnrecoverableError = undefined;
5213
- this.isDisposed = true;
5214
- this.detachEventHandlers();
5215
- this.pc.close();
5216
- };
5217
5208
  /**
5218
5209
  * Handles events synchronously.
5219
5210
  * Consecutive events are queued and executed one after the other.
@@ -5350,6 +5341,15 @@ class BasePeerConnection {
5350
5341
  this.pc.addEventListener('icegatheringstatechange', this.onIceGatherChange);
5351
5342
  this.pc.addEventListener('signalingstatechange', this.onSignalingChange);
5352
5343
  }
5344
+ /**
5345
+ * Disposes the `RTCPeerConnection` instance.
5346
+ */
5347
+ dispose() {
5348
+ this.onUnrecoverableError = undefined;
5349
+ this.isDisposed = true;
5350
+ this.detachEventHandlers();
5351
+ this.pc.close();
5352
+ }
5353
5353
  /**
5354
5354
  * Detaches the event handlers from the `RTCPeerConnection`.
5355
5355
  */
@@ -5710,7 +5710,9 @@ class Publisher extends BasePeerConnection {
5710
5710
  this.addTransceiver(trackToPublish, publishOption);
5711
5711
  }
5712
5712
  else {
5713
+ const previousTrack = transceiver.sender.track;
5713
5714
  await transceiver.sender.replaceTrack(trackToPublish);
5715
+ previousTrack?.stop();
5714
5716
  }
5715
5717
  }
5716
5718
  };
@@ -5802,6 +5804,14 @@ class Publisher extends BasePeerConnection {
5802
5804
  transceiver.sender.track?.stop();
5803
5805
  }
5804
5806
  };
5807
+ /**
5808
+ * Stops all the cloned tracks that are being published to the SFU.
5809
+ */
5810
+ this.stopAllTracks = () => {
5811
+ for (const { transceiver } of this.transceiverCache.items()) {
5812
+ transceiver.sender.track?.stop();
5813
+ }
5814
+ };
5805
5815
  this.changePublishQuality = async (videoSender) => {
5806
5816
  const { trackType, layers, publishOptionId } = videoSender;
5807
5817
  const enabledLayers = layers.filter((l) => l.active);
@@ -6010,6 +6020,13 @@ class Publisher extends BasePeerConnection {
6010
6020
  // abort any ongoing negotiation
6011
6021
  withCancellation('publisher.negotiate', () => Promise.resolve());
6012
6022
  }
6023
+ /**
6024
+ * Disposes this Publisher instance.
6025
+ */
6026
+ dispose() {
6027
+ super.dispose();
6028
+ this.stopAllTracks();
6029
+ }
6013
6030
  }
6014
6031
 
6015
6032
  /**
@@ -7433,7 +7450,7 @@ const aggregate = (stats) => {
7433
7450
  return report;
7434
7451
  };
7435
7452
 
7436
- const version = "1.16.3";
7453
+ const version = "1.16.4";
7437
7454
  const [major, minor, patch] = version.split('.');
7438
7455
  let sdkInfo = {
7439
7456
  type: SdkType.PLAIN_JAVASCRIPT,
@@ -13039,7 +13056,7 @@ class StreamClient {
13039
13056
  return await this.wsConnection.connect(this.defaultWSTimeout);
13040
13057
  };
13041
13058
  this.getUserAgent = () => {
13042
- const version = "1.16.3";
13059
+ const version = "1.16.4";
13043
13060
  return (this.userAgent ||
13044
13061
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
13045
13062
  };