@stream-io/video-client 0.4.0 → 0.4.2
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 +51 -42
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +51 -42
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +51 -42
- package/dist/index.es.js.map +1 -1
- package/dist/src/Call.d.ts +1 -0
- package/dist/src/devices/InputMediaDeviceManager.d.ts +1 -1
- package/package.json +1 -1
- package/src/Call.ts +45 -32
- package/src/StreamVideoClient.ts +1 -0
- package/src/__tests__/StreamVideoClient.test.ts +0 -3
- package/src/devices/InputMediaDeviceManager.ts +17 -22
package/dist/index.cjs.js
CHANGED
|
@@ -10285,13 +10285,13 @@ class InputMediaDeviceManager {
|
|
|
10285
10285
|
* Starts stream.
|
|
10286
10286
|
*/
|
|
10287
10287
|
async enable() {
|
|
10288
|
-
if (this.state.status === 'enabled')
|
|
10288
|
+
if (this.state.status === 'enabled')
|
|
10289
10289
|
return;
|
|
10290
|
-
}
|
|
10291
10290
|
this.enablePromise = this.unmuteStream();
|
|
10292
10291
|
try {
|
|
10293
10292
|
await this.enablePromise;
|
|
10294
10293
|
this.state.setStatus('enabled');
|
|
10294
|
+
this.enablePromise = undefined;
|
|
10295
10295
|
}
|
|
10296
10296
|
catch (error) {
|
|
10297
10297
|
this.enablePromise = undefined;
|
|
@@ -10303,10 +10303,10 @@ class InputMediaDeviceManager {
|
|
|
10303
10303
|
*/
|
|
10304
10304
|
async disable() {
|
|
10305
10305
|
this.state.prevStatus = this.state.status;
|
|
10306
|
-
if (this.state.status === 'disabled')
|
|
10306
|
+
if (this.state.status === 'disabled')
|
|
10307
10307
|
return;
|
|
10308
|
-
|
|
10309
|
-
this.disablePromise = this.muteStream(
|
|
10308
|
+
const stopTracks = this.state.disableMode === 'stop-tracks';
|
|
10309
|
+
this.disablePromise = this.muteStream(stopTracks);
|
|
10310
10310
|
try {
|
|
10311
10311
|
await this.disablePromise;
|
|
10312
10312
|
this.state.setStatus('disabled');
|
|
@@ -10343,7 +10343,7 @@ class InputMediaDeviceManager {
|
|
|
10343
10343
|
*
|
|
10344
10344
|
* @param constraints the constraints to set.
|
|
10345
10345
|
*/
|
|
10346
|
-
|
|
10346
|
+
setDefaultConstraints(constraints) {
|
|
10347
10347
|
this.state.setDefaultConstraints(constraints);
|
|
10348
10348
|
}
|
|
10349
10349
|
/**
|
|
@@ -10373,25 +10373,23 @@ class InputMediaDeviceManager {
|
|
|
10373
10373
|
return this.state.mediaStream?.getTracks() ?? [];
|
|
10374
10374
|
}
|
|
10375
10375
|
async muteStream(stopTracks = true) {
|
|
10376
|
-
if (!this.state.mediaStream)
|
|
10376
|
+
if (!this.state.mediaStream)
|
|
10377
10377
|
return;
|
|
10378
|
-
}
|
|
10379
10378
|
this.logger('debug', `${stopTracks ? 'Stopping' : 'Disabling'} stream`);
|
|
10380
10379
|
if (this.call.state.callingState === exports.CallingState.JOINED) {
|
|
10381
10380
|
await this.stopPublishStream(stopTracks);
|
|
10382
10381
|
}
|
|
10383
10382
|
this.muteLocalStream(stopTracks);
|
|
10384
|
-
this.getTracks().
|
|
10385
|
-
|
|
10383
|
+
const allEnded = this.getTracks().every((t) => t.readyState === 'ended');
|
|
10384
|
+
if (allEnded) {
|
|
10385
|
+
if (this.state.mediaStream &&
|
|
10386
10386
|
// @ts-expect-error release() is present in react-native-webrtc
|
|
10387
|
-
|
|
10388
|
-
|
|
10389
|
-
|
|
10390
|
-
this.state.mediaStream.release();
|
|
10391
|
-
}
|
|
10392
|
-
this.state.setMediaStream(undefined);
|
|
10387
|
+
typeof this.state.mediaStream.release === 'function') {
|
|
10388
|
+
// @ts-expect-error called to dispose the stream in RN
|
|
10389
|
+
this.state.mediaStream.release();
|
|
10393
10390
|
}
|
|
10394
|
-
|
|
10391
|
+
this.state.setMediaStream(undefined);
|
|
10392
|
+
}
|
|
10395
10393
|
}
|
|
10396
10394
|
muteTracks() {
|
|
10397
10395
|
this.getTracks().forEach((track) => {
|
|
@@ -11137,6 +11135,7 @@ class Call {
|
|
|
11137
11135
|
this.watching = true;
|
|
11138
11136
|
this.clientStore.registerCall(this);
|
|
11139
11137
|
}
|
|
11138
|
+
this.applyDeviceConfig();
|
|
11140
11139
|
return response;
|
|
11141
11140
|
};
|
|
11142
11141
|
/**
|
|
@@ -11156,6 +11155,7 @@ class Call {
|
|
|
11156
11155
|
this.watching = true;
|
|
11157
11156
|
this.clientStore.registerCall(this);
|
|
11158
11157
|
}
|
|
11158
|
+
this.applyDeviceConfig();
|
|
11159
11159
|
return response;
|
|
11160
11160
|
};
|
|
11161
11161
|
/**
|
|
@@ -11488,8 +11488,8 @@ class Call {
|
|
|
11488
11488
|
this.reconnectAttempts = 0; // reset the reconnect attempts counter
|
|
11489
11489
|
this.state.setCallingState(exports.CallingState.JOINED);
|
|
11490
11490
|
try {
|
|
11491
|
-
await this.initCamera();
|
|
11492
|
-
await this.initMic();
|
|
11491
|
+
await this.initCamera({ setStatus: true });
|
|
11492
|
+
await this.initMic({ setStatus: true });
|
|
11493
11493
|
}
|
|
11494
11494
|
catch (error) {
|
|
11495
11495
|
this.logger('warn', 'Camera and/or mic init failed during join call');
|
|
@@ -12065,6 +12065,10 @@ class Call {
|
|
|
12065
12065
|
this.sendCustomEvent = async (payload) => {
|
|
12066
12066
|
return this.streamClient.post(`${this.streamClientBasePath}/event`, { custom: payload });
|
|
12067
12067
|
};
|
|
12068
|
+
this.applyDeviceConfig = () => {
|
|
12069
|
+
this.initCamera({ setStatus: false });
|
|
12070
|
+
this.initMic({ setStatus: false });
|
|
12071
|
+
};
|
|
12068
12072
|
/**
|
|
12069
12073
|
* Will begin tracking the given element for visibility changes within the
|
|
12070
12074
|
* configured viewport element (`call.setViewport`).
|
|
@@ -12310,7 +12314,7 @@ class Call {
|
|
|
12310
12314
|
get isCreatedByMe() {
|
|
12311
12315
|
return this.state.createdBy?.id === this.currentUserId;
|
|
12312
12316
|
}
|
|
12313
|
-
async initCamera() {
|
|
12317
|
+
async initCamera(options) {
|
|
12314
12318
|
// Wait for any in progress camera operation
|
|
12315
12319
|
if (this.camera.enablePromise) {
|
|
12316
12320
|
await this.camera.enablePromise;
|
|
@@ -12336,19 +12340,21 @@ class Call {
|
|
|
12336
12340
|
if (targetResolution) {
|
|
12337
12341
|
await this.camera.selectTargetResolution(targetResolution);
|
|
12338
12342
|
}
|
|
12339
|
-
|
|
12340
|
-
|
|
12341
|
-
this.camera.state.
|
|
12342
|
-
|
|
12343
|
-
|
|
12344
|
-
|
|
12345
|
-
|
|
12346
|
-
|
|
12347
|
-
this.state.
|
|
12348
|
-
|
|
12343
|
+
if (options.setStatus) {
|
|
12344
|
+
// Publish already that was set before we joined
|
|
12345
|
+
if (this.camera.state.status === 'enabled' &&
|
|
12346
|
+
this.camera.state.mediaStream &&
|
|
12347
|
+
!this.publisher?.isPublishing(TrackType.VIDEO)) {
|
|
12348
|
+
await this.publishVideoStream(this.camera.state.mediaStream);
|
|
12349
|
+
}
|
|
12350
|
+
// Start camera if backend config speicifies, and there is no local setting
|
|
12351
|
+
if (this.camera.state.status === undefined &&
|
|
12352
|
+
this.state.settings?.video.camera_default_on) {
|
|
12353
|
+
await this.camera.enable();
|
|
12354
|
+
}
|
|
12349
12355
|
}
|
|
12350
12356
|
}
|
|
12351
|
-
async initMic() {
|
|
12357
|
+
async initMic(options) {
|
|
12352
12358
|
// Wait for any in progress mic operation
|
|
12353
12359
|
if (this.microphone.enablePromise) {
|
|
12354
12360
|
await this.microphone.enablePromise;
|
|
@@ -12360,16 +12366,18 @@ class Call {
|
|
|
12360
12366
|
!this.permissionsContext.hasPermission('send-audio')) {
|
|
12361
12367
|
return;
|
|
12362
12368
|
}
|
|
12363
|
-
|
|
12364
|
-
|
|
12365
|
-
this.microphone.state.
|
|
12366
|
-
|
|
12367
|
-
|
|
12368
|
-
|
|
12369
|
-
|
|
12370
|
-
|
|
12371
|
-
this.state.
|
|
12372
|
-
|
|
12369
|
+
if (options.setStatus) {
|
|
12370
|
+
// Publish media stream that was set before we joined
|
|
12371
|
+
if (this.microphone.state.status === 'enabled' &&
|
|
12372
|
+
this.microphone.state.mediaStream &&
|
|
12373
|
+
!this.publisher?.isPublishing(TrackType.AUDIO)) {
|
|
12374
|
+
await this.publishAudioStream(this.microphone.state.mediaStream);
|
|
12375
|
+
}
|
|
12376
|
+
// Start mic if backend config specifies, and there is no local setting
|
|
12377
|
+
if (this.microphone.state.status === undefined &&
|
|
12378
|
+
this.state.settings?.audio.mic_default_on) {
|
|
12379
|
+
await this.microphone.enable();
|
|
12380
|
+
}
|
|
12373
12381
|
}
|
|
12374
12382
|
}
|
|
12375
12383
|
}
|
|
@@ -13955,7 +13963,7 @@ class StreamClient {
|
|
|
13955
13963
|
});
|
|
13956
13964
|
};
|
|
13957
13965
|
this.getUserAgent = () => {
|
|
13958
|
-
const version = "0.4.
|
|
13966
|
+
const version = "0.4.2" ;
|
|
13959
13967
|
return (this.userAgent ||
|
|
13960
13968
|
`stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
|
|
13961
13969
|
};
|
|
@@ -14203,6 +14211,7 @@ class StreamVideoClient {
|
|
|
14203
14211
|
clientStore: this.writeableStateStore,
|
|
14204
14212
|
});
|
|
14205
14213
|
call.state.updateFromCallResponse(c.call);
|
|
14214
|
+
call.applyDeviceConfig();
|
|
14206
14215
|
if (data.watch) {
|
|
14207
14216
|
this.writeableStateStore.registerCall(call);
|
|
14208
14217
|
}
|