@stream-io/video-client 1.8.0 → 1.8.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 +7 -0
- package/dist/index.browser.es.js +19 -5
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +19 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +19 -5
- package/dist/index.es.js.map +1 -1
- package/dist/src/helpers/RNSpeechDetector.d.ts +2 -0
- package/package.json +1 -1
- package/src/events/call.ts +2 -3
- package/src/helpers/RNSpeechDetector.ts +18 -0
|
@@ -3,6 +3,7 @@ export declare class RNSpeechDetector {
|
|
|
3
3
|
private pc1;
|
|
4
4
|
private pc2;
|
|
5
5
|
private intervalId;
|
|
6
|
+
private audioStream;
|
|
6
7
|
/**
|
|
7
8
|
* Starts the speech detection.
|
|
8
9
|
*/
|
|
@@ -15,4 +16,5 @@ export declare class RNSpeechDetector {
|
|
|
15
16
|
* Public method that detects the audio levels and returns the status.
|
|
16
17
|
*/
|
|
17
18
|
onSpeakingDetectedStateChange(onSoundDetectedStateChanged: SoundStateChangeHandler): () => void;
|
|
19
|
+
private cleanupAudioStream;
|
|
18
20
|
}
|
package/package.json
CHANGED
package/src/events/call.ts
CHANGED
|
@@ -76,9 +76,8 @@ export const watchCallEnded = (call: Call) => {
|
|
|
76
76
|
return function onCallEnded() {
|
|
77
77
|
const { callingState } = call.state;
|
|
78
78
|
if (
|
|
79
|
-
callingState
|
|
80
|
-
callingState
|
|
81
|
-
callingState === CallingState.JOINING
|
|
79
|
+
callingState !== CallingState.IDLE &&
|
|
80
|
+
callingState !== CallingState.LEFT
|
|
82
81
|
) {
|
|
83
82
|
call.leave({ reason: 'call.ended event received' }).catch((err) => {
|
|
84
83
|
call.logger('error', 'Failed to leave call after call.ended ', err);
|
|
@@ -8,15 +8,18 @@ export class RNSpeechDetector {
|
|
|
8
8
|
private pc1 = new RTCPeerConnection({});
|
|
9
9
|
private pc2 = new RTCPeerConnection({});
|
|
10
10
|
private intervalId: NodeJS.Timeout | undefined;
|
|
11
|
+
private audioStream: MediaStream | undefined;
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Starts the speech detection.
|
|
14
15
|
*/
|
|
15
16
|
public async start() {
|
|
16
17
|
try {
|
|
18
|
+
this.cleanupAudioStream();
|
|
17
19
|
const audioStream = await navigator.mediaDevices.getUserMedia({
|
|
18
20
|
audio: true,
|
|
19
21
|
});
|
|
22
|
+
this.audioStream = audioStream;
|
|
20
23
|
|
|
21
24
|
this.pc1.addEventListener('icecandidate', async (e) => {
|
|
22
25
|
await this.pc2.addIceCandidate(
|
|
@@ -55,6 +58,7 @@ export class RNSpeechDetector {
|
|
|
55
58
|
public stop() {
|
|
56
59
|
this.pc1.close();
|
|
57
60
|
this.pc2.close();
|
|
61
|
+
this.cleanupAudioStream();
|
|
58
62
|
if (this.intervalId) {
|
|
59
63
|
clearInterval(this.intervalId);
|
|
60
64
|
}
|
|
@@ -97,4 +101,18 @@ export class RNSpeechDetector {
|
|
|
97
101
|
clearInterval(this.intervalId);
|
|
98
102
|
};
|
|
99
103
|
}
|
|
104
|
+
|
|
105
|
+
private cleanupAudioStream() {
|
|
106
|
+
if (!this.audioStream) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
this.audioStream.getTracks().forEach((track) => track.stop());
|
|
110
|
+
if (
|
|
111
|
+
// @ts-expect-error release() is present in react-native-webrtc
|
|
112
|
+
typeof this.audioStream.release === 'function'
|
|
113
|
+
) {
|
|
114
|
+
// @ts-expect-error called to dispose the stream in RN
|
|
115
|
+
this.audioStream.release();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
100
118
|
}
|