@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.es.js CHANGED
@@ -3021,7 +3021,7 @@ const retryable = async (rpc, signal) => {
3021
3021
  return result;
3022
3022
  };
3023
3023
 
3024
- const version = "1.8.1";
3024
+ const version = "1.8.2";
3025
3025
  const [major, minor, patch] = version.split('.');
3026
3026
  let sdkInfo = {
3027
3027
  type: SdkType.PLAIN_JAVASCRIPT,
@@ -5238,6 +5238,11 @@ class Publisher {
5238
5238
  if (previousTrack && previousTrack !== track) {
5239
5239
  previousTrack.stop();
5240
5240
  previousTrack.removeEventListener('ended', handleTrackEnded);
5241
+ // @ts-expect-error release() is present in react-native-webrtc and must be called to dispose the track
5242
+ if (typeof previousTrack.release === 'function') {
5243
+ // @ts-expect-error
5244
+ track.release();
5245
+ }
5241
5246
  track.addEventListener('ended', handleTrackEnded);
5242
5247
  }
5243
5248
  if (!track.enabled) {
@@ -5257,14 +5262,19 @@ class Publisher {
5257
5262
  const transceiver = this.pc
5258
5263
  .getTransceivers()
5259
5264
  .find((t) => t === this.transceiverRegistry[trackType] && t.sender.track);
5260
- if (transceiver &&
5261
- transceiver.sender.track &&
5262
- (stopTrack
5263
- ? transceiver.sender.track.readyState === 'live'
5264
- : transceiver.sender.track.enabled)) {
5265
- stopTrack
5266
- ? transceiver.sender.track.stop()
5267
- : (transceiver.sender.track.enabled = false);
5265
+ const track = transceiver?.sender.track;
5266
+ if (track && (stopTrack ? track.readyState === 'live' : track.enabled)) {
5267
+ if (stopTrack) {
5268
+ track.stop();
5269
+ // @ts-expect-error release() is present in react-native-webrtc and must be called to dispose the track
5270
+ if (typeof track.release === 'function') {
5271
+ // @ts-expect-error
5272
+ track.release();
5273
+ }
5274
+ }
5275
+ else {
5276
+ track.enabled = false;
5277
+ }
5268
5278
  // We don't need to notify SFU if unpublishing in response to remote soft mute
5269
5279
  if (this.state.localParticipant?.publishedTracks.includes(trackType)) {
5270
5280
  await this.notifyTrackMuteStateChanged(undefined, trackType, true);
@@ -5311,7 +5321,13 @@ class Publisher {
5311
5321
  this.stopPublishing = () => {
5312
5322
  this.logger('debug', 'Stopping publishing all tracks');
5313
5323
  this.pc.getSenders().forEach((s) => {
5314
- s.track?.stop();
5324
+ const track = s.track;
5325
+ track?.stop();
5326
+ // @ts-expect-error release() is present in react-native-webrtc and must be called to dispose the track
5327
+ if (typeof track?.release === 'function') {
5328
+ // @ts-expect-error
5329
+ track.release();
5330
+ }
5315
5331
  if (this.pc.signalingState !== 'closed') {
5316
5332
  this.pc.removeTrack(s);
5317
5333
  }
@@ -7940,6 +7956,11 @@ const disposeOfMediaStream = (stream) => {
7940
7956
  stream.getTracks().forEach((track) => {
7941
7957
  track.stop();
7942
7958
  stream.removeTrack(track);
7959
+ // @ts-expect-error release() is present in react-native-webrtc and must be called to dispose the track
7960
+ if (typeof track.release === 'function') {
7961
+ // @ts-expect-error
7962
+ track.release();
7963
+ }
7943
7964
  });
7944
7965
  // @ts-expect-error release() is present in react-native-webrtc and must be called to dispose the stream
7945
7966
  if (typeof stream.release === 'function') {
@@ -8159,8 +8180,14 @@ class InputMediaDeviceManager {
8159
8180
  }
8160
8181
  stopTracks() {
8161
8182
  this.getTracks().forEach((track) => {
8162
- if (track.readyState === 'live')
8183
+ if (track.readyState === 'live') {
8163
8184
  track.stop();
8185
+ // @ts-expect-error release() is present in react-native-webrtc and must be called to dispose the track
8186
+ if (typeof track.release === 'function') {
8187
+ // @ts-expect-error
8188
+ track.release();
8189
+ }
8190
+ }
8164
8191
  });
8165
8192
  }
8166
8193
  muteLocalStream(stopTracks) {
@@ -8801,7 +8828,14 @@ class RNSpeechDetector {
8801
8828
  if (!this.audioStream) {
8802
8829
  return;
8803
8830
  }
8804
- this.audioStream.getTracks().forEach((track) => track.stop());
8831
+ this.audioStream.getTracks().forEach((track) => {
8832
+ track.stop();
8833
+ // @ts-expect-error release() is present in react-native-webrtc and must be called to dispose the track
8834
+ if (typeof track.release === 'function') {
8835
+ // @ts-expect-error
8836
+ track.release();
8837
+ }
8838
+ });
8805
8839
  if (
8806
8840
  // @ts-expect-error release() is present in react-native-webrtc
8807
8841
  typeof this.audioStream.release === 'function') {
@@ -12469,7 +12503,7 @@ class StreamClient {
12469
12503
  });
12470
12504
  };
12471
12505
  this.getUserAgent = () => {
12472
- const version = "1.8.1";
12506
+ const version = "1.8.2";
12473
12507
  return (this.userAgent ||
12474
12508
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
12475
12509
  };