@stream-io/video-client 1.16.4 → 1.16.5

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.es.js CHANGED
@@ -5685,6 +5685,7 @@ class Publisher extends BasePeerConnection {
5685
5685
  constructor({ publishOptions, ...baseOptions }) {
5686
5686
  super(PeerType.PUBLISHER_UNSPECIFIED, baseOptions);
5687
5687
  this.transceiverCache = new TransceiverCache();
5688
+ this.clonedTracks = new Set();
5688
5689
  /**
5689
5690
  * Starts publishing the given track of the given media stream.
5690
5691
  *
@@ -5703,7 +5704,7 @@ class Publisher extends BasePeerConnection {
5703
5704
  continue;
5704
5705
  // create a clone of the track as otherwise the same trackId will
5705
5706
  // appear in the SDP in multiple transceivers
5706
- const trackToPublish = track.clone();
5707
+ const trackToPublish = this.cloneTrack(track);
5707
5708
  const transceiver = this.transceiverCache.get(publishOption);
5708
5709
  if (!transceiver) {
5709
5710
  this.addTransceiver(trackToPublish, publishOption);
@@ -5711,7 +5712,7 @@ class Publisher extends BasePeerConnection {
5711
5712
  else {
5712
5713
  const previousTrack = transceiver.sender.track;
5713
5714
  await transceiver.sender.replaceTrack(trackToPublish);
5714
- previousTrack?.stop();
5715
+ this.stopTrack(previousTrack);
5715
5716
  }
5716
5717
  }
5717
5718
  };
@@ -5748,7 +5749,7 @@ class Publisher extends BasePeerConnection {
5748
5749
  continue;
5749
5750
  // take the track from the existing transceiver for the same track type,
5750
5751
  // clone it and publish it with the new publish options
5751
- const track = item.transceiver.sender.track.clone();
5752
+ const track = this.cloneTrack(item.transceiver.sender.track);
5752
5753
  this.addTransceiver(track, publishOption);
5753
5754
  }
5754
5755
  // stop publishing with options not required anymore -> [vp9]
@@ -5759,7 +5760,7 @@ class Publisher extends BasePeerConnection {
5759
5760
  if (hasPublishOption)
5760
5761
  continue;
5761
5762
  // it is safe to stop the track here, it is a clone
5762
- transceiver.sender.track?.stop();
5763
+ this.stopTrack(transceiver.sender.track);
5763
5764
  await transceiver.sender.replaceTrack(null);
5764
5765
  }
5765
5766
  };
@@ -5800,7 +5801,7 @@ class Publisher extends BasePeerConnection {
5800
5801
  const { publishOption, transceiver } = item;
5801
5802
  if (!trackTypes.includes(publishOption.trackType))
5802
5803
  continue;
5803
- transceiver.sender.track?.stop();
5804
+ this.stopTrack(transceiver.sender.track);
5804
5805
  }
5805
5806
  };
5806
5807
  /**
@@ -5808,7 +5809,10 @@ class Publisher extends BasePeerConnection {
5808
5809
  */
5809
5810
  this.stopAllTracks = () => {
5810
5811
  for (const { transceiver } of this.transceiverCache.items()) {
5811
- transceiver.sender.track?.stop();
5812
+ this.stopTrack(transceiver.sender.track);
5813
+ }
5814
+ for (const track of this.clonedTracks) {
5815
+ this.stopTrack(track);
5812
5816
  }
5813
5817
  };
5814
5818
  this.changePublishQuality = async (videoSender) => {
@@ -5988,6 +5992,17 @@ class Publisher extends BasePeerConnection {
5988
5992
  publishOptionId: publishOption.id,
5989
5993
  };
5990
5994
  };
5995
+ this.cloneTrack = (track) => {
5996
+ const clone = track.clone();
5997
+ this.clonedTracks.add(clone);
5998
+ return clone;
5999
+ };
6000
+ this.stopTrack = (track) => {
6001
+ if (!track)
6002
+ return;
6003
+ track.stop();
6004
+ this.clonedTracks.delete(track);
6005
+ };
5991
6006
  this.publishOptions = publishOptions;
5992
6007
  this.pc.addEventListener('negotiationneeded', this.onNegotiationNeeded);
5993
6008
  this.on('iceRestart', (iceRestart) => {
@@ -6025,6 +6040,7 @@ class Publisher extends BasePeerConnection {
6025
6040
  dispose() {
6026
6041
  super.dispose();
6027
6042
  this.stopAllTracks();
6043
+ this.clonedTracks.clear();
6028
6044
  }
6029
6045
  }
6030
6046
 
@@ -7449,7 +7465,7 @@ const aggregate = (stats) => {
7449
7465
  return report;
7450
7466
  };
7451
7467
 
7452
- const version = "1.16.4";
7468
+ const version = "1.16.5";
7453
7469
  const [major, minor, patch] = version.split('.');
7454
7470
  let sdkInfo = {
7455
7471
  type: SdkType.PLAIN_JAVASCRIPT,
@@ -13055,7 +13071,7 @@ class StreamClient {
13055
13071
  return await this.wsConnection.connect(this.defaultWSTimeout);
13056
13072
  };
13057
13073
  this.getUserAgent = () => {
13058
- const version = "1.16.4";
13074
+ const version = "1.16.5";
13059
13075
  return (this.userAgent ||
13060
13076
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
13061
13077
  };