@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.es.js
CHANGED
|
@@ -10265,13 +10265,13 @@ class InputMediaDeviceManager {
|
|
|
10265
10265
|
* Starts stream.
|
|
10266
10266
|
*/
|
|
10267
10267
|
async enable() {
|
|
10268
|
-
if (this.state.status === 'enabled')
|
|
10268
|
+
if (this.state.status === 'enabled')
|
|
10269
10269
|
return;
|
|
10270
|
-
}
|
|
10271
10270
|
this.enablePromise = this.unmuteStream();
|
|
10272
10271
|
try {
|
|
10273
10272
|
await this.enablePromise;
|
|
10274
10273
|
this.state.setStatus('enabled');
|
|
10274
|
+
this.enablePromise = undefined;
|
|
10275
10275
|
}
|
|
10276
10276
|
catch (error) {
|
|
10277
10277
|
this.enablePromise = undefined;
|
|
@@ -10283,10 +10283,10 @@ class InputMediaDeviceManager {
|
|
|
10283
10283
|
*/
|
|
10284
10284
|
async disable() {
|
|
10285
10285
|
this.state.prevStatus = this.state.status;
|
|
10286
|
-
if (this.state.status === 'disabled')
|
|
10286
|
+
if (this.state.status === 'disabled')
|
|
10287
10287
|
return;
|
|
10288
|
-
|
|
10289
|
-
this.disablePromise = this.muteStream(
|
|
10288
|
+
const stopTracks = this.state.disableMode === 'stop-tracks';
|
|
10289
|
+
this.disablePromise = this.muteStream(stopTracks);
|
|
10290
10290
|
try {
|
|
10291
10291
|
await this.disablePromise;
|
|
10292
10292
|
this.state.setStatus('disabled');
|
|
@@ -10323,7 +10323,7 @@ class InputMediaDeviceManager {
|
|
|
10323
10323
|
*
|
|
10324
10324
|
* @param constraints the constraints to set.
|
|
10325
10325
|
*/
|
|
10326
|
-
|
|
10326
|
+
setDefaultConstraints(constraints) {
|
|
10327
10327
|
this.state.setDefaultConstraints(constraints);
|
|
10328
10328
|
}
|
|
10329
10329
|
/**
|
|
@@ -10353,25 +10353,23 @@ class InputMediaDeviceManager {
|
|
|
10353
10353
|
return this.state.mediaStream?.getTracks() ?? [];
|
|
10354
10354
|
}
|
|
10355
10355
|
async muteStream(stopTracks = true) {
|
|
10356
|
-
if (!this.state.mediaStream)
|
|
10356
|
+
if (!this.state.mediaStream)
|
|
10357
10357
|
return;
|
|
10358
|
-
}
|
|
10359
10358
|
this.logger('debug', `${stopTracks ? 'Stopping' : 'Disabling'} stream`);
|
|
10360
10359
|
if (this.call.state.callingState === CallingState.JOINED) {
|
|
10361
10360
|
await this.stopPublishStream(stopTracks);
|
|
10362
10361
|
}
|
|
10363
10362
|
this.muteLocalStream(stopTracks);
|
|
10364
|
-
this.getTracks().
|
|
10365
|
-
|
|
10363
|
+
const allEnded = this.getTracks().every((t) => t.readyState === 'ended');
|
|
10364
|
+
if (allEnded) {
|
|
10365
|
+
if (this.state.mediaStream &&
|
|
10366
10366
|
// @ts-expect-error release() is present in react-native-webrtc
|
|
10367
|
-
|
|
10368
|
-
|
|
10369
|
-
|
|
10370
|
-
this.state.mediaStream.release();
|
|
10371
|
-
}
|
|
10372
|
-
this.state.setMediaStream(undefined);
|
|
10367
|
+
typeof this.state.mediaStream.release === 'function') {
|
|
10368
|
+
// @ts-expect-error called to dispose the stream in RN
|
|
10369
|
+
this.state.mediaStream.release();
|
|
10373
10370
|
}
|
|
10374
|
-
|
|
10371
|
+
this.state.setMediaStream(undefined);
|
|
10372
|
+
}
|
|
10375
10373
|
}
|
|
10376
10374
|
muteTracks() {
|
|
10377
10375
|
this.getTracks().forEach((track) => {
|
|
@@ -11117,6 +11115,7 @@ class Call {
|
|
|
11117
11115
|
this.watching = true;
|
|
11118
11116
|
this.clientStore.registerCall(this);
|
|
11119
11117
|
}
|
|
11118
|
+
this.applyDeviceConfig();
|
|
11120
11119
|
return response;
|
|
11121
11120
|
};
|
|
11122
11121
|
/**
|
|
@@ -11136,6 +11135,7 @@ class Call {
|
|
|
11136
11135
|
this.watching = true;
|
|
11137
11136
|
this.clientStore.registerCall(this);
|
|
11138
11137
|
}
|
|
11138
|
+
this.applyDeviceConfig();
|
|
11139
11139
|
return response;
|
|
11140
11140
|
};
|
|
11141
11141
|
/**
|
|
@@ -11468,8 +11468,8 @@ class Call {
|
|
|
11468
11468
|
this.reconnectAttempts = 0; // reset the reconnect attempts counter
|
|
11469
11469
|
this.state.setCallingState(CallingState.JOINED);
|
|
11470
11470
|
try {
|
|
11471
|
-
await this.initCamera();
|
|
11472
|
-
await this.initMic();
|
|
11471
|
+
await this.initCamera({ setStatus: true });
|
|
11472
|
+
await this.initMic({ setStatus: true });
|
|
11473
11473
|
}
|
|
11474
11474
|
catch (error) {
|
|
11475
11475
|
this.logger('warn', 'Camera and/or mic init failed during join call');
|
|
@@ -12045,6 +12045,10 @@ class Call {
|
|
|
12045
12045
|
this.sendCustomEvent = async (payload) => {
|
|
12046
12046
|
return this.streamClient.post(`${this.streamClientBasePath}/event`, { custom: payload });
|
|
12047
12047
|
};
|
|
12048
|
+
this.applyDeviceConfig = () => {
|
|
12049
|
+
this.initCamera({ setStatus: false });
|
|
12050
|
+
this.initMic({ setStatus: false });
|
|
12051
|
+
};
|
|
12048
12052
|
/**
|
|
12049
12053
|
* Will begin tracking the given element for visibility changes within the
|
|
12050
12054
|
* configured viewport element (`call.setViewport`).
|
|
@@ -12290,7 +12294,7 @@ class Call {
|
|
|
12290
12294
|
get isCreatedByMe() {
|
|
12291
12295
|
return this.state.createdBy?.id === this.currentUserId;
|
|
12292
12296
|
}
|
|
12293
|
-
async initCamera() {
|
|
12297
|
+
async initCamera(options) {
|
|
12294
12298
|
// Wait for any in progress camera operation
|
|
12295
12299
|
if (this.camera.enablePromise) {
|
|
12296
12300
|
await this.camera.enablePromise;
|
|
@@ -12316,19 +12320,21 @@ class Call {
|
|
|
12316
12320
|
if (targetResolution) {
|
|
12317
12321
|
await this.camera.selectTargetResolution(targetResolution);
|
|
12318
12322
|
}
|
|
12319
|
-
|
|
12320
|
-
|
|
12321
|
-
this.camera.state.
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
|
|
12325
|
-
|
|
12326
|
-
|
|
12327
|
-
this.state.
|
|
12328
|
-
|
|
12323
|
+
if (options.setStatus) {
|
|
12324
|
+
// Publish already that was set before we joined
|
|
12325
|
+
if (this.camera.state.status === 'enabled' &&
|
|
12326
|
+
this.camera.state.mediaStream &&
|
|
12327
|
+
!this.publisher?.isPublishing(TrackType.VIDEO)) {
|
|
12328
|
+
await this.publishVideoStream(this.camera.state.mediaStream);
|
|
12329
|
+
}
|
|
12330
|
+
// Start camera if backend config speicifies, and there is no local setting
|
|
12331
|
+
if (this.camera.state.status === undefined &&
|
|
12332
|
+
this.state.settings?.video.camera_default_on) {
|
|
12333
|
+
await this.camera.enable();
|
|
12334
|
+
}
|
|
12329
12335
|
}
|
|
12330
12336
|
}
|
|
12331
|
-
async initMic() {
|
|
12337
|
+
async initMic(options) {
|
|
12332
12338
|
// Wait for any in progress mic operation
|
|
12333
12339
|
if (this.microphone.enablePromise) {
|
|
12334
12340
|
await this.microphone.enablePromise;
|
|
@@ -12340,16 +12346,18 @@ class Call {
|
|
|
12340
12346
|
!this.permissionsContext.hasPermission('send-audio')) {
|
|
12341
12347
|
return;
|
|
12342
12348
|
}
|
|
12343
|
-
|
|
12344
|
-
|
|
12345
|
-
this.microphone.state.
|
|
12346
|
-
|
|
12347
|
-
|
|
12348
|
-
|
|
12349
|
-
|
|
12350
|
-
|
|
12351
|
-
this.state.
|
|
12352
|
-
|
|
12349
|
+
if (options.setStatus) {
|
|
12350
|
+
// Publish media stream that was set before we joined
|
|
12351
|
+
if (this.microphone.state.status === 'enabled' &&
|
|
12352
|
+
this.microphone.state.mediaStream &&
|
|
12353
|
+
!this.publisher?.isPublishing(TrackType.AUDIO)) {
|
|
12354
|
+
await this.publishAudioStream(this.microphone.state.mediaStream);
|
|
12355
|
+
}
|
|
12356
|
+
// Start mic if backend config specifies, and there is no local setting
|
|
12357
|
+
if (this.microphone.state.status === undefined &&
|
|
12358
|
+
this.state.settings?.audio.mic_default_on) {
|
|
12359
|
+
await this.microphone.enable();
|
|
12360
|
+
}
|
|
12353
12361
|
}
|
|
12354
12362
|
}
|
|
12355
12363
|
}
|
|
@@ -13935,7 +13943,7 @@ class StreamClient {
|
|
|
13935
13943
|
});
|
|
13936
13944
|
};
|
|
13937
13945
|
this.getUserAgent = () => {
|
|
13938
|
-
const version = "0.4.
|
|
13946
|
+
const version = "0.4.2" ;
|
|
13939
13947
|
return (this.userAgent ||
|
|
13940
13948
|
`stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
|
|
13941
13949
|
};
|
|
@@ -14183,6 +14191,7 @@ class StreamVideoClient {
|
|
|
14183
14191
|
clientStore: this.writeableStateStore,
|
|
14184
14192
|
});
|
|
14185
14193
|
call.state.updateFromCallResponse(c.call);
|
|
14194
|
+
call.applyDeviceConfig();
|
|
14186
14195
|
if (data.watch) {
|
|
14187
14196
|
this.writeableStateStore.registerCall(call);
|
|
14188
14197
|
}
|