From 0de0d37028621be72044a3b0dbf6142942470d1c Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Thu, 7 Nov 2024 13:41:55 -0300 Subject: [PATCH 01/12] feat(voice): integrate voice activity detection for improved audio handling --- package.json | 1 + src/lib/media/Voice.ts | 62 ++++++++++++++++++++++++++---------------- vite.config.js | 2 ++ 3 files changed, 41 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index 66004040d..48f4c9c86 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,7 @@ "trystero": "^0.20.0", "uuid": "^9.0.1", "vite-plugin-node-polyfills": "^0.21.0", + "voice-activity-detection": "^0.0.5", "warp-wasm": "1.5.1" } } diff --git a/src/lib/media/Voice.ts b/src/lib/media/Voice.ts index dc7c66856..e801bbbeb 100644 --- a/src/lib/media/Voice.ts +++ b/src/lib/media/Voice.ts @@ -11,6 +11,7 @@ import type { Room } from "trystero" import { joinRoom } from "trystero" import { NoiseSuppressorWorklet_Name } from "@timephy/rnnoise-wasm" import NoiseSuppressorWorklet from "@timephy/rnnoise-wasm/NoiseSuppressorWorklet?worker&url" +import vad from "voice-activity-detection" const CALL_ACK = "CALL_ACCEPT" @@ -93,47 +94,60 @@ function handleStreamMeta(did: string, stream: MediaStream): StreamMetaHandler { analyser.smoothingTimeConstant = 0.1 const dataArray = new Uint8Array(analyser.frequencyBinCount) let noiseSuppressionNode: AudioWorkletNode - let checker: NodeJS.Timeout + let voiceStopTimeout: NodeJS.Timeout | null = null + let speaking = false + let gainNode = audioContext.createGain() + gainNode.gain.value = 1 audioContext.audioWorklet.addModule(NoiseSuppressorWorklet).then(() => { noiseSuppressionNode = new AudioWorkletNode(audioContext, NoiseSuppressorWorklet_Name) const mediaStreamSource = audioContext.createMediaStreamSource(stream) mediaStreamSource.connect(noiseSuppressionNode).connect(analyser) - - function volume() { - analyser.getByteFrequencyData(dataArray) - return dataArray.reduce((prev, value) => (prev && prev > value ? prev : value)) - } + mediaStreamSource.connect(gainNode).connect(audioContext.destination) function updateMeta(did: string) { let muted = stream.getAudioTracks().some(track => !track.enabled || track.readyState === "ended") - let speaking = false let user = Store.getUser(did) - let current = get(user) - let vol = volume() - if (!muted && vol > VOLUME_THRESHOLD) { + + user.update(u => ({ + ...u, + media: { + ...u.media, + is_muted: muted, + is_playing_audio: speaking, + }, + })) + } + const options = { + noiseCaptureDuration: 3000, + minNoiseLevel: 0.4, + maxNoiseLevel: 0.6, + onVoiceStart: () => { + gainNode.gain.value = 1 + if (voiceStopTimeout) { + clearTimeout(voiceStopTimeout) + voiceStopTimeout = null + } + log.debug("Voice detected.") speaking = true - } - if (current.media.is_muted !== muted || current.media.is_playing_audio !== speaking) { - user.update(u => ({ - ...u, - media: { - ...u.media, - is_muted: muted, - is_playing_audio: speaking, - }, - })) - } + updateMeta(did) + }, + onVoiceStop: () => { + voiceStopTimeout = setTimeout(() => { + gainNode.gain.value = 0 + log.debug("Voice not detected.") + speaking = false + updateMeta(did) + }, 500) + }, } - - checker = setInterval(() => updateMeta(did), 300) + vad(audioContext, stream, options) }) return { remove: () => { analyser.disconnect() if (noiseSuppressionNode) noiseSuppressionNode.disconnect() - if (checker) clearInterval(checker) }, } } diff --git a/vite.config.js b/vite.config.js index 7b1ac54eb..dde6302a1 100644 --- a/vite.config.js +++ b/vite.config.js @@ -39,8 +39,10 @@ export default defineConfig({ nodePolyfills(), ], optimizeDeps: { + include: ["voice-activity-detection"], exclude: ["warp-wasm"], }, + css: { preprocessorOptions: { scss: { From 222b66cf4b77be6d928cdca56131055d612bc2b3 Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Thu, 7 Nov 2024 15:01:41 -0300 Subject: [PATCH 02/12] fix(voice): remove gain node and adjust volume handling for voice detection --- src/lib/media/Voice.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/lib/media/Voice.ts b/src/lib/media/Voice.ts index e801bbbeb..5e21b2b9f 100644 --- a/src/lib/media/Voice.ts +++ b/src/lib/media/Voice.ts @@ -96,14 +96,11 @@ function handleStreamMeta(did: string, stream: MediaStream): StreamMetaHandler { let noiseSuppressionNode: AudioWorkletNode let voiceStopTimeout: NodeJS.Timeout | null = null let speaking = false - let gainNode = audioContext.createGain() - gainNode.gain.value = 1 audioContext.audioWorklet.addModule(NoiseSuppressorWorklet).then(() => { noiseSuppressionNode = new AudioWorkletNode(audioContext, NoiseSuppressorWorklet_Name) const mediaStreamSource = audioContext.createMediaStreamSource(stream) mediaStreamSource.connect(noiseSuppressionNode).connect(analyser) - mediaStreamSource.connect(gainNode).connect(audioContext.destination) function updateMeta(did: string) { let muted = stream.getAudioTracks().some(track => !track.enabled || track.readyState === "ended") @@ -123,18 +120,22 @@ function handleStreamMeta(did: string, stream: MediaStream): StreamMetaHandler { minNoiseLevel: 0.4, maxNoiseLevel: 0.6, onVoiceStart: () => { - gainNode.gain.value = 1 if (voiceStopTimeout) { clearTimeout(voiceStopTimeout) voiceStopTimeout = null } + if (VoiceRTCInstance.localVideoCurrentSrc) { + VoiceRTCInstance.localVideoCurrentSrc.volume = 1 + } log.debug("Voice detected.") speaking = true updateMeta(did) }, onVoiceStop: () => { voiceStopTimeout = setTimeout(() => { - gainNode.gain.value = 0 + if (VoiceRTCInstance.localVideoCurrentSrc) { + VoiceRTCInstance.localVideoCurrentSrc.volume = 0 + } log.debug("Voice not detected.") speaking = false updateMeta(did) @@ -724,10 +725,7 @@ export class VoiceRTC { let localStream localStream = await navigator.mediaDevices.getUserMedia({ video: true, - audio: { - echoCancellation: true, - noiseSuppression: true, - }, + audio: true, }) localStream.getVideoTracks().forEach(track => { track.enabled = this.callOptions.video.enabled From 57748d100ae3ef01b6215d05677a651a8ac3f859 Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Thu, 7 Nov 2024 15:23:27 -0300 Subject: [PATCH 03/12] fix(voice): adjust noise detection parameters for improved voice recognition --- src/lib/media/Voice.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/lib/media/Voice.ts b/src/lib/media/Voice.ts index 5e21b2b9f..67d9becc5 100644 --- a/src/lib/media/Voice.ts +++ b/src/lib/media/Voice.ts @@ -116,26 +116,24 @@ function handleStreamMeta(did: string, stream: MediaStream): StreamMetaHandler { })) } const options = { - noiseCaptureDuration: 3000, - minNoiseLevel: 0.4, - maxNoiseLevel: 0.6, + fftSize: 1024, + bufferLen: 1024, + noiseCaptureDuration: 1000, + minNoiseLevel: 0.3, + maxNoiseLevel: 0.7, + avgNoiseMultiplier: 1.2, onVoiceStart: () => { if (voiceStopTimeout) { clearTimeout(voiceStopTimeout) voiceStopTimeout = null } - if (VoiceRTCInstance.localVideoCurrentSrc) { - VoiceRTCInstance.localVideoCurrentSrc.volume = 1 - } + log.debug("Voice detected.") speaking = true updateMeta(did) }, onVoiceStop: () => { voiceStopTimeout = setTimeout(() => { - if (VoiceRTCInstance.localVideoCurrentSrc) { - VoiceRTCInstance.localVideoCurrentSrc.volume = 0 - } log.debug("Voice not detected.") speaking = false updateMeta(did) From d85c455239c62d3fc2623f13fe5dc3de7e6594f0 Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Thu, 7 Nov 2024 15:36:34 -0300 Subject: [PATCH 04/12] fix(voice): increase relay redundancy for improved connection reliability --- src/lib/media/Voice.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/media/Voice.ts b/src/lib/media/Voice.ts index 67d9becc5..c0c1ab18e 100644 --- a/src/lib/media/Voice.ts +++ b/src/lib/media/Voice.ts @@ -623,8 +623,7 @@ export class VoiceRTC { joinRoom( { appId: "uplink", - relayUrls: ["wss://nostr-pub.wellorder.net", "wss://relay.snort.social", "wss://nostr.oxtr.dev", "wss://relay.nostr.band", "wss://nostr.mom", "wss://nostr-relay.digitalmob.ro"], - relayRedundancy: 3, + relayRedundancy: 4, }, this.channel! ) From b6da242910621ee66189a16faffcb102b95c7557 Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Fri, 8 Nov 2024 13:16:00 -0300 Subject: [PATCH 05/12] feat(voice): implement relay testing for improved connection reliability --- src/lib/media/Voice.ts | 49 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/src/lib/media/Voice.ts b/src/lib/media/Voice.ts index c0c1ab18e..c2023cb45 100644 --- a/src/lib/media/Voice.ts +++ b/src/lib/media/Voice.ts @@ -5,7 +5,7 @@ import { create_cancellable_handler, type Cancellable } from "$lib/utils/Cancell import { log } from "$lib/utils/Logger" import { RaygunStoreInstance } from "$lib/wasm/RaygunStore" import Peer, { DataConnection } from "peerjs" -import { _ } from "svelte-i18n" +import { _, t } from "svelte-i18n" import { get, writable, type Writable } from "svelte/store" import type { Room } from "trystero" import { joinRoom } from "trystero" @@ -27,6 +27,20 @@ export const connectionOpened = writable(false) export const timeCallStarted: Writable = writable(null) export const callInProgress: Writable = writable(null) +const relaysToTest = [ + "wss://nostr-pub.wellorder.net", + "wss://brb.io", + "wss://relay.snort.social", + "wss://relay.damus.io", + "wss://nostr.mom", + "wss://relay.nostr.band", + "wss://nostr.oxtr.dev", + "wss://nostr.fmt.wiz.biz", + "wss://nostr-relay.digitalmob.ro", + "wss://nostr.openchain.fr", +] +const relaysAvailable: Writable = writable(relaysToTest) + export enum VoiceRTCMessageType { UpdateUser = "UPDATE_USER", None = "NONE", @@ -232,6 +246,9 @@ export class CallRoom { this.start = new Date() } }) + room.onPeerTrack((stream, peer, _meta) => { + log.debug(`Receiving track from ${peer}`) + }) room.onPeerLeave(peer => { log.debug(`Peer ${peer} left the room`) let participant = Object.entries(this.participants).find(p => p[1].remotePeerId === peer) @@ -421,6 +438,7 @@ export class VoiceRTC { } private async setupLocalPeer(reset?: boolean) { + this.testGoodRelaysForCall() if ((reset && this.localPeer) || this.localPeer?.disconnected || this.localPeer?.destroyed) { this.localPeer.destroy() this.localPeer = null @@ -616,14 +634,41 @@ export class VoiceRTC { return accepted } + private testGoodRelaysForCall() { + let remainingRelays: string[] = get(relaysAvailable) + let relaysWithSuccessfulConnection: string[] = [] + for (let i = 0; i < relaysToTest.length; i++) { + let currentRelayUrl = relaysToTest[i] + + const socket = new WebSocket(currentRelayUrl) + + socket.onerror = error => { + log.warn(`WebSocket Error for this relay ${currentRelayUrl}, error: ${error}`) + remainingRelays = remainingRelays.filter(relay => relay !== currentRelayUrl) + socket.close() + relaysAvailable.set(remainingRelays) + } + + socket.onopen = () => { + relaysWithSuccessfulConnection.push(currentRelayUrl) + socket.send("ping") + } + } + log.debug(`Relays connected: ${relaysWithSuccessfulConnection}`) + } + private createAndSetRoom() { log.debug(`Creating/Joining room in channel ${this.channel}`) + log.info("Remaining relay urls to create room: ", get(relaysAvailable)) + Store.updateMuted(true) + this.call = new CallRoom( joinRoom( { appId: "uplink", - relayRedundancy: 4, + relayUrls: get(relaysAvailable), + relayRedundancy: 2, }, this.channel! ) From a556cadc8d0936dbf3b775783e8ec5ed7b01c9f5 Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Fri, 8 Nov 2024 13:54:23 -0300 Subject: [PATCH 06/12] feat(voice): add relay connectivity testing method for improved call reliability --- src/lib/media/Voice.ts | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/lib/media/Voice.ts b/src/lib/media/Voice.ts index c2023cb45..be038dbab 100644 --- a/src/lib/media/Voice.ts +++ b/src/lib/media/Voice.ts @@ -129,6 +129,7 @@ function handleStreamMeta(did: string, stream: MediaStream): StreamMetaHandler { }, })) } + const options = { fftSize: 1024, bufferLen: 1024, @@ -138,6 +139,7 @@ function handleStreamMeta(did: string, stream: MediaStream): StreamMetaHandler { avgNoiseMultiplier: 1.2, onVoiceStart: () => { if (voiceStopTimeout) { + voiceStopTimeout.refresh() clearTimeout(voiceStopTimeout) voiceStopTimeout = null } @@ -151,7 +153,7 @@ function handleStreamMeta(did: string, stream: MediaStream): StreamMetaHandler { log.debug("Voice not detected.") speaking = false updateMeta(did) - }, 500) + }, 1000) }, } vad(audioContext, stream, options) @@ -634,6 +636,30 @@ export class VoiceRTC { return accepted } + /** + * Tests the connectivity of relay servers for initiating calls. + * + * This method iterates over a list of relay URLs specified in `relaysToTest` and attempts to establish a WebSocket + * connection with each one. It performs the following actions for each relay: + * + * - **On Successful Connection (`socket.onopen`):** + * - Adds the relay URL to the `relaysWithSuccessfulConnection` array. + * - Sends a "ping" message over the WebSocket connection. + * + * - **On Connection Error (`socket.onerror`):** + * - Logs a warning message with the relay URL and error details. + * - Removes the relay from the `remainingRelays` array. + * - Closes the WebSocket connection. + * - Updates the `relaysAvailable` store with the updated list of remaining relays. + * + * After testing all relays, it logs the list of relays with successful connections for debugging purposes. + * + * **Side Effects:** + * - Updates the `relaysAvailable` store by removing relays that failed to connect. + * - Logs warnings and debug information to assist with monitoring and troubleshooting. + * + * @private + */ private testGoodRelaysForCall() { let remainingRelays: string[] = get(relaysAvailable) let relaysWithSuccessfulConnection: string[] = [] From b52bcde96da9354f79ddf23e13303c7776cfe215 Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Fri, 8 Nov 2024 14:19:02 -0300 Subject: [PATCH 07/12] fix(voice): remove unnecessary refresh of voice stop timeout --- src/lib/media/Voice.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib/media/Voice.ts b/src/lib/media/Voice.ts index 8715da39e..34256761a 100644 --- a/src/lib/media/Voice.ts +++ b/src/lib/media/Voice.ts @@ -140,7 +140,6 @@ function handleStreamMeta(did: string, stream: MediaStream): StreamMetaHandler { avgNoiseMultiplier: 1.2, onVoiceStart: () => { if (voiceStopTimeout) { - voiceStopTimeout.refresh() clearTimeout(voiceStopTimeout) voiceStopTimeout = null } From 3cfb232d1d4ce46fd74ebb94b8c9749d12926ee9 Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Fri, 8 Nov 2024 17:13:45 -0300 Subject: [PATCH 08/12] fix(voice): enhance logging for voice detection and stop events fix(multipass): optimize user lookup in friends list --- src/lib/media/Voice.ts | 9 +++++---- src/lib/wasm/MultipassStore.ts | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/lib/media/Voice.ts b/src/lib/media/Voice.ts index 34256761a..78cdedca5 100644 --- a/src/lib/media/Voice.ts +++ b/src/lib/media/Voice.ts @@ -143,17 +143,18 @@ function handleStreamMeta(did: string, stream: MediaStream): StreamMetaHandler { clearTimeout(voiceStopTimeout) voiceStopTimeout = null } - - log.debug("Voice detected.") + let user = Store.getUser(did) + log.debug(`Voice detected from ${get(user).name}.`) speaking = true updateMeta(did) }, onVoiceStop: () => { voiceStopTimeout = setTimeout(() => { - log.debug("Voice not detected.") + let user = Store.getUser(did) + log.debug(`Voice Stopped from ${get(user).name}.`) speaking = false updateMeta(did) - }, 1000) + }, 300) }, } vad(audioContext, stream, options) diff --git a/src/lib/wasm/MultipassStore.ts b/src/lib/wasm/MultipassStore.ts index 7a05fb776..807d4d121 100644 --- a/src/lib/wasm/MultipassStore.ts +++ b/src/lib/wasm/MultipassStore.ts @@ -387,6 +387,12 @@ class MultipassStore { let friendsAny: Array = await multipass.list_friends() let friendsUsers: Array = [] for (let i = 0; i < friendsAny.length; i++) { + let userInCache = Store.getUsersLookup(friendsAny[i]) + + if (userInCache) { + continue + } + let friendUser = await this.identity_from_did(friendsAny[i]) if (friendUser) { friendsUsers.push(friendUser.key) From c7ad52f802055688a57a47bbea667d5c6c98b53e Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Fri, 8 Nov 2024 17:38:07 -0300 Subject: [PATCH 09/12] fix(voice): remove unused options and optimize voice stop timeout duration --- src/lib/media/Voice.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/lib/media/Voice.ts b/src/lib/media/Voice.ts index 78cdedca5..e650648c8 100644 --- a/src/lib/media/Voice.ts +++ b/src/lib/media/Voice.ts @@ -107,7 +107,6 @@ function handleStreamMeta(did: string, stream: MediaStream): StreamMetaHandler { const analyser = audioContext.createAnalyser() analyser.fftSize = AUDIO_WINDOW_SIZE analyser.smoothingTimeConstant = 0.1 - const dataArray = new Uint8Array(analyser.frequencyBinCount) let noiseSuppressionNode: AudioWorkletNode let voiceStopTimeout: NodeJS.Timeout | null = null let speaking = false @@ -132,12 +131,6 @@ function handleStreamMeta(did: string, stream: MediaStream): StreamMetaHandler { } const options = { - fftSize: 1024, - bufferLen: 1024, - noiseCaptureDuration: 1000, - minNoiseLevel: 0.3, - maxNoiseLevel: 0.7, - avgNoiseMultiplier: 1.2, onVoiceStart: () => { if (voiceStopTimeout) { clearTimeout(voiceStopTimeout) @@ -154,7 +147,7 @@ function handleStreamMeta(did: string, stream: MediaStream): StreamMetaHandler { log.debug(`Voice Stopped from ${get(user).name}.`) speaking = false updateMeta(did) - }, 300) + }, 200) }, } vad(audioContext, stream, options) @@ -670,7 +663,6 @@ export class VoiceRTC { const socket = new WebSocket(currentRelayUrl) socket.onerror = error => { - log.warn(`WebSocket Error for this relay ${currentRelayUrl}, error: ${error}`) remainingRelays = remainingRelays.filter(relay => relay !== currentRelayUrl) socket.close() relaysAvailable.set(remainingRelays) From 3237763281a7a950df453957303d2ebe20a42ee6 Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Fri, 8 Nov 2024 18:02:49 -0300 Subject: [PATCH 10/12] fix(voice): refactor handleStreamMeta to be async and improve voice detection handling --- src/lib/media/Voice.ts | 84 ++++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 39 deletions(-) diff --git a/src/lib/media/Voice.ts b/src/lib/media/Voice.ts index e650648c8..36ad93a50 100644 --- a/src/lib/media/Voice.ts +++ b/src/lib/media/Voice.ts @@ -102,7 +102,7 @@ export type StreamMetaHandler = { remove(): void } -function handleStreamMeta(did: string, stream: MediaStream): StreamMetaHandler { +async function handleStreamMeta(did: string, stream: MediaStream): Promise { const audioContext = new window.AudioContext() const analyser = audioContext.createAnalyser() analyser.fftSize = AUDIO_WINDOW_SIZE @@ -111,52 +111,58 @@ function handleStreamMeta(did: string, stream: MediaStream): StreamMetaHandler { let voiceStopTimeout: NodeJS.Timeout | null = null let speaking = false - audioContext.audioWorklet.addModule(NoiseSuppressorWorklet).then(() => { - noiseSuppressionNode = new AudioWorkletNode(audioContext, NoiseSuppressorWorklet_Name) - const mediaStreamSource = audioContext.createMediaStreamSource(stream) - mediaStreamSource.connect(noiseSuppressionNode).connect(analyser) + await audioContext.audioWorklet.addModule(NoiseSuppressorWorklet) - function updateMeta(did: string) { - let muted = stream.getAudioTracks().some(track => !track.enabled || track.readyState === "ended") - let user = Store.getUser(did) + noiseSuppressionNode = new AudioWorkletNode(audioContext, NoiseSuppressorWorklet_Name) + const mediaStreamSource = audioContext.createMediaStreamSource(stream) + mediaStreamSource.connect(noiseSuppressionNode).connect(analyser) - user.update(u => ({ - ...u, - media: { - ...u.media, - is_muted: muted, - is_playing_audio: speaking, - }, - })) - } + function updateMeta(did: string) { + let muted = stream.getAudioTracks().some(track => !track.enabled || track.readyState === "ended") + let user = Store.getUser(did) - const options = { - onVoiceStart: () => { - if (voiceStopTimeout) { - clearTimeout(voiceStopTimeout) - voiceStopTimeout = null - } + user.update(u => ({ + ...u, + media: { + ...u.media, + is_muted: muted, + is_playing_audio: speaking, + }, + })) + } + + const options = { + onVoiceStart: () => { + VoiceRTCInstance.localVideoCurrentSrc!.volume = 1 + if (voiceStopTimeout) { + clearTimeout(voiceStopTimeout) + voiceStopTimeout = null + } + let user = Store.getUser(did) + log.debug(`Voice detected from ${get(user).name}.`) + speaking = true + + updateMeta(did) + }, + onVoiceStop: () => { + voiceStopTimeout = setTimeout(() => { + VoiceRTCInstance.localVideoCurrentSrc!.volume = 0 let user = Store.getUser(did) - log.debug(`Voice detected from ${get(user).name}.`) - speaking = true + log.debug(`Voice Stopped from ${get(user).name}.`) + speaking = false updateMeta(did) - }, - onVoiceStop: () => { - voiceStopTimeout = setTimeout(() => { - let user = Store.getUser(did) - log.debug(`Voice Stopped from ${get(user).name}.`) - speaking = false - updateMeta(did) - }, 200) - }, - } - vad(audioContext, stream, options) - }) + }, 200) + }, + } + const voiceDetector = vad(audioContext, stream, options) + voiceDetector.connect() return { remove: () => { analyser.disconnect() if (noiseSuppressionNode) noiseSuppressionNode.disconnect() + voiceDetector.disconnect() + voiceDetector.destroy() }, } } @@ -199,7 +205,7 @@ export class Participant { if (this.streamHandler) { this.streamHandler.remove() } - this.streamHandler = handleStreamMeta(this.did, stream) + this.streamHandler = await handleStreamMeta(this.did, stream) this.stream = stream } @@ -771,7 +777,7 @@ export class VoiceRTC { if (this.localStreamHandler) { this.localStreamHandler.remove() } - this.localStreamHandler = handleStreamMeta(get(Store.state.user).key, this.localStream) + this.localStreamHandler = await handleStreamMeta(get(Store.state.user).key, this.localStream) if (this.localVideoCurrentSrc) { this.localVideoCurrentSrc.srcObject = this.localStream await this.localVideoCurrentSrc.play() From add9eaaeea1aa6e84957e1a59a64f8a5cc008e9a Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Mon, 11 Nov 2024 15:17:44 -0300 Subject: [PATCH 11/12] feat(call-screen): manage call screen visibility and update friend fetching logic --- src/lib/components/Polling.svelte | 3 ++- src/lib/components/calling/CallScreen.svelte | 6 ++++-- src/lib/media/Voice.ts | 2 ++ src/lib/wasm/MultipassStore.ts | 12 ++++-------- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/lib/components/Polling.svelte b/src/lib/components/Polling.svelte index f035d10df..3aed5d4d3 100644 --- a/src/lib/components/Polling.svelte +++ b/src/lib/components/Polling.svelte @@ -1,4 +1,5 @@