@stream-io/video-client 1.8.1 → 1.8.2

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
@@ -3041,7 +3041,7 @@ const retryable = async (rpc, signal) => {
3041
3041
  return result;
3042
3042
  };
3043
3043
 
3044
- const version = "1.8.1";
3044
+ const version = "1.8.2";
3045
3045
  const [major, minor, patch] = version.split('.');
3046
3046
  let sdkInfo = {
3047
3047
  type: SdkType.PLAIN_JAVASCRIPT,
@@ -5258,6 +5258,11 @@ class Publisher {
5258
5258
  if (previousTrack && previousTrack !== track) {
5259
5259
  previousTrack.stop();
5260
5260
  previousTrack.removeEventListener('ended', handleTrackEnded);
5261
+ // @ts-expect-error release() is present in react-native-webrtc and must be called to dispose the track
5262
+ if (typeof previousTrack.release === 'function') {
5263
+ // @ts-expect-error
5264
+ track.release();
5265
+ }
5261
5266
  track.addEventListener('ended', handleTrackEnded);
5262
5267
  }
5263
5268
  if (!track.enabled) {
@@ -5277,14 +5282,19 @@ class Publisher {
5277
5282
  const transceiver = this.pc
5278
5283
  .getTransceivers()
5279
5284
  .find((t) => t === this.transceiverRegistry[trackType] && t.sender.track);
5280
- if (transceiver &&
5281
- transceiver.sender.track &&
5282
- (stopTrack
5283
- ? transceiver.sender.track.readyState === 'live'
5284
- : transceiver.sender.track.enabled)) {
5285
- stopTrack
5286
- ? transceiver.sender.track.stop()
5287
- : (transceiver.sender.track.enabled = false);
5285
+ const track = transceiver?.sender.track;
5286
+ if (track && (stopTrack ? track.readyState === 'live' : track.enabled)) {
5287
+ if (stopTrack) {
5288
+ track.stop();
5289
+ // @ts-expect-error release() is present in react-native-webrtc and must be called to dispose the track
5290
+ if (typeof track.release === 'function') {
5291
+ // @ts-expect-error
5292
+ track.release();
5293
+ }
5294
+ }
5295
+ else {
5296
+ track.enabled = false;
5297
+ }
5288
5298
  // We don't need to notify SFU if unpublishing in response to remote soft mute
5289
5299
  if (this.state.localParticipant?.publishedTracks.includes(trackType)) {
5290
5300
  await this.notifyTrackMuteStateChanged(undefined, trackType, true);
@@ -5331,7 +5341,13 @@ class Publisher {
5331
5341
  this.stopPublishing = () => {
5332
5342
  this.logger('debug', 'Stopping publishing all tracks');
5333
5343
  this.pc.getSenders().forEach((s) => {
5334
- s.track?.stop();
5344
+ const track = s.track;
5345
+ track?.stop();
5346
+ // @ts-expect-error release() is present in react-native-webrtc and must be called to dispose the track
5347
+ if (typeof track?.release === 'function') {
5348
+ // @ts-expect-error
5349
+ track.release();
5350
+ }
5335
5351
  if (this.pc.signalingState !== 'closed') {
5336
5352
  this.pc.removeTrack(s);
5337
5353
  }
@@ -7960,6 +7976,11 @@ const disposeOfMediaStream = (stream) => {
7960
7976
  stream.getTracks().forEach((track) => {
7961
7977
  track.stop();
7962
7978
  stream.removeTrack(track);
7979
+ // @ts-expect-error release() is present in react-native-webrtc and must be called to dispose the track
7980
+ if (typeof track.release === 'function') {
7981
+ // @ts-expect-error
7982
+ track.release();
7983
+ }
7963
7984
  });
7964
7985
  // @ts-expect-error release() is present in react-native-webrtc and must be called to dispose the stream
7965
7986
  if (typeof stream.release === 'function') {
@@ -8179,8 +8200,14 @@ class InputMediaDeviceManager {
8179
8200
  }
8180
8201
  stopTracks() {
8181
8202
  this.getTracks().forEach((track) => {
8182
- if (track.readyState === 'live')
8203
+ if (track.readyState === 'live') {
8183
8204
  track.stop();
8205
+ // @ts-expect-error release() is present in react-native-webrtc and must be called to dispose the track
8206
+ if (typeof track.release === 'function') {
8207
+ // @ts-expect-error
8208
+ track.release();
8209
+ }
8210
+ }
8184
8211
  });
8185
8212
  }
8186
8213
  muteLocalStream(stopTracks) {
@@ -8821,7 +8848,14 @@ class RNSpeechDetector {
8821
8848
  if (!this.audioStream) {
8822
8849
  return;
8823
8850
  }
8824
- this.audioStream.getTracks().forEach((track) => track.stop());
8851
+ this.audioStream.getTracks().forEach((track) => {
8852
+ track.stop();
8853
+ // @ts-expect-error release() is present in react-native-webrtc and must be called to dispose the track
8854
+ if (typeof track.release === 'function') {
8855
+ // @ts-expect-error
8856
+ track.release();
8857
+ }
8858
+ });
8825
8859
  if (
8826
8860
  // @ts-expect-error release() is present in react-native-webrtc
8827
8861
  typeof this.audioStream.release === 'function') {
@@ -12489,7 +12523,7 @@ class StreamClient {
12489
12523
  });
12490
12524
  };
12491
12525
  this.getUserAgent = () => {
12492
- const version = "1.8.1";
12526
+ const version = "1.8.2";
12493
12527
  return (this.userAgent ||
12494
12528
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
12495
12529
  };