@stream-io/video-client 1.46.0 → 1.46.1
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 +8 -0
- package/dist/index.browser.es.js +43 -16
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +43 -16
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +43 -16
- package/dist/index.es.js.map +1 -1
- package/dist/src/helpers/RNSpeechDetector.d.ts +4 -2
- package/package.json +1 -1
- package/src/helpers/RNSpeechDetector.ts +52 -16
- package/src/helpers/__tests__/RNSpeechDetector.test.ts +52 -0
package/dist/index.es.js
CHANGED
|
@@ -6285,7 +6285,7 @@ const getSdkVersion = (sdk) => {
|
|
|
6285
6285
|
return sdk ? `${sdk.major}.${sdk.minor}.${sdk.patch}` : '0.0.0-development';
|
|
6286
6286
|
};
|
|
6287
6287
|
|
|
6288
|
-
const version = "1.46.
|
|
6288
|
+
const version = "1.46.1";
|
|
6289
6289
|
const [major, minor, patch] = version.split('.');
|
|
6290
6290
|
let sdkInfo = {
|
|
6291
6291
|
type: SdkType.PLAIN_JAVASCRIPT,
|
|
@@ -11928,35 +11928,43 @@ class RNSpeechDetector {
|
|
|
11928
11928
|
constructor(externalAudioStream) {
|
|
11929
11929
|
this.pc1 = new RTCPeerConnection({});
|
|
11930
11930
|
this.pc2 = new RTCPeerConnection({});
|
|
11931
|
+
this.isStopped = false;
|
|
11931
11932
|
this.externalAudioStream = externalAudioStream;
|
|
11932
11933
|
}
|
|
11933
11934
|
/**
|
|
11934
11935
|
* Starts the speech detection.
|
|
11935
11936
|
*/
|
|
11936
11937
|
async start(onSoundDetectedStateChanged) {
|
|
11938
|
+
let detachListeners;
|
|
11939
|
+
let unsubscribe;
|
|
11937
11940
|
try {
|
|
11941
|
+
this.isStopped = false;
|
|
11938
11942
|
const audioStream = this.externalAudioStream != null
|
|
11939
11943
|
? this.externalAudioStream
|
|
11940
11944
|
: await navigator.mediaDevices.getUserMedia({ audio: true });
|
|
11941
11945
|
this.audioStream = audioStream;
|
|
11942
|
-
|
|
11943
|
-
this.pc2
|
|
11944
|
-
|
|
11945
|
-
|
|
11946
|
-
|
|
11947
|
-
|
|
11948
|
-
|
|
11949
|
-
// do nothing
|
|
11950
|
-
});
|
|
11951
|
-
});
|
|
11952
|
-
this.pc2.addEventListener('track', (e) => {
|
|
11946
|
+
const onPc1IceCandidate = (e) => {
|
|
11947
|
+
this.forwardIceCandidate(this.pc2, e.candidate);
|
|
11948
|
+
};
|
|
11949
|
+
const onPc2IceCandidate = (e) => {
|
|
11950
|
+
this.forwardIceCandidate(this.pc1, e.candidate);
|
|
11951
|
+
};
|
|
11952
|
+
const onTrackPc2 = (e) => {
|
|
11953
11953
|
e.streams[0].getTracks().forEach((track) => {
|
|
11954
11954
|
// In RN, the remote track is automatically added to the audio output device
|
|
11955
11955
|
// so we need to mute it to avoid hearing the audio back
|
|
11956
11956
|
// @ts-expect-error _setVolume is a private method in react-native-webrtc
|
|
11957
11957
|
track._setVolume(0);
|
|
11958
11958
|
});
|
|
11959
|
-
}
|
|
11959
|
+
};
|
|
11960
|
+
this.pc1.addEventListener('icecandidate', onPc1IceCandidate);
|
|
11961
|
+
this.pc2.addEventListener('icecandidate', onPc2IceCandidate);
|
|
11962
|
+
this.pc2.addEventListener('track', onTrackPc2);
|
|
11963
|
+
detachListeners = () => {
|
|
11964
|
+
this.pc1.removeEventListener('icecandidate', onPc1IceCandidate);
|
|
11965
|
+
this.pc2.removeEventListener('icecandidate', onPc2IceCandidate);
|
|
11966
|
+
this.pc2.removeEventListener('track', onTrackPc2);
|
|
11967
|
+
};
|
|
11960
11968
|
audioStream
|
|
11961
11969
|
.getTracks()
|
|
11962
11970
|
.forEach((track) => this.pc1.addTrack(track, audioStream));
|
|
@@ -11966,13 +11974,17 @@ class RNSpeechDetector {
|
|
|
11966
11974
|
const answer = await this.pc2.createAnswer();
|
|
11967
11975
|
await this.pc1.setRemoteDescription(answer);
|
|
11968
11976
|
await this.pc2.setLocalDescription(answer);
|
|
11969
|
-
|
|
11977
|
+
unsubscribe = this.onSpeakingDetectedStateChange(onSoundDetectedStateChanged);
|
|
11970
11978
|
return () => {
|
|
11971
|
-
|
|
11979
|
+
detachListeners?.();
|
|
11980
|
+
unsubscribe?.();
|
|
11972
11981
|
this.stop();
|
|
11973
11982
|
};
|
|
11974
11983
|
}
|
|
11975
11984
|
catch (error) {
|
|
11985
|
+
detachListeners?.();
|
|
11986
|
+
unsubscribe?.();
|
|
11987
|
+
this.stop();
|
|
11976
11988
|
const logger = videoLoggerSystem.getLogger('RNSpeechDetector');
|
|
11977
11989
|
logger.error('error handling permissions: ', error);
|
|
11978
11990
|
return () => { };
|
|
@@ -11982,6 +11994,9 @@ class RNSpeechDetector {
|
|
|
11982
11994
|
* Stops the speech detection and releases all allocated resources.
|
|
11983
11995
|
*/
|
|
11984
11996
|
stop() {
|
|
11997
|
+
if (this.isStopped)
|
|
11998
|
+
return;
|
|
11999
|
+
this.isStopped = true;
|
|
11985
12000
|
this.pc1.close();
|
|
11986
12001
|
this.pc2.close();
|
|
11987
12002
|
if (this.externalAudioStream != null) {
|
|
@@ -12081,6 +12096,18 @@ class RNSpeechDetector {
|
|
|
12081
12096
|
this.audioStream.release();
|
|
12082
12097
|
}
|
|
12083
12098
|
}
|
|
12099
|
+
forwardIceCandidate(destination, candidate) {
|
|
12100
|
+
if (this.isStopped ||
|
|
12101
|
+
!candidate ||
|
|
12102
|
+
destination.signalingState === 'closed') {
|
|
12103
|
+
return;
|
|
12104
|
+
}
|
|
12105
|
+
destination.addIceCandidate(candidate).catch(() => {
|
|
12106
|
+
// silently ignore the error
|
|
12107
|
+
const logger = videoLoggerSystem.getLogger('RNSpeechDetector');
|
|
12108
|
+
logger.info('cannot add ice candidate - ignoring');
|
|
12109
|
+
});
|
|
12110
|
+
}
|
|
12084
12111
|
}
|
|
12085
12112
|
|
|
12086
12113
|
class MicrophoneManager extends AudioDeviceManager {
|
|
@@ -16106,7 +16133,7 @@ class StreamClient {
|
|
|
16106
16133
|
this.getUserAgent = () => {
|
|
16107
16134
|
if (!this.cachedUserAgent) {
|
|
16108
16135
|
const { clientAppIdentifier = {} } = this.options;
|
|
16109
|
-
const { sdkName = 'js', sdkVersion = "1.46.
|
|
16136
|
+
const { sdkName = 'js', sdkVersion = "1.46.1", ...extras } = clientAppIdentifier;
|
|
16110
16137
|
this.cachedUserAgent = [
|
|
16111
16138
|
`stream-video-${sdkName}-v${sdkVersion}`,
|
|
16112
16139
|
...Object.entries(extras).map(([key, value]) => `${key}=${value}`),
|