@stream-io/video-client 0.4.0 → 0.4.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/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ### [0.4.2](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-0.4.1...@stream-io/video-client-0.4.2) (2023-11-01)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * respect server-side settings in the lobby ([#1175](https://github.com/GetStream/stream-video-js/issues/1175)) ([b722a0a](https://github.com/GetStream/stream-video-js/commit/b722a0a4f8fd4e4e56787db3d9a56e45ee195974))
11
+
12
+ ### [0.4.1](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-0.4.0...@stream-io/video-client-0.4.1) (2023-10-30)
13
+
14
+
15
+ ### Features
16
+
17
+ * Apply device config settings when call state becomes available ([#1167](https://github.com/GetStream/stream-video-js/issues/1167)) ([38e8ba4](https://github.com/GetStream/stream-video-js/commit/38e8ba459b60d9705af96ad7b9a2a7fa1827ad1e))
18
+
5
19
  ## [0.4.0](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-0.3.36...@stream-io/video-client-0.4.0) (2023-10-27)
6
20
 
7
21
 
@@ -10262,13 +10262,13 @@ class InputMediaDeviceManager {
10262
10262
  * Starts stream.
10263
10263
  */
10264
10264
  async enable() {
10265
- if (this.state.status === 'enabled') {
10265
+ if (this.state.status === 'enabled')
10266
10266
  return;
10267
- }
10268
10267
  this.enablePromise = this.unmuteStream();
10269
10268
  try {
10270
10269
  await this.enablePromise;
10271
10270
  this.state.setStatus('enabled');
10271
+ this.enablePromise = undefined;
10272
10272
  }
10273
10273
  catch (error) {
10274
10274
  this.enablePromise = undefined;
@@ -10280,10 +10280,10 @@ class InputMediaDeviceManager {
10280
10280
  */
10281
10281
  async disable() {
10282
10282
  this.state.prevStatus = this.state.status;
10283
- if (this.state.status === 'disabled') {
10283
+ if (this.state.status === 'disabled')
10284
10284
  return;
10285
- }
10286
- this.disablePromise = this.muteStream(this.state.disableMode === 'stop-tracks');
10285
+ const stopTracks = this.state.disableMode === 'stop-tracks';
10286
+ this.disablePromise = this.muteStream(stopTracks);
10287
10287
  try {
10288
10288
  await this.disablePromise;
10289
10289
  this.state.setStatus('disabled');
@@ -10320,7 +10320,7 @@ class InputMediaDeviceManager {
10320
10320
  *
10321
10321
  * @param constraints the constraints to set.
10322
10322
  */
10323
- async setDefaultConstraints(constraints) {
10323
+ setDefaultConstraints(constraints) {
10324
10324
  this.state.setDefaultConstraints(constraints);
10325
10325
  }
10326
10326
  /**
@@ -10350,25 +10350,23 @@ class InputMediaDeviceManager {
10350
10350
  return this.state.mediaStream?.getTracks() ?? [];
10351
10351
  }
10352
10352
  async muteStream(stopTracks = true) {
10353
- if (!this.state.mediaStream) {
10353
+ if (!this.state.mediaStream)
10354
10354
  return;
10355
- }
10356
10355
  this.logger('debug', `${stopTracks ? 'Stopping' : 'Disabling'} stream`);
10357
10356
  if (this.call.state.callingState === CallingState.JOINED) {
10358
10357
  await this.stopPublishStream(stopTracks);
10359
10358
  }
10360
10359
  this.muteLocalStream(stopTracks);
10361
- this.getTracks().forEach((track) => {
10362
- if (track.readyState === 'ended') {
10360
+ const allEnded = this.getTracks().every((t) => t.readyState === 'ended');
10361
+ if (allEnded) {
10362
+ if (this.state.mediaStream &&
10363
10363
  // @ts-expect-error release() is present in react-native-webrtc
10364
- // and must be called to dispose the stream
10365
- if (typeof this.state.mediaStream.release === 'function') {
10366
- // @ts-expect-error
10367
- this.state.mediaStream.release();
10368
- }
10369
- this.state.setMediaStream(undefined);
10364
+ typeof this.state.mediaStream.release === 'function') {
10365
+ // @ts-expect-error called to dispose the stream in RN
10366
+ this.state.mediaStream.release();
10370
10367
  }
10371
- });
10368
+ this.state.setMediaStream(undefined);
10369
+ }
10372
10370
  }
10373
10371
  muteTracks() {
10374
10372
  this.getTracks().forEach((track) => {
@@ -11114,6 +11112,7 @@ class Call {
11114
11112
  this.watching = true;
11115
11113
  this.clientStore.registerCall(this);
11116
11114
  }
11115
+ this.applyDeviceConfig();
11117
11116
  return response;
11118
11117
  };
11119
11118
  /**
@@ -11133,6 +11132,7 @@ class Call {
11133
11132
  this.watching = true;
11134
11133
  this.clientStore.registerCall(this);
11135
11134
  }
11135
+ this.applyDeviceConfig();
11136
11136
  return response;
11137
11137
  };
11138
11138
  /**
@@ -11465,8 +11465,8 @@ class Call {
11465
11465
  this.reconnectAttempts = 0; // reset the reconnect attempts counter
11466
11466
  this.state.setCallingState(CallingState.JOINED);
11467
11467
  try {
11468
- await this.initCamera();
11469
- await this.initMic();
11468
+ await this.initCamera({ setStatus: true });
11469
+ await this.initMic({ setStatus: true });
11470
11470
  }
11471
11471
  catch (error) {
11472
11472
  this.logger('warn', 'Camera and/or mic init failed during join call');
@@ -12042,6 +12042,10 @@ class Call {
12042
12042
  this.sendCustomEvent = async (payload) => {
12043
12043
  return this.streamClient.post(`${this.streamClientBasePath}/event`, { custom: payload });
12044
12044
  };
12045
+ this.applyDeviceConfig = () => {
12046
+ this.initCamera({ setStatus: false });
12047
+ this.initMic({ setStatus: false });
12048
+ };
12045
12049
  /**
12046
12050
  * Will begin tracking the given element for visibility changes within the
12047
12051
  * configured viewport element (`call.setViewport`).
@@ -12287,7 +12291,7 @@ class Call {
12287
12291
  get isCreatedByMe() {
12288
12292
  return this.state.createdBy?.id === this.currentUserId;
12289
12293
  }
12290
- async initCamera() {
12294
+ async initCamera(options) {
12291
12295
  // Wait for any in progress camera operation
12292
12296
  if (this.camera.enablePromise) {
12293
12297
  await this.camera.enablePromise;
@@ -12313,19 +12317,21 @@ class Call {
12313
12317
  if (targetResolution) {
12314
12318
  await this.camera.selectTargetResolution(targetResolution);
12315
12319
  }
12316
- // Publish already that was set before we joined
12317
- if (this.camera.state.status === 'enabled' &&
12318
- this.camera.state.mediaStream &&
12319
- !this.publisher?.isPublishing(TrackType.VIDEO)) {
12320
- await this.publishVideoStream(this.camera.state.mediaStream);
12321
- }
12322
- // Start camera if backend config speicifies, and there is no local setting
12323
- if (this.camera.state.status === undefined &&
12324
- this.state.settings?.video.camera_default_on) {
12325
- await this.camera.enable();
12320
+ if (options.setStatus) {
12321
+ // Publish already that was set before we joined
12322
+ if (this.camera.state.status === 'enabled' &&
12323
+ this.camera.state.mediaStream &&
12324
+ !this.publisher?.isPublishing(TrackType.VIDEO)) {
12325
+ await this.publishVideoStream(this.camera.state.mediaStream);
12326
+ }
12327
+ // Start camera if backend config speicifies, and there is no local setting
12328
+ if (this.camera.state.status === undefined &&
12329
+ this.state.settings?.video.camera_default_on) {
12330
+ await this.camera.enable();
12331
+ }
12326
12332
  }
12327
12333
  }
12328
- async initMic() {
12334
+ async initMic(options) {
12329
12335
  // Wait for any in progress mic operation
12330
12336
  if (this.microphone.enablePromise) {
12331
12337
  await this.microphone.enablePromise;
@@ -12337,16 +12343,18 @@ class Call {
12337
12343
  !this.permissionsContext.hasPermission('send-audio')) {
12338
12344
  return;
12339
12345
  }
12340
- // Publish media stream that was set before we joined
12341
- if (this.microphone.state.status === 'enabled' &&
12342
- this.microphone.state.mediaStream &&
12343
- !this.publisher?.isPublishing(TrackType.AUDIO)) {
12344
- await this.publishAudioStream(this.microphone.state.mediaStream);
12345
- }
12346
- // Start mic if backend config specifies, and there is no local setting
12347
- if (this.microphone.state.status === undefined &&
12348
- this.state.settings?.audio.mic_default_on) {
12349
- await this.microphone.enable();
12346
+ if (options.setStatus) {
12347
+ // Publish media stream that was set before we joined
12348
+ if (this.microphone.state.status === 'enabled' &&
12349
+ this.microphone.state.mediaStream &&
12350
+ !this.publisher?.isPublishing(TrackType.AUDIO)) {
12351
+ await this.publishAudioStream(this.microphone.state.mediaStream);
12352
+ }
12353
+ // Start mic if backend config specifies, and there is no local setting
12354
+ if (this.microphone.state.status === undefined &&
12355
+ this.state.settings?.audio.mic_default_on) {
12356
+ await this.microphone.enable();
12357
+ }
12350
12358
  }
12351
12359
  }
12352
12360
  }
@@ -13931,7 +13939,7 @@ class StreamClient {
13931
13939
  });
13932
13940
  };
13933
13941
  this.getUserAgent = () => {
13934
- const version = "0.4.0" ;
13942
+ const version = "0.4.2" ;
13935
13943
  return (this.userAgent ||
13936
13944
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
13937
13945
  };
@@ -14179,6 +14187,7 @@ class StreamVideoClient {
14179
14187
  clientStore: this.writeableStateStore,
14180
14188
  });
14181
14189
  call.state.updateFromCallResponse(c.call);
14190
+ call.applyDeviceConfig();
14182
14191
  if (data.watch) {
14183
14192
  this.writeableStateStore.registerCall(call);
14184
14193
  }