@stream-io/video-client 0.3.6 → 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 +7 -0
- package/dist/index.browser.es.js +88 -36
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +88 -36
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +88 -36
- package/dist/index.es.js.map +1 -1
- package/dist/src/devices/CameraManager.d.ts +8 -0
- package/dist/src/devices/InputMediaDeviceManager.d.ts +8 -0
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/Call.ts +41 -24
- package/src/devices/CameraManager.ts +32 -0
- package/src/devices/InputMediaDeviceManager.ts +27 -4
- package/src/devices/__tests__/CameraManager.test.ts +53 -2
- package/src/devices/__tests__/mocks.ts +2 -0
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.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
|
+
|
|
5
12
|
### [0.3.6](https://github.com/GetStream/stream-video-js/compare/client0.3.5...client0.3.6) (2023-08-23)
|
|
6
13
|
|
|
7
14
|
|
package/dist/index.browser.es.js
CHANGED
|
@@ -9914,8 +9914,15 @@ class InputMediaDeviceManager {
|
|
|
9914
9914
|
if (this.state.status === 'enabled') {
|
|
9915
9915
|
return;
|
|
9916
9916
|
}
|
|
9917
|
-
|
|
9918
|
-
|
|
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
|
-
|
|
9933
|
-
|
|
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.
|
|
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
|
-
//
|
|
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
|
-
((
|
|
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
|
|
11336
|
-
if (this.microphone.state.status === 'enabled'
|
|
11337
|
-
|
|
11338
|
-
this.
|
|
11339
|
-
|
|
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
|
-
//
|
|
11399
|
+
// Start mic if backend config speicifies, and there is no local setting
|
|
11348
11400
|
if (this.microphone.state.status === undefined &&
|
|
11349
|
-
((
|
|
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.
|
|
12516
|
+
const version = '0.3.7';
|
|
12465
12517
|
|
|
12466
12518
|
const logger = getLogger(['location']);
|
|
12467
12519
|
const HINT_URL = `https://hint.stream-io-video.com/`;
|