From ee43fcc91fffeecafb618a6b73082d3a8a01b937 Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Mon, 13 Jun 2022 13:31:44 -0400 Subject: [PATCH] Make AEC work with spatial audio on Chrome --- package.json | 1 + src/room/InCallView.jsx | 9 +-- src/video-grid/VideoTileContainer.jsx | 2 + src/video-grid/useMediaStream.js | 93 ++++++++++++++++++++++++--- yarn.lock | 5 ++ 5 files changed, 97 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 4f0309e..9c4b8fc 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "react-router-dom": "^5.2.0", "react-use-clipboard": "^1.0.7", "react-use-measure": "^2.1.1", + "sdp-transform": "^2.14.1", "unique-names-generator": "^4.6.0" }, "devDependencies": { diff --git a/src/room/InCallView.jsx b/src/room/InCallView.jsx index de9f5bc..4a4c1cb 100644 --- a/src/room/InCallView.jsx +++ b/src/room/InCallView.jsx @@ -42,6 +42,7 @@ import { usePreventScroll } from "@react-aria/overlays"; import { useMediaHandler } from "../settings/useMediaHandler"; import { useShowInspector } from "../settings/useSetting"; import { useModalTriggerState } from "../Modal"; +import { useAudioContext } from "../video-grid/useMediaStream"; const canScreenshare = "getDisplayMedia" in navigator.mediaDevices; // There is currently a bug in Safari our our code with cloning and sending MediaStreams @@ -70,12 +71,10 @@ export function InCallView({ usePreventScroll(); const [layout, setLayout] = useVideoGridLayout(screenshareFeeds.length > 0); + const [audioContext, audioDestination, audioRef] = useAudioContext(); const { audioOutput } = useMediaHandler(); const [showInspector] = useShowInspector(); - const audioContext = useRef(); - if (!audioContext.current) audioContext.current = new AudioContext(); - const { modalState: feedbackModalState, modalProps: feedbackModalProps } = useModalTriggerState(); @@ -139,6 +138,7 @@ export function InCallView({ return (
+