@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.cjs.js
CHANGED
|
@@ -9937,8 +9937,15 @@ class InputMediaDeviceManager {
|
|
|
9937
9937
|
if (this.state.status === 'enabled') {
|
|
9938
9938
|
return;
|
|
9939
9939
|
}
|
|
9940
|
-
|
|
9941
|
-
|
|
9940
|
+
this.enablePromise = this.unmuteStream();
|
|
9941
|
+
try {
|
|
9942
|
+
yield this.enablePromise;
|
|
9943
|
+
this.state.setStatus('enabled');
|
|
9944
|
+
}
|
|
9945
|
+
catch (error) {
|
|
9946
|
+
this.enablePromise = undefined;
|
|
9947
|
+
throw error;
|
|
9948
|
+
}
|
|
9942
9949
|
});
|
|
9943
9950
|
}
|
|
9944
9951
|
/**
|
|
@@ -9948,12 +9955,20 @@ class InputMediaDeviceManager {
|
|
|
9948
9955
|
*/
|
|
9949
9956
|
disable() {
|
|
9950
9957
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9958
|
+
this.state.prevStatus = this.state.status;
|
|
9951
9959
|
if (this.state.status === 'disabled') {
|
|
9952
9960
|
return;
|
|
9953
9961
|
}
|
|
9954
|
-
this.
|
|
9955
|
-
|
|
9956
|
-
|
|
9962
|
+
this.disablePromise = this.muteStream(this.state.disableMode === 'stop-tracks');
|
|
9963
|
+
try {
|
|
9964
|
+
yield this.disablePromise;
|
|
9965
|
+
this.state.setStatus('disabled');
|
|
9966
|
+
this.disablePromise = undefined;
|
|
9967
|
+
}
|
|
9968
|
+
catch (error) {
|
|
9969
|
+
this.disablePromise = undefined;
|
|
9970
|
+
throw error;
|
|
9971
|
+
}
|
|
9957
9972
|
});
|
|
9958
9973
|
}
|
|
9959
9974
|
/**
|
|
@@ -10049,6 +10064,10 @@ class InputMediaDeviceManager {
|
|
|
10049
10064
|
class CameraManager extends InputMediaDeviceManager {
|
|
10050
10065
|
constructor(call) {
|
|
10051
10066
|
super(call, new CameraManagerState());
|
|
10067
|
+
this.targetResolution = {
|
|
10068
|
+
width: 1280,
|
|
10069
|
+
height: 720,
|
|
10070
|
+
};
|
|
10052
10071
|
}
|
|
10053
10072
|
/**
|
|
10054
10073
|
* Select the camera direaction
|
|
@@ -10074,10 +10093,37 @@ class CameraManager extends InputMediaDeviceManager {
|
|
|
10074
10093
|
this.selectDirection(newDirection);
|
|
10075
10094
|
});
|
|
10076
10095
|
}
|
|
10096
|
+
/**
|
|
10097
|
+
* @internal
|
|
10098
|
+
*/
|
|
10099
|
+
selectTargetResolution(resolution) {
|
|
10100
|
+
var _a;
|
|
10101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10102
|
+
this.targetResolution.height = resolution.height;
|
|
10103
|
+
this.targetResolution.width = resolution.width;
|
|
10104
|
+
if (this.enablePromise) {
|
|
10105
|
+
try {
|
|
10106
|
+
yield this.enablePromise;
|
|
10107
|
+
}
|
|
10108
|
+
catch (error) {
|
|
10109
|
+
// couldn't enable device, target resolution will be applied the next time user attempts to start the device
|
|
10110
|
+
}
|
|
10111
|
+
}
|
|
10112
|
+
if (this.state.status === 'enabled') {
|
|
10113
|
+
const { width, height } = (_a = this.state
|
|
10114
|
+
.mediaStream.getVideoTracks()[0]) === null || _a === void 0 ? void 0 : _a.getSettings();
|
|
10115
|
+
if (width !== this.targetResolution.width ||
|
|
10116
|
+
height !== this.targetResolution.height)
|
|
10117
|
+
yield this.applySettingsToStream();
|
|
10118
|
+
}
|
|
10119
|
+
});
|
|
10120
|
+
}
|
|
10077
10121
|
getDevices() {
|
|
10078
10122
|
return getVideoDevices();
|
|
10079
10123
|
}
|
|
10080
10124
|
getStream(constraints) {
|
|
10125
|
+
constraints.width = this.targetResolution.width;
|
|
10126
|
+
constraints.height = this.targetResolution.height;
|
|
10081
10127
|
// We can't set both device id and facing mode
|
|
10082
10128
|
// Device id has higher priority
|
|
10083
10129
|
if (!constraints.deviceId && this.state.direction) {
|
|
@@ -10575,8 +10621,13 @@ class Call {
|
|
|
10575
10621
|
this.state.setCallingState(exports.CallingState.JOINED);
|
|
10576
10622
|
// React uses a different device management for now
|
|
10577
10623
|
if (((_h = getSdkInfo()) === null || _h === void 0 ? void 0 : _h.type) !== SdkType.REACT) {
|
|
10578
|
-
|
|
10579
|
-
|
|
10624
|
+
try {
|
|
10625
|
+
yield this.initCamera();
|
|
10626
|
+
yield this.initMic();
|
|
10627
|
+
}
|
|
10628
|
+
catch (error) {
|
|
10629
|
+
this.logger('warn', 'Camera and/or mic init failed during join call');
|
|
10630
|
+
}
|
|
10580
10631
|
}
|
|
10581
10632
|
// 3. once we have the "joinResponse", and possibly reconciled the local state
|
|
10582
10633
|
// we schedule a fast subscription update for all remote participants
|
|
@@ -11308,62 +11359,72 @@ class Call {
|
|
|
11308
11359
|
return ((_a = this.state.createdBy) === null || _a === void 0 ? void 0 : _a.id) === this.currentUserId;
|
|
11309
11360
|
}
|
|
11310
11361
|
initCamera() {
|
|
11311
|
-
var _a, _b, _c;
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
|
|
11315
|
-
|
|
11316
|
-
|
|
11317
|
-
|
|
11318
|
-
|
|
11319
|
-
|
|
11320
|
-
|
|
11321
|
-
|
|
11322
|
-
|
|
11323
|
-
}
|
|
11324
|
-
|
|
11325
|
-
|
|
11326
|
-
|
|
11327
|
-
|
|
11328
|
-
|
|
11329
|
-
|
|
11330
|
-
.pipe(rxjs.takeWhile((s) => s === undefined, true))
|
|
11331
|
-
.subscribe((stream) => {
|
|
11332
|
-
var _a;
|
|
11333
|
-
if (!((_a = this.state.localParticipant) === null || _a === void 0 ? void 0 : _a.videoStream)) {
|
|
11334
|
-
this.publishVideoStream(stream);
|
|
11362
|
+
var _a, _b, _c, _d, _e;
|
|
11363
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11364
|
+
// Wait for any in progress camera operation
|
|
11365
|
+
if (this.camera.enablePromise) {
|
|
11366
|
+
yield this.camera.enablePromise;
|
|
11367
|
+
}
|
|
11368
|
+
if (this.camera.disablePromise) {
|
|
11369
|
+
yield this.camera.disablePromise;
|
|
11370
|
+
}
|
|
11371
|
+
if (((_a = this.state.localParticipant) === null || _a === void 0 ? void 0 : _a.videoStream) ||
|
|
11372
|
+
!this.permissionsContext.hasPermission('send-video')) {
|
|
11373
|
+
return;
|
|
11374
|
+
}
|
|
11375
|
+
// Set camera direction if it's not yet set
|
|
11376
|
+
if (!this.camera.state.direction && !this.camera.state.selectedDevice) {
|
|
11377
|
+
let defaultDirection = 'front';
|
|
11378
|
+
const backendSetting = (_b = this.state.settings) === null || _b === void 0 ? void 0 : _b.video.camera_facing;
|
|
11379
|
+
if (backendSetting) {
|
|
11380
|
+
defaultDirection = backendSetting === 'front' ? 'front' : 'back';
|
|
11335
11381
|
}
|
|
11336
|
-
|
|
11337
|
-
|
|
11338
|
-
|
|
11339
|
-
|
|
11340
|
-
(
|
|
11341
|
-
|
|
11342
|
-
|
|
11382
|
+
this.camera.state.setDirection(defaultDirection);
|
|
11383
|
+
}
|
|
11384
|
+
// Set target resolution
|
|
11385
|
+
const targetResolution = (_c = this.state.settings) === null || _c === void 0 ? void 0 : _c.video.target_resolution;
|
|
11386
|
+
if (targetResolution) {
|
|
11387
|
+
yield this.camera.selectTargetResolution(targetResolution);
|
|
11388
|
+
}
|
|
11389
|
+
// Publish already that was set before we joined
|
|
11390
|
+
if (this.camera.state.status === 'enabled' &&
|
|
11391
|
+
this.camera.state.mediaStream &&
|
|
11392
|
+
!((_d = this.publisher) === null || _d === void 0 ? void 0 : _d.isPublishing(TrackType.VIDEO))) {
|
|
11393
|
+
yield this.publishVideoStream(this.camera.state.mediaStream);
|
|
11394
|
+
}
|
|
11395
|
+
// Start camera if backend config speicifies, and there is no local setting
|
|
11396
|
+
if (this.camera.state.status === undefined &&
|
|
11397
|
+
((_e = this.state.settings) === null || _e === void 0 ? void 0 : _e.video.camera_default_on)) {
|
|
11398
|
+
yield this.camera.enable();
|
|
11399
|
+
}
|
|
11400
|
+
});
|
|
11343
11401
|
}
|
|
11344
11402
|
initMic() {
|
|
11345
|
-
var _a, _b;
|
|
11346
|
-
|
|
11347
|
-
|
|
11348
|
-
|
|
11349
|
-
|
|
11350
|
-
|
|
11351
|
-
|
|
11352
|
-
|
|
11353
|
-
|
|
11354
|
-
|
|
11355
|
-
.
|
|
11356
|
-
|
|
11357
|
-
|
|
11358
|
-
|
|
11359
|
-
|
|
11360
|
-
|
|
11361
|
-
|
|
11362
|
-
|
|
11363
|
-
|
|
11364
|
-
|
|
11365
|
-
|
|
11366
|
-
|
|
11403
|
+
var _a, _b, _c;
|
|
11404
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
11405
|
+
// Wait for any in progress mic operation
|
|
11406
|
+
if (this.microphone.enablePromise) {
|
|
11407
|
+
yield this.microphone.enablePromise;
|
|
11408
|
+
}
|
|
11409
|
+
if (this.microphone.disablePromise) {
|
|
11410
|
+
yield this.microphone.disablePromise;
|
|
11411
|
+
}
|
|
11412
|
+
if (((_a = this.state.localParticipant) === null || _a === void 0 ? void 0 : _a.audioStream) ||
|
|
11413
|
+
!this.permissionsContext.hasPermission('send-audio')) {
|
|
11414
|
+
return;
|
|
11415
|
+
}
|
|
11416
|
+
// Publish media stream that was set before we joined
|
|
11417
|
+
if (this.microphone.state.status === 'enabled' &&
|
|
11418
|
+
this.microphone.state.mediaStream &&
|
|
11419
|
+
!((_b = this.publisher) === null || _b === void 0 ? void 0 : _b.isPublishing(TrackType.AUDIO))) {
|
|
11420
|
+
this.publishAudioStream(this.microphone.state.mediaStream);
|
|
11421
|
+
}
|
|
11422
|
+
// Start mic if backend config speicifies, and there is no local setting
|
|
11423
|
+
if (this.microphone.state.status === undefined &&
|
|
11424
|
+
((_c = this.state.settings) === null || _c === void 0 ? void 0 : _c.audio.mic_default_on)) {
|
|
11425
|
+
yield this.microphone.enable();
|
|
11426
|
+
}
|
|
11427
|
+
});
|
|
11367
11428
|
}
|
|
11368
11429
|
}
|
|
11369
11430
|
|
|
@@ -12476,7 +12537,7 @@ class WSConnectionFallback {
|
|
|
12476
12537
|
}
|
|
12477
12538
|
}
|
|
12478
12539
|
|
|
12479
|
-
const version = '0.3.
|
|
12540
|
+
const version = '0.3.7';
|
|
12480
12541
|
|
|
12481
12542
|
const logger = getLogger(['location']);
|
|
12482
12543
|
const HINT_URL = `https://hint.stream-io-video.com/`;
|