@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/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
|
/**
|
|
@@ -9932,8 +9939,16 @@ class InputMediaDeviceManager {
|
|
|
9932
9939
|
if (this.state.status === 'disabled') {
|
|
9933
9940
|
return;
|
|
9934
9941
|
}
|
|
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) {
|
|
@@ -11293,63 +11339,69 @@ class Call {
|
|
|
11293
11339
|
return ((_a = this.state.createdBy) === null || _a === void 0 ? void 0 : _a.id) === this.currentUserId;
|
|
11294
11340
|
}
|
|
11295
11341
|
initCamera() {
|
|
11296
|
-
var _a, _b, _c;
|
|
11342
|
+
var _a, _b, _c, _d, _e;
|
|
11297
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
|
+
}
|
|
11298
11351
|
if (((_a = this.state.localParticipant) === null || _a === void 0 ? void 0 : _a.videoStream) ||
|
|
11299
11352
|
!this.permissionsContext.hasPermission('send-video')) {
|
|
11300
11353
|
return;
|
|
11301
11354
|
}
|
|
11302
11355
|
// Set camera direction if it's not yet set
|
|
11303
|
-
// This will also start publishing if camera is enabled
|
|
11304
11356
|
if (!this.camera.state.direction && !this.camera.state.selectedDevice) {
|
|
11305
11357
|
let defaultDirection = 'front';
|
|
11306
11358
|
const backendSetting = (_b = this.state.settings) === null || _b === void 0 ? void 0 : _b.video.camera_facing;
|
|
11307
11359
|
if (backendSetting) {
|
|
11308
11360
|
defaultDirection = backendSetting === 'front' ? 'front' : 'back';
|
|
11309
11361
|
}
|
|
11310
|
-
this.camera.
|
|
11311
|
-
}
|
|
11312
|
-
else if (this.camera.state.status === 'enabled') {
|
|
11313
|
-
// Publish already started media streams (this is the case if there is a lobby screen before join)
|
|
11314
|
-
// Wait for media stream
|
|
11315
|
-
this.camera.state.mediaStream$
|
|
11316
|
-
.pipe(takeWhile((s) => s === undefined, true))
|
|
11317
|
-
.subscribe((stream) => {
|
|
11318
|
-
var _a;
|
|
11319
|
-
if (!((_a = this.state.localParticipant) === null || _a === void 0 ? void 0 : _a.videoStream)) {
|
|
11320
|
-
this.publishVideoStream(stream);
|
|
11321
|
-
}
|
|
11322
|
-
});
|
|
11362
|
+
this.camera.state.setDirection(defaultDirection);
|
|
11323
11363
|
}
|
|
11324
|
-
//
|
|
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
|
|
11325
11376
|
if (this.camera.state.status === undefined &&
|
|
11326
|
-
((
|
|
11377
|
+
((_e = this.state.settings) === null || _e === void 0 ? void 0 : _e.video.camera_default_on)) {
|
|
11327
11378
|
yield this.camera.enable();
|
|
11328
11379
|
}
|
|
11329
11380
|
});
|
|
11330
11381
|
}
|
|
11331
11382
|
initMic() {
|
|
11332
|
-
var _a, _b;
|
|
11383
|
+
var _a, _b, _c;
|
|
11333
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
|
+
}
|
|
11334
11392
|
if (((_a = this.state.localParticipant) === null || _a === void 0 ? void 0 : _a.audioStream) ||
|
|
11335
11393
|
!this.permissionsContext.hasPermission('send-audio')) {
|
|
11336
11394
|
return;
|
|
11337
11395
|
}
|
|
11338
|
-
// Publish
|
|
11339
|
-
if (this.microphone.state.status === 'enabled'
|
|
11340
|
-
|
|
11341
|
-
this.
|
|
11342
|
-
|
|
11343
|
-
.subscribe((stream) => {
|
|
11344
|
-
var _a;
|
|
11345
|
-
if (!((_a = this.state.localParticipant) === null || _a === void 0 ? void 0 : _a.audioStream)) {
|
|
11346
|
-
this.publishAudioStream(stream);
|
|
11347
|
-
}
|
|
11348
|
-
});
|
|
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);
|
|
11349
11401
|
}
|
|
11350
|
-
//
|
|
11402
|
+
// Start mic if backend config speicifies, and there is no local setting
|
|
11351
11403
|
if (this.microphone.state.status === undefined &&
|
|
11352
|
-
((
|
|
11404
|
+
((_c = this.state.settings) === null || _c === void 0 ? void 0 : _c.audio.mic_default_on)) {
|
|
11353
11405
|
yield this.microphone.enable();
|
|
11354
11406
|
}
|
|
11355
11407
|
});
|
|
@@ -12465,7 +12517,7 @@ class WSConnectionFallback {
|
|
|
12465
12517
|
}
|
|
12466
12518
|
}
|
|
12467
12519
|
|
|
12468
|
-
const version = '0.3.
|
|
12520
|
+
const version = '0.3.7';
|
|
12469
12521
|
|
|
12470
12522
|
const logger = getLogger(['location']);
|
|
12471
12523
|
const HINT_URL = `https://hint.stream-io-video.com/`;
|