@stream-io/video-client 0.3.6 → 0.3.8

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.3.8](https://github.com/GetStream/stream-video-js/compare/client0.3.7...client0.3.8) (2023-08-29)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * type definition of user object for ws auth ([#1003](https://github.com/GetStream/stream-video-js/issues/1003)) ([e0ed3d1](https://github.com/GetStream/stream-video-js/commit/e0ed3d17214e9a300d84c85a0e168ad4a7d16239))
11
+
12
+ ### [0.3.7](https://github.com/GetStream/stream-video-js/compare/client0.3.6...client0.3.7) (2023-08-24)
13
+
14
+
15
+ ### Features
16
+
17
+ * apply target resolution to video feed, sync camera/mic init ([#977](https://github.com/GetStream/stream-video-js/issues/977)) ([8ee6488](https://github.com/GetStream/stream-video-js/commit/8ee64882ebd4911445242beef5fd3148372283e3))
18
+
5
19
  ### [0.3.6](https://github.com/GetStream/stream-video-js/compare/client0.3.5...client0.3.6) (2023-08-23)
6
20
 
7
21
 
@@ -9914,8 +9914,15 @@ class InputMediaDeviceManager {
9914
9914
  if (this.state.status === 'enabled') {
9915
9915
  return;
9916
9916
  }
9917
- yield this.unmuteStream();
9918
- this.state.setStatus('enabled');
9917
+ this.enablePromise = this.unmuteStream();
9918
+ try {
9919
+ yield this.enablePromise;
9920
+ this.state.setStatus('enabled');
9921
+ }
9922
+ catch (error) {
9923
+ this.enablePromise = undefined;
9924
+ throw error;
9925
+ }
9919
9926
  });
9920
9927
  }
9921
9928
  /**
@@ -9929,8 +9936,16 @@ class InputMediaDeviceManager {
9929
9936
  if (this.state.status === 'disabled') {
9930
9937
  return;
9931
9938
  }
9932
- yield this.muteStream(this.state.disableMode === 'stop-tracks');
9933
- this.state.setStatus('disabled');
9939
+ this.disablePromise = this.muteStream(this.state.disableMode === 'stop-tracks');
9940
+ try {
9941
+ yield this.disablePromise;
9942
+ this.state.setStatus('disabled');
9943
+ this.disablePromise = undefined;
9944
+ }
9945
+ catch (error) {
9946
+ this.disablePromise = undefined;
9947
+ throw error;
9948
+ }
9934
9949
  });
9935
9950
  }
9936
9951
  /**
@@ -10026,6 +10041,10 @@ class InputMediaDeviceManager {
10026
10041
  class CameraManager extends InputMediaDeviceManager {
10027
10042
  constructor(call) {
10028
10043
  super(call, new CameraManagerState());
10044
+ this.targetResolution = {
10045
+ width: 1280,
10046
+ height: 720,
10047
+ };
10029
10048
  }
10030
10049
  /**
10031
10050
  * Select the camera direaction
@@ -10051,10 +10070,37 @@ class CameraManager extends InputMediaDeviceManager {
10051
10070
  this.selectDirection(newDirection);
10052
10071
  });
10053
10072
  }
10073
+ /**
10074
+ * @internal
10075
+ */
10076
+ selectTargetResolution(resolution) {
10077
+ var _a;
10078
+ return __awaiter(this, void 0, void 0, function* () {
10079
+ this.targetResolution.height = resolution.height;
10080
+ this.targetResolution.width = resolution.width;
10081
+ if (this.enablePromise) {
10082
+ try {
10083
+ yield this.enablePromise;
10084
+ }
10085
+ catch (error) {
10086
+ // couldn't enable device, target resolution will be applied the next time user attempts to start the device
10087
+ }
10088
+ }
10089
+ if (this.state.status === 'enabled') {
10090
+ const { width, height } = (_a = this.state
10091
+ .mediaStream.getVideoTracks()[0]) === null || _a === void 0 ? void 0 : _a.getSettings();
10092
+ if (width !== this.targetResolution.width ||
10093
+ height !== this.targetResolution.height)
10094
+ yield this.applySettingsToStream();
10095
+ }
10096
+ });
10097
+ }
10054
10098
  getDevices() {
10055
10099
  return getVideoDevices();
10056
10100
  }
10057
10101
  getStream(constraints) {
10102
+ constraints.width = this.targetResolution.width;
10103
+ constraints.height = this.targetResolution.height;
10058
10104
  // We can't set both device id and facing mode
10059
10105
  // Device id has higher priority
10060
10106
  if (!constraints.deviceId && this.state.direction) {
@@ -11290,63 +11336,69 @@ class Call {
11290
11336
  return ((_a = this.state.createdBy) === null || _a === void 0 ? void 0 : _a.id) === this.currentUserId;
11291
11337
  }
11292
11338
  initCamera() {
11293
- var _a, _b, _c;
11339
+ var _a, _b, _c, _d, _e;
11294
11340
  return __awaiter(this, void 0, void 0, function* () {
11341
+ // Wait for any in progress camera operation
11342
+ if (this.camera.enablePromise) {
11343
+ yield this.camera.enablePromise;
11344
+ }
11345
+ if (this.camera.disablePromise) {
11346
+ yield this.camera.disablePromise;
11347
+ }
11295
11348
  if (((_a = this.state.localParticipant) === null || _a === void 0 ? void 0 : _a.videoStream) ||
11296
11349
  !this.permissionsContext.hasPermission('send-video')) {
11297
11350
  return;
11298
11351
  }
11299
11352
  // Set camera direction if it's not yet set
11300
- // This will also start publishing if camera is enabled
11301
11353
  if (!this.camera.state.direction && !this.camera.state.selectedDevice) {
11302
11354
  let defaultDirection = 'front';
11303
11355
  const backendSetting = (_b = this.state.settings) === null || _b === void 0 ? void 0 : _b.video.camera_facing;
11304
11356
  if (backendSetting) {
11305
11357
  defaultDirection = backendSetting === 'front' ? 'front' : 'back';
11306
11358
  }
11307
- this.camera.selectDirection(defaultDirection);
11308
- }
11309
- else if (this.camera.state.status === 'enabled') {
11310
- // Publish already started media streams (this is the case if there is a lobby screen before join)
11311
- // Wait for media stream
11312
- this.camera.state.mediaStream$
11313
- .pipe(takeWhile((s) => s === undefined, true))
11314
- .subscribe((stream) => {
11315
- var _a;
11316
- if (!((_a = this.state.localParticipant) === null || _a === void 0 ? void 0 : _a.videoStream)) {
11317
- this.publishVideoStream(stream);
11318
- }
11319
- });
11359
+ this.camera.state.setDirection(defaultDirection);
11320
11360
  }
11321
- // Apply backend config (this is the case if there is no lobby screen before join)
11361
+ // Set target resolution
11362
+ const targetResolution = (_c = this.state.settings) === null || _c === void 0 ? void 0 : _c.video.target_resolution;
11363
+ if (targetResolution) {
11364
+ yield this.camera.selectTargetResolution(targetResolution);
11365
+ }
11366
+ // Publish already that was set before we joined
11367
+ if (this.camera.state.status === 'enabled' &&
11368
+ this.camera.state.mediaStream &&
11369
+ !((_d = this.publisher) === null || _d === void 0 ? void 0 : _d.isPublishing(TrackType.VIDEO))) {
11370
+ yield this.publishVideoStream(this.camera.state.mediaStream);
11371
+ }
11372
+ // Start camera if backend config speicifies, and there is no local setting
11322
11373
  if (this.camera.state.status === undefined &&
11323
- ((_c = this.state.settings) === null || _c === void 0 ? void 0 : _c.video.camera_default_on)) {
11374
+ ((_e = this.state.settings) === null || _e === void 0 ? void 0 : _e.video.camera_default_on)) {
11324
11375
  yield this.camera.enable();
11325
11376
  }
11326
11377
  });
11327
11378
  }
11328
11379
  initMic() {
11329
- var _a, _b;
11380
+ var _a, _b, _c;
11330
11381
  return __awaiter(this, void 0, void 0, function* () {
11382
+ // Wait for any in progress mic operation
11383
+ if (this.microphone.enablePromise) {
11384
+ yield this.microphone.enablePromise;
11385
+ }
11386
+ if (this.microphone.disablePromise) {
11387
+ yield this.microphone.disablePromise;
11388
+ }
11331
11389
  if (((_a = this.state.localParticipant) === null || _a === void 0 ? void 0 : _a.audioStream) ||
11332
11390
  !this.permissionsContext.hasPermission('send-audio')) {
11333
11391
  return;
11334
11392
  }
11335
- // Publish already started media streams (this is the case if there is a lobby screen before join)
11336
- if (this.microphone.state.status === 'enabled') {
11337
- // Wait for media stream
11338
- this.microphone.state.mediaStream$
11339
- .pipe(takeWhile((s) => s === undefined, true))
11340
- .subscribe((stream) => {
11341
- var _a;
11342
- if (!((_a = this.state.localParticipant) === null || _a === void 0 ? void 0 : _a.audioStream)) {
11343
- this.publishAudioStream(stream);
11344
- }
11345
- });
11393
+ // Publish media stream that was set before we joined
11394
+ if (this.microphone.state.status === 'enabled' &&
11395
+ this.microphone.state.mediaStream &&
11396
+ !((_b = this.publisher) === null || _b === void 0 ? void 0 : _b.isPublishing(TrackType.AUDIO))) {
11397
+ this.publishAudioStream(this.microphone.state.mediaStream);
11346
11398
  }
11347
- // Apply backend config (this is the case if there is no lobby screen before join)
11399
+ // Start mic if backend config speicifies, and there is no local setting
11348
11400
  if (this.microphone.state.status === undefined &&
11349
- ((_b = this.state.settings) === null || _b === void 0 ? void 0 : _b.audio.mic_default_on)) {
11401
+ ((_c = this.state.settings) === null || _c === void 0 ? void 0 : _c.audio.mic_default_on)) {
11350
11402
  yield this.microphone.enable();
11351
11403
  }
11352
11404
  });
@@ -12461,7 +12513,7 @@ class WSConnectionFallback {
12461
12513
  }
12462
12514
  }
12463
12515
 
12464
- const version = '0.3.6';
12516
+ const version = '0.3.8';
12465
12517
 
12466
12518
  const logger = getLogger(['location']);
12467
12519
  const HINT_URL = `https://hint.stream-io-video.com/`;