@stream-io/video-client 0.3.5 → 0.3.7

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.7](https://github.com/GetStream/stream-video-js/compare/client0.3.6...client0.3.7) (2023-08-24)
6
+
7
+
8
+ ### Features
9
+
10
+ * 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))
11
+
12
+ ### [0.3.6](https://github.com/GetStream/stream-video-js/compare/client0.3.5...client0.3.6) (2023-08-23)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * device api small fixes ([#970](https://github.com/GetStream/stream-video-js/issues/970)) ([15b09fd](https://github.com/GetStream/stream-video-js/commit/15b09fd5e1d25046f8e2cbaa951f551631a91779))
18
+
5
19
  ### [0.3.5](https://github.com/GetStream/stream-video-js/compare/client0.3.4...client0.3.5) (2023-08-22)
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
  /**
@@ -9925,12 +9932,20 @@ class InputMediaDeviceManager {
9925
9932
  */
9926
9933
  disable() {
9927
9934
  return __awaiter(this, void 0, void 0, function* () {
9935
+ this.state.prevStatus = this.state.status;
9928
9936
  if (this.state.status === 'disabled') {
9929
9937
  return;
9930
9938
  }
9931
- this.state.prevStatus = this.state.status;
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) {
@@ -10552,8 +10598,13 @@ class Call {
10552
10598
  this.state.setCallingState(CallingState.JOINED);
10553
10599
  // React uses a different device management for now
10554
10600
  if (((_h = getSdkInfo()) === null || _h === void 0 ? void 0 : _h.type) !== SdkType.REACT) {
10555
- this.initCamera();
10556
- this.initMic();
10601
+ try {
10602
+ yield this.initCamera();
10603
+ yield this.initMic();
10604
+ }
10605
+ catch (error) {
10606
+ this.logger('warn', 'Camera and/or mic init failed during join call');
10607
+ }
10557
10608
  }
10558
10609
  // 3. once we have the "joinResponse", and possibly reconciled the local state
10559
10610
  // we schedule a fast subscription update for all remote participants
@@ -11285,62 +11336,72 @@ class Call {
11285
11336
  return ((_a = this.state.createdBy) === null || _a === void 0 ? void 0 : _a.id) === this.currentUserId;
11286
11337
  }
11287
11338
  initCamera() {
11288
- var _a, _b, _c;
11289
- if (((_a = this.state.localParticipant) === null || _a === void 0 ? void 0 : _a.videoStream) ||
11290
- !this.permissionsContext.hasPermission('send-video')) {
11291
- return;
11292
- }
11293
- // Set camera direction if it's not yet set
11294
- // This will also start publishing if camera is enabled
11295
- if (!this.camera.state.direction && !this.camera.state.selectedDevice) {
11296
- let defaultDirection = 'front';
11297
- const backendSetting = (_b = this.state.settings) === null || _b === void 0 ? void 0 : _b.video.camera_facing;
11298
- if (backendSetting) {
11299
- defaultDirection = backendSetting === 'front' ? 'front' : 'back';
11300
- }
11301
- this.camera.selectDirection(defaultDirection);
11302
- }
11303
- else if (this.camera.state.status === 'enabled') {
11304
- // Publish already started media streams (this is the case if there is a lobby screen before join)
11305
- // Wait for media stream
11306
- this.camera.state.mediaStream$
11307
- .pipe(takeWhile((s) => s === undefined, true))
11308
- .subscribe((stream) => {
11309
- var _a;
11310
- if (!((_a = this.state.localParticipant) === null || _a === void 0 ? void 0 : _a.videoStream)) {
11311
- this.publishVideoStream(stream);
11339
+ var _a, _b, _c, _d, _e;
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
+ }
11348
+ if (((_a = this.state.localParticipant) === null || _a === void 0 ? void 0 : _a.videoStream) ||
11349
+ !this.permissionsContext.hasPermission('send-video')) {
11350
+ return;
11351
+ }
11352
+ // Set camera direction if it's not yet set
11353
+ if (!this.camera.state.direction && !this.camera.state.selectedDevice) {
11354
+ let defaultDirection = 'front';
11355
+ const backendSetting = (_b = this.state.settings) === null || _b === void 0 ? void 0 : _b.video.camera_facing;
11356
+ if (backendSetting) {
11357
+ defaultDirection = backendSetting === 'front' ? 'front' : 'back';
11312
11358
  }
11313
- });
11314
- }
11315
- // Apply backend config (this is the case if there is no lobby screen before join)
11316
- if (this.camera.state.status === undefined &&
11317
- ((_c = this.state.settings) === null || _c === void 0 ? void 0 : _c.video.camera_default_on)) {
11318
- void this.camera.enable();
11319
- }
11359
+ this.camera.state.setDirection(defaultDirection);
11360
+ }
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
11373
+ if (this.camera.state.status === undefined &&
11374
+ ((_e = this.state.settings) === null || _e === void 0 ? void 0 : _e.video.camera_default_on)) {
11375
+ yield this.camera.enable();
11376
+ }
11377
+ });
11320
11378
  }
11321
11379
  initMic() {
11322
- var _a, _b;
11323
- if (((_a = this.state.localParticipant) === null || _a === void 0 ? void 0 : _a.audioStream) ||
11324
- !this.permissionsContext.hasPermission('send-audio')) {
11325
- return;
11326
- }
11327
- // Publish already started media streams (this is the case if there is a lobby screen before join)
11328
- if (this.microphone.state.status === 'enabled') {
11329
- // Wait for media stream
11330
- this.microphone.state.mediaStream$
11331
- .pipe(takeWhile((s) => s === undefined, true))
11332
- .subscribe((stream) => {
11333
- var _a;
11334
- if (!((_a = this.state.localParticipant) === null || _a === void 0 ? void 0 : _a.audioStream)) {
11335
- this.publishAudioStream(stream);
11336
- }
11337
- });
11338
- }
11339
- // Apply backend config (this is the case if there is no lobby screen before join)
11340
- if (this.microphone.state.status === undefined &&
11341
- ((_b = this.state.settings) === null || _b === void 0 ? void 0 : _b.audio.mic_default_on)) {
11342
- void this.microphone.enable();
11343
- }
11380
+ var _a, _b, _c;
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
+ }
11389
+ if (((_a = this.state.localParticipant) === null || _a === void 0 ? void 0 : _a.audioStream) ||
11390
+ !this.permissionsContext.hasPermission('send-audio')) {
11391
+ return;
11392
+ }
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);
11398
+ }
11399
+ // Start mic if backend config speicifies, and there is no local setting
11400
+ if (this.microphone.state.status === undefined &&
11401
+ ((_c = this.state.settings) === null || _c === void 0 ? void 0 : _c.audio.mic_default_on)) {
11402
+ yield this.microphone.enable();
11403
+ }
11404
+ });
11344
11405
  }
11345
11406
  }
11346
11407
 
@@ -12452,7 +12513,7 @@ class WSConnectionFallback {
12452
12513
  }
12453
12514
  }
12454
12515
 
12455
- const version = '0.3.5';
12516
+ const version = '0.3.7';
12456
12517
 
12457
12518
  const logger = getLogger(['location']);
12458
12519
  const HINT_URL = `https://hint.stream-io-video.com/`;