@stream-io/video-client 0.3.14 → 0.3.16

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
@@ -6379,10 +6379,9 @@ class Publisher {
6379
6379
  * @param dispatcher the dispatcher to use.
6380
6380
  * @param isDtxEnabled whether DTX is enabled.
6381
6381
  * @param isRedEnabled whether RED is enabled.
6382
- * @param preferredVideoCodec the preferred video codec.
6383
6382
  * @param iceRestartDelay the delay in milliseconds to wait before restarting ICE once connection goes to `disconnected` state.
6384
6383
  */
6385
- constructor({ connectionConfig, sfuClient, dispatcher, state, isDtxEnabled, isRedEnabled, preferredVideoCodec, iceRestartDelay = 2500, }) {
6384
+ constructor({ connectionConfig, sfuClient, dispatcher, state, isDtxEnabled, isRedEnabled, iceRestartDelay = 2500, }) {
6386
6385
  this.transceiverRegistry = {
6387
6386
  [TrackType.AUDIO]: undefined,
6388
6387
  [TrackType.VIDEO]: undefined,
@@ -6882,7 +6881,6 @@ class Publisher {
6882
6881
  this.state = state;
6883
6882
  this.isDtxEnabled = isDtxEnabled;
6884
6883
  this.isRedEnabled = isRedEnabled;
6885
- this.preferredVideoCodec = preferredVideoCodec;
6886
6884
  this.iceRestartDelay = iceRestartDelay;
6887
6885
  this.unsubscribeOnIceRestart = dispatcher.on('iceRestart', (message) => __awaiter(this, void 0, void 0, function* () {
6888
6886
  if (message.eventPayload.oneofKind !== 'iceRestart')
@@ -8752,6 +8750,43 @@ const watchPinsUpdated = (state) => {
8752
8750
  };
8753
8751
  };
8754
8752
 
8753
+ /**
8754
+ * An event handler that handles soft mutes.
8755
+ *
8756
+ * @param call the call.
8757
+ */
8758
+ const handleRemoteSoftMute = (call) => {
8759
+ return call.on('trackUnpublished', (event) => __awaiter(void 0, void 0, void 0, function* () {
8760
+ var _a;
8761
+ if (event.eventPayload.oneofKind !== 'trackUnpublished')
8762
+ return;
8763
+ const { trackUnpublished: { cause, type, sessionId }, } = event.eventPayload;
8764
+ const { localParticipant } = call.state;
8765
+ if (cause === TrackUnpublishReason.MODERATION &&
8766
+ sessionId === (localParticipant === null || localParticipant === void 0 ? void 0 : localParticipant.sessionId)) {
8767
+ const logger = call.logger;
8768
+ logger('info', `Local participant's ${TrackType[type]} track is muted remotely`);
8769
+ try {
8770
+ if (type === TrackType.VIDEO) {
8771
+ yield call.camera.disable();
8772
+ }
8773
+ else if (type === TrackType.AUDIO) {
8774
+ yield call.microphone.disable();
8775
+ }
8776
+ else {
8777
+ logger('warn', 'Unsupported track type to soft mute', TrackType[type]);
8778
+ }
8779
+ if ((_a = call.publisher) === null || _a === void 0 ? void 0 : _a.isPublishing(type)) {
8780
+ yield call.stopPublish(type);
8781
+ }
8782
+ }
8783
+ catch (error) {
8784
+ logger('error', 'Failed to stop publishing', error);
8785
+ }
8786
+ }
8787
+ }));
8788
+ };
8789
+
8755
8790
  /**
8756
8791
  * An event responder which handles the `participantJoined` event.
8757
8792
  */
@@ -8901,6 +8936,7 @@ const registerEventHandlers = (call, state, dispatcher) => {
8901
8936
  watchDominantSpeakerChanged(dispatcher, state),
8902
8937
  call.on('callGrantsUpdated', watchCallGrantsUpdated(state)),
8903
8938
  call.on('pinsUpdated', watchPinsUpdated(state)),
8939
+ handleRemoteSoftMute(call),
8904
8940
  ];
8905
8941
  if (call.ringing) {
8906
8942
  // these events are only relevant when the call is ringing
@@ -9769,7 +9805,7 @@ class InputMediaDeviceManagerState {
9769
9805
  }
9770
9806
  /**
9771
9807
  * @internal
9772
- * @param stream
9808
+ * @param stream the stream to set.
9773
9809
  */
9774
9810
  setMediaStream(stream) {
9775
9811
  this.setCurrentValue(this.mediaStreamSubject, stream);
@@ -9779,7 +9815,7 @@ class InputMediaDeviceManagerState {
9779
9815
  }
9780
9816
  /**
9781
9817
  * @internal
9782
- * @param stream
9818
+ * @param deviceId the device id to set.
9783
9819
  */
9784
9820
  setDevice(deviceId) {
9785
9821
  this.setCurrentValue(this.selectedDeviceSubject, deviceId);
@@ -9896,7 +9932,7 @@ class InputMediaDeviceManager {
9896
9932
  return __awaiter(this, void 0, void 0, function* () {
9897
9933
  if (this.state.prevStatus === 'enabled' &&
9898
9934
  this.state.status === 'disabled') {
9899
- this.enable();
9935
+ yield this.enable();
9900
9936
  }
9901
9937
  });
9902
9938
  }
@@ -10291,7 +10327,7 @@ class CameraManager extends InputMediaDeviceManager {
10291
10327
  flip() {
10292
10328
  return __awaiter(this, void 0, void 0, function* () {
10293
10329
  const newDirection = this.state.direction === 'front' ? 'back' : 'front';
10294
- this.selectDirection(newDirection);
10330
+ yield this.selectDirection(newDirection);
10295
10331
  });
10296
10332
  }
10297
10333
  /**
@@ -10854,7 +10890,6 @@ class Call {
10854
10890
  connectionConfig,
10855
10891
  isDtxEnabled,
10856
10892
  isRedEnabled,
10857
- preferredVideoCodec: this.streamClient.options.preferredVideoCodec,
10858
10893
  });
10859
10894
  }
10860
10895
  if (!isMigrating) {
@@ -11638,27 +11673,6 @@ class Call {
11638
11673
  this.leaveCallHooks.add(createSubscription(this.trackSubscriptionsSubject.pipe(debounce((v) => timer(v.type)), map$2((v) => v.data)), (subscriptions) => { var _a; return (_a = this.sfuClient) === null || _a === void 0 ? void 0 : _a.updateSubscriptions(subscriptions); }));
11639
11674
  this.camera = new CameraManager(this);
11640
11675
  this.microphone = new MicrophoneManager(this);
11641
- this.state.localParticipant$.subscribe((p) => __awaiter(this, void 0, void 0, function* () {
11642
- var _l, _m;
11643
- // Mute via device manager
11644
- // If integrator doesn't use device manager, we mute using stopPublish
11645
- if (!(p === null || p === void 0 ? void 0 : p.publishedTracks.includes(TrackType.VIDEO)) &&
11646
- ((_l = this.publisher) === null || _l === void 0 ? void 0 : _l.isPublishing(TrackType.VIDEO))) {
11647
- this.logger('info', `Local participant's video track is muted remotely`);
11648
- yield this.camera.disable();
11649
- if (this.publisher.isPublishing(TrackType.VIDEO)) {
11650
- this.stopPublish(TrackType.VIDEO);
11651
- }
11652
- }
11653
- if (!(p === null || p === void 0 ? void 0 : p.publishedTracks.includes(TrackType.AUDIO)) &&
11654
- ((_m = this.publisher) === null || _m === void 0 ? void 0 : _m.isPublishing(TrackType.AUDIO))) {
11655
- this.logger('info', `Local participant's audio track is muted remotely`);
11656
- yield this.microphone.disable();
11657
- if (this.publisher.isPublishing(TrackType.AUDIO)) {
11658
- this.stopPublish(TrackType.AUDIO);
11659
- }
11660
- }
11661
- }));
11662
11676
  this.speaker = new SpeakerManager();
11663
11677
  }
11664
11678
  registerEffects() {
@@ -11712,7 +11726,7 @@ class Call {
11712
11726
  this.leaveCallHooks.add(
11713
11727
  // handles the case when the user is blocked by the call owner.
11714
11728
  createSubscription(this.state.blockedUserIds$, (blockedUserIds) => __awaiter(this, void 0, void 0, function* () {
11715
- if (!blockedUserIds)
11729
+ if (!blockedUserIds || blockedUserIds.length === 0)
11716
11730
  return;
11717
11731
  const currentUserId = this.currentUserId;
11718
11732
  if (currentUserId && blockedUserIds.includes(currentUserId)) {
@@ -11848,9 +11862,9 @@ class Call {
11848
11862
  if (this.microphone.state.status === 'enabled' &&
11849
11863
  this.microphone.state.mediaStream &&
11850
11864
  !((_b = this.publisher) === null || _b === void 0 ? void 0 : _b.isPublishing(TrackType.AUDIO))) {
11851
- this.publishAudioStream(this.microphone.state.mediaStream);
11865
+ yield this.publishAudioStream(this.microphone.state.mediaStream);
11852
11866
  }
11853
- // Start mic if backend config speicifies, and there is no local setting
11867
+ // Start mic if backend config specifies, and there is no local setting
11854
11868
  if (this.microphone.state.status === undefined &&
11855
11869
  ((_c = this.state.settings) === null || _c === void 0 ? void 0 : _c.audio.mic_default_on)) {
11856
11870
  yield this.microphone.enable();
@@ -12968,7 +12982,7 @@ class WSConnectionFallback {
12968
12982
  }
12969
12983
  }
12970
12984
 
12971
- const version = '0.3.14';
12985
+ const version = '0.3.16';
12972
12986
 
12973
12987
  const logger = getLogger(['location']);
12974
12988
  const HINT_URL = `https://hint.stream-io-video.com/`;