@stream-io/video-client 0.4.2 → 0.4.4
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 +52 -23
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +52 -23
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +52 -23
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
- package/src/devices/devices.ts +49 -17
- package/src/helpers/DynascaleManager.ts +9 -0
- package/src/rtc/Publisher.ts +2 -4
package/dist/index.es.js
CHANGED
|
@@ -6567,11 +6567,8 @@ class Publisher {
|
|
|
6567
6567
|
? transceiver.sender.track.stop()
|
|
6568
6568
|
: (transceiver.sender.track.enabled = false);
|
|
6569
6569
|
// We don't need to notify SFU if unpublishing in response to remote soft mute
|
|
6570
|
-
if (
|
|
6571
|
-
|
|
6572
|
-
}
|
|
6573
|
-
else {
|
|
6574
|
-
return this.notifyTrackMuteStateChanged(undefined, transceiver.sender.track, trackType, true);
|
|
6570
|
+
if (this.state.localParticipant?.publishedTracks.includes(trackType)) {
|
|
6571
|
+
await this.notifyTrackMuteStateChanged(undefined, transceiver.sender.track, trackType, true);
|
|
6575
6572
|
}
|
|
6576
6573
|
}
|
|
6577
6574
|
};
|
|
@@ -9794,6 +9791,14 @@ class DynascaleManager {
|
|
|
9794
9791
|
audioElement.play().catch((e) => {
|
|
9795
9792
|
this.logger('warn', `Failed to play stream`, e);
|
|
9796
9793
|
});
|
|
9794
|
+
// audio output device shall be set after the audio element is played
|
|
9795
|
+
// otherwise, the browser will not pick it up, and will always
|
|
9796
|
+
// play audio through the system's default device
|
|
9797
|
+
const { selectedDevice } = this.call.speaker.state;
|
|
9798
|
+
if (selectedDevice && 'setSinkId' in audioElement) {
|
|
9799
|
+
// @ts-expect-error setSinkId is not yet in the lib
|
|
9800
|
+
audioElement.setSinkId(selectedDevice);
|
|
9801
|
+
}
|
|
9797
9802
|
}
|
|
9798
9803
|
});
|
|
9799
9804
|
});
|
|
@@ -9959,22 +9964,43 @@ const CallTypes = new CallTypesRegistry([
|
|
|
9959
9964
|
}),
|
|
9960
9965
|
]);
|
|
9961
9966
|
|
|
9962
|
-
|
|
9967
|
+
/**
|
|
9968
|
+
* Returns an Observable that emits the list of available devices
|
|
9969
|
+
* that meet the given constraints.
|
|
9970
|
+
*
|
|
9971
|
+
* @param constraints the constraints to use when requesting the devices.
|
|
9972
|
+
* @param kind the kind of devices to enumerate.
|
|
9973
|
+
*/
|
|
9974
|
+
const getDevices = (constraints, kind) => {
|
|
9963
9975
|
return new Observable((subscriber) => {
|
|
9964
|
-
|
|
9965
|
-
.
|
|
9966
|
-
|
|
9967
|
-
// in
|
|
9968
|
-
//
|
|
9969
|
-
|
|
9970
|
-
|
|
9971
|
-
|
|
9972
|
-
|
|
9973
|
-
|
|
9974
|
-
|
|
9976
|
+
const enumerate = async () => {
|
|
9977
|
+
let devices = await navigator.mediaDevices.enumerateDevices();
|
|
9978
|
+
// some browsers report empty device labels (Firefox).
|
|
9979
|
+
// in that case, we need to request permissions (via getUserMedia)
|
|
9980
|
+
// to be able to get the device labels
|
|
9981
|
+
const needsGetUserMedia = devices.some((device) => device.kind === kind && device.label === '');
|
|
9982
|
+
if (needsGetUserMedia) {
|
|
9983
|
+
let mediaStream;
|
|
9984
|
+
try {
|
|
9985
|
+
mediaStream = await navigator.mediaDevices.getUserMedia(constraints);
|
|
9986
|
+
devices = await navigator.mediaDevices.enumerateDevices();
|
|
9987
|
+
}
|
|
9988
|
+
finally {
|
|
9989
|
+
if (mediaStream)
|
|
9990
|
+
disposeOfMediaStream(mediaStream);
|
|
9991
|
+
}
|
|
9992
|
+
}
|
|
9993
|
+
return devices;
|
|
9994
|
+
};
|
|
9995
|
+
enumerate()
|
|
9996
|
+
.then((devices) => {
|
|
9997
|
+
// notify subscribers and complete
|
|
9998
|
+
subscriber.next(devices);
|
|
9999
|
+
subscriber.complete();
|
|
9975
10000
|
})
|
|
9976
10001
|
.catch((error) => {
|
|
9977
|
-
getLogger(['devices'])
|
|
10002
|
+
const logger = getLogger(['devices']);
|
|
10003
|
+
logger('error', 'Failed to enumerate devices', error);
|
|
9978
10004
|
subscriber.error(error);
|
|
9979
10005
|
});
|
|
9980
10006
|
});
|
|
@@ -9988,7 +10014,7 @@ const checkIfAudioOutputChangeSupported = () => {
|
|
|
9988
10014
|
if (typeof document === 'undefined')
|
|
9989
10015
|
return false;
|
|
9990
10016
|
const element = document.createElement('audio');
|
|
9991
|
-
return
|
|
10017
|
+
return 'setSinkId' in element;
|
|
9992
10018
|
};
|
|
9993
10019
|
/**
|
|
9994
10020
|
* The default constraints used to request audio devices.
|
|
@@ -10039,10 +10065,13 @@ const getDeviceChangeObserver = memoizedObservable(() => {
|
|
|
10039
10065
|
}).pipe(debounceTime(500), concatMap(() => from(navigator.mediaDevices.enumerateDevices())), shareReplay(1));
|
|
10040
10066
|
});
|
|
10041
10067
|
const getAudioDevicesObserver = memoizedObservable(() => {
|
|
10042
|
-
return merge(getDevices(audioDeviceConstraints), getDeviceChangeObserver()).pipe(shareReplay(1));
|
|
10068
|
+
return merge(getDevices(audioDeviceConstraints, 'audioinput'), getDeviceChangeObserver()).pipe(shareReplay(1));
|
|
10069
|
+
});
|
|
10070
|
+
const getAudioOutputDevicesObserver = memoizedObservable(() => {
|
|
10071
|
+
return merge(getDevices(audioDeviceConstraints, 'audiooutput'), getDeviceChangeObserver()).pipe(shareReplay(1));
|
|
10043
10072
|
});
|
|
10044
10073
|
const getVideoDevicesObserver = memoizedObservable(() => {
|
|
10045
|
-
return merge(getDevices(videoDeviceConstraints), getDeviceChangeObserver()).pipe(shareReplay(1));
|
|
10074
|
+
return merge(getDevices(videoDeviceConstraints, 'videoinput'), getDeviceChangeObserver()).pipe(shareReplay(1));
|
|
10046
10075
|
});
|
|
10047
10076
|
/**
|
|
10048
10077
|
* Prompts the user for a permission to use audio devices (if not already granted) and lists the available 'audioinput' devices, if devices are added/removed the list is updated.
|
|
@@ -10060,7 +10089,7 @@ const getVideoDevices = () => {
|
|
|
10060
10089
|
* Prompts the user for a permission to use audio devices (if not already granted) and lists the available 'audiooutput' devices, if devices are added/removed the list is updated. Selecting 'audiooutput' device only makes sense if [the browser has support for changing audio output on 'audio' elements](#checkifaudiooutputchangesupported)
|
|
10061
10090
|
*/
|
|
10062
10091
|
const getAudioOutputDevices = () => {
|
|
10063
|
-
return
|
|
10092
|
+
return getAudioOutputDevicesObserver().pipe(map$1((values) => values.filter((d) => d.kind === 'audiooutput')));
|
|
10064
10093
|
};
|
|
10065
10094
|
const getStream = async (constraints) => {
|
|
10066
10095
|
try {
|
|
@@ -13943,7 +13972,7 @@ class StreamClient {
|
|
|
13943
13972
|
});
|
|
13944
13973
|
};
|
|
13945
13974
|
this.getUserAgent = () => {
|
|
13946
|
-
const version = "0.4.
|
|
13975
|
+
const version = "0.4.4" ;
|
|
13947
13976
|
return (this.userAgent ||
|
|
13948
13977
|
`stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
|
|
13949
13978
|
};
|