@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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ### [0.3.16](https://github.com/GetStream/stream-video-js/compare/client0.3.15...client0.3.16) (2023-09-13)
6
+
7
+
8
+ ### Features
9
+
10
+ * restore remote muting functionality ([#1078](https://github.com/GetStream/stream-video-js/issues/1078)) ([091d444](https://github.com/GetStream/stream-video-js/commit/091d4440a423e5f265e6fd6b1ceea32a447de93a)), closes [#1070](https://github.com/GetStream/stream-video-js/issues/1070) [#988](https://github.com/GetStream/stream-video-js/issues/988)
11
+
5
12
  ### [0.3.15](https://github.com/GetStream/stream-video-js/compare/client0.3.14...client0.3.15) (2023-09-11)
6
13
 
7
14
 
@@ -6376,10 +6376,9 @@ class Publisher {
6376
6376
  * @param dispatcher the dispatcher to use.
6377
6377
  * @param isDtxEnabled whether DTX is enabled.
6378
6378
  * @param isRedEnabled whether RED is enabled.
6379
- * @param preferredVideoCodec the preferred video codec.
6380
6379
  * @param iceRestartDelay the delay in milliseconds to wait before restarting ICE once connection goes to `disconnected` state.
6381
6380
  */
6382
- constructor({ connectionConfig, sfuClient, dispatcher, state, isDtxEnabled, isRedEnabled, preferredVideoCodec, iceRestartDelay = 2500, }) {
6381
+ constructor({ connectionConfig, sfuClient, dispatcher, state, isDtxEnabled, isRedEnabled, iceRestartDelay = 2500, }) {
6383
6382
  this.transceiverRegistry = {
6384
6383
  [TrackType.AUDIO]: undefined,
6385
6384
  [TrackType.VIDEO]: undefined,
@@ -6409,14 +6408,6 @@ class Publisher {
6409
6408
  [TrackType.SCREEN_SHARE_AUDIO]: undefined,
6410
6409
  [TrackType.UNSPECIFIED]: undefined,
6411
6410
  };
6412
- /**
6413
- * A map keeping track of track types that were published to the SFU.
6414
- * This map shouldn't be cleared when unpublishing a track, as it is used
6415
- * to determine whether a track was published before.
6416
- *
6417
- * @private
6418
- */
6419
- this.trackTypePublishHistory = new Map();
6420
6411
  this.isIceRestarting = false;
6421
6412
  this.createPeerConnection = (connectionConfig) => {
6422
6413
  const pc = new RTCPeerConnection(connectionConfig);
@@ -6511,7 +6502,6 @@ class Publisher {
6511
6502
  logger$3('debug', `Added ${TrackType[trackType]} transceiver`);
6512
6503
  this.transceiverInitOrder.push(trackType);
6513
6504
  this.transceiverRegistry[trackType] = transceiver;
6514
- this.trackTypePublishHistory.set(trackType, true);
6515
6505
  if ('setCodecPreferences' in transceiver && codecPreferences) {
6516
6506
  logger$3('info', `Setting ${TrackType[trackType]} codec preferences`, codecPreferences);
6517
6507
  transceiver.setCodecPreferences(codecPreferences);
@@ -6575,17 +6565,6 @@ class Publisher {
6575
6565
  }
6576
6566
  return false;
6577
6567
  };
6578
- /**
6579
- * Returns true if the given track type was ever published to the SFU.
6580
- * Contrary to `isPublishing`, this method returns true if a certain
6581
- * track type was published before, even if it is currently unpublished.
6582
- *
6583
- * @param trackType the track type to check.
6584
- */
6585
- this.hasEverPublished = (trackType) => {
6586
- var _a;
6587
- return (_a = this.trackTypePublishHistory.get(trackType)) !== null && _a !== void 0 ? _a : false;
6588
- };
6589
6568
  /**
6590
6569
  * Returns true if the given track type is currently live
6591
6570
  *
@@ -6899,7 +6878,6 @@ class Publisher {
6899
6878
  this.state = state;
6900
6879
  this.isDtxEnabled = isDtxEnabled;
6901
6880
  this.isRedEnabled = isRedEnabled;
6902
- this.preferredVideoCodec = preferredVideoCodec;
6903
6881
  this.iceRestartDelay = iceRestartDelay;
6904
6882
  this.unsubscribeOnIceRestart = dispatcher.on('iceRestart', (message) => __awaiter(this, void 0, void 0, function* () {
6905
6883
  if (message.eventPayload.oneofKind !== 'iceRestart')
@@ -8769,6 +8747,43 @@ const watchPinsUpdated = (state) => {
8769
8747
  };
8770
8748
  };
8771
8749
 
8750
+ /**
8751
+ * An event handler that handles soft mutes.
8752
+ *
8753
+ * @param call the call.
8754
+ */
8755
+ const handleRemoteSoftMute = (call) => {
8756
+ return call.on('trackUnpublished', (event) => __awaiter(void 0, void 0, void 0, function* () {
8757
+ var _a;
8758
+ if (event.eventPayload.oneofKind !== 'trackUnpublished')
8759
+ return;
8760
+ const { trackUnpublished: { cause, type, sessionId }, } = event.eventPayload;
8761
+ const { localParticipant } = call.state;
8762
+ if (cause === TrackUnpublishReason.MODERATION &&
8763
+ sessionId === (localParticipant === null || localParticipant === void 0 ? void 0 : localParticipant.sessionId)) {
8764
+ const logger = call.logger;
8765
+ logger('info', `Local participant's ${TrackType[type]} track is muted remotely`);
8766
+ try {
8767
+ if (type === TrackType.VIDEO) {
8768
+ yield call.camera.disable();
8769
+ }
8770
+ else if (type === TrackType.AUDIO) {
8771
+ yield call.microphone.disable();
8772
+ }
8773
+ else {
8774
+ logger('warn', 'Unsupported track type to soft mute', TrackType[type]);
8775
+ }
8776
+ if ((_a = call.publisher) === null || _a === void 0 ? void 0 : _a.isPublishing(type)) {
8777
+ yield call.stopPublish(type);
8778
+ }
8779
+ }
8780
+ catch (error) {
8781
+ logger('error', 'Failed to stop publishing', error);
8782
+ }
8783
+ }
8784
+ }));
8785
+ };
8786
+
8772
8787
  /**
8773
8788
  * An event responder which handles the `participantJoined` event.
8774
8789
  */
@@ -8918,6 +8933,7 @@ const registerEventHandlers = (call, state, dispatcher) => {
8918
8933
  watchDominantSpeakerChanged(dispatcher, state),
8919
8934
  call.on('callGrantsUpdated', watchCallGrantsUpdated(state)),
8920
8935
  call.on('pinsUpdated', watchPinsUpdated(state)),
8936
+ handleRemoteSoftMute(call),
8921
8937
  ];
8922
8938
  if (call.ringing) {
8923
8939
  // these events are only relevant when the call is ringing
@@ -9786,7 +9802,7 @@ class InputMediaDeviceManagerState {
9786
9802
  }
9787
9803
  /**
9788
9804
  * @internal
9789
- * @param stream
9805
+ * @param stream the stream to set.
9790
9806
  */
9791
9807
  setMediaStream(stream) {
9792
9808
  this.setCurrentValue(this.mediaStreamSubject, stream);
@@ -9796,7 +9812,7 @@ class InputMediaDeviceManagerState {
9796
9812
  }
9797
9813
  /**
9798
9814
  * @internal
9799
- * @param stream
9815
+ * @param deviceId the device id to set.
9800
9816
  */
9801
9817
  setDevice(deviceId) {
9802
9818
  this.setCurrentValue(this.selectedDeviceSubject, deviceId);
@@ -9913,7 +9929,7 @@ class InputMediaDeviceManager {
9913
9929
  return __awaiter(this, void 0, void 0, function* () {
9914
9930
  if (this.state.prevStatus === 'enabled' &&
9915
9931
  this.state.status === 'disabled') {
9916
- this.enable();
9932
+ yield this.enable();
9917
9933
  }
9918
9934
  });
9919
9935
  }
@@ -10308,7 +10324,7 @@ class CameraManager extends InputMediaDeviceManager {
10308
10324
  flip() {
10309
10325
  return __awaiter(this, void 0, void 0, function* () {
10310
10326
  const newDirection = this.state.direction === 'front' ? 'back' : 'front';
10311
- this.selectDirection(newDirection);
10327
+ yield this.selectDirection(newDirection);
10312
10328
  });
10313
10329
  }
10314
10330
  /**
@@ -10871,7 +10887,6 @@ class Call {
10871
10887
  connectionConfig,
10872
10888
  isDtxEnabled,
10873
10889
  isRedEnabled,
10874
- preferredVideoCodec: this.streamClient.options.preferredVideoCodec,
10875
10890
  });
10876
10891
  }
10877
10892
  if (!isMigrating) {
@@ -11655,40 +11670,6 @@ class Call {
11655
11670
  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); }));
11656
11671
  this.camera = new CameraManager(this);
11657
11672
  this.microphone = new MicrophoneManager(this);
11658
- // FIXME OL: disable soft-mutes as they are not working properly
11659
- // this.state.localParticipant$.subscribe(async (p) => {
11660
- // if (!this.publisher) return;
11661
- // // Mute via device manager
11662
- // // If integrator doesn't use device manager, we mute using stopPublish
11663
- // if (
11664
- // this.publisher.hasEverPublished(TrackType.VIDEO) &&
11665
- // this.publisher.isPublishing(TrackType.VIDEO) &&
11666
- // !p?.publishedTracks.includes(TrackType.VIDEO)
11667
- // ) {
11668
- // this.logger(
11669
- // 'info',
11670
- // `Local participant's video track is muted remotely`,
11671
- // );
11672
- // await this.camera.disable();
11673
- // if (this.publisher.isPublishing(TrackType.VIDEO)) {
11674
- // await this.stopPublish(TrackType.VIDEO);
11675
- // }
11676
- // }
11677
- // if (
11678
- // this.publisher.hasEverPublished(TrackType.AUDIO) &&
11679
- // this.publisher.isPublishing(TrackType.AUDIO) &&
11680
- // !p?.publishedTracks.includes(TrackType.AUDIO)
11681
- // ) {
11682
- // this.logger(
11683
- // 'info',
11684
- // `Local participant's audio track is muted remotely`,
11685
- // );
11686
- // await this.microphone.disable();
11687
- // if (this.publisher.isPublishing(TrackType.AUDIO)) {
11688
- // await this.stopPublish(TrackType.AUDIO);
11689
- // }
11690
- // }
11691
- // });
11692
11673
  this.speaker = new SpeakerManager();
11693
11674
  }
11694
11675
  registerEffects() {
@@ -11742,7 +11723,7 @@ class Call {
11742
11723
  this.leaveCallHooks.add(
11743
11724
  // handles the case when the user is blocked by the call owner.
11744
11725
  createSubscription(this.state.blockedUserIds$, (blockedUserIds) => __awaiter(this, void 0, void 0, function* () {
11745
- if (!blockedUserIds)
11726
+ if (!blockedUserIds || blockedUserIds.length === 0)
11746
11727
  return;
11747
11728
  const currentUserId = this.currentUserId;
11748
11729
  if (currentUserId && blockedUserIds.includes(currentUserId)) {
@@ -11878,9 +11859,9 @@ class Call {
11878
11859
  if (this.microphone.state.status === 'enabled' &&
11879
11860
  this.microphone.state.mediaStream &&
11880
11861
  !((_b = this.publisher) === null || _b === void 0 ? void 0 : _b.isPublishing(TrackType.AUDIO))) {
11881
- this.publishAudioStream(this.microphone.state.mediaStream);
11862
+ yield this.publishAudioStream(this.microphone.state.mediaStream);
11882
11863
  }
11883
- // Start mic if backend config speicifies, and there is no local setting
11864
+ // Start mic if backend config specifies, and there is no local setting
11884
11865
  if (this.microphone.state.status === undefined &&
11885
11866
  ((_c = this.state.settings) === null || _c === void 0 ? void 0 : _c.audio.mic_default_on)) {
11886
11867
  yield this.microphone.enable();
@@ -12997,7 +12978,7 @@ class WSConnectionFallback {
12997
12978
  }
12998
12979
  }
12999
12980
 
13000
- const version = '0.3.15';
12981
+ const version = '0.3.16';
13001
12982
 
13002
12983
  const logger = getLogger(['location']);
13003
12984
  const HINT_URL = `https://hint.stream-io-video.com/`;