@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 +14 -0
- package/dist/index.browser.es.js +122 -61
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +122 -61
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +122 -61
- 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 +51 -30
- package/src/devices/CameraManager.ts +32 -0
- package/src/devices/InputMediaDeviceManager.ts +28 -5
- package/src/devices/__tests__/CameraManager.test.ts +53 -2
- package/src/devices/__tests__/InputMediaDeviceManager.test.ts +17 -0
- package/src/devices/__tests__/mocks.ts +2 -0
package/dist/index.es.js
CHANGED
|
@@ -9917,8 +9917,15 @@ class InputMediaDeviceManager {
|
|
|
9917
9917
|
if (this.state.status === 'enabled') {
|
|
9918
9918
|
return;
|
|
9919
9919
|
}
|
|
9920
|
-
|
|
9921
|
-
|
|
9920
|
+
this.enablePromise = this.unmuteStream();
|
|
9921
|
+
try {
|
|
9922
|
+
yield this.enablePromise;
|
|
9923
|
+
this.state.setStatus('enabled');
|
|
9924
|
+
}
|
|
9925
|
+
catch (error) {
|
|
9926
|
+
this.enablePromise = undefined;
|
|
9927
|
+
throw error;
|
|
9928
|
+
}
|
|
9922
9929
|
});
|
|
9923
9930
|
}
|
|
9924
9931
|
/**
|
|
@@ -9928,12 +9935,20 @@ class InputMediaDeviceManager {
|
|
|
9928
9935
|
*/
|
|
9929
9936
|
disable() {
|
|
9930
9937
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9938
|
+
this.state.prevStatus = this.state.status;
|
|
9931
9939
|
if (this.state.status === 'disabled') {
|
|
9932
9940
|
return;
|
|
9933
9941
|
}
|
|
9934
|
-
this.
|
|
9935
|
-
|
|
9936
|
-
|
|
9942
|
+
this.disablePromise = this.muteStream(this.state.disableMode === 'stop-tracks');
|
|
9943
|
+
try {
|
|
9944
|
+
yield this.disablePromise;
|
|
9945
|
+
this.state.setStatus('disabled');
|
|
9946
|
+
this.disablePromise = undefined;
|
|
9947
|
+
}
|
|
9948
|
+
catch (error) {
|
|
9949
|
+
this.disablePromise = undefined;
|
|
9950
|
+
throw error;
|
|
9951
|
+
}
|
|
9937
9952
|
});
|
|
9938
9953
|
}
|
|
9939
9954
|
/**
|
|
@@ -10029,6 +10044,10 @@ class InputMediaDeviceManager {
|
|
|
10029
10044
|
class CameraManager extends InputMediaDeviceManager {
|
|
10030
10045
|
constructor(call) {
|
|
10031
10046
|
super(call, new CameraManagerState());
|
|
10047
|
+
this.targetResolution = {
|
|
10048
|
+
width: 1280,
|
|
10049
|
+
height: 720,
|
|
10050
|
+
};
|
|
10032
10051
|
}
|
|
10033
10052
|
/**
|
|
10034
10053
|
* Select the camera direaction
|
|
@@ -10054,10 +10073,37 @@ class CameraManager extends InputMediaDeviceManager {
|
|
|
10054
10073
|
this.selectDirection(newDirection);
|
|
10055
10074
|
});
|
|
10056
10075
|
}
|
|
10076
|
+
/**
|
|
10077
|
+
* @internal
|
|
10078
|
+
*/
|
|
10079
|
+
selectTargetResolution(resolution) {
|
|
10080
|
+
var _a;
|
|
10081
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10082
|
+
this.targetResolution.height = resolution.height;
|
|
10083
|
+
this.targetResolution.width = resolution.width;
|
|
10084
|
+
if (this.enablePromise) {
|
|
10085
|
+
try {
|
|
10086
|
+
yield this.enablePromise;
|
|
10087
|
+
}
|
|
10088
|
+
catch (error) {
|
|
10089
|
+
// couldn't enable device, target resolution will be applied the next time user attempts to start the device
|
|
10090
|
+
}
|
|
10091
|
+
}
|
|
10092
|
+
if (this.state.status === 'enabled') {
|
|
10093
|
+
const { width, height } = (_a = this.state
|
|
10094
|
+
.mediaStream.getVideoTracks()[0]) === null || _a === void 0 ? void 0 : _a.getSettings();
|
|
10095
|
+
if (width !== this.targetResolution.width ||
|
|
10096
|
+
height !== this.targetResolution.height)
|
|
10097
|
+
yield this.applySettingsToStream();
|
|
10098
|
+
}
|
|
10099
|
+
});
|
|
10100
|
+
}
|
|
10057
10101
|
getDevices() {
|
|
10058
10102
|
return getVideoDevices();
|
|
10059
10103
|
}
|
|
10060
10104
|
getStream(constraints) {
|
|
10105
|
+
constraints.width = this.targetResolution.width;
|
|
10106
|
+
constraints.height = this.targetResolution.height;
|
|
10061
10107
|
// We can't set both device id and facing mode
|
|
10062
10108
|
// Device id has higher priority
|
|
10063
10109
|
if (!constraints.deviceId && this.state.direction) {
|
|
@@ -10555,8 +10601,13 @@ class Call {
|
|
|
10555
10601
|
this.state.setCallingState(CallingState.JOINED);
|
|
10556
10602
|
// React uses a different device management for now
|
|
10557
10603
|
if (((_h = getSdkInfo()) === null || _h === void 0 ? void 0 : _h.type) !== SdkType.REACT) {
|
|
10558
|
-
|
|
10559
|
-
|
|
10604
|
+
try {
|
|
10605
|
+
yield this.initCamera();
|
|
10606
|
+
yield this.initMic();
|
|
10607
|
+
}
|
|
10608
|
+
catch (error) {
|
|
10609
|
+
this.logger('warn', 'Camera and/or mic init failed during join call');
|
|
10610
|
+
}
|
|
10560
10611
|
}
|
|
10561
10612
|
// 3. once we have the "joinResponse", and possibly reconciled the local state
|
|
10562
10613
|
// we schedule a fast subscription update for all remote participants
|
|
@@ -11288,62 +11339,72 @@ class Call {
|
|
|
11288
11339
|
return ((_a = this.state.createdBy) === null || _a === void 0 ? void 0 : _a.id) === this.currentUserId;
|
|
11289
11340
|
}
|
|
11290
11341
|
initCamera() {
|
|
11291
|
-
var _a, _b, _c;
|
|
11292
|
-
|
|
11293
|
-
|
|
11294
|
-
|
|
11295
|
-
|
|
11296
|
-
|
|
11297
|
-
|
|
11298
|
-
|
|
11299
|
-
|
|
11300
|
-
|
|
11301
|
-
|
|
11302
|
-
|
|
11303
|
-
}
|
|
11304
|
-
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
|
|
11309
|
-
|
|
11310
|
-
.pipe(takeWhile((s) => s === undefined, true))
|
|
11311
|
-
.subscribe((stream) => {
|
|
11312
|
-
var _a;
|
|
11313
|
-
if (!((_a = this.state.localParticipant) === null || _a === void 0 ? void 0 : _a.videoStream)) {
|
|
11314
|
-
this.publishVideoStream(stream);
|
|
11342
|
+
var _a, _b, _c, _d, _e;
|
|
11343
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11344
|
+
// Wait for any in progress camera operation
|
|
11345
|
+
if (this.camera.enablePromise) {
|
|
11346
|
+
yield this.camera.enablePromise;
|
|
11347
|
+
}
|
|
11348
|
+
if (this.camera.disablePromise) {
|
|
11349
|
+
yield this.camera.disablePromise;
|
|
11350
|
+
}
|
|
11351
|
+
if (((_a = this.state.localParticipant) === null || _a === void 0 ? void 0 : _a.videoStream) ||
|
|
11352
|
+
!this.permissionsContext.hasPermission('send-video')) {
|
|
11353
|
+
return;
|
|
11354
|
+
}
|
|
11355
|
+
// Set camera direction if it's not yet set
|
|
11356
|
+
if (!this.camera.state.direction && !this.camera.state.selectedDevice) {
|
|
11357
|
+
let defaultDirection = 'front';
|
|
11358
|
+
const backendSetting = (_b = this.state.settings) === null || _b === void 0 ? void 0 : _b.video.camera_facing;
|
|
11359
|
+
if (backendSetting) {
|
|
11360
|
+
defaultDirection = backendSetting === 'front' ? 'front' : 'back';
|
|
11315
11361
|
}
|
|
11316
|
-
|
|
11317
|
-
|
|
11318
|
-
|
|
11319
|
-
|
|
11320
|
-
(
|
|
11321
|
-
|
|
11322
|
-
|
|
11362
|
+
this.camera.state.setDirection(defaultDirection);
|
|
11363
|
+
}
|
|
11364
|
+
// Set target resolution
|
|
11365
|
+
const targetResolution = (_c = this.state.settings) === null || _c === void 0 ? void 0 : _c.video.target_resolution;
|
|
11366
|
+
if (targetResolution) {
|
|
11367
|
+
yield this.camera.selectTargetResolution(targetResolution);
|
|
11368
|
+
}
|
|
11369
|
+
// Publish already that was set before we joined
|
|
11370
|
+
if (this.camera.state.status === 'enabled' &&
|
|
11371
|
+
this.camera.state.mediaStream &&
|
|
11372
|
+
!((_d = this.publisher) === null || _d === void 0 ? void 0 : _d.isPublishing(TrackType.VIDEO))) {
|
|
11373
|
+
yield this.publishVideoStream(this.camera.state.mediaStream);
|
|
11374
|
+
}
|
|
11375
|
+
// Start camera if backend config speicifies, and there is no local setting
|
|
11376
|
+
if (this.camera.state.status === undefined &&
|
|
11377
|
+
((_e = this.state.settings) === null || _e === void 0 ? void 0 : _e.video.camera_default_on)) {
|
|
11378
|
+
yield this.camera.enable();
|
|
11379
|
+
}
|
|
11380
|
+
});
|
|
11323
11381
|
}
|
|
11324
11382
|
initMic() {
|
|
11325
|
-
var _a, _b;
|
|
11326
|
-
|
|
11327
|
-
|
|
11328
|
-
|
|
11329
|
-
|
|
11330
|
-
|
|
11331
|
-
|
|
11332
|
-
|
|
11333
|
-
|
|
11334
|
-
|
|
11335
|
-
.
|
|
11336
|
-
|
|
11337
|
-
|
|
11338
|
-
|
|
11339
|
-
|
|
11340
|
-
|
|
11341
|
-
|
|
11342
|
-
|
|
11343
|
-
|
|
11344
|
-
|
|
11345
|
-
|
|
11346
|
-
|
|
11383
|
+
var _a, _b, _c;
|
|
11384
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11385
|
+
// Wait for any in progress mic operation
|
|
11386
|
+
if (this.microphone.enablePromise) {
|
|
11387
|
+
yield this.microphone.enablePromise;
|
|
11388
|
+
}
|
|
11389
|
+
if (this.microphone.disablePromise) {
|
|
11390
|
+
yield this.microphone.disablePromise;
|
|
11391
|
+
}
|
|
11392
|
+
if (((_a = this.state.localParticipant) === null || _a === void 0 ? void 0 : _a.audioStream) ||
|
|
11393
|
+
!this.permissionsContext.hasPermission('send-audio')) {
|
|
11394
|
+
return;
|
|
11395
|
+
}
|
|
11396
|
+
// Publish media stream that was set before we joined
|
|
11397
|
+
if (this.microphone.state.status === 'enabled' &&
|
|
11398
|
+
this.microphone.state.mediaStream &&
|
|
11399
|
+
!((_b = this.publisher) === null || _b === void 0 ? void 0 : _b.isPublishing(TrackType.AUDIO))) {
|
|
11400
|
+
this.publishAudioStream(this.microphone.state.mediaStream);
|
|
11401
|
+
}
|
|
11402
|
+
// Start mic if backend config speicifies, and there is no local setting
|
|
11403
|
+
if (this.microphone.state.status === undefined &&
|
|
11404
|
+
((_c = this.state.settings) === null || _c === void 0 ? void 0 : _c.audio.mic_default_on)) {
|
|
11405
|
+
yield this.microphone.enable();
|
|
11406
|
+
}
|
|
11407
|
+
});
|
|
11347
11408
|
}
|
|
11348
11409
|
}
|
|
11349
11410
|
|
|
@@ -12456,7 +12517,7 @@ class WSConnectionFallback {
|
|
|
12456
12517
|
}
|
|
12457
12518
|
}
|
|
12458
12519
|
|
|
12459
|
-
const version = '0.3.
|
|
12520
|
+
const version = '0.3.7';
|
|
12460
12521
|
|
|
12461
12522
|
const logger = getLogger(['location']);
|
|
12462
12523
|
const HINT_URL = `https://hint.stream-io-video.com/`;
|