@stream-io/video-client 1.0.9 → 1.0.10
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 +72 -53
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +72 -53
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +72 -53
- package/dist/index.es.js.map +1 -1
- package/dist/src/Call.d.ts +6 -1
- package/package.json +1 -1
- package/src/Call.ts +17 -6
- package/src/StreamVideoClient.ts +5 -4
- package/src/devices/InputMediaDeviceManager.ts +39 -32
- package/src/devices/MicrophoneManager.ts +14 -10
- package/src/devices/devices.ts +1 -1
package/dist/src/Call.d.ts
CHANGED
|
@@ -503,7 +503,12 @@ export declare class Call {
|
|
|
503
503
|
sendCustomEvent: (payload: {
|
|
504
504
|
[key: string]: any;
|
|
505
505
|
}) => Promise<SendCallEventResponse>;
|
|
506
|
-
|
|
506
|
+
/**
|
|
507
|
+
* Applies the device configuration from the backend.
|
|
508
|
+
*
|
|
509
|
+
* @internal
|
|
510
|
+
*/
|
|
511
|
+
applyDeviceConfig: () => Promise<void>;
|
|
507
512
|
private initCamera;
|
|
508
513
|
private initMic;
|
|
509
514
|
/**
|
package/package.json
CHANGED
package/src/Call.ts
CHANGED
|
@@ -388,7 +388,9 @@ export class Call {
|
|
|
388
388
|
const currentUserId = this.currentUserId;
|
|
389
389
|
if (currentUserId && blockedUserIds.includes(currentUserId)) {
|
|
390
390
|
this.logger('info', 'Leaving call because of being blocked');
|
|
391
|
-
await this.leave({ reason: 'user blocked' })
|
|
391
|
+
await this.leave({ reason: 'user blocked' }).catch((err) => {
|
|
392
|
+
this.logger('error', 'Error leaving call after being blocked', err);
|
|
393
|
+
});
|
|
392
394
|
}
|
|
393
395
|
}),
|
|
394
396
|
);
|
|
@@ -600,7 +602,7 @@ export class Call {
|
|
|
600
602
|
this.clientStore.registerCall(this);
|
|
601
603
|
}
|
|
602
604
|
|
|
603
|
-
this.applyDeviceConfig();
|
|
605
|
+
await this.applyDeviceConfig();
|
|
604
606
|
|
|
605
607
|
return response;
|
|
606
608
|
};
|
|
@@ -629,7 +631,7 @@ export class Call {
|
|
|
629
631
|
this.clientStore.registerCall(this);
|
|
630
632
|
}
|
|
631
633
|
|
|
632
|
-
this.applyDeviceConfig();
|
|
634
|
+
await this.applyDeviceConfig();
|
|
633
635
|
|
|
634
636
|
return response;
|
|
635
637
|
};
|
|
@@ -2019,9 +2021,18 @@ export class Call {
|
|
|
2019
2021
|
);
|
|
2020
2022
|
};
|
|
2021
2023
|
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2024
|
+
/**
|
|
2025
|
+
* Applies the device configuration from the backend.
|
|
2026
|
+
*
|
|
2027
|
+
* @internal
|
|
2028
|
+
*/
|
|
2029
|
+
applyDeviceConfig = async () => {
|
|
2030
|
+
await this.initCamera({ setStatus: false }).catch((err) => {
|
|
2031
|
+
this.logger('warn', 'Camera init failed', err);
|
|
2032
|
+
});
|
|
2033
|
+
await this.initMic({ setStatus: false }).catch((err) => {
|
|
2034
|
+
this.logger('warn', 'Mic init failed', err);
|
|
2035
|
+
});
|
|
2025
2036
|
};
|
|
2026
2037
|
|
|
2027
2038
|
private async initCamera(options: { setStatus: boolean }) {
|
package/src/StreamVideoClient.ts
CHANGED
|
@@ -345,7 +345,8 @@ export class StreamVideoClient {
|
|
|
345
345
|
QueryCallsResponse,
|
|
346
346
|
QueryCallsRequest
|
|
347
347
|
>('/calls', data);
|
|
348
|
-
const calls =
|
|
348
|
+
const calls = [];
|
|
349
|
+
for (const c of response.calls) {
|
|
349
350
|
const call = new Call({
|
|
350
351
|
streamClient: this.streamClient,
|
|
351
352
|
id: c.call.id,
|
|
@@ -356,12 +357,12 @@ export class StreamVideoClient {
|
|
|
356
357
|
clientStore: this.writeableStateStore,
|
|
357
358
|
});
|
|
358
359
|
call.state.updateFromCallResponse(c.call);
|
|
359
|
-
call.applyDeviceConfig();
|
|
360
|
+
await call.applyDeviceConfig();
|
|
360
361
|
if (data.watch) {
|
|
361
362
|
this.writeableStateStore.registerCall(call);
|
|
362
363
|
}
|
|
363
|
-
|
|
364
|
-
}
|
|
364
|
+
calls.push(call);
|
|
365
|
+
}
|
|
365
366
|
return {
|
|
366
367
|
...response,
|
|
367
368
|
calls: calls,
|
|
@@ -381,42 +381,49 @@ export abstract class InputMediaDeviceManager<
|
|
|
381
381
|
this.state.selectedDevice$,
|
|
382
382
|
]),
|
|
383
383
|
async ([[prevDevices, currentDevices], deviceId]) => {
|
|
384
|
-
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
if (this.statusChangePromise) {
|
|
384
|
+
try {
|
|
385
|
+
if (!deviceId) return;
|
|
388
386
|
await this.statusChangePromise;
|
|
389
|
-
}
|
|
390
387
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
currentDevice &&
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
if (isDeviceDisconnected) {
|
|
407
|
-
await this.disable();
|
|
408
|
-
this.select(undefined);
|
|
409
|
-
}
|
|
410
|
-
if (isDeviceReplaced) {
|
|
411
|
-
if (
|
|
412
|
-
this.isTrackStoppedDueToTrackEnd &&
|
|
413
|
-
this.state.status === 'disabled'
|
|
388
|
+
let isDeviceDisconnected = false;
|
|
389
|
+
let isDeviceReplaced = false;
|
|
390
|
+
const currentDevice = this.findDeviceInList(
|
|
391
|
+
currentDevices,
|
|
392
|
+
deviceId,
|
|
393
|
+
);
|
|
394
|
+
const prevDevice = this.findDeviceInList(prevDevices, deviceId);
|
|
395
|
+
if (!currentDevice && prevDevice) {
|
|
396
|
+
isDeviceDisconnected = true;
|
|
397
|
+
} else if (
|
|
398
|
+
currentDevice &&
|
|
399
|
+
prevDevice &&
|
|
400
|
+
currentDevice.deviceId === prevDevice.deviceId &&
|
|
401
|
+
currentDevice.groupId !== prevDevice.groupId
|
|
414
402
|
) {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
403
|
+
isDeviceReplaced = true;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
if (isDeviceDisconnected) {
|
|
407
|
+
await this.disable();
|
|
408
|
+
await this.select(undefined);
|
|
409
|
+
}
|
|
410
|
+
if (isDeviceReplaced) {
|
|
411
|
+
if (
|
|
412
|
+
this.isTrackStoppedDueToTrackEnd &&
|
|
413
|
+
this.state.status === 'disabled'
|
|
414
|
+
) {
|
|
415
|
+
await this.enable();
|
|
416
|
+
this.isTrackStoppedDueToTrackEnd = false;
|
|
417
|
+
} else {
|
|
418
|
+
await this.applySettingsToStream();
|
|
419
|
+
}
|
|
419
420
|
}
|
|
421
|
+
} catch (err) {
|
|
422
|
+
this.logger(
|
|
423
|
+
'warn',
|
|
424
|
+
'Unexpected error while handling disconnected or replaced device',
|
|
425
|
+
err,
|
|
426
|
+
);
|
|
420
427
|
}
|
|
421
428
|
},
|
|
422
429
|
),
|
|
@@ -41,20 +41,24 @@ export class MicrophoneManager extends InputMediaDeviceManager<MicrophoneManager
|
|
|
41
41
|
this.state.status$,
|
|
42
42
|
]),
|
|
43
43
|
async ([callingState, ownCapabilities, deviceId, status]) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
try {
|
|
45
|
+
if (callingState === CallingState.LEFT) {
|
|
46
|
+
await this.stopSpeakingWhileMutedDetection();
|
|
47
|
+
}
|
|
48
|
+
if (callingState !== CallingState.JOINED) return;
|
|
49
|
+
if (!this.speakingWhileMutedNotificationEnabled) return;
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
if (ownCapabilities.includes(OwnCapability.SEND_AUDIO)) {
|
|
52
|
+
if (status === 'disabled') {
|
|
53
|
+
await this.startSpeakingWhileMutedDetection(deviceId);
|
|
54
|
+
} else {
|
|
55
|
+
await this.stopSpeakingWhileMutedDetection();
|
|
56
|
+
}
|
|
53
57
|
} else {
|
|
54
58
|
await this.stopSpeakingWhileMutedDetection();
|
|
55
59
|
}
|
|
56
|
-
}
|
|
57
|
-
|
|
60
|
+
} catch (err) {
|
|
61
|
+
this.logger('warn', 'Could not enable speaking while muted', err);
|
|
58
62
|
}
|
|
59
63
|
},
|
|
60
64
|
),
|
package/src/devices/devices.ts
CHANGED
|
@@ -172,7 +172,7 @@ const getStream = async (constraints: MediaStreamConstraints) => {
|
|
|
172
172
|
try {
|
|
173
173
|
return await navigator.mediaDevices.getUserMedia(constraints);
|
|
174
174
|
} catch (e) {
|
|
175
|
-
getLogger(['devices'])('error', `Failed
|
|
175
|
+
getLogger(['devices'])('error', `Failed to getUserMedia`, {
|
|
176
176
|
error: e,
|
|
177
177
|
constraints: constraints,
|
|
178
178
|
});
|