@@ -12,6 +12,7 @@ import { useCallback, useState } from "react";
1212 import { ImSpinner10 } from "react-icons/im";
1313 import { IoEye } from "react-icons/io5";
1414
15+import useVirtualBackground from "@/hooks/use-agora-virtual-background";
1516 import useCamera from "@/hooks/use-camera";
1617 import useMicrophone from "@/hooks/use-microphone";
1718 import { appId, channel, HOST, OWNER, token } from "@/lib/config";
@@ -32,8 +33,18 @@ export default function AgoraHost({
3233 const [callStarted, setCallStarted] = useState(false);
3334 const [videoStarted, setVideoStarted] = useState(false);
3435 const [audioStarted, setAudioStarted] = useState(false);
35- const { localCameraTrack } = useCamera(videoStarted);
36- const { localMicrophoneTrack } = useMicrophone(audioStarted);
36+ const {
37+ localCameraTrack,
38+ availableCameras,
39+ selectedCameraId,
40+ setSelectedCameraId,
41+ } = useCamera(videoStarted);
42+ const {
43+ localMicrophoneTrack,
44+ availableMicrophones,
45+ selectedMicrophoneId,
46+ setSelectedMicrophoneId,
47+ } = useMicrophone(audioStarted);
3748 const isConnected = useIsConnected();
3849 const remoteUsers = useRemoteUsers();
3950 const otherHosts = remoteUsers.filter((u) => u.uid === HOST);
@@ -59,6 +70,10 @@ export default function AgoraHost({
5970 setVideoStarted(!videoStarted);
6071 }, [videoStarted]);
6172
73+ const { backgroundBlurred, handleBlurBackground } = useVirtualBackground({
74+ localCameraTrack,
75+ });
76+
6277 return (
6378 <div className="w-full flex flex-col justify-center items-center gap-4">
6479 <div className="flex flex-col md:flex-row gap-8 w-full justify-center items-center">
@@ -84,8 +99,16 @@ export default function AgoraHost({
8499 >
85100 <div className="p-4 bg-stone-800 rounded-2xl flex flex-col gap-4 text-left">
86101 <StreamSettings
87- audioStarted={audioStarted}
88- videoStarted={videoStarted}
102+ {...{
103+ availableCameras,
104+ selectedCameraId,
105+ setSelectedCameraId,
106+ availableMicrophones,
107+ selectedMicrophoneId,
108+ setSelectedMicrophoneId,
109+ backgroundBlurred,
110+ handleBlurBackground,
111+ }}
89112 />
90113
91114 <div className="text-center">