@stream-io/video-client 0.3.15 → 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,
@@ -6412,14 +6411,6 @@ class Publisher {
6412
6411
  [TrackType.SCREEN_SHARE_AUDIO]: undefined,
6413
6412
  [TrackType.UNSPECIFIED]: undefined,
6414
6413
  };
6415
- /**
6416
- * A map keeping track of track types that were published to the SFU.
6417
- * This map shouldn't be cleared when unpublishing a track, as it is used
6418
- * to determine whether a track was published before.
6419
- *
6420
- * @private
6421
- */
6422
- this.trackTypePublishHistory = new Map();
6423
6414
  this.isIceRestarting = false;
6424
6415
  this.createPeerConnection = (connectionConfig) => {
6425
6416
  const pc = new RTCPeerConnection(connectionConfig);
@@ -6514,7 +6505,6 @@ class Publisher {
6514
6505
  logger$3('debug', `Added ${TrackType[trackType]} transceiver`);
6515
6506
  this.transceiverInitOrder.push(trackType);
6516
6507
  this.transceiverRegistry[trackType] = transceiver;
6517
- this.trackTypePublishHistory.set(trackType, true);
6518
6508
  if ('setCodecPreferences' in transceiver && codecPreferences) {
6519
6509
  logger$3('info', `Setting ${TrackType[trackType]} codec preferences`, codecPreferences);
6520
6510
  transceiver.setCodecPreferences(codecPreferences);
@@ -6578,17 +6568,6 @@ class Publisher {
6578
6568
  }
6579
6569
  return false;
6580
6570
  };
6581
- /**
6582
- * Returns true if the given track type was ever published to the SFU.
6583
- * Contrary to `isPublishing`, this method returns true if a certain
6584
- * track type was published before, even if it is currently unpublished.
6585
- *
6586
- * @param trackType the track type to check.
6587
- */
6588
- this.hasEverPublished = (trackType) => {
6589
- var _a;
6590
- return (_a = this.trackTypePublishHistory.get(trackType)) !== null && _a !== void 0 ? _a : false;
6591
- };
6592
6571
  /**
6593
6572
  * Returns true if the given track type is currently live
6594
6573
  *
@@ -6902,7 +6881,6 @@ class Publisher {
6902
6881
  this.state = state;
6903
6882
  this.isDtxEnabled = isDtxEnabled;
6904
6883
  this.isRedEnabled = isRedEnabled;
6905
- this.preferredVideoCodec = preferredVideoCodec;
6906
6884
  this.iceRestartDelay = iceRestartDelay;
6907
6885
  this.unsubscribeOnIceRestart = dispatcher.on('iceRestart', (message) => __awaiter(this, void 0, void 0, function* () {
6908
6886
  if (message.eventPayload.oneofKind !== 'iceRestart')
@@ -8772,6 +8750,43 @@ const watchPinsUpdated = (state) => {
8772
8750
  };
8773
8751
  };
8774
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
+
8775
8790
  /**
8776
8791
  * An event responder which handles the `participantJoined` event.
8777
8792
  */
@@ -8921,6 +8936,7 @@ const registerEventHandlers = (call, state, dispatcher) => {
8921
8936
  watchDominantSpeakerChanged(dispatcher, state),
8922
8937
  call.on('callGrantsUpdated', watchCallGrantsUpdated(state)),
8923
8938
  call.on('pinsUpdated', watchPinsUpdated(state)),
8939
+ handleRemoteSoftMute(call),
8924
8940
  ];
8925
8941
  if (call.ringing) {
8926
8942
  // these events are only relevant when the call is ringing
@@ -9789,7 +9805,7 @@ class InputMediaDeviceManagerState {
9789
9805
  }
9790
9806
  /**
9791
9807
  * @internal
9792
- * @param stream
9808
+ * @param stream the stream to set.
9793
9809
  */
9794
9810
  setMediaStream(stream) {
9795
9811
  this.setCurrentValue(this.mediaStreamSubject, stream);
@@ -9799,7 +9815,7 @@ class InputMediaDeviceManagerState {
9799
9815
  }
9800
9816
  /**
9801
9817
  * @internal
9802
- * @param stream
9818
+ * @param deviceId the device id to set.
9803
9819
  */
9804
9820
  setDevice(deviceId) {
9805
9821
  this.setCurrentValue(this.selectedDeviceSubject, deviceId);
@@ -9916,7 +9932,7 @@ class InputMediaDeviceManager {
9916
9932
  return __awaiter(this, void 0, void 0, function* () {
9917
9933
  if (this.state.prevStatus === 'enabled' &&
9918
9934
  this.state.status === 'disabled') {
9919
- this.enable();
9935
+ yield this.enable();
9920
9936
  }
9921
9937
  });
9922
9938
  }
@@ -10311,7 +10327,7 @@ class CameraManager extends InputMediaDeviceManager {
10311
10327
  flip() {
10312
10328
  return __awaiter(this, void 0, void 0, function* () {
10313
10329
  const newDirection = this.state.direction === 'front' ? 'back' : 'front';
10314
- this.selectDirection(newDirection);
10330
+ yield this.selectDirection(newDirection);
10315
10331
  });
10316
10332
  }
10317
10333
  /**
@@ -10874,7 +10890,6 @@ class Call {
10874
10890
  connectionConfig,
10875
10891
  isDtxEnabled,
10876
10892
  isRedEnabled,
10877
- preferredVideoCodec: this.streamClient.options.preferredVideoCodec,
10878
10893
  });
10879
10894
  }
10880
10895
  if (!isMigrating) {
@@ -11658,40 +11673,6 @@ class Call {
11658
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); }));
11659
11674
  this.camera = new CameraManager(this);
11660
11675
  this.microphone = new MicrophoneManager(this);
11661
- // FIXME OL: disable soft-mutes as they are not working properly
11662
- // this.state.localParticipant$.subscribe(async (p) => {
11663
- // if (!this.publisher) return;
11664
- // // Mute via device manager
11665
- // // If integrator doesn't use device manager, we mute using stopPublish
11666
- // if (
11667
- // this.publisher.hasEverPublished(TrackType.VIDEO) &&
11668
- // this.publisher.isPublishing(TrackType.VIDEO) &&
11669
- // !p?.publishedTracks.includes(TrackType.VIDEO)
11670
- // ) {
11671
- // this.logger(
11672
- // 'info',
11673
- // `Local participant's video track is muted remotely`,
11674
- // );
11675
- // await this.camera.disable();
11676
- // if (this.publisher.isPublishing(TrackType.VIDEO)) {
11677
- // await this.stopPublish(TrackType.VIDEO);
11678
- // }
11679
- // }
11680
- // if (
11681
- // this.publisher.hasEverPublished(TrackType.AUDIO) &&
11682
- // this.publisher.isPublishing(TrackType.AUDIO) &&
11683
- // !p?.publishedTracks.includes(TrackType.AUDIO)
11684
- // ) {
11685
- // this.logger(
11686
- // 'info',
11687
- // `Local participant's audio track is muted remotely`,
11688
- // );
11689
- // await this.microphone.disable();
11690
- // if (this.publisher.isPublishing(TrackType.AUDIO)) {
11691
- // await this.stopPublish(TrackType.AUDIO);
11692
- // }
11693
- // }
11694
- // });
11695
11676
  this.speaker = new SpeakerManager();
11696
11677
  }
11697
11678
  registerEffects() {
@@ -11745,7 +11726,7 @@ class Call {
11745
11726
  this.leaveCallHooks.add(
11746
11727
  // handles the case when the user is blocked by the call owner.
11747
11728
  createSubscription(this.state.blockedUserIds$, (blockedUserIds) => __awaiter(this, void 0, void 0, function* () {
11748
- if (!blockedUserIds)
11729
+ if (!blockedUserIds || blockedUserIds.length === 0)
11749
11730
  return;
11750
11731
  const currentUserId = this.currentUserId;
11751
11732
  if (currentUserId && blockedUserIds.includes(currentUserId)) {
@@ -11881,9 +11862,9 @@ class Call {
11881
11862
  if (this.microphone.state.status === 'enabled' &&
11882
11863
  this.microphone.state.mediaStream &&
11883
11864
  !((_b = this.publisher) === null || _b === void 0 ? void 0 : _b.isPublishing(TrackType.AUDIO))) {
11884
- this.publishAudioStream(this.microphone.state.mediaStream);
11865
+ yield this.publishAudioStream(this.microphone.state.mediaStream);
11885
11866
  }
11886
- // 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
11887
11868
  if (this.microphone.state.status === undefined &&
11888
11869
  ((_c = this.state.settings) === null || _c === void 0 ? void 0 : _c.audio.mic_default_on)) {
11889
11870
  yield this.microphone.enable();
@@ -13001,7 +12982,7 @@ class WSConnectionFallback {
13001
12982
  }
13002
12983
  }
13003
12984
 
13004
- const version = '0.3.15';
12985
+ const version = '0.3.16';
13005
12986
 
13006
12987
  const logger = getLogger(['location']);
13007
12988
  const HINT_URL = `https://hint.stream-io-video.com/`;